Re: [CFT][PATCH] kernfs: Correct kernfs directory seeks.

From: Al Viro
Date: Thu Jun 07 2018 - 14:36:36 EST


On Tue, Jun 05, 2018 at 12:47:33PM -0500, Eric W. Biederman wrote:

> Sigh, I have found another issue with kernfs_fop_readdir.
>
> We are not currently protecting file->private_data with the kernfs_mutex
> or any other kind of serialization. Which means if two processes are
> calling readdir on the same file descriptor we might get unpredictable
> behavior.
>
> It doesn't look too bad and easy enough to fix, but definitely something
> to be watchful of.

As discussed off-list - this is not a problem; getdents() et.al. are
serialized on per-struct-file basis by fdget_pos() in relevant syscalls,
since all directories automatically get FMODE_ATOMIC_POS in ->f_mode.