public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
From: Kui-Feng Lee <sinquersw@gmail.com>
To: Dan Carpenter <dan.carpenter@linaro.org>, thinker.li@gmail.com
Cc: bpf@vger.kernel.org
Subject: Re: [bug report] selftests/bpf: Verify that the cgroup_skb filters receive expected packets.
Date: Thu, 3 Aug 2023 13:43:33 -0700	[thread overview]
Message-ID: <eb2997ef-0fd4-a564-d166-9459b017e10c@gmail.com> (raw)
In-Reply-To: <8820810d-572f-1e63-0b58-a496fe49b4f1@gmail.com>



On 8/3/23 12:52, Kui-Feng Lee wrote:
> 
> 
> On 7/31/23 00:27, Dan Carpenter wrote:
>> Hello Kui-Feng Lee,
>>
>> The patch 539c7e67aa4a: "selftests/bpf: Verify that the cgroup_skb
>> filters receive expected packets." from Jun 23, 2023 (linux-next),
>> leads to the following Smatch static checker warning:
>>
>>     ./tools/testing/selftests/bpf/prog_tests/cgroup_tcp_skb.c:116 
>> connect_client_server_v6()
>>     warn: unsigned 'addr.sin6_port' is never less than zero.
>>
>> ./tools/testing/selftests/bpf/prog_tests/cgroup_tcp_skb.c
>>      107 static int connect_client_server_v6(int client_fd, int 
>> listen_fd)
>>      108 {
>>      109         struct sockaddr_in6 addr = {
>>      110                 .sin6_family = AF_INET6,
>>      111                 .sin6_addr = IN6ADDR_LOOPBACK_INIT,
>>      112         };
>>      113         int err;
>>      114
>>      115         addr.sin6_port = htons(get_sock_port_v6(listen_fd));
>> --> 116         if (addr.sin6_port < 0)
>>                      ^^^^^^^^^^^^^^^^^^
>> Impossible and also it doesn't make sense to compare network endian data
>> with < 0.
> 
> Hi Dan,
> 
> Thank you for pointing it out. It should check the returned value
> of get_sock_port_v6() before calling htons(). I will send a patch
> to fix it asap.

Could you show me how to run Smatch againt bpf selftests?

> 
> 
>>
>>      117                 return -1;
>>      118
>>      119         err = connect(client_fd, (struct sockaddr *)&addr, 
>> sizeof(addr));
>>      120         if (err < 0) {
>>      121                 perror("connect");
>>      122                 return -1;
>>      123         }
>>      124
>>      125         return 0;
>>      126 }
>>
>> regards,
>> dan carpenter
>>

  reply	other threads:[~2023-08-03 20:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-31  7:27 [bug report] selftests/bpf: Verify that the cgroup_skb filters receive expected packets Dan Carpenter
2023-08-03 19:52 ` Kui-Feng Lee
2023-08-03 20:43   ` Kui-Feng Lee [this message]
2023-08-04  5:13     ` Dan Carpenter
2023-08-04 17:32       ` Kui-Feng Lee

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=eb2997ef-0fd4-a564-d166-9459b017e10c@gmail.com \
    --to=sinquersw@gmail.com \
    --cc=bpf@vger.kernel.org \
    --cc=dan.carpenter@linaro.org \
    --cc=thinker.li@gmail.com \
    /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