summaryrefslogtreecommitdiff
path: root/fs/nsfs.c
diff options
context:
space:
mode:
authorChristian Brauner <brauner@kernel.org>2024-07-16 10:19:11 +0300
committerChristian Brauner <brauner@kernel.org>2024-07-18 10:50:08 +0300
commit280e36f0d5b997173d014c07484c03a7f7750668 (patch)
tree1ced174f145d76838f4c9b9dee5affe9000156d6 /fs/nsfs.c
parent400e4064b63a4c302dff11136828f54de91eda2a (diff)
downloadlinux-280e36f0d5b997173d014c07484c03a7f7750668.tar.xz
nsfs: use cleanup guard
Ensure that rcu read lock is given up before returning. Link: https://lore.kernel.org/r/20240716-elixier-fliesen-1ab342151a61@brauner Fixes: ca567df74a28 ("nsfs: add pid translation ioctls") Reported-by: syzbot+a3e82ae343b26b4d2335@syzkaller.appspotmail.com Signed-off-by: Christian Brauner <brauner@kernel.org>
Diffstat (limited to 'fs/nsfs.c')
-rw-r--r--fs/nsfs.c6
1 files 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;
}