* [PATCH v2] selftests/net: fix uninitialized variables
@ 2024-05-06 19:02 John Hubbard
2024-05-06 19:23 ` Willem de Bruijn
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: John Hubbard @ 2024-05-06 19:02 UTC (permalink / raw)
To: Shuah Khan
Cc: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Steffen Klassert, Herbert Xu, Andreas Färber,
Manivannan Sadhasivam, Matthieu Baerts, Mat Martineau,
Geliang Tang, Pravin B Shelar, Willem de Bruijn,
Alexander Mikhalitsyn, zhujun2, Petr Machata, Ido Schimmel,
Hangbin Liu, Nikolay Aleksandrov, Benjamin Poirier,
Sebastian Andrzej Siewior, Dmitry Safonov, netdev,
linux-arm-kernel, linux-actions, mptcp, dev, Valentin Obst,
linux-kselftest, LKML, llvm, John Hubbard
When building with clang, via:
make LLVM=1 -C tools/testing/selftest
...clang warns about three variables that are not initialized in all
cases:
1) The opt_ipproto_off variable is used uninitialized if "testname" is
not "ip". Willem de Bruijn pointed out that this is an actual bug, and
suggested the fix that I'm using here (thanks!).
2) The addr_len is used uninitialized, but only in the assert case,
which bails out, so this is harmless.
3) The family variable in add_listener() is only used uninitialized in
the error case (neither IPv4 nor IPv6 is specified), so it's also
harmless.
Fix by initializing each variable.
Cc: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
tools/testing/selftests/net/gro.c | 3 +++
tools/testing/selftests/net/ip_local_port_range.c | 2 +-
tools/testing/selftests/net/mptcp/pm_nl_ctl.c | 2 +-
3 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/net/gro.c b/tools/testing/selftests/net/gro.c
index 353e1e867fbb..6038b96ecee8 100644
--- a/tools/testing/selftests/net/gro.c
+++ b/tools/testing/selftests/net/gro.c
@@ -119,6 +119,9 @@ static void setup_sock_filter(int fd)
next_off = offsetof(struct ipv6hdr, nexthdr);
ipproto_off = ETH_HLEN + next_off;
+ /* Overridden later if exthdrs are used: */
+ opt_ipproto_off = ipproto_off;
+
if (strcmp(testname, "ip") == 0) {
if (proto == PF_INET)
optlen = sizeof(struct ip_timestamp);
diff --git a/tools/testing/selftests/net/ip_local_port_range.c b/tools/testing/selftests/net/ip_local_port_range.c
index 193b82745fd8..29451d2244b7 100644
--- a/tools/testing/selftests/net/ip_local_port_range.c
+++ b/tools/testing/selftests/net/ip_local_port_range.c
@@ -359,7 +359,7 @@ TEST_F(ip_local_port_range, late_bind)
struct sockaddr_in v4;
struct sockaddr_in6 v6;
} addr;
- socklen_t addr_len;
+ socklen_t addr_len = 0;
const int one = 1;
int fd, err;
__u32 range;
diff --git a/tools/testing/selftests/net/mptcp/pm_nl_ctl.c b/tools/testing/selftests/net/mptcp/pm_nl_ctl.c
index 7426a2cbd4a0..7ad5a59adff2 100644
--- a/tools/testing/selftests/net/mptcp/pm_nl_ctl.c
+++ b/tools/testing/selftests/net/mptcp/pm_nl_ctl.c
@@ -1276,7 +1276,7 @@ int add_listener(int argc, char *argv[])
struct sockaddr_storage addr;
struct sockaddr_in6 *a6;
struct sockaddr_in *a4;
- u_int16_t family;
+ u_int16_t family = AF_UNSPEC;
int enable = 1;
int sock;
int err;
base-commit: f462ae0edd3703edd6f22fe41d336369c38b884b
prerequisite-patch-id: b901ece2a5b78503e2fb5480f20e304d36a0ea27
prerequisite-patch-id: e81ae5ca6c427dde802acd4c1442c82e170c251a
--
2.45.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH v2] selftests/net: fix uninitialized variables
2024-05-06 19:02 [PATCH v2] selftests/net: fix uninitialized variables John Hubbard
@ 2024-05-06 19:23 ` Willem de Bruijn
2024-05-07 1:27 ` Mat Martineau
2024-05-08 0:30 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Willem de Bruijn @ 2024-05-06 19:23 UTC (permalink / raw)
To: John Hubbard, Shuah Khan
Cc: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Steffen Klassert, Herbert Xu, Andreas Färber,
Manivannan Sadhasivam, Matthieu Baerts, Mat Martineau,
Geliang Tang, Pravin B Shelar, Willem de Bruijn,
Alexander Mikhalitsyn, zhujun2, Petr Machata, Ido Schimmel,
Hangbin Liu, Nikolay Aleksandrov, Benjamin Poirier,
Sebastian Andrzej Siewior, Dmitry Safonov, netdev,
linux-arm-kernel, linux-actions, mptcp, dev, Valentin Obst,
linux-kselftest, LKML, llvm, John Hubbard
John Hubbard wrote:
> When building with clang, via:
>
> make LLVM=1 -C tools/testing/selftest
>
> ...clang warns about three variables that are not initialized in all
> cases:
>
> 1) The opt_ipproto_off variable is used uninitialized if "testname" is
> not "ip". Willem de Bruijn pointed out that this is an actual bug, and
> suggested the fix that I'm using here (thanks!).
>
> 2) The addr_len is used uninitialized, but only in the assert case,
> which bails out, so this is harmless.
>
> 3) The family variable in add_listener() is only used uninitialized in
> the error case (neither IPv4 nor IPv6 is specified), so it's also
> harmless.
>
> Fix by initializing each variable.
>
> Cc: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
> Signed-off-by: John Hubbard <jhubbard@nvidia.com>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] selftests/net: fix uninitialized variables
2024-05-06 19:02 [PATCH v2] selftests/net: fix uninitialized variables John Hubbard
2024-05-06 19:23 ` Willem de Bruijn
@ 2024-05-07 1:27 ` Mat Martineau
2024-05-08 0:30 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Mat Martineau @ 2024-05-07 1:27 UTC (permalink / raw)
To: John Hubbard
Cc: Shuah Khan, David S . Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Steffen Klassert, Herbert Xu, Andreas Färber,
Manivannan Sadhasivam, Matthieu Baerts, Geliang Tang,
Pravin B Shelar, Willem de Bruijn, Alexander Mikhalitsyn, zhujun2,
Petr Machata, Ido Schimmel, Hangbin Liu, Nikolay Aleksandrov,
Benjamin Poirier, Sebastian Andrzej Siewior, Dmitry Safonov,
netdev, linux-arm-kernel, linux-actions, mptcp, dev,
Valentin Obst, linux-kselftest, LKML, llvm
On Mon, 6 May 2024, John Hubbard wrote:
> When building with clang, via:
>
> make LLVM=1 -C tools/testing/selftest
>
> ...clang warns about three variables that are not initialized in all
> cases:
>
> 1) The opt_ipproto_off variable is used uninitialized if "testname" is
> not "ip". Willem de Bruijn pointed out that this is an actual bug, and
> suggested the fix that I'm using here (thanks!).
>
> 2) The addr_len is used uninitialized, but only in the assert case,
> which bails out, so this is harmless.
>
> 3) The family variable in add_listener() is only used uninitialized in
> the error case (neither IPv4 nor IPv6 is specified), so it's also
> harmless.
>
> Fix by initializing each variable.
>
> Cc: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
> Signed-off-by: John Hubbard <jhubbard@nvidia.com>
Hi John -
MPTCP change looks good to me:
Acked-by: Mat Martineau <martineau@kernel.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] selftests/net: fix uninitialized variables
2024-05-06 19:02 [PATCH v2] selftests/net: fix uninitialized variables John Hubbard
2024-05-06 19:23 ` Willem de Bruijn
2024-05-07 1:27 ` Mat Martineau
@ 2024-05-08 0:30 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-05-08 0:30 UTC (permalink / raw)
To: John Hubbard
Cc: shuah, davem, edumazet, kuba, pabeni, steffen.klassert, herbert,
afaerber, manivannan.sadhasivam, matttbe, martineau, geliang,
pshelar, willemdebruijn.kernel, alexander, zhujun2, petrm, idosch,
liuhangbin, razor, bpoirier, bigeasy, 0x7f454c46, netdev,
linux-arm-kernel, linux-actions, mptcp, dev, kernel,
linux-kselftest, linux-kernel, llvm
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Mon, 6 May 2024 12:02:04 -0700 you wrote:
> When building with clang, via:
>
> make LLVM=1 -C tools/testing/selftest
>
> ...clang warns about three variables that are not initialized in all
> cases:
>
> [...]
Here is the summary with links:
- [v2] selftests/net: fix uninitialized variables
https://git.kernel.org/netdev/net-next/c/eb709b5f6536
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-05-08 0:30 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-06 19:02 [PATCH v2] selftests/net: fix uninitialized variables John Hubbard
2024-05-06 19:23 ` Willem de Bruijn
2024-05-07 1:27 ` Mat Martineau
2024-05-08 0:30 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox