1. 15 3月, 2023 4 次提交
    • M
      scsi: iscsi_tcp: Fix UAF during logout when accessing the shost ipaddress · 744050c7
      Mike Christie 提交于
      mainline inclusion
      from mainline-v6.2-rc6
      commit 6f1d64b1
      category: bugfix
      bugzilla: 188443, https://gitee.com/openeuler/kernel/issues/I6I8YD
      CVE: NA
      
      Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=6f1d64b13097e85abda0f91b5638000afc5f9a06
      
      ----------------------------------------
      
      Bug report and analysis from Ding Hui.
      
      During iSCSI session logout, if another task accesses the shost ipaddress
      attr, we can get a KASAN UAF report like this:
      
      [  276.942144] BUG: KASAN: use-after-free in _raw_spin_lock_bh+0x78/0xe0
      [  276.942535] Write of size 4 at addr ffff8881053b45b8 by task cat/4088
      [  276.943511] CPU: 2 PID: 4088 Comm: cat Tainted: G            E      6.1.0-rc8+ #3
      [  276.943997] Hardware name: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform, BIOS 6.00 11/12/2020
      [  276.944470] Call Trace:
      [  276.944943]  <TASK>
      [  276.945397]  dump_stack_lvl+0x34/0x48
      [  276.945887]  print_address_description.constprop.0+0x86/0x1e7
      [  276.946421]  print_report+0x36/0x4f
      [  276.947358]  kasan_report+0xad/0x130
      [  276.948234]  kasan_check_range+0x35/0x1c0
      [  276.948674]  _raw_spin_lock_bh+0x78/0xe0
      [  276.949989]  iscsi_sw_tcp_host_get_param+0xad/0x2e0 [iscsi_tcp]
      [  276.951765]  show_host_param_ISCSI_HOST_PARAM_IPADDRESS+0xe9/0x130 [scsi_transport_iscsi]
      [  276.952185]  dev_attr_show+0x3f/0x80
      [  276.953005]  sysfs_kf_seq_show+0x1fb/0x3e0
      [  276.953401]  seq_read_iter+0x402/0x1020
      [  276.954260]  vfs_read+0x532/0x7b0
      [  276.955113]  ksys_read+0xed/0x1c0
      [  276.955952]  do_syscall_64+0x38/0x90
      [  276.956347]  entry_SYSCALL_64_after_hwframe+0x63/0xcd
      [  276.956769] RIP: 0033:0x7f5d3a679222
      [  276.957161] Code: c0 e9 b2 fe ff ff 50 48 8d 3d 32 c0 0b 00 e8 a5 fe 01 00 0f 1f 44 00 00 f3 0f 1e fa 64 8b 04 25 18 00 00 00 85 c0 75 10 0f 05 <48> 3d 00 f0 ff ff 77 56 c3 0f 1f 44 00 00 48 83 ec 28 48 89 54 24
      [  276.958009] RSP: 002b:00007ffc864d16a8 EFLAGS: 00000246 ORIG_RAX: 0000000000000000
      [  276.958431] RAX: ffffffffffffffda RBX: 0000000000020000 RCX: 00007f5d3a679222
      [  276.958857] RDX: 0000000000020000 RSI: 00007f5d3a4fe000 RDI: 0000000000000003
      [  276.959281] RBP: 00007f5d3a4fe000 R08: 00000000ffffffff R09: 0000000000000000
      [  276.959682] R10: 0000000000000022 R11: 0000000000000246 R12: 0000000000020000
      [  276.960126] R13: 0000000000000003 R14: 0000000000000000 R15: 0000557a26dada58
      [  276.960536]  </TASK>
      [  276.961357] Allocated by task 2209:
      [  276.961756]  kasan_save_stack+0x1e/0x40
      [  276.962170]  kasan_set_track+0x21/0x30
      [  276.962557]  __kasan_kmalloc+0x7e/0x90
      [  276.962923]  __kmalloc+0x5b/0x140
      [  276.963308]  iscsi_alloc_session+0x28/0x840 [scsi_transport_iscsi]
      [  276.963712]  iscsi_session_setup+0xda/0xba0 [libiscsi]
      [  276.964078]  iscsi_sw_tcp_session_create+0x1fd/0x330 [iscsi_tcp]
      [  276.964431]  iscsi_if_create_session.isra.0+0x50/0x260 [scsi_transport_iscsi]
      [  276.964793]  iscsi_if_recv_msg+0xc5a/0x2660 [scsi_transport_iscsi]
      [  276.965153]  iscsi_if_rx+0x198/0x4b0 [scsi_transport_iscsi]
      [  276.965546]  netlink_unicast+0x4d5/0x7b0
      [  276.965905]  netlink_sendmsg+0x78d/0xc30
      [  276.966236]  sock_sendmsg+0xe5/0x120
      [  276.966576]  ____sys_sendmsg+0x5fe/0x860
      [  276.966923]  ___sys_sendmsg+0xe0/0x170
      [  276.967300]  __sys_sendmsg+0xc8/0x170
      [  276.967666]  do_syscall_64+0x38/0x90
      [  276.968028]  entry_SYSCALL_64_after_hwframe+0x63/0xcd
      [  276.968773] Freed by task 2209:
      [  276.969111]  kasan_save_stack+0x1e/0x40
      [  276.969449]  kasan_set_track+0x21/0x30
      [  276.969789]  kasan_save_free_info+0x2a/0x50
      [  276.970146]  __kasan_slab_free+0x106/0x190
      [  276.970470]  __kmem_cache_free+0x133/0x270
      [  276.970816]  device_release+0x98/0x210
      [  276.971145]  kobject_cleanup+0x101/0x360
      [  276.971462]  iscsi_session_teardown+0x3fb/0x530 [libiscsi]
      [  276.971775]  iscsi_sw_tcp_session_destroy+0xd8/0x130 [iscsi_tcp]
      [  276.972143]  iscsi_if_recv_msg+0x1bf1/0x2660 [scsi_transport_iscsi]
      [  276.972485]  iscsi_if_rx+0x198/0x4b0 [scsi_transport_iscsi]
      [  276.972808]  netlink_unicast+0x4d5/0x7b0
      [  276.973201]  netlink_sendmsg+0x78d/0xc30
      [  276.973544]  sock_sendmsg+0xe5/0x120
      [  276.973864]  ____sys_sendmsg+0x5fe/0x860
      [  276.974248]  ___sys_sendmsg+0xe0/0x170
      [  276.974583]  __sys_sendmsg+0xc8/0x170
      [  276.974891]  do_syscall_64+0x38/0x90
      [  276.975216]  entry_SYSCALL_64_after_hwframe+0x63/0xcd
      
      We can easily reproduce by two tasks:
      1. while :; do iscsiadm -m node --login; iscsiadm -m node --logout; done
      2. while :; do cat \
      /sys/devices/platform/host*/iscsi_host/host*/ipaddress; done
      
                  iscsid              |        cat
      --------------------------------+---------------------------------------
      |- iscsi_sw_tcp_session_destroy |
        |- iscsi_session_teardown     |
          |- device_release           |
            |- iscsi_session_release  ||- dev_attr_show
              |- kfree                |  |- show_host_param_
                                      |             ISCSI_HOST_PARAM_IPADDRESS
                                      |    |- iscsi_sw_tcp_host_get_param
                                      |      |- r/w tcp_sw_host->session (UAF)
        |- iscsi_host_remove          |
        |- iscsi_host_free            |
      
      Fix the above bug by splitting the session removal into 2 parts:
      
       1. removal from iSCSI class which includes sysfs and removal from host
          tracking.
      
       2. freeing of session.
      
      During iscsi_tcp host and session removal we can remove the session from
      sysfs then remove the host from sysfs. At this point we know userspace is
      not accessing the kernel via sysfs so we can free the session and host.
      
      Link: https://lore.kernel.org/r/20230117193937.21244-2-michael.christie@oracle.comSigned-off-by: NMike Christie <michael.christie@oracle.com>
      Reviewed-by: NLee Duncan <lduncan@suse.com>
      Acked-by: NDing Hui <dinghui@sangfor.com.cn>
      Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: NZhong Jinghua <zhongjinghua@huawei.com>
      conflicts:
      	drivers/scsi/iscsi_tcp.c
      Reviewed-by: NHou Tao <houtao1@huawei.com>
      Signed-off-by: NJialin Zhang <zhangjialin11@huawei.com>
      744050c7
    • M
      scsi: iscsi: Move pool freeing · 7883e908
      Mike Christie 提交于
      mainline inclusion
      from mainline-v5.14-rc1
      commit a1f3486b
      category: bugfix
      bugzilla: 188443, https://gitee.com/openeuler/kernel/issues/I6I8YD
      CVE: NA
      
      Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=a1f3486b3b095ed2259d7a1fc021a8b6e72a5365
      
      ----------------------------------------
      
      This doesn't fix any bugs, but it makes more sense to free the pool after
      we have removed the session. At that time we know nothing is touching any
      of the session fields, because all devices have been removed and scans are
      stopped.
      
      Link: https://lore.kernel.org/r/20210525181821.7617-19-michael.christie@oracle.comReviewed-by: NLee Duncan <lduncan@suse.com>
      Signed-off-by: NMike Christie <michael.christie@oracle.com>
      Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: NZhong Jinghua <zhongjinghua@huawei.com>
      Reviewed-by: NHou Tao <houtao1@huawei.com>
      Signed-off-by: NJialin Zhang <zhangjialin11@huawei.com>
      7883e908
    • D
      xfs: aborting inodes on shutdown may need buffer lock · 8c1ba703
      Dave Chinner 提交于
      mainline inclusion
      from mainline-v5.17-rc6
      commit d2d7c047
      category: bugfix
      bugzilla: https://gitee.com/openeuler/kernel/issues/I4KIAO
      CVE: NA
      
      Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d2d7c0473586d2f22e85d615275f34cf19f94447
      
      --------------------------------
      
      Most buffer io list operations are run with the bp->b_lock held, but
      xfs_iflush_abort() can be called without the buffer lock being held
      resulting in inodes being removed from the buffer list while other
      list operations are occurring. This causes problems with corrupted
      bp->b_io_list inode lists during filesystem shutdown, leading to
      traversals that never end, double removals from the AIL, etc.
      
      Fix this by passing the buffer to xfs_iflush_abort() if we have
      it locked. If the inode is attached to the buffer, we're going to
      have to remove it from the buffer list and we'd have to get the
      buffer off the inode log item to do that anyway.
      
      If we don't have a buffer passed in (e.g. from xfs_reclaim_inode())
      then we can determine if the inode has a log item and if it is
      attached to a buffer before we do anything else. If it does have an
      attached buffer, we can lock it safely (because the inode has a
      reference to it) and then perform the inode abort.
      Signed-off-by: NDave Chinner <dchinner@redhat.com>
      Reviewed-by: NDarrick J. Wong <djwong@kernel.org>
      Signed-off-by: NDarrick J. Wong <djwong@kernel.org>
      
      conflicts:
      	fs/xfs/xfs_icache.c
      Signed-off-by: NLong Li <leo.lilong@huawei.com>
      Reviewed-by: NZhang Yi <yi.zhang@huawei.com>
      Reviewed-by: NYang Erkun <yangerkun@huawei.com>
      Signed-off-by: NJialin Zhang <zhangjialin11@huawei.com>
      8c1ba703
    • Z
      ext4: fix incorrect options show of original mount_opt and extend mount_opt2 · feb72ad7
      Zhang Yi 提交于
      maillist inclusion
      category: bugfix
      bugzilla: https://gitee.com/openeuler/kernel/issues/I6D5XF
      
      Reference: https://lore.kernel.org/linux-ext4/20230130111138.76tp6pij3yhh4brh@quack3/T/#t
      
      --------------------------------
      
      Current _ext4_show_options() do not distinguish MOPT_2 flag, so it mixed
      extend sbi->s_mount_opt2 options with sbi->s_mount_opt, it could lead to
      show incorrect options, e.g. show fc_debug_force if we mount with
      errors=continue mode and miss it if we set.
      
        $ mkfs.ext4 /dev/pmem0
        $ mount -o errors=remount-ro /dev/pmem0 /mnt
        $ cat /proc/fs/ext4/pmem0/options | grep fc_debug_force
          #empty
        $ mount -o remount,errors=continue /mnt
        $ cat /proc/fs/ext4/pmem0/options | grep fc_debug_force
          fc_debug_force
        $ mount -o remount,errors=remount-ro,fc_debug_force /mnt
        $ cat /proc/fs/ext4/pmem0/options | grep fc_debug_force
          #empty
      
      Fixes: 995a3ed6 ("ext4: add fast_commit feature and handling for extended mount options")
      Signed-off-by: NZhang Yi <yi.zhang@huawei.com>
      
      Conflict:
        fs/ext4/super.c
      Reviewed-by: NZhihao Cheng <chengzhihao1@huawei.com>
      Reviewed-by: NZhang Xiaoxu <zhangxiaoxu5@huawei.com>
      Signed-off-by: NJialin Zhang <zhangjialin11@huawei.com>
      feb72ad7
  2. 13 3月, 2023 2 次提交
  3. 10 3月, 2023 2 次提交
  4. 09 3月, 2023 2 次提交
  5. 08 3月, 2023 30 次提交