Re: [PATCH] proc: Show the mountid associated with exe

From: Al Viro
Date: Sun May 11 2025 - 10:23:04 EST


On Sun, May 11, 2025 at 07:42:43PM +0800, WangYuli wrote:

> +static int proc_exe_mntid(struct seq_file *m, struct pid_namespace *ns,
> + struct pid *pid, struct task_struct *task)
> +{
> + struct file *exe_file;
> + struct path exe_path;
> +
> + exe_file = get_task_exe_file(task);
> +
> + if (exe_file) {
> + exe_path = exe_file->f_path;
> + path_get(&exe_file->f_path);
> +
> + seq_printf(m, "%i\n", real_mount(exe_path.mnt)->mnt_id);
> +
> + path_put(&exe_file->f_path);

Excuse me, just what is that path_get/path_put for? If you have
an opened file, you do have its ->f_path pinned and unchanging.
Otherwise this call of path_get() would've itself been unsafe...

And I still wonder about the rationale, TBH...