Skip to contentSkip to conversation

netfilter: conntrack: fix an unsigned int comparison to less than zero

PATCH New Colin King 1 participant 1 message May 26, 2020

Subsystems (4)
lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH 1/1 netfilter: conntrack: fix an unsigned int comparison to less than zero

From: Colin Ian King <[email protected]>

The error check to see if protoff is less than zero is always false because it is a unsigned int. The call to ipv6_skip_exthdr can return negative values for an error so cast protoff to int to fix this check.

Addresses-Coverity: ("Macro compares unsigned to 0 (no effect)")

Fixes ee04805ff54a ("netfilter: conntrack: make conntrack userspace helpers work again")
---
 net/netfilter/nf_conntrack_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/nf_conntrack_core.c +1 -1
index 08e0c19f6b39..2933b96a90c6 100644
@@ -2114,7 +2114,7 @@ static int nf_confirm_cthelper(struct sk_buff *skb, struct nf_conn *ct,
 		pnum = ipv6_hdr(skb)->nexthdr;
 		protoff = ipv6_skip_exthdr(skb, sizeof(struct ipv6hdr), &pnum,
 					   &frag_off);
-		if (protoff < 0 || (frag_off & htons(~0x7)) != 0)
+		if ((int)protoff < 0 || (frag_off & htons(~0x7)) != 0)
 			return 0;
 		break;
 	}
Signature · 1 line
2.25.1