Re: [PATCH v3] tty: tty_io: remove hung_up_tty_fops

From: Tetsuo Handa
Date: Thu May 02 2024 - 19:54:50 EST


On 2024/05/03 2:29, Linus Torvalds wrote:
>> Hmm, debugfs assumes that f_op does not change?
>>
>> fs/debugfs/file.c: In function 'full_proxy_release':
>> fs/debugfs/file.c:357:45: warning: initialization discards 'volatile' qualifier from pointer target type [-Wdiscarded-qualifiers]
>> const struct file_operations *proxy_fops = filp->f_op;
>> ^~~~
>
> This error is a direct result of placing the __data_racy in the wrong place.

Oops. But it seems to me that the problem is that

>
> It's not that the _result_ of reading filp->f_op is racy. It's the
> read of filp->f_op itself that is.

debugfs (or maybe any filesystems that wraps f_op) caches filp->f_op into
private data

struct debugfs_fsdata {
const struct file_operations *real_fops; // <= may not be up to dated?
(...snip...)
}

and cannot update cached real_fops value when

filp->f_op = &hung_up_tty_fops;

or

mfile->file->f_op = &snd_shutdown_f_ops;

is called.

Such filesystems need to be updated to cache "struct file *" rather than
"struct file_operations *" ?