mirror of
https://github.com/torvalds/linux.git
synced 2024-11-24 13:11:40 +00:00
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: ca567df74a
("nsfs: add pid translation ioctls")
Reported-by: syzbot+a3e82ae343b26b4d2335@syzkaller.appspotmail.com
Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
parent
400e4064b6
commit
280e36f0d5
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user