public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Quentin Monnet <qmo@kernel.org>
To: Tao Chen <chen.dylane@linux.dev>,
	ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org,
	martin.lau@linux.dev, eddyz87@gmail.com, song@kernel.org,
	yonghong.song@linux.dev, john.fastabend@gmail.com,
	kpsingh@kernel.org, sdf@fomichev.me, haoluo@google.com,
	jolsa@kernel.org
Cc: bpf@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH bpf-next v3 2/2] bpftool: Fix UAF in get_delegate_value
Date: Thu, 18 Sep 2025 21:07:58 +0100	[thread overview]
Message-ID: <226947cd-a28d-4c09-81cb-0fa0a21c7075@kernel.org> (raw)
In-Reply-To: <20250918120908.1255263-2-chen.dylane@linux.dev>

2025-09-18 20:09 UTC+0800 ~ Tao Chen <chen.dylane@linux.dev>
> The return value ret pointer is pointing opts_copy, but opts_copy
> gets freed in get_delegate_value before return, fix this by free
> the mntent->mnt_opts strdup memory after show delegate value.
> 
> Fixes: 2d812311c2b2 ("bpftool: Add bpf_token show")
> Signed-off-by: Tao Chen <chen.dylane@linux.dev>
> ---
>  tools/bpf/bpftool/token.c | 90 +++++++++++++++------------------------
>  1 file changed, 35 insertions(+), 55 deletions(-)
> 
> diff --git a/tools/bpf/bpftool/token.c b/tools/bpf/bpftool/token.c
> index 82b829e44c8..20c4c78a8a8 100644
> --- a/tools/bpf/bpftool/token.c
> +++ b/tools/bpf/bpftool/token.c


> @@ -69,38 +73,29 @@ static void print_items_per_line(const char *input, int items_per_line)
>  		printf("%-20s", str);
>  		cnt++;
>  	}
> -
> -	free(strs);
>  }
>  
>  #define ITEMS_PER_LINE 4
>  static void show_token_info_plain(struct mntent *mntent)
>  {
> -	char *value;
> +	char *opts, *value;


Thank you! I just have style nits: can you move the declaration of
"opts" and "value" inside of the for loop, please? They're not used
outside of it.


>  
>  	printf("token_info  %s", mntent->mnt_dir);
>  
> -	printf("\n\tallowed_cmds:");
> -	value = get_delegate_value(mntent->mnt_opts, "delegate_cmds");
> -	print_items_per_line(value, ITEMS_PER_LINE);
> -
> -	printf("\n\tallowed_maps:");
> -	value = get_delegate_value(mntent->mnt_opts, "delegate_maps");
> -	print_items_per_line(value, ITEMS_PER_LINE);
> -
> -	printf("\n\tallowed_progs:");
> -	value = get_delegate_value(mntent->mnt_opts, "delegate_progs");
> -	print_items_per_line(value, ITEMS_PER_LINE);
> +	for (size_t i = 0; i < ARRAY_SIZE(sets); i++) {


And could you please move the declaration of variable "i" to the top of
the function, for consistency with the rest of the code?

Same comments for the JSON function.

Thanks,
Quentin

  reply	other threads:[~2025-09-18 20:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-18 12:09 [PATCH bpf-next v3 1/2] bpftool: Add HELP_SPEC_OPTIONS in token.c Tao Chen
2025-09-18 12:09 ` [PATCH bpf-next v3 2/2] bpftool: Fix UAF in get_delegate_value Tao Chen
2025-09-18 20:07   ` Quentin Monnet [this message]
2025-09-19  2:17     ` Tao Chen
2025-09-18 20:09 ` [PATCH bpf-next v3 1/2] bpftool: Add HELP_SPEC_OPTIONS in token.c Quentin Monnet

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=226947cd-a28d-4c09-81cb-0fa0a21c7075@kernel.org \
    --to=qmo@kernel.org \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=chen.dylane@linux.dev \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=haoluo@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=sdf@fomichev.me \
    --cc=song@kernel.org \
    --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