All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Andrea Righi" <arighi@nvidia.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH 2/5] bpf: Expose pinned arenas as sized bpffs files
Date: Sat, 10 Oct 2026 23:06:45 +0000	[thread overview]
Message-ID: <sashiko-outbox-166925@kernel.org> (raw)
In-Reply-To: <20261010224902.1232178-3-arighi@nvidia.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] bpf: unreachable overlap calculation logic for exported arenas in zap_pages()
--

commit 0faffaea3054cd9867f7c5fb15288b7583784671
Author: Andrea Righi <arighi@nvidia.com>

bpf: Expose pinned arenas as sized bpffs files

This commit introduces the BPF_F_ARENA_EXPORT flag to expose pinned BPF
arenas as sized files in bpffs, allowing userspace programs to mmap them.
Map fault handling and page zapping are updated to support disjoint slice
mappings using file offsets. It also mandates that exported arenas use the
BPF_F_ARENA_NO_FREE flag.

> diff --git a/kernel/bpf/arena.c b/kernel/bpf/arena.c
> --- a/kernel/bpf/arena.c
> +++ b/kernel/bpf/arena.c
[ ... ]
> @@ -881,8 +917,14 @@ static void zap_pages(struct bpf_arena *arena, long uaddr, long page_cnt)
>  		 */
>  		vma = find_vma(mm, vm_start);
>  		if (vma && vma->vm_start == vm_start &&
> -		    vma->vm_file && vma->vm_file->private_data == &arena->map)
> -			zap_vma_range(vma, uaddr, size);
> +		    vma->vm_file && vma->vm_file->private_data == &arena->map) {
> +			vma_start = (u64)vma->vm_pgoff << PAGE_SHIFT;
> +			vma_end = vma_start + vma->vm_end - vma->vm_start;
> +			if (start < vma_end && end > vma_start)
> +				zap_vma_range(vma, vma->vm_start +
> +					      (max(start, vma_start) - vma_start),
> +					      min(end, vma_end) - max(start, vma_start));
> +		}

[Severity: Low]
Is this overlap calculation in zap_pages() reachable for exported arenas?

The offset calculation here uses vma->vm_pgoff to compute overlaps for
partial page zaps. This specific offset math is only strictly necessary
for exported mappings, because canonical arena VMAs always have a zero
page offset.

However, zap_pages() is exclusively called during page freeing operations
such as bpf_arena_free_pages() or via arena_free_worker().

Because arena_map_alloc() requires exported arenas to have the
BPF_F_ARENA_NO_FREE flag set, and bpf_arena_free_pages() explicitly returns
early when this flag is present, BPF programs can never free pages in
exported arenas.

Could this make the newly added partial zap logic using vma->vm_pgoff
completely dead code?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261010224902.1232178-1-arighi@nvidia.com?part=2

  reply	other threads:[~2026-10-10 23:06 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-10 22:45 [PATCH bpf-next 0/5] bpf: Expose pinned arenas as sized bpffs files Andrea Righi
2026-10-10 22:45 ` [PATCH 1/5] bpf: Add an arena flag to retain allocated pages Andrea Righi
2026-10-10 23:00   ` sashiko-bot
2026-10-10 22:45 ` [PATCH 2/5] bpf: Expose pinned arenas as sized bpffs files Andrea Righi
2026-10-10 23:06   ` sashiko-bot [this message]
2026-10-10 23:40   ` bot+bpf-ci
2026-10-10 22:45 ` [PATCH 3/5] docs/bpf: Document pinned arena file mappings Andrea Righi
2026-10-10 23:19   ` bot+bpf-ci
2026-10-10 22:45 ` [PATCH 4/5] selftests/bpf: Test " Andrea Righi
2026-10-10 23:40   ` bot+bpf-ci
2026-10-10 22:46 ` [PATCH 5/5] selftests/bpf: Test two-way arena access with two guests Andrea Righi
2026-10-10 23:00   ` sashiko-bot
2026-10-10 23:40   ` bot+bpf-ci

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=sashiko-outbox-166925@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=arighi@nvidia.com \
    --cc=bpf@vger.kernel.org \
    --cc=sashiko-reviews@lists.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.