1. 25 7月, 2023 1 次提交
  2. 24 7月, 2023 2 次提交
  3. 21 7月, 2023 1 次提交
  4. 20 7月, 2023 3 次提交
    • T
      netfilter: nf_tables: prevent OOB access in nft_byteorder_eval · c7bffe6e
      Thadeu Lima de Souza Cascardo 提交于
      mainline inclusion
      from mainline-v6.5-rc2
      commit caf3ef7468f7534771b5c44cd8dbd6f7f87c2cbd
      category: bugfix
      bugzilla: https://gitee.com/src-openeuler/kernel/issues/I7ISR1
      CVE: CVE-2023-35001
      
      Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=caf3ef7468f7534771b5c44cd8dbd6f7f87c2cbd
      
      ---------------------------
      
      When evaluating byteorder expressions with size 2, a union with 32-bit and
      16-bit members is used. Since the 16-bit members are aligned to 32-bit,
      the array accesses will be out-of-bounds.
      
      It may lead to a stack-out-of-bounds access like the one below:
      
      [   23.095215] ==================================================================
      [   23.095625] BUG: KASAN: stack-out-of-bounds in nft_byteorder_eval+0x13c/0x320
      [   23.096020] Read of size 2 at addr ffffc90000007948 by task ping/115
      [   23.096358]
      [   23.096456] CPU: 0 PID: 115 Comm: ping Not tainted 6.4.0+ #413
      [   23.096770] Call Trace:
      [   23.096910]  <IRQ>
      [   23.097030]  dump_stack_lvl+0x60/0xc0
      [   23.097218]  print_report+0xcf/0x630
      [   23.097388]  ? nft_byteorder_eval+0x13c/0x320
      [   23.097577]  ? kasan_addr_to_slab+0xd/0xc0
      [   23.097760]  ? nft_byteorder_eval+0x13c/0x320
      [   23.097949]  kasan_report+0xc9/0x110
      [   23.098106]  ? nft_byteorder_eval+0x13c/0x320
      [   23.098298]  __asan_load2+0x83/0xd0
      [   23.098453]  nft_byteorder_eval+0x13c/0x320
      [   23.098659]  nft_do_chain+0x1c8/0xc50
      [   23.098852]  ? __pfx_nft_do_chain+0x10/0x10
      [   23.099078]  ? __kasan_check_read+0x11/0x20
      [   23.099295]  ? __pfx___lock_acquire+0x10/0x10
      [   23.099535]  ? __pfx___lock_acquire+0x10/0x10
      [   23.099745]  ? __kasan_check_read+0x11/0x20
      [   23.099929]  nft_do_chain_ipv4+0xfe/0x140
      [   23.100105]  ? __pfx_nft_do_chain_ipv4+0x10/0x10
      [   23.100327]  ? lock_release+0x204/0x400
      [   23.100515]  ? nf_hook.constprop.0+0x340/0x550
      [   23.100779]  nf_hook_slow+0x6c/0x100
      [   23.100977]  ? __pfx_nft_do_chain_ipv4+0x10/0x10
      [   23.101223]  nf_hook.constprop.0+0x334/0x550
      [   23.101443]  ? __pfx_ip_local_deliver_finish+0x10/0x10
      [   23.101677]  ? __pfx_nf_hook.constprop.0+0x10/0x10
      [   23.101882]  ? __pfx_ip_rcv_finish+0x10/0x10
      [   23.102071]  ? __pfx_ip_local_deliver_finish+0x10/0x10
      [   23.102291]  ? rcu_read_lock_held+0x4b/0x70
      [   23.102481]  ip_local_deliver+0xbb/0x110
      [   23.102665]  ? __pfx_ip_rcv+0x10/0x10
      [   23.102839]  ip_rcv+0x199/0x2a0
      [   23.102980]  ? __pfx_ip_rcv+0x10/0x10
      [   23.103140]  __netif_receive_skb_one_core+0x13e/0x150
      [   23.103362]  ? __pfx___netif_receive_skb_one_core+0x10/0x10
      [   23.103647]  ? mark_held_locks+0x48/0xa0
      [   23.103819]  ? process_backlog+0x36c/0x380
      [   23.103999]  __netif_receive_skb+0x23/0xc0
      [   23.104179]  process_backlog+0x91/0x380
      [   23.104350]  __napi_poll.constprop.0+0x66/0x360
      [   23.104589]  ? net_rx_action+0x1cb/0x610
      [   23.104811]  net_rx_action+0x33e/0x610
      [   23.105024]  ? _raw_spin_unlock+0x23/0x50
      [   23.105257]  ? __pfx_net_rx_action+0x10/0x10
      [   23.105485]  ? mark_held_locks+0x48/0xa0
      [   23.105741]  __do_softirq+0xfa/0x5ab
      [   23.105956]  ? __dev_queue_xmit+0x765/0x1c00
      [   23.106193]  do_softirq.part.0+0x49/0xc0
      [   23.106423]  </IRQ>
      [   23.106547]  <TASK>
      [   23.106670]  __local_bh_enable_ip+0xf5/0x120
      [   23.106903]  __dev_queue_xmit+0x789/0x1c00
      [   23.107131]  ? __pfx___dev_queue_xmit+0x10/0x10
      [   23.107381]  ? find_held_lock+0x8e/0xb0
      [   23.107585]  ? lock_release+0x204/0x400
      [   23.107798]  ? neigh_resolve_output+0x185/0x350
      [   23.108049]  ? mark_held_locks+0x48/0xa0
      [   23.108265]  ? neigh_resolve_output+0x185/0x350
      [   23.108514]  neigh_resolve_output+0x246/0x350
      [   23.108753]  ? neigh_resolve_output+0x246/0x350
      [   23.109003]  ip_finish_output2+0x3c3/0x10b0
      [   23.109250]  ? __pfx_ip_finish_output2+0x10/0x10
      [   23.109510]  ? __pfx_nf_hook+0x10/0x10
      [   23.109732]  __ip_finish_output+0x217/0x390
      [   23.109978]  ip_finish_output+0x2f/0x130
      [   23.110207]  ip_output+0xc9/0x170
      [   23.110404]  ip_push_pending_frames+0x1a0/0x240
      [   23.110652]  raw_sendmsg+0x102e/0x19e0
      [   23.110871]  ? __pfx_raw_sendmsg+0x10/0x10
      [   23.111093]  ? lock_release+0x204/0x400
      [   23.111304]  ? __mod_lruvec_page_state+0x148/0x330
      [   23.111567]  ? find_held_lock+0x8e/0xb0
      [   23.111777]  ? find_held_lock+0x8e/0xb0
      [   23.111993]  ? __rcu_read_unlock+0x7c/0x2f0
      [   23.112225]  ? aa_sk_perm+0x18a/0x550
      [   23.112431]  ? filemap_map_pages+0x4f1/0x900
      [   23.112665]  ? __pfx_aa_sk_perm+0x10/0x10
      [   23.112880]  ? find_held_lock+0x8e/0xb0
      [   23.113098]  inet_sendmsg+0xa0/0xb0
      [   23.113297]  ? inet_sendmsg+0xa0/0xb0
      [   23.113500]  ? __pfx_inet_sendmsg+0x10/0x10
      [   23.113727]  sock_sendmsg+0xf4/0x100
      [   23.113924]  ? move_addr_to_kernel.part.0+0x4f/0xa0
      [   23.114190]  __sys_sendto+0x1d4/0x290
      [   23.114391]  ? __pfx___sys_sendto+0x10/0x10
      [   23.114621]  ? __pfx_mark_lock.part.0+0x10/0x10
      [   23.114869]  ? lock_release+0x204/0x400
      [   23.115076]  ? find_held_lock+0x8e/0xb0
      [   23.115287]  ? rcu_is_watching+0x23/0x60
      [   23.115503]  ? __rseq_handle_notify_resume+0x6e2/0x860
      [   23.115778]  ? __kasan_check_write+0x14/0x30
      [   23.116008]  ? blkcg_maybe_throttle_current+0x8d/0x770
      [   23.116285]  ? mark_held_locks+0x28/0xa0
      [   23.116503]  ? do_syscall_64+0x37/0x90
      [   23.116713]  __x64_sys_sendto+0x7f/0xb0
      [   23.116924]  do_syscall_64+0x59/0x90
      [   23.117123]  ? irqentry_exit_to_user_mode+0x25/0x30
      [   23.117387]  ? irqentry_exit+0x77/0xb0
      [   23.117593]  ? exc_page_fault+0x92/0x140
      [   23.117806]  entry_SYSCALL_64_after_hwframe+0x6e/0xd8
      [   23.118081] RIP: 0033:0x7f744aee2bba
      [   23.118282] Code: d8 64 89 02 48 c7 c0 ff ff ff ff eb b8 0f 1f 00 f3 0f 1e fa 41 89 ca 64 8b 04 25 18 00 00 00 85 c0 75 15 b8 2c 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 7e c3 0f 1f 44 00 00 41 54 48 83 ec 30 44 89
      [   23.119237] RSP: 002b:00007ffd04a7c9f8 EFLAGS: 00000246 ORIG_RAX: 000000000000002c
      [   23.119644] RAX: ffffffffffffffda RBX: 00007ffd04a7e0a0 RCX: 00007f744aee2bba
      [   23.120023] RDX: 0000000000000040 RSI: 000056488e9e6300 RDI: 0000000000000003
      [   23.120413] RBP: 000056488e9e6300 R08: 00007ffd04a80320 R09: 0000000000000010
      [   23.120809] R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000040
      [   23.121219] R13: 00007ffd04a7dc38 R14: 00007ffd04a7ca00 R15: 00007ffd04a7e0a0
      [   23.121617]  </TASK>
      [   23.121749]
      [   23.121845] The buggy address belongs to the virtual mapping at
      [   23.121845]  [ffffc90000000000, ffffc90000009000) created by:
      [   23.121845]  irq_init_percpu_irqstack+0x1cf/0x270
      [   23.122707]
      [   23.122803] The buggy address belongs to the physical page:
      [   23.123104] page:0000000072ac19f0 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x24a09
      [   23.123609] flags: 0xfffffc0001000(reserved|node=0|zone=1|lastcpupid=0x1fffff)
      [   23.123998] page_type: 0xffffffff()
      [   23.124194] raw: 000fffffc0001000 ffffea0000928248 ffffea0000928248 0000000000000000
      [   23.124610] raw: 0000000000000000 0000000000000000 00000001ffffffff 0000000000000000
      [   23.125023] page dumped because: kasan: bad access detected
      [   23.125326]
      [   23.125421] Memory state around the buggy address:
      [   23.125682]  ffffc90000007800: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
      [   23.126072]  ffffc90000007880: 00 00 00 00 00 f1 f1 f1 f1 f1 f1 00 00 f2 f2 00
      [   23.126455] >ffffc90000007900: 00 00 00 00 00 00 00 00 00 f2 f2 f2 f2 00 00 00
      [   23.126840]                                               ^
      [   23.127138]  ffffc90000007980: 00 00 00 00 00 00 00 00 00 00 00 00 00 f3 f3 f3
      [   23.127522]  ffffc90000007a00: f3 00 00 00 00 00 00 00 00 00 00 00 f1 f1 f1 f1
      [   23.127906] ==================================================================
      [   23.128324] Disabling lock debugging due to kernel taint
      
      Using simple s16 pointers for the 16-bit accesses fixes the problem. For
      the 32-bit accesses, src and dst can be used directly.
      
      Fixes: 96518518 ("netfilter: add nftables")
      Cc: stable@vger.kernel.org
      Reported-by: Tanguy DUBROCA (@SidewayRE) from @Synacktiv working with ZDI
      Signed-off-by: NThadeu Lima de Souza Cascardo <cascardo@canonical.com>
      Reviewed-by: NFlorian Westphal <fw@strlen.de>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: NZiyang Xuan <william.xuanziyang@huawei.com>
      (cherry picked from commit d241d149)
      c7bffe6e
    • Z
      ipv6/addrconf: fix a potential refcount underflow for idev · 367c9e36
      Ziyang Xuan 提交于
      mainline inclusion
      from mainline-v6.5-rc2
      commit 06a0716949c22e2aefb648526580671197151acc
      category: bugfix
      bugzilla: https://gitee.com/openeuler/kernel/issues/I7M991
      
      Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=06a0716949c22e2aefb648526580671197151acc
      
      ---------------------------
      
      Now in addrconf_mod_rs_timer(), reference idev depends on whether
      rs_timer is not pending. Then modify rs_timer timeout.
      
      There is a time gap in [1], during which if the pending rs_timer
      becomes not pending. It will miss to hold idev, but the rs_timer
      is activated. Thus rs_timer callback function addrconf_rs_timer()
      will be executed and put idev later without holding idev. A refcount
      underflow issue for idev can be caused by this.
      
      	if (!timer_pending(&idev->rs_timer))
      		in6_dev_hold(idev);
      		  <--------------[1]
      	mod_timer(&idev->rs_timer, jiffies + when);
      
      To fix the issue, hold idev if mod_timer() return 0.
      
      Fixes: b7b1bfce ("ipv6: split duplicate address detection and router solicitation timer")
      Suggested-by: NEric Dumazet <edumazet@google.com>
      Signed-off-by: NZiyang Xuan <william.xuanziyang@huawei.com>
      Reviewed-by: NEric Dumazet <edumazet@google.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      Signed-off-by: NZiyang Xuan <william.xuanziyang@huawei.com>
      (cherry picked from commit 7c087997)
      367c9e36
    • H
      media: dvb-core: Fix use-after-free due on race condition at dvb_net · f1e9d165
      Hyunwoo Kim 提交于
      mainline inclusion
      from mainline-v6.4-rc3
      commit 4172385b
      category: bugfix
      bugzilla: https://gitee.com/src-openeuler/kernel/issues/I635JD
      CVE: CVE-2022-45886
      
      Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit?id=4172385b0c9ac366dcab78eda48c26814b87ed1a
      
      ----------------------------------------
      
      A race condition may occur between the .disconnect function, which
      is called when the device is disconnected, and the dvb_device_open()
      function, which is called when the device node is open()ed.
      This results in several types of UAFs.
      
      The root cause of this is that you use the dvb_device_open() function,
      which does not implement a conditional statement
      that checks 'dvbnet->exit'.
      
      So, add 'remove_mutex` to protect 'dvbnet->exit' and use
      locked_dvb_net_open() function to check 'dvbnet->exit'.
      
      [mchehab: fix a checkpatch warning]
      
      Link: https://lore.kernel.org/linux-media/20221117045925.14297-3-imv4bel@gmail.comSigned-off-by: NHyunwoo Kim <imv4bel@gmail.com>
      Signed-off-by: NMauro Carvalho Chehab <mchehab@kernel.org>
      Signed-off-by: NCai Xinchen <caixinchen1@huawei.com>
      (cherry picked from commit b47ba5df)
      f1e9d165
  5. 19 7月, 2023 3 次提交
  6. 18 7月, 2023 11 次提交
  7. 17 7月, 2023 2 次提交
  8. 14 7月, 2023 6 次提交
  9. 13 7月, 2023 6 次提交
  10. 12 7月, 2023 5 次提交
    • Z
      jbd2: Check 'jh->b_transaction' before remove it from checkpoint · 663a92d7
      Zhihao Cheng 提交于
      hulk inclusion
      category: bugfix
      bugzilla: https://gitee.com/openeuler/kernel/issues/I70WHL
      CVE: NA
      
      --------------------------------
      
      Following process will corrupt ext4 image:
      Step 1:
      jbd2_journal_commit_transaction
       __jbd2_journal_insert_checkpoint(jh, commit_transaction)
       // Put jh into trans1->t_checkpoint_list
       journal->j_checkpoint_transactions = commit_transaction
       // Put trans1 into journal->j_checkpoint_transactions
      
      Step 2:
      do_get_write_access
       test_clear_buffer_dirty(bh) // clear buffer dirty,set jbd dirty
       __jbd2_journal_file_buffer(jh, transaction) // jh belongs to trans2
      
      Step 3:
      drop_cache
       journal_shrink_one_cp_list
        jbd2_journal_try_remove_checkpoint
         if (!trylock_buffer(bh))  // lock bh, true
         if (buffer_dirty(bh))     // buffer is not dirty
         __jbd2_journal_remove_checkpoint(jh)
         // remove jh from trans1->t_checkpoint_list
      
      Step 4:
      jbd2_log_do_checkpoint
       trans1 = journal->j_checkpoint_transactions
       // jh is not in trans1->t_checkpoint_list
       jbd2_cleanup_journal_tail(journal)  // trans1 is done
      
      Step 5: Power cut, trans2 is not committed, jh is lost in next mounting.
      
      Fix it by checking 'jh->b_transaction' before remove it from checkpoint.
      
      Fixes: 80079353 ("jbd2: fix a race when checking checkpoint ...")
      Signed-off-by: NZhihao Cheng <chengzhihao1@huawei.com>
      (cherry picked from commit 7723e91d)
      663a92d7
    • B
      quota: simplify drop_dquot_ref() · 8d16ece8
      Baokun Li 提交于
      maillist inclusion
      category: bugfix
      bugzilla: 188812,https://gitee.com/openeuler/kernel/issues/I7E0YR
      
      Reference: https://www.spinics.net/lists/kernel/msg4844759.html
      
      ----------------------------------------
      
      As Honza said, remove_inode_dquot_ref() currently does not release the
      last dquot reference but instead adds the dquot to tofree_head list. This
      is because dqput() can sleep while dropping of the last dquot reference
      (writing back the dquot and calling ->release_dquot()) and that must not
      happen under dq_list_lock. Now that dqput() queues the final dquot cleanup
      into a workqueue, remove_inode_dquot_ref() can call dqput() unconditionally
      and we can significantly simplify it.
      
      Here we open code the simplified code of remove_inode_dquot_ref() into
      remove_dquot_ref() and remove the function put_dquot_list() which is no
      longer used.
      Signed-off-by: NBaokun Li <libaokun1@huawei.com>
      (cherry picked from commit a13fcef3)
      8d16ece8
    • B
      quota: fix dqput() to follow the guarantees dquot_srcu should provide · 50a9c1dc
      Baokun Li 提交于
      maillist inclusion
      category: bugfix
      bugzilla: 188812,https://gitee.com/openeuler/kernel/issues/I7E0YR
      
      Reference: https://www.spinics.net/lists/kernel/msg4844759.html
      
      ----------------------------------------
      
      The dquot_mark_dquot_dirty() using dquot references from the inode
      should be protected by dquot_srcu. quota_off code takes care to call
      synchronize_srcu(&dquot_srcu) to not drop dquot references while they
      are used by other users. But dquot_transfer() breaks this assumption.
      We call dquot_transfer() to drop the last reference of dquot and add
      it to free_dquots, but there may still be other users using the dquot
      at this time, as shown in the function graph below:
      
             cpu1              cpu2
      _________________|_________________
      wb_do_writeback         CHOWN(1)
       ...
        ext4_da_update_reserve_space
         dquot_claim_block
          ...
           dquot_mark_dquot_dirty // try to dirty old quota
            test_bit(DQ_ACTIVE_B, &dquot->dq_flags) // still ACTIVE
            if (test_bit(DQ_MOD_B, &dquot->dq_flags))
            // test no dirty, wait dq_list_lock
                          ...
                           dquot_transfer
                            __dquot_transfer
                            dqput_all(transfer_from) // rls old dquot
                             dqput // last dqput
                              dquot_release
                               clear_bit(DQ_ACTIVE_B, &dquot->dq_flags)
                              atomic_dec(&dquot->dq_count)
                              put_dquot_last(dquot)
                               list_add_tail(&dquot->dq_free, &free_dquots)
                               // add the dquot to free_dquots
            if (!test_and_set_bit(DQ_MOD_B, &dquot->dq_flags))
              add dqi_dirty_list // add released dquot to dirty_list
      
      This can cause various issues, such as dquot being destroyed by
      dqcache_shrink_scan() after being added to free_dquots, which can trigger
      a UAF in dquot_mark_dquot_dirty(); or after dquot is added to free_dquots
      and then to dirty_list, it is added to free_dquots again after
      dquot_writeback_dquots() is executed, which causes the free_dquots list to
      be corrupted and triggers a UAF when dqcache_shrink_scan() is called for
      freeing dquot twice.
      
      As Honza said, we need to fix dquot_transfer() to follow the guarantees
      dquot_srcu should provide. But calling synchronize_srcu() directly from
      dquot_transfer() is too expensive (and mostly unnecessary). So we add
      dquot whose last reference should be dropped to the new global dquot
      list releasing_dquots, and then queue work item which would call
      synchronize_srcu() and after that perform the final cleanup of all the
      dquots on releasing_dquots.
      
      Fixes: 4580b30e ("quota: Do not dirty bad dquots")
      Suggested-by: NJan Kara <jack@suse.cz>
      Signed-off-by: NBaokun Li <libaokun1@huawei.com>
      (cherry picked from commit d82ddaab)
      50a9c1dc
    • B
      quota: add new helper dquot_active() · 364aa369
      Baokun Li 提交于
      maillist inclusion
      category: bugfix
      bugzilla: 188812,https://gitee.com/openeuler/kernel/issues/I7E0YR
      
      Reference: https://www.spinics.net/lists/kernel/msg4844759.html
      
      ----------------------------------------
      
      Add new helper function dquot_active() to make the code more concise.
      Signed-off-by: NBaokun Li <libaokun1@huawei.com>
      (cherry picked from commit 3fb7aa3a)
      364aa369
    • B
      quota: rename dquot_active() to inode_quota_active() · 2dc40f74
      Baokun Li 提交于
      maillist inclusion
      category: bugfix
      bugzilla: 188812,https://gitee.com/openeuler/kernel/issues/I7E0YR
      
      Reference: https://www.spinics.net/lists/kernel/msg4844759.html
      
      ----------------------------------------
      
      Now we have a helper function dquot_dirty() to determine if dquot has
      DQ_MOD_B bit. dquot_active() can easily be misunderstood as a helper
      function to determine if dquot has DQ_ACTIVE_B bit. So we avoid this by
      renaming it to inode_quota_active() and later on we will add the helper
      function dquot_active() to determine if dquot has DQ_ACTIVE_B bit.
      Signed-off-by: NBaokun Li <libaokun1@huawei.com>
      (cherry picked from commit 329a1eb4)
      2dc40f74