netfilter: nf_flow_table_offload: Don't use offset uninitialized in flow_offload_port_{d,s}nat
Subsystems (3)
PATCH 1/1 netfilter: nf_flow_table_offload: Don't use offset uninitialized in flow_offload_port_{d,s}nat
Clang warns (trimmed the second warning for brevity):
../net/netfilter/nf_flow_table_offload.c:342:2: warning: variable 'offset' is used uninitialized whenever switch default is taken [-Wsometimes-uninitialized]
default:
^~~~~~~../net/netfilter/nf_flow_table_offload.c:346:57: note: uninitialized use occurs here
flow_offload_mangle(entry, flow_offload_l4proto(flow), offset,
^~~~~~../net/netfilter/nf_flow_table_offload.c:331:12: note: initialize the variable 'offset' to silence this warning
u32 offset;
^
= 0Match what was done in the flow_offload_ipv{4,6}_{d,s}nat functions and just return in the default case, since port would also be uninitialized.
--- net/netfilter/nf_flow_table_offload.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/netfilter/nf_flow_table_offload.c +2 -2
@@ -340,7 +340,7 @@ static void flow_offload_port_snat(struct net *net, offset =0 ;/* offsetof(struct tcphdr, dest); */ break ;default : -break ; +return ; } flow_offload_mangle(entry, flow_offload_l4proto(flow), offset,
@@ -367,7 +367,7 @@ static void flow_offload_port_dnat(struct net *net, offset =0 ;/* offsetof(struct tcphdr, dest); */ break ;default : -break ; +return ; } flow_offload_mangle(entry, flow_offload_l4proto(flow), offset,
Signature · 1 line
2.24.0
Quoted 14 lines · Nathan Chancellor
Clang warns (trimmed the second warning for brevity):
../net/netfilter/nf_flow_table_offload.c:342:2: warning: variable 'offset' is used uninitialized whenever switch default is taken [-Wsometimes-uninitialized]default: ^~~~~~~
../net/netfilter/nf_flow_table_offload.c:346:57: note: uninitialized use occurs here
flow_offload_mangle(entry,flow_offload_l4proto(flow), offset,
^~~~~~../net/netfilter/nf_flow_table_offload.c:331:12: note: initialize the variable 'offset' to silence this warning
Quoted 6 lines
u32 offset; ^ = 0Match what was done in the flow_offload_ipv{4,6}_{d,s}nat functions and just return in the default case, since port would also be uninitialized.
Thanks for the patch. I have a report of this from kernelci bot, would you mind crediting it:
Looks like port is uninitialized (prior to your patch), too.
These two functions look identical except for the mask. The maintainers should consider reusing more code between them and passing in the mask.
Quoted 37 lines
Fixes c29f74e0df7a ("netfilter: nf_flow_table: hardware offload support")Signed-off-by Nathan Chancellor <[email protected]>--- net/netfilter/nf_flow_table_offload.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)net/netfilter/nf_flow_table_offload.c +2
-3@@ -340,7 +340,7 @@ static void flow_offload_port_snat(struct net *net, offset =0 ;/* offsetof(struct tcphdr, dest); */ break ;default : -break ; +return ; } flow_offload_mangle(entry, flow_offload_l4proto(flow), offset,@@ -367,7 +367,7 @@ static void flow_offload_port_dnat(struct net *net, offset =0 ;/* offsetof(struct tcphdr, dest); */ break ;default : -break ; +return ; } flow_offload_mangle(entry, flow_offload_l4proto(flow), offset, --2.24.0
--
You received this message because you are subscribed to the Google Groups "Clang Built Linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/clang-built-linux/20191126201226.51857-1-natechancellor%40gmail.com.
Signature · 2 lines
Thanks, ~Nick Desaulniers
Quoted 13 lines · Nathan Chancellor
Clang warns (trimmed the second warning for brevity):
../net/netfilter/nf_flow_table_offload.c:342:2: warning: variable 'offset' is used uninitialized whenever switch default is taken [-Wsometimes-uninitialized]default: ^~~~~~~
../net/netfilter/nf_flow_table_offload.c:346:57: note: uninitialized use occurs here
flow_offload_mangle(entry,flow_offload_l4proto(flow), offset,
^~~~~~../net/netfilter/nf_flow_table_offload.c:331:12: note: initialize the variable 'offset' to silence this warning
Quoted 6 lines
u32 offset; ^ = 0Match what was done in the flow_offload_ipv{4,6}_{d,s}nat functions and just return in the default case, since port would also be uninitialized.
Applied, thanks.