netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tao Chen <chen.dylane@linux.dev>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>, Chris Mason <clm@meta.com>
Cc: qmo@kernel.org, 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, davem@davemloft.net,
	kuba@kernel.org, hawk@kernel.org, linux-kernel@vger.kernel.org,
	bpf@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH bpf-next v4 1/3] bpftool: Add bpf_token show
Date: Tue, 16 Sep 2025 10:16:42 +0800	[thread overview]
Message-ID: <af23d217-4053-4a42-8f70-4e214f9623bf@linux.dev> (raw)
In-Reply-To: <CAEf4BzYDgkEwVo3T_jW2QtjXxCxYPxPMC-+46C12Us+9F2bOFg@mail.gmail.com>

在 2025/9/16 00:21, Andrii Nakryiko 写道:

Hi Andrii, Chris,

> On Sat, Sep 13, 2025 at 10:18 AM Chris Mason <clm@meta.com> wrote:
>>
>> On Wed, 23 Jul 2025 22:44:40 +0800 Tao Chen <chen.dylane@linux.dev> wrote:
>>
>> [ ... ]
>>
>>> diff --git a/tools/bpf/bpftool/token.c b/tools/bpf/bpftool/token.c
>>> new file mode 100644
>>> index 00000000000..6312e662a12
>>> --- /dev/null
>>> +++ b/tools/bpf/bpftool/token.c
>>> @@ -0,0 +1,225 @@
>>
>> [ ... ]
>>
>>> +
>>> +static char *get_delegate_value(const char *opts, const char *key)
>>> +{
>>> +     char *token, *rest, *ret = NULL;
>>> +     char *opts_copy = strdup(opts);
>>> +
>>> +     if (!opts_copy)
>>> +             return NULL;
>>> +
>>> +     for (token = strtok_r(opts_copy, ",", &rest); token;
>>> +                     token = strtok_r(NULL, ",", &rest)) {
>>> +             if (strncmp(token, key, strlen(key)) == 0 &&
>>> +                 token[strlen(key)] == '=') {
>>> +                     ret = token + strlen(key) + 1;
>>> +                     break;
>>> +             }
>>> +     }
>>> +     free(opts_copy);
>>> +
>>> +     return ret;
>>
>> The ret pointer is pointing inside opts_copy, but opts_copy gets freed
>> before returning?
> 
> Thanks for the bug report, Chris!
> 
> Tao, the fix probably should be something along the lines of:
> 
> ret = token + strlen(key) + 1 - opts_copy + opts;
> 
> to translate that pointer back into the original string? Can you
> please send a patch?
> 

Of course, i will fix it, thanks for the bug report.

>>
>> -chris
-- 
Best Regards
Tao Chen

      reply	other threads:[~2025-09-16  2:16 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-23 14:44 [PATCH bpf-next v4 1/3] bpftool: Add bpf_token show Tao Chen
2025-07-23 14:44 ` [PATCH bpf-next v4 2/3] bpftool: Add bpftool-token manpage Tao Chen
2025-07-23 14:44 ` [PATCH bpf-next v4 3/3] bpftool: Add bash completion for token argument Tao Chen
2025-07-28 15:25 ` [PATCH bpf-next v4 1/3] bpftool: Add bpf_token show Tao Chen
2025-07-29  2:34   ` Alexei Starovoitov
2025-08-02  1:15 ` patchwork-bot+netdevbpf
     [not found] ` <20250913162643.879707-1-clm@meta.com>
2025-09-15 16:21   ` Andrii Nakryiko
2025-09-16  2:16     ` Tao Chen [this message]

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=af23d217-4053-4a42-8f70-4e214f9623bf@linux.dev \
    --to=chen.dylane@linux.dev \
    --cc=andrii.nakryiko@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=clm@meta.com \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=eddyz87@gmail.com \
    --cc=haoluo@google.com \
    --cc=hawk@kernel.org \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=netdev@vger.kernel.org \
    --cc=qmo@kernel.org \
    --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;
as well as URLs for NNTP newsgroup(s).