From: Martin KaFai Lau <martin.lau@linux.dev>
To: Prabhav Kumar Vaish <pvkumar5749404@gmail.com>
Cc: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org,
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, mykolal@fb.com,
shuah@kernel.org, bpf@vger.kernel.org,
linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] selftests/bpf: Fix null pointer check in skb_pkt_end.c
Date: Tue, 22 Apr 2025 15:15:52 -0700 [thread overview]
Message-ID: <e7ee365f-f275-4ee0-80fb-370cb3c242ea@linux.dev> (raw)
In-Reply-To: <20250422182331.1188338-1-pvkumar5749404@gmail.com>
On 4/22/25 11:23 AM, Prabhav Kumar Vaish wrote:
> Ensure that 'tcp' is checked for NULL before dereferencing. This resolves
> a potential null pointer dereference warning reported by static analysis.
>
> Signed-off-by: Prabhav Kumar Vaish <pvkumar5749404@gmail.com>
> ---
> tools/testing/selftests/bpf/progs/skb_pkt_end.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/progs/skb_pkt_end.c b/tools/testing/selftests/bpf/progs/skb_pkt_end.c
> index 3bb4451524a1..db33ff2839f7 100644
> --- a/tools/testing/selftests/bpf/progs/skb_pkt_end.c
> +++ b/tools/testing/selftests/bpf/progs/skb_pkt_end.c
> @@ -45,10 +45,10 @@ int main_prog(struct __sk_buff *skb)
> goto out;
>
> tcp = (void*)(ip + 1);
> - if (tcp->dest != 0)
> - goto out;
> if (!tcp)
This case will never be hit, so this change is not doing anything other than
silencing the static checker. Take a look at commit 9cc873e85800
("selftests/bpf: Add skb_pkt_end test"). The test was written to have a specific
llvm generated code. You will need to check the generated code is still testing
what it is supposed to test.
pw-bot: cr
> goto out;
> + if (tcp->dest != 0)
> + goto out;
>
> urg_ptr = tcp->urg_ptr;
>
next prev parent reply other threads:[~2025-04-22 22:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-22 18:23 [PATCH] selftests/bpf: Fix null pointer check in skb_pkt_end.c Prabhav Kumar Vaish
2025-04-22 22:15 ` Martin KaFai Lau [this message]
2025-04-23 17:58 ` [PATCH] selftests/bpf: Fix potential null pointer dereference " Prabhav Kumar Vaish
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=e7ee365f-f275-4ee0-80fb-370cb3c242ea@linux.dev \
--to=martin.lau@linux.dev \
--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=mykolal@fb.com \
--cc=pvkumar5749404@gmail.com \
--cc=sdf@fomichev.me \
--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