1. 07 6月, 2023 6 次提交
    • Z
      block: Fix the partition start may overflow in add_partition() · a325a269
      Zhong Jinghua 提交于
      hulk inclusion
      category: bugfix
      bugzilla: 187268, https://gitee.com/openeuler/kernel/issues/I76JDY
      CVE: NA
      
      ----------------------------------------
      
      In the block_ioctl, we can pass in the unsigned number 0x8000000000000000
      as an input parameter, like below:
      
      block_ioctl
        blkdev_ioctl
          blkpg_ioctl
            blkpg_do_ioctl
              copy_from_user
              bdev_add_partition
                add_partition
                  p->start_sect = start; // start = 0x8000000000000000
      
      Then, there was an warning when submit bio:
      
      WARNING: CPU: 0 PID: 382 at fs/iomap/apply.c:54
      Call trace:
       iomap_apply+0x644/0x6e0
       __iomap_dio_rw+0x5cc/0xa24
       iomap_dio_rw+0x4c/0xcc
       ext4_dio_read_iter
       ext4_file_read_iter
       ext4_file_read_iter+0x318/0x39c
       call_read_iter
       lo_rw_aio.isra.0+0x748/0x75c
       do_req_filebacked+0x2d4/0x370
       loop_handle_cmd
       loop_queue_work+0x94/0x23c
       kthread_worker_fn+0x160/0x6bc
       loop_kthread_worker_fn+0x3c/0x50
       kthread+0x20c/0x25c
       ret_from_fork+0x10/0x18
      
      Stack:
      
      submit_bio_noacct
        submit_bio_checks
          blk_partition_remap
            bio->bi_iter.bi_sector += p->start_sect
            // bio->bi_iter.bi_sector = 0xffc0000000000000 + 65408
      ..
      loop_queue_work
       loop_handle_cmd
        do_req_filebacked
         pos = ((loff_t) blk_rq_pos(rq) << 9) + lo->lo_offset // pos < 0
         lo_rw_aio
           call_read_iter
            ext4_dio_read_iter
             __iomap_dio_rw
              iomap_apply
               ext4_iomap_begin
                 map.m_lblk = offset >> blkbits
                   ext4_set_iomap
                   iomap->offset = (u64) map->m_lblk << blkbits
                   // iomap->offset = 64512
               WARN_ON(iomap.offset > pos) // iomap.offset = 64512 and pos < 0
      
      This is unreasonable for start + length > disk->part0.nr_sects. There is
      already a similar check in blk_add_partition().
      Fix it by adding a check in bdev_add_partition().
      Signed-off-by: NZhong Jinghua <zhongjinghua@huawei.com>
      Reviewed-by: NHou Tao <houtao1@huawei.com>
      Signed-off-by: NYongqiang Liu <liuyongqiang13@huawei.com>
      a325a269
    • C
      block: refactor blkpg_ioctl · ad0628d3
      Christoph Hellwig 提交于
      mainline inclusion
      from mainline-v5.8-rc1
      commit fa9156ae
      category: bugfix
      bugzilla: 187268, https://gitee.com/openeuler/kernel/issues/I76JDY
      CVE: NA
      
      ----------------------------------------
      
      Split each sub-command out into a separate helper, and move those helpers
      to block/partitions/core.c instead of having a lot of partition
      manipulation logic open coded in block/ioctl.c.
      
      Signed-off-by: Christoph Hellwig <hch@lst.de
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      
      conflicts:
      	block/ioctl.c
      	block/partition-generic.c
      	include/linux/genhd.h
      Signed-off-by: NZhong Jinghua <zhongjinghua@huawei.com>
      Reviewed-by: NHou Tao <houtao1@huawei.com>
      Signed-off-by: NYongqiang Liu <liuyongqiang13@huawei.com>
      ad0628d3
    • Z
      nbd: get config_lock before sock_shutdown · 4b53fff3
      Zhong Jinghua 提交于
      hulk inclusion
      category: bugfix
      bugzilla: 188799, https://gitee.com/openeuler/kernel/issues/I79QWO
      CVE: NA
      
      ----------------------------------------
      
      Config->socks in sock_shutdown may trigger a UAF problem.
      The reason is that sock_shutdown does not hold the config_lock,
      so that nbd_ioctl can release config->socks at this time.
      
      T0: NBD_SET_SOCK
      T1: NBD_DO_IT
      
      T0						T1
      
      nbd_ioctl
        mutex_lock(&nbd->config_lock)
        // get lock
        __nbd_ioctl
      	nbd_start_device_ioctl
      	  nbd_start_device
      	  mutex_unlock(&nbd->config_lock)
      	  // relase lock
      	  wait_event_interruptible
      	  (kill, enter sock_shutdown)
      	  sock_shutdown
      					nbd_ioctl
      					  mutex_lock(&nbd->config_lock)
      					  // get lock
      					  __nbd_ioctl
      					    nbd_add_socket
      					      krealloc
      						kfree(p)
      					        //config->socks is NULL
      	    nbd_sock *nsock = config->socks // error
      
      Fix it by moving config_lock up before sock_shutdown.
      Signed-off-by: NZhong Jinghua <zhongjinghua@huawei.com>
      Reviewed-by: NYu Kuai <yukuai3@huawei.com>
      Reviewed-by: NHou Tao <houtao1@huawei.com>
      Signed-off-by: NYongqiang Liu <liuyongqiang13@huawei.com>
      4b53fff3
    • D
      ipv6: sr: fix out-of-bounds read when setting HMAC data. · d9d1ff02
      David Lebrun 提交于
      stable inclusion
      from stable-v4.19.258
      commit f684c16971ed5e77dfa25a9ad25b5297e1f58eab
      category: bugfix
      bugzilla: https://gitee.com/src-openeuler/kernel/issues/I7ASU6
      CVE: CVE-2023-2860
      
      Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=f684c16971ed5e77dfa25a9ad25b5297e1f58eab
      
      --------------------------------
      
      [ Upstream commit 84a53580 ]
      
      The SRv6 layer allows defining HMAC data that can later be used to sign IPv6
      Segment Routing Headers. This configuration is realised via netlink through
      four attributes: SEG6_ATTR_HMACKEYID, SEG6_ATTR_SECRET, SEG6_ATTR_SECRETLEN and
      SEG6_ATTR_ALGID. Because the SECRETLEN attribute is decoupled from the actual
      length of the SECRET attribute, it is possible to provide invalid combinations
      (e.g., secret = "", secretlen = 64). This case is not checked in the code and
      with an appropriately crafted netlink message, an out-of-bounds read of up
      to 64 bytes (max secret length) can occur past the skb end pointer and into
      skb_shared_info:
      
      Breakpoint 1, seg6_genl_sethmac (skb=<optimized out>, info=<optimized out>) at net/ipv6/seg6.c:208
      208		memcpy(hinfo->secret, secret, slen);
      (gdb) bt
       #0  seg6_genl_sethmac (skb=<optimized out>, info=<optimized out>) at net/ipv6/seg6.c:208
       #1  0xffffffff81e012e9 in genl_family_rcv_msg_doit (skb=skb@entry=0xffff88800b1f9f00, nlh=nlh@entry=0xffff88800b1b7600,
          extack=extack@entry=0xffffc90000ba7af0, ops=ops@entry=0xffffc90000ba7a80, hdrlen=4, net=0xffffffff84237580 <init_net>, family=<optimized out>,
          family=<optimized out>) at net/netlink/genetlink.c:731
       #2  0xffffffff81e01435 in genl_family_rcv_msg (extack=0xffffc90000ba7af0, nlh=0xffff88800b1b7600, skb=0xffff88800b1f9f00,
          family=0xffffffff82fef6c0 <seg6_genl_family>) at net/netlink/genetlink.c:775
       #3  genl_rcv_msg (skb=0xffff88800b1f9f00, nlh=0xffff88800b1b7600, extack=0xffffc90000ba7af0) at net/netlink/genetlink.c:792
       #4  0xffffffff81dfffc3 in netlink_rcv_skb (skb=skb@entry=0xffff88800b1f9f00, cb=cb@entry=0xffffffff81e01350 <genl_rcv_msg>)
          at net/netlink/af_netlink.c:2501
       #5  0xffffffff81e00919 in genl_rcv (skb=0xffff88800b1f9f00) at net/netlink/genetlink.c:803
       #6  0xffffffff81dff6ae in netlink_unicast_kernel (ssk=0xffff888010eec800, skb=0xffff88800b1f9f00, sk=0xffff888004aed000)
          at net/netlink/af_netlink.c:1319
       #7  netlink_unicast (ssk=ssk@entry=0xffff888010eec800, skb=skb@entry=0xffff88800b1f9f00, portid=portid@entry=0, nonblock=<optimized out>)
          at net/netlink/af_netlink.c:1345
       #8  0xffffffff81dff9a4 in netlink_sendmsg (sock=<optimized out>, msg=0xffffc90000ba7e48, len=<optimized out>) at net/netlink/af_netlink.c:1921
      ...
      (gdb) p/x ((struct sk_buff *)0xffff88800b1f9f00)->head + ((struct sk_buff *)0xffff88800b1f9f00)->end
      $1 = 0xffff88800b1b76c0
      (gdb) p/x secret
      $2 = 0xffff88800b1b76c0
      (gdb) p slen
      $3 = 64 '@'
      
      The OOB data can then be read back from userspace by dumping HMAC state. This
      commit fixes this by ensuring SECRETLEN cannot exceed the actual length of
      SECRET.
      Reported-by: NLucas Leong <wmliang.tw@gmail.com>
      Tested: verified that EINVAL is correctly returned when secretlen > len(secret)
      Fixes: 4f4853dc ("ipv6: sr: implement API to control SR HMAC structure")
      Signed-off-by: NDavid Lebrun <dlebrun@google.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NZiyang Xuan <william.xuanziyang@huawei.com>
      Reviewed-by: NLiu Jian <liujian56@huawei.com>
      Reviewed-by: NWang Weiyang <wangweiyang2@huawei.com>
      Signed-off-by: NYongqiang Liu <liuyongqiang13@huawei.com>
      d9d1ff02
    • L
      dm: add disk before alloc dax · ee776389
      Li Lingfeng 提交于
      hulk inclusion
      category: feature
      bugzilla: https://gitee.com/openeuler/kernel/issues/I78SWJ
      CVE: NA
      
      -------------------------------
      
      In dm_create(), alloc_dev() may trigger panic if alloc_dax() fail since
      del_gendisk() will be called with add_disk() wasn't called before.
      
      Call add_disk() before alloc_dax() to avoid it.
      Signed-off-by: NLi Lingfeng <lilingfeng3@huawei.com>
      Reviewed-by: NHou Tao <houtao1@huawei.com>
      Signed-off-by: NYongqiang Liu <liuyongqiang13@huawei.com>
      ee776389
    • L
      dm thin: Fix ABBA deadlock by resetting dm_bufio_client · c7ca9c06
      Li Lingfeng 提交于
      hulk inclusion
      category: bugfix
      bugzilla: https://gitee.com/openeuler/kernel/issues/I79ZEK
      CVE: NA
      
      --------------------------------
      
      As described in commit 273494b2 ("dm thin: Fix ABBA deadlock between
      shrink_slab and dm_pool_abort_metadata"), ABBA deadlock will be triggered
      since shrinker_rwsem need to be held when operations failed on dm pool
      metadata.
      
      We have noticed the following three problem scenarios:
      1) Described by commit 273494b2 ("dm thin: Fix ABBA deadlock between
      shrink_slab and dm_pool_abort_metadata")
      
      2) shrinker_rwsem and throttle->lock
                P1(drop cache)                        P2(kworker)
      drop_caches_sysctl_handler
       drop_slab
        shrink_slab
         down_read(&shrinker_rwsem)  - LOCK A
         do_shrink_slab
          super_cache_scan
           prune_icache_sb
            dispose_list
             evict
              ext4_evict_inode
               ext4_clear_inode
                ext4_discard_preallocations
                 ext4_mb_load_buddy_gfp
                  ext4_mb_init_cache
                   ext4_wait_block_bitmap
                    __ext4_error
                     ext4_handle_error
                      ext4_commit_super
                       ...
                       dm_submit_bio
                                           do_worker
                                            throttle_work_update
                                             down_write(&t->lock) -- LOCK B
                                            process_deferred_bios
                                             commit
                                              metadata_operation_failed
                                               dm_pool_abort_metadata
                                                dm_block_manager_create
                                                 dm_bufio_client_create
                                                  register_shrinker
                                                   down_write(&shrinker_rwsem)
                                                   -- LOCK A
                       thin_map
                        thin_bio_map
                         thin_defer_bio_with_throttle
                          throttle_lock
                           down_read(&t->lock)  - LOCK B
      
      3) shrinker_rwsem and wait_on_buffer
                P1(drop cache)                            P2(kworker)
      drop_caches_sysctl_handler
       drop_slab
        shrink_slab
         down_read(&shrinker_rwsem)  - LOCK A
         do_shrink_slab
         ...
          ext4_wait_block_bitmap
           __ext4_error
            ext4_handle_error
             jbd2_journal_abort
              jbd2_journal_update_sb_errno
               jbd2_write_superblock
                submit_bh
                 // LOCK B
                 // RELEASE B
                                   do_worker
                                    throttle_work_update
                                     down_write(&t->lock) - LOCK B
                                    process_deferred_bios
                                     process_bio
                                     commit
                                      metadata_operation_failed
                                       dm_pool_abort_metadata
                                        dm_block_manager_create
                                         dm_bufio_client_create
                                          register_shrinker
                                           register_shrinker_prepared
                                            down_write(&shrinker_rwsem)  - LOCK A
                                     bio_endio
            wait_on_buffer
             __wait_on_buffer
      
      Fix these by resetting dm_bufio_client without holding shrinker_rwsem.
      Signed-off-by: NLi Lingfeng <lilingfeng3@huawei.com>
      Reviewed-by: NHou Tao <houtao1@huawei.com>
      Signed-off-by: NYongqiang Liu <liuyongqiang13@huawei.com>
      c7ca9c06
  2. 06 6月, 2023 5 次提交
  3. 02 6月, 2023 1 次提交
  4. 01 6月, 2023 1 次提交
    • Z
      net: sched: fix NULL pointer dereference in mq_attach · 90dd6587
      Zhengchao Shao 提交于
      mainline inclusion
      from mainline-v6.4-rc5
      commit 36eec020
      category: bugfix
      bugzilla: https://gitee.com/openeuler/kernel/issues/I79V6E
      CVE: NA
      
      Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=36eec020fab668719b541f34d97f44e232ffa165
      
      --------------------------------
      
      When use the following command to test:
      1)ip link add bond0 type bond
      2)ip link set bond0 up
      3)tc qdisc add dev bond0 root handle ffff: mq
      4)tc qdisc replace dev bond0 parent ffff:fff1 handle ffff: mq
      
      The kernel reports NULL pointer dereference issue. The stack information
      is as follows:
      Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000
      Internal error: Oops: 0000000096000006 [#1] SMP
      Modules linked in:
      pstate: 20000005 (nzCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
      pc : mq_attach+0x44/0xa0
      lr : qdisc_graft+0x20c/0x5cc
      sp : ffff80000e2236a0
      x29: ffff80000e2236a0 x28: ffff0000c0e59d80 x27: ffff0000c0be19c0
      x26: ffff0000cae3e800 x25: 0000000000000010 x24: 00000000fffffff1
      x23: 0000000000000000 x22: ffff0000cae3e800 x21: ffff0000c9df4000
      x20: ffff0000c9df4000 x19: 0000000000000000 x18: ffff80000a934000
      x17: ffff8000f5b56000 x16: ffff80000bb08000 x15: 0000000000000000
      x14: 0000000000000000 x13: 6b6b6b6b6b6b6b6b x12: 6b6b6b6b00000001
      x11: 0000000000000000 x10: 0000000000000000 x9 : 0000000000000000
      x8 : ffff0000c0be0730 x7 : bbbbbbbbbbbbbbbb x6 : 0000000000000008
      x5 : ffff0000cae3e864 x4 : 0000000000000000 x3 : 0000000000000001
      x2 : 0000000000000001 x1 : ffff8000090bc23c x0 : 0000000000000000
      Call trace:
      mq_attach+0x44/0xa0
      qdisc_graft+0x20c/0x5cc
      tc_modify_qdisc+0x1c4/0x664
      rtnetlink_rcv_msg+0x354/0x440
      netlink_rcv_skb+0x64/0x144
      rtnetlink_rcv+0x28/0x34
      netlink_unicast+0x1e8/0x2a4
      netlink_sendmsg+0x308/0x4a0
      sock_sendmsg+0x64/0xac
      ____sys_sendmsg+0x29c/0x358
      ___sys_sendmsg+0x90/0xd0
      __sys_sendmsg+0x7c/0xd0
      __arm64_sys_sendmsg+0x2c/0x38
      invoke_syscall+0x54/0x114
      el0_svc_common.constprop.1+0x90/0x174
      do_el0_svc+0x3c/0xb0
      el0_svc+0x24/0xec
      el0t_64_sync_handler+0x90/0xb4
      el0t_64_sync+0x174/0x178
      
      This is because when mq is added for the first time, qdiscs in mq is set
      to NULL in mq_attach(). Therefore, when replacing mq after adding mq, we
      need to initialize qdiscs in the mq before continuing to graft. Otherwise,
      it will couse NULL pointer dereference issue in mq_attach(). And the same
      issue will occur in the attach functions of mqprio, taprio and htb.
      ffff:fff1 means that the repalce qdisc is ingress. Ingress does not allow
      any qdisc to be attached. Therefore, ffff:fff1 is incorrectly used, and
      the command should be dropped.
      
      Fixes: 6ec1c69a ("net_sched: add classful multiqueue dummy scheduler")
      Signed-off-by: NZhengchao Shao <shaozhengchao@huawei.com>
      Tested-by: NPeilin Ye <peilin.ye@bytedance.com>
      Acked-by: NJamal Hadi Salim <jhs@mojatatu.com>
      Link: https://lore.kernel.org/r/20230527093747.3583502-1-shaozhengchao@huawei.comSigned-off-by: NJakub Kicinski <kuba@kernel.org>
      Reviewed-by: NLiu Jian <liujian56@huawei.com>
      Signed-off-by: NYongqiang Liu <liuyongqiang13@huawei.com>
      90dd6587
  5. 31 5月, 2023 1 次提交
    • O
      !841 【openEuler-1.0-LTS】cpufreq: conservative: Add a switch to enable fast mode · 6ce8e9f4
      openeuler-ci-bot 提交于
      Merge Pull Request from: @xuesinian 
       
      Frequency scaling strategy switch for fast mode. Enable conservative governor changing frequency a little bit quickly.
      
      Conservative governor belongs to a slow frequency governor. In some scenarios where performance loss is significant. Therefore, endow the conservative governor with fast frequency scaling capability and add switches to use fast mode in these scenarios to reduce performance loss.
      
      Related issue : #I78PCH 
       
      Link:https://gitee.com/openeuler/kernel/pulls/841 
      
      Reviewed-by: Xiongfeng Wang <wangxiongfeng2@huawei.com> 
      Signed-off-by: Zhang Changzhong <zhangchangzhong@huawei.com> 
      Acked-by: Xie XiuQi <xiexiuqi@huawei.com> 
      6ce8e9f4
  6. 30 5月, 2023 3 次提交
  7. 29 5月, 2023 1 次提交
  8. 27 5月, 2023 6 次提交
  9. 22 5月, 2023 1 次提交
  10. 18 5月, 2023 3 次提交
    • N
      x86/msr-index: make SPEC_CTRL_IBRS assembler-portable · 2b05b5e1
      Nick Desaulniers 提交于
      maillist inclusion
      category: bugfix
      bugzilla: https://gitee.com/src-openeuler/kernel/issues/I6V709
      CVE: NA
      
      Reference: https://lore.kernel.org/lkml/20221103210748.1343090-1-ndesaulniers@google.com/T/#m9aaa15d32b7dc265e15e9be934bd6ceb0395cf16
      
      --------------------------------
      
      GNU binutils' assembler (GAS) didn't support L suffixes on immediates
      until binutils 2.28 release. Building arch/x86/entry/entry_64.S with GAS
      v2.27 will produce the following assembler errors:
      
        arch/x86/entry/entry_64.S: Assembler messages:
        arch/x86/entry/entry_64.S:308: Error: found 'L', expected: ')'
        arch/x86/entry/entry_64.S:308: Error: found 'L', expected: ')'
        arch/x86/entry/entry_64.S:308: Error: junk `L<<(0)))' after expression
        arch/x86/entry/entry_64.S:596: Error: found 'L', expected: ')'
        arch/x86/entry/entry_64.S:596: Error: found 'L', expected: ')'
        arch/x86/entry/entry_64.S:596: Error: junk `L<<(0)))' after expression
      
      These come from the use of the preprocessor defined SPEC_CTRL_IBRS in
      the IBRS_ENTER and IBRS_EXIT assembler macros. SPEC_CTRL_IBRS was using
      the BIT macros from include/linux/bits.h which are only portable between
      C and assembler for assemblers such as GAS v2.28 (or newer) or clang
      because they use the L suffixes for immediate operands, which older GAS
      releases cannot parse. The kernel still supports GAS v2.23 and newer
      (and older for branches of stable). Let's expand the value of
      SPEC_CTRL_IBRS in place so that assemblers don't have issues parsing the
      value.
      
      Fixes: 2dbb887e ("x86/entry: Add kernel IBRS implementation")
      Reported-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: NNick Desaulniers <ndesaulniers@google.com>
      Signed-off-by: NLin Yujun <linyujun809@huawei.com>
      Reviewed-by: NLiao Chang <liaochang1@huawei.com>
      Reviewed-by: NZhang Jianhua <chris.zjh@huawei.com>
      Signed-off-by: NYongqiang Liu <liuyongqiang13@huawei.com>
      2b05b5e1
    • D
      xfs: verify buffer contents when we skip log replay · f5a69974
      Darrick J. Wong 提交于
      mainline inclusion
      from mainline-v6.3-rc6
      commit 22ed903e
      category: bugfix
      bugzilla: https://gitee.com/src-openeuler/kernel/issues/I6X4UN
      CVE: CVE-2023-2124
      
      Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=22ed903eee23a5b174e240f1cdfa9acf393a5210
      
      --------------------------------
      
      syzbot detected a crash during log recovery:
      
      XFS (loop0): Mounting V5 Filesystem bfdc47fc-10d8-4eed-a562-11a831b3f791
      XFS (loop0): Torn write (CRC failure) detected at log block 0x180. Truncating head block from 0x200.
      XFS (loop0): Starting recovery (logdev: internal)
      ==================================================================
      BUG: KASAN: slab-out-of-bounds in xfs_btree_lookup_get_block+0x15c/0x6d0 fs/xfs/libxfs/xfs_btree.c:1813
      Read of size 8 at addr ffff88807e89f258 by task syz-executor132/5074
      
      CPU: 0 PID: 5074 Comm: syz-executor132 Not tainted 6.2.0-rc1-syzkaller #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022
      Call Trace:
       <TASK>
       __dump_stack lib/dump_stack.c:88 [inline]
       dump_stack_lvl+0x1b1/0x290 lib/dump_stack.c:106
       print_address_description+0x74/0x340 mm/kasan/report.c:306
       print_report+0x107/0x1f0 mm/kasan/report.c:417
       kasan_report+0xcd/0x100 mm/kasan/report.c:517
       xfs_btree_lookup_get_block+0x15c/0x6d0 fs/xfs/libxfs/xfs_btree.c:1813
       xfs_btree_lookup+0x346/0x12c0 fs/xfs/libxfs/xfs_btree.c:1913
       xfs_btree_simple_query_range+0xde/0x6a0 fs/xfs/libxfs/xfs_btree.c:4713
       xfs_btree_query_range+0x2db/0x380 fs/xfs/libxfs/xfs_btree.c:4953
       xfs_refcount_recover_cow_leftovers+0x2d1/0xa60 fs/xfs/libxfs/xfs_refcount.c:1946
       xfs_reflink_recover_cow+0xab/0x1b0 fs/xfs/xfs_reflink.c:930
       xlog_recover_finish+0x824/0x920 fs/xfs/xfs_log_recover.c:3493
       xfs_log_mount_finish+0x1ec/0x3d0 fs/xfs/xfs_log.c:829
       xfs_mountfs+0x146a/0x1ef0 fs/xfs/xfs_mount.c:933
       xfs_fs_fill_super+0xf95/0x11f0 fs/xfs/xfs_super.c:1666
       get_tree_bdev+0x400/0x620 fs/super.c:1282
       vfs_get_tree+0x88/0x270 fs/super.c:1489
       do_new_mount+0x289/0xad0 fs/namespace.c:3145
       do_mount fs/namespace.c:3488 [inline]
       __do_sys_mount fs/namespace.c:3697 [inline]
       __se_sys_mount+0x2d3/0x3c0 fs/namespace.c:3674
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x63/0xcd
      RIP: 0033:0x7f89fa3f4aca
      Code: 83 c4 08 5b 5d c3 66 2e 0f 1f 84 00 00 00 00 00 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 49 89 ca b8 a5 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 c0 ff ff ff f7 d8 64 89 01 48
      RSP: 002b:00007fffd5fb5ef8 EFLAGS: 00000206 ORIG_RAX: 00000000000000a5
      RAX: ffffffffffffffda RBX: 00646975756f6e2c RCX: 00007f89fa3f4aca
      RDX: 0000000020000100 RSI: 0000000020009640 RDI: 00007fffd5fb5f10
      RBP: 00007fffd5fb5f10 R08: 00007fffd5fb5f50 R09: 000000000000970d
      R10: 0000000000200800 R11: 0000000000000206 R12: 0000000000000004
      R13: 0000555556c6b2c0 R14: 0000000000200800 R15: 00007fffd5fb5f50
       </TASK>
      
      The fuzzed image contains an AGF with an obviously garbage
      agf_refcount_level value of 32, and a dirty log with a buffer log item
      for that AGF.  The ondisk AGF has a higher LSN than the recovered log
      item.  xlog_recover_buf_commit_pass2 reads the buffer, compares the
      LSNs, and decides to skip replay because the ondisk buffer appears to be
      newer.
      
      Unfortunately, the ondisk buffer is corrupt, but recovery just read the
      buffer with no buffer ops specified:
      
      	error = xfs_buf_read(mp->m_ddev_targp, buf_f->blf_blkno,
      			buf_f->blf_len, buf_flags, &bp, NULL);
      
      Skipping the buffer leaves its contents in memory unverified.  This sets
      us up for a kernel crash because xfs_refcount_recover_cow_leftovers
      reads the buffer (which is still around in XBF_DONE state, so no read
      verification) and creates a refcountbt cursor of height 32.  This is
      impossible so we run off the end of the cursor object and crash.
      
      Fix this by invoking the verifier on all skipped buffers and aborting
      log recovery if the ondisk buffer is corrupt.  It might be smarter to
      force replay the log item atop the buffer and then see if it'll pass the
      write verifier (like ext4 does) but for now let's go with the
      conservative option where we stop immediately.
      
      Link: https://syzkaller.appspot.com/bug?extid=7e9494b8b399902e994eSigned-off-by: NDarrick J. Wong <djwong@kernel.org>
      Reviewed-by: NDave Chinner <dchinner@redhat.com>
      Signed-off-by: NDave Chinner <david@fromorbit.com>
      
      Conflicts:
      	fs/xfs/xfs_log_recover.c
      Signed-off-by: NLong Li <leo.lilong@huawei.com>
      Reviewed-by: NZhang Yi <yi.zhang@huawei.com>
      Reviewed-by: NXiu Jianfeng <xiujianfeng@huawei.com>
      Signed-off-by: NYongqiang Liu <liuyongqiang13@huawei.com>
      f5a69974
    • O
      !586 [openEuelr-1.0-LTS] kvm: arm64: fix some pvsched bugs · 8bf8523b
      openeuler-ci-bot 提交于
      Merge Pull Request from: @jiaoff 
       
      kvm: arm64: fix some pvsched bugs
      
      Clear kvm_vcpu_arch::pvsched::base on vcpu reset
      The guest memory will otherwise be corrupted by KVM if we reboot into
      an old guest kernel which is not aware of the pvsched feature.
      
      Fix boot cpu pvsched init abnormal
      The pv_sched_init was called too early in the boot in setup_arch, hence
      pvsched_vcpu_state was not initializedfo vcpu 0.
      
      https://gitee.com/openeuler/kernel/issues/I6WRGD?from=project-issue 
       
      Link:https://gitee.com/openeuler/kernel/pulls/586 
      
      Reviewed-by: Kevin Zhu <zhukeqian1@huawei.com> 
      Signed-off-by: Zhang Changzhong <zhangchangzhong@huawei.com> 
      8bf8523b
  11. 12 5月, 2023 4 次提交
  12. 11 5月, 2023 7 次提交
    • O
      !437 [openEuler-1.0-LTS] USB: HCD: Fix URB giveback issue in tasklet function · 951bd644
      openeuler-ci-bot 提交于
      Merge Pull Request from: @leoliu-oc 
       
      Backport USB bugfix patch from linux mainline.
      commit 26c6c2f8 upstream.
      
      Issue
      https://gitee.com/openeuler/kernel/issues/I62VRB
      
      Test
      FIO/Iometer test: 
      Set Block size to 4k and randomly read in libaio mode to test for keyboard and mouse jamming.
      During the FIO/Iometer performance test, there will be no jamming of the mouse and keyboard.
      
      Knowe Issue
      N/A
      
      Default config change
      N/A 
       
      Link:https://gitee.com/openeuler/kernel/pulls/437 
      
      Reviewed-by: Zheng Zengkai <zhengzengkai@huawei.com> 
      Signed-off-by: Zhang Changzhong <zhangchangzhong@huawei.com> 
      951bd644
    • L
      openeuler_defconfig: Add configuration items for zhaoxin · 7a9fe891
      leoliu-oc 提交于
      zhaoxin inclusion
      category: other
      bugzilla: https://gitee.com/openeuler/kernel/issues/I722EJ
      CVE: NA
      
      ----------------------------------------------------------------
      
      Set the default configuration for the Zhaoxin CPUs.
      Signed-off-by: Nleoliu-oc <leoliu-oc@zhaoxin.com>
      7a9fe891
    • R
      bluetooth: Perform careful capability checks in hci_sock_ioctl() · 63055a9f
      Ruihan Li 提交于
      mainline inclusion
      from mainline-v6.4-rc1
      commit 25c150ac
      category: bugfix
      bugzilla: https://gitee.com/src-openeuler/kernel/issues/I6WHKQ
      CVE: CVE-2023-2002
      
      Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit?id=25c150ac103a4ebeed0319994c742a90634ddf18
      
      ----------------------------------------
      
      Previously, capability was checked using capable(), which verified that the
      caller of the ioctl system call had the required capability. In addition,
      the result of the check would be stored in the HCI_SOCK_TRUSTED flag,
      making it persistent for the socket.
      
      However, malicious programs can abuse this approach by deliberately sharing
      an HCI socket with a privileged task. The HCI socket will be marked as
      trusted when the privileged task occasionally makes an ioctl call.
      
      This problem can be solved by using sk_capable() to check capability, which
      ensures that not only the current task but also the socket opener has the
      specified capability, thus reducing the risk of privilege escalation
      through the previously identified vulnerability.
      
      Cc: stable@vger.kernel.org
      Fixes: f81f5b2d ("Bluetooth: Send control open and close messages for HCI raw sockets")
      Signed-off-by: NRuihan Li <lrh2000@pku.edu.cn>
      Signed-off-by: NLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      Signed-off-by: NZiyang Xuan <william.xuanziyang@huawei.com>
      Reviewed-by: NLiu Jian <liujian56@huawei.com>
      Reviewed-by: NWang Weiyang <wangweiyang2@huawei.com>
      Signed-off-by: NYongqiang Liu <liuyongqiang13@huawei.com>
      63055a9f
    • H
      netrom: Fix use-after-free caused by accept on already connected socket · 768851b2
      Hyunwoo Kim 提交于
      stable inclusion
      from stable-v4.19.273
      commit 2c1984d101978e979783bdb2376eb6eca9f8f627
      category: bugfix
      bugzilla: https://gitee.com/src-openeuler/kernel/issues/I70OFF
      CVE: CVE-2023-32269
      
      Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=2c1984d101978e979783bdb2376eb6eca9f8f627
      
      --------------------------------
      
      [ Upstream commit 61179292 ]
      
      If you call listen() and accept() on an already connect()ed
      AF_NETROM socket, accept() can successfully connect.
      This is because when the peer socket sends data to sendmsg,
      the skb with its own sk stored in the connected socket's
      sk->sk_receive_queue is connected, and nr_accept() dequeues
      the skb waiting in the sk->sk_receive_queue.
      
      As a result, nr_accept() allocates and returns a sock with
      the sk of the parent AF_NETROM socket.
      
      And here use-after-free can happen through complex race conditions:
      ```
                        cpu0                                                     cpu1
                                                                     1. socket_2 = socket(AF_NETROM)
                                                                              .
                                                                              .
                                                                        listen(socket_2)
                                                                        accepted_socket = accept(socket_2)
             2. socket_1 = socket(AF_NETROM)
                  nr_create()    // sk refcount : 1
                connect(socket_1)
                                                                     3. write(accepted_socket)
                                                                          nr_sendmsg()
                                                                          nr_output()
                                                                          nr_kick()
                                                                          nr_send_iframe()
                                                                          nr_transmit_buffer()
                                                                          nr_route_frame()
                                                                          nr_loopback_queue()
                                                                          nr_loopback_timer()
                                                                          nr_rx_frame()
                                                                          nr_process_rx_frame(sk, skb);    // sk : socket_1's sk
                                                                          nr_state3_machine()
                                                                          nr_queue_rx_frame()
                                                                          sock_queue_rcv_skb()
                                                                          sock_queue_rcv_skb_reason()
                                                                          __sock_queue_rcv_skb()
                                                                          __skb_queue_tail(list, skb);    // list : socket_1's sk->sk_receive_queue
             4. listen(socket_1)
                  nr_listen()
                uaf_socket = accept(socket_1)
                  nr_accept()
                  skb_dequeue(&sk->sk_receive_queue);
                                                                     5. close(accepted_socket)
                                                                          nr_release()
                                                                          nr_write_internal(sk, NR_DISCREQ)
                                                                          nr_transmit_buffer()    // NR_DISCREQ
                                                                          nr_route_frame()
                                                                          nr_loopback_queue()
                                                                          nr_loopback_timer()
                                                                          nr_rx_frame()    // sk : socket_1's sk
                                                                          nr_process_rx_frame()  // NR_STATE_3
                                                                          nr_state3_machine()    // NR_DISCREQ
                                                                          nr_disconnect()
                                                                          nr_sk(sk)->state = NR_STATE_0;
             6. close(socket_1)    // sk refcount : 3
                  nr_release()    // NR_STATE_0
                  sock_put(sk);    // sk refcount : 0
                  sk_free(sk);
                close(uaf_socket)
                  nr_release()
                  sock_hold(sk);    // UAF
      ```
      
      KASAN report by syzbot:
      ```
      BUG: KASAN: use-after-free in nr_release+0x66/0x460 net/netrom/af_netrom.c:520
      Write of size 4 at addr ffff8880235d8080 by task syz-executor564/5128
      
      Call Trace:
       <TASK>
       __dump_stack lib/dump_stack.c:88 [inline]
       dump_stack_lvl+0xd1/0x138 lib/dump_stack.c:106
       print_address_description mm/kasan/report.c:306 [inline]
       print_report+0x15e/0x461 mm/kasan/report.c:417
       kasan_report+0xbf/0x1f0 mm/kasan/report.c:517
       check_region_inline mm/kasan/generic.c:183 [inline]
       kasan_check_range+0x141/0x190 mm/kasan/generic.c:189
       instrument_atomic_read_write include/linux/instrumented.h:102 [inline]
       atomic_fetch_add_relaxed include/linux/atomic/atomic-instrumented.h:116 [inline]
       __refcount_add include/linux/refcount.h:193 [inline]
       __refcount_inc include/linux/refcount.h:250 [inline]
       refcount_inc include/linux/refcount.h:267 [inline]
       sock_hold include/net/sock.h:775 [inline]
       nr_release+0x66/0x460 net/netrom/af_netrom.c:520
       __sock_release+0xcd/0x280 net/socket.c:650
       sock_close+0x1c/0x20 net/socket.c:1365
       __fput+0x27c/0xa90 fs/file_table.c:320
       task_work_run+0x16f/0x270 kernel/task_work.c:179
       exit_task_work include/linux/task_work.h:38 [inline]
       do_exit+0xaa8/0x2950 kernel/exit.c:867
       do_group_exit+0xd4/0x2a0 kernel/exit.c:1012
       get_signal+0x21c3/0x2450 kernel/signal.c:2859
       arch_do_signal_or_restart+0x79/0x5c0 arch/x86/kernel/signal.c:306
       exit_to_user_mode_loop kernel/entry/common.c:168 [inline]
       exit_to_user_mode_prepare+0x15f/0x250 kernel/entry/common.c:203
       __syscall_exit_to_user_mode_work kernel/entry/common.c:285 [inline]
       syscall_exit_to_user_mode+0x1d/0x50 kernel/entry/common.c:296
       do_syscall_64+0x46/0xb0 arch/x86/entry/common.c:86
       entry_SYSCALL_64_after_hwframe+0x63/0xcd
      RIP: 0033:0x7f6c19e3c9b9
      Code: Unable to access opcode bytes at 0x7f6c19e3c98f.
      RSP: 002b:00007fffd4ba2ce8 EFLAGS: 00000246 ORIG_RAX: 0000000000000133
      RAX: 0000000000000116 RBX: 0000000000000003 RCX: 00007f6c19e3c9b9
      RDX: 0000000000000318 RSI: 00000000200bd000 RDI: 0000000000000006
      RBP: 0000000000000003 R08: 000000000000000d R09: 000000000000000d
      R10: 0000000000000000 R11: 0000000000000246 R12: 000055555566a2c0
      R13: 0000000000000011 R14: 0000000000000000 R15: 0000000000000000
       </TASK>
      
      Allocated by task 5128:
       kasan_save_stack+0x22/0x40 mm/kasan/common.c:45
       kasan_set_track+0x25/0x30 mm/kasan/common.c:52
       ____kasan_kmalloc mm/kasan/common.c:371 [inline]
       ____kasan_kmalloc mm/kasan/common.c:330 [inline]
       __kasan_kmalloc+0xa3/0xb0 mm/kasan/common.c:380
       kasan_kmalloc include/linux/kasan.h:211 [inline]
       __do_kmalloc_node mm/slab_common.c:968 [inline]
       __kmalloc+0x5a/0xd0 mm/slab_common.c:981
       kmalloc include/linux/slab.h:584 [inline]
       sk_prot_alloc+0x140/0x290 net/core/sock.c:2038
       sk_alloc+0x3a/0x7a0 net/core/sock.c:2091
       nr_create+0xb6/0x5f0 net/netrom/af_netrom.c:433
       __sock_create+0x359/0x790 net/socket.c:1515
       sock_create net/socket.c:1566 [inline]
       __sys_socket_create net/socket.c:1603 [inline]
       __sys_socket_create net/socket.c:1588 [inline]
       __sys_socket+0x133/0x250 net/socket.c:1636
       __do_sys_socket net/socket.c:1649 [inline]
       __se_sys_socket net/socket.c:1647 [inline]
       __x64_sys_socket+0x73/0xb0 net/socket.c:1647
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x63/0xcd
      
      Freed by task 5128:
       kasan_save_stack+0x22/0x40 mm/kasan/common.c:45
       kasan_set_track+0x25/0x30 mm/kasan/common.c:52
       kasan_save_free_info+0x2b/0x40 mm/kasan/generic.c:518
       ____kasan_slab_free mm/kasan/common.c:236 [inline]
       ____kasan_slab_free+0x13b/0x1a0 mm/kasan/common.c:200
       kasan_slab_free include/linux/kasan.h:177 [inline]
       __cache_free mm/slab.c:3394 [inline]
       __do_kmem_cache_free mm/slab.c:3580 [inline]
       __kmem_cache_free+0xcd/0x3b0 mm/slab.c:3587
       sk_prot_free net/core/sock.c:2074 [inline]
       __sk_destruct+0x5df/0x750 net/core/sock.c:2166
       sk_destruct net/core/sock.c:2181 [inline]
       __sk_free+0x175/0x460 net/core/sock.c:2192
       sk_free+0x7c/0xa0 net/core/sock.c:2203
       sock_put include/net/sock.h:1991 [inline]
       nr_release+0x39e/0x460 net/netrom/af_netrom.c:554
       __sock_release+0xcd/0x280 net/socket.c:650
       sock_close+0x1c/0x20 net/socket.c:1365
       __fput+0x27c/0xa90 fs/file_table.c:320
       task_work_run+0x16f/0x270 kernel/task_work.c:179
       exit_task_work include/linux/task_work.h:38 [inline]
       do_exit+0xaa8/0x2950 kernel/exit.c:867
       do_group_exit+0xd4/0x2a0 kernel/exit.c:1012
       get_signal+0x21c3/0x2450 kernel/signal.c:2859
       arch_do_signal_or_restart+0x79/0x5c0 arch/x86/kernel/signal.c:306
       exit_to_user_mode_loop kernel/entry/common.c:168 [inline]
       exit_to_user_mode_prepare+0x15f/0x250 kernel/entry/common.c:203
       __syscall_exit_to_user_mode_work kernel/entry/common.c:285 [inline]
       syscall_exit_to_user_mode+0x1d/0x50 kernel/entry/common.c:296
       do_syscall_64+0x46/0xb0 arch/x86/entry/common.c:86
       entry_SYSCALL_64_after_hwframe+0x63/0xcd
      ```
      
      To fix this issue, nr_listen() returns -EINVAL for sockets that
      successfully nr_connect().
      
      Reported-by: syzbot+caa188bdfc1eeafeb418@syzkaller.appspotmail.com
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Signed-off-by: NHyunwoo Kim <v4bel@theori.io>
      Reviewed-by: NKuniyuki Iwashima <kuniyu@amazon.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NZiyang Xuan <william.xuanziyang@huawei.com>
      Reviewed-by: NLiu Jian <liujian56@huawei.com>
      Reviewed-by: NXiu Jianfeng <xiujianfeng@huawei.com>
      Signed-off-by: NYongqiang Liu <liuyongqiang13@huawei.com>
      768851b2
    • O
      !689 Fix compile error in allyesconfigs · 802a6328
      openeuler-ci-bot 提交于
      Merge Pull Request from: @aspiresky01 
       
      When using allyesconfig to configure the kernel, errors may occur during the linking process when making. 
       
      Link:https://gitee.com/openeuler/kernel/pulls/689 
      
      Reviewed-by: Chiqijun <chiqijun@huawei.com> 
      Signed-off-by: Zhang Changzhong <zhangchangzhong@huawei.com> 
      802a6328
    • O
      !441 [openEuler-1.0-LTS] Add support for Zhaoxin SM3 and SM4 instruction · e87dfde7
      openeuler-ci-bot 提交于
      Merge Pull Request from: @leoliu-oc 
       
      Include 2 patches:
      1. Driver for Zhaoxin GMI SM3 Secure Hash algorithm
      This SM3 algorithm driver is developed to support the SM3 instruction, making user develop their applications with both high performance and high security.
      
      2. Driver for Zhaoxin GMI SM4 Block Cipher Algorithm
      This SM4 algorithm driver is developed to support the SM4 instruction, making user develop their applications with both high performance and high security.
      
      Issue
      https://gitee.com/openeuler/kernel/issues/I6J50I
      
      Test
      N/A
      
      Knowe Issue
      N/A
      
      Introduced config change
      CONFIG_CRYPTO_DEV_ZHAOXIN_SM3=m
      CONFIG_CRYPTO_DEV_ZHAOXIN_SM4=m 
       
      Link:https://gitee.com/openeuler/kernel/pulls/441 
      
      Reviewed-by: Zheng Zengkai <zhengzengkai@huawei.com> 
      Signed-off-by: Zhang Changzhong <zhangchangzhong@huawei.com> 
      e87dfde7
    • O
      !438 [openEuler-1.0-LTS] Add Zhaoxin I2C driver · ad79acb3
      openeuler-ci-bot 提交于
      Merge Pull Request from: @leoliu-oc 
       
      Zhaoxin I2C Linux driver support all bidirectional bus protocols speed
      specified in the I2C Specification 7.0. The speed mode listed in the
      followed table.
      
      |   Speed Name    |           Description                |
      | Standard-mode   | Bit rate up to 100 kbit/s            |
      | Fast-mode       | Bit rate up to 400 kbit/s.(default)  |
      | Fast-mode Plus  | Bit rate up to 1 Mbit/s              |
      | High-speed mode | Bit rate up to 3.4 Mbit/s.           |
      
      Issue
      https://gitee.com/openeuler/kernel/issues/I6J3EV
      
      Test
      N/A
      
      Knowe Issue
      N/A
      
      Introduced config change
      CONFIG_I2C_ZHAOXIN=m 
       
      Link:https://gitee.com/openeuler/kernel/pulls/438 
      
      Reviewed-by: Zheng Zengkai <zhengzengkai@huawei.com> 
      Signed-off-by: Zhang Changzhong <zhangchangzhong@huawei.com> 
      ad79acb3
  13. 10 5月, 2023 1 次提交
    • L
      i2c: Add Zhaoxin I2C driver · 735c81b4
      leoliu-oc 提交于
      zhaoxin inclusion
      category: feature
      bugzilla: https://gitee.com/openeuler/kernel/issues/I6J3EV
      CVE: NA
      
      --------------------------------------------
      
      Zhaoxin I2C Linux driver support all bidirectional bus protocols speed
      specified in the I2C Specification 7.0. The speed mode listed in the
      followed table.
      
      |   Speed Name    |           Description                |
      | Standard-mode   | Bit rate up to 100 kbit/s            |
      | Fast-mode       | Bit rate up to 400 kbit/s.(default)  |
      | Fast-mode Plus  | Bit rate up to 1 Mbit/s              |
      | High-speed mode | Bit rate up to 3.4 Mbit/s.           |
      Signed-off-by: Nleoliu-oc <leoliu-oc@zhaoxin.com>
      735c81b4