From: Qu Wenruo <wqu(a)suse.com>
stable inclusion
from stable-v5.10.227
commit d73d48acf36f57362df7e4f9d76568168bf5e944
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/IAYRC7
CVE: CVE-2024-49868
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id…
--------------------------------
commit c3b47f49e83197e8dffd023ec568403bcdbb774b upstream.
[BUG]
Syzbot reported a NULL pointer dereference with the following crash:
FAULT_INJECTION: forcing a failure.
start_transaction+0x830/0x1670 fs/btrfs/transaction.c:676
prepare_to_relocate+0x31f/0x4c0 fs/btrfs/relocation.c:3642
relocate_block_group+0x169/0xd20 fs/btrfs/relocation.c:3678
...
BTRFS info (device loop0): balance: ended with status: -12
Oops: general protection fault, probably for non-canonical address 0xdffffc00000000cc: 0000 [#1] PREEMPT SMP KASAN NOPTI
KASAN: null-ptr-deref in range [0x0000000000000660-0x0000000000000667]
RIP: 0010:btrfs_update_reloc_root+0x362/0xa80 fs/btrfs/relocation.c:926
Call Trace:
<TASK>
commit_fs_roots+0x2ee/0x720 fs/btrfs/transaction.c:1496
btrfs_commit_transaction+0xfaf/0x3740 fs/btrfs/transaction.c:2430
del_balance_item fs/btrfs/volumes.c:3678 [inline]
reset_balance_state+0x25e/0x3c0 fs/btrfs/volumes.c:3742
btrfs_balance+0xead/0x10c0 fs/btrfs/volumes.c:4574
btrfs_ioctl_balance+0x493/0x7c0 fs/btrfs/ioctl.c:3673
vfs_ioctl fs/ioctl.c:51 [inline]
__do_sys_ioctl fs/ioctl.c:907 [inline]
__se_sys_ioctl+0xf9/0x170 fs/ioctl.c:893
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x77/0x7f
[CAUSE]
The allocation failure happens at the start_transaction() inside
prepare_to_relocate(), and during the error handling we call
unset_reloc_control(), which makes fs_info->balance_ctl to be NULL.
Then we continue the error path cleanup in btrfs_balance() by calling
reset_balance_state() which will call del_balance_item() to fully delete
the balance item in the root tree.
However during the small window between set_reloc_contrl() and
unset_reloc_control(), we can have a subvolume tree update and created a
reloc_root for that subvolume.
Then we go into the final btrfs_commit_transaction() of
del_balance_item(), and into btrfs_update_reloc_root() inside
commit_fs_roots().
That function checks if fs_info->reloc_ctl is in the merge_reloc_tree
stage, but since fs_info->reloc_ctl is NULL, it results a NULL pointer
dereference.
[FIX]
Just add extra check on fs_info->reloc_ctl inside
btrfs_update_reloc_root(), before checking
fs_info->reloc_ctl->merge_reloc_tree.
That DEAD_RELOC_TREE handling is to prevent further modification to the
reloc tree during merge stage, but since there is no reloc_ctl at all,
we do not need to bother that.
Reported-by: syzbot+283673dbc38527ef9f3d(a)syzkaller.appspotmail.com
Link: https://lore.kernel.org/linux-btrfs/66f6bfa7.050a0220.38ace9.0019.GAE@googl…
CC: stable(a)vger.kernel.org # 4.19+
Reviewed-by: Josef Bacik <josef(a)toxicpanda.com>
Signed-off-by: Qu Wenruo <wqu(a)suse.com>
Reviewed-by: David Sterba <dsterba(a)suse.com>
Signed-off-by: David Sterba <dsterba(a)suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh(a)linuxfoundation.org>
Signed-off-by: Yifan Qiao <qiaoyifan4(a)huawei.com>
---
fs/btrfs/relocation.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index cf7a8fcea4d6..6712d082023e 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -910,7 +910,7 @@ int btrfs_update_reloc_root(struct btrfs_trans_handle *trans,
btrfs_grab_root(reloc_root);
/* root->reloc_root will stay until current relocation finished */
- if (fs_info->reloc_ctl->merge_reloc_tree &&
+ if (fs_info->reloc_ctl && fs_info->reloc_ctl->merge_reloc_tree &&
btrfs_root_refs(root_item) == 0) {
set_bit(BTRFS_ROOT_DEAD_RELOC_TREE, &root->state);
/*
--
2.39.2
From: VanGiang Nguyen <vangiang.nguyen(a)rohde-schwarz.com>
stable inclusion
from stable-v6.6.54
commit 1b8cf11b3ca593a8802a51802cd0c28c38501428
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/IAYQSB
CVE: CVE-2024-47739
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id…
--------------------------------
commit 9a22b2812393d93d84358a760c347c21939029a6 upstream.
When submitting more than 2^32 padata objects to padata_do_serial, the
current sorting implementation incorrectly sorts padata objects with
overflowed seq_nr, causing them to be placed before existing objects in
the reorder list. This leads to a deadlock in the serialization process
as padata_find_next cannot match padata->seq_nr and pd->processed
because the padata instance with overflowed seq_nr will be selected
next.
To fix this, we use an unsigned integer wrap around to correctly sort
padata objects in scenarios with integer overflow.
Fixes: bfde23ce200e ("padata: unbind parallel jobs from specific CPUs")
Cc: <stable(a)vger.kernel.org>
Co-developed-by: Christian Gafert <christian.gafert(a)rohde-schwarz.com>
Signed-off-by: Christian Gafert <christian.gafert(a)rohde-schwarz.com>
Co-developed-by: Max Ferger <max.ferger(a)rohde-schwarz.com>
Signed-off-by: Max Ferger <max.ferger(a)rohde-schwarz.com>
Signed-off-by: Van Giang Nguyen <vangiang.nguyen(a)rohde-schwarz.com>
Acked-by: Daniel Jordan <daniel.m.jordan(a)oracle.com>
Signed-off-by: Herbert Xu <herbert(a)gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh(a)linuxfoundation.org>
Signed-off-by: Cheng Yu <serein.chengyu(a)huawei.com>
---
kernel/padata.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/kernel/padata.c b/kernel/padata.c
index 29545dd6dd53..8f0af2c09e17 100644
--- a/kernel/padata.c
+++ b/kernel/padata.c
@@ -404,7 +404,8 @@ void padata_do_serial(struct padata_priv *padata)
/* Sort in ascending order of sequence number. */
list_for_each_prev(pos, &reorder->list) {
cur = list_entry(pos, struct padata_priv, list);
- if (cur->seq_nr < padata->seq_nr)
+ /* Compare by difference to consider integer wrap around */
+ if ((signed int)(cur->seq_nr - padata->seq_nr) < 0)
break;
}
list_add(&padata->list, pos);
--
2.25.1
From: VanGiang Nguyen <vangiang.nguyen(a)rohde-schwarz.com>
stable inclusion
from stable-v5.10.227
commit 46c4079460f4dcaf445860679558eedef4e1bc91
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/IAYQSB
CVE: CVE-2024-47739
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id…
--------------------------------
commit 9a22b2812393d93d84358a760c347c21939029a6 upstream.
When submitting more than 2^32 padata objects to padata_do_serial, the
current sorting implementation incorrectly sorts padata objects with
overflowed seq_nr, causing them to be placed before existing objects in
the reorder list. This leads to a deadlock in the serialization process
as padata_find_next cannot match padata->seq_nr and pd->processed
because the padata instance with overflowed seq_nr will be selected
next.
To fix this, we use an unsigned integer wrap around to correctly sort
padata objects in scenarios with integer overflow.
Fixes: bfde23ce200e ("padata: unbind parallel jobs from specific CPUs")
Cc: <stable(a)vger.kernel.org>
Co-developed-by: Christian Gafert <christian.gafert(a)rohde-schwarz.com>
Signed-off-by: Christian Gafert <christian.gafert(a)rohde-schwarz.com>
Co-developed-by: Max Ferger <max.ferger(a)rohde-schwarz.com>
Signed-off-by: Max Ferger <max.ferger(a)rohde-schwarz.com>
Signed-off-by: Van Giang Nguyen <vangiang.nguyen(a)rohde-schwarz.com>
Acked-by: Daniel Jordan <daniel.m.jordan(a)oracle.com>
Signed-off-by: Herbert Xu <herbert(a)gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh(a)linuxfoundation.org>
Conflicts:
kernel/padata.c
[Conflicts due to 7033f87927d5 ("padata: Fix list iterator in
padata_do_serial()") not merged.]
Signed-off-by: Cheng Yu <serein.chengyu(a)huawei.com>
---
kernel/padata.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/kernel/padata.c b/kernel/padata.c
index 915945c932db..09e6207048aa 100644
--- a/kernel/padata.c
+++ b/kernel/padata.c
@@ -404,9 +404,11 @@ void padata_do_serial(struct padata_priv *padata)
spin_lock(&reorder->lock);
/* Sort in ascending order of sequence number. */
- list_for_each_entry_reverse(cur, &reorder->list, list)
- if (cur->seq_nr < padata->seq_nr)
+ list_for_each_entry_reverse(cur, &reorder->list, list) {
+ /* Compare by difference to consider integer wrap around */
+ if ((signed int)(cur->seq_nr - padata->seq_nr) < 0)
break;
+ }
list_add(&padata->list, &cur->list);
spin_unlock(&reorder->lock);
--
2.25.1
From: VanGiang Nguyen <vangiang.nguyen(a)rohde-schwarz.com>
stable inclusion
from stable-v5.10.227
commit 46c4079460f4dcaf445860679558eedef4e1bc91
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/IAYQSB
CVE: CVE-2024-47739
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id…
--------------------------------
commit 9a22b2812393d93d84358a760c347c21939029a6 upstream.
When submitting more than 2^32 padata objects to padata_do_serial, the
current sorting implementation incorrectly sorts padata objects with
overflowed seq_nr, causing them to be placed before existing objects in
the reorder list. This leads to a deadlock in the serialization process
as padata_find_next cannot match padata->seq_nr and pd->processed
because the padata instance with overflowed seq_nr will be selected
next.
To fix this, we use an unsigned integer wrap around to correctly sort
padata objects in scenarios with integer overflow.
Fixes: bfde23ce200e ("padata: unbind parallel jobs from specific CPUs")
Cc: <stable(a)vger.kernel.org>
Co-developed-by: Christian Gafert <christian.gafert(a)rohde-schwarz.com>
Signed-off-by: Christian Gafert <christian.gafert(a)rohde-schwarz.com>
Co-developed-by: Max Ferger <max.ferger(a)rohde-schwarz.com>
Signed-off-by: Max Ferger <max.ferger(a)rohde-schwarz.com>
Signed-off-by: Van Giang Nguyen <vangiang.nguyen(a)rohde-schwarz.com>
Acked-by: Daniel Jordan <daniel.m.jordan(a)oracle.com>
Signed-off-by: Herbert Xu <herbert(a)gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh(a)linuxfoundation.org>
Signed-off-by: Cheng Yu <serein.chengyu(a)huawei.com>
---
kernel/padata.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/kernel/padata.c b/kernel/padata.c
index 7b8d92f44b16..e24244c9c2cc 100644
--- a/kernel/padata.c
+++ b/kernel/padata.c
@@ -409,7 +409,8 @@ void padata_do_serial(struct padata_priv *padata)
/* Sort in ascending order of sequence number. */
list_for_each_prev(pos, &reorder->list) {
cur = list_entry(pos, struct padata_priv, list);
- if (cur->seq_nr < padata->seq_nr)
+ /* Compare by difference to consider integer wrap around */
+ if ((signed int)(cur->seq_nr - padata->seq_nr) < 0)
break;
}
list_add(&padata->list, pos);
--
2.25.1
Hi Yang,
FYI, the error/warning still remains.
tree: https://gitee.com/openeuler/kernel.git openEuler-1.0-LTS
head: fc5b1a61061cb6d640f3336024fb616182ef2614
commit: e63b4759933f6a5c5ce6cdc1d11c7bf2201d0612 [15045/23857] arm64: arch_timer: only do cntvct workaround on VDSO path on D05
config: arm64-randconfig-004-20241024 (https://download.01.org/0day-ci/archive/20241025/202410250213.xpJhjcfg-lkp@…)
compiler: aarch64-linux-gcc (GCC) 14.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241025/202410250213.xpJhjcfg-lkp@…)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp(a)intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202410250213.xpJhjcfg-lkp@intel.com/
All errors (new ones prefixed by >>):
drivers/clocksource/arm_arch_timer.c: In function 'arch_timer_enable_workaround':
>> drivers/clocksource/arm_arch_timer.c:554:44: error: 'hisi_161010101_read_cntvct_el0' undeclared (first use in this function)
554 | if (wa->read_cntvct_el0 == hisi_161010101_read_cntvct_el0) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/clocksource/arm_arch_timer.c:554:44: note: each undeclared identifier is reported only once for each function it appears in
vim +/hisi_161010101_read_cntvct_el0 +554 drivers/clocksource/arm_arch_timer.c
527
528 static
529 void arch_timer_enable_workaround(const struct arch_timer_erratum_workaround *wa,
530 bool local)
531 {
532 int i;
533
534 if (local) {
535 __this_cpu_write(timer_unstable_counter_workaround, wa);
536 } else {
537 for_each_possible_cpu(i)
538 per_cpu(timer_unstable_counter_workaround, i) = wa;
539 }
540
541 /*
542 * Use the locked version, as we're called from the CPU
543 * hotplug framework. Otherwise, we end-up in deadlock-land.
544 */
545 static_branch_enable_cpuslocked(&arch_timer_read_ool_enabled);
546
547 /*
548 * Don't use the vdso fastpath if errata require using the
549 * out-of-line counter accessor. We may change our mind pretty
550 * late in the game (with a per-CPU erratum, for example), so
551 * change both the default value and the vdso itself.
552 */
553 if (wa->read_cntvct_el0) {
> 554 if (wa->read_cntvct_el0 == hisi_161010101_read_cntvct_el0) {
555 clocksource_counter.archdata.vdso_direct = true;
556 vdso_default = true;
557 vdso_fix = true;
558 } else {
559 clocksource_counter.archdata.vdso_direct = false;
560 vdso_default = false;
561 }
562 }
563 }
564
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
tree: https://gitee.com/openeuler/kernel.git openEuler-1.0-LTS
head: fc5b1a61061cb6d640f3336024fb616182ef2614
commit: 71e217e85c3dff8a9151707ed3afc7b4b054a2d4 [5421/23857] selinux: use kernel linux/socket.h for genheaders and mdp
config: arm64-randconfig-004-20241024 (https://download.01.org/0day-ci/archive/20241025/202410250017.rJYuRb99-lkp@…)
compiler: aarch64-linux-gcc (GCC) 14.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241025/202410250017.rJYuRb99-lkp@…)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp(a)intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202410250017.rJYuRb99-lkp@intel.com/
All errors (new ones prefixed by >>):
arch/arm64/kernel/smp.c:840:6: warning: no previous prototype for 'arch_irq_work_raise' [-Wmissing-prototypes]
840 | void arch_irq_work_raise(void)
| ^~~~~~~~~~~~~~~~~~~
arch/arm64/kernel/smp.c: In function 'hw_nmi_get_sample_period':
>> arch/arm64/kernel/smp.c:1217:14: error: 'pmu_nmi_enable' undeclared (first use in this function); did you mean 'perf_pmu_enable'?
1217 | if (!pmu_nmi_enable)
| ^~~~~~~~~~~~~~
| perf_pmu_enable
arch/arm64/kernel/smp.c:1217:14: note: each undeclared identifier is reported only once for each function it appears in
In file included from include/linux/kernel.h:14,
from include/linux/list.h:9,
from include/linux/resource_ext.h:17,
from include/linux/acpi.h:26,
from arch/arm64/kernel/smp.c:20:
arch/arm64/kernel/smp.c: In function '__cpu_up':
include/linux/printk.h:346:9: warning: this statement may fall through [-Wimplicit-fallthrough=]
346 | printk(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/arm64/kernel/smp.c:169:25: note: in expansion of macro 'pr_crit'
169 | pr_crit("CPU%u: may not have shut down cleanly\n", cpu);
| ^~~~~~~
arch/arm64/kernel/smp.c:170:17: note: here
170 | case CPU_STUCK_IN_KERNEL:
| ^~~~
vim +1217 arch/arm64/kernel/smp.c
c17272c92d2ee1 Wei Li 2019-03-28 1212
5bffbe2174676c Wei Li 2019-03-20 1213 u64 hw_nmi_get_sample_period(int watchdog_thresh)
5bffbe2174676c Wei Li 2019-03-20 1214 {
c17272c92d2ee1 Wei Li 2019-03-28 1215 u64 cpu_freq;
c17272c92d2ee1 Wei Li 2019-03-28 1216
9f05210dfee3a2 Yang Yingliang 2019-03-23 @1217 if (!pmu_nmi_enable)
:::::: The code at line 1217 was first introduced by commit
:::::: 9f05210dfee3a2319a61302f9bfd7317b522fa96 arm64: perf: add pmu_nmi_enable to control pmu nmi support
:::::: TO: Yang Yingliang <yangyingliang(a)huawei.com>
:::::: CC: Xie XiuQi <xiexiuqi(a)huawei.com>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki