1. 15 1月, 2016 1 次提交
    • T
      ALSA: timer: Harden slave timer list handling · b5a663aa
      Takashi Iwai 提交于
      A slave timer instance might be still accessible in a racy way while
      operating the master instance as it lacks of locking.  Since the
      master operation is mostly protected with timer->lock, we should cope
      with it while changing the slave instance, too.  Also, some linked
      lists (active_list and ack_list) of slave instances aren't unlinked
      immediately at stopping or closing, and this may lead to unexpected
      accesses.
      
      This patch tries to address these issues.  It adds spin lock of
      timer->lock (either from master or slave, which is equivalent) in a
      few places.  For avoiding a deadlock, we ensure that the global
      slave_active_lock is always locked at first before each timer lock.
      
      Also, ack and active_list of slave instances are properly unlinked at
      snd_timer_stop() and snd_timer_close().
      
      Last but not least, remove the superfluous call of _snd_timer_stop()
      at removing slave links.  This is a noop, and calling it may confuse
      readers wrt locking.  Further cleanup will follow in a later patch.
      
      Actually we've got reports of use-after-free by syzkaller fuzzer, and
      this hopefully fixes these issues.
      Reported-by: NDmitry Vyukov <dvyukov@google.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      b5a663aa
  2. 14 1月, 2016 2 次提交
  3. 13 1月, 2016 3 次提交
  4. 21 12月, 2015 1 次提交
  5. 07 12月, 2015 1 次提交
  6. 04 12月, 2015 1 次提交
    • T
      ALSA: Fix compat_ioctl handling for OSS emulations · 83266b6b
      Takashi Iwai 提交于
      The ALSA PCM, mixer and sequencer OSS emulations provide the 32bit
      compatible ioctl, but they just call the 64bit native ioctl as is.
      Although this works in most cases, passing the argument value as-is
      isn't guaranteed to work on all architectures.  We need to convert it
      via compat_ptr() instead.
      
      This patch addresses the missing conversions.  Since all relevant
      ioctls in these functions take the argument as a pointer, we do the
      pointer conversion in each compat_ioctl and pass it as a 64bit value
      to the native ioctl.
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      83266b6b
  7. 30 11月, 2015 3 次提交
  8. 22 11月, 2015 1 次提交
  9. 28 10月, 2015 1 次提交
  10. 22 10月, 2015 1 次提交
  11. 16 10月, 2015 1 次提交
  12. 15 10月, 2015 1 次提交
  13. 09 10月, 2015 1 次提交
    • K
      ALSA: seq_oss: fix waitqueue_active without memory barrier in snd-seq-oss · 69447027
      Kosuke Tatsukawa 提交于
      snd_seq_oss_readq_put_event() seems to be missing a memory barrier which
      might cause the waker to not notice the waiter and miss sending a
      wake_up as in the following figure.
      
          snd_seq_oss_readq_put_event		    snd_seq_oss_readq_wait
      ------------------------------------------------------------------------
      					/* wait_event_interruptible_timeout */
      					 /* __wait_event_interruptible_timeout */
      					  /* ___wait_event */
      					  for (;;) {									 prepare_to_wait_event(&wq, &__wait,
      					    state);
      spin_lock_irqsave(&q->lock, flags);
      if (waitqueue_active(&q->midi_sleep))
      /* The CPU might reorder the test for
         the waitqueue up here, before
         prior writes complete */
      					  if ((q->qlen>0 || q->head==q->tail)
      					  ...
      					  __ret = schedule_timeout(__ret)
      if (q->qlen >= q->maxlen - 1) {
      memcpy(&q->q[q->tail], ev, sizeof(*ev));
      q->tail = (q->tail + 1) % q->maxlen;
      q->qlen++;
      ------------------------------------------------------------------------
      
      There are two other place in sound/core/seq/oss/ which have similar
      code.  The attached patch removes the call to waitqueue_active() leaving
      just wake_up() behind.  This fixes the problem because the call to
      spin_lock_irqsave() in wake_up() will be an ACQUIRE operation.
      
      I found this issue when I was looking through the linux source code
      for places calling waitqueue_active() before wake_up*(), but without
      preceding memory barriers, after sending a patch to fix a similar
      issue in drivers/tty/n_tty.c  (Details about the original issue can be
      found here: https://lkml.org/lkml/2015/9/28/849).
      Signed-off-by: NKosuke Tatsukawa <tatsu@ab.jp.nec.com>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      69447027
  14. 29 9月, 2015 1 次提交
  15. 24 9月, 2015 1 次提交
  16. 13 9月, 2015 1 次提交
    • T
      ALSA: pcm: remove structure member of 'struct snd_pcm_hwptr_log *' type... · 0052b7dc
      Takashi Sakamoto 提交于
      ALSA: pcm: remove structure member of 'struct snd_pcm_hwptr_log *' type because this structure had been removed
      
      This structure was added by 4d96eb25 ('ALSA: pcm_lib - add possibility
      to log last 10 DMA ring buffer positions') to store PCM pointers
      information of latest 10 pointer movements (=XRUN_LOG_CNT). When
      CONFIG_SND_PCM_XRUN_DEBUG is configured, 'struct snd_pcm_runtime' has
      'hwptr_log' member with a pointer to the structure. When calling
      xrun_log() in pcm_lib.c, the structure was allocated to the pointer.
      When calling snd_pcm_detach_substream() in pcm.c, the allocated pointer
      is released.
      
      In f5914908 ('ALSA: pcm: Replace PCM hwptr tracking with tracepoints'),
      the pointer logging is replaced with using Linux Kernel Tracepoints. The
      structure was also removed, while it's just declared. The member and kfree
      still remains.
      
      This commit removes the member and related codes. I think this was
      overlooked because it brings no errors/warnings to C compilers.
      
      Fixes: f5914908 ('ALSA: pcm: Replace PCM hwptr tracking with tracepoints')
      Signed-off-by: NTakashi Sakamoto <o-takashi@sakamocchi.jp>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      0052b7dc
  17. 17 7月, 2015 1 次提交
    • T
      ALSA: pcm: Fix lockdep warning with nonatomic PCM ops · 67756e31
      Takashi Iwai 提交于
      With the nonatomic PCM ops, the system may spew lockdep warnings like:
      
       =============================================
       [ INFO: possible recursive locking detected ]
       4.2.0-rc1-jeejaval3 #12 Not tainted
       ---------------------------------------------
       aplay/4029 is trying to acquire lock:
        (snd_pcm_link_rwsem){.+.+.+}, at: [<ffffffff816fd473>] snd_pcm_stream_lock+0x43/0x60
      
       but task is already holding lock:
        (snd_pcm_link_rwsem){.+.+.+}, at: [<ffffffff816fcf29>] snd_pcm_action_nonatomic+0x29/0x80
      
       other info that might help us debug this:
        Possible unsafe locking scenario:
      
              CPU0
              ----
         lock(snd_pcm_link_rwsem);
         lock(snd_pcm_link_rwsem);
      
      Although this is false-positive as the rwsem is taken always as
      read-only for these code paths, it's certainly annoying to see this at
      any occasion.  A simple fix is to use down_read_nested() in
      snd_pcm_stream_lock() that can be called inside another lock.
      Reported-by: NVinod Koul <vinod.koul@intel.com>
      Reported-by: NJeeja Kp <jeeja.kp@intel.com>
      Tested-by: NJeeja Kp <jeeja.kp@intel.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      67756e31
  18. 01 7月, 2015 1 次提交
    • V
      genalloc: rename of_get_named_gen_pool() to of_gen_pool_get() · abdd4a70
      Vladimir Zapolskiy 提交于
      To be consistent with other kernel interface namings, rename
      of_get_named_gen_pool() to of_gen_pool_get().  In the original function
      name "_named" suffix references to a device tree property, which contains
      a phandle to a device and the corresponding device driver is assumed to
      register a gen_pool object.
      
      Due to a weak relation and to avoid any confusion (e.g.  in future
      possible scenario if gen_pool objects are named) the suffix is removed.
      
      [sfr@canb.auug.org.au: crypto/marvell/cesa - fix up for of_get_named_gen_pool() rename]
      Signed-off-by: NVladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
      Cc: Nicolas Ferre <nicolas.ferre@atmel.com>
      Cc: Philipp Zabel <p.zabel@pengutronix.de>
      Cc: Shawn Guo <shawn.guo@linaro.org>
      Cc: Sascha Hauer <kernel@pengutronix.de>
      Cc: Alexandre Belloni <alexandre.belloni@free-electrons.com>
      Cc: Russell King <linux@arm.linux.org.uk>
      Cc: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
      Cc: Vinod Koul <vinod.koul@intel.com>
      Cc: Takashi Iwai <tiwai@suse.de>
      Cc: Jaroslav Kysela <perex@perex.cz>
      Signed-off-by: NStephen Rothwell <sfr@canb.auug.org.au>
      Cc: Herbert Xu <herbert@gondor.apana.org.au>
      Cc: Boris BREZILLON <boris.brezillon@free-electrons.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      abdd4a70
  19. 30 6月, 2015 1 次提交
    • C
      ALSA: Fix uninintialized error return · 0755e74b
      Colin Ian King 提交于
      Static analysis with cppcheck found the following error:
        [sound/core/init.c:118]: (error) Uninitialized variable: err
      
      ..this was introduced by commit 2471b6c8
      ("ALSA: info: Register proc entries recursively, too") where the call
      to snd_info_card_register was removed and no longer setting the error
      return in err.  When snd_info_create_card_entry fails to allocate a
      an entry, the error path exits with garbage in err.  Fix is to return
      -ENOMEM if entry fails to be allocated.
      
      Fixes: 2471b6c8 ("ALSA: info: Register proc entries recursively, too")
      Signed-off-by: NColin Ian King <colin.king@canonical.com>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      0755e74b
  20. 26 6月, 2015 1 次提交
  21. 23 6月, 2015 1 次提交
    • T
      ALSA: pcm: Fix pcm_class sysfs output · 60b93030
      Takashi Iwai 提交于
      The pcm_class sysfs of each PCM substream gives only "none" since the
      recent code change to embed the struct device.  Fix the code to point
      directly to the embedded device object properly.
      
      Fixes: ef46c7af ('ALSA: pcm: Embed struct device')
      Cc: <stable@vger.kernel.org> # v4.0+
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      60b93030
  22. 29 5月, 2015 2 次提交
  23. 28 5月, 2015 2 次提交
  24. 22 5月, 2015 2 次提交
  25. 21 5月, 2015 1 次提交
  26. 19 5月, 2015 1 次提交
    • K
      ALSA: pcm: Modify double acknowledged interrupts check condition · 13a98839
      Koro Chen 提交于
      Currently in snd_pcm_update_hw_ptr0 during interrupt,
      we consider there were double acknowledged interrupts when:
      1. HW reported pointer is smaller than expected, and
      2. Time from last update time (hdelta) is over half a buffer time.
      
      However, when HW reported pointer is only a few bytes smaller than
      expected, and when hdelta is just a little larger than half a buffer time
      (e.g. ping-pong buffer), it wrongly treats this IRQ as double acknowledged.
      
      The condition #2 uses jiffies, but jiffies is not high resolution
      since it is integer. We should consider jiffies inaccuracy.
      Signed-off-by: NKoro Chen <koro.chen@mediatek.com>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      13a98839
  27. 18 5月, 2015 4 次提交
  28. 30 4月, 2015 2 次提交