Re: [PATCH v3] tty: tty_io: remove hung_up_tty_fops
From: Linus Torvalds
Date: Wed May 01 2024 - 17:07:00 EST
On Wed, 1 May 2024 at 13:15, Marco Elver <elver@xxxxxxxxxx> wrote:
>
> This is relatively trivial:
>
> #ifdef __SANITIZE_THREAD__
> #define __data_racy volatile
> #endif
I really wouldn't want to make a code generation difference, but I
guess when the sanitizer is on, the compiler generating crap code
isn't a huge deal.
> In some cases it might cause the compiler to complain if converting a
> volatile pointer to a non-volatile pointer
No. Note that it's not the *pointer* that is volatile, it's the
structure member.
So it would be something like
const struct file_operations * __data_racy f_op;
and only the load of f_op would be volatile - not the pointer itself.
Of course, if somebody then does "&file->f_op" to get a pointer to a
pointer, *that* would now be a volatile pointer, but I don't see
people doing that.
So I guess this might be a way forward. Anybody want to verify?
Now, the "hung_up_tty_fops" *do* need to be expanded to have hung up
ops for every op that is non-NULL in the normal tty ops. That was a
real bug. We'd also want to add a big comment to the tty fops to make
sure anybody who adds a new tty f_op member to make sure to populate
the hung up version too.
Linus