Re: [syzbot] [afs?] [net?] KCSAN: data-race in rxrpc_send_data / rxrpc_set_call_completion

From: David Howells
Date: Mon Apr 24 2023 - 12:06:50 EST


Dmitry Vyukov <dvyukov@xxxxxxxxxx> wrote:

> If I am reading this correctly, rxrpc_send_data() can read wrong
> call->completion and state and incorrectly exit with an error if
> rxrpc_wait_to_be_connected() exists early right after observing error
> set here:
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/net/rxrpc/sendmsg.c?id=148341f0a2f53b5e8808d093333d85170586a15d#n58
> The code seems to assume that at that point all writes done by
> rxrpc_set_call_completion() are already finished, but it's not
> necessarily the case.

I'm not sure it matters. call->error can only be set by the I/O thread and
only if a call fails - in which case the call state will be set shortly
thereafter - plus a couple of places where we fail to set the call up, in
which case we're under the call's user_mutex or didn't even manage to fully
allocate it.

That said, I probably should check the call state first. I might also want to
ignore any signal if the call did manage to get connected, lest I leave it
dangling - a problem might come if userspace issues a single sendmsg() to set
up the call and supply data to be transmitted. I need to have a ponder on
that one.

David