1. 09 11月, 2017 1 次提交
  2. 07 11月, 2017 1 次提交
    • T
      ALSA: seq: Fix OSS sysex delivery in OSS emulation · 132d358b
      Takashi Iwai 提交于
      The SYSEX event delivery in OSS sequencer emulation assumed that the
      event is encoded in the variable-length data with the straight
      buffering.  This was the normal behavior in the past, but during the
      development, the chained buffers were introduced for carrying more
      data, while the OSS code was left intact.  As a result, when a SYSEX
      event with the chained buffer data is passed to OSS sequencer port,
      it may end up with the wrong memory access, as if it were having a too
      large buffer.
      
      This patch addresses the bug, by applying the buffer data expansion by
      the generic snd_seq_dump_var_event() helper function.
      Reported-by: Nsyzbot <syzkaller@googlegroups.com>
      Reported-by: NMark Salyzyn <salyzyn@android.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      132d358b
  3. 06 11月, 2017 1 次提交
    • T
      ALSA: timer: Limit max instances per timer · 9b7d869e
      Takashi Iwai 提交于
      Currently we allow unlimited number of timer instances, and it may
      bring the system hogging way too much CPU when too many timer
      instances are opened and processed concurrently.  This may end up with
      a soft-lockup report as triggered by syzkaller, especially when
      hrtimer backend is deployed.
      
      Since such insane number of instances aren't demanded by the normal
      use case of ALSA sequencer and it merely  opens a risk only for abuse,
      this patch introduces the upper limit for the number of instances per
      timer backend.  As default, it's set to 1000, but for the fine-grained
      timer like hrtimer, it's set to 100.
      
      Reported-by: syzbot
      Tested-by: NJérôme Glisse <jglisse@redhat.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      9b7d869e
  4. 02 11月, 2017 2 次提交
    • G
      License cleanup: add SPDX GPL-2.0 license identifier to files with no license · b2441318
      Greg Kroah-Hartman 提交于
      Many source files in the tree are missing licensing information, which
      makes it harder for compliance tools to determine the correct license.
      
      By default all files without license information are under the default
      license of the kernel, which is GPL version 2.
      
      Update the files which contain no license information with the 'GPL-2.0'
      SPDX license identifier.  The SPDX identifier is a legally binding
      shorthand, which can be used instead of the full boiler plate text.
      
      This patch is based on work done by Thomas Gleixner and Kate Stewart and
      Philippe Ombredanne.
      
      How this work was done:
      
      Patches were generated and checked against linux-4.14-rc6 for a subset of
      the use cases:
       - file had no licensing information it it.
       - file was a */uapi/* one with no licensing information in it,
       - file was a */uapi/* one with existing licensing information,
      
      Further patches will be generated in subsequent months to fix up cases
      where non-standard license headers were used, and references to license
      had to be inferred by heuristics based on keywords.
      
      The analysis to determine which SPDX License Identifier to be applied to
      a file was done in a spreadsheet of side by side results from of the
      output of two independent scanners (ScanCode & Windriver) producing SPDX
      tag:value files created by Philippe Ombredanne.  Philippe prepared the
      base worksheet, and did an initial spot review of a few 1000 files.
      
      The 4.13 kernel was the starting point of the analysis with 60,537 files
      assessed.  Kate Stewart did a file by file comparison of the scanner
      results in the spreadsheet to determine which SPDX license identifier(s)
      to be applied to the file. She confirmed any determination that was not
      immediately clear with lawyers working with the Linux Foundation.
      
      Criteria used to select files for SPDX license identifier tagging was:
       - Files considered eligible had to be source code files.
       - Make and config files were included as candidates if they contained >5
         lines of source
       - File already had some variant of a license header in it (even if <5
         lines).
      
      All documentation files were explicitly excluded.
      
      The following heuristics were used to determine which SPDX license
      identifiers to apply.
      
       - when both scanners couldn't find any license traces, file was
         considered to have no license information in it, and the top level
         COPYING file license applied.
      
         For non */uapi/* files that summary was:
      
         SPDX license identifier                            # files
         ---------------------------------------------------|-------
         GPL-2.0                                              11139
      
         and resulted in the first patch in this series.
      
         If that file was a */uapi/* path one, it was "GPL-2.0 WITH
         Linux-syscall-note" otherwise it was "GPL-2.0".  Results of that was:
      
         SPDX license identifier                            # files
         ---------------------------------------------------|-------
         GPL-2.0 WITH Linux-syscall-note                        930
      
         and resulted in the second patch in this series.
      
       - if a file had some form of licensing information in it, and was one
         of the */uapi/* ones, it was denoted with the Linux-syscall-note if
         any GPL family license was found in the file or had no licensing in
         it (per prior point).  Results summary:
      
         SPDX license identifier                            # files
         ---------------------------------------------------|------
         GPL-2.0 WITH Linux-syscall-note                       270
         GPL-2.0+ WITH Linux-syscall-note                      169
         ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause)    21
         ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)    17
         LGPL-2.1+ WITH Linux-syscall-note                      15
         GPL-1.0+ WITH Linux-syscall-note                       14
         ((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause)    5
         LGPL-2.0+ WITH Linux-syscall-note                       4
         LGPL-2.1 WITH Linux-syscall-note                        3
         ((GPL-2.0 WITH Linux-syscall-note) OR MIT)              3
         ((GPL-2.0 WITH Linux-syscall-note) AND MIT)             1
      
         and that resulted in the third patch in this series.
      
       - when the two scanners agreed on the detected license(s), that became
         the concluded license(s).
      
       - when there was disagreement between the two scanners (one detected a
         license but the other didn't, or they both detected different
         licenses) a manual inspection of the file occurred.
      
       - In most cases a manual inspection of the information in the file
         resulted in a clear resolution of the license that should apply (and
         which scanner probably needed to revisit its heuristics).
      
       - When it was not immediately clear, the license identifier was
         confirmed with lawyers working with the Linux Foundation.
      
       - If there was any question as to the appropriate license identifier,
         the file was flagged for further research and to be revisited later
         in time.
      
      In total, over 70 hours of logged manual review was done on the
      spreadsheet to determine the SPDX license identifiers to apply to the
      source files by Kate, Philippe, Thomas and, in some cases, confirmation
      by lawyers working with the Linux Foundation.
      
      Kate also obtained a third independent scan of the 4.13 code base from
      FOSSology, and compared selected files where the other two scanners
      disagreed against that SPDX file, to see if there was new insights.  The
      Windriver scanner is based on an older version of FOSSology in part, so
      they are related.
      
      Thomas did random spot checks in about 500 files from the spreadsheets
      for the uapi headers and agreed with SPDX license identifier in the
      files he inspected. For the non-uapi files Thomas did random spot checks
      in about 15000 files.
      
      In initial set of patches against 4.14-rc6, 3 files were found to have
      copy/paste license identifier errors, and have been fixed to reflect the
      correct identifier.
      
      Additionally Philippe spent 10 hours this week doing a detailed manual
      inspection and review of the 12,461 patched files from the initial patch
      version early this week with:
       - a full scancode scan run, collecting the matched texts, detected
         license ids and scores
       - reviewing anything where there was a license detected (about 500+
         files) to ensure that the applied SPDX license was correct
       - reviewing anything where there was no detection but the patch license
         was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
         SPDX license was correct
      
      This produced a worksheet with 20 files needing minor correction.  This
      worksheet was then exported into 3 different .csv files for the
      different types of files to be modified.
      
      These .csv files were then reviewed by Greg.  Thomas wrote a script to
      parse the csv files and add the proper SPDX tag to the file, in the
      format that the file expected.  This script was further refined by Greg
      based on the output to detect more types of files automatically and to
      distinguish between header and source .c files (which need different
      comment types.)  Finally Greg ran the script using the .csv files to
      generate the patches.
      Reviewed-by: NKate Stewart <kstewart@linuxfoundation.org>
      Reviewed-by: NPhilippe Ombredanne <pombredanne@nexb.com>
      Reviewed-by: NThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b2441318
    • J
      ALSA: usb-audio: support new Amanero Combo384 firmware version · f5ce8179
      Jussi Laako 提交于
      Support DSD_U32_BE sample format on new Amanero Combo384 firmware
      version on older VID/PID.
      
      Fixes: 3eff682d ("ALSA: usb-audio: Support both DSD LE/BE Amanero firmware versions")
      Signed-off-by: NJussi Laako <jussi@sonarnerd.net>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      f5ce8179
  5. 31 10月, 2017 2 次提交
  6. 25 10月, 2017 1 次提交
    • M
      locking/atomics: COCCINELLE/treewide: Convert trivial ACCESS_ONCE() patterns... · 6aa7de05
      Mark Rutland 提交于
      locking/atomics: COCCINELLE/treewide: Convert trivial ACCESS_ONCE() patterns to READ_ONCE()/WRITE_ONCE()
      
      Please do not apply this to mainline directly, instead please re-run the
      coccinelle script shown below and apply its output.
      
      For several reasons, it is desirable to use {READ,WRITE}_ONCE() in
      preference to ACCESS_ONCE(), and new code is expected to use one of the
      former. So far, there's been no reason to change most existing uses of
      ACCESS_ONCE(), as these aren't harmful, and changing them results in
      churn.
      
      However, for some features, the read/write distinction is critical to
      correct operation. To distinguish these cases, separate read/write
      accessors must be used. This patch migrates (most) remaining
      ACCESS_ONCE() instances to {READ,WRITE}_ONCE(), using the following
      coccinelle script:
      
      ----
      // Convert trivial ACCESS_ONCE() uses to equivalent READ_ONCE() and
      // WRITE_ONCE()
      
      // $ make coccicheck COCCI=/home/mark/once.cocci SPFLAGS="--include-headers" MODE=patch
      
      virtual patch
      
      @ depends on patch @
      expression E1, E2;
      @@
      
      - ACCESS_ONCE(E1) = E2
      + WRITE_ONCE(E1, E2)
      
      @ depends on patch @
      expression E;
      @@
      
      - ACCESS_ONCE(E)
      + READ_ONCE(E)
      ----
      Signed-off-by: NMark Rutland <mark.rutland@arm.com>
      Signed-off-by: NPaul E. McKenney <paulmck@linux.vnet.ibm.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: davem@davemloft.net
      Cc: linux-arch@vger.kernel.org
      Cc: mpe@ellerman.id.au
      Cc: shuah@kernel.org
      Cc: snitzer@redhat.com
      Cc: thor.thayer@linux.intel.com
      Cc: tj@kernel.org
      Cc: viro@zeniv.linux.org.uk
      Cc: will.deacon@arm.com
      Link: http://lkml.kernel.org/r/1508792849-3115-19-git-send-email-paulmck@linux.vnet.ibm.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      6aa7de05
  7. 24 10月, 2017 1 次提交
  8. 21 10月, 2017 1 次提交
  9. 20 10月, 2017 1 次提交
  10. 18 10月, 2017 6 次提交
    • B
      ASoC: rt5659: connect LOUT Amp with Charge Pump · a6189d37
      Bard Liao 提交于
      "Charge Pump" is necessary for "LOUT Amp".
      Signed-off-by: NBard Liao <bardliao@realtek.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      a6189d37
    • B
      ASoC: rt5659: register power bit of LOUT Amp · d1e84308
      Bard Liao 提交于
      There is a power bit for LOUT Amp.
      Signed-off-by: NBard Liao <bardliao@realtek.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      d1e84308
    • T
      ALSA: hda - Fix incorrect TLV callback check introduced during set_fs() removal · a91d6612
      Takashi Iwai 提交于
      The commit 99b5c5bb ("ALSA: hda - Remove the use of set_fs()")
      converted the get_kctl_0dB_offset() call for killing set_fs() usage in
      HD-audio codec code.  The conversion assumed that the TLV callback
      used in HD-audio code is only snd_hda_mixer_amp() and applies the TLV
      calculation locally.
      
      Although this assumption is correct, and all slave kctls are actually
      with that callback, the current code is still utterly buggy; it
      doesn't hit this condition and falls back to the next check.  It's
      because the function gets called after adding slave kctls to vmaster.
      By assigning a slave kctl, the slave kctl object is faked inside
      vmaster code, and the whole kctl ops are overridden.  Thus the
      callback op points to a different value from what we've assumed.
      
      More badly, as reported by the KERNEXEC and UDEREF features of PaX,
      the code flow turns into the unexpected pitfall.  The next fallback
      check is SNDRV_CTL_ELEM_ACCESS_TLV_READ access bit, and this always
      hits for each kctl with TLV.  Then it evaluates the callback function
      pointer wrongly as if it were a TLV array.  Although currently its
      side-effect is fairly limited, this incorrect reference may lead to an
      unpleasant result.
      
      For addressing the regression, this patch introduces a new helper to
      vmaster code, snd_ctl_apply_vmaster_slaves().  This works similarly
      like the existing map_slaves() in hda_codec.c: it loops over the slave
      list of the given master, and applies the given function to each
      slave.  Then the initializer function receives the right kctl object
      and we can compare the correct pointer instead of the faked one.
      
      Also, for catching the similar breakage in future, give an error
      message when the unexpected TLV callback is found and bail out
      immediately.
      
      Fixes: 99b5c5bb ("ALSA: hda - Remove the use of set_fs()")
      Reported-by: NPaX Team <pageexec@freemail.hu>
      Cc: <stable@vger.kernel.org> # v4.13
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      a91d6612
    • T
      ALSA: hda: Remove superfluous '-' added by printk conversion · 6bf88a34
      Takashi Iwai 提交于
      While converting the error messages to the standard macros in the
      commit 4e76a883 ("ALSA: hda - Replace with standard printk"), a
      superfluous '-' slipped in the code mistakenly.  Its influence is
      almost negligible, merely shows a dB value as negative integer instead
      of positive integer (or vice versa) in the rare error message.
      So let's kill this embarrassing byte to show more correct value.
      
      Fixes: 4e76a883 ("ALSA: hda - Replace with standard printk")
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      6bf88a34
    • T
      ALSA: hda: Abort capability probe at invalid register read · 098a0a62
      Takashi Iwai 提交于
      The loop in snd_hdac_bus_parse_capabilities() may go to nirvana when
      it hits an invalid register value read:
      
       BUG: unable to handle kernel paging request at ffffad5dc41f3fff
       IP: pci_azx_readl+0x5/0x10 [snd_hda_intel]
       Call Trace:
        snd_hdac_bus_parse_capabilities+0x3c/0x1f0 [snd_hda_core]
        azx_probe_continue+0x7d5/0x940 [snd_hda_intel]
        .....
      
      This happened on a new Intel machine, and we need to check the value
      and abort the loop accordingly.
      
      [Note: the fixes tag below indicates only the commit where this patch
       can be applied; the original problem was introduced even before that
       commit]
      
      Fixes: 6720b384 ("ALSA: hda - move bus_parse_capabilities to core")
      Cc: <stable@vger.kernel.org>
      Acked-by: NVinod Koul <vinod.koul@intel.com>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      098a0a62
    • B
      ALSA: seq: Enable 'use' locking in all configurations · 8009d506
      Ben Hutchings 提交于
      The 'use' locking macros are no-ops if neither SMP or SND_DEBUG is
      enabled.  This might once have been OK in non-preemptible
      configurations, but even in that case snd_seq_read() may sleep while
      relying on a 'use' lock.  So always use the proper implementations.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: NBen Hutchings <ben.hutchings@codethink.co.uk>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      8009d506
  11. 16 10月, 2017 1 次提交
  12. 11 10月, 2017 2 次提交
    • T
      ALSA: caiaq: Fix stray URB at probe error path · 99fee508
      Takashi Iwai 提交于
      caiaq driver doesn't kill the URB properly at its error path during
      the probe, which may lead to a use-after-free error later.  This patch
      addresses it.
      Reported-by: NJohan Hovold <johan@kernel.org>
      Reviewed-by: NJohan Hovold <johan@kernel.org>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      99fee508
    • T
      ALSA: seq: Fix use-after-free at creating a port · 71105998
      Takashi Iwai 提交于
      There is a potential race window opened at creating and deleting a
      port via ioctl, as spotted by fuzzing.  snd_seq_create_port() creates
      a port object and returns its pointer, but it doesn't take the
      refcount, thus it can be deleted immediately by another thread.
      Meanwhile, snd_seq_ioctl_create_port() still calls the function
      snd_seq_system_client_ev_port_start() with the created port object
      that is being deleted, and this triggers use-after-free like:
      
       BUG: KASAN: use-after-free in snd_seq_ioctl_create_port+0x504/0x630 [snd_seq] at addr ffff8801f2241cb1
       =============================================================================
       BUG kmalloc-512 (Tainted: G    B          ): kasan: bad access detected
       -----------------------------------------------------------------------------
       INFO: Allocated in snd_seq_create_port+0x94/0x9b0 [snd_seq] age=1 cpu=3 pid=4511
       	___slab_alloc+0x425/0x460
       	__slab_alloc+0x20/0x40
        	kmem_cache_alloc_trace+0x150/0x190
      	snd_seq_create_port+0x94/0x9b0 [snd_seq]
      	snd_seq_ioctl_create_port+0xd1/0x630 [snd_seq]
       	snd_seq_do_ioctl+0x11c/0x190 [snd_seq]
       	snd_seq_ioctl+0x40/0x80 [snd_seq]
       	do_vfs_ioctl+0x54b/0xda0
       	SyS_ioctl+0x79/0x90
       	entry_SYSCALL_64_fastpath+0x16/0x75
       INFO: Freed in port_delete+0x136/0x1a0 [snd_seq] age=1 cpu=2 pid=4717
       	__slab_free+0x204/0x310
       	kfree+0x15f/0x180
       	port_delete+0x136/0x1a0 [snd_seq]
       	snd_seq_delete_port+0x235/0x350 [snd_seq]
       	snd_seq_ioctl_delete_port+0xc8/0x180 [snd_seq]
       	snd_seq_do_ioctl+0x11c/0x190 [snd_seq]
       	snd_seq_ioctl+0x40/0x80 [snd_seq]
       	do_vfs_ioctl+0x54b/0xda0
       	SyS_ioctl+0x79/0x90
       	entry_SYSCALL_64_fastpath+0x16/0x75
       Call Trace:
        [<ffffffff81b03781>] dump_stack+0x63/0x82
        [<ffffffff81531b3b>] print_trailer+0xfb/0x160
        [<ffffffff81536db4>] object_err+0x34/0x40
        [<ffffffff815392d3>] kasan_report.part.2+0x223/0x520
        [<ffffffffa07aadf4>] ? snd_seq_ioctl_create_port+0x504/0x630 [snd_seq]
        [<ffffffff815395fe>] __asan_report_load1_noabort+0x2e/0x30
        [<ffffffffa07aadf4>] snd_seq_ioctl_create_port+0x504/0x630 [snd_seq]
        [<ffffffffa07aa8f0>] ? snd_seq_ioctl_delete_port+0x180/0x180 [snd_seq]
        [<ffffffff8136be50>] ? taskstats_exit+0xbc0/0xbc0
        [<ffffffffa07abc5c>] snd_seq_do_ioctl+0x11c/0x190 [snd_seq]
        [<ffffffffa07abd10>] snd_seq_ioctl+0x40/0x80 [snd_seq]
        [<ffffffff8136d433>] ? acct_account_cputime+0x63/0x80
        [<ffffffff815b515b>] do_vfs_ioctl+0x54b/0xda0
        .....
      
      We may fix this in a few different ways, and in this patch, it's fixed
      simply by taking the refcount properly at snd_seq_create_port() and
      letting the caller unref the object after use.  Also, there is another
      potential use-after-free by sprintf() call in snd_seq_create_port(),
      and this is moved inside the lock.
      
      This fix covers CVE-2017-15265.
      Reported-and-tested-by: NMichael23 Yu <ycqzsy@gmail.com>
      Suggested-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      71105998
  13. 10 10月, 2017 1 次提交
    • T
      ALSA: usb-audio: Kill stray URB at exiting · 124751d5
      Takashi Iwai 提交于
      USB-audio driver may leave a stray URB for the mixer interrupt when it
      exits by some error during probe.  This leads to a use-after-free
      error as spotted by syzkaller like:
        ==================================================================
        BUG: KASAN: use-after-free in snd_usb_mixer_interrupt+0x604/0x6f0
        Call Trace:
         <IRQ>
         __dump_stack lib/dump_stack.c:16
         dump_stack+0x292/0x395 lib/dump_stack.c:52
         print_address_description+0x78/0x280 mm/kasan/report.c:252
         kasan_report_error mm/kasan/report.c:351
         kasan_report+0x23d/0x350 mm/kasan/report.c:409
         __asan_report_load8_noabort+0x19/0x20 mm/kasan/report.c:430
         snd_usb_mixer_interrupt+0x604/0x6f0 sound/usb/mixer.c:2490
         __usb_hcd_giveback_urb+0x2e0/0x650 drivers/usb/core/hcd.c:1779
         ....
      
        Allocated by task 1484:
         save_stack_trace+0x1b/0x20 arch/x86/kernel/stacktrace.c:59
         save_stack+0x43/0xd0 mm/kasan/kasan.c:447
         set_track mm/kasan/kasan.c:459
         kasan_kmalloc+0xad/0xe0 mm/kasan/kasan.c:551
         kmem_cache_alloc_trace+0x11e/0x2d0 mm/slub.c:2772
         kmalloc ./include/linux/slab.h:493
         kzalloc ./include/linux/slab.h:666
         snd_usb_create_mixer+0x145/0x1010 sound/usb/mixer.c:2540
         create_standard_mixer_quirk+0x58/0x80 sound/usb/quirks.c:516
         snd_usb_create_quirk+0x92/0x100 sound/usb/quirks.c:560
         create_composite_quirk+0x1c4/0x3e0 sound/usb/quirks.c:59
         snd_usb_create_quirk+0x92/0x100 sound/usb/quirks.c:560
         usb_audio_probe+0x1040/0x2c10 sound/usb/card.c:618
         ....
      
        Freed by task 1484:
         save_stack_trace+0x1b/0x20 arch/x86/kernel/stacktrace.c:59
         save_stack+0x43/0xd0 mm/kasan/kasan.c:447
         set_track mm/kasan/kasan.c:459
         kasan_slab_free+0x72/0xc0 mm/kasan/kasan.c:524
         slab_free_hook mm/slub.c:1390
         slab_free_freelist_hook mm/slub.c:1412
         slab_free mm/slub.c:2988
         kfree+0xf6/0x2f0 mm/slub.c:3919
         snd_usb_mixer_free+0x11a/0x160 sound/usb/mixer.c:2244
         snd_usb_mixer_dev_free+0x36/0x50 sound/usb/mixer.c:2250
         __snd_device_free+0x1ff/0x380 sound/core/device.c:91
         snd_device_free_all+0x8f/0xe0 sound/core/device.c:244
         snd_card_do_free sound/core/init.c:461
         release_card_device+0x47/0x170 sound/core/init.c:181
         device_release+0x13f/0x210 drivers/base/core.c:814
         ....
      
      Actually such a URB is killed properly at disconnection when the
      device gets probed successfully, and what we need is to apply it for
      the error-path, too.
      
      In this patch, we apply snd_usb_mixer_disconnect() at releasing.
      Also introduce a new flag, disconnected, to struct usb_mixer_interface
      for not performing the disconnection procedure twice.
      Reported-by: NAndrey Konovalov <andreyknvl@google.com>
      Tested-by: NAndrey Konovalov <andreyknvl@google.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      124751d5
  14. 09 10月, 2017 5 次提交
    • T
      ALSA: line6: Fix leftover URB at error-path during probe · c95072b3
      Takashi Iwai 提交于
      While line6_probe() may kick off URB for a control MIDI endpoint, the
      function doesn't clean up it properly at its error path.  This results
      in a leftover URB action that is eventually triggered later and causes
      an Oops like:
        general protection fault: 0000 [#1] PREEMPT SMP KASAN
        CPU: 1 PID: 0 Comm: swapper/1 Not tainted
        RIP: 0010:usb_fill_bulk_urb ./include/linux/usb.h:1619
        RIP: 0010:line6_start_listen+0x3fe/0x9e0 sound/usb/line6/driver.c:76
        Call Trace:
         <IRQ>
         line6_data_received+0x1f7/0x470 sound/usb/line6/driver.c:326
         __usb_hcd_giveback_urb+0x2e0/0x650 drivers/usb/core/hcd.c:1779
         usb_hcd_giveback_urb+0x337/0x420 drivers/usb/core/hcd.c:1845
         dummy_timer+0xba9/0x39f0 drivers/usb/gadget/udc/dummy_hcd.c:1965
         call_timer_fn+0x2a2/0x940 kernel/time/timer.c:1281
         ....
      
      Since the whole clean-up procedure is done in line6_disconnect()
      callback, we can simply call it in the error path instead of
      open-coding the whole again.  It'll fix such an issue automagically.
      
      The bug was spotted by syzkaller.
      
      Fixes: eedd0e95 ("ALSA: line6: Don't forget to call driver's destructor at error path")
      Reported-by: NAndrey Konovalov <andreyknvl@google.com>
      Tested-by: NAndrey Konovalov <andreyknvl@google.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      c95072b3
    • T
      ALSA: line6: Fix NULL dereference at podhd_disconnect() · 54a4b2b4
      Takashi Iwai 提交于
      When podhd_init() failed with the acquiring a ctrl i/f, the line6
      helper still calls the disconnect callback that eventually calls again
      usb_driver_release_interface() with the NULL intf.
      
      Put the proper NULL check before calling it for avoiding an Oops.
      
      Fixes: fc90172b ("ALSA: line6: Claim pod x3 usb data interface")
      Reported-by: NAndrey Konovalov <andreyknvl@google.com>
      Tested-by: NAndrey Konovalov <andreyknvl@google.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      54a4b2b4
    • T
      ALSA: line6: Fix missing initialization before error path · cb02ffc7
      Takashi Iwai 提交于
      The error path in podhd_init() tries to clear the pending timer, while
      the timer object is initialized at the end of init sequence, thus it
      may hit the uninitialized object, as spotted by syzkaller:
      
        INFO: trying to register non-static key.
        the code is fine but needs lockdep annotation.
        turning off the locking correctness validator.
        CPU: 1 PID: 1845 Comm: kworker/1:2 Not tainted
        4.14.0-rc2-42613-g1488251d1a98 #238
        Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
        Workqueue: usb_hub_wq hub_event
        Call Trace:
         __dump_stack lib/dump_stack.c:16
         dump_stack+0x292/0x395 lib/dump_stack.c:52
         register_lock_class+0x6c4/0x1a00 kernel/locking/lockdep.c:769
         __lock_acquire+0x27e/0x4550 kernel/locking/lockdep.c:3385
         lock_acquire+0x259/0x620 kernel/locking/lockdep.c:4002
         del_timer_sync+0x12c/0x280 kernel/time/timer.c:1237
         podhd_disconnect+0x8c/0x160 sound/usb/line6/podhd.c:299
         line6_probe+0x844/0x1310 sound/usb/line6/driver.c:783
         podhd_probe+0x64/0x70 sound/usb/line6/podhd.c:474
         ....
      
      For addressing it, assure the initializations of timer and work by
      moving them to the beginning of podhd_init().
      
      Fixes: 790869da ("ALSA: line6: Add support for POD X3")
      Reported-by: NAndrey Konovalov <andreyknvl@google.com>
      Tested-by: NAndrey Konovalov <andreyknvl@google.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      cb02ffc7
    • T
      ALSA: seq: Fix copy_from_user() call inside lock · 5803b023
      Takashi Iwai 提交于
      The event handler in the virmidi sequencer code takes a read-lock for
      the linked list traverse, while it's calling snd_seq_dump_var_event()
      in the loop.  The latter function may expand the user-space data
      depending on the event type.  It eventually invokes copy_from_user(),
      which might be a potential dead-lock.
      
      The sequencer core guarantees that the user-space data is passed only
      with atomic=0 argument, but snd_virmidi_dev_receive_event() ignores it
      and always takes read-lock().  For avoiding the problem above, this
      patch introduces rwsem for non-atomic case, while keeping rwlock for
      atomic case.
      
      Also while we're at it: the superfluous irq flags is dropped in
      snd_virmidi_input_open().
      Reported-by: NJia-Ju Bai <baijiaju1990@163.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      5803b023
    • K
      ALSA: usb-audio: Add sample rate quirk for Plantronics P610 · c247487c
      Kai-Heng Feng 提交于
      Like other Plantronics devices, P610 does not support sample
      rate reading. Apply sample rate quirk to it.
      
      BugLink: https://bugs.launchpad.net/bugs/1719853Signed-off-by: NKai-Heng Feng <kai.heng.feng@canonical.com>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      c247487c
  15. 05 10月, 2017 1 次提交
    • K
      timer: Remove expires and data arguments from DEFINE_TIMER · 1d27e3e2
      Kees Cook 提交于
      Drop the arguments from the macro and adjust all callers with the
      following script:
      
        perl -pi -e 's/DEFINE_TIMER\((.*), 0, 0\);/DEFINE_TIMER($1);/g;' \
          $(git grep DEFINE_TIMER | cut -d: -f1 | sort -u | grep -v timer.h)
      Signed-off-by: NKees Cook <keescook@chromium.org>
      Acked-by: Geert Uytterhoeven <geert@linux-m68k.org> # for m68k parts
      Acked-by: Guenter Roeck <linux@roeck-us.net> # for watchdog parts
      Acked-by: David S. Miller <davem@davemloft.net> # for networking parts
      Acked-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Acked-by: Kalle Valo <kvalo@codeaurora.org> # for wireless parts
      Acked-by: NArnd Bergmann <arnd@arndb.de>
      Cc: linux-mips@linux-mips.org
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Lai Jiangshan <jiangshanlai@gmail.com>
      Cc: Sebastian Reichel <sre@kernel.org>
      Cc: Kalle Valo <kvalo@qca.qualcomm.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Pavel Machek <pavel@ucw.cz>
      Cc: linux1394-devel@lists.sourceforge.net
      Cc: Chris Metcalf <cmetcalf@mellanox.com>
      Cc: linux-s390@vger.kernel.org
      Cc: linux-wireless@vger.kernel.org
      Cc: "James E.J. Bottomley" <jejb@linux.vnet.ibm.com>
      Cc: Wim Van Sebroeck <wim@iguana.be>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Ursula Braun <ubraun@linux.vnet.ibm.com>
      Cc: Viresh Kumar <viresh.kumar@linaro.org>
      Cc: Harish Patil <harish.patil@cavium.com>
      Cc: Stephen Boyd <sboyd@codeaurora.org>
      Cc: Michael Reed <mdr@sgi.com>
      Cc: Manish Chopra <manish.chopra@cavium.com>
      Cc: Len Brown <len.brown@intel.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: linux-pm@vger.kernel.org
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Tejun Heo <tj@kernel.org>
      Cc: Julian Wiedmann <jwi@linux.vnet.ibm.com>
      Cc: John Stultz <john.stultz@linaro.org>
      Cc: Mark Gross <mark.gross@intel.com>
      Cc: linux-watchdog@vger.kernel.org
      Cc: linux-scsi@vger.kernel.org
      Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Stefan Richter <stefanr@s5r6.in-berlin.de>
      Cc: Guenter Roeck <linux@roeck-us.net>
      Cc: netdev@vger.kernel.org
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: linuxppc-dev@lists.ozlabs.org
      Cc: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
      Link: https://lkml.kernel.org/r/1507159627-127660-11-git-send-email-keescook@chromium.orgSigned-off-by: NThomas Gleixner <tglx@linutronix.de>
      1d27e3e2
  16. 03 10月, 2017 1 次提交
    • T
      ALSA: usx2y: Suppress kernel warning at page allocation failures · 7682e399
      Takashi Iwai 提交于
      The usx2y driver allocates the stream read/write buffers in continuous
      pages depending on the stream setup, and this may spew the kernel
      warning messages with a stack trace like:
        WARNING: CPU: 1 PID: 1846 at mm/page_alloc.c:3883
        __alloc_pages_slowpath+0x1ef2/0x2d70
        Modules linked in:
        CPU: 1 PID: 1846 Comm: kworker/1:2 Not tainted
        ....
      
      It may confuse user as if it were any serious error, although this is
      no fatal error and the driver handles the error case gracefully.
      Since the driver has already some sanity check of the given size (128
      and 256 pages), it can't pass any crazy value.  So it's merely page
      fragmentation.
      
      This patch adds __GFP_NOWARN to each caller for suppressing such
      kernel warnings.  The original issue was spotted by syzkaller.
      Reported-by: NAndrey Konovalov <andreyknvl@google.com>
      Tested-by: NAndrey Konovalov <andreyknvl@google.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      7682e399
  17. 02 10月, 2017 1 次提交
    • T
      Revert "ALSA: echoaudio: purge contradictions between dimension matrix members... · 51db452d
      Takashi Sakamoto 提交于
      Revert "ALSA: echoaudio: purge contradictions between dimension matrix members and total number of members"
      
      This reverts commit 275353bb to fix a regression which can abort
      'alsactl' program in alsa-utils due to assertion in alsa-lib.
      
      alsactl: control.c:2513: snd_ctl_elem_value_get_integer: Assertion `idx < sizeof(obj->value.integer.value) / sizeof(obj->value.integer.value[0])' failed.
      
      alsactl: control.c:2976: snd_ctl_elem_value_get_integer: Assertion `idx < ARRAY_SIZE(obj->value.integer.value)' failed.
      
      This commit is a band-aid. In a point of usage of ALSA control interface,
      the drivers still bring an issue that they prevent userspace applications
      to have a consistent way to parse each levels of the dimension information
      via ALSA control interface.
      
      Let me investigate this issue. Current implementation of the drivers
      have three control element sets with dimension information:
       * 'Monitor Mixer Volume' (type: integer)
       * 'VMixer Volume' (type: integer)
       * 'VU-meters' (type: boolean)
      
      Although the number of elements named as 'Monitor Mixer Volume' differs
      depending on drivers in this group, it can be calculated by macros
      defined by each driver (= (BX_NUM - BX_ANALOG_IN) * BX_ANALOG_IN). Each
      of the elements has one member for value and has dimension information
      with 2 levels (= BX_ANALOG_IN * (BX_NUM - BX_ANALOG_IN)). For these
      elements, userspace applications are expected to handle the dimension
      information so that all of the elements construct a matrix where the
      number of rows and columns are represented by the dimension information.
      
      The same way is applied to elements named as 'VMixer Volume'. The number
      of these elements can also be calculated by macros defined by each
      drivers (= PX_ANALOG_IN * BX_ANALOG_IN). Each of the element has one
      member for value and has dimension information with 2 levels
      (= BX_ANALOG_IN * PX_ANALOG_IN). All of the elements construct a matrix
      with the dimension information.
      
      An element named as 'VU-meters' gets a different way in a point of
      dimension information. The element includes 96 members for value. The
      element has dimension information with 3 levels (= 3 or 2 * 16 * 2). For
      this element, userspace applications are expected to handle the dimension
      information so that all of the members for value construct a matrix
      where the number of rows and columns are represented by the dimension
      information. This is different from the way for the former.
      
      As a summary, the drivers were not designed to produce a consistent way to
      parse the dimension information. This makes it hard for general userspace
      applications such as amixer to parse the information by a consistent way,
      and actually no userspace applications except for 'echomixer' utilize the
      dimension information. Additionally, no drivers excluding this group use
      the information.
      
      The reverted commit was written based on the latter way. A commit
      860c1994 ('ALSA: control: add dimension validator for userspace
      elements') is written based on the latter way, too. The patch should be
      reconsider too in the same time to re-define a consistent way to parse the
      dimension information.
      Reported-by: NMark Hills <mark@xwax.org>
      Reported-by: NS. Christian Collins <s.chriscollins@gmail.com>
      Fixes: 275353bb ('ALSA: echoaudio: purge contradictions between dimension matrix members and total number of members')
      Cc: <stable@vger.kernel.org> # v4.8+
      Signed-off-by: NTakashi Sakamoto <o-takashi@sakamocchi.jp>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      51db452d
  18. 26 9月, 2017 1 次提交
  19. 22 9月, 2017 2 次提交
    • T
      ALSA: usb-audio: Check out-of-bounds access by corrupted buffer descriptor · bfc81a8b
      Takashi Iwai 提交于
      When a USB-audio device receives a maliciously adjusted or corrupted
      buffer descriptor, the USB-audio driver may access an out-of-bounce
      value at its parser.  This was detected by syzkaller, something like:
      
        BUG: KASAN: slab-out-of-bounds in usb_audio_probe+0x27b2/0x2ab0
        Read of size 1 at addr ffff88006b83a9e8 by task kworker/0:1/24
        CPU: 0 PID: 24 Comm: kworker/0:1 Not tainted 4.14.0-rc1-42251-gebb2c243 #224
        Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
        Workqueue: usb_hub_wq hub_event
        Call Trace:
         __dump_stack lib/dump_stack.c:16
         dump_stack+0x292/0x395 lib/dump_stack.c:52
         print_address_description+0x78/0x280 mm/kasan/report.c:252
         kasan_report_error mm/kasan/report.c:351
         kasan_report+0x22f/0x340 mm/kasan/report.c:409
         __asan_report_load1_noabort+0x19/0x20 mm/kasan/report.c:427
         snd_usb_create_streams sound/usb/card.c:248
         usb_audio_probe+0x27b2/0x2ab0 sound/usb/card.c:605
         usb_probe_interface+0x35d/0x8e0 drivers/usb/core/driver.c:361
         really_probe drivers/base/dd.c:413
         driver_probe_device+0x610/0xa00 drivers/base/dd.c:557
         __device_attach_driver+0x230/0x290 drivers/base/dd.c:653
         bus_for_each_drv+0x161/0x210 drivers/base/bus.c:463
         __device_attach+0x26e/0x3d0 drivers/base/dd.c:710
         device_initial_probe+0x1f/0x30 drivers/base/dd.c:757
         bus_probe_device+0x1eb/0x290 drivers/base/bus.c:523
         device_add+0xd0b/0x1660 drivers/base/core.c:1835
         usb_set_configuration+0x104e/0x1870 drivers/usb/core/message.c:1932
         generic_probe+0x73/0xe0 drivers/usb/core/generic.c:174
         usb_probe_device+0xaf/0xe0 drivers/usb/core/driver.c:266
         really_probe drivers/base/dd.c:413
         driver_probe_device+0x610/0xa00 drivers/base/dd.c:557
         __device_attach_driver+0x230/0x290 drivers/base/dd.c:653
         bus_for_each_drv+0x161/0x210 drivers/base/bus.c:463
         __device_attach+0x26e/0x3d0 drivers/base/dd.c:710
         device_initial_probe+0x1f/0x30 drivers/base/dd.c:757
         bus_probe_device+0x1eb/0x290 drivers/base/bus.c:523
         device_add+0xd0b/0x1660 drivers/base/core.c:1835
         usb_new_device+0x7b8/0x1020 drivers/usb/core/hub.c:2457
         hub_port_connect drivers/usb/core/hub.c:4903
         hub_port_connect_change drivers/usb/core/hub.c:5009
         port_event drivers/usb/core/hub.c:5115
         hub_event+0x194d/0x3740 drivers/usb/core/hub.c:5195
         process_one_work+0xc7f/0x1db0 kernel/workqueue.c:2119
         worker_thread+0x221/0x1850 kernel/workqueue.c:2253
         kthread+0x3a1/0x470 kernel/kthread.c:231
         ret_from_fork+0x2a/0x40 arch/x86/entry/entry_64.S:431
      
      This patch adds the checks of out-of-bounce accesses at appropriate
      places and bails out when it goes out of the given buffer.
      Reported-by: NAndrey Konovalov <andreyknvl@google.com>
      Tested-by: NAndrey Konovalov <andreyknvl@google.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      bfc81a8b
    • B
      ALSA: pcm: Fix structure definition for X32 ABI · c9adcdbc
      Baolin Wang 提交于
      X32 ABI uses the 64bit timespec in addition to 64bit alignment of 64bit
      values. We have added compat ABI for these ioctls, but this patch adds
      one missing padding into 'struct snd_pcm_mmap_status_x32' to fix
      incompatibilities.
      Signed-off-by: NBaolin Wang <baolin.wang@linaro.org>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      c9adcdbc
  20. 21 9月, 2017 1 次提交
  21. 20 9月, 2017 2 次提交
  22. 18 9月, 2017 1 次提交
  23. 16 9月, 2017 1 次提交
  24. 15 9月, 2017 3 次提交