public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
From: Martin KaFai Lau <martin.lau@linux.dev>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: xulang <xulang@uniontech.com>,
	"Andrii Nakryiko" <andrii@kernel.org>,
	"Alexei Starovoitov" <ast@kernel.org>, bpf <bpf@vger.kernel.org>,
	"Daniel Borkmann" <daniel@iogearbox.net>,
	"Dongliang Mu" <dzm91@hust.edu.cn>, Eduard <eddyz87@gmail.com>,
	"Hao Luo" <haoluo@google.com>,
	"Ihor Solodrai" <ihor.solodrai@linux.dev>,
	"John Fastabend" <john.fastabend@gmail.com>,
	"Jiri Olsa" <jolsa@kernel.org>, 梅开彦 <kaiyanm@hust.edu.cn>,
	kernel@uniontech.com, "KP Singh" <kpsingh@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	"Paul Chaignon" <paul.chaignon@gmail.com>,
	"Stanislav Fomichev" <sdf@fomichev.me>,
	"Song Liu" <song@kernel.org>,
	"Yonghong Song" <yonghong.song@linux.dev>
Subject: Re: [PATCH bpf v5 1/2] bpf: Fix OOB in pcpu_init_value
Date: Thu, 2 Apr 2026 10:01:33 -0700	[thread overview]
Message-ID: <ac6ejZrcnfQfaTZS@devbig1721.ftw5.facebook.com> (raw)
In-Reply-To: <CAADnVQJawYEk53kS9-w5EXU0GnUYWWW7AF_n02bUs-GPJ+4Raw@mail.gmail.com>

On Thu, Apr 02, 2026 at 07:17:17AM -0700, Alexei Starovoitov wrote:
> On Thu, Apr 2, 2026 at 12:43 AM xulang <xulang@uniontech.com> wrote:
> >
> > From: Lang Xu <xulang@uniontech.com>
> >
> > An out-of-bounds read occurs when copying element from a
> > BPF_MAP_TYPE_CGROUP_STORAGE map to another pcpu map with the
> > same value_size that is not rounded up to 8 bytes.
> >
> > The issue happens when:
> > 1. A CGROUP_STORAGE map is created with value_size not aligned to
> >    8 bytes (e.g., 4 bytes)
> > 2. A pcpu map is created with the same value_size (e.g., 4 bytes)
> > 3. Update element in 2 with data in 1
> >
> > pcpu_init_value assumes that all sources are rounded up to 8 bytes,
> > and invokes copy_map_value_long to make a data copy, However, the
> > assumption doesn't stand since there are some cases where the source
> > may not be rounded up to 8 bytes, e.g., CGROUP_STORAGE,
> 
> why? Just round it up there instead of penalizing perf everywhere.
> 
> > skb->data.
> 
> what that means?
> 
> pcpu_init_value() can access skb->data ?

After bound check, the skb->data can be used in
bpf_map_update_elem(&percpu_lru_map, &key, skb_data, BPF_NOEXIST)
which will call pcpu_init_value().

  reply	other threads:[~2026-04-02 17:01 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-02  7:39 [PATCH bpf v5 0/2] bpf: Fix OOB in pcpu_init_value and add a test xulang
2026-04-02  7:42 ` [PATCH bpf v5 1/2] bpf: Fix OOB in pcpu_init_value xulang
2026-04-02 14:17   ` Alexei Starovoitov
2026-04-02 17:01     ` Martin KaFai Lau [this message]
2026-04-02 18:36       ` Alexei Starovoitov
2026-04-02 19:58         ` Martin KaFai Lau
2026-04-03  0:05           ` Alexei Starovoitov
2026-04-03  1:59             ` Martin KaFai Lau
2026-04-03  2:09               ` Alexei Starovoitov
2026-04-03  2:24                 ` Martin KaFai Lau
2026-04-03  2:28                   ` Alexei Starovoitov
2026-04-03  2:41                     ` Martin KaFai Lau
2026-04-03  2:46                       ` Alexei Starovoitov
2026-04-02  7:42 ` [PATCH bpf v5 2/2] selftests/bpf: Add test for cgroup storage OOB read xulang

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=ac6ejZrcnfQfaTZS@devbig1721.ftw5.facebook.com \
    --to=martin.lau@linux.dev \
    --cc=alexei.starovoitov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=dzm91@hust.edu.cn \
    --cc=eddyz87@gmail.com \
    --cc=haoluo@google.com \
    --cc=ihor.solodrai@linux.dev \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kaiyanm@hust.edu.cn \
    --cc=kernel@uniontech.com \
    --cc=kpsingh@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paul.chaignon@gmail.com \
    --cc=sdf@fomichev.me \
    --cc=song@kernel.org \
    --cc=xulang@uniontech.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