1. 14 1月, 2023 1 次提交
  2. 21 10月, 2022 1 次提交
  3. 26 8月, 2022 1 次提交
  4. 24 8月, 2022 1 次提交
  5. 29 7月, 2022 1 次提交
  6. 13 7月, 2022 1 次提交
  7. 15 6月, 2022 4 次提交
  8. 25 5月, 2021 3 次提交
    • T
      ALSA: control: Minor optimization for SNDRV_CTL_IOCTL_POWER_STATE · 968bb2ba
      Takashi Iwai 提交于
      Long long time ago, before the proper PM framework was introduced, it
      was still possible to reach SNDRV_CTL_IOCTL_POWER ioctl during the
      power off state.  This ioctl existed as a main control for the suspend
      resume state in the past, but the feature was already dropped along
      with the standard PM framework.  Now the read part,
      SNDRV_IOCTL_POWER_STATE ioctl, returns practically always D0, and we
      can do some minor optimization there.
      Reviewed-by: NJaroslav Kysela <perex@perex.cz>
      Link: https://lore.kernel.org/r/20210523090920.15345-5-tiwai@suse.deSigned-off-by: NTakashi Iwai <tiwai@suse.de>
      968bb2ba
    • T
      ALSA: control: Drop superfluous snd_power_wait() calls · 73063cd3
      Takashi Iwai 提交于
      Now we have more fine-grained power controls in each kcontrol ops, the
      coarse checks of snd_power_wait() in a few control ioctls became
      superfluous.  Let's drop them.
      Reviewed-by: NJaroslav Kysela <perex@perex.cz>
      Link: https://lore.kernel.org/r/20210523090920.15345-4-tiwai@suse.deSigned-off-by: NTakashi Iwai <tiwai@suse.de>
      73063cd3
    • T
      ALSA: control: Track in-flight control read/write/tlv accesses · e94fdbd7
      Takashi Iwai 提交于
      Although the power state check is performed in various places (e.g. at
      the entrance of quite a few ioctls), there can be still some pending
      tasks that already went into the ioctl handler or other ops, and those
      may access the hardware even after the power state check.  For
      example, kcontrol access ioctl paths that call info/get/put callbacks
      may update the hardware registers.  If a system wants to assure the
      free from such hw access (like the case of PCI rescan feature we're
      going to implement in future), this situation must be avoided, and we
      have to sync such in-flight tasks finishing beforehand.
      
      For that purpose, this patch introduces a few new things in core code:
      - A refcount, power_ref, and a wait queue, power_ref_sleep, to the
        card object
      - A few new helpers, snd_power_ref(), snd_power_unref(),
        snd_power_ref_and_wait(), and snd_power_sync_ref()
      
      In the code paths that call kctl info/read/write/tlv ops, we check the
      power state with the newly introduced snd_power_ref_and_wait().  This
      function also takes the card.power_ref refcount for tracking this
      in-flight task.  Once after the access finishes, snd_power_unref() is
      called to released the refcount in return.  So the driver can sync via
      snd_power_sync_ref() assuring that all in-flight tasks have been
      finished.
      
      As of this patch, snd_power_sync_ref() is called only at
      snd_card_disconnect(), but it'll be used in other places in future.
      
      Note that atomic_t is used for power_ref intentionally instead of
      refcount_t.  It's because of the design of refcount_t type; refcount_t
      cannot be zero-based, and it cannot do dec_and_test() call for
      multiple times, hence it's not suitable for our purpose.
      
      Also, this patch changes snd_power_wait() to accept only
      SNDRV_CTL_POWER_D0, which is the only value that makes sense.
      In later patch, the snd_power_wait() calls will be cleaned up.
      Reviewed-by: NJaroslav Kysela <perex@perex.cz>
      Link: https://lore.kernel.org/r/20210523090920.15345-3-tiwai@suse.deSigned-off-by: NTakashi Iwai <tiwai@suse.de>
      e94fdbd7
  9. 16 4月, 2021 1 次提交
    • T
      ALSA: control: Fix racy management of user ctl memory size account · 998f26f4
      Takashi Iwai 提交于
      We've got a report about the possible race in the user control element
      counts (card->user_ctl_count), and it was confirmed that the race
      wasn't serious in the old code up to 5.12.  There, the value
      modification itself was exclusive and protected via a write semaphore,
      hence it's at most concurrent reads and evaluations before the
      increment.  Since it's only about the soft-limit to avoid the
      exhausting memory usage, one-off isn't a big problem at all.
      
      Meanwhile, the relevant code has been largely modified recently, and
      now card->user_ctl_count was replaced with card->user_ctl_alloc_size,
      and a few more places were added to access this field.  And, in this
      new code, it turned out to be more serious: the modifications are
      scattered in various places, and a few of them are without protection.
      It implies that it may lead to an inconsistent value by racy
      accesses.
      
      For addressing it, this patch extends the range covered by the
      card->controls_rwsem write lock at snd_ctl_elem_add() so that the all
      code paths that modify and refer to card->user_ctl_alloc_size are
      protected by the rwsem properly.
      
      The patch adds also comments in a couple of functions to indicate that
      they are under the rwsem lock.
      
      Fixes: 66c6d1ef ("ALSA: control: Add memory consumption limit to user controls")
      Link: https://lore.kernel.org/r/FEEBF384-44BE-42CF-8FB3-93470933F64F@purdue.edu
      Link: https://lore.kernel.org/r/20210415131856.13113-1-tiwai@suse.deSigned-off-by: NTakashi Iwai <tiwai@suse.de>
      998f26f4
  10. 08 4月, 2021 1 次提交
    • T
      ALSA: control: Add memory consumption limit to user controls · 66c6d1ef
      Takashi Sakamoto 提交于
      ALSA control interface allows users to add arbitrary control elements
      (called "user controls" or "user elements"), and its resource usage is
      limited just by the max number of control sets (currently 32).  This
      limit, however, is quite loose: each allocation of control set may
      have 1028 elements, and each element may have up to 512 bytes (ILP32) or
      1024 bytes (LP64) of value data. Moreover, each control set may contain
      the enum strings and TLV data, which can be up to 64kB and 128kB,
      respectively.  Totally, the whole memory consumption may go over 38MB --
      it's quite large, and we'd rather like to reduce the size.
      
      OTOH, there have been other requests even to increase the max number
      of user elements; e.g. ALSA firewire stack require the more user
      controls, hence we want to raise the bar, too.
      
      For satisfying both requirements, this patch changes the management of
      user controls: instead of setting the upper limit of the number of
      user controls, we check the actual memory allocation size and set the
      upper limit of the total allocation in bytes.  As long as the memory
      consumption stays below the limit, more user controls are allowed than
      the current limit 32. At the same time, we set the lower limit (8MB)
      as default than the current theoretical limit, in order to lower the
      risk of DoS.
      
      As a compromise for lowering the default limit, now the actual memory
      limit is defined as a module option, 'max_user_ctl_alloc_size', so that
      user can increase/decrease the limit if really needed, too.
      
      Link: https://lore.kernel.org/r/s5htur3zl5e.wl-tiwai@suse.deCo-developed-by: NTakashi Iwai <tiwai@suse.de>
      Reviewed-by: NTakashi Sakamoto <o-takashi@sakamocchi.jp>
      Tested-by: NTakashi Sakamoto <o-takashi@sakamocchi.jp>
      Signed-off-by: NTakashi Sakamoto <o-takashi@sakamocchi.jp>
      Link: https://lore.kernel.org/r/20210408103149.40357-1-o-takashi@sakamocchi.jpSigned-off-by: NTakashi Iwai <tiwai@suse.de>
      66c6d1ef
  11. 01 4月, 2021 1 次提交
  12. 30 3月, 2021 3 次提交
  13. 08 1月, 2021 1 次提交
  14. 25 12月, 2020 1 次提交
  15. 13 11月, 2020 1 次提交
  16. 26 10月, 2020 1 次提交
  17. 22 9月, 2020 1 次提交
    • T
      ALSA: ctl: Workaround for lockdep warning wrt card->ctl_files_rwlock · 6564d0ad
      Takashi Iwai 提交于
      The recent change in lockdep for read lock caused the deadlock
      warnings in ALSA control code which uses the read_lock() for
      notification and else while write_lock_irqsave() is used for adding
      and removing the list entry.  Although a deadlock would practically
      never hit in a real usage (the addition and the deletion can't happen
      with the notification), it's better to fix the read_lock() usage in a
      semantically correct way.
      
      This patch replaces the read_lock() calls with read_lock_irqsave()
      version for avoiding a reported deadlock.  The notification code path
      takes the irq disablement in anyway, and other code paths are very
      short execution, hence there shouldn't be any big performance hit by
      this change.
      
      Fixes: e9181886 ("locking: More accurate annotations for read_lock()")
      Reported-by: syzbot+561a74f84100162990b2@syzkaller.appspotmail.com
      Link: https://lore.kernel.org/r/20200922084953.29018-1-tiwai@suse.deSigned-off-by: NTakashi Iwai <tiwai@suse.de>
      6564d0ad
  18. 21 9月, 2020 1 次提交
  19. 08 1月, 2020 1 次提交
  20. 04 1月, 2020 1 次提交
    • T
      ALSA: control: Add verification for kctl accesses · fbd3eb7f
      Takashi Iwai 提交于
      The current implementation of ALSA control API fully relies on the
      callbacks of each driver, and there is no verification of the values
      passed via API.  This patch is an attempt to improve the situation
      slightly by adding the validation code for the values stored via info
      and get callbacks.
      
      The patch adds a new kconfig, CONFIG_SND_CTL_VALIDATION.  It depends
      on CONFIG_SND_DEBUG and off as default since the validation would
      require a slight overhead including the additional call of info
      callback at each get callback invocation.
      
      When this config is enabled, the values stored by each info callback
      invocation are verified, namely:
      - Whether the info type is valid
      - Whether the number of enum items is non-zero
      - Whether the given info count is within the allowed boundary
      
      Similarly, the values stored at each get callback are verified as
      well:
      - Whether the values are within the given range
      - Whether the values are aligned with the given step
      - Whether any further changes are seen in the data array over the
        given info count
      
      The last point helps identifying a possibly invalid data type access,
      typically a case where the info callback declares the type being
      SNDRV_CTL_ELEM_TYPE_ENUMERATED while the get/put callbacks store
      the values in value.integer.value[] array.
      
      When a validation fails, the ALSA core logs an error message including
      the device and the control ID, and the API call also returns an
      error.  So, with the new validation turned on, the driver behavior
      difference may be visible on user-space, too -- it's intentional,
      though, so that we can catch an error more clearly.
      
      The patch also introduces a new ctl access type,
      SNDRV_CTL_ELEM_ACCESS_SKIP_CHECK.  A driver may pass this flag with
      other access bits to indicate that the ctl element won't be verified.
      It's useful when a driver code is specially written to access the data
      greater than info->count size by some reason.  For example, this flag
      is actually set now in HD-audio HDMI codec driver which needs to clear
      the data array in the case of the disconnected monitor.
      
      Also, the PCM channel-map helper code is slightly modified to avoid
      the false-positive hit by this validation code, too.
      
      Link: https://lore.kernel.org/r/20200104083556.27789-1-tiwai@suse.deSigned-off-by: NTakashi Iwai <tiwai@suse.de>
      fbd3eb7f
  21. 03 1月, 2020 1 次提交
  22. 24 12月, 2019 1 次提交
    • T
      ALSA: ctl: allow TLV read operation for callback type of element in locked case · d61fe22c
      Takashi Sakamoto 提交于
      A design of ALSA control core allows applications to execute three
      operations for TLV feature; read, write and command. Furthermore, it
      allows driver developers to process the operations by two ways; allocated
      array or callback function. In the former, read operation is just allowed,
      thus developers uses the latter when device driver supports variety of
      models or the target model is expected to dynamically change information
      stored in TLV container.
      
      The core also allows applications to lock any element so that the other
      applications can't perform write operation to the element for element
      value and TLV information. When the element is locked, write and command
      operation for TLV information are prohibited as well as element value.
      Any read operation should be allowed in the case.
      
      At present, when an element has callback function for TLV information,
      TLV read operation returns EPERM if the element is locked. On the
      other hand, the read operation is success when an element has allocated
      array for TLV information. In both cases, read operation is success for
      element value expectedly.
      
      This commit fixes the bug. This change can be backported to v4.14
      kernel or later.
      Signed-off-by: NTakashi Sakamoto <o-takashi@sakamocchi.jp>
      Reviewed-by: NJaroslav Kysela <perex@perex.cz>
      Link: https://lore.kernel.org/r/20191223093347.15279-1-o-takashi@sakamocchi.jpSigned-off-by: NTakashi Iwai <tiwai@suse.de>
      d61fe22c
  23. 23 12月, 2019 1 次提交
  24. 31 5月, 2019 2 次提交
  25. 06 5月, 2019 1 次提交
    • K
      *: convert stream-like files from nonseekable_open -> stream_open · c5bf68fe
      Kirill Smelkov 提交于
      Using scripts/coccinelle/api/stream_open.cocci added in 10dce8af
      ("fs: stream_open - opener for stream-like files so that read and write
      can run simultaneously without deadlock"), search and convert to
      stream_open all in-kernel nonseekable_open users for which read and
      write actually do not depend on ppos and where there is no other methods
      in file_operations which assume @offset access.
      
      I've verified each generated change manually - that it is correct to convert -
      and each other nonseekable_open instance left - that it is either not correct
      to convert there, or that it is not converted due to current stream_open.cocci
      limitations. The script also does not convert files that should be valid to
      convert, but that currently have .llseek = noop_llseek or generic_file_llseek
      for unknown reason despite file being opened with nonseekable_open (e.g.
      drivers/input/mousedev.c)
      
      Among cases converted 14 were potentially vulnerable to read vs write deadlock
      (see details in 10dce8af):
      
      	drivers/char/pcmcia/cm4000_cs.c:1685:7-23: ERROR: cm4000_fops: .read() can deadlock .write(); change nonseekable_open -> stream_open to fix.
      	drivers/gnss/core.c:45:1-17: ERROR: gnss_fops: .read() can deadlock .write(); change nonseekable_open -> stream_open to fix.
      	drivers/hid/uhid.c:635:1-17: ERROR: uhid_fops: .read() can deadlock .write(); change nonseekable_open -> stream_open to fix.
      	drivers/infiniband/core/user_mad.c:988:1-17: ERROR: umad_fops: .read() can deadlock .write(); change nonseekable_open -> stream_open to fix.
      	drivers/input/evdev.c:527:1-17: ERROR: evdev_fops: .read() can deadlock .write(); change nonseekable_open -> stream_open to fix.
      	drivers/input/misc/uinput.c:401:1-17: ERROR: uinput_fops: .read() can deadlock .write(); change nonseekable_open -> stream_open to fix.
      	drivers/isdn/capi/capi.c:963:8-24: ERROR: capi_fops: .read() can deadlock .write(); change nonseekable_open -> stream_open to fix.
      	drivers/leds/uleds.c:77:1-17: ERROR: uleds_fops: .read() can deadlock .write(); change nonseekable_open -> stream_open to fix.
      	drivers/media/rc/lirc_dev.c:198:1-17: ERROR: lirc_fops: .read() can deadlock .write(); change nonseekable_open -> stream_open to fix.
      	drivers/s390/char/fs3270.c:488:1-17: ERROR: fs3270_fops: .read() can deadlock .write(); change nonseekable_open -> stream_open to fix.
      	drivers/usb/misc/ldusb.c:310:1-17: ERROR: ld_usb_fops: .read() can deadlock .write(); change nonseekable_open -> stream_open to fix.
      	drivers/xen/evtchn.c:667:8-24: ERROR: evtchn_fops: .read() can deadlock .write(); change nonseekable_open -> stream_open to fix.
      	net/batman-adv/icmp_socket.c:80:1-17: ERROR: batadv_fops: .read() can deadlock .write(); change nonseekable_open -> stream_open to fix.
      	net/rfkill/core.c:1146:8-24: ERROR: rfkill_fops: .read() can deadlock .write(); change nonseekable_open -> stream_open to fix.
      
      and the rest were just safe to convert to stream_open because their read and
      write do not use ppos at all and corresponding file_operations do not
      have methods that assume @offset file access(*):
      
      	arch/powerpc/platforms/52xx/mpc52xx_gpt.c:631:8-24: WARNING: mpc52xx_wdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	arch/powerpc/platforms/cell/spufs/file.c:591:8-24: WARNING: spufs_ibox_fops: .read() has stream semantic; safe to change nonseekable_open -> stream_open.
      	arch/powerpc/platforms/cell/spufs/file.c:591:8-24: WARNING: spufs_ibox_stat_fops: .read() has stream semantic; safe to change nonseekable_open -> stream_open.
      	arch/powerpc/platforms/cell/spufs/file.c:591:8-24: WARNING: spufs_mbox_fops: .read() has stream semantic; safe to change nonseekable_open -> stream_open.
      	arch/powerpc/platforms/cell/spufs/file.c:591:8-24: WARNING: spufs_mbox_stat_fops: .read() has stream semantic; safe to change nonseekable_open -> stream_open.
      	arch/powerpc/platforms/cell/spufs/file.c:591:8-24: WARNING: spufs_wbox_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	arch/powerpc/platforms/cell/spufs/file.c:591:8-24: WARNING: spufs_wbox_stat_fops: .read() has stream semantic; safe to change nonseekable_open -> stream_open.
      	arch/um/drivers/harddog_kern.c:88:8-24: WARNING: harddog_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	arch/x86/kernel/cpu/microcode/core.c:430:33-49: WARNING: microcode_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/char/ds1620.c:215:8-24: WARNING: ds1620_fops: .read() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/char/dtlk.c:301:1-17: WARNING: dtlk_fops: .read() and .write() have stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/char/ipmi/ipmi_watchdog.c:840:9-25: WARNING: ipmi_wdog_fops: .read() and .write() have stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/char/pcmcia/scr24x_cs.c:95:8-24: WARNING: scr24x_fops: .read() and .write() have stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/char/tb0219.c:246:9-25: WARNING: tb0219_fops: .read() and .write() have stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/firewire/nosy.c:306:8-24: WARNING: nosy_ops: .read() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/hwmon/fschmd.c:840:8-24: WARNING: watchdog_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/hwmon/w83793.c:1344:8-24: WARNING: watchdog_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/infiniband/core/ucma.c:1747:8-24: WARNING: ucma_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/infiniband/core/ucm.c:1178:8-24: WARNING: ucm_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/infiniband/core/uverbs_main.c:1086:8-24: WARNING: uverbs_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/input/joydev.c:282:1-17: WARNING: joydev_fops: .read() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/pci/switch/switchtec.c:393:1-17: WARNING: switchtec_fops: .read() and .write() have stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/platform/chrome/cros_ec_debugfs.c:135:8-24: WARNING: cros_ec_console_log_fops: .read() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/rtc/rtc-ds1374.c:470:9-25: WARNING: ds1374_wdt_fops: .read() and .write() have stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/rtc/rtc-m41t80.c:805:9-25: WARNING: wdt_fops: .read() and .write() have stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/s390/char/tape_char.c:293:2-18: WARNING: tape_fops: .read() and .write() have stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/s390/char/zcore.c:194:8-24: WARNING: zcore_reipl_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/s390/crypto/zcrypt_api.c:528:8-24: WARNING: zcrypt_fops: .read() and .write() have stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/spi/spidev.c:594:1-17: WARNING: spidev_fops: .read() and .write() have stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/staging/pi433/pi433_if.c:974:1-17: WARNING: pi433_fops: .read() and .write() have stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/acquirewdt.c:203:8-24: WARNING: acq_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/advantechwdt.c:202:8-24: WARNING: advwdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/alim1535_wdt.c:252:8-24: WARNING: ali_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/alim7101_wdt.c:217:8-24: WARNING: wdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/ar7_wdt.c:166:8-24: WARNING: ar7_wdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/at91rm9200_wdt.c:113:8-24: WARNING: at91wdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/ath79_wdt.c:135:8-24: WARNING: ath79_wdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/bcm63xx_wdt.c:119:8-24: WARNING: bcm63xx_wdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/cpu5wdt.c:143:8-24: WARNING: cpu5wdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/cpwd.c:397:8-24: WARNING: cpwd_fops: .read() and .write() have stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/eurotechwdt.c:319:8-24: WARNING: eurwdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/f71808e_wdt.c:528:8-24: WARNING: watchdog_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/gef_wdt.c:232:8-24: WARNING: gef_wdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/geodewdt.c:95:8-24: WARNING: geodewdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/ib700wdt.c:241:8-24: WARNING: ibwdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/ibmasr.c:326:8-24: WARNING: asr_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/indydog.c:80:8-24: WARNING: indydog_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/intel_scu_watchdog.c:307:8-24: WARNING: intel_scu_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/iop_wdt.c:104:8-24: WARNING: iop_wdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/it8712f_wdt.c:330:8-24: WARNING: it8712f_wdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/ixp4xx_wdt.c:68:8-24: WARNING: ixp4xx_wdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/ks8695_wdt.c:145:8-24: WARNING: ks8695wdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/m54xx_wdt.c:88:8-24: WARNING: m54xx_wdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/machzwd.c:336:8-24: WARNING: zf_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/mixcomwd.c:153:8-24: WARNING: mixcomwd_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/mtx-1_wdt.c:121:8-24: WARNING: mtx1_wdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/mv64x60_wdt.c:136:8-24: WARNING: mv64x60_wdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/nuc900_wdt.c:134:8-24: WARNING: nuc900wdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/nv_tco.c:164:8-24: WARNING: nv_tco_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/pc87413_wdt.c:289:8-24: WARNING: pc87413_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/pcwd.c:698:8-24: WARNING: pcwd_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/pcwd.c:737:8-24: WARNING: pcwd_temp_fops: .read() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/pcwd_pci.c:581:8-24: WARNING: pcipcwd_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/pcwd_pci.c:623:8-24: WARNING: pcipcwd_temp_fops: .read() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/pcwd_usb.c:488:8-24: WARNING: usb_pcwd_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/pcwd_usb.c:527:8-24: WARNING: usb_pcwd_temperature_fops: .read() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/pika_wdt.c:121:8-24: WARNING: pikawdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/pnx833x_wdt.c:119:8-24: WARNING: pnx833x_wdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/rc32434_wdt.c:153:8-24: WARNING: rc32434_wdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/rdc321x_wdt.c:145:8-24: WARNING: rdc321x_wdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/riowd.c:79:1-17: WARNING: riowd_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/sa1100_wdt.c:62:8-24: WARNING: sa1100dog_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/sbc60xxwdt.c:211:8-24: WARNING: wdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/sbc7240_wdt.c:139:8-24: WARNING: wdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/sbc8360.c:274:8-24: WARNING: sbc8360_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/sbc_epx_c3.c:81:8-24: WARNING: epx_c3_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/sbc_fitpc2_wdt.c:78:8-24: WARNING: fitpc2_wdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/sb_wdog.c:108:1-17: WARNING: sbwdog_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/sc1200wdt.c:181:8-24: WARNING: sc1200wdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/sc520_wdt.c:261:8-24: WARNING: wdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/sch311x_wdt.c:319:8-24: WARNING: sch311x_wdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/scx200_wdt.c:105:8-24: WARNING: scx200_wdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/smsc37b787_wdt.c:369:8-24: WARNING: wb_smsc_wdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/w83877f_wdt.c:227:8-24: WARNING: wdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/w83977f_wdt.c:301:8-24: WARNING: wdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/wafer5823wdt.c:200:8-24: WARNING: wafwdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/watchdog_dev.c:828:8-24: WARNING: watchdog_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/wdrtas.c:379:8-24: WARNING: wdrtas_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/wdrtas.c:445:8-24: WARNING: wdrtas_temp_fops: .read() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/wdt285.c:104:1-17: WARNING: watchdog_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/wdt977.c:276:8-24: WARNING: wdt977_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/wdt.c:424:8-24: WARNING: wdt_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/wdt.c:484:8-24: WARNING: wdt_temp_fops: .read() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/wdt_pci.c:464:8-24: WARNING: wdtpci_fops: .write() has stream semantic; safe to change nonseekable_open -> stream_open.
      	drivers/watchdog/wdt_pci.c:527:8-24: WARNING: wdtpci_temp_fops: .read() has stream semantic; safe to change nonseekable_open -> stream_open.
      	net/batman-adv/log.c:105:1-17: WARNING: batadv_log_fops: .read() has stream semantic; safe to change nonseekable_open -> stream_open.
      	sound/core/control.c:57:7-23: WARNING: snd_ctl_f_ops: .read() has stream semantic; safe to change nonseekable_open -> stream_open.
      	sound/core/rawmidi.c:385:7-23: WARNING: snd_rawmidi_f_ops: .read() and .write() have stream semantic; safe to change nonseekable_open -> stream_open.
      	sound/core/seq/seq_clientmgr.c:310:7-23: WARNING: snd_seq_f_ops: .read() and .write() have stream semantic; safe to change nonseekable_open -> stream_open.
      	sound/core/timer.c:1428:7-23: WARNING: snd_timer_f_ops: .read() has stream semantic; safe to change nonseekable_open -> stream_open.
      
      One can also recheck/review the patch via generating it with explanation comments included via
      
      	$ make coccicheck MODE=patch COCCI=scripts/coccinelle/api/stream_open.cocci SPFLAGS="-D explain"
      
      (*) This second group also contains cases with read/write deadlocks that
      stream_open.cocci don't yet detect, but which are still valid to convert to
      stream_open since ppos is not used. For example drivers/pci/switch/switchtec.c
      calls wait_for_completion_interruptible() in its .read, but stream_open.cocci
      currently detects only "wait_event*" as blocking.
      
      Cc: Michael Kerrisk <mtk.manpages@gmail.com>
      Cc: Yongzhi Pan <panyongzhi@gmail.com>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: David Vrabel <david.vrabel@citrix.com>
      Cc: Juergen Gross <jgross@suse.com>
      Cc: Miklos Szeredi <miklos@szeredi.hu>
      Cc: Tejun Heo <tj@kernel.org>
      Cc: Kirill Tkhai <ktkhai@virtuozzo.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Julia Lawall <Julia.Lawall@lip6.fr>
      Cc: Nikolaus Rath <Nikolaus@rath.org>
      Cc: Han-Wen Nienhuys <hanwen@google.com>
      Cc: Anatolij Gustschin <agust@denx.de>
      Cc: Jeff Dike <jdike@addtoit.com>
      Cc: Richard Weinberger <richard@nod.at>
      Cc: Anton Ivanov <anton.ivanov@cambridgegreys.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: "James R. Van Zandt" <jrv@vanzandt.mv.com>
      Cc: Corey Minyard <minyard@acm.org>
      Cc: Harald Welte <laforge@gnumonks.org>
      Acked-by: Lubomir Rintel <lkundrak@v3.sk> [scr24x_cs]
      Cc: Stefan Richter <stefanr@s5r6.in-berlin.de>
      Cc: Johan Hovold <johan@kernel.org>
      Cc: David Herrmann <dh.herrmann@googlemail.com>
      Cc: Jiri Kosina <jikos@kernel.org>
      Cc: Benjamin Tissoires <benjamin.tissoires@redhat.com>
      Cc: Jean Delvare <jdelvare@suse.com>
      Acked-by: Guenter Roeck <linux@roeck-us.net>	[watchdog/* hwmon/*]
      Cc: Rudolf Marek <r.marek@assembler.cz>
      Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
      Cc: Karsten Keil <isdn@linux-pingi.de>
      Cc: Jacek Anaszewski <jacek.anaszewski@gmail.com>
      Cc: Pavel Machek <pavel@ucw.cz>
      Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
      Cc: Kurt Schwemmer <kurt.schwemmer@microsemi.com>
      Acked-by: Logan Gunthorpe <logang@deltatee.com> [drivers/pci/switch/switchtec]
      Acked-by: Bjorn Helgaas <bhelgaas@google.com> [drivers/pci/switch/switchtec]
      Cc: Benson Leung <bleung@chromium.org>
      Acked-by: Enric Balletbo i Serra <enric.balletbo@collabora.com> [platform/chrome]
      Cc: Alessandro Zummo <a.zummo@towertech.it>
      Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com> [rtc/*]
      Cc: Mark Brown <broonie@kernel.org>
      Cc: Wim Van Sebroeck <wim@linux-watchdog.org>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: bcm-kernel-feedback-list@broadcom.com
      Cc: Wan ZongShun <mcuos.com@gmail.com>
      Cc: Zwane Mwaikambo <zwanem@gmail.com>
      Cc: Marek Lindner <mareklindner@neomailbox.ch>
      Cc: Simon Wunderlich <sw@simonwunderlich.de>
      Cc: Antonio Quartulli <a@unstable.cc>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Johannes Berg <johannes@sipsolutions.net>
      Cc: Jaroslav Kysela <perex@perex.cz>
      Cc: Takashi Iwai <tiwai@suse.com>
      Signed-off-by: NKirill Smelkov <kirr@nexedi.com>
      c5bf68fe
  26. 25 11月, 2018 2 次提交
    • T
      ALSA: control: Consolidate helpers for adding and replacing ctl elements · 3103c08f
      Takashi Iwai 提交于
      Both snd_ctl_add() and snd_ctl_replace() process the things in a
      fairly similar way, and indeed the most of the codes can be unified.
      
      This patch is a refactoring to consolidate the both functions to call
      a single helper with an extra "mode" argument.  There should be no
      functional difference, except for one additional sanity check applied
      now to snd_ctl_replace() (which was rather overlooking, IMO), too.
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      3103c08f
    • T
      ALSA: control: Fix race between adding and removing a user element · e1a7bfe3
      Takashi Iwai 提交于
      The procedure for adding a user control element has some window opened
      for race against the concurrent removal of a user element.  This was
      caught by syzkaller, hitting a KASAN use-after-free error.
      
      This patch addresses the bug by wrapping the whole procedure to add a
      user control element with the card->controls_rwsem, instead of only
      around the increment of card->user_ctl_count.
      
      This required a slight code refactoring, too.  The function
      snd_ctl_add() is split to two parts: a core function to add the
      control element and a part calling it.  The former is called from the
      function for adding a user control element inside the controls_rwsem.
      
      One change to be noted is that snd_ctl_notify() for adding a control
      element gets called inside the controls_rwsem as well while it was
      called outside the rwsem.  But this should be OK, as snd_ctl_notify()
      takes another (finer) rwlock instead of rwsem, and the call of
      snd_ctl_notify() inside rwsem is already done in another code path.
      
      Reported-by: syzbot+dc09047bce3820621ba2@syzkaller.appspotmail.com
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      e1a7bfe3
  27. 23 4月, 2018 1 次提交
  28. 28 2月, 2018 2 次提交
    • R
      ALSA: control: Fix a bunch of whitespace errors · dd5f313b
      Richard Fitzgerald 提交于
      Remove a bunch of trailing whitespace errors. They are
      fairly annoying if you have your editor set to strip trailing
      whitespace because you find you've introduced more changes
      than you were trying to make.
      Signed-off-by: NRichard Fitzgerald <rf@opensource.cirrus.com>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      dd5f313b
    • R
      ALSA: control: Fix memory corruption risk in snd_ctl_elem_read · 5a23699a
      Richard Fitzgerald 提交于
      The patch "ALSA: control: code refactoring for ELEM_READ/ELEM_WRITE
      operations" introduced a potential for kernel memory corruption due
      to an incorrect if statement allowing non-readable controls to fall
      through and call the get function. For TLV controls a driver can omit
      SNDRV_CTL_ELEM_ACCESS_READ to ensure that only the TLV get function
      can be called. Instead the normal get() can be invoked unexpectedly
      and as the driver expects that this will only be called for controls
      <= 512 bytes, potentially try to copy >512 bytes into the 512 byte
      return array, so corrupting kernel memory.
      
      The problem is an attempt to refactor the snd_ctl_elem_read function
      to invert the logic so that it conditionally aborted if the control
      is unreadable instead of conditionally executing. But the if statement
      wasn't inverted correctly.
      
      The correct inversion of
      
          if (a && !b)
      
      is
          if (!a || b)
      
      Fixes: becf9e5d ("ALSA: control: code refactoring for ELEM_READ/ELEM_WRITE operations")
      Signed-off-by: NRichard Fitzgerald <rf@opensource.cirrus.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      5a23699a
  29. 12 2月, 2018 1 次提交
    • L
      vfs: do bulk POLL* -> EPOLL* replacement · a9a08845
      Linus Torvalds 提交于
      This is the mindless scripted replacement of kernel use of POLL*
      variables as described by Al, done by this script:
      
          for V in IN OUT PRI ERR RDNORM RDBAND WRNORM WRBAND HUP RDHUP NVAL MSG; do
              L=`git grep -l -w POLL$V | grep -v '^t' | grep -v /um/ | grep -v '^sa' | grep -v '/poll.h$'|grep -v '^D'`
              for f in $L; do sed -i "-es/^\([^\"]*\)\(\<POLL$V\>\)/\\1E\\2/" $f; done
          done
      
      with de-mangling cleanups yet to come.
      
      NOTE! On almost all architectures, the EPOLL* constants have the same
      values as the POLL* constants do.  But they keyword here is "almost".
      For various bad reasons they aren't the same, and epoll() doesn't
      actually work quite correctly in some cases due to this on Sparc et al.
      
      The next patch from Al will sort out the final differences, and we
      should be all done.
      Scripted-by: NAl Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      a9a08845
  30. 20 1月, 2018 1 次提交