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

From: Tetsuo Handa
Date: Sun Apr 23 2023 - 19:56:25 EST


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.