sfc: fix uninitialized variable use
Subsystems (3)
PATCH 1/2 sfc: fix uninitialized variable use
From: Arnd Bergmann <[email protected]>
The new efx_bind_neigh() function contains a broken code path when IPV6 is disabled:
drivers/net/ethernet/sfc/tc_encap_actions.c:144:7: error: variable 'n' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized]
if (encap->type & EFX_ENCAP_FLAG_IPV6) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/sfc/tc_encap_actions.c:184:8: note: uninitialized use occurs here
if (!n) {
^
drivers/net/ethernet/sfc/tc_encap_actions.c:144:3: note: remove the 'if' if its condition is always false
if (encap->type & EFX_ENCAP_FLAG_IPV6) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/sfc/tc_encap_actions.c:141:22: note: initialize the variable 'n' to silence this warning
struct neighbour *n;
^
= NULLChange it to use the existing error handling path here.
--- drivers/net/ethernet/sfc/tc_encap_actions.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/sfc/tc_encap_actions.c +1 -0
@@ -163,6 +163,7 @@ static int efx_bind_neigh(struct efx_nic *efx,* enabled how did someone create an IPv6 tunnel_key? */ rc = -EOPNOTSUPP ; + n =NULL ;NL_SET_ERR_MSG_MOD (extack,"No IPv6 support (neigh bind)" );#endif }else {
Signature · 1 line
2.39.2
PATCH 2/2 sfc: add CONFIG_INET dependency for TC offload
From: Arnd Bergmann <[email protected]>
The driver now fails to link when CONFIG_INET is disabled, so add an explicit Kconfig dependency:
ld.lld: error: undefined symbol: ip_route_output_flow
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
referenced by
tc_encap_actions.c
drivers/net/ethernet/sfc/tc_encap_actions.o:(efx_tc_flower_create_encap_md) in archive vmlinux.a
ld.lld: error: undefined symbol: ip_send_check
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
referenced by
tc_encap_actions.c
drivers/net/ethernet/sfc/tc_encap_actions.o:(efx_gen_encap_header) in archive vmlinux.a
referenced bytc_encap_actions.c
drivers/net/ethernet/sfc/tc_encap_actions.o:(efx_gen_encap_header) in archive vmlinux.a
ld.lld: error: undefined symbol: arp_tbl
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
referenced by
tc_encap_actions.c
drivers/net/ethernet/sfc/tc_encap_actions.o:(efx_tc_netevent_event) in archive vmlinux.a
referenced bytc_encap_actions.c
drivers/net/ethernet/sfc/tc_encap_actions.o:(efx_tc_netevent_event) in archive vmlinux.a
--- drivers/net/ethernet/sfc/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/sfc/Kconfig +1 -0
@@ -50,6 +50,7 @@ config SFC_MCDI_MON config SFC_SRIOV bool "Solarflare SFC9100-family SR-IOV support" depends on SFC && PCI_IOV + depends on INET default y help This enables support for the Single Root I/O Virtualization
Signature · 1 line
2.39.2
Quoted 19 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
The new
efx_bind_neigh()function contains a broken code path when IPV6 is disabled:
drivers/net/ethernet/sfc/tc_encap_actions.c:144:7: error: variable 'n' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized]if (encap->type & EFX_ENCAP_FLAG_IPV6) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/net/ethernet/sfc/tc_encap_actions.c:184:8: note: uninitialized use occurs here if (!n) { ^ drivers/net/ethernet/sfc/tc_encap_actions.c:144:3: note: remove the 'if' if its condition is always false if (encap->type & EFX_ENCAP_FLAG_IPV6) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/net/ethernet/sfc/tc_encap_actions.c:141:22: note: initialize the variable 'n' to silence this warning struct neighbour *n; ^ = NULL
Quoted 4 lines
Change it to use the existing error handling path here.
Fixes 7e5e7d800011a ("sfc: neighbour lookup for TC encap action offload")Signed-off-by Arnd Bergmann <[email protected]>
Re: [PATCH 2/2] sfc: add CONFIG_INET dependency for TC offload
In reply to Arnd BergmannQuoted 15 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
The driver now fails to link when
CONFIG_INETis disabled, so add an explicitKconfigdependency:ld.lld: error: undefined symbol:
ip_route_output_flowQuoted 2 lines
Quoted 2 lines
Quoted 2 lines
referenced by
tc_encap_actions.c
drivers/net/ethernet/sfc/tc_encap_actions.o:(efx_tc_flower_create_encap_md) in archive vmlinux.ald.lld: error: undefined symbol:
ip_send_checkQuoted 4 lines
Quoted 4 lines
Quoted 4 lines
referenced by
tc_encap_actions.c
drivers/net/ethernet/sfc/tc_encap_actions.o:(efx_gen_encap_header) in archive vmlinux.a
referenced bytc_encap_actions.c
drivers/net/ethernet/sfc/tc_encap_actions.o:(efx_gen_encap_header) in archive vmlinux.a
Quoted 8 lines
ld.lld: error: undefined symbol:
arp_tblQuoted 4 lines
Quoted 4 lines
Quoted 4 lines
referenced by
tc_encap_actions.c
drivers/net/ethernet/sfc/tc_encap_actions.o:(efx_tc_netevent_event) in archive vmlinux.a
referenced bytc_encap_actions.c
drivers/net/ethernet/sfc/tc_encap_actions.o:(efx_tc_netevent_event) in archive vmlinux.aFixes a1e82162af0b8 ("sfc: generate encap headers for TC offload")Signed-off-by Arnd Bergmann <[email protected]>
Edward Cree
maintainerQuoted 33 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
The new
efx_bind_neigh()function contains a broken code path when IPV6 is disabled:
drivers/net/ethernet/sfc/tc_encap_actions.c:144:7: error: variable 'n' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized]if (encap->type & EFX_ENCAP_FLAG_IPV6) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/net/ethernet/sfc/tc_encap_actions.c:184:8: note: uninitialized use occurs here if (!n) { ^ drivers/net/ethernet/sfc/tc_encap_actions.c:144:3: note: remove the 'if' if its condition is always false if (encap->type & EFX_ENCAP_FLAG_IPV6) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/net/ethernet/sfc/tc_encap_actions.c:141:22: note: initialize the variable 'n' to silence this warning struct neighbour *n; ^ = NULLChange it to use the existing error handling path here.
Fixes 7e5e7d800011a ("sfc: neighbour lookup for TC encap action offload")Signed-off-by Arnd Bergmann <[email protected]>--- drivers/net/ethernet/sfc/tc_encap_actions.c | 1 + 1 file changed, 1 insertion(+)drivers/net/ethernet/sfc/tc_encap_actions.c +0
-0
drivers/net/ethernet/sfc/tc_encap_actions.c static int efx_bind_neigh(struct efx_nic *efx, · line 169
Quoted 7 lines
drivers/net/ethernet/sfc/tc_encap_actions.c +1
-0@@ -163,6 +163,7 @@ static int efx_bind_neigh(struct efx_nic *efx,* enabled how did someone create an IPv6 tunnel_key? */ rc = -EOPNOTSUPP ; + n =NULL ;NL_SET_ERR_MSG_MOD (extack,"No IPv6 support (neigh bind)" );#endif }else {
Nack. There is a bug here, as you've identified, but the right fix
is to add a 'goto out_free;' after setting the rc and extack msg.
Setting n to NULL and relying on the subsequent error path will not
only produce the wrong rc and error message, it will also attempt to drop a reference on neigh->egdev that was never taken.
-ed
Re: [PATCH 2/2] sfc: add CONFIG_INET dependency for TC offload
In reply to Arnd BergmannQuoted 15 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
The driver now fails to link when
CONFIG_INETis disabled, so add an explicitKconfigdependency:ld.lld: error: undefined symbol:
ip_route_output_flowQuoted 2 lines
Quoted 2 lines
Quoted 2 lines
referenced by
tc_encap_actions.c
drivers/net/ethernet/sfc/tc_encap_actions.o:(efx_tc_flower_create_encap_md) in archive vmlinux.ald.lld: error: undefined symbol:
ip_send_checkQuoted 4 lines
Quoted 4 lines
Quoted 4 lines
referenced by
tc_encap_actions.c
drivers/net/ethernet/sfc/tc_encap_actions.o:(efx_gen_encap_header) in archive vmlinux.a
referenced bytc_encap_actions.c
drivers/net/ethernet/sfc/tc_encap_actions.o:(efx_gen_encap_header) in archive vmlinux.a
Quoted 8 lines
ld.lld: error: undefined symbol:
arp_tblQuoted 4 lines
Quoted 4 lines
Quoted 4 lines
referenced by
tc_encap_actions.c
drivers/net/ethernet/sfc/tc_encap_actions.o:(efx_tc_netevent_event) in archive vmlinux.a
referenced bytc_encap_actions.c
drivers/net/ethernet/sfc/tc_encap_actions.o:(efx_tc_netevent_event) in archive vmlinux.aFixes a1e82162af0b8 ("sfc: generate encap headers for TC offload")Signed-off-by Arnd Bergmann <[email protected]>
and I think you also need
since that added the references to ip_route_output_flow and arp_tbl (the commit in your Fixes: added the ip_send_check reference on top of that).
You also might want to add the Closes: tag from [1], I don't know how
that works but I assume it'll make someone's regression-bot happy.
-ed
[1] https://lore.kernel.org/oe-kbuild-all/[email protected]/
Quoted 17 lines
--- drivers/net/ethernet/sfc/Kconfig | 1 + 1 file changed, 1 insertion(+)drivers/net/ethernet/sfc/Kconfig +1
-0@@ -50,6 +50,7 @@ config SFC_MCDI_MON config SFC_SRIOV bool "Solarflare SFC9100-family SR-IOV support" depends on SFC && PCI_IOV + depends on INET default y help This enables support for the Single Root I/O Virtualization
Re: [PATCH 2/2] sfc: add CONFIG_INET dependency for TC offload
Quoted 7 lines · Edward Cree
Quoted 3 lines · Arnd Bergmann
Fixes a1e82162af0b8 ("sfc: generate encap headers for TC offload")Signed-off-by Arnd Bergmann <[email protected]>Reviewed-by Edward Cree <[email protected]>and I think you also need
Quoted 8 lines
Fixes 7e5e7d800011 ("sfc: neighbour lookup for TC encap action offload")since that added the references to
ip_route_output_flowandarp_tbl(the commit in your Fixes: added theip_send_checkreference on top of that).You also might want to add the Closes: tag from [1], I don't know how
that works but I assume it'll make someone's regression-bot happy.[1] https://lore.kernel.org/oe-kbuild-all/[email protected]/
FWIW, yes, regression tracking relies on them (for now Link: and the newly introduced Closes: work; the latter came up totally independent of regression tracking). And I have no problem with being the bad guy here. :-D
But for completeness, in case anyone cares:
It's Linus that for many years already wants these links. He a while ago mentioned that in a few posts I bookmarked:
https://lore.kernel.org/all/CAHk-=wjMmSZzMJ3Xnskdg4+GGz=5p5p+GSYyFBTh0f-DgvdBWg@mail.gmail.com/
https://lore.kernel.org/all/CAHk-=wgs38ZrfPvy=nOwVkVzjpM3VFU1zobP37Fwd_h9iAD5JQ@mail.gmail.com/
https://lore.kernel.org/all/CAHk-=wjxzafG-=J8oT30s7upn4RhBs6TX-uVFZ5rME+L5_DoJA@mail.gmail.com/
But that's nothing new: Documentation/process/submitting-patches.rst explained this usage for many years already (I just made this more explicit a while a go).
Ciao, Thorsten