aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
authorAlexey Dobriyan <adobriyan@gmail.com>2026-04-22 22:17:44 +0300
committerAndrew Morton <akpm@linux-foundation.org>2026-05-28 21:24:38 -0700
commit9794de4500e7dc8686f4ae5f2d11d76e43f299c5 (patch)
tree94d24c0102aab89286ca9102add3b810f9e0608f /fs
parentd60ec36cab338dfe2ae40d73e9c8d6c4af70d2b8 (diff)
downloadlinux-next-history-9794de4500e7dc8686f4ae5f2d11d76e43f299c5.tar.gz
proc: add tgid_iter.pid_ns member
next_tgid() accepts pid namespace as an argument, but it never changes during readdir (which would be unthinkable thing to do anyway). Move it inside iterator type and hide from direct usage. Link: https://lore.kernel.org/20260422191745.435556-1-adobriyan@gmail.com Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/proc/base.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/fs/proc/base.c b/fs/proc/base.c
index d9acfa89c894b..f2db455dbbfd2 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -3543,8 +3543,10 @@ out:
struct tgid_iter {
unsigned int tgid;
struct task_struct *task;
+ struct pid_namespace *pid_ns;
};
-static struct tgid_iter next_tgid(struct pid_namespace *ns, struct tgid_iter iter)
+
+static struct tgid_iter next_tgid(struct tgid_iter iter)
{
struct pid *pid;
@@ -3553,9 +3555,9 @@ static struct tgid_iter next_tgid(struct pid_namespace *ns, struct tgid_iter ite
rcu_read_lock();
retry:
iter.task = NULL;
- pid = find_ge_pid(iter.tgid, ns);
+ pid = find_ge_pid(iter.tgid, iter.pid_ns);
if (pid) {
- iter.tgid = pid_nr_ns(pid, ns);
+ iter.tgid = pid_nr_ns(pid, iter.pid_ns);
iter.task = pid_task(pid, PIDTYPE_TGID);
if (!iter.task) {
iter.tgid += 1;
@@ -3574,7 +3576,7 @@ int proc_pid_readdir(struct file *file, struct dir_context *ctx)
{
struct tgid_iter iter;
struct proc_fs_info *fs_info = proc_sb_info(file_inode(file)->i_sb);
- struct pid_namespace *ns = proc_pid_ns(file_inode(file)->i_sb);
+ struct pid_namespace *pid_ns = proc_pid_ns(file_inode(file)->i_sb);
loff_t pos = ctx->pos;
if (pos >= PID_MAX_LIMIT + TGID_OFFSET)
@@ -3592,9 +3594,10 @@ int proc_pid_readdir(struct file *file, struct dir_context *ctx)
}
iter.tgid = pos - TGID_OFFSET;
iter.task = NULL;
- for (iter = next_tgid(ns, iter);
+ iter.pid_ns = pid_ns;
+ for (iter = next_tgid(iter);
iter.task;
- iter.tgid += 1, iter = next_tgid(ns, iter)) {
+ iter.tgid += 1, iter = next_tgid(iter)) {
char name[10 + 1];
unsigned int len;