Skip to content

Commit 56a62e2

Browse files
arndbummakynes
authored andcommitted
netfilter: conntrack: fix NF_REPEAT handling
gcc correctly identified a theoretical uninitialized variable use: net/netfilter/nf_conntrack_core.c: In function 'nf_conntrack_in': net/netfilter/nf_conntrack_core.c:1125:14: error: 'l4proto' may be used uninitialized in this function [-Werror=maybe-uninitialized] This could only happen when we 'goto out' before looking up l4proto, and then enter the retry, implying that l3proto->get_l4proto() returned NF_REPEAT. This does not currently get returned in any code path and probably won't ever happen, but is not good to rely on. Moving the repeat handling up a little should have the same behavior as today but avoids the warning by making that case impossible to enter. [ I have mangled this original patch to remove the check for tmpl, we should inconditionally jump back to the repeat label in case we hit NF_REPEAT instead. I have also moved the comment that explains this where it belongs. --pablo ] Fixes: 08733a0 ("netfilter: handle NF_REPEAT from nf_conntrack_in()") Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
1 parent 30f5815 commit 56a62e2

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

net/netfilter/nf_conntrack_core.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,23 +1337,21 @@ nf_conntrack_in(struct net *net, u_int8_t pf, unsigned int hooknum,
13371337
NF_CT_STAT_INC_ATOMIC(net, invalid);
13381338
if (ret == -NF_DROP)
13391339
NF_CT_STAT_INC_ATOMIC(net, drop);
1340+
/* Special case: TCP tracker reports an attempt to reopen a
1341+
* closed/aborted connection. We have to go back and create a
1342+
* fresh conntrack.
1343+
*/
1344+
if (ret == -NF_REPEAT)
1345+
goto repeat;
13401346
ret = -ret;
13411347
goto out;
13421348
}
13431349

13441350
if (set_reply && !test_and_set_bit(IPS_SEEN_REPLY_BIT, &ct->status))
13451351
nf_conntrack_event_cache(IPCT_REPLY, ct);
13461352
out:
1347-
if (tmpl) {
1348-
/* Special case: TCP tracker reports an attempt to reopen a
1349-
* closed/aborted connection. We have to go back and create a
1350-
* fresh conntrack.
1351-
*/
1352-
if (ret == NF_REPEAT)
1353-
goto repeat;
1354-
else
1355-
nf_ct_put(tmpl);
1356-
}
1353+
if (tmpl)
1354+
nf_ct_put(tmpl);
13571355

13581356
return ret;
13591357
}

0 commit comments

Comments
 (0)