Re: [PATCH] bpf: fix filed access without lock
From: Cong Wang
Date: Sat Oct 26 2024 - 16:37:25 EST
On Mon, Oct 21, 2024 at 09:37:05AM +0800, mrpre wrote:
> The tcp_bpf_recvmsg_parser() function, running in user context,
> retrieves seq_copied from tcp_sk without holding the socket lock, and
> stores it in a local variable seq. However, the softirq context can
> modify tcp_sk->seq_copied concurrently, for example, n tcp_read_sock().
>
> As a result, the seq value is stale when it is assigned back to
> tcp_sk->copied_seq at the end of tcp_bpf_recvmsg_parser(), leading to
> incorrect behavior.
Good catch! This makes sense to me. Mind to be more specific on the
"incorrect behavior" here? What error or misbehavior did you see?
>
> Signed-off-by: mrpre <mrpre@xxxxxxx>
Please use your real name for SoB, see https://docs.kernel.org/process/submitting-patches.html
Thanks.