All of lore.kernel.org
 help / color / mirror / Atom feed
From: Leon Hwang <leon.hwang@linux.dev>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: bpf <bpf@vger.kernel.org>, Alexei Starovoitov <ast@kernel.org>,
	Andrii Nakryiko <andrii@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>
Subject: Re: [RFC PATCH bpf-next v3 03/10] bpf: Refactor reporting log_true_size for prog_load
Date: Fri, 3 Oct 2025 10:06:53 +0800	[thread overview]
Message-ID: <69432b06-bf1c-41c7-83a4-7c8bfbd0b2a6@linux.dev> (raw)
In-Reply-To: <CAADnVQKarwu9xciE=itxxXDS+DRtdHmVxD3rftuqBU5iu9FYLA@mail.gmail.com>



On 3/10/25 02:34, Alexei Starovoitov wrote:
> On Thu, Oct 2, 2025 at 8:49 AM Leon Hwang <leon.hwang@linux.dev> wrote:
>>
>> In the next commit, it will be able to report logs via extended common
>> attributes, which will report 'log_true_size' via the extended common
>> attributes meanwhile.
>>
>> Therefore, refactor the way of 'log_true_size' reporting in order to
>> report 'log_true_size' via the extended common attributes easily.
>>

[...]

>>
>> +static int copy_prog_load_log_true_size(union bpf_attr *attr, bpfptr_t uattr, unsigned int size)
>> +{
>> +       if (!attr->log_true_size)
>> +               return 0;
> 
> We've been through this many times :(
> The commit log says that it's a refactoring patch, but
> you introduce this new logic.
> Do NOT do it.
> If you want to add such additional check, do it in a separate patch
> and explain why it's ok.
> 
> So why is it ok to skip writing to user space when it's zero?
> 

My mistake — I see now that introducing this extra check changes the
behavior and doesn't belong in a refactoring patch.

My original intention was just to avoid calling copy_to_user() when
there is no log, but as you pointed out, it's important to still report
log_true_size back to user space, even if it's zero. That way, users can
reliably check if a log is present.

I'll drop this new logic in the next revision and keep the patch
strictly as a refactoring.

Thanks,
Leon

  reply	other threads:[~2025-10-03  2:07 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-02 15:48 [RFC PATCH bpf-next v3 00/10] bpf: Extend bpf syscall with common attributes support Leon Hwang
2025-10-02 15:48 ` [RFC PATCH bpf-next v3 01/10] " Leon Hwang
2025-10-02 15:48 ` [RFC PATCH bpf-next v3 02/10] libbpf: Add support for extended bpf syscall Leon Hwang
2025-10-06 23:08   ` Andrii Nakryiko
2025-10-09  5:15     ` Leon Hwang
2025-10-02 15:48 ` [RFC PATCH bpf-next v3 03/10] bpf: Refactor reporting log_true_size for prog_load Leon Hwang
2025-10-02 18:34   ` Alexei Starovoitov
2025-10-03  2:06     ` Leon Hwang [this message]
2025-10-02 15:48 ` [RFC PATCH bpf-next v3 04/10] bpf: Add common attr support " Leon Hwang
2025-10-02 23:51   ` Alexei Starovoitov
2025-10-03  2:25     ` Leon Hwang
2025-10-02 15:48 ` [RFC PATCH bpf-next v3 05/10] bpf: Refactor reporting btf_log_true_size for btf_load Leon Hwang
2025-10-02 15:48 ` [RFC PATCH bpf-next v3 06/10] bpf: Add common attr support " Leon Hwang
2025-10-02 15:48 ` [RFC PATCH bpf-next v3 07/10] bpf: Add warnings for internal bugs in map_create Leon Hwang
2025-10-03  0:06   ` Alexei Starovoitov
2025-10-03  2:31     ` Leon Hwang
2025-10-02 15:48 ` [RFC PATCH bpf-next v3 08/10] bpf: Add common attr support for map_create Leon Hwang
2025-10-02 15:48 ` [RFC PATCH bpf-next v3 09/10] libbpf: " Leon Hwang
2025-10-06 23:08   ` Andrii Nakryiko
2025-10-09  5:35     ` Leon Hwang
2025-10-02 15:48 ` [RFC PATCH bpf-next v3 10/10] selftests/bpf: Add cases to test map create failure log Leon Hwang
2025-10-03  6:38 ` [syzbot ci] Re: bpf: Extend bpf syscall with common attributes support syzbot ci
2025-10-03  6:44   ` Leon Hwang

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=69432b06-bf1c-41c7-83a4-7c8bfbd0b2a6@linux.dev \
    --to=leon.hwang@linux.dev \
    --cc=alexei.starovoitov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    /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.