Skip to content
  1. Aug 15, 2021
    • Shreyansh Chouhan's avatar
      reiserfs: check directory items on read from disk · 4ababa17
      Shreyansh Chouhan authored
      [ Upstream commit 13d25750
      
       ]
      
      While verifying the leaf item that we read from the disk, reiserfs
      doesn't check the directory items, this could cause a crash when we
      read a directory item from the disk that has an invalid deh_location.
      
      This patch adds a check to the directory items read from the disk that
      does a bounds check on deh_location for the directory entries. Any
      directory entry header with a directory entry offset greater than the
      item length is considered invalid.
      
      Link: https://lore.kernel.org/r/20210709152929.766363-1-chouhan.shreyansh630@gmail.com
      Reported-by: default avatar <syzbot+c31a48e6702ccb3d64c9@syzkaller.appspotmail.com>
      Signed-off-by: default avatarShreyansh Chouhan <chouhan.shreyansh630@gmail.com>
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      4ababa17
    • Yu Kuai's avatar
      reiserfs: add check for root_inode in reiserfs_fill_super · bbddd8fc
      Yu Kuai authored
      [ Upstream commit 2acf15b9
      
       ]
      
      Our syzcaller report a NULL pointer dereference:
      
      BUG: kernel NULL pointer dereference, address: 0000000000000000
      PGD 116e95067 P4D 116e95067 PUD 1080b5067 PMD 0
      Oops: 0010 [#1] SMP KASAN
      CPU: 7 PID: 592 Comm: a.out Not tainted 5.13.0-next-20210629-dirty #67
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS ?-20190727_073836-buildvm-p4
      RIP: 0010:0x0
      Code: Unable to access opcode bytes at RIP 0xffffffffffffffd6.
      RSP: 0018:ffff888114e779b8 EFLAGS: 00010246
      RAX: 0000000000000000 RBX: 1ffff110229cef39 RCX: ffffffffaa67e1aa
      RDX: 0000000000000000 RSI: ffff88810a58ee00 RDI: ffff8881233180b0
      RBP: ffffffffac38e9c0 R08: ffffffffaa67e17e R09: 0000000000000001
      R10: ffffffffb91c5557 R11: fffffbfff7238aaa R12: ffff88810a58ee00
      R13: ffff888114e77aa0 R14: 0000000000000000 R15: ffff8881233180b0
      FS:  00007f946163c480(0000) GS:ffff88839f1c0000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: ffffffffffffffd6 CR3: 00000001099c1000 CR4: 00000000000006e0
      DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      Call Trace:
       __lookup_slow+0x116/0x2d0
       ? page_put_link+0x120/0x120
       ? __d_lookup+0xfc/0x320
       ? d_lookup+0x49/0x90
       lookup_one_len+0x13c/0x170
       ? __lookup_slow+0x2d0/0x2d0
       ? reiserfs_schedule_old_flush+0x31/0x130
       reiserfs_lookup_privroot+0x64/0x150
       reiserfs_fill_super+0x158c/0x1b90
       ? finish_unfinished+0xb10/0xb10
       ? bprintf+0xe0/0xe0
       ? __mutex_lock_slowpath+0x30/0x30
       ? __kasan_check_write+0x20/0x30
       ? up_write+0x51/0xb0
       ? set_blocksize+0x9f/0x1f0
       mount_bdev+0x27c/0x2d0
       ? finish_unfinished+0xb10/0xb10
       ? reiserfs_kill_sb+0x120/0x120
       get_super_block+0x19/0x30
       legacy_get_tree+0x76/0xf0
       vfs_get_tree+0x49/0x160
       ? capable+0x1d/0x30
       path_mount+0xacc/0x1380
       ? putname+0x97/0xd0
       ? finish_automount+0x450/0x450
       ? kmem_cache_free+0xf8/0x5a0
       ? putname+0x97/0xd0
       do_mount+0xe2/0x110
       ? path_mount+0x1380/0x1380
       ? copy_mount_options+0x69/0x140
       __x64_sys_mount+0xf0/0x190
       do_syscall_64+0x35/0x80
       entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      This is because 'root_inode' is initialized with wrong mode, and
      it's i_op is set to 'reiserfs_special_inode_operations'. Thus add
      check for 'root_inode' to fix the problem.
      
      Link: https://lore.kernel.org/r/20210702040743.1918552-1-yukuai3@huawei.com
      Signed-off-by: default avatarYu Kuai <yukuai3@huawei.com>
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      bbddd8fc
    • Zheyu Ma's avatar
      pcmcia: i82092: fix a null pointer dereference bug · e595b468
      Zheyu Ma authored
      commit e39cdacf
      
       upstream.
      
      During the driver loading process, the 'dev' field was not assigned, but
      the 'dev' field was referenced in the subsequent 'i82092aa_set_mem_map'
      function.
      
      Signed-off-by: default avatarZheyu Ma <zheyuma97@gmail.com>
      CC: <stable@vger.kernel.org>
      [linux@dominikbrodowski.net: shorten commit message, add Cc to stable]
      Signed-off-by: default avatarDominik Brodowski <linux@dominikbrodowski.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e595b468
    • Maciej W. Rozycki's avatar
      MIPS: Malta: Do not byte-swap accesses to the CBUS UART · 5c824d48
      Maciej W. Rozycki authored
      commit 9a936d6c upstream.
      
      Correct big-endian accesses to the CBUS UART, a Malta on-board discrete
      TI16C550C part wired directly to the system controller's device bus, and
      do not use byte swapping with the 32-bit accesses to the device.
      
      The CBUS is used for devices such as the boot flash memory needed early
      on in system bootstrap even before PCI has been initialised.  Therefore
      it uses the system controller's device bus, which follows the endianness
      set with the CPU, which means no byte-swapping is ever required for data
      accesses to CBUS, unlike with PCI.
      
      The CBUS UART uses the UPIO_MEM32 access method, that is the `readl' and
      `writel' MMIO accessors, which on the MIPS platform imply byte-swapping
      with PCI systems.  Consequently the wrong byte lane is accessed with the
      big-endian configuration and the UART is not correctly accessed.
      
      As it happens the UPIO_MEM32BE access method makes use of the `ioread32'
      and `iowrite32' MMIO accessors, which still use `readl' and `writel'
      respectively, however they byte-swap data passed, effectively cancelling
      swapping done with the accessors themselves and making it suitable for
      the CBUS UART.
      
      Make the CBUS UART switch between UPIO_MEM32 and UPIO_MEM32BE then,
      based on the endianness selected.  With this change in place the device
      is correctly recognised with big-endian Malta at boot, along with the
      Super I/O devices behind PCI:
      
      Serial: 8250/16550 driver, 5 ports, IRQ sharing enabled
      printk: console [ttyS0] disabled
      serial8250.0: ttyS0 at I/O 0x3f8 (irq = 4, base_baud = 115200) is a 16550A
      printk: console [ttyS0] enabled
      printk: bootconsole [uart8250] disabled
      serial8250.0: ttyS1 at I/O 0x2f8 (irq = 3, base_baud = 115200) is a 16550A
      serial8250.0: ttyS2 at MMIO 0x1f000900 (irq = 20, base_baud = 230400) is a 16550A
      
      Fixes: e7c4782f
      
       ("[MIPS] Put an end to <asm/serial.h>'s long and annyoing existence")
      Cc: stable@vger.kernel.org # v2.6.23+
      Reviewed-by: default avatarPhilippe Mathieu-Daudé <f4bug@amsat.org>
      Signed-off-by: default avatarMaciej W. Rozycki <macro@orcam.me.uk>
      Link: https://lore.kernel.org/r/alpine.DEB.2.21.2106260524430.37803@angie.orcam.me.uk
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5c824d48
    • Maciej W. Rozycki's avatar
      serial: 8250: Mask out floating 16/32-bit bus bits · c1174bff
      Maciej W. Rozycki authored
      commit e5227c51 upstream.
      
      Make sure only actual 8 bits of the IIR register are used in determining
      the port type in `autoconfig'.
      
      The `serial_in' port accessor returns the `unsigned int' type, meaning
      that with UPIO_AU, UPIO_MEM16, UPIO_MEM32, and UPIO_MEM32BE access types
      more than 8 bits of data are returned, of which the high order bits will
      often come from bus lines that are left floating in the data phase.  For
      example with the MIPS Malta board's CBUS UART, where the registers are
      aligned on 8-byte boundaries and which uses 32-bit accesses, data as
      follows is returned:
      
      YAMON> dump -32 0xbf000900 0x40
      
      BF000900: 1F000942 1F000942 1F000900 1F000900  ...B...B........
      BF000910: 1F000901 1F000901 1F000900 1F000900  ................
      BF000920: 1F000900 1F000900 1F000960 1F000960  ...........`...`
      BF000930: 1F000900 1F000900 1F0009FF 1F0009FF  ................
      
      YAMON>
      
      Evidently high-order 24 bits return values previously driven in the
      address phase (the 3 highest order address bits used with the command
      above are masked out in the simple virtual address mapping used here and
      come out at zeros on the external bus), a common scenario with bus lines
      left floating, due to bus capacitance.
      
      Consequently when the value of IIR, mapped at 0x1f000910, is retrieved
      in `autoconfig', it comes out at 0x1f0009c1 and when it is right-shifted
      by 6 and then assigned to 8-bit `scratch' variable, the value calculated
      is 0x27, not one of 0, 1, 2, 3 expected in port type determination.
      
      Fix the issue then, by assigning the value returned from `serial_in' to
      `scratch' first, which masks out 24 high-order bits retrieved, and only
      then right-shift the resulting 8-bit data quantity, producing the value
      of 3 in this case, as expected.  Fix the same issue in `serial_dl_read'.
      
      The problem first appeared with Linux 2.6.9-rc3 which predates our repo
      history, but the origin could be identified with the old MIPS/Linux repo
      also at: <git://git.kernel.org/pub/scm/linux/kernel/git/ralf/linux.git>
      as commit e0d2356c0777 ("Merge with Linux 2.6.9-rc3."), where code in
      `serial_in' was updated with this case:
      
      +	case UPIO_MEM32:
      +		return readl(up->port.membase + offset);
      +
      
      which made it produce results outside the unsigned 8-bit range for the
      first time, though obviously it is system dependent what actual values
      appear in the high order bits retrieved and it may well have been zeros
      in the relevant positions with the system the change originally was
      intended for.  It is at that point that code in `autoconf' should have
      been updated accordingly, but clearly it was overlooked.
      
      Fixes: 1da177e4
      
       ("Linux-2.6.12-rc2")
      Cc: stable@vger.kernel.org # v2.6.12+
      Reviewed-by: default avatarPhilippe Mathieu-Daudé <f4bug@amsat.org>
      Signed-off-by: default avatarMaciej W. Rozycki <macro@orcam.me.uk>
      Link: https://lore.kernel.org/r/alpine.DEB.2.21.2106260516220.37803@angie.orcam.me.uk
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c1174bff
    • Johan Hovold's avatar
      media: rtl28xxu: fix zero-length control request · 7d1a1fec
      Johan Hovold authored
      commit 76f22c93
      
       upstream.
      
      The direction of the pipe argument must match the request-type direction
      bit or control requests may fail depending on the host-controller-driver
      implementation.
      
      Control transfers without a data stage are treated as OUT requests by
      the USB stack and should be using usb_sndctrlpipe(). Failing to do so
      will now trigger a warning.
      
      The driver uses a zero-length i2c-read request for type detection so
      update the control-request code to use usb_sndctrlpipe() in this case.
      
      Note that actually trying to read the i2c register in question does not
      work as the register might not exist (e.g. depending on the demodulator)
      as reported by Eero Lehtinen <debiangamer2@gmail.com>.
      
      Reported-by: default avatar <syzbot+faf11bbadc5a372564da@syzkaller.appspotmail.com>
      Reported-by: default avatarEero Lehtinen <debiangamer2@gmail.com>
      Tested-by: default avatarEero Lehtinen <debiangamer2@gmail.com>
      Fixes: d0f232e8
      
       ("[media] rtl28xxu: add heuristic to detect chip type")
      Cc: stable@vger.kernel.org      # 4.0
      Cc: Antti Palosaari <crope@iki.fi>
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarSean Young <sean@mess.org>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7d1a1fec
    • Hui Su's avatar
      scripts/tracing: fix the bug that can't parse raw_trace_func · 8caad908
      Hui Su authored
      commit 1c0cec64 upstream.
      
      Since commit 77271ce4 ("tracing: Add irq, preempt-count and need resched info
      to default trace output"), the default trace output format has been changed to:
                <idle>-0       [009] d.h. 22420.068695: _raw_spin_lock_irqsave <-hrtimer_interrupt
                <idle>-0       [000] ..s. 22420.068695: _nohz_idle_balance <-run_rebalance_domains
                <idle>-0       [011] d.h. 22420.068695: account_process_tick <-update_process_times
      
      origin trace output format:(before v3.2.0)
           # tracer: nop
           #
           #           TASK-PID    CPU#    TIMESTAMP  FUNCTION
           #              | |       |          |         |
                migration/0-6     [000]    50.025810: rcu_note_context_switch <-__schedule
                migration/0-6     [000]    50.025812: trace_rcu_utilization <-rcu_note_context_switch
                migration/0-6     [000]    50.025813: rcu_sched_qs <-rcu_note_context_switch
                migration/0-6     [000]    50.025815: rcu_preempt_qs <-rcu_note_context_switch
                migration/0-6     [000]    50.025817: trace_rcu_utilization <-rcu_note_context_switch
                migration/0-6     [000]    50.025818: debug_lockdep_rcu_enabled <-__schedule
                migration/0-6     [000]    50.025820: debug_lockdep_rcu_enabled <-__schedule
      
      The draw_functrace.py(introduced in v2.6.28) can't parse the new version format trace_func,
      So we need modify draw_functrace.py to adapt the new version trace output format.
      
      Link: https://lkml.kernel.org/r/20210611022107.608787-1-suhui@zeku.com
      
      Cc: stable@vger.kernel.org
      Fixes: 77271ce4
      
       tracing: Add irq, preempt-count and need resched info to default trace output
      Signed-off-by: default avatarHui Su <suhui@zeku.com>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8caad908
    • David Bauer's avatar
      USB: serial: ftdi_sio: add device ID for Auto-M3 OP-COM v2 · 9f3d03fb
      David Bauer authored
      commit 8da0e55c
      
       upstream.
      
      The Auto-M3 OP-COM v2 is a OBD diagnostic device using a FTD232 for the
      USB connection.
      
      Signed-off-by: default avatarDavid Bauer <mail@david-bauer.net>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9f3d03fb
    • Willy Tarreau's avatar
      USB: serial: ch341: fix character loss at high transfer rates · 4e8a4398
      Willy Tarreau authored
      commit 3c18e9ba
      
       upstream.
      
      The chip supports high transfer rates, but with the small default buffers
      (64 bytes read), some entire blocks are regularly lost. This typically
      happens at 1.5 Mbps (which is the default speed on Rockchip devices) when
      used as a console to access U-Boot where the output of the "help" command
      misses many lines and where "printenv" mangles the environment.
      
      The FTDI driver doesn't suffer at all from this. One difference is that
      it uses 512 bytes rx buffers and 256 bytes tx buffers. Adopting these
      values completely resolved the issue, even the output of "dmesg" is
      reliable. I preferred to leave the Tx value unchanged as it is not
      involved in this issue, while a change could increase the risk of
      triggering the same issue with other devices having too small buffers.
      
      I verified that it backports well (and works) at least to 5.4. It's of
      low importance enough to be dropped where it doesn't trivially apply
      anymore.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      Link: https://lore.kernel.org/r/20210724152739.18726-1-w@1wt.eu
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4e8a4398
    • Daniele Palmas's avatar
      USB: serial: option: add Telit FD980 composition 0x1056 · d1c5bfb1
      Daniele Palmas authored
      commit 5648c073
      
       upstream.
      
      Add the following Telit FD980 composition 0x1056:
      
      Cfg #1: mass storage
      Cfg #2: rndis, tty, adb, tty, tty, tty, tty
      
      Signed-off-by: default avatarDaniele Palmas <dnlplm@gmail.com>
      Link: https://lore.kernel.org/r/20210803194711.3036-1-dnlplm@gmail.com
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d1c5bfb1
    • Tetsuo Handa's avatar
      Bluetooth: defer cleanup of resources in hci_unregister_dev() · d6ef8bb0
      Tetsuo Handa authored
      [ Upstream commit e0448092 ]
      
      syzbot is hitting might_sleep() warning at hci_sock_dev_event() due to
      calling lock_sock() with rw spinlock held [1].
      
      It seems that history of this locking problem is a trial and error.
      
      Commit b40df574 ("[PATCH] bluetooth: fix socket locking in
      hci_sock_dev_event()") in 2.6.21-rc4 changed bh_lock_sock() to
      lock_sock() as an attempt to fix lockdep warning.
      
      Then, commit 4ce61d1c ("[BLUETOOTH]: Fix locking in
      hci_sock_dev_event().") in 2.6.22-rc2 changed lock_sock() to
      local_bh_disable() + bh_lock_sock_nested() as an attempt to fix the
      sleep in atomic context warning.
      
      Then, commit 4b5dd696 ("Bluetooth: Remove local_bh_disable() from
      hci_sock.c") in 3.3-rc1 removed local_bh_disable().
      
      Then, commit e305509e
      
       ("Bluetooth: use correct lock to prevent UAF
      of hdev object") in 5.13-rc5 again changed bh_lock_sock_nested() to
      lock_sock() as an attempt to fix CVE-2021-3573.
      
      This difficulty comes from current implementation that
      hci_sock_dev_event(HCI_DEV_UNREG) is responsible for dropping all
      references from sockets because hci_unregister_dev() immediately
      reclaims resources as soon as returning from
      hci_sock_dev_event(HCI_DEV_UNREG).
      
      But the history suggests that hci_sock_dev_event(HCI_DEV_UNREG) was not
      doing what it should do.
      
      Therefore, instead of trying to detach sockets from device, let's accept
      not detaching sockets from device at hci_sock_dev_event(HCI_DEV_UNREG),
      by moving actual cleanup of resources from hci_unregister_dev() to
      hci_cleanup_dev() which is called by bt_host_release() when all
      references to this unregistered device (which is a kobject) are gone.
      
      Since hci_sock_dev_event(HCI_DEV_UNREG) no longer resets
      hci_pi(sk)->hdev, we need to check whether this device was unregistered
      and return an error based on HCI_UNREGISTER flag.  There might be subtle
      behavioral difference in "monitor the hdev" functionality; please report
      if you found something went wrong due to this patch.
      
      Link: https://syzkaller.appspot.com/bug?extid=a5df189917e79d5e59c9 [1]
      Reported-by: default avatarsyzbot <syzbot+a5df189917e79d5e59c9@syzkaller.appspotmail.com>
      Suggested-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Fixes: e305509e
      
       ("Bluetooth: use correct lock to prevent UAF of hdev object")
      Acked-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d6ef8bb0
    • Pavel Skripkin's avatar
      net: vxge: fix use-after-free in vxge_device_unregister · 914054dc
      Pavel Skripkin authored
      [ Upstream commit 942e560a ]
      
      Smatch says:
      drivers/net/ethernet/neterion/vxge/vxge-main.c:3518 vxge_device_unregister() error: Using vdev after free_{netdev,candev}(dev);
      drivers/net/ethernet/neterion/vxge/vxge-main.c:3518 vxge_device_unregister() error: Using vdev after free_{netdev,candev}(dev);
      drivers/net/ethernet/neterion/vxge/vxge-main.c:3520 vxge_device_unregister() error: Using vdev after free_{netdev,candev}(dev);
      drivers/net/ethernet/neterion/vxge/vxge-main.c:3520 vxge_device_unregister() error: Using vdev after free_{netdev,candev}(dev);
      
      Since vdev pointer is netdev private data accessing it after free_netdev()
      call can cause use-after-free bug. Fix it by moving free_netdev() call at
      the end of the function
      
      Fixes: 6cca2003
      
       ("vxge: cleanup probe error paths")
      Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarPavel Skripkin <paskripkin@gmail.com>
      Reviewed-by: default avatarJesse Brandeburg <jesse.brandeburg@intel.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      914054dc
    • Pavel Skripkin's avatar
      net: pegasus: fix uninit-value in get_interrupt_interval · 6dde2ac5
      Pavel Skripkin authored
      [ Upstream commit af35fc37
      
       ]
      
      Syzbot reported uninit value pegasus_probe(). The problem was in missing
      error handling.
      
      get_interrupt_interval() internally calls read_eprom_word() which can
      fail in some cases. For example: failed to receive usb control message.
      These cases should be handled to prevent uninit value bug, since
      read_eprom_word() will not initialize passed stack variable in case of
      internal failure.
      
      Fail log:
      
      BUG: KMSAN: uninit-value in get_interrupt_interval drivers/net/usb/pegasus.c:746 [inline]
      BUG: KMSAN: uninit-value in pegasus_probe+0x10e7/0x4080 drivers/net/usb/pegasus.c:1152
      CPU: 1 PID: 825 Comm: kworker/1:1 Not tainted 5.12.0-rc6-syzkaller #0
      ...
      Workqueue: usb_hub_wq hub_event
      Call Trace:
       __dump_stack lib/dump_stack.c:79 [inline]
       dump_stack+0x24c/0x2e0 lib/dump_stack.c:120
       kmsan_report+0xfb/0x1e0 mm/kmsan/kmsan_report.c:118
       __msan_warning+0x5c/0xa0 mm/kmsan/kmsan_instr.c:197
       get_interrupt_interval drivers/net/usb/pegasus.c:746 [inline]
       pegasus_probe+0x10e7/0x4080 drivers/net/usb/pegasus.c:1152
      ....
      
      Local variable ----data.i@pegasus_probe created at:
       get_interrupt_interval drivers/net/usb/pegasus.c:1151 [inline]
       pegasus_probe+0xe57/0x4080 drivers/net/usb/pegasus.c:1152
       get_interrupt_interval drivers/net/usb/pegasus.c:1151 [inline]
       pegasus_probe+0xe57/0x4080 drivers/net/usb/pegasus.c:1152
      
      Reported-and-tested-by: default avatar <syzbot+02c9f70f3afae308464a@syzkaller.appspotmail.com>
      Fixes: 1da177e4
      
       ("Linux-2.6.12-rc2")
      Signed-off-by: default avatarPavel Skripkin <paskripkin@gmail.com>
      Link: https://lore.kernel.org/r/20210804143005.439-1-paskripkin@gmail.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6dde2ac5
    • Dan Carpenter's avatar
      bnx2x: fix an error code in bnx2x_nic_load() · 0bc5fdab
      Dan Carpenter authored
      [ Upstream commit fb653827 ]
      
      Set the error code if bnx2x_alloc_fw_stats_mem() fails.  The current
      code returns success.
      
      Fixes: ad5afc89
      
       ("bnx2x: Separate VF and PF logic")
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      0bc5fdab
    • H. Nikolaus Schaller's avatar
      mips: Fix non-POSIX regexp · b2386d80
      H. Nikolaus Schaller authored
      [ Upstream commit 28bbbb98 ]
      
      When cross compiling a MIPS kernel on a BSD based HOSTCC leads
      to errors like
      
        SYNC    include/config/auto.conf.cmd - due to: .config
      egrep: empty (sub)expression
        UPD     include/config/kernel.release
        HOSTCC  scripts/dtc/dtc.o - due to target missing
      
      It turns out that egrep uses this egrep pattern:
      
      		(|MINOR_|PATCHLEVEL_)
      
      This is not valid syntax or gives undefined results according
      to POSIX 9.5.3 ERE Grammar
      
      	https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html
      
      It seems to be silently accepted by the Linux egrep implementation
      while a BSD host complains.
      
      Such patterns can be replaced by a transformation like
      
      	"(|p1|p2)" -> "(p1|p2)?"
      
      Fixes: 48c35b2d
      
       ("[MIPS] There is no __GNUC_MAJOR__")
      Signed-off-by: default avatarH. Nikolaus Schaller <hns@goldelico.com>
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b2386d80
    • Wang Hai's avatar
      net: natsemi: Fix missing pci_disable_device() in probe and remove · 995abf77
      Wang Hai authored
      [ Upstream commit 7fe74dfd ]
      
      Replace pci_enable_device() with pcim_enable_device(),
      pci_disable_device() and pci_release_regions() will be
      called in release automatically.
      
      Fixes: 1da177e4
      
       ("Linux-2.6.12-rc2")
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Signed-off-by: default avatarWang Hai <wanghai38@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      995abf77
    • Hans Verkuil's avatar
      media: videobuf2-core: dequeue if start_streaming fails · 0dd09c61
      Hans Verkuil authored
      [ Upstream commit c592b469
      
       ]
      
      If a vb2_queue sets q->min_buffers_needed then when the number of
      queued buffers reaches q->min_buffers_needed, vb2_core_qbuf() will call
      the start_streaming() callback. If start_streaming() returns an error,
      then that error was just returned by vb2_core_qbuf(), but the buffer
      was still queued. However, userspace expects that if VIDIOC_QBUF fails,
      the buffer is returned dequeued.
      
      So if start_streaming() fails, then remove the buffer from the queue,
      thus avoiding this unwanted side-effect.
      
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
      Tested-by: default avatarKieran Bingham <kieran.bingham@ideasonboard.com>
      Fixes: b3379c62
      
       ("[media] vb2: only call start_streaming if sufficient buffers are queued")
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      0dd09c61
    • Li Manyi's avatar
      scsi: sr: Return correct event when media event code is 3 · 1991e004
      Li Manyi authored
      [ Upstream commit 5c04243a ]
      
      Media event code 3 is defined in the MMC-6 spec as follows:
      
        "MediaRemoval: The media has been removed from the specified slot, and
         the Drive is unable to access the media without user intervention. This
         applies to media changers only."
      
      This indicated that treating the condition as an EJECT_REQUEST was
      appropriate. However, doing so had the unfortunate side-effect of causing
      the drive tray to be physically ejected on resume. Instead treat the event
      as a MEDIA_CHANGE request.
      
      Fixes: 7dd753ca
      
       ("scsi: sr: Return appropriate error code when disk is ejected")
      Link: https://bugzilla.kernel.org/show_bug.cgi?id=213759
      Link: https://lore.kernel.org/r/20210726114913.6760-1-limanyi@uniontech.com
      Signed-off-by: default avatarLi Manyi <limanyi@uniontech.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      1991e004
    • Takashi Iwai's avatar
      ALSA: seq: Fix racy deletion of subscriber · 4fdbffde
      Takashi Iwai authored
      commit 97367c97
      
       upstream.
      
      It turned out that the current implementation of the port subscription
      is racy.  The subscription contains two linked lists, and we have to
      add to or delete from both lists.  Since both connection and
      disconnection procedures perform the same order for those two lists
      (i.e. src list, then dest list), when a deletion happens during a
      connection procedure, the src list may be deleted before the dest list
      addition completes, and this may lead to a use-after-free or an Oops,
      even though the access to both lists are protected via mutex.
      
      The simple workaround for this race is to change the access order for
      the disconnection, namely, dest list, then src list.  This assures
      that the connection has been established when disconnecting, and also
      the concurrent deletion can be avoided.
      
      Reported-and-tested-by: default avatarfolkert <folkert@vanheusden.com>
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20210801182754.GP890690@belle.intranet.vanheusden.com
      Link: https://lore.kernel.org/r/20210803114312.2536-1-tiwai@suse.de
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4fdbffde
  2. Aug 10, 2021
  3. Aug 08, 2021
    • Greg Kroah-Hartman's avatar
      Linux 4.4.279 · aff9d4e6
      Greg Kroah-Hartman authored
      
      
      Link: https://lore.kernel.org/r/20210806081108.939164003@linuxfoundation.org
      Tested-by: default avatarPavel Machek (CIP) <pavel@denx.de>
      Tested-by: default avatarJon Hunter <jonathanh@nvidia.com>
      Tested-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Tested-by: default avatarLinux Kernel Functional Testing <lkft@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      v4.4.279
      aff9d4e6
    • Ziyang Xuan's avatar
      can: raw: raw_setsockopt(): fix raw_rcv panic for sock UAF · 19a3982a
      Ziyang Xuan authored
      commit 54f93336 upstream.
      
      We get a bug during ltp can_filter test as following.
      
      ===========================================
      [60919.264984] BUG: unable to handle kernel NULL pointer dereference at 0000000000000010
      [60919.265223] PGD 8000003dda726067 P4D 8000003dda726067 PUD 3dda727067 PMD 0
      [60919.265443] Oops: 0000 [#1] SMP PTI
      [60919.265550] CPU: 30 PID: 3638365 Comm: can_filter Kdump: loaded Tainted: G        W         4.19.90+ #1
      [60919.266068] RIP: 0010:selinux_socket_sock_rcv_skb+0x3e/0x200
      [60919.293289] RSP: 0018:ffff8d53bfc03cf8 EFLAGS: 00010246
      [60919.307140] RAX: 0000000000000000 RBX: 000000000000001d RCX: 0000000000000007
      [60919.320756] RDX: 0000000000000001 RSI: ffff8d5104a8ed00 RDI: ffff8d53bfc03d30
      [60919.334319] RBP: ffff8d9338056800 R08: ffff8d53bfc29d80 R09: 0000000000000001
      [60919.347969] R10: ffff8d53bfc03ec0 R11: ffffb8526ef47c98 R12: ffff8d53bfc03d30
      [60919.350320] perf: interrupt took too long (3063 > 2500), lowering kernel.perf_event_max_sample_rate to 65000
      [60919.361148] R13: 0000000000000001 R14: ffff8d53bcf90000 R15: 0000000000000000
      [60919.361151] FS:  00007fb78b6b3600(0000) GS:ffff8d53bfc00000(0000) knlGS:0000000000000000
      [60919.400812] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [60919.413730] CR2: 0000000000000010 CR3: 0000003e3f784006 CR4: 00000000007606e0
      [60919.426479] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      [60919.439339] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      [60919.451608] PKRU: 55555554
      [60919.463622] Call Trace:
      [60919.475617]  <IRQ>
      [60919.487122]  ? update_load_avg+0x89/0x5d0
      [60919.498478]  ? update_load_avg+0x89/0x5d0
      [60919.509822]  ? account_entity_enqueue+0xc5/0xf0
      [60919.520709]  security_sock_rcv_skb+0x2a/0x40
      [60919.531413]  sk_filter_trim_cap+0x47/0x1b0
      [60919.542178]  ? kmem_cache_alloc+0x38/0x1b0
      [60919.552444]  sock_queue_rcv_skb+0x17/0x30
      [60919.562477]  raw_rcv+0x110/0x190 [can_raw]
      [60919.572539]  can_rcv_filter+0xbc/0x1b0 [can]
      [60919.582173]  can_receive+0x6b/0xb0 [can]
      [60919.591595]  can_rcv+0x31/0x70 [can]
      [60919.600783]  __netif_receive_skb_one_core+0x5a/0x80
      [60919.609864]  process_backlog+0x9b/0x150
      [60919.618691]  net_rx_action+0x156/0x400
      [60919.627310]  ? sched_clock_cpu+0xc/0xa0
      [60919.635714]  __do_softirq+0xe8/0x2e9
      [60919.644161]  do_softirq_own_stack+0x2a/0x40
      [60919.652154]  </IRQ>
      [60919.659899]  do_softirq.part.17+0x4f/0x60
      [60919.667475]  __local_bh_enable_ip+0x60/0x70
      [60919.675089]  __dev_queue_xmit+0x539/0x920
      [60919.682267]  ? finish_wait+0x80/0x80
      [60919.689218]  ? finish_wait+0x80/0x80
      [60919.695886]  ? sock_alloc_send_pskb+0x211/0x230
      [60919.702395]  ? can_send+0xe5/0x1f0 [can]
      [60919.708882]  can_send+0xe5/0x1f0 [can]
      [60919.715037]  raw_sendmsg+0x16d/0x268 [can_raw]
      
      It's because raw_setsockopt() concurrently with
      unregister_netdevice_many(). Concurrent scenario as following.
      
      	cpu0						cpu1
      raw_bind
      raw_setsockopt					unregister_netdevice_many
      						unlist_netdevice
      dev_get_by_index				raw_notifier
      raw_enable_filters				......
      can_rx_register
      can_rcv_list_find(..., net->can.rx_alldev_list)
      
      ......
      
      sock_close
      raw_release(sock_a)
      
      ......
      
      can_receive
      can_rcv_filter(net->can.rx_alldev_list, ...)
      raw_rcv(skb, sock_a)
      BUG
      
      After unlist_netdevice(), dev_get_by_index() return NULL in
      raw_setsockopt(). Function raw_enable_filters() will add sock
      and can_filter to net->can.rx_alldev_list. Then the sock is closed.
      Followed by, we sock_sendmsg() to a new vcan device use the same
      can_filter. Protocol stack match the old receiver whose sock has
      been released on net->can.rx_alldev_list in can_rcv_filter().
      Function raw_rcv() uses the freed sock. UAF BUG is triggered.
      
      We can find that the key issue is that net_device has not been
      protected in raw_setsockopt(). Use rtnl_lock to protect net_device
      in raw_setsockopt().
      
      Fixes: c18ce101
      
       ("[CAN]: Add raw protocol")
      Link: https://lore.kernel.org/r/20210722070819.1048263-1-william.xuanziyang@huawei.com
      Cc: linux-stable <stable@vger.kernel.org>
      Signed-off-by: default avatarZiyang Xuan <william.xuanziyang@huawei.com>
      Acked-by: default avatarOliver Hartkopp <socketcan@hartkopp.net>
      Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      19a3982a
    • Greg Kroah-Hartman's avatar
      Revert "Bluetooth: Shutdown controller after workqueues are flushed or cancelled" · d992022d
      Greg Kroah-Hartman authored
      This reverts commit 5d16a828 which is
      commit 0ea9fd00
      
       upstream.
      
      It has been reported to have problems:
      	https://lore.kernel.org/linux-bluetooth/8735ryk0o7.fsf@baylibre.com/
      
      Reported-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Cc: Kai-Heng Feng <kai.heng.feng@canonical.com>
      Cc: Marcel Holtmann <marcel@holtmann.org>
      Cc: Sasha Levin <sashal@kernel.org>
      Link: https://lore.kernel.org/r/efee3a58-a4d2-af22-0931-e81b877ab539@roeck-us.net
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d992022d
    • Pravin B Shelar's avatar
      net: Fix zero-copy head len calculation. · 1fb80d62
      Pravin B Shelar authored
      [ Upstream commit a17ad096
      
       ]
      
      In some cases skb head could be locked and entire header
      data is pulled from skb. When skb_zerocopy() called in such cases,
      following BUG is triggered. This patch fixes it by copying entire
      skb in such cases.
      This could be optimized incase this is performance bottleneck.
      
      ---8<---
      kernel BUG at net/core/skbuff.c:2961!
      invalid opcode: 0000 [#1] SMP PTI
      CPU: 2 PID: 0 Comm: swapper/2 Tainted: G           OE     5.4.0-77-generic #86-Ubuntu
      Hardware name: OpenStack Foundation OpenStack Nova, BIOS 1.13.0-1ubuntu1.1 04/01/2014
      RIP: 0010:skb_zerocopy+0x37a/0x3a0
      RSP: 0018:ffffbcc70013ca38 EFLAGS: 00010246
      Call Trace:
       <IRQ>
       queue_userspace_packet+0x2af/0x5e0 [openvswitch]
       ovs_dp_upcall+0x3d/0x60 [openvswitch]
       ovs_dp_process_packet+0x125/0x150 [openvswitch]
       ovs_vport_receive+0x77/0xd0 [openvswitch]
       netdev_port_receive+0x87/0x130 [openvswitch]
       netdev_frame_hook+0x4b/0x60 [openvswitch]
       __netif_receive_skb_core+0x2b4/0xc90
       __netif_receive_skb_one_core+0x3f/0xa0
       __netif_receive_skb+0x18/0x60
       process_backlog+0xa9/0x160
       net_rx_action+0x142/0x390
       __do_softirq+0xe1/0x2d6
       irq_exit+0xae/0xb0
       do_IRQ+0x5a/0xf0
       common_interrupt+0xf/0xf
      
      Code that triggered BUG:
      int
      skb_zerocopy(struct sk_buff *to, struct sk_buff *from, int len, int hlen)
      {
              int i, j = 0;
              int plen = 0; /* length of skb->head fragment */
              int ret;
              struct page *page;
              unsigned int offset;
      
              BUG_ON(!from->head_frag && !hlen);
      
      Signed-off-by: default avatarPravin B Shelar <pshelar@ovn.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      1fb80d62
    • Takashi Iwai's avatar
      r8152: Fix potential PM refcount imbalance · ac5008a0
      Takashi Iwai authored
      [ Upstream commit 9c23aa51
      
       ]
      
      rtl8152_close() takes the refcount via usb_autopm_get_interface() but
      it doesn't release when RTL8152_UNPLUG test hits.  This may lead to
      the imbalance of PM refcount.  This patch addresses it.
      
      Link: https://bugzilla.suse.com/show_bug.cgi?id=1186194
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ac5008a0
    • Axel Lin's avatar
      regulator: rt5033: Fix n_voltages settings for BUCK and LDO · 225f3fed
      Axel Lin authored
      [ Upstream commit 6549c46a
      
       ]
      
      For linear regulators, the n_voltages should be (max - min) / step + 1.
      
      Buck voltage from 1v to 3V, per step 100mV, and vout mask is 0x1f.
      If value is from 20 to 31, the voltage will all be fixed to 3V.
      And LDO also, just vout range is different from 1.2v to 3v, step is the
      same. If value is from 18 to 31, the voltage will also be fixed to 3v.
      
      Signed-off-by: default avatarAxel Lin <axel.lin@ingics.com>
      Reviewed-by: default avatarChiYuan Huang <cy_huang@richtek.com>
      Link: https://lore.kernel.org/r/20210627080418.1718127-1-axel.lin@ingics.com
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      225f3fed
    • Goldwyn Rodrigues's avatar
      btrfs: mark compressed range uptodate only if all bio succeed · 2714679a
      Goldwyn Rodrigues authored
      [ Upstream commit 240246f6
      
       ]
      
      In compression write endio sequence, the range which the compressed_bio
      writes is marked as uptodate if the last bio of the compressed (sub)bios
      is completed successfully. There could be previous bio which may
      have failed which is recorded in cb->errors.
      
      Set the writeback range as uptodate only if cb->errors is zero, as opposed
      to checking only the last bio's status.
      
      Backporting notes: in all versions up to 4.4 the last argument is always
      replaced by "!cb->errors".
      
      CC: stable@vger.kernel.org # 4.4+
      Signed-off-by: default avatarGoldwyn Rodrigues <rgoldwyn@suse.com>
      Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2714679a
  4. Aug 04, 2021