Re: [PATCH v2 1/2] procfs: avoid some usages of seq_file private data

From: Kees Cook
Date: Fri Nov 08 2024 - 10:32:22 EST




On November 8, 2024 2:13:38 AM PST, Stas Sergeev <stsp2@xxxxxxxxx> wrote:
>seq_file private data carries the inode pointer here.
>Replace
>`struct inode *inode = m->private;`
>with:
>`struct inode *inode = file_inode(m->file);`
>to avoid the reliance on private data.

Conceptually this seems good, though I'd expect to see the removal of _setting_ m->private too in this patch.

>This is needed so that `proc_single_show()` can be used by
>custom fops that utilize seq_file private data for other things.
>This is used in the next patch.

Now that next patch is pretty wild. I think using proc is totally wrong for managing uid/gid. If that's going to happen at all, I think it should be tied to pidfd which will already do the correct process lifetime management, etc.

-Kees

--
Kees Cook