mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: bot+bpf-ci@kernel.org
To: nicholasfvelten@gmail.com,ast@kernel.org,daniel@iogearbox.net,andrii@kernel.org,eddyz87@gmail.com,memxor@gmail.com,martin.lau@linux.dev,song@kernel.org,yonghong.song@linux.dev,jolsa@kernel.org,emil@etsalapatis.com,ihor.solodrai@linux.dev
Cc: bpf@vger.kernel.org,linux-kernel@vger.kernel.org,syzbot+1ea4f564bf6f1f3d1dc4@syzkaller.appspotmail.com,nicholasfvelten@gmail.com,ast@kernel.org,andrii@kernel.org,daniel@iogearbox.net,martin.lau@kernel.org,eddyz87@gmail.com,yonghong.song@linux.dev,mason@kernel.org,ihor.solodrai@linux.dev
Subject: Re: [PATCH bpf-next] bpf: Annotate data races on bpf_lru_node type
Date: Wed, 14 Oct 2026 02:53:59 +0000 (UTC)	[thread overview]
Message-ID: <f8c821cc97a2e46cae72802b781429ebbc0e6c4213c6f93e586b77255fa2abf5@mail.kernel.org> (raw)
In-Reply-To: <20261013-fix-lru-node-type-kcsan-v1-1-0b743f5af2f3@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2381 bytes --]

> bpf: Annotate data races on bpf_lru_node type

TL;DR: Commit message only: it may be inaccurate about the locking for the
node->type writes, and "the sanity check only feeds a warning" is questionable
since the check also causes an early return.

> bpf: Annotate data races on bpf_lru_node type

[ ... ]

> node->type is written under the global l->lock when a node moves between
> the active, inactive and free lists, and under the per-CPU loc_l->lock
> when it moves to or from a local list. It is read in two places that do
> not hold the lock the writer holds:

The commit message says node->type is written under the per-CPU
loc_l->lock when it moves to or from a local list.  Is that complete for
the writers this patch converts to WRITE_ONCE()?

The failure path in bpf_common_lru_pop_free() writes node->type after
taking loc_l->lock has failed:

kernel/bpf/bpf_lru_list.c:bpf_common_lru_pop_free() {
    ...
	if (raw_res_spin_lock_irqsave(&loc_l->lock, flags)) {
		/* ... */
		WRITE_ONCE(node->type, BPF_LRU_LOCAL_LIST_T_FREE);
    ...
}

so no lock is held for that write.  Could the commit message mention
that this write is safe because the stolen node is not on any list and
is owned by the current CPU at that point?

[ ... ]

> Both races are benign: the type is a single byte, the sanity check only
> feeds a warning, and the re-check exists precisely because the value can
> change concurrently (any change sends the node down the check_lru_list
> path, which revalidates under l->lock). Mark the two reads with

Is "the sanity check only feeds a warning" accurate?  In
bpf_lru_list_push_free() the WARN_ON_ONCE() condition also controls an
early return:

kernel/bpf/bpf_lru_list.c:bpf_lru_list_push_free() {
    ...
	if (WARN_ON_ONCE(IS_LOCAL_LIST_TYPE(READ_ONCE(node->type))))
		return;
    ...
}

so the racy value affects control flow and not only the warning.

Would it be more precise to say the race is benign because a concurrent
writer can only store BPF_LRU_LIST_T_ACTIVE or BPF_LRU_LIST_T_INACTIVE
for a node being pushed free, so IS_LOCAL_LIST_TYPE() gives the same
result for any value the read can observe?


---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md

CI run summary: https://github.com/kernel-patches/bpf/actions/runs/38500297852

  reply	other threads:[~2026-10-14  2:54 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-14  2:00 Nicholas Velten via B4 Relay
2026-10-14  2:53 ` bot+bpf-ci [this message]
2026-10-16 16:06 ` Alexei Starovoitov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f8c821cc97a2e46cae72802b781429ebbc0e6c4213c6f93e586b77255fa2abf5@mail.kernel.org \
    --to=bot+bpf-ci@kernel.org \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=emil@etsalapatis.com \
    --cc=ihor.solodrai@linux.dev \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.lau@kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=mason@kernel.org \
    --cc=memxor@gmail.com \
    --cc=nicholasfvelten@gmail.com \
    --cc=song@kernel.org \
    --cc=syzbot+1ea4f564bf6f1f3d1dc4@syzkaller.appspotmail.com \
    --cc=yonghong.song@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®