> u64_stats: Mark the update helpers used by BPF notrace
TL;DR: The seqcount helpers called by the u64_stats helpers
(32-bit/PREEMPT_RT) aren't marked notrace, so once plain inline stops implying
notrace, an fentry program may possibly recurse from BPF stats updates.
> diff --git a/include/linux/u64_stats_sync.h b/include/linux/u64_stats_sync.h
> --- a/include/linux/u64_stats_sync.h
> +++ b/include/linux/u64_stats_sync.h
[ ... ]
> @@ -166,19 +166,19 @@ static inline void u64_stats_inc(u64_stats_t *p)
> seqcount_init(&__s->seq); \
> } while (0)
>
> -static inline void __u64_stats_update_begin(struct u64_stats_sync *syncp)
> +static inline void notrace __u64_stats_update_begin(struct u64_stats_sync
> *syncp)
> {
> preempt_disable_nested();
> write_seqcount_begin(&syncp->seq);
> }
>
> -static inline void __u64_stats_update_end(struct u64_stats_sync *syncp)
> +static inline void notrace __u64_stats_update_end(struct u64_stats_sync
> *syncp)
> {
> write_seqcount_end(&syncp->seq);
> preempt_enable_nested();
> }
On 32-bit and PREEMPT_RT, these helpers call write_seqcount_begin() and
write_seqcount_end(), which expand to do_write_seqcount_begin() and
do_write_seqcount_end() in include/linux/seqlock.h, and then to the
do_raw_write_seqcount_*() helpers.
Those are plain static inline without notrace. Once the last patch in this
series removes notrace from plain inline, can an out-of-line copy of them
be traced?
If so, could an fentry program attached there and run from
bpf_prog_inc_misses_counter() or __update_prog_stats() recurse, which is
what this patch is meant to prevent?
Should the seqcount helpers be marked notrace as well, or is the
commit message claim that the helpers they call are covered too broad?
---
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/46577721107