Skip to content

Commit 280e36f

Browse files
committed
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: ca567df ("nsfs: add pid translation ioctls") Reported-by: [email protected] Signed-off-by: Christian Brauner <[email protected]>
1 parent 400e406 commit 280e36f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

fs/nsfs.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,14 +174,14 @@ static long ns_ioctl(struct file *filp, unsigned int ioctl,
174174
fallthrough;
175175
case NS_GET_PID_IN_PIDNS:
176176
fallthrough;
177-
case NS_GET_TGID_IN_PIDNS:
177+
case NS_GET_TGID_IN_PIDNS: {
178178
if (ns->ops->type != CLONE_NEWPID)
179179
return -EINVAL;
180180

181181
ret = -ESRCH;
182182
pid_ns = container_of(ns, struct pid_namespace, ns);
183183

184-
rcu_read_lock();
184+
guard(rcu)();
185185

186186
if (ioctl == NS_GET_PID_IN_PIDNS ||
187187
ioctl == NS_GET_TGID_IN_PIDNS)
@@ -208,11 +208,11 @@ static long ns_ioctl(struct file *filp, unsigned int ioctl,
208208
ret = 0;
209209
break;
210210
}
211-
rcu_read_unlock();
212211

213212
if (!ret)
214213
ret = -ESRCH;
215214
break;
215+
}
216216
default:
217217
ret = -ENOTTY;
218218
}

0 commit comments

Comments
 (0)