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

From: Linus Torvalds
Date: Mon Nov 25 2019 - 22:38:47 EST


On Mon, Nov 25, 2019 at 7:21 PM Linus Torvalds
<torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> Anyway, I think the thing to do (for now) is to just say "character
> devices are FMODE_STREAM files if they have no llseek operations".
> That should take care of both tty's and the sound devices.

A cleaner thing might be to add an explicit field to 'struct
file_operations' to show that it is a stream operation. That would
make it much easier for drivers to say "mark me as a stream" without
having to change their open routines (not all cases might even have
open routines).

The file operations already have a history of this kind of "this is
what I support" flags with the "mmap_supported_flags" mask, which is a
different (but at the same time somewhat similar) set of "this is the
set of operations I support" thing. FMODE_STREAM wouldn't be that
different.

Anyway, I was clearly too optimistic as to how painless this would be.
I tested it on my desktop and laptop, but they have very similar
setups other than their form factor, so the fact that neither showed
any issues was perhaps not all that meaningful.

Linus