Skip to contentSkip to conversation

selftests/bpf: Fix incorrect parameters in NULL pointer checking

PATCH In review Hao Ge 4 participants 7 messages Aug 20, 2024 – Aug 23, 2024

Subsystems (3)
lore
Share & tools
lore

Hao Ge

author
#0 lore raw

PATCH 1/1 selftests/bpf: Fix incorrect parameters in NULL pointer checking

From: Hao Ge <[email protected]>

Smatch reported the following warning:
./tools/testing/selftests/bpf/testing_helpers.c:455 get_xlated_program()
warn: variable dereferenced before check 'buf' (see line 454)

It seems correct,so let's modify it based on it's suggestion.

Actually,commit b23ed4d74c4d ("selftests/bpf: Fix invalid pointer check in get_xlated_program()") fixed an issue in the test_verifier.c once,but it was reverted this time.

Let's solve this issue with the minimal changes possible.

Fixes b4b7a4099b8c ("selftests/bpf: Factor out get_xlated_program() helper")
---
 tools/testing/selftests/bpf/testing_helpers.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/bpf/testing_helpers.c +1 -1
index d5379a0e6da8..34dfea295c8e 100644
@@ -451,7 +451,7 @@ int get_xlated_program(int fd_prog, struct bpf_insn **buf, __u32 *cnt)
 
 	*cnt = xlated_prog_len / buf_element_size;
 	*buf = calloc(*cnt, buf_element_size);
-	if (!buf) {
+	if (!*buf) {
 		perror("can't allocate xlated program buffer");
 		return -ENOMEM;
 	}
Signature · 1 line
2.25.1
reviewer Acked-by on v1 1/1
#1 lore raw
Quoted 12 lines · Hao Ge

From: Hao Ge <[email protected]>

Smatch reported the following warning:
./tools/testing/selftests/bpf/testing_helpers.c:455 get_xlated_program()
warn: variable dereferenced before check 'buf' (see line 454)

It seems correct,so let's modify it based on it's suggestion.

Actually,commit b23ed4d74c4d ("selftests/bpf: Fix invalid pointer check in get_xlated_program()") fixed an issue in the test_verifier.c once,but it was reverted this time.

Quoted 6 lines

Let's solve this issue with the minimal changes possible.

Fixes b4b7a4099b8c ("selftests/bpf: Factor out get_xlated_program() helper")

In the future, please change subject '[PATCH] ...' to '[PATCH bpf-next] ...' so CI can properly test it.

#2 lore raw
Quoted 16 lines · Yonghong Song
Quoted 14 lines · Hao Ge

From: Hao Ge <[email protected]>

Smatch reported the following warning:
./tools/testing/selftests/bpf/testing_helpers.c:455 get_xlated_program()
warn: variable dereferenced before check 'buf' (see line 454)

It seems correct,so let's modify it based on it's suggestion.

Actually,commit b23ed4d74c4d ("selftests/bpf: Fix invalid pointer check in get_xlated_program()") fixed an issue in the test_verifier.c once,but it was reverted this time.

Let's solve this issue with the minimal changes possible.

Quoted 7 lines
Quoted 4 lines
Fixes b4b7a4099b8c ("selftests/bpf: Factor out get_xlated_program() helper")

In the future, please change subject '[PATCH] ...' to '[PATCH bpf-next] ...' so CI can properly test it.

It feels like there should be a technical solution to this. The CI system is something on AWS and it's too expensive to just check every patch that's sent to the bpf list? My understanding is that there are only two bpf trees.

	if [ "$FIXES_HASH" == "" ] ; then
		TREE=next
	elif git merge-base --is-ancestor $FIXES_HASH origin/master ; then
		TREE=linus
	else
		TREE=next
	fi

These days the zero day bot people are checking around a thousand git trees. They pull emails off the various lists and apply them to the right places. It's a doable thing.

regards,
dan carpenter

#3 lore raw
Quoted 38 lines · Dan Carpenter
Quoted 16 lines · Yonghong Song
Quoted 14 lines · Hao Ge

From: Hao Ge <[email protected]>

Smatch reported the following warning:
./tools/testing/selftests/bpf/testing_helpers.c:455 get_xlated_program()
warn: variable dereferenced before check 'buf' (see line 454)

It seems correct,so let's modify it based on it's suggestion.

Actually,commit b23ed4d74c4d ("selftests/bpf: Fix invalid pointer check in get_xlated_program()") fixed an issue in the test_verifier.c once,but it was reverted this time.

Let's solve this issue with the minimal changes possible.

Quoted 7 lines
Quoted 4 lines
Fixes b4b7a4099b8c ("selftests/bpf: Factor out get_xlated_program() helper")

In the future, please change subject '[PATCH] ...' to '[PATCH bpf-next] ...' so CI can properly test it.

It feels like there should be a technical solution to this. The CI system is something on AWS and it's too expensive to just check every patch that's sent to the bpf list? My understanding is that there are only two bpf trees.

        if [ "$FIXES_HASH" == "" ] ; then
                TREE=next
        elif git merge-base --is-ancestor $FIXES_HASH origin/master ; then
                TREE=linus
        else
                TREE=next
        fi
Quoted 3 lines

These days the zero day bot people are checking around a thousand git trees. They pull emails off the various lists and apply them to the right places. It's a doable thing.

Dan,

Various people pointed out that you need to use the proper subject in the patches.
You clearly knew that rule and yet you ignored it,
and worse still you keep coming up with these excuses. Don't be surprised that people who are supposed to review your patches will take a long time to reply or "forget" about them as you "forget" about patch submission rules.

#4 lore raw
Quoted 45 lines · Alexei Starovoitov
Quoted 38 lines · Dan Carpenter
Quoted 16 lines · Yonghong Song
Quoted 14 lines · Hao Ge

From: Hao Ge <[email protected]>

Smatch reported the following warning:
./tools/testing/selftests/bpf/testing_helpers.c:455 get_xlated_program()
warn: variable dereferenced before check 'buf' (see line 454)

It seems correct,so let's modify it based on it's suggestion.

Actually,commit b23ed4d74c4d ("selftests/bpf: Fix invalid pointer check in get_xlated_program()") fixed an issue in the test_verifier.c once,but it was reverted this time.

Let's solve this issue with the minimal changes possible.

Quoted 7 lines
Quoted 4 lines
Fixes b4b7a4099b8c ("selftests/bpf: Factor out get_xlated_program() helper")

In the future, please change subject '[PATCH] ...' to '[PATCH bpf-next] ...' so CI can properly test it.

It feels like there should be a technical solution to this. The CI system is something on AWS and it's too expensive to just check every patch that's sent to the bpf list? My understanding is that there are only two bpf trees.

        if [ "$FIXES_HASH" == "" ] ; then
                TREE=next
        elif git merge-base --is-ancestor $FIXES_HASH origin/master ; then
                TREE=linus
        else
                TREE=next
        fi
Quoted 3 lines

These days the zero day bot people are checking around a thousand git trees. They pull emails off the various lists and apply them to the right places. It's a doable thing.

Dan,

Quoted 7 lines

Various people pointed out that you need to use the proper subject in the patches.
You clearly knew that rule and yet you ignored it,
and worse still you keep coming up with these excuses. Don't be surprised that people who are supposed to review your patches will take a long time to reply or "forget" about them as you "forget" about patch submission rules.

You're emailing the wrong person. This isn't my patch. I don't send BPF patches.

regards,
dan carpenter

author
#6 lore raw
In reply to Yonghong Song

Hi Yonghong

Thank you very much for taking the time to review my patch.

Quoted 16 lines · Yonghong Song
Quoted 14 lines · Hao Ge

From: Hao Ge <[email protected]>

Smatch reported the following warning:
     ./tools/testing/selftests/bpf/testing_helpers.c:455 get_xlated_program()
     warn: variable dereferenced before check 'buf' (see line 454)

It seems correct,so let's modify it based on it's suggestion.

Actually,commit b23ed4d74c4d ("selftests/bpf: Fix invalid pointer check in get_xlated_program()") fixed an issue in the test_verifier.c once,but it was reverted this time.

Let's solve this issue with the minimal changes possible.

Quoted 8 lines
Quoted 4 lines
Fixes b4b7a4099b8c ("selftests/bpf: Factor out get_xlated_program() helper")

In the future, please change subject '[PATCH] ...' to '[PATCH bpf-next] ...' so CI can properly test it.

OK, I understand. I will follow this rule in the future.

Quoted 2 lines
author
#5 lore raw
In reply to Dan Carpenter

Hi Dan and Alexei

I apologize for any inconvenience my mistake may have caused to both of you.

Quoted 41 lines · Dan Carpenter
Quoted 40 lines · Alexei Starovoitov
Quoted 34 lines · Dan Carpenter
Quoted 13 lines · Yonghong Song
Quoted 12 lines · Hao Ge

From: Hao Ge <[email protected]>

Smatch reported the following warning:
./tools/testing/selftests/bpf/testing_helpers.c:455 get_xlated_program()
warn: variable dereferenced before check 'buf' (see line 454)

It seems correct,so let's modify it based on it's suggestion.

Actually,commit b23ed4d74c4d ("selftests/bpf: Fix invalid pointer check in get_xlated_program()") fixed an issue in the test_verifier.c once,but it was reverted this time.

Quoted 8 lines
Quoted 6 lines

Let's solve this issue with the minimal changes possible.

Fixes b4b7a4099b8c ("selftests/bpf: Factor out get_xlated_program() helper")

In the future, please change subject '[PATCH] ...' to '[PATCH bpf-next] ...' so CI can properly test it.

It feels like there should be a technical solution to this. The CI system is something on AWS and it's too expensive to just check every patch that's sent to the bpf list? My understanding is that there are only two bpf trees.

         if [ "$FIXES_HASH" == "" ] ; then
                 TREE=next
         elif git merge-base --is-ancestor $FIXES_HASH origin/master ; then
                 TREE=linus
         else
                 TREE=next
         fi
Quoted 3 lines

These days the zero day bot people are checking around a thousand git trees. They pull emails off the various lists and apply them to the right places. It's a doable thing.

Dan,

Quoted 7 lines
Quoted 7 lines

Various people pointed out that you need to use the proper subject in the patches.
You clearly knew that rule and yet you ignored it,
and worse still you keep coming up with these excuses. Don't be surprised that people who are supposed to review your patches will take a long time to reply or "forget" about them as you "forget" about patch submission rules.

Perhaps it was referring to me? Regardless, I will reflect on myself and make improvements.

Quoted 5 lines

You're emailing the wrong person. This isn't my patch. I don't send BPF patches.

regards,
dan carpenter