All of lore.kernel.org
 help / color / mirror / Atom feed
From: Carlos Llamas <cmllamas@google.com>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: mykyta.yatsenko5@gmail.com, Andrii Nakryiko <andrii@kernel.org>,
	Eduard Zingerman <eddyz87@gmail.com>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Martin KaFai Lau <martin.lau@linux.dev>,
	Kumar Kartikeya Dwivedi <memxor@gmail.com>,
	Song Liu <song@kernel.org>,
	Yonghong Song <yonghong.song@linux.dev>,
	Jiri Olsa <jolsa@kernel.org>,
	kernel-team@android.com, linux-kernel@vger.kernel.org,
	Mykyta Yatsenko <yatsenko@meta.com>,
	"open list:BPF [GENERAL] (Safe Dynamic Programs and Tools)"
	<bpf@vger.kernel.org>
Subject: Re: [PATCH v2] libbpf: fix UAF in strset__add_str()
Date: Mon, 18 May 2026 04:59:10 +0000	[thread overview]
Message-ID: <agqcnt81eI16gOYr@google.com> (raw)
In-Reply-To: <CAEf4BzZMoWdgYFGXwT9kkZ1TKbe9ZB=XKJCuKy0+2uqzSMDMUw@mail.gmail.com>

On Fri, May 15, 2026 at 03:08:47PM -0700, Andrii Nakryiko wrote:
> I agree that this is a usability problem, but I'd handle it by
> recalculating s pointer to correct one if it happens to be coming from
> invalidated strs_data. Something along the lines of:
> 
> const char *old_data = set->strs_data;
> size_t old_data_len = set->strs_data_len;
> 
> p = strset_add_str_mem(...);
> if (!p)
>     return -ENOMEM;
> 
> if (p != old_data && s >= old_data && s < old_data + old_data_len)
>     s = p + (s - old_data);
> 
> 
> At this point s will be correct even if it was invalidated.
> 
> pw-bot: cr

Oh right, that totally works. I've tested the changes and will send a
new patch. Obviously 'p' was meant to be 'set->strs_data' in the check.

Thanks,
--
Carlos Llamas

  reply	other threads:[~2026-05-18  4:59 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-13 23:20 [PATCH] libbpf: fix UAF in strset__add_str() Carlos Llamas
2026-05-13 23:55 ` bot+bpf-ci
2026-05-14  1:10   ` Carlos Llamas
2026-05-14 11:57 ` sashiko-bot
2026-05-14 13:38   ` Mykyta Yatsenko
2026-05-14 18:39     ` Carlos Llamas
2026-05-15  4:47     ` [PATCH v2] " Carlos Llamas
2026-05-15 22:08       ` Andrii Nakryiko
2026-05-18  4:59         ` Carlos Llamas [this message]
2026-05-18  5:05         ` [PATCH v3] " Carlos Llamas
2026-05-18  5:31           ` sashiko-bot
2026-05-18 17:36           ` Andrii Nakryiko
2026-05-22 18:35             ` Andrii Nakryiko
2026-05-22 18:50               ` Carlos Llamas
2026-05-23 16:27             ` [PATCH v4] " Carlos Llamas
2026-05-23 16:51               ` sashiko-bot
2026-05-23 17:05               ` bot+bpf-ci
2026-05-28 21:31               ` Andrii Nakryiko

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=agqcnt81eI16gOYr@google.com \
    --to=cmllamas@google.com \
    --cc=andrii.nakryiko@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kernel-team@android.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=memxor@gmail.com \
    --cc=mykyta.yatsenko5@gmail.com \
    --cc=song@kernel.org \
    --cc=yatsenko@meta.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 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.