12 May, 2022

3 commits

  • commit a7ecbe92b9243edbe94772f6f2c854e4142a3345 upstream.

    card->local_node and card->bm_retries are both always accessed under
    card->lock.
    fw_core_handle_bus_reset has a check whose condition depends on
    card->local_node and whose body writes to card->bm_retries.
    Both of these accesses are not under card->lock. Move the lock acquiring
    of card->lock to before this check such that these accesses do happen
    when card->lock is held.
    fw_destroy_nodes is called inside the check.
    Since fw_destroy_nodes already acquires card->lock inside its function
    body, move this out to the callsites of fw_destroy_nodes.
    Also add a comment to indicate which locking is necessary when calling
    fw_destroy_nodes.

    Cc:
    Signed-off-by: Niels Dossche
    Signed-off-by: Takashi Sakamoto
    Link: https://lore.kernel.org/r/20220409041243.603210-4-o-takashi@sakamocchi.jp
    Signed-off-by: Takashi Iwai
    Signed-off-by: Greg Kroah-Hartman

    Niels Dossche
     
  • commit 9423973869bd4632ffe669f950510c49296656e0 upstream.

    When list_for_each_entry() completes the iteration over the whole list
    without breaking the loop, the iterator value will be a bogus pointer
    computed based on the head element.

    While it is safe to use the pointer to determine if it was computed
    based on the head element, either with list_entry_is_head() or
    &pos->member == head, using the iterator variable after the loop should
    be avoided.

    In preparation to limit the scope of a list iterator to the list
    traversal loop, use a dedicated pointer to point to the found element [1].

    Link: https://lore.kernel.org/all/CAHk-=wgRr_D8CB-D9Kg-c=EHreAsk5SqXPwr9Y7k9sA6cWXJ6w@mail.gmail.com/ [1]
    Cc:
    Signed-off-by: Jakob Koschel
    Signed-off-by: Takashi Sakamoto
    Link: https://lore.kernel.org/r/20220409041243.603210-3-o-takashi@sakamocchi.jp
    Signed-off-by: Takashi Iwai
    Signed-off-by: Greg Kroah-Hartman

    Jakob Koschel
     
  • commit b7c81f80246fac44077166f3e07103affe6db8ff upstream.

    &e->event and e point to the same address, and &e->event could
    be freed in queue_event. So there is a potential uaf issue if
    we dereference e after calling queue_event(). Fix this by adding
    a temporary variable to maintain e->client in advance, this can
    avoid the potential uaf issue.

    Cc:
    Signed-off-by: Chengfeng Ye
    Signed-off-by: Takashi Sakamoto
    Link: https://lore.kernel.org/r/20220409041243.603210-2-o-takashi@sakamocchi.jp
    Signed-off-by: Takashi Iwai
    Signed-off-by: Greg Kroah-Hartman

    Chengfeng Ye
     

12 Sep, 2021

1 commit

  • Pull firewire updates from Stefan Richter:

    - Migrate the bus snooper driver 'nosy' from PCI to DMA API

    - Small janitorial cleanup in the IPv4/v6-over-1394 driver

    [ The 'nosy' change already come in as a different commit through Greg
    KH in the misc tree back in the previous merge window, so only the
    cleanup ends up being new to 5.15 - Linus ]

    * tag 'firewire-update' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394:
    firewire: nosy: switch from 'pci_' to 'dma_' API
    firewire: net: remove unused variable 'guid'

    Linus Torvalds
     

21 Jul, 2021

1 commit

  • The driver core ignores the return value of this callback because there
    is only little it can do when a device disappears.

    This is the final bit of a long lasting cleanup quest where several
    buses were converted to also return void from their remove callback.
    Additionally some resource leaks were fixed that were caused by drivers
    returning an error code in the expectation that the driver won't go
    away.

    With struct bus_type::remove returning void it's prevented that newly
    implemented buses return an ignored error code and so don't anticipate
    wrong expectations for driver authors.

    Reviewed-by: Tom Rix (For fpga)
    Reviewed-by: Mathieu Poirier
    Reviewed-by: Cornelia Huck (For drivers/s390 and drivers/vfio)
    Acked-by: Russell King (Oracle) (For ARM, Amba and related parts)
    Acked-by: Mark Brown
    Acked-by: Chen-Yu Tsai (for sunxi-rsb)
    Acked-by: Pali Rohár
    Acked-by: Mauro Carvalho Chehab (for media)
    Acked-by: Hans de Goede (For drivers/platform)
    Acked-by: Alexandre Belloni
    Acked-By: Vinod Koul
    Acked-by: Juergen Gross (For xen)
    Acked-by: Lee Jones (For mfd)
    Acked-by: Johannes Thumshirn (For mcb)
    Acked-by: Johan Hovold
    Acked-by: Srinivas Kandagatla (For slimbus)
    Acked-by: Kirti Wankhede (For vfio)
    Acked-by: Maximilian Luz
    Acked-by: Heikki Krogerus (For ulpi and typec)
    Acked-by: Samuel Iglesias Gonsálvez (For ipack)
    Acked-by: Geoff Levand (For ps3)
    Acked-by: Yehezkel Bernat (For thunderbolt)
    Acked-by: Alexander Shishkin (For intel_th)
    Acked-by: Dominik Brodowski (For pcmcia)
    Acked-by: Rafael J. Wysocki (For ACPI)
    Acked-by: Bjorn Andersson (rpmsg and apr)
    Acked-by: Srinivas Pandruvada (For intel-ish-hid)
    Acked-by: Dan Williams (For CXL, DAX, and NVDIMM)
    Acked-by: William Breathitt Gray (For isa)
    Acked-by: Stefan Richter (For firewire)
    Acked-by: Benjamin Tissoires (For hid)
    Acked-by: Thorsten Scherer (For siox)
    Acked-by: Sven Van Asbroeck (For anybuss)
    Acked-by: Ulf Hansson (For MMC)
    Acked-by: Wolfram Sang # for I2C
    Acked-by: Sudeep Holla
    Acked-by: Geert Uytterhoeven
    Acked-by: Dmitry Torokhov
    Acked-by: Finn Thain
    Signed-off-by: Uwe Kleine-König
    Link: https://lore.kernel.org/r/20210713193522.1770306-6-u.kleine-koenig@pengutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Uwe Kleine-König
     

06 Jul, 2021

3 commits

  • Pull char / misc driver updates from Greg KH:
    "Here is the big set of char / misc and other driver subsystem updates
    for 5.14-rc1. Included in here are:

    - habanalabs driver updates

    - fsl-mc driver updates

    - comedi driver updates

    - fpga driver updates

    - extcon driver updates

    - interconnect driver updates

    - mei driver updates

    - nvmem driver updates

    - phy driver updates

    - pnp driver updates

    - soundwire driver updates

    - lots of other tiny driver updates for char and misc drivers

    This is looking more and more like the "various driver subsystems
    mushed together" tree...

    All of these have been in linux-next for a while with no reported
    issues"

    * tag 'char-misc-5.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: (292 commits)
    mcb: Use DEFINE_RES_MEM() helper macro and fix the end address
    PNP: moved EXPORT_SYMBOL so that it immediately followed its function/variable
    bus: mhi: pci-generic: Add missing 'pci_disable_pcie_error_reporting()' calls
    bus: mhi: Wait for M2 state during system resume
    bus: mhi: core: Fix power down latency
    intel_th: Wait until port is in reset before programming it
    intel_th: msu: Make contiguous buffers uncached
    intel_th: Remove an unused exit point from intel_th_remove()
    stm class: Spelling fix
    nitro_enclaves: Set Bus Master for the NE PCI device
    misc: ibmasm: Modify matricies to matrices
    misc: vmw_vmci: return the correct errno code
    siox: Simplify error handling via dev_err_probe()
    fpga: machxo2-spi: Address warning about unused variable
    lkdtm/heap: Add init_on_alloc tests
    selftests/lkdtm: Enable various testable CONFIGs
    lkdtm: Add CONFIG hints in errors where possible
    lkdtm: Enable DOUBLE_FAULT on all architectures
    lkdtm/heap: Add vmalloc linear overflow test
    lkdtm/bugs: XFAIL UNALIGNED_LOAD_STORE_WRITE
    ...

    Linus Torvalds
     
  • The wrappers in include/linux/pci-dma-compat.h should go away.

    The patch has been generated with the coccinelle script below and has been
    hand modified to replace GFP_ with a correct flag.
    It has been compile tested.

    When memory is allocated in 'add_card()', GFP_KERNEL can be used because
    this flag is already used a few lines above and no lock is taken in the
    between.

    While at it, also remove some useless casting.

    @@ @@
    - PCI_DMA_BIDIRECTIONAL
    + DMA_BIDIRECTIONAL

    @@ @@
    - PCI_DMA_TODEVICE
    + DMA_TO_DEVICE

    @@ @@
    - PCI_DMA_FROMDEVICE
    + DMA_FROM_DEVICE

    @@ @@
    - PCI_DMA_NONE
    + DMA_NONE

    @@
    expression e1, e2, e3;
    @@
    - pci_alloc_consistent(e1, e2, e3)
    + dma_alloc_coherent(&e1->dev, e2, e3, GFP_)

    @@
    expression e1, e2, e3;
    @@
    - pci_zalloc_consistent(e1, e2, e3)
    + dma_alloc_coherent(&e1->dev, e2, e3, GFP_)

    @@
    expression e1, e2, e3, e4;
    @@
    - pci_free_consistent(e1, e2, e3, e4)
    + dma_free_coherent(&e1->dev, e2, e3, e4)

    @@
    expression e1, e2, e3, e4;
    @@
    - pci_map_single(e1, e2, e3, e4)
    + dma_map_single(&e1->dev, e2, e3, e4)

    @@
    expression e1, e2, e3, e4;
    @@
    - pci_unmap_single(e1, e2, e3, e4)
    + dma_unmap_single(&e1->dev, e2, e3, e4)

    @@
    expression e1, e2, e3, e4, e5;
    @@
    - pci_map_page(e1, e2, e3, e4, e5)
    + dma_map_page(&e1->dev, e2, e3, e4, e5)

    @@
    expression e1, e2, e3, e4;
    @@
    - pci_unmap_page(e1, e2, e3, e4)
    + dma_unmap_page(&e1->dev, e2, e3, e4)

    @@
    expression e1, e2, e3, e4;
    @@
    - pci_map_sg(e1, e2, e3, e4)
    + dma_map_sg(&e1->dev, e2, e3, e4)

    @@
    expression e1, e2, e3, e4;
    @@
    - pci_unmap_sg(e1, e2, e3, e4)
    + dma_unmap_sg(&e1->dev, e2, e3, e4)

    @@
    expression e1, e2, e3, e4;
    @@
    - pci_dma_sync_single_for_cpu(e1, e2, e3, e4)
    + dma_sync_single_for_cpu(&e1->dev, e2, e3, e4)

    @@
    expression e1, e2, e3, e4;
    @@
    - pci_dma_sync_single_for_device(e1, e2, e3, e4)
    + dma_sync_single_for_device(&e1->dev, e2, e3, e4)

    @@
    expression e1, e2, e3, e4;
    @@
    - pci_dma_sync_sg_for_cpu(e1, e2, e3, e4)
    + dma_sync_sg_for_cpu(&e1->dev, e2, e3, e4)

    @@
    expression e1, e2, e3, e4;
    @@
    - pci_dma_sync_sg_for_device(e1, e2, e3, e4)
    + dma_sync_sg_for_device(&e1->dev, e2, e3, e4)

    @@
    expression e1, e2;
    @@
    - pci_dma_mapping_error(e1, e2)
    + dma_mapping_error(&e1->dev, e2)

    @@
    expression e1, e2;
    @@
    - pci_set_dma_mask(e1, e2)
    + dma_set_mask(&e1->dev, e2)

    @@
    expression e1, e2;
    @@
    - pci_set_consistent_dma_mask(e1, e2)
    + dma_set_coherent_mask(&e1->dev, e2)

    Signed-off-by: Christophe JAILLET
    Signed-off-by: Stefan Richter

    Christophe JAILLET
     
  • GCC reports the following warning with W=1:

    drivers/firewire/net.c:493:9: warning:
    variable ‘guid’ set but not used [-Wunused-but-set-variable]
    493 | __be64 guid;
    | ^~~~

    This variable is not used anymore since commit 6752c8db8e0c ("firewire
    net, ipv4 arp: Extend hardware address and remove driver-level packet
    inspection."). Remove it to fix the warning.

    Signed-off-by: Pu Lehui
    Signed-off-by: Stefan Richter

    Pu Lehui
     

15 Jun, 2021

1 commit

  • The wrappers in include/linux/pci-dma-compat.h should go away.

    The patch has been generated with the coccinelle script below and has been
    hand modified to replace GFP_ with a correct flag.
    It has been compile tested.

    When memory is allocated in 'add_card()', GFP_KERNEL can be used because
    this flag is already used a few lines above and no lock is taken in the
    between.

    While at it, also remove some useless casting.

    @@ @@
    - PCI_DMA_BIDIRECTIONAL
    + DMA_BIDIRECTIONAL

    @@ @@
    - PCI_DMA_TODEVICE
    + DMA_TO_DEVICE

    @@ @@
    - PCI_DMA_FROMDEVICE
    + DMA_FROM_DEVICE

    @@ @@
    - PCI_DMA_NONE
    + DMA_NONE

    @@
    expression e1, e2, e3;
    @@
    - pci_alloc_consistent(e1, e2, e3)
    + dma_alloc_coherent(&e1->dev, e2, e3, GFP_)

    @@
    expression e1, e2, e3;
    @@
    - pci_zalloc_consistent(e1, e2, e3)
    + dma_alloc_coherent(&e1->dev, e2, e3, GFP_)

    @@
    expression e1, e2, e3, e4;
    @@
    - pci_free_consistent(e1, e2, e3, e4)
    + dma_free_coherent(&e1->dev, e2, e3, e4)

    @@
    expression e1, e2, e3, e4;
    @@
    - pci_map_single(e1, e2, e3, e4)
    + dma_map_single(&e1->dev, e2, e3, e4)

    @@
    expression e1, e2, e3, e4;
    @@
    - pci_unmap_single(e1, e2, e3, e4)
    + dma_unmap_single(&e1->dev, e2, e3, e4)

    @@
    expression e1, e2, e3, e4, e5;
    @@
    - pci_map_page(e1, e2, e3, e4, e5)
    + dma_map_page(&e1->dev, e2, e3, e4, e5)

    @@
    expression e1, e2, e3, e4;
    @@
    - pci_unmap_page(e1, e2, e3, e4)
    + dma_unmap_page(&e1->dev, e2, e3, e4)

    @@
    expression e1, e2, e3, e4;
    @@
    - pci_map_sg(e1, e2, e3, e4)
    + dma_map_sg(&e1->dev, e2, e3, e4)

    @@
    expression e1, e2, e3, e4;
    @@
    - pci_unmap_sg(e1, e2, e3, e4)
    + dma_unmap_sg(&e1->dev, e2, e3, e4)

    @@
    expression e1, e2, e3, e4;
    @@
    - pci_dma_sync_single_for_cpu(e1, e2, e3, e4)
    + dma_sync_single_for_cpu(&e1->dev, e2, e3, e4)

    @@
    expression e1, e2, e3, e4;
    @@
    - pci_dma_sync_single_for_device(e1, e2, e3, e4)
    + dma_sync_single_for_device(&e1->dev, e2, e3, e4)

    @@
    expression e1, e2, e3, e4;
    @@
    - pci_dma_sync_sg_for_cpu(e1, e2, e3, e4)
    + dma_sync_sg_for_cpu(&e1->dev, e2, e3, e4)

    @@
    expression e1, e2, e3, e4;
    @@
    - pci_dma_sync_sg_for_device(e1, e2, e3, e4)
    + dma_sync_sg_for_device(&e1->dev, e2, e3, e4)

    @@
    expression e1, e2;
    @@
    - pci_dma_mapping_error(e1, e2)
    + dma_mapping_error(&e1->dev, e2)

    @@
    expression e1, e2;
    @@
    - pci_set_dma_mask(e1, e2)
    + dma_set_mask(&e1->dev, e2)

    @@
    expression e1, e2;
    @@
    - pci_set_consistent_dma_mask(e1, e2)
    + dma_set_coherent_mask(&e1->dev, e2)

    Signed-off-by: Christophe JAILLET
    Link: https://lore.kernel.org/r/e1d7fa558f31abf294659a9d4edcc1e4fc065fab.1623590706.git.christophe.jaillet@wanadoo.fr
    Signed-off-by: Greg Kroah-Hartman

    Christophe JAILLET
     

18 May, 2021

1 commit


27 Apr, 2021

1 commit

  • Pull irq updates from Thomas Gleixner:
    "The usual updates from the irq departement:

    Core changes:

    - Provide IRQF_NO_AUTOEN as a flag for request*_irq() so drivers can
    be cleaned up which either use a seperate mechanism to prevent
    auto-enable at request time or have a racy mechanism which disables
    the interrupt right after request.

    - Get rid of the last usage of irq_create_identity_mapping() and
    remove the interface.

    - An overhaul of tasklet_disable().

    Most usage sites of tasklet_disable() are in task context and
    usually in cleanup, teardown code pathes. tasklet_disable()
    spinwaits for a tasklet which is currently executed. That's not
    only a problem for PREEMPT_RT where this can lead to a live lock
    when the disabling task preempts the softirq thread. It's also
    problematic in context of virtualization when the vCPU which runs
    the tasklet is scheduled out and the disabling code has to spin
    wait until it's scheduled back in.

    There are a few code pathes which invoke tasklet_disable() from
    non-sleepable context. For these a new disable variant which still
    spinwaits is provided which allows to switch tasklet_disable() to a
    sleep wait mechanism. For the atomic use cases this does not solve
    the live lock issue on PREEMPT_RT. That is mitigated by blocking on
    the RT specific softirq lock.

    - The PREEMPT_RT specific implementation of softirq processing and
    local_bh_disable/enable().

    On RT enabled kernels soft interrupt processing happens always in
    task context and all interrupt handlers, which are not explicitly
    marked to be invoked in hard interrupt context are forced into task
    context as well. This allows to protect against softirq processing
    with a per CPU lock, which in turn allows to make BH disabled
    regions preemptible.

    Most of the softirq handling code is still shared. The RT/non-RT
    specific differences are addressed with a set of inline functions
    which provide the context specific functionality. The
    local_bh_disable() / local_bh_enable() mechanism are obviously
    seperate.

    - The usual set of small improvements and cleanups

    Driver changes:

    - New drivers for Nuvoton WPCM450 and DT 79rc3243x interrupt
    controllers

    - Extended functionality for MStar, STM32 and SC7280 irq chips

    - Enhanced robustness for ARM GICv3/4.1 drivers

    - The usual set of cleanups and improvements all over the place"

    * tag 'irq-core-2021-04-26' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (53 commits)
    irqchip/xilinx: Expose Kconfig option for Zynq/ZynqMP
    irqchip/gic-v3: Do not enable irqs when handling spurious interrups
    dt-bindings: interrupt-controller: Add IDT 79RC3243x Interrupt Controller
    irqchip: Add support for IDT 79rc3243x interrupt controller
    irqdomain: Drop references to recusive irqdomain setup
    irqdomain: Get rid of irq_create_strict_mappings()
    irqchip/jcore-aic: Kill use of irq_create_strict_mappings()
    ARM: PXA: Kill use of irq_create_strict_mappings()
    irqchip/gic-v4.1: Disable vSGI upon (GIC CPUIF < v4.1) detection
    irqchip/tb10x: Use 'fallthrough' to eliminate a warning
    genirq: Reduce irqdebug cacheline bouncing
    kernel: Initialize cpumask before parsing
    irqchip/wpcm450: Drop COMPILE_TEST
    irqchip/irq-mst: Support polarity configuration
    irqchip: Add driver for WPCM450 interrupt controller
    dt-bindings: interrupt-controller: Add nuvoton, wpcm450-aic
    dt-bindings: qcom,pdc: Add compatible for sc7280
    irqchip/stm32: Add usart instances exti direct event support
    irqchip/gic-v3: Fix OF_BAD_ADDR error handling
    irqchip/sifive-plic: Mark two global variables __ro_after_init
    ...

    Linus Torvalds
     

05 Apr, 2021

1 commit

  • For each device, the nosy driver allocates a pcilynx structure.
    A use-after-free might happen in the following scenario:

    1. Open nosy device for the first time and call ioctl with command
    NOSY_IOC_START, then a new client A will be malloced and added to
    doubly linked list.
    2. Open nosy device for the second time and call ioctl with command
    NOSY_IOC_START, then a new client B will be malloced and added to
    doubly linked list.
    3. Call ioctl with command NOSY_IOC_START for client A, then client A
    will be readded to the doubly linked list. Now the doubly linked
    list is messed up.
    4. Close the first nosy device and nosy_release will be called. In
    nosy_release, client A will be unlinked and freed.
    5. Close the second nosy device, and client A will be referenced,
    resulting in UAF.

    The root cause of this bug is that the element in the doubly linked list
    is reentered into the list.

    Fix this bug by adding a check before inserting a client. If a client
    is already in the linked list, don't insert it.

    The following KASAN report reveals it:

    BUG: KASAN: use-after-free in nosy_release+0x1ea/0x210
    Write of size 8 at addr ffff888102ad7360 by task poc
    CPU: 3 PID: 337 Comm: poc Not tainted 5.12.0-rc5+ #6
    Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.12.0-59-gc9ba5276e321-prebuilt.qemu.org 04/01/2014
    Call Trace:
    nosy_release+0x1ea/0x210
    __fput+0x1e2/0x840
    task_work_run+0xe8/0x180
    exit_to_user_mode_prepare+0x114/0x120
    syscall_exit_to_user_mode+0x1d/0x40
    entry_SYSCALL_64_after_hwframe+0x44/0xae

    Allocated by task 337:
    nosy_open+0x154/0x4d0
    misc_open+0x2ec/0x410
    chrdev_open+0x20d/0x5a0
    do_dentry_open+0x40f/0xe80
    path_openat+0x1cf9/0x37b0
    do_filp_open+0x16d/0x390
    do_sys_openat2+0x11d/0x360
    __x64_sys_open+0xfd/0x1a0
    do_syscall_64+0x33/0x40
    entry_SYSCALL_64_after_hwframe+0x44/0xae

    Freed by task 337:
    kfree+0x8f/0x210
    nosy_release+0x158/0x210
    __fput+0x1e2/0x840
    task_work_run+0xe8/0x180
    exit_to_user_mode_prepare+0x114/0x120
    syscall_exit_to_user_mode+0x1d/0x40
    entry_SYSCALL_64_after_hwframe+0x44/0xae

    The buggy address belongs to the object at ffff888102ad7300 which belongs to the cache kmalloc-128 of size 128
    The buggy address is located 96 bytes inside of 128-byte region [ffff888102ad7300, ffff888102ad7380)

    [ Modified to use 'list_empty()' inside proper lock - Linus ]

    Link: https://lore.kernel.org/lkml/1617433116-5930-1-git-send-email-zheyuma97@gmail.com/
    Reported-and-tested-by: 马哲宇 (Zheyu Ma)
    Signed-off-by: Zheyu Ma
    Cc: Greg Kroah-Hartman
    Cc: Stefan Richter
    Signed-off-by: Linus Torvalds

    Zheyu Ma
     

17 Mar, 2021

1 commit

  • tasklet_disable() is invoked in several places. Some of them are in atomic
    context which prevents a conversion of tasklet_disable() to a sleepable
    function.

    The atomic callchains are:

    ar_context_tasklet()
    ohci_cancel_packet()
    tasklet_disable()

    ...
    ohci_flush_iso_completions()
    tasklet_disable()

    The invocation of tasklet_disable() from at_context_flush() is always in
    preemptible context.

    Use tasklet_disable_in_atomic() for the two invocations in
    ohci_cancel_packet() and ohci_flush_iso_completions().

    Signed-off-by: Sebastian Andrzej Siewior
    Signed-off-by: Thomas Gleixner
    Acked-by: Peter Zijlstra (Intel)
    Link: https://lore.kernel.org/r/20210309084242.616379058@linutronix.de

    Sebastian Andrzej Siewior
     

09 Feb, 2021

1 commit

  • struct fw_driver::remove returns void, still the comma expression's value
    is zero. This is harder to parse than necessary, so replace the single
    expression by two easier ones.

    Signed-off-by: Uwe Kleine-König
    Link: https://lore.kernel.org/r/20210126221444.713837-1-uwe@kleine-koenig.org
    Signed-off-by: Greg Kroah-Hartman

    Uwe Kleine-König
     

25 Sep, 2020

1 commit


24 Aug, 2020

1 commit

  • Replace the existing /* fall through */ comments and its variants with
    the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary
    fall-through markings when it is the case.

    [1] https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through

    Signed-off-by: Gustavo A. R. Silva

    Gustavo A. R. Silva
     

17 Jul, 2020

1 commit

  • Using uninitialized_var() is dangerous as it papers over real bugs[1]
    (or can in the future), and suppresses unrelated compiler warnings
    (e.g. "unused variable"). If the compiler thinks it is uninitialized,
    either simply initialize the variable or make compiler changes.

    In preparation for removing[2] the[3] macro[4], remove all remaining
    needless uses with the following script:

    git grep '\buninitialized_var\b' | cut -d: -f1 | sort -u | \
    xargs perl -pi -e \
    's/\buninitialized_var\(([^\)]+)\)/\1/g;
    s:\s*/\* (GCC be quiet|to make compiler happy) \*/$::g;'

    drivers/video/fbdev/riva/riva_hw.c was manually tweaked to avoid
    pathological white-space.

    No outstanding warnings were found building allmodconfig with GCC 9.3.0
    for x86_64, i386, arm64, arm, powerpc, powerpc64le, s390x, mips, sparc64,
    alpha, and m68k.

    [1] https://lore.kernel.org/lkml/20200603174714.192027-1-glider@google.com/
    [2] https://lore.kernel.org/lkml/CA+55aFw+Vbj0i=1TGqCR5vQkCzWJ0QxK6CernOU6eedsudAixw@mail.gmail.com/
    [3] https://lore.kernel.org/lkml/CA+55aFwgbgqhbp1fkxvRKEpzyR5J8n1vKT1VZdz9knmPuXhOeg@mail.gmail.com/
    [4] https://lore.kernel.org/lkml/CA+55aFz2500WfbKXAx8s67wrm9=yVJu65TpLgN_ybYNv0VEOKA@mail.gmail.com/

    Reviewed-by: Leon Romanovsky # drivers/infiniband and mlx4/mlx5
    Acked-by: Jason Gunthorpe # IB
    Acked-by: Kalle Valo # wireless drivers
    Reviewed-by: Chao Yu # erofs
    Signed-off-by: Kees Cook

    Kees Cook
     

16 Jun, 2020

1 commit

  • There is a regular need in the kernel to provide a way to declare having a
    dynamically sized set of trailing elements in a structure. Kernel code should
    always use “flexible array members”[1] for these cases. The older style of
    one-element or zero-length arrays should no longer be used[2].

    [1] https://en.wikipedia.org/wiki/Flexible_array_member
    [2] https://github.com/KSPP/linux/issues/21

    Signed-off-by: Gustavo A. R. Silva

    Gustavo A. R. Silva
     

23 Apr, 2020

1 commit


06 Jan, 2020

1 commit


03 Dec, 2019

1 commit


02 Dec, 2019

1 commit

  • Pull removal of most of fs/compat_ioctl.c from Arnd Bergmann:
    "As part of the cleanup of some remaining y2038 issues, I came to
    fs/compat_ioctl.c, which still has a couple of commands that need
    support for time64_t.

    In completely unrelated work, I spent time on cleaning up parts of
    this file in the past, moving things out into drivers instead.

    After Al Viro reviewed an earlier version of this series and did a lot
    more of that cleanup, I decided to try to completely eliminate the
    rest of it and move it all into drivers.

    This series incorporates some of Al's work and many patches of my own,
    but in the end stops short of actually removing the last part, which
    is the scsi ioctl handlers. I have patches for those as well, but they
    need more testing or possibly a rewrite"

    * tag 'compat-ioctl-5.5' of git://git.kernel.org:/pub/scm/linux/kernel/git/arnd/playground: (42 commits)
    scsi: sd: enable compat ioctls for sed-opal
    pktcdvd: add compat_ioctl handler
    compat_ioctl: move SG_GET_REQUEST_TABLE handling
    compat_ioctl: ppp: move simple commands into ppp_generic.c
    compat_ioctl: handle PPPIOCGIDLE for 64-bit time_t
    compat_ioctl: move PPPIOCSCOMPRESS to ppp_generic
    compat_ioctl: unify copy-in of ppp filters
    tty: handle compat PPP ioctls
    compat_ioctl: move SIOCOUTQ out of compat_ioctl.c
    compat_ioctl: handle SIOCOUTQNSD
    af_unix: add compat_ioctl support
    compat_ioctl: reimplement SG_IO handling
    compat_ioctl: move WDIOC handling into wdt drivers
    fs: compat_ioctl: move FITRIM emulation into file systems
    gfs2: add compat_ioctl support
    compat_ioctl: remove unused convert_in_user macro
    compat_ioctl: remove last RAID handling code
    compat_ioctl: remove /dev/raw ioctl translation
    compat_ioctl: remove PCI ioctl translation
    compat_ioctl: remove joystick ioctl translation
    ...

    Linus Torvalds
     

14 Nov, 2019

2 commits

  • Commit 22660db89262 turned fw_iso_buffer_map_vma into a one-liner.
    There is no need to keep this in the core-iso.c collection of buffer
    management functions; put it inline into the sole user, the character
    device file driver.

    Signed-off-by: Stefan Richter

    Stefan Richter
     
  • The ohci driver uses the get_seconds() function to implement the 32-bit
    CSR_BUS_TIME register. This was added in 2010 commit a48777e03ad5
    ("firewire: add CSR BUS_TIME support").

    As get_seconds() returns a 32-bit value (on 32-bit architectures), it
    seems like a good fit for that register, but it is also deprecated because
    of the y2038/y2106 overflow problem, and should be replaced throughout
    the kernel with either ktime_get_real_seconds() or ktime_get_seconds().

    I'm using the latter here, which uses monotonic time. This has the
    advantage of behaving better during concurrent settimeofday() updates
    or leap second adjustments and won't overflow a 32-bit integer, but
    the downside of using CLOCK_MONOTONIC instead of CLOCK_REALTIME is
    that the observed values are not related to external clocks.

    If we instead need UTC but can live with clock jumps or overflows,
    then we should use ktime_get_real_seconds() instead, retaining the
    existing behavior.

    Signed-off-by: Arnd Bergmann
    Link: https://lore.kernel.org/lkml/20180711124923.1205200-1-arnd@arndb.de/
    Reviewed-by: Clemens Ladisch
    Signed-off-by: Stefan Richter

    Arnd Bergmann
     

08 Nov, 2019

1 commit

  • KCSAN reported a data-race [1]

    While we can use READ_ONCE() on the read sides,
    we need to make sure hh->hh_len is written last.

    [1]

    BUG: KCSAN: data-race in eth_header_cache / neigh_resolve_output

    write to 0xffff8880b9dedcb8 of 4 bytes by task 29760 on cpu 0:
    eth_header_cache+0xa9/0xd0 net/ethernet/eth.c:247
    neigh_hh_init net/core/neighbour.c:1463 [inline]
    neigh_resolve_output net/core/neighbour.c:1480 [inline]
    neigh_resolve_output+0x415/0x470 net/core/neighbour.c:1470
    neigh_output include/net/neighbour.h:511 [inline]
    ip6_finish_output2+0x7a2/0xec0 net/ipv6/ip6_output.c:116
    __ip6_finish_output net/ipv6/ip6_output.c:142 [inline]
    __ip6_finish_output+0x2d7/0x330 net/ipv6/ip6_output.c:127
    ip6_finish_output+0x41/0x160 net/ipv6/ip6_output.c:152
    NF_HOOK_COND include/linux/netfilter.h:294 [inline]
    ip6_output+0xf2/0x280 net/ipv6/ip6_output.c:175
    dst_output include/net/dst.h:436 [inline]
    NF_HOOK include/linux/netfilter.h:305 [inline]
    ndisc_send_skb+0x459/0x5f0 net/ipv6/ndisc.c:505
    ndisc_send_ns+0x207/0x430 net/ipv6/ndisc.c:647
    rt6_probe_deferred+0x98/0xf0 net/ipv6/route.c:615
    process_one_work+0x3d4/0x890 kernel/workqueue.c:2269
    worker_thread+0xa0/0x800 kernel/workqueue.c:2415
    kthread+0x1d4/0x200 drivers/block/aoe/aoecmd.c:1253
    ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:352

    read to 0xffff8880b9dedcb8 of 4 bytes by task 29572 on cpu 1:
    neigh_resolve_output net/core/neighbour.c:1479 [inline]
    neigh_resolve_output+0x113/0x470 net/core/neighbour.c:1470
    neigh_output include/net/neighbour.h:511 [inline]
    ip6_finish_output2+0x7a2/0xec0 net/ipv6/ip6_output.c:116
    __ip6_finish_output net/ipv6/ip6_output.c:142 [inline]
    __ip6_finish_output+0x2d7/0x330 net/ipv6/ip6_output.c:127
    ip6_finish_output+0x41/0x160 net/ipv6/ip6_output.c:152
    NF_HOOK_COND include/linux/netfilter.h:294 [inline]
    ip6_output+0xf2/0x280 net/ipv6/ip6_output.c:175
    dst_output include/net/dst.h:436 [inline]
    NF_HOOK include/linux/netfilter.h:305 [inline]
    ndisc_send_skb+0x459/0x5f0 net/ipv6/ndisc.c:505
    ndisc_send_ns+0x207/0x430 net/ipv6/ndisc.c:647
    rt6_probe_deferred+0x98/0xf0 net/ipv6/route.c:615
    process_one_work+0x3d4/0x890 kernel/workqueue.c:2269
    worker_thread+0xa0/0x800 kernel/workqueue.c:2415
    kthread+0x1d4/0x200 drivers/block/aoe/aoecmd.c:1253
    ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:352

    Reported by Kernel Concurrency Sanitizer on:
    CPU: 1 PID: 29572 Comm: kworker/1:4 Not tainted 5.4.0-rc6+ #0
    Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
    Workqueue: events rt6_probe_deferred

    Signed-off-by: Eric Dumazet
    Reported-by: syzbot
    Signed-off-by: David S. Miller

    Eric Dumazet
     

23 Oct, 2019

1 commit

  • Each of these drivers has a copy of the same trivial helper function to
    convert the pointer argument and then call the native ioctl handler.

    We now have a generic implementation of that, so use it.

    Acked-by: Greg Kroah-Hartman
    Acked-by: Michael S. Tsirkin
    Acked-by: David S. Miller
    Acked-by: Jarkko Sakkinen
    Reviewed-by: Jarkko Sakkinen
    Reviewed-by: Jason Gunthorpe
    Reviewed-by: Jiri Kosina
    Reviewed-by: Stefan Hajnoczi
    Reviewed-by: Cornelia Huck
    Signed-off-by: Arnd Bergmann

    Arnd Bergmann
     

26 Jul, 2019

1 commit

  • In preparation to enabling -Wimplicit-fallthrough, mark switch
    cases where we are expecting to fall through.

    This patch fixes the following warnings:

    drivers/firewire/core-device.c: In function ‘set_broadcast_channel’:
    drivers/firewire/core-device.c:969:7: warning: this statement may fall through [-Wimplicit-fallthrough=]
    if (data & cpu_to_be32(1 << 31)) {
    ^
    drivers/firewire/core-device.c:974:3: note: here
    case RCODE_ADDRESS_ERROR:
    ^~~~
    drivers/firewire/core-iso.c: In function ‘manage_channel’:
    drivers/firewire/core-iso.c:308:7: warning: this statement may fall through [-Wimplicit-fallthrough=]
    if ((data[0] & bit) == (data[1] & bit))
    ^
    drivers/firewire/core-iso.c:312:3: note: here
    default:
    ^~~~~~~
    drivers/firewire/core-topology.c: In function ‘count_ports’:
    drivers/firewire/core-topology.c:69:23: warning: this statement may fall through [-Wimplicit-fallthrough=]
    (*child_port_count)++;
    ~~~~~~~~~~~~~~~~~~~^~
    drivers/firewire/core-topology.c:70:3: note: here
    case SELFID_PORT_PARENT:
    ^~~~

    Warning level 3 was used: -Wimplicit-fallthrough=3

    Notice that in some cases, the code comment is modified in
    accordance with what GCC is expecting to find.

    This patch is part of the ongoing efforts to enable
    -Wimplicit-fallthrough.

    Cc: Kees Cook
    Cc: Mathieu Malaterre
    Signed-off-by: Stefan Richter (reworded a comment)
    Signed-off-by: Gustavo A. R. Silva

    Gustavo A. R. Silva
     

31 May, 2019

1 commit

  • Based on 1 normalized pattern(s):

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license as published by
    the free software foundation either version 2 of the license or at
    your option any later version this program is distributed in the
    hope that it will be useful but without any warranty without even
    the implied warranty of merchantability or fitness for a particular
    purpose see the gnu general public license for more details you
    should have received a copy of the gnu general public license along
    with this program if not write to the free software foundation inc
    59 temple place suite 330 boston ma 02111 1307 usa

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-or-later

    has been chosen to replace the boilerplate/reference in 1334 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Allison Randal
    Reviewed-by: Richard Fontana
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190527070033.113240726@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

21 May, 2019

2 commits


15 May, 2019

1 commit

  • Convert to use vm_map_pages_zero() to map range of kernel memory to user
    vma.

    This driver has ignored vm_pgoff and mapped the entire pages. We could
    later "fix" these drivers to behave according to the normal vm_pgoff
    offsetting simply by removing the _zero suffix on the function name and if
    that causes regressions, it gives us an easy way to revert.

    Link: http://lkml.kernel.org/r/88645f5ea8202784a8baaf389e592aeb8c505e8e.1552921225.git.jrdr.linux@gmail.com
    Signed-off-by: Souptick Joarder
    Cc: Boris Ostrovsky
    Cc: David Airlie
    Cc: Heiko Stuebner
    Cc: Joerg Roedel
    Cc: Joonsoo Kim
    Cc: Juergen Gross
    Cc: Kees Cook
    Cc: "Kirill A. Shutemov"
    Cc: Kyungmin Park
    Cc: Marek Szyprowski
    Cc: Matthew Wilcox
    Cc: Mauro Carvalho Chehab
    Cc: Michal Hocko
    Cc: Mike Rapoport
    Cc: Oleksandr Andrushchenko
    Cc: Pawel Osciak
    Cc: Peter Zijlstra
    Cc: Rik van Riel
    Cc: Robin Murphy
    Cc: Russell King
    Cc: Sandy Huang
    Cc: Stefan Richter
    Cc: Stephen Rothwell
    Cc: Thierry Reding
    Cc: Vlastimil Babka
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Souptick Joarder
     

08 May, 2019

1 commit

  • Pull stream_open conversion from Kirill Smelkov:

    - remove unnecessary double nonseekable_open from drivers/char/dtlk.c
    as noticed by Pavel Machek while reviewing nonseekable_open ->
    stream_open mass conversion.

    - the mass conversion patch promised in commit 10dce8af3422 ("fs:
    stream_open - opener for stream-like files so that read and write can
    run simultaneously without deadlock") and is automatically generated
    by running

    $ make coccicheck MODE=patch COCCI=scripts/coccinelle/api/stream_open.cocci

    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. More details on this in the
    patch.

    - finally, change VFS to pass ppos=NULL into .read/.write for files
    that declare themselves streams. It was suggested by Rasmus Villemoes
    and makes sure that if ppos starts to be erroneously used in a stream
    file, such bug won't go unnoticed and will produce an oops instead of
    creating illusion of position change being taken into account.

    Note: this patch does not conflict with "fuse: Add FOPEN_STREAM to
    use stream_open()" that will be hopefully coming via FUSE tree,
    because fs/fuse/ uses new-style .read_iter/.write_iter, and for these
    accessors position is still passed as non-pointer kiocb.ki_pos .

    * tag 'stream_open-5.2' of https://lab.nexedi.com/kirr/linux:
    vfs: pass ppos=NULL to .read()/.write() of FMODE_STREAM files
    *: convert stream-like files from nonseekable_open -> stream_open
    dtlk: remove double call to nonseekable_open

    Linus Torvalds
     

06 May, 2019

1 commit

  • Using scripts/coccinelle/api/stream_open.cocci added in 10dce8af3422
    ("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 10dce8af3422):

    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
    Cc: Yongzhi Pan
    Cc: Jonathan Corbet
    Cc: David Vrabel
    Cc: Juergen Gross
    Cc: Miklos Szeredi
    Cc: Tejun Heo
    Cc: Kirill Tkhai
    Cc: Arnd Bergmann
    Cc: Christoph Hellwig
    Cc: Greg Kroah-Hartman
    Cc: Julia Lawall
    Cc: Nikolaus Rath
    Cc: Han-Wen Nienhuys
    Cc: Anatolij Gustschin
    Cc: Jeff Dike
    Cc: Richard Weinberger
    Cc: Anton Ivanov
    Cc: Borislav Petkov
    Cc: Thomas Gleixner
    Cc: Ingo Molnar
    Cc: "James R. Van Zandt"
    Cc: Corey Minyard
    Cc: Harald Welte
    Acked-by: Lubomir Rintel [scr24x_cs]
    Cc: Stefan Richter
    Cc: Johan Hovold
    Cc: David Herrmann
    Cc: Jiri Kosina
    Cc: Benjamin Tissoires
    Cc: Jean Delvare
    Acked-by: Guenter Roeck [watchdog/* hwmon/*]
    Cc: Rudolf Marek
    Cc: Dmitry Torokhov
    Cc: Karsten Keil
    Cc: Jacek Anaszewski
    Cc: Pavel Machek
    Cc: Mauro Carvalho Chehab
    Cc: Kurt Schwemmer
    Acked-by: Logan Gunthorpe [drivers/pci/switch/switchtec]
    Acked-by: Bjorn Helgaas [drivers/pci/switch/switchtec]
    Cc: Benson Leung
    Acked-by: Enric Balletbo i Serra [platform/chrome]
    Cc: Alessandro Zummo
    Acked-by: Alexandre Belloni [rtc/*]
    Cc: Mark Brown
    Cc: Wim Van Sebroeck
    Cc: Florian Fainelli
    Cc: bcm-kernel-feedback-list@broadcom.com
    Cc: Wan ZongShun
    Cc: Zwane Mwaikambo
    Cc: Marek Lindner
    Cc: Simon Wunderlich
    Cc: Antonio Quartulli
    Cc: "David S. Miller"
    Cc: Johannes Berg
    Cc: Jaroslav Kysela
    Cc: Takashi Iwai
    Signed-off-by: Kirill Smelkov

    Kirill Smelkov
     

08 Apr, 2019

1 commit

  • mmiowb() is now implied by spin_unlock() on architectures that require
    it, so there is no reason to call it from driver code. This patch was
    generated using coccinelle:

    @mmiowb@
    @@
    - mmiowb();

    and invoked as:

    $ for d in drivers include/linux/qed sound; do \
    spatch --include-headers --sp-file mmiowb.cocci --dir $d --in-place; done

    NOTE: mmiowb() has only ever guaranteed ordering in conjunction with
    spin_unlock(). However, pairing each mmiowb() removal in this patch with
    the corresponding call to spin_unlock() is not at all trivial, so there
    is a small chance that this change may regress any drivers incorrectly
    relying on mmiowb() to order MMIO writes between CPUs using lock-free
    synchronisation. If you've ended up bisecting to this commit, you can
    reintroduce the mmiowb() calls using wmb() instead, which should restore
    the old behaviour on all architectures other than some esoteric ia64
    systems.

    Acked-by: Linus Torvalds
    Signed-off-by: Will Deacon

    Will Deacon
     

23 Jan, 2019

1 commit

  • When a host driver sets a maximum segment size we should not only propagate
    that setting to the block layer, which can merge segments, but also to the
    DMA mapping layer which can merge segments as well.

    Fixes: 50c2e9107f ("scsi: introduce a max_segment_size host_template parameters")
    Signed-off-by: Christoph Hellwig
    Signed-off-by: Martin K. Petersen

    Christoph Hellwig
     

06 Jan, 2019

1 commit


04 Jan, 2019

1 commit

  • Nobody has actually used the type (VERIFY_READ vs VERIFY_WRITE) argument
    of the user address range verification function since we got rid of the
    old racy i386-only code to walk page tables by hand.

    It existed because the original 80386 would not honor the write protect
    bit when in kernel mode, so you had to do COW by hand before doing any
    user access. But we haven't supported that in a long time, and these
    days the 'type' argument is a purely historical artifact.

    A discussion about extending 'user_access_begin()' to do the range
    checking resulted this patch, because there is no way we're going to
    move the old VERIFY_xyz interface to that model. And it's best done at
    the end of the merge window when I've done most of my merges, so let's
    just get this done once and for all.

    This patch was mostly done with a sed-script, with manual fix-ups for
    the cases that weren't of the trivial 'access_ok(VERIFY_xyz' form.

    There were a couple of notable cases:

    - csky still had the old "verify_area()" name as an alias.

    - the iter_iov code had magical hardcoded knowledge of the actual
    values of VERIFY_{READ,WRITE} (not that they mattered, since nothing
    really used it)

    - microblaze used the type argument for a debug printout

    but other than those oddities this should be a total no-op patch.

    I tried to fix up all architectures, did fairly extensive grepping for
    access_ok() uses, and the changes are trivial, but I may have missed
    something. Any missed conversion should be trivially fixable, though.

    Signed-off-by: Linus Torvalds

    Linus Torvalds
     

19 Dec, 2018

1 commit

  • Most SCSI drivers want to enable "clustering", that is merging of
    segments so that they might span more than a single page. Remove the
    ENABLE_CLUSTERING define, and require drivers to explicitly set
    DISABLE_CLUSTERING to disable this feature.

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Martin K. Petersen

    Christoph Hellwig
     

04 Dec, 2018

1 commit

  • Remove dependencies on HAS_DMA where a Kconfig symbol depends on another
    symbol that implies HAS_DMA, and, optionally, on "|| COMPILE_TEST".
    In most cases this other symbol is an architecture or platform specific
    symbol, or PCI.

    Generic symbols and drivers without platform dependencies keep their
    dependencies on HAS_DMA, to prevent compiling subsystems or drivers that
    cannot work anyway.

    This simplifies the dependencies, and allows to improve compile-testing.

    Signed-off-by: Geert Uytterhoeven
    Reviewed-by: Mark Brown
    Acked-by: Robin Murphy
    Signed-off-by: Stefan Richter

    Geert Uytterhoeven
     

06 Sep, 2018

1 commit

  • Clean up kernel-doc warnings in
    so that it can be added to a Firewire/IEEE 1394 driver-api chapter
    without adding lots of noisy warnings to the documentation build.

    Signed-off-by: Randy Dunlap
    Cc: Stefan Richter
    Cc: Takashi Sakamoto
    Cc: linux-doc@vger.kernel.org
    Cc: linux-scsi@vger.kernel.org
    Cc: Randy Dunlap
    Cc: Andrew Morton
    Cc: "James E.J. Bottomley"
    Cc: "Martin K. Petersen"
    Cc: Jonathan Corbet
    Signed-off-by: Jonathan Corbet

    Randy Dunlap