2021-02-13 16:59:47

by syzbot

[permalink] [raw]
Subject: WARNING in pstore_kill_sb

Hello,

syzbot found the following issue on:

HEAD commit: e0756cfc Merge tag 'trace-v5.11-rc7' of git://git.kernel.o..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=10692850d00000
kernel config: https://syzkaller.appspot.com/x/.config?x=b9a66c874a03a1ed
dashboard link: https://syzkaller.appspot.com/bug?extid=d0cf0ad6513e9a1da5df
userspace arch: arm

Unfortunately, I don't have any reproducer for this issue yet.

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: [email protected]

do_el0_svc_compat+0x40/0x80 arch/arm64/kernel/syscall.c:204
el0_svc_compat+0x20/0x30 arch/arm64/kernel/entry-common.c:442
el0_sync_compat_handler+0x90/0x140 arch/arm64/kernel/entry-common.c:451
el0_sync_compat+0x178/0x180 arch/arm64/kernel/entry.S:708
------------[ cut here ]------------
WARNING: CPU: 0 PID: 5780 at fs/pstore/inode.c:470 pstore_kill_sb+0x88/0x90 fs/pstore/inode.c:480
Modules linked in:
CPU: 0 PID: 5780 Comm: syz-executor.1 Not tainted 5.11.0-rc7-syzkaller-00002-ge0756cfc7d7c #0
Hardware name: linux,dummy-virt (DT)
pstate: 00000005 (nzcv daif -PAN -UAO -TCO BTYPE=--)
pc : pstore_kill_sb+0x88/0x90 fs/pstore/inode.c:470
lr : pstore_kill_sb+0x30/0x90 fs/pstore/inode.c:469
sp : ffff00001d1e7a70
x29: ffff00001d1e7a70 x28: 0000000000000004
x27: 0000000000008000 x26: ffff000016070a00
x25: 0000000000000000 x24: ffff00000df2e068
x23: 1fffe00001be5c0d x22: ffff800011edf070
x21: ffff80001bbea000 x20: ffff00000df2e000
x19: ffff800019a97a20 x18: 0000000000000000
x17: 0000000000000000 x16: 0000000000000002
x15: ffff800019c06380 x14: 1fffe00003a3cee8
x13: 0000000000000000 x12: ffff700003352f45
x11: 1ffff00003352f44 x10: ffff700003352f44
x9 : dfff800000000000 x8 : ffff800019a97a27
x7 : 0000000000000001 x6 : 00008ffffccad0bc
x5 : ffff800019a97a20 x4 : 1fffe00001de59a9
x3 : 0000000000000000 x2 : 0000000000000000
x1 : ffff00000ef2cd40 x0 : 0000000000000000
Call trace:
pstore_kill_sb+0x88/0x90 fs/pstore/inode.c:480
deactivate_locked_super+0x94/0x154 fs/super.c:335
mount_single+0x114/0x180 fs/super.c:1470
pstore_mount+0x1c/0x30 fs/pstore/inode.c:464
legacy_get_tree+0xd0/0x190 fs/fs_context.c:592
vfs_get_tree+0x74/0x2a0 fs/super.c:1496
do_new_mount fs/namespace.c:2881 [inline]
path_mount+0xf64/0x2170 fs/namespace.c:3211
do_mount fs/namespace.c:3224 [inline]
__do_sys_mount fs/namespace.c:3432 [inline]
__se_sys_mount fs/namespace.c:3409 [inline]
__arm64_sys_mount+0x2ec/0x520 fs/namespace.c:3409
__invoke_syscall arch/arm64/kernel/syscall.c:37 [inline]
invoke_syscall arch/arm64/kernel/syscall.c:49 [inline]
el0_svc_common.constprop.0+0x110/0x3c0 arch/arm64/kernel/syscall.c:159
do_el0_svc_compat+0x40/0x80 arch/arm64/kernel/syscall.c:204
el0_svc_compat+0x20/0x30 arch/arm64/kernel/entry-common.c:442
el0_sync_compat_handler+0x90/0x140 arch/arm64/kernel/entry-common.c:451
el0_sync_compat+0x178/0x180 arch/arm64/kernel/entry.S:708


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at [email protected].

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.


2021-02-14 03:18:07

by Tetsuo Handa

[permalink] [raw]
Subject: [PATCH] pstore: fix warning in pstore_kill_sb()

syzbot is hitting WARN_ON(pstore_sb != sb) at pstore_kill_sb() [1], for the
assumption that pstore_sb != NULL is wrong because pstore_fill_super() will
not assign pstore_sb = sb when new_inode() for d_make_root() returned NULL
(due to memory allocation fault injection).

Since mount_single() calls pstore_kill_sb() when pstore_fill_super()
failed, pstore_kill_sb() needs to be aware of such failure path.

[1] https://syzkaller.appspot.com/bug?id=6abacb8da5137cb47a416f2bef95719ed60508a0

Reported-by: syzbot <[email protected]>
Signed-off-by: Tetsuo Handa <[email protected]>
---
fs/pstore/inode.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/pstore/inode.c b/fs/pstore/inode.c
index 93a217e4f563..14658b009f1b 100644
--- a/fs/pstore/inode.c
+++ b/fs/pstore/inode.c
@@ -467,7 +467,7 @@ static struct dentry *pstore_mount(struct file_system_type *fs_type,
static void pstore_kill_sb(struct super_block *sb)
{
mutex_lock(&pstore_sb_lock);
- WARN_ON(pstore_sb != sb);
+ WARN_ON(pstore_sb && pstore_sb != sb);

kill_litter_super(sb);
pstore_sb = NULL;
--
2.18.4

2021-02-23 17:32:26

by Kees Cook

[permalink] [raw]
Subject: Re: [PATCH] pstore: fix warning in pstore_kill_sb()

On Sun, 14 Feb 2021 12:13:07 +0900, Tetsuo Handa wrote:
> syzbot is hitting WARN_ON(pstore_sb != sb) at pstore_kill_sb() [1], for the
> assumption that pstore_sb != NULL is wrong because pstore_fill_super() will
> not assign pstore_sb = sb when new_inode() for d_make_root() returned NULL
> (due to memory allocation fault injection).
>
> Since mount_single() calls pstore_kill_sb() when pstore_fill_super()
> failed, pstore_kill_sb() needs to be aware of such failure path.
>
> [...]

Applied to for-next/pstore, thanks!

[1/1] pstore: Fix warning in pstore_kill_sb()
https://git.kernel.org/kees/c/9c7d83ae6ba6

--
Kees Cook