Syzkaller reports general protection fault at reweight_entity() in 5.10
stable releases. The problem has been fixed by the following patch which
can be applied with minor changes to the 5.10 branch.
Found by Linux Verification Center (linuxtesting.org) with Syzkaller.
This is the backport for v5.15.x stable branch.
The full explananation can be found here:
https://lore.kernel.org/linux-btrfs/Yv85PTBsDhrQITZp@kroah.com/T/#t
Difference between v5.15.x and v5.18.x backports:
- btrfs_io_contrl::fs_info and btrfs_raid_bio::fs_info refactor
In v5.15 and older kernel, btrfs_raid_bio and btrfs_io_control both
have fs_info member, and the new rbio_add_bio() function utilizes
btrfs_io_ctrl::fs_info.
Unfortunately that rbio->bioc->fs_info is not always initialized in
v5.15 and older kernels.
Thus has to use rbio->fs_info instead.
If not properly handled, can lead to btrfs/158 crash.
Qu Wenruo (2):
btrfs: only write the sectors in the vertical stripe which has data
stripes
btrfs: raid56: don't trust any cached sector in
__raid56_parity_recover()
fs/btrfs/raid56.c | 74 ++++++++++++++++++++++++++++++++++++-----------
1 file changed, 57 insertions(+), 17 deletions(-)
--
2.37.1
The panic comes from the sanity test code, but after trying to boil down the
.config differences between the kitchen sink our test team uses, and a
"defconfig", it seems there are at least a couple extra dependencies for
creating a reproducer:
make defconfig
echo CONFIG_FUNCTION_TRACER=y >> .config
echo CONFIG_KPROBES_SANITY_TEST=y >> .config
echo CONFIG_UNWINDER_FRAME_POINTER=y >> .config
yes "" | make oldconfig
Note that ftrace is probably just opening the door to CONFIG_KPROBES_ON_FTRACE=y
The report I got was with gcc-11 on an Atom; I was able to reproduce it
with the default gcc-7 found on Ubuntu 18.04 and booting on a Xeon v2 -
so it seems to not be specific to gcc options or processor features.
I don't know if the v5.15 backports were specifically tested to be fully
bisectable, but if we assume they are, a bisect between 56 and 57 says:
commit 1d61a2988612ac0632134454d5407c63ae0b9d42 (refs/bisect/bad)
Author: Peter Zijlstra <peterz(a)infradead.org>
Date: Tue Jun 14 23:15:45 2022 +0200
x86: Use return-thunk in asm code
commit aa3d480315ba6c3025a60958e1981072ea37c3df upstream.
Use the return thunk in asm code. If the thunk isn't needed, it will
get patched into a RET instruction during boot by apply_returns().
Splat follows:
rcu: Hierarchical SRCU implementation.
Kprobe smoke test: started
BUG: unable to handle page fault for address: ffffffffc110f3e7
#PF: supervisor instruction fetch in kernel mode
#PF: error_code(0x0010) - not-present page
PGD b2c60f067 P4D b2c60f067 PUD b2c611067 PMD 0
Oops: 0010 [#1] SMP NOPTI
CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.15.57 #33
Hardware name: Intel Corporation S2600CP/S2600CP, BIOS SE5C600.86B.02.06.E006.013120181511 01/31/2018
RIP: 0010:0xffffffffc110f3e7
Code: Unable to access opcode bytes at RIP 0xffffffffc110f3bd.
RSP: 0000:ffffae4bc006be38 EFLAGS: 00010246
RAX: ffffffffb973f310 RBX: 0000000000000000 RCX: 0000000000000000
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 000000005856e7bd
RBP: ffffae4bc006be60 R08: 0000000000000000 R09: 0000000000000001
R10: 0000000000000001 R11: 0000000000000000 R12: 0000000000000001
R13: ffffffffbae38560 R14: 0000000000000000 R15: 0000000000000000
FS: 0000000000000000(0000) GS:ffff8c92df800000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: ffffffffc110f3bd CR3: 0000000b2c60c001 CR4: 00000000001706f0
Call Trace:
<TASK>
? kprobe_target+0x5/0x20
? init_test_probes+0x78/0x420
init_kprobes+0x16c/0x18e
? init_optprobes+0x27/0x27
do_one_initcall+0x43/0x1d0
kernel_init_freeable+0xf1/0x240
? rest_init+0xd0/0xd0
kernel_init+0x1a/0x120
ret_from_fork+0x1f/0x30
</TASK>
Modules linked in:
CR2: ffffffffc110f3e7
---[ end trace 759f040622219261 ]---
[ Upstream commit dd8de84b57b02ba9c1fe530a6d916c0853f136bd ]
On FSL_BOOK3E, _PAGE_RW is defined with two bits, one for user and one
for supervisor. As soon as one of the two bits is set, the page has
to be display as RW. But the way it is implemented today requires both
bits to be set in order to display it as RW.
Instead of display RW when _PAGE_RW bits are set and R otherwise,
reverse the logic and display R when _PAGE_RW bits are all 0 and
RW otherwise.
This change has no impact on other platforms as _PAGE_RW is a single
bit on all of them.
Fixes: 8eb07b187000 ("powerpc/mm: Dump linux pagetables")
Cc: stable(a)vger.kernel.org
Signed-off-by: Christophe Leroy <christophe.leroy(a)csgroup.eu>
Signed-off-by: Michael Ellerman <mpe(a)ellerman.id.au>
Link: https://lore.kernel.org/r/0c33b96317811edf691e81698aaee8fa45ec3449.16564273…
---
arch/powerpc/mm/dump_linuxpagetables.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/arch/powerpc/mm/dump_linuxpagetables.c b/arch/powerpc/mm/dump_linuxpagetables.c
index 0bbaf7344872..07541d322b56 100644
--- a/arch/powerpc/mm/dump_linuxpagetables.c
+++ b/arch/powerpc/mm/dump_linuxpagetables.c
@@ -123,15 +123,10 @@ static const struct flag_info flag_array[] = {
.set = "user",
.clear = " ",
}, {
-#if _PAGE_RO == 0
- .mask = _PAGE_RW,
- .val = _PAGE_RW,
-#else
- .mask = _PAGE_RO,
- .val = 0,
-#endif
- .set = "rw",
- .clear = "ro",
+ .mask = _PAGE_RW | _PAGE_RO,
+ .val = _PAGE_RO,
+ .set = "ro",
+ .clear = "rw",
}, {
.mask = _PAGE_EXEC,
.val = _PAGE_EXEC,
--
2.37.1
The patch below does not apply to the 4.19-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable(a)vger.kernel.org>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From dd8de84b57b02ba9c1fe530a6d916c0853f136bd Mon Sep 17 00:00:00 2001
From: Christophe Leroy <christophe.leroy(a)csgroup.eu>
Date: Tue, 28 Jun 2022 16:43:35 +0200
Subject: [PATCH] powerpc/ptdump: Fix display of RW pages on FSL_BOOK3E
On FSL_BOOK3E, _PAGE_RW is defined with two bits, one for user and one
for supervisor. As soon as one of the two bits is set, the page has
to be display as RW. But the way it is implemented today requires both
bits to be set in order to display it as RW.
Instead of display RW when _PAGE_RW bits are set and R otherwise,
reverse the logic and display R when _PAGE_RW bits are all 0 and
RW otherwise.
This change has no impact on other platforms as _PAGE_RW is a single
bit on all of them.
Fixes: 8eb07b187000 ("powerpc/mm: Dump linux pagetables")
Cc: stable(a)vger.kernel.org
Signed-off-by: Christophe Leroy <christophe.leroy(a)csgroup.eu>
Signed-off-by: Michael Ellerman <mpe(a)ellerman.id.au>
Link: https://lore.kernel.org/r/0c33b96317811edf691e81698aaee8fa45ec3449.16564273…
diff --git a/arch/powerpc/mm/ptdump/shared.c b/arch/powerpc/mm/ptdump/shared.c
index 03607ab90c66..f884760ca5cf 100644
--- a/arch/powerpc/mm/ptdump/shared.c
+++ b/arch/powerpc/mm/ptdump/shared.c
@@ -17,9 +17,9 @@ static const struct flag_info flag_array[] = {
.clear = " ",
}, {
.mask = _PAGE_RW,
- .val = _PAGE_RW,
- .set = "rw",
- .clear = "r ",
+ .val = 0,
+ .set = "r ",
+ .clear = "rw",
}, {
.mask = _PAGE_EXEC,
.val = _PAGE_EXEC,