Commit 280e36f0 authored by Christian Brauner's avatar Christian Brauner

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: ca567df7 ("nsfs: add pid translation ioctls")
Reported-by: syzbot+a3e82ae343b26b4d2335@syzkaller.appspotmail.com
Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
parent 400e4064
...@@ -174,14 +174,14 @@ static long ns_ioctl(struct file *filp, unsigned int ioctl, ...@@ -174,14 +174,14 @@ static long ns_ioctl(struct file *filp, unsigned int ioctl,
fallthrough; fallthrough;
case NS_GET_PID_IN_PIDNS: case NS_GET_PID_IN_PIDNS:
fallthrough; fallthrough;
case NS_GET_TGID_IN_PIDNS: case NS_GET_TGID_IN_PIDNS: {
if (ns->ops->type != CLONE_NEWPID) if (ns->ops->type != CLONE_NEWPID)
return -EINVAL; return -EINVAL;
ret = -ESRCH; ret = -ESRCH;
pid_ns = container_of(ns, struct pid_namespace, ns); pid_ns = container_of(ns, struct pid_namespace, ns);
rcu_read_lock(); guard(rcu)();
if (ioctl == NS_GET_PID_IN_PIDNS || if (ioctl == NS_GET_PID_IN_PIDNS ||
ioctl == NS_GET_TGID_IN_PIDNS) ioctl == NS_GET_TGID_IN_PIDNS)
...@@ -208,11 +208,11 @@ static long ns_ioctl(struct file *filp, unsigned int ioctl, ...@@ -208,11 +208,11 @@ static long ns_ioctl(struct file *filp, unsigned int ioctl,
ret = 0; ret = 0;
break; break;
} }
rcu_read_unlock();
if (!ret) if (!ret)
ret = -ESRCH; ret = -ESRCH;
break; break;
}
default: default:
ret = -ENOTTY; ret = -ENOTTY;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment