BPF Archive mirror
 help / color / mirror / Atom feed
From: Kunwu Chan <kunwu.chan@hotmail.com>
To: Daniel Borkmann <daniel@iogearbox.net>,
	ast@kernel.org, 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@google.com,
	haoluo@google.com, jolsa@kernel.org, mykolal@fb.com,
	shuah@kernel.org, kunwu.chan@hotmail.com
Cc: bpf@vger.kernel.org, linux-kselftest@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH bpf-next 4/4] selftests/bpf: Add a null pointer check for the serial_test_tp_attach_query
Date: Fri, 10 May 2024 16:21:04 +0800	[thread overview]
Message-ID: <CY8PR11MB777932FEDD8F24325A236B8197E72@CY8PR11MB7779.namprd11.prod.outlook.com> (raw)
In-Reply-To: <79df3541-5557-05fa-a81e-84728d509bfc@iogearbox.net>

Thanks all for your reply.

On 2024/5/3 23:47, Daniel Borkmann wrote:
> On 4/24/24 4:04 AM, Kunwu Chan wrote:
>> There is a 'malloc' call, which can be unsuccessful.
>> Add the malloc failure checking to avoid possible null
>> dereference.
>>
>> Signed-off-by: Kunwu Chan <chentao@kylinos.cn>
>> ---
>>   tools/testing/selftests/bpf/prog_tests/tp_attach_query.c | 3 +++
>>   1 file changed, 3 insertions(+)
>>
>> diff --git a/tools/testing/selftests/bpf/prog_tests/tp_attach_query.c 
>> b/tools/testing/selftests/bpf/prog_tests/tp_attach_query.c
>> index 655d69f0ff0b..302b25408a53 100644
>> --- a/tools/testing/selftests/bpf/prog_tests/tp_attach_query.c
>> +++ b/tools/testing/selftests/bpf/prog_tests/tp_attach_query.c
>> @@ -39,6 +39,9 @@ void serial_test_tp_attach_query(void)
>>       attr.wakeup_events = 1;
>>         query = malloc(sizeof(*query) + sizeof(__u32) * num_progs);
>> +    if (CHECK(!query, "malloc()", "error:%s\n", strerror(errno)))
>
> Series looks reasonable, small nit on CHECK() : Lets use ASSERT*() 
> macros given they are
> preferred over the latter :
>
> if (!ASSERT_OK_PTR(buf, "malloc"))

Thanks, I'll update it in v2:

1: Use ASSERT_OK_PTR instead of CHECK

2: Add a suggested-by tag for you

>
>> +        return;
>> +
>>       for (i = 0; i < num_progs; i++) {
>>           err = bpf_prog_test_load(file, BPF_PROG_TYPE_TRACEPOINT, 
>> &obj[i],
>>                       &prog_fd[i]);
>>
>

      parent reply	other threads:[~2024-05-10  8:21 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-24  2:04 [PATCH bpf-next 0/4] Add some 'malloc' failure checks Kunwu Chan
2024-04-24  2:04 ` [PATCH bpf-next 1/4] selftests/bpf: Add some null pointer checks Kunwu Chan
2024-04-24  9:35   ` Markus Elfring
2024-04-24  2:04 ` [PATCH bpf-next 2/4] selftests/bpf/sockopt: Add a null pointer check for the run_test Kunwu Chan
2024-04-24 10:21   ` Markus Elfring
2024-04-24  2:04 ` [PATCH bpf-next 3/4] selftests/bpf: Add a null pointer check for the load_btf_spec Kunwu Chan
2024-04-24 10:40   ` Markus Elfring
2024-04-24  2:04 ` [PATCH bpf-next 4/4] selftests/bpf: Add a null pointer check for the serial_test_tp_attach_query Kunwu Chan
2024-04-24 10:48   ` Markus Elfring
2024-05-03 15:47   ` Daniel Borkmann
2024-05-03 15:51     ` Daniel Borkmann
2024-05-10  8:21     ` Kunwu Chan [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=CY8PR11MB777932FEDD8F24325A236B8197E72@CY8PR11MB7779.namprd11.prod.outlook.com \
    --to=kunwu.chan@hotmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --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=linux-kselftest@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=mykolal@fb.com \
    --cc=sdf@google.com \
    --cc=shuah@kernel.org \
    --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 read-only IMAP folder(s) and NNTP newsgroup(s).