1. 21 7月, 2014 1 次提交
    • T
      ALSA: pcm: Introduce protocol version field to sw_params · 58900810
      Takashi Iwai 提交于
      For controlling the new fields more strictly, add sw_params.proto
      field indicating the protocol version of the user-space.  User-space
      should fill the SNDRV_PCM_VERSION value it's built with, then kernel
      can know whether the new fields should be evaluated or not.
      
      And now tstamp_type field is evaluated only when the valid value is
      set there.  This avoids the wrong override of tstamp_type to zero,
      which is SNDRV_PCM_TSTAMP_TYPE_GETTIMEOFDAY.
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      58900810
  2. 10 7月, 2014 2 次提交
  3. 18 6月, 2014 5 次提交
    • L
      ALSA: control: Make sure that id->index does not overflow · 883a1d49
      Lars-Peter Clausen 提交于
      The ALSA control code expects that the range of assigned indices to a control is
      continuous and does not overflow. Currently there are no checks to enforce this.
      If a control with a overflowing index range is created that control becomes
      effectively inaccessible and unremovable since snd_ctl_find_id() will not be
      able to find it. This patch adds a check that makes sure that controls with a
      overflowing index range can not be created.
      Signed-off-by: NLars-Peter Clausen <lars@metafoo.de>
      Acked-by: NJaroslav Kysela <perex@perex.cz>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      883a1d49
    • L
      ALSA: control: Handle numid overflow · ac902c11
      Lars-Peter Clausen 提交于
      Each control gets automatically assigned its numids when the control is created.
      The allocation is done by incrementing the numid by the amount of allocated
      numids per allocation. This means that excessive creation and destruction of
      controls (e.g. via SNDRV_CTL_IOCTL_ELEM_ADD/REMOVE) can cause the id to
      eventually overflow. Currently when this happens for the control that caused the
      overflow kctl->id.numid + kctl->count will also over flow causing it to be
      smaller than kctl->id.numid. Most of the code assumes that this is something
      that can not happen, so we need to make sure that it won't happen
      Signed-off-by: NLars-Peter Clausen <lars@metafoo.de>
      Acked-by: NJaroslav Kysela <perex@perex.cz>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      ac902c11
    • L
      ALSA: control: Don't access controls outside of protected regions · fd9f26e4
      Lars-Peter Clausen 提交于
      A control that is visible on the card->controls list can be freed at any time.
      This means we must not access any of its memory while not holding the
      controls_rw_lock. Otherwise we risk a use after free access.
      Signed-off-by: NLars-Peter Clausen <lars@metafoo.de>
      Acked-by: NJaroslav Kysela <perex@perex.cz>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      fd9f26e4
    • L
      ALSA: control: Fix replacing user controls · 82262a46
      Lars-Peter Clausen 提交于
      There are two issues with the current implementation for replacing user
      controls. The first is that the code does not check if the control is actually a
      user control and neither does it check if the control is owned by the process
      that tries to remove it. That allows userspace applications to remove arbitrary
      controls, which can cause a user after free if a for example a driver does not
      expect a control to be removed from under its feed.
      
      The second issue is that on one hand when a control is replaced the
      user_ctl_count limit is not checked and on the other hand the user_ctl_count is
      increased (even though the number of user controls does not change). This allows
      userspace, once the user_ctl_count limit as been reached, to repeatedly replace
      a control until user_ctl_count overflows. Once that happens new controls can be
      added effectively bypassing the user_ctl_count limit.
      
      Both issues can be fixed by instead of open-coding the removal of the control
      that is to be replaced to use snd_ctl_remove_user_ctl(). This function does
      proper permission checks as well as decrements user_ctl_count after the control
      has been removed.
      
      Note that by using snd_ctl_remove_user_ctl() the check which returns -EBUSY at
      beginning of the function if the control already exists is removed. This is not
      a problem though since the check is quite useless, because the lock that is
      protecting the control list is released between the check and before adding the
      new control to the list, which means that it is possible that a different
      control with the same settings is added to the list after the check. Luckily
      there is another check that is done while holding the lock in snd_ctl_add(), so
      we'll rely on that to make sure that the same control is not added twice.
      Signed-off-by: NLars-Peter Clausen <lars@metafoo.de>
      Acked-by: NJaroslav Kysela <perex@perex.cz>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      82262a46
    • L
      ALSA: control: Protect user controls against concurrent access · 07f4d9d7
      Lars-Peter Clausen 提交于
      The user-control put and get handlers as well as the tlv do not protect against
      concurrent access from multiple threads. Since the state of the control is not
      updated atomically it is possible that either two write operations or a write
      and a read operation race against each other. Both can lead to arbitrary memory
      disclosure. This patch introduces a new lock that protects user-controls from
      concurrent access. Since applications typically access controls sequentially
      than in parallel a single lock per card should be fine.
      Signed-off-by: NLars-Peter Clausen <lars@metafoo.de>
      Acked-by: NJaroslav Kysela <perex@perex.cz>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      07f4d9d7
  4. 12 6月, 2014 1 次提交
  5. 04 6月, 2014 2 次提交
    • A
      ALSA: seq: Continue broadcasting events to ports if one of them fails · 27423257
      Adam Goode 提交于
      Sometimes PORT_EXIT messages are lost when a process is exiting.
      This happens if you subscribe to the announce port with client A,
      then subscribe to the announce port with client B, then kill client A.
      Client B will not see the PORT_EXIT message because client A's port is
      closing and is earlier in the announce port subscription list. The
      for each loop will try to send the announcement to client A and fail,
      then will stop trying to broadcast to other ports. Killing B works fine
      since the announcement will already have gone to A. The CLIENT_EXIT
      message does not get lost.
      
      How to reproduce problem:
      
      *** termA
      $ aseqdump -p 0:1
        0:1   Port subscribed            0:1 -> 128:0
      
      *** termB
      $ aseqdump -p 0:1
      
      *** termA
        0:1   Client start               client 129
        0:1   Port start                 129:0
        0:1   Port subscribed            0:1 -> 129:0
      
      *** termB
        0:1   Port subscribed            0:1 -> 129:0
      
      *** termA
      ^C
      
      *** termB
        0:1   Client exit                client 128
         <--- expected Port exit as well (before client exit)
      Signed-off-by: NAdam Goode <agoode@google.com>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      27423257
    • A
      ALSA: seq: correctly detect input buffer overflow · 21fd3e95
      Adam Goode 提交于
      snd_seq_event_dup returns -ENOMEM in some buffer-full conditions,
      but usually returns -EAGAIN. Make -EAGAIN trigger the overflow
      condition in snd_seq_fifo_event_in so that the fifo is cleared
      and -ENOSPC is returned to userspace as stated in the alsa-lib docs.
      Signed-off-by: NAdam Goode <agoode@google.com>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      21fd3e95
  6. 19 5月, 2014 1 次提交
  7. 28 4月, 2014 1 次提交
  8. 16 4月, 2014 1 次提交
  9. 19 3月, 2014 1 次提交
  10. 27 2月, 2014 1 次提交
  11. 25 2月, 2014 5 次提交
    • T
      ALSA: Clean up snd_device_*() codes · 72620d60
      Takashi Iwai 提交于
      A few code cleanups and optimizations.  In addition, drop
      snd_device_disconnect() that isn't used at all, and drop the return
      values from snd_device_free*().
      
      Another slight difference by this change is that now the device state
      will become always SNDRV_DEV_REGISTERED no matter whether dev_register
      ops is present or not.  It's for better consistency.  There should be
      no impact for the current tree, as the state isn't checked.
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      72620d60
    • T
      ALSA: Use priority list for managing device list · 289ca025
      Takashi Iwai 提交于
      Basically, the device type specifies the priority of the device to be
      registered / freed, too.  However, the priority value isn't well
      utilized but only it's checked as a group.  This results in
      inconsistent register and free order (where each of them should be in
      reversed direction).
      
      This patch simplifies the device list management code by simply
      inserting a list entry at creation time in an incremental order for
      the priority value.  Since we can just follow the link for register,
      disconnect and free calls, we don't have to specify the group; so the
      whole enum definitions are also simplified as well.
      
      The visible change to outside is that the priorities of some object
      types are revisited.  For example, now the SNDRV_DEV_LOWLEVEL object
      is registered before others (control, PCM, etc) and, in return,
      released after others.  Similarly, SNDRV_DEV_CODEC is in a lower
      priority than SNDRV_DEV_BUS for ensuring the dependency.
      
      Also, the unused SNDRV_DEV_TOPLEVEL, SNDRV_DEV_LOWLEVEL_PRE and
      SNDRV_DEV_LOWLEVEL_NORMAL are removed as a cleanup.
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      289ca025
    • T
      ALSA: hwdep: Allow to assign the given parent · 71e2e1c1
      Takashi Iwai 提交于
      Just like PCM, allow hwdep to be assigned to a different parent device
      than the card.  It'll be used for the HD-audio codec device in the
      later patches.
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      71e2e1c1
    • T
      ALSA: hwdep: Take private_data as drvdata for sysfs · f806bdb2
      Takashi Iwai 提交于
      For referring to a different object from sysfs ops, take hwdep
      private_data as stored via dev_set_drvdata() at creating the device
      object.  In that way, the same sysfs ops can be used by different
      device types.
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      f806bdb2
    • T
      ALSA: Create sysfs attribute files via groups · caa751ba
      Takashi Iwai 提交于
      Instead of calling each time device_create_file(), create the groups
      of sysfs attribute files at once in a normal way.  Add a new helper
      function, snd_get_device(), to return the associated device object,
      so that we can handle the sysfs addition locally.
      
      Since the sysfs file addition is done differently now,
      snd_add_device_sysfs_file() helper function is removed.
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      caa751ba
  12. 20 2月, 2014 1 次提交
  13. 19 2月, 2014 1 次提交
    • T
      ALSA: core: Fix missing card sysfs contents · b203dbab
      Takashi Iwai 提交于
      While moving the card device into struct snd_card, the reference to
      the assigned card in sysfs show/store callbacks were forgotten to be
      refreshed, still accessing to the no longer used drvdata.  Fix these
      places to refer correctly via container_of().
      
      Also, remove the superfluous NULL checks since it's guaranteed to be
      non-NULL now.
      
      Fixes: 8bfb181c ('ALSA: Embed card device into struct snd_card')
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      b203dbab
  14. 14 2月, 2014 14 次提交
  15. 12 2月, 2014 2 次提交
    • T
      ALSA: Mandate to pass a device pointer at card creation time · 393aa9c1
      Takashi Iwai 提交于
      This is a part of preliminary works for modernizing the ALSA device
      structure.  So far, we set card->dev at later point after the object
      creation.  Because of this, the core layer doesn't always know which
      device is being handled before it's actually registered, and it makes
      impossible to show the device in error messages, for example.  The
      first goal is to achieve a proper struct device initialization at the
      very beginning of probing.
      
      As a first step, this patch introduces snd_card_new() function (yes
      there was the same named function in the very past), in order to
      receive the parent device pointer from the very beginning.
      snd_card_create() is marked as deprecated.
      
      At this point, there is no functional change other than that.  The
      actual change of the device creation scheme will follow later.
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      393aa9c1
    • T
      ALSA: Drop unused name argument in snd_register_oss_device() · 80d7d771
      Takashi Iwai 提交于
      The last argument, name, of snd_oss_register_device() is nowhere
      referred in the function in the current code.  Let's drop it.
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      80d7d771
  16. 10 2月, 2014 1 次提交
    • T
      ALSA: Replace with IS_ENABLED() · 8eeaa2f9
      Takashi Iwai 提交于
      Replace the lengthy #if defined(XXX) || defined(XXX_MODULE) with the
      new IS_ENABLED() macro.
      
      The patch still doesn't cover all ifdefs.  For example, the dependency
      on CONFIG_GAMEPORT is still open-coded because this also has an extra
      dependency on MODULE.  Similarly, an open-coded ifdef in pcm_oss.c and
      some sequencer-related stuff are left untouched.
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      8eeaa2f9