Skip to content

Commit 5eb119d

Browse files
Florian Westphalummakynes
authored andcommitted
netfilter: conntrack: fix ipv6 exthdr error check
smatch warnings: net/netfilter/nf_conntrack_proto.c:167 nf_confirm() warn: unsigned 'protoff' is never less than zero. We need to check if ipv6_skip_exthdr() returned an error, but protoff is unsigned. Use a signed integer for this. Fixes: a70e483 ("netfilter: conntrack: merge ipv4+ipv6 confirm functions") Reported-by: kernel test robot <[email protected]> Signed-off-by: Florian Westphal <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent 19e72b0 commit 5eb119d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

net/netfilter/nf_conntrack_proto.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ unsigned int nf_confirm(void *priv,
141141
struct nf_conn *ct;
142142
bool seqadj_needed;
143143
__be16 frag_off;
144+
int start;
144145
u8 pnum;
145146

146147
ct = nf_ct_get(skb, &ctinfo);
@@ -163,9 +164,11 @@ unsigned int nf_confirm(void *priv,
163164
break;
164165
case NFPROTO_IPV6:
165166
pnum = ipv6_hdr(skb)->nexthdr;
166-
protoff = ipv6_skip_exthdr(skb, sizeof(struct ipv6hdr), &pnum, &frag_off);
167-
if (protoff < 0 || (frag_off & htons(~0x7)) != 0)
167+
start = ipv6_skip_exthdr(skb, sizeof(struct ipv6hdr), &pnum, &frag_off);
168+
if (start < 0 || (frag_off & htons(~0x7)) != 0)
168169
return nf_conntrack_confirm(skb);
170+
171+
protoff = start;
169172
break;
170173
default:
171174
return nf_conntrack_confirm(skb);

0 commit comments

Comments
 (0)