1. 12 Apr, 2019 3 commits
    • Takashi Iwai's avatar
      ALSA: seq: Protect racy pool manipulation from OSS sequencer · 6b580f52
      Takashi Iwai authored
      OSS sequencer emulation still allows to queue and issue the events
      that manipulate the client pool concurrently in a racy way.  This
      patch serializes the access like the normal sequencer write / ioctl
      via taking the client ioctl_mutex.  Since the access to the sequencer
      client is done indirectly via a client id number, a new helper to
      take/release the mutex is introduced.
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      6b580f52
    • Takashi Iwai's avatar
      ALSA: seq: Simplify snd_seq_kernel_client_enqueue() helper · 6740ea67
      Takashi Iwai authored
      We have two helpers for queuing a sequencer event from the kernel
      client, and both are used only from OSS sequencer layer without any
      hop and atomic set.  Let's simplify and unify two helpers into one.
      
      No functional change, just a call pattern change.
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      6740ea67
    • Takashi Iwai's avatar
      ALSA: seq: Cover unsubscribe_port() in list_mutex · 7c32ae35
      Takashi Iwai authored
      The call of unsubscribe_port() which manages the group count and
      module refcount from delete_and_unsubscribe_port() looks racy; it's
      not covered by the group list lock, and it's likely a cause of the
      reported unbalance at port deletion.  Let's move the call inside the
      group list_mutex to plug the hole.
      
      Reported-by: syzbot+e4c8abb920efa77bace9@syzkaller.appspotmail.com
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      7c32ae35
  2. 11 Apr, 2019 1 commit
  3. 10 Apr, 2019 2 commits
  4. 09 Apr, 2019 6 commits
    • Takashi Iwai's avatar
      ALSA: seq: Fix race of get-subscription call vs port-delete ioctls · 2eabc5ec
      Takashi Iwai authored
      The snd_seq_ioctl_get_subscription() retrieves the port subscriber
      information as a pointer, while the object isn't protected, hence it
      may be deleted before the actual reference.  This race was spotted by
      syzkaller and may lead to a UAF.
      
      The fix is simply copying the data in the lookup function that
      performs in the rwsem to protect against the deletion.
      
      Reported-by: syzbot+9437020c82413d00222d@syzkaller.appspotmail.com
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      2eabc5ec
    • Takashi Iwai's avatar
      ALSA: seq: Protect in-kernel ioctl calls with mutex · feb68902
      Takashi Iwai authored
      ALSA OSS sequencer calls the ioctl function indirectly via
      snd_seq_kernel_client_ctl().  While we already applied the protection
      against races between the normal ioctls and writes via the client's
      ioctl_mutex, this code path was left untouched.  And this seems to be
      the cause of still remaining some rare UAF as spontaneously triggered
      by syzkaller.
      
      For the sake of robustness, wrap the ioctl_mutex also for the call via
      snd_seq_kernel_client_ctl(), too.
      
      Reported-by: syzbot+e4c8abb920efa77bace9@syzkaller.appspotmail.com
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      feb68902
    • Takashi Iwai's avatar
      ALSA: seq: Remove superfluous irqsave flags · f823b8a7
      Takashi Iwai authored
      spin_lock_irqsave() is used unnecessarily in various places in
      sequencer core code although it's pretty obvious that the context is
      sleepable.  Remove irqsave and use the plain spin_lock_irq() in such
      places for simplicity.
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      f823b8a7
    • Takashi Iwai's avatar
      ALSA: seq: Align temporary re-locking with irqsave version · 4b24b960
      Takashi Iwai authored
      In a few places in sequencer core, we temporarily unlock / re-lock the
      pool spin lock while waiting for the allocation in the blocking mode.
      There spin_unlock_irq() / spin_lock_irq() pairs are called while
      initially spin_lock_irqsave() is used (and spin_lock_irqrestore() at
      the end of the function again).  This is likely OK for now, but it's a
      bit confusing and error-prone.
      
      This patch replaces these temporary relocking lines with the irqsave
      variant to make the lock/unlock sequence more consistently.
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      4b24b960
    • Takashi Iwai's avatar
      ALSA: seq: Use kvmalloc() for cell pools · fd7ae83d
      Takashi Iwai authored
      Use kvmalloc() for allocating cell pools since the pool size can be
      relatively small that may be covered better by slab.
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      fd7ae83d
    • Takashi Iwai's avatar
      ALSA: timer: Revert active callback sync check at close · df55531b
      Takashi Iwai authored
      This is essentially a revert of the commit a7588c89 ("ALSA: timer:
      Check ack_list emptiness instead of bit flag").  The intended change
      by the commit turns out to be insufficient, as snd_timer_close*()
      always calls snd_timer_stop() that deletes the ack_list beforehand.
      
      In theory, we can change the behavior of snd_timer_stop() to sync the
      pending ack_list, but this will become a deadlock for the callback
      like sequencer that calls again snd_timer_stop() from itself.  So,
      reverting the change is a more straightforward solution.
      
      Fixes: a7588c89 ("ALSA: timer: Check ack_list emptiness instead of bit flag")
      Reported-by: syzbot+58813d77154713f4de15@syzkaller.appspotmail.com
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      df55531b
  5. 03 Apr, 2019 1 commit
  6. 28 Mar, 2019 1 commit
  7. 27 Mar, 2019 6 commits
    • Takashi Iwai's avatar
      ALSA: us122l: Use alloc_pages_exact() · 36b8defc
      Takashi Iwai authored
      alloc_pages_exact() is more suitable choice for allocating the sound
      buffers, as it doesn't need to align with power-of-two.  Along with
      the conversion, we can drop __GFP_COMP as well.
      
      The patch also replace the error messages to be more explicit.
      Acked-by: default avatarMichal Hocko <mhocko@suse.com>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      36b8defc
    • Takashi Iwai's avatar
      ALSA: Replace snd_malloc_pages() and snd_free_pages() with standard helpers, take#2 · 734b5a0b
      Takashi Iwai authored
      snd_malloc_pages() and snd_free_pages() are merely thin wrappers of
      the standard page allocator / free functions.  Even the arguments are
      compatible with some standard helpers, so there is little merit of
      keeping these wrappers.
      
      This patch replaces the all existing callers of snd_malloc_pages() and
      snd_free_pages() with the direct calls of the standard helper
      functions.  In this version, we use a recently introduced one,
      alloc_pages_exact(), which suits better than the old
      snd_malloc_pages() implementation for our purposes.  Then we can avoid
      the waste of pages by alignment to power-of-two.
      
      Since alloc_pages_exact() does split pages, we need no longer
      __GFP_COMP flag; or better to say, we must not pass __GFP_COMP to
      alloc_pages_exact().  So the former unconditional addition of
      __GFP_COMP flag in snd_malloc_pages() is dropped, as well as in most
      other places.
      Reviewed-by: default avatarTakashi Sakamoto <o-takashi@sakamocchi.jp>
      Acked-by: default avatarMichal Hocko <mhocko@suse.com>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      734b5a0b
    • Takashi Iwai's avatar
      ALSA: timer: Make snd_timer_close() really kill pending actions · fe1b26c9
      Takashi Iwai authored
      snd_timer_close() is supposed to close the timer instance and sync
      with the deactivation of pending actions.  However, there are still
      some overlooked cases:
      
      - It calls snd_timer_stop() at the beginning, but some other might
        re-trigger the timer right after that.
      
      - snd_timer_stop() calls del_timer_sync() only when all belonging
        instances are closed.  If multiple instances were assigned to a
        timer object and one is closed, the timer is still running.  Then
        the pending action assigned to this timer might be left.
      
      Actually either of the above is the likely cause of the reported
      syzkaller UAF.
      
      This patch plug these holes by introducing SNDRV_TIMER_IFLG_DEAD
      flag.  This is set at the beginning of snd_timer_close(), and the flag
      is checked at snd_timer_start*() and else, so that no longer new
      action is left after snd_timer_close().
      
      Reported-by: syzbot+d5136d4d3240cbe45a2a@syzkaller.appspotmail.com
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      fe1b26c9
    • Takashi Iwai's avatar
      ALSA: timer: Check ack_list emptiness instead of bit flag · a7588c89
      Takashi Iwai authored
      For checking the pending timer instance that is still left on the
      timer object that is being closed, we set/clear a bit flag
      SNDRV_TIMER_IFLG_CALLBACK around the call of callbacks.  This can be
      simplified by replace with the list_empty() call for ti->ack_list.
      This covers the existence more comprehensively and safely.
      
      A gratis bonus is that we can get rid of SNDRV_TIMER_IFLG_CALLBACK bit
      flag definition as well.
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      a7588c89
    • Takashi Iwai's avatar
      ALSA: timer: Make sure to clear pending ack list · 7bb4a8a2
      Takashi Iwai authored
      When a card is under disconnection, we bail out immediately at each
      timer interrupt or tasklet.  This might leave some items left in ack
      list.  For a better integration of the upcoming change to check
      ack_list emptiness, clear out the whole list upon the emergency exit
      route.
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      7bb4a8a2
    • Takashi Iwai's avatar
      ALSA: timer: Unify timer callback process code · 8748b850
      Takashi Iwai authored
      The timer core has two almost identical code for processing callbacks:
      once in snd_timer_interrupt() for fast callbacks and another in
      snd_timer_tasklet() for delayed callbacks.  Let's unify them.
      
      In the new version, the resolution is read from ti->resolution at each
      call, and this must be fine; ti->resolution is set in the preparation
      step in snd_timer_interrupt().
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      8748b850
  8. 26 Mar, 2019 1 commit
    • Takashi Iwai's avatar
      ALSA: emux: Add support of loading GUS-patch · e42dd3ee
      Takashi Iwai authored
      It's a feature request for the ancient sutff, but it's still valid;
      the loading of a GUS-patch isn't available via hwdep device although
      it's supported over OSS sequencer.  The only missing piece is the call
      of snd_soundfont_load_guspatch() in synth emux hwdep code.
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      e42dd3ee
  9. 25 Mar, 2019 1 commit
  10. 18 Mar, 2019 5 commits
    • Takashi Sakamoto's avatar
      ALSA: firewire-lib: use 8 byte header for IR context to get isochronous cycle · cc4f8e91
      Takashi Sakamoto authored
      In kernel API of Linux FireWire subsystem, handlers of isochronous
      receive (IR) context can get context headers as an argument of
      callback. When 4 byte header is used, the context header includes
      isochronous packet header for each packet. When 8 byte header is
      used, it includes isochronous cycle as well.
      
      ALSA IEC 61883-1/6 engine uses 4 byte header, and computes isochronous
      cycle from the cycle of interrupt. The usage of 8 byte header can
      obsolete the computation.
      
      Furthermore, this change works well for a case that a series of
      packet in one interrupt includes skipped isochronous cycle,
      
      This commit uses 8 byte header to handle isochronous cycle.
      Signed-off-by: default avatarTakashi Sakamoto <o-takashi@sakamocchi.jp>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      cc4f8e91
    • Takashi Sakamoto's avatar
      ALSA: firewire-motu: add support MOTU 8pre FireWire · 35033d8c
      Takashi Sakamoto authored
      This commit adds support for MOTU 8pre FireWire, which was shipped 2007
      and nowadays already discontinued. Userspace applications can transmit
      and receive PCM frames and MIDI messages for this model via ALSA PCM
      interface and RawMidi/Sequencer interfaces.
      
      Like the other models of MOTU FireWire series, this model has many
      quirks in its CIP.
      
      At first, data channels for two pairs of optical interfaces. At lower
      sampling transmission frequency, i.e. 44.1 and 48.0 kHz, one pair is
      available for ADAT data, thus 8 data chunks are transferred by CIP.
      At middle sampling transmission frequency, i.e.  88.2 and 96.0 kHz,
      two pairs are available to keep 8 chunks for ADAT data, thus CIP
      still includes 8 data chunks.
      
      Apart from data chunks for optical interface, CIP includes fixed number
      of data chunks. In tx stream, two chunks for status message, eight
      chunks for samples from analog 1-8 input, two chunks for mix-return.
      In rx stream, two chunks for control message, two chunks for main 1-2
      output, two chunks for phone 1-2 output, two chunks for dummy 1-2.
      
      CIP header in tx stream includes quirks for its dbs and dbc fields.
      The value of dbs field is fixed to 0x13, against its actual size.
      The value of dbc field is firstly updated to 0x07 from zero, then
      it's incremented continuously according to actual number of data h
      blocks.
      
      Finally, the model has own bits to disable frame fetch.
      
      This commit uses several options to absorb the above quirks.
      
      $ python2 crpp < /sys/bus/firewire/devices/fw1/config_rom
                     ROM header and bus information block
                     -----------------------------------------------------------------
      400  0410b57d  bus_info_length 4, crc_length 16, crc 46461
      404  31333934  bus_name "1394"
      408  20001000  irmc 0, cmc 0, isc 1, bmc 0, cyc_clk_acc 0, max_rec 1 (4)
      40c  0001f200  company_id 0001f2     |
      410  00083dfb  device_id 0000083dfb  | EUI-64 0001f20000083dfb
      
                     root directory
                     -----------------------------------------------------------------
      414  0004c65c  directory_length 4, crc 50780
      418  030001f2  vendor
      41c  0c0083c0  node capabilities per IEEE 1394
      420  8d000006  --> eui-64 leaf at 438
      424  d1000001  --> unit directory at 428
      
                     unit directory at 428
                     -----------------------------------------------------------------
      428  0003991c  directory_length 3, crc 39196
      42c  120001f2  specifier id
      430  1300000f  version
      434  17103800  model
      
                     eui-64 leaf at 438
                     -----------------------------------------------------------------
      438  00022681  leaf_length 2, crc 9857
      43c  0001f200  company_id 0001f2     |
      440  00083dfb  device_id 0000083dfb  | EUI-64 0001f20000083dfb
      Signed-off-by: default avatarTakashi Sakamoto <o-takashi@sakamocchi.jp>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      35033d8c
    • Takashi Iwai's avatar
      Merge branch 'for-linus' into for-next · b3f5c0f3
      Takashi Iwai authored
      Back-merge the current devel branch for further development.
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      b3f5c0f3
    • Colin Ian King's avatar
      ALSA: opl3: fix mismatch between snd_opl3_drum_switch definition and declaration · b4748e7a
      Colin Ian King authored
      The function snd_opl3_drum_switch declaration in the header file
      has the order of the two arguments on_off and vel swapped when
      compared to the definition arguments of vel and on_off.  Fix this
      by swapping them around to match the definition.
      
      This error predates the git history, so no idea when this error
      was introduced.
      Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      b4748e7a
    • Jaroslav Kysela's avatar
      ALSA: hda - add Lenovo IdeaCentre B550 to the power_save_blacklist · 721f1e6c
      Jaroslav Kysela authored
      Another machine which does not like the power saving (noise):
        https://bugzilla.redhat.com/show_bug.cgi?id=1689623
      
      Also, reorder the Lenovo C50 entry to keep the table sorted.
      
      Reported-by: hs.guimaraes@outlook.com
      Signed-off-by: default avatarJaroslav Kysela <perex@perex.cz>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      721f1e6c
  11. 17 Mar, 2019 13 commits