Re: [PATCH 6.6 046/139] selftests/net: fix uninitialized variables

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 8/30/24 4:06 AM, Greg Kroah-Hartman wrote:
On Thu, Jul 11, 2024 at 04:31:45PM +0100, Ignat Korchagin wrote:
Hi,
On 9 Jul 2024, at 12:09, Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> wrote:

6.6-stable review patch.  If anyone has any objections, please let me know.

------------------

From: John Hubbard <jhubbard@xxxxxxxxxx>

[ Upstream commit eb709b5f6536636dfb87b85ded0b2af9bb6cd9e6 ]

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.

Signed-off-by: John Hubbard <jhubbard@xxxxxxxxxx>
Reviewed-by: Willem de Bruijn <willemb@xxxxxxxxxx>
Acked-by: Mat Martineau <martineau@xxxxxxxxxx>
Link: https://lore.kernel.org/r/20240506190204.28497-1-jhubbard@xxxxxxxxxx
Signed-off-by: Jakub Kicinski <kuba@xxxxxxxxxx>
Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>
---
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 30024d0ed3739..b204df4f33322 100644
--- a/tools/testing/selftests/net/gro.c
+++ b/tools/testing/selftests/net/gro.c
@@ -113,6 +113,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;
+

This breaks selftest compilation on 6.6, because opt_ipproto_off is not
defined in the first place in 6.6

So should it be reverted or fixed up?

It should be fixed up. And that's what we already did, last month:

https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=6b05ad408f09a1b30dc279d35b1cd238361dc856


thanks,
--
John Hubbard
NVIDIA


Can you send a patch doing either one of these?

thanks,

greg k-h





[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux