Re: [syzbot] [kernel?] KCSAN: data-race in __fput / __tty_hangup (4)

From: Al Viro
Date: Sun Apr 23 2023 - 20:47:11 EST


On Mon, Apr 24, 2023 at 08:55:58AM +0900, Tetsuo Handa wrote:
> On 2023/04/24 8:34, Al Viro wrote:
> > As for the original report - add a (failing) ->splice_read() in hung_ut_tty_fops
> > to deal with the original problem.
>
> Yes, adding a dummy splice_read callback is OK for avoiding NULL pointer dereference.
> But we need more changes for avoiding KCSAN race reporting.
>
> Are you OK with https://lkml.kernel.org/r/6bec279c-07b3-d6f1-0860-4d6b136a2025@xxxxxxxxxxxxxxxxxxx
> which will require touching so many locations ?
>
> If you want tty layer handle this race without rewriting all f_op dereferences,
> we would need to replace
>
> filp->f_op = &hung_up_tty_fops;
>
> with
>
> data_race(filp->some_flags_for_tty = true);
>
> rather than
>
> data_race(filp->f_op = &hung_up_tty_fops);
>
> and check
>
> if (data_race(filp->some_flags_for_tty)) {
> return error;
> }
>
> from each "struct tty_operations" callback function.

What struct tty_operations? It's file_operations, unfortunately, and
their calls are on quite a few fast paths.

Do you mean doing that in method instances that are present in tty_fops
you mean doing that in method instances that are present in tty_fops
and different in hung_up_tty_fops?