Thread (20 messages) flat view 20 messages, 3 authors, 2020-01-24

Re: [PATCH v2 1/6] fs/readdir: Fix filldir() and filldir64() use of user_access_begin()

From: Linus Torvalds <torvalds@linux-foundation.org>
Date: 2020-01-22 20:16:02
Also in: linux-fsdevel, linux-mm, lkml

On Wed, Jan 22, 2020 at 12:00 PM Linus Torvalds
[off-list ref] wrote:
A bit more re-organization also allows us to do the unsafe_put_user()
unconditionally.
I meant the "user_access_begin()", of course.

Code was right, explanation was wrong.

That said, with this model, we _could_ make the

        unsafe_put_user(offset, &prev->d_off, efault_end);

be unconditional too, since now 'prev' will actually be a valid
pointer - it will match 'dirent' if there was no prev.

But since we want to test whether we had a previous entry anyway (for
the signal handling latency issue), making the write to the previous
d_reclen unconditional (and then overwriting it the next iteration)
doesn't actually buy us anything.

It was the user_access_begin() I'd rather have unconditional, since
otherwise it gets duplicated in two (very slightly) different versions
and we have unnecessary code bloat.

           Linus
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help