From: sashiko-bot@kernel.org
To: "Zhen Ni" <zhen.ni@easystack.cn>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH 5/6] mm/page_owner: add bpf_page_owner_get_memcg_info() kfunc
Date: Fri, 09 Oct 2026 12:43:20 +0000 [thread overview]
Message-ID: <sashiko-outbox-165554@kernel.org> (raw)
In-Reply-To: <20261009112308.240769-6-zhen.ni@easystack.cn>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Critical] bpf: Missing __sz annotation allows BPF stack overflow in memcg kfunc
- [High] bpf: missing __sz annotation on size param causes stack buffer overflow
--
commit 98bc7e204a48312a6be1bc67be9ade762ffed9ff
Author: Zhen Ni <zhen.ni@easystack.cn>
mm/page_owner: add bpf_page_owner_get_memcg_info() kfunc
This commit introduces a new BPF kfunc to expose per-page memcg information,
including the cgroup path. It extracts memcg data collection into a new
helper function that the kfunc calls directly.
> diff --git a/mm/page_owner_iter.c b/mm/page_owner_iter.c
> index 907517a291443..e7a8ca1e90e8d 100644
> --- a/mm/page_owner_iter.c
> +++ b/mm/page_owner_iter.c
[ ... ]
> @@ -170,4 +170,11 @@ __bpf_kfunc int bpf_page_owner_get_nid(struct page_owner_scan *scan)
> return page_owner_get_nid(scan->page);
> }
>
> +__bpf_kfunc int bpf_page_owner_get_memcg_info(struct page_owner_scan *scan,
> + struct memcg_info *info,
> + char *buf, u32 size)
[Severity: Critical]
Does this size parameter need the __sz suffix for the verifier to track
memory bounds correctly?
Because the parameter is named size rather than buf__sz, it appears the
verifier might treat buf as a fixed 1-byte allocation and size as an
unconstrained scalar.
Could this allow a BPF program to pass a 1-byte stack buffer alongside an
arbitrarily large size value? If so, when this calls into
get_page_memcg_info() in mm/page_owner.c and executes:
get_page_memcg_info()
...
if (buf && size)
cgroup_path(memcg->css.cgroup, buf, size);
can it overwrite the BPF stack and corrupt adjacent kernel memory?
[Severity: High]
Do the buf and info parameters also need the __uninit suffix?
Without this suffix, the verifier might improperly force BPF programs to
pre-initialize these output variables just to pass verification.
> +{
> + return get_page_memcg_info(scan->page, info, buf, size);
> +}
> +
> __bpf_kfunc_end_defs();
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261009112308.240769-1-zhen.ni@easystack.cn?part=5
next prev parent reply other threads:[~2026-10-09 12:43 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-09 11:23 [PATCH 0/6] mm/page_owner: add bpf_iter and kfuncs Zhen Ni
2026-10-09 11:23 ` [PATCH 1/6] mm/page_owner: extract page_owner_next_eligible() from read loop Zhen Ni
2026-10-09 11:35 ` sashiko-bot
2026-10-10 9:40 ` zhen.ni
2026-10-09 11:23 ` [PATCH 2/6] mm/page_owner: add bpf_iter target "page_owner" Zhen Ni
2026-10-09 11:50 ` sashiko-bot
2026-10-12 6:28 ` zhen.ni
2026-10-09 11:23 ` [PATCH 3/6] mm/page_owner: add open-coded page_owner iterator Zhen Ni
2026-10-09 12:00 ` sashiko-bot
2026-10-12 6:41 ` zhen.ni
2026-10-09 11:23 ` [PATCH 4/6] mm/page_owner: add bpf_page_owner_get_nid() kfunc Zhen Ni
2026-10-09 12:20 ` sashiko-bot
2026-10-12 7:01 ` zhen.ni
2026-10-09 11:23 ` [PATCH 5/6] mm/page_owner: add bpf_page_owner_get_memcg_info() kfunc Zhen Ni
2026-10-09 12:43 ` sashiko-bot [this message]
2026-10-12 7:09 ` zhen.ni
2026-10-09 11:23 ` [PATCH 6/6] selftests/bpf: add tests for the page_owner bpf_iter target Zhen Ni
2026-10-09 12:50 ` sashiko-bot
2026-10-12 7:15 ` zhen.ni
2026-10-09 13:48 ` 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-165554@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=zhen.ni@easystack.cn \
/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.