Re: Commit 0be0ee71 ("fs: properly and reliably lock f_pos in fdget_pos()") breaking userspace

From: Linus Torvalds
Date: Mon Nov 25 2019 - 22:40:07 EST


On Mon, Nov 25, 2019 at 7:21 PM Linus Torvalds
<torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> Of course, this may fix the f_pos locking issue, but replace it with a
> "oops, the character device driver tried to look at *pos anyway", and
> that will give you a nice OOPS instead.

Confirmed. At least the x86 firmware update code uses
"simple_read_from_buffer()", which does use the file position, but
doesn't actually allow llseek().

So no, "it's a character device no llseek" does not mean that it acts
as a pure streaming device with no file position, and we'd actually
have to mark individual drivers (either by adding 'stream_open()' in
their open routines, or adding the extra field to 'struct
file_operations' that I mentioned).

I think I'll have to revert that trial commit. I'll give it another
day in case somebody has a better idea, but it looks like it's too
early to do that nice cleanup as things are now.

Linus