Skip to content
Snippets Groups Projects
  1. Jun 17, 2021
  2. Jun 16, 2021
  3. Jun 15, 2021
  4. Jun 11, 2021
    • Lin Ma's avatar
      Bluetooth: fix the erroneous flush_work() order · 01d38e25
      Lin Ma authored
      
      stable inclusion
      from linux-4.19.194
      commit 64700748e8a7af4883538c72ada57999d9a78e92
      CVE: CVE-2021-3564
      
      --------------------------------
      
      commit 6a137caec23aeb9e036cdfd8a46dd8a366460e5d upstream.
      
      In the cleanup routine for failed initialization of HCI device,
      the flush_work(&hdev->rx_work) need to be finished before the
      flush_work(&hdev->cmd_work). Otherwise, the hci_rx_work() can
      possibly invoke new cmd_work and cause a bug, like double free,
      in late processings.
      
      This was assigned CVE-2021-3564.
      
      This patch reorder the flush_work() to fix this bug.
      
      Cc: Marcel Holtmann <marcel@holtmann.org>
      Cc: Johan Hedberg <johan.hedberg@gmail.com>
      Cc: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Jakub Kicinski <kuba@kernel.org>
      Cc: linux-bluetooth@vger.kernel.org
      Cc: netdev@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      Signed-off-by: default avatarLin Ma <linma@zju.edu.cn>
      Signed-off-by: default avatarHao Xiong <mart1n@zju.edu.cn>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      Reviewed-by: default avatarXiu Jianfeng <xiujianfeng@huawei.com>
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      01d38e25
    • Andreas Gruenbacher's avatar
      iomap: Make sure iomap_end is called after iomap_begin · dc3c8625
      Andreas Gruenbacher authored
      
      mainline inclusion
      from mainline-5.9-rc1
      commit 856473cd
      category: bugfix
      bugzilla: 40769
      CVE: NA
      ---------------------------
      
      Make sure iomap_end is always called when iomap_begin succeeds.
      
      Without this fix, iomap_end won't be called when a filesystem's
      iomap_begin operation returns an invalid mapping, bypassing any
      unlocking done in iomap_end.  With this fix, the unlocking will still
      happen.
      
      This bug was found by Bob Peterson during code review.  It's unlikely
      that such iomap_begin bugs will survive to affect users, so backporting
      this fix seems unnecessary.
      
      Fixes: ae259a9c ("fs: introduce iomap infrastructure")
      Signed-off-by: default avatarAndreas Gruenbacher <agruenba@redhat.com>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Reviewed-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
      Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
      [fs/iomap/apply.c not exist, instead fs/iomap.c]
      Signed-off-by: default avataryangerkun <yangerkun@huawei.com>
      Reviewed-by: default avatarZhang Yi <yi.zhang@huawei.com>
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      dc3c8625
    • Zhenzhong Duan's avatar
      x86/kvm: Add "nopvspin" parameter to disable PV spinlocks · c631feb1
      Zhenzhong Duan authored
      mainline inclusion
      from mainline-5.1
      commit 05eee619
      category: feature
      bugzilla: https://gitee.com/openeuler/kernel/issues/I3T22N
      
      
      CVE: NA
      
      There are cases where a guest tries to switch spinlocks to bare metal
      behavior (e.g. by setting "xen_nopvspin" on XEN platform and
      "hv_nopvspin" on HYPER_V).
      
      That feature is missed on KVM, add a new parameter "nopvspin" to disable
      PV spinlocks for KVM guest.
      
      The new 'nopvspin' parameter will also replace Xen and Hyper-V specific
      parameters in future patches.
      
      Define variable nopvsin as global because it will be used in future
      patches as above.
      
      Signed-off-by: default avatarZhenzhong Duan <zhenzhong.duan@oracle.com>
      Reviewed-by: default avatarVitaly Kuznetsov <vkuznets@redhat.com>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Radim Krcmar <rkrcmar@redhat.com>
      Cc: Sean Christopherson <sean.j.christopherson@intel.com>
      Cc: Vitaly Kuznetsov <vkuznets@redhat.com>
      Cc: Wanpeng Li <wanpengli@tencent.com>
      Cc: Jim Mattson <jmattson@google.com>
      Cc: Joerg Roedel <joro@8bytes.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Will Deacon <will@kernel.org>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarJiajun Chen <chenjiajun8@huawei.com>
      Reviewed-by: default avatarXiangyou Xie <xiexiangyou@huawei.com>
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      c631feb1
    • Yufen Yu's avatar
      scsi: libsas: add lun number check in .slave_alloc callback · efa2c015
      Yufen Yu authored
      
      hulk inclusion
      category: bugfix
      bugzilla: 51878
      CVE: NA
      
      -------------------------------------------------
      
      We found that offline a sata device on hisi sas control and then
      scanning the host can probe 255 non-existent devices into system.
      
      [root@localhost ~]# lsscsi
        [2:0:0:0]    disk    ATA      Samsung SSD 860  2B6Q  /dev/sda
        [2:0:1:0]    disk    ATA      WDC WD2003FYYS-3 1D01  /dev/sdb
        [2:0:2:0]    disk    SEAGATE  ST600MM0006      B001  /dev/sdc
      
       1) echo "offline" > /sys/block/sdb/device/state
       2) echo "- - -" > /sys/class/scsi_host/host2/scan
      
      Then, we can see another 255 non-existent devices in system:
        [root@localhost ~]# lsscsi
        [2:0:0:0]    disk    ATA      Samsung SSD 860  2B6Q  /dev/sda
        [2:0:1:0]    disk    ATA      WDC WD2003FYYS-3 1D01  /dev/sdb
        [2:0:1:1]    disk    ATA      WDC WD2003FYYS-3 1D01  /dev/sdh
        ...
        [2:0:1:255]  disk    ATA      WDC WD2003FYYS-3 1D01  /dev/sdjb
      
      After REPORT LUN command issued to the offline device fail, it tries
      to do a sequential scan and probe all devices whose lun is not 0
      successfully.
      
      To fix the problem, we try to do same things as commit 2fc62e2a
      ("[SCSI] libsas: disable scanning lun > 0 on ata devices"), which
      will prevent the device whose lun number is not zero probe into system.
      
      Reported-by: default avatarWu Bo <wubo40@huawei.com>
      Suggested-by: default avatarJohn Garry <john.garry@huawei.com>
      Signed-off-by: default avatarYufen Yu <yuyufen@huawei.com>
      Reviewed-by: default avatarJason Yan <yanaijie@huawei.com>
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      efa2c015
    • Krzysztof Kozlowski's avatar
      nfc: fix NULL ptr dereference in llcp_sock_getname() after failed connect · 4d469a45
      Krzysztof Kozlowski authored
      stable inclusion
      from linux-4.19.194
      commit 93e4ac2a9979a9a4ecc158409ed9c3044dc0ae1f
      CVE: CVE-2021-3587
      
      --------------------------------
      
      commit 4ac06a1e013cf5fdd963317ffd3b968560f33bba upstream.
      
      It's possible to trigger NULL pointer dereference by local unprivileged
      user, when calling getsockname() after failed bind() (e.g. the bind
      fails because LLCP_SAP_MAX used as SAP):
      
        BUG: kernel NULL pointer dereference, address: 0000000000000000
        CPU: 1 PID: 426 Comm: llcp_sock_getna Not tainted 5.13.0-rc2-next-20210521+ #9
        Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.14.0-1 04/01/2014
        Call Trace:
         llcp_sock_getname+0xb1/0xe0
         __sys_getpeername+0x95/0xc0
         ? lockdep_hardirqs_on_prepare+0xd5/0x180
         ? syscall_enter_from_user_mode+0x1c/0x40
         __x64_sys_getpeername+0x11/0x20
         do_syscall_64+0x36/0x70
         entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      This can be reproduced with Syzkaller C repro (bind followed by
      ge...
      4d469a45
  5. Jun 10, 2021
    • Longfang Liu's avatar
      USB:ehci:fix Kunpeng920 ehci hardware problem · af95a0b6
      Longfang Liu authored
      
      mainline inclusion
      from mainline-5.13
      commit 26b75952ca0b
      category: bugfix
      bugzilla: NA
      CVE: NA
      
      -------------------------------------------------
      
      Kunpeng920's EHCI controller does not have SBRN register.
      Reading the SBRN register when the controller driver is
      initialized will get 0.
      
      When rebooting the EHCI driver, ehci_shutdown() will be called.
      if the sbrn flag is 0, ehci_shutdown() will return directly.
      The sbrn flag being 0 will cause the EHCI interrupt signal to
      not be turned off after reboot. this interrupt that is not closed
      will cause an exception to the device sharing the interrupt.
      
      Therefore, the EHCI controller of Kunpeng920 needs to skip
      the read operation of the SBRN register.
      
      Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: default avatarLongfang Liu <liulongfang@huawei.com>
      Link: https://lore.kernel.org/r/1617958081-17999-1-git-send-email-liulongfang@huawei.com
      
      
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWenchao Hao <haowenchao@huawei.com>
      Reviewed-by: default avatarWeifeng Su <suweifeng1@huawei.com>
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      af95a0b6
    • Keith Busch's avatar
      nvme: don't warn on block content change effects · 4a2a2252
      Keith Busch authored
      
      mainline inclusion
      from mainline-5.1
      commit 415df90b
      category: bugfix
      bugzilla: NA
      CVE: NA
      
      -------------------------------------------------
      
      A write or flush IO passthrough command is expected to change the
      logical block content, so don't warn on these as no additional handling
      is necessary.
      
      Signed-off-by: default avatarKeith Busch <keith.busch@intel.com>
      Reviewed-by: default avatarSagi Grimberg <sagi@grimberg.me>
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarWenchao Hao <haowenchao@huawei.com>
      Reviewed-by: default avatarWeifeng Su <suweifeng1@huawei.com>
      Reviewed-by: default avatarYufen Yu <yuyufen@huawei.com>
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      4a2a2252
    • David Jeffery's avatar
      block: recalculate segment count for multi-segment discards correctly · 87e42965
      David Jeffery authored
      
      mainline inclusion
      from mainline-5.12-rc5
      commit	a958937ff166fc60d1c3a721036f6ff41bfa2821
      category: bugfix
      bugzilla: 51373
      CVE: NA
      
      -------------------------------------------------
      
      When a stacked block device inserts a request into another block device
      using blk_insert_cloned_request, the request's nr_phys_segments field gets
      recalculated by a call to blk_recalc_rq_segments in
      blk_cloned_rq_check_limits. But blk_recalc_rq_segments does not know how to
      handle multi-segment discards. For disk types which can handle
      multi-segment discards like nvme, this results in discard requests which
      claim a single segment when it should report several, triggering a warning
      in nvme and causing nvme to fail the discard from the invalid state.
      
       WARNING: CPU: 5 PID: 191 at drivers/nvme/host/core.c:700 nvme_setup_discard+0x170/0x1e0 [nvme_core]
       ...
       nvme_setup_cmd+0x217/0x270 [nvme_core]
       nvme_loop_queue_rq+0x51/0x1b0 [nvme_loop]
       __blk_mq_try_issue_directly+0xe7/0x1b0
       blk_mq_request_issue_directly+0x41/0x70
       ? blk_account_io_start+0x40/0x50
       dm_mq_queue_rq+0x200/0x3e0
       blk_mq_dispatch_rq_list+0x10a/0x7d0
       ? __sbitmap_queue_get+0x25/0x90
       ? elv_rb_del+0x1f/0x30
       ? deadline_remove_request+0x55/0xb0
       ? dd_dispatch_request+0x181/0x210
       __blk_mq_do_dispatch_sched+0x144/0x290
       ? bio_attempt_discard_merge+0x134/0x1f0
       __blk_mq_sched_dispatch_requests+0x129/0x180
       blk_mq_sched_dispatch_requests+0x30/0x60
       __blk_mq_run_hw_queue+0x47/0xe0
       __blk_mq_delay_run_hw_queue+0x15b/0x170
       blk_mq_sched_insert_requests+0x68/0xe0
       blk_mq_flush_plug_list+0xf0/0x170
       blk_finish_plug+0x36/0x50
       xlog_cil_committed+0x19f/0x290 [xfs]
       xlog_cil_process_committed+0x57/0x80 [xfs]
       xlog_state_do_callback+0x1e0/0x2a0 [xfs]
       xlog_ioend_work+0x2f/0x80 [xfs]
       process_one_work+0x1b6/0x350
       worker_thread+0x53/0x3e0
       ? process_one_work+0x350/0x350
       kthread+0x11b/0x140
       ? __kthread_bind_mask+0x60/0x60
       ret_from_fork+0x22/0x30
      
      This patch fixes blk_recalc_rq_segments to be aware of devices which can
      have multi-segment discards. It calculates the correct discard segment
      count by counting the number of bio as each discard bio is considered its
      own segment.
      
      Fixes: 1e739730 ("block: optionally merge discontiguous discard bios into a single request")
      Signed-off-by: default avatarDavid Jeffery <djeffery@redhat.com>
      Reviewed-by: default avatarMing Lei <ming.lei@redhat.com>
      Reviewed-by: default avatarLaurence Oberman <loberman@redhat.com>
      Link: https://lore.kernel.org/r/20210211143807.GA115624@redhat
      
      
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      
      Conflicts:
              block/blk-merge.c
      
      Signed-off-by: default avatarBaokun Li <libaokun1@huawei.com>
      Reviewed-by: default avatarYufen Yu <yuyufen@huawei.com>
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      87e42965
    • Sun Ke's avatar
      nbd: Fix NULL pointer in flush_workqueue · a329b8db
      Sun Ke authored
      
      mainline inclusion
      from mainline-v5.13-rc2
      commit 79ebe9110fa458d58f1fceb078e2068d7ad37390
      category: bugfix
      bugzilla: 27457
      CVE: NA
      
      -----------------------------------------------
      
      Open /dev/nbdX first, the config_refs will be 1 and
      the pointers in nbd_device are still null. Disconnect
      /dev/nbdX, then reference a null recv_workq. The
      protection by config_refs in nbd_genl_disconnect is useless.
      
      [  656.366194] BUG: kernel NULL pointer dereference, address: 0000000000000020
      [  656.368943] #PF: supervisor write access in kernel mode
      [  656.369844] #PF: error_code(0x0002) - not-present page
      [  656.370717] PGD 10cc87067 P4D 10cc87067 PUD 1074b4067 PMD 0
      [  656.371693] Oops: 0002 [#1] SMP
      [  656.372242] CPU: 5 PID: 7977 Comm: nbd-client Not tainted 5.11.0-rc5-00040-g76c057c84d28 #1
      [  656.373661] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS ?-20190727_073836-buildvm-ppc64le-16.ppc.fedoraproject.org-3.fc31 04/01/2014
      [  656.375904] RIP: 0010:mutex_lock+0x29/0x60
      [  656.376627] Code: 00 0f 1f 44 00 00 55 48 89 fd 48 83 05 6f d7 fe 08 01 e8 7a c3 ff ff 48 83 05 6a d7 fe 08 01 31 c0 65 48 8b 14 25 00 6d 01 00 <f0> 48 0f b1 55 d
      [  656.378934] RSP: 0018:ffffc900005eb9b0 EFLAGS: 00010246
      [  656.379350] RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000
      [  656.379915] RDX: ffff888104cf2600 RSI: ffffffffaae8f452 RDI: 0000000000000020
      [  656.380473] RBP: 0000000000000020 R08: 0000000000000000 R09: ffff88813bd6b318
      [  656.381039] R10: 00000000000000c7 R11: fefefefefefefeff R12: ffff888102710b40
      [  656.381599] R13: ffffc900005eb9e0 R14: ffffffffb2930680 R15: ffff88810770ef00
      [  656.382166] FS:  00007fdf117ebb40(0000) GS:ffff88813bd40000(0000) knlGS:0000000000000000
      [  656.382806] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [  656.383261] CR2: 0000000000000020 CR3: 0000000100c84000 CR4: 00000000000006e0
      [  656.383819] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      [  656.384370] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      [  656.384927] Call Trace:
      [  656.385111]  flush_workqueue+0x92/0x6c0
      [  656.385395]  nbd_disconnect_and_put+0x81/0xd0
      [  656.385716]  nbd_genl_disconnect+0x125/0x2a0
      [  656.386034]  genl_family_rcv_msg_doit.isra.0+0x102/0x1b0
      [  656.386422]  genl_rcv_msg+0xfc/0x2b0
      [  656.386685]  ? nbd_ioctl+0x490/0x490
      [  656.386954]  ? genl_family_rcv_msg_doit.isra.0+0x1b0/0x1b0
      [  656.387354]  netlink_rcv_skb+0x62/0x180
      [  656.387638]  genl_rcv+0x34/0x60
      [  656.387874]  netlink_unicast+0x26d/0x590
      [  656.388162]  netlink_sendmsg+0x398/0x6c0
      [  656.388451]  ? netlink_rcv_skb+0x180/0x180
      [  656.388750]  ____sys_sendmsg+0x1da/0x320
      [  656.389038]  ? ____sys_recvmsg+0x130/0x220
      [  656.389334]  ___sys_sendmsg+0x8e/0xf0
      [  656.389605]  ? ___sys_recvmsg+0xa2/0xf0
      [  656.389889]  ? handle_mm_fault+0x1671/0x21d0
      [  656.390201]  __sys_sendmsg+0x6d/0xe0
      [  656.390464]  __x64_sys_sendmsg+0x23/0x30
      [  656.390751]  do_syscall_64+0x45/0x70
      [  656.391017]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
      
      To fix it, just add if (nbd->recv_workq) to nbd_disconnect_and_put().
      
      Fixes: e9e006f5 ("nbd: fix max number of supported devs")
      Signed-off-by: default avatarSun Ke <sunke32@huawei.com>
      Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
      Link: https://lore.kernel.org/r/20210512114331.1233964-2-sunke32@huawei.com
      
      
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarYe Bin <yebin10@huawei.com>
      Reviewed-by: default avatarYufen Yu <yuyufen@huawei.com>
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      a329b8db
    • Peilin Ye's avatar
      Bluetooth: Fix slab-out-of-bounds read in hci_extended_inquiry_result_evt() · f328b128
      Peilin Ye authored
      stable inclusion
      from linux-4.19.139
      commit 8c4a649c20fec015ebb326f36b47d4e39d9ff5b7
      CVE: CVE-2020-36386
      
      --------------------------------
      
      commit 51c19bf3 upstream.
      
      Check upon `num_rsp` is insufficient. A malformed event packet with a
      large `num_rsp` number makes hci_extended_inquiry_result_evt() go out
      of bounds. Fix it.
      
      This patch fixes the following syzbot bug:
      
          https://syzkaller.appspot.com/bug?id=4bf11aa05c4ca51ce0df86e500fce486552dc8d2
      
      
      
      Reported-by: default avatar <syzbot+d8489a79b781849b9c46@syzkaller.appspotmail.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarPeilin Ye <yepeilin.cs@gmail.com>
      Acked-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      Reviewed-by: default avatarXiu Jianfeng <xiujianfeng@huawei.com>
      Signed-off-by: Yang Yingliang <ya...
      f328b128
    • Will McVicker's avatar
      HID: make arrays usage and value to be the same · a6a13f48
      Will McVicker authored
      
      stable inclusion
      from linux-4.19.178
      commit ffca531f71d078c6caf752d64bc2a592f420f7c6
      CVE: CVE-2021-0512
      
      --------------------------------
      
      commit ed9be64eefe26d7d8b0b5b9fa3ffdf425d87a01f upstream.
      
      The HID subsystem allows an "HID report field" to have a different
      number of "values" and "usages" when it is allocated. When a field
      struct is created, the size of the usage array is guaranteed to be at
      least as large as the values array, but it may be larger. This leads to
      a potential out-of-bounds write in
      __hidinput_change_resolution_multipliers() and an out-of-bounds read in
      hidinput_count_leds().
      
      To fix this, let's make sure that both the usage and value arrays are
      the same size.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarWill McVicker <willmcvicker@google.com>
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      Reviewed-by: default avatarXiu Jianfeng <xiujianfeng@huawei.com>
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      a6a13f48
  6. Jun 09, 2021
  7. Jun 08, 2021