Re: [syzbot] Re: [keyrings?] [lsm?] [ext4?] possible deadlock in keyring_clear (2)

From: syzbot
Date: Fri Sep 27 2024 - 10:00:31 EST


For archival purposes, forwarding an incoming command email to
linux-kernel@xxxxxxxxxxxxxxx.

***

Subject: Re: [keyrings?] [lsm?] [ext4?] possible deadlock in keyring_clear (2)
Author: lizhi.xu@xxxxxxxxxxxxx

tmp no use nofs

#syz test

diff --git a/init/main.c b/init/main.c
index c4778edae797..7e08a69fc432 100644
--- a/init/main.c
+++ b/init/main.c
@@ -1261,12 +1261,15 @@ int __init_or_module do_one_initcall(initcall_t fn)
int count = preempt_count();
char msgbuf[64];
int ret;
+ unsigned int nofs_flag;

if (initcall_blacklisted(fn))
return -EPERM;

do_trace_initcall_start(fn);
+ nofs_flag = memalloc_nofs_save();
ret = fn();
+ memalloc_nofs_restore(nofs_flag);
do_trace_initcall_finish(fn, ret);

msgbuf[0] = 0;
diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
index 1c77400bd88e..fa16932f799d 100644
--- a/fs/ext4/ioctl.c
+++ b/fs/ext4/ioctl.c
@@ -1623,7 +1623,12 @@ static long __ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)

long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
{
- return __ext4_ioctl(filp, cmd, arg);
+ long ret;
+ unsigned int nofs_flag;
+ nofs_flag = memalloc_nofs_save();
+ ret = __ext4_ioctl(filp, cmd, arg);
+ memalloc_nofs_restore(nofs_flag);
+ return ret;
}

#ifdef CONFIG_COMPAT