From: Christian Brauner <brauner@kernel.org>
To: syzkaller-bugs@googlegroups.com,
syzbot+a3e82ae343b26b4d2335@syzkaller.appspotmail.com
Cc: Christian Brauner <brauner@kernel.org>,
akpm@linux-foundation.org, aleksandr.mikhalitsyn@canonical.com,
jack@suse.cz, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
viro@zeniv.linux.org.uk
Subject: [PATCH] nsfs: use cleanup guard
Date: Tue, 16 Jul 2024 09:19:11 +0200 [thread overview]
Message-ID: <20240716-elixier-fliesen-1ab342151a61@brauner> (raw)
In-Reply-To: <20240715205140.c260410215836e753a44b5e9@linux-foundation.org>
Ensure that rcu read lock is given up before returning.
Reported-by: syzbot+a3e82ae343b26b4d2335@syzkaller.appspotmail.com
Fixes: ca567df74a28 ("nsfs: add pid translation ioctls")
Signed-off-by: Christian Brauner <brauner@kernel.org>
---
I have a few fixes pending I plan to send out asap.
---
fs/nsfs.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/fs/nsfs.c b/fs/nsfs.c
index a4a925dce331..97c37a9631e5 100644
--- a/fs/nsfs.c
+++ b/fs/nsfs.c
@@ -174,14 +174,14 @@ static long ns_ioctl(struct file *filp, unsigned int ioctl,
fallthrough;
case NS_GET_PID_IN_PIDNS:
fallthrough;
- case NS_GET_TGID_IN_PIDNS:
+ case NS_GET_TGID_IN_PIDNS: {
if (ns->ops->type != CLONE_NEWPID)
return -EINVAL;
ret = -ESRCH;
pid_ns = container_of(ns, struct pid_namespace, ns);
- rcu_read_lock();
+ guard(rcu)();
if (ioctl == NS_GET_PID_IN_PIDNS ||
ioctl == NS_GET_TGID_IN_PIDNS)
@@ -208,11 +208,11 @@ static long ns_ioctl(struct file *filp, unsigned int ioctl,
ret = 0;
break;
}
- rcu_read_unlock();
if (!ret)
ret = -ESRCH;
break;
+ }
default:
ret = -ENOTTY;
}
--
2.43.0
next prev parent reply other threads:[~2024-07-16 7:19 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-16 1:24 [syzbot] [mm?] BUG: sleeping function called from invalid context in vma_alloc_folio_noprof syzbot
2024-07-16 3:51 ` Andrew Morton
2024-07-16 7:19 ` Christian Brauner [this message]
2024-07-16 7:28 ` [PATCH] nsfs: use cleanup guard Christian Brauner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240716-elixier-fliesen-1ab342151a61@brauner \
--to=brauner@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=aleksandr.mikhalitsyn@canonical.com \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=syzbot+a3e82ae343b26b4d2335@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox