Skip to contentSkip to conversation

ipv4: Use return value of inet_iif() for __raw_v4_lookup in the while loop

PATCH In review Stephen Suryaputra 4 participants 4 messages Jun 25, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ipv4: Use return value of inet_iif() for __raw_v4_lookup in the while loop

In commit 19e4e768064a8 ("ipv4: Fix raw socket lookup for local traffic"), the dif argument to __raw_v4_lookup() is coming from the returned value of inet_iif() but the change was done only for the first lookup. Subsequent lookups in the while loop still use skb->dev->ifIndex.

---
 net/ipv4/raw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/raw.c +1 -1
index 0b8e06ca75d6..40a6abbc9cf6 100644
@@ -197,7 +197,7 @@ static int raw_v4_input(struct sk_buff *skb, const struct iphdr *iph, int hash)
 		}
 		sk = __raw_v4_lookup(net, sk_next(sk), iph->protocol,
 				     iph->saddr, iph->daddr,
-				     skb->dev->ifindex, sdif);
+				     dif, sdif);
 	}
 out:
 	read_unlock(&raw_v4_hashinfo.lock);
Signature · 1 line
2.17.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 16 lines · Stephen Suryaputra

In commit 19e4e768064a8 ("ipv4: Fix raw socket lookup for local traffic"), the dif argument to __raw_v4_lookup() is coming from the returned value of inet_iif() but the change was done only for the first lookup. Subsequent lookups in the while loop still use skb->dev->ifIndex.

---
 net/ipv4/raw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/raw.c +0 -0
index 0b8e06ca75d6..40a6abbc9cf6 100644

net/ipv4/raw.c static int raw_v4_input(struct sk_buff *skb, const struct iphdr *iph, int hash) · line 203

Quoted 8 lines
net/ipv4/raw.c +1 -1
@@ -197,7 +197,7 @@ static int raw_v4_input(struct sk_buff *skb, const struct iphdr *iph, int hash)
 		}
 		sk = __raw_v4_lookup(net, sk_next(sk), iph->protocol,
 				     iph->saddr, iph->daddr,
-				     skb->dev->ifindex, sdif);
+				     dif, sdif);
 	}
 out:
 	read_unlock(&raw_v4_hashinfo.lock);

ugh, missed that in 19e4e768064a8; thanks for the patch.

maintainer
#2 lore raw
In reply to Stephen Suryaputra

From: Stephen Suryaputra <[email protected]>
Date: Mon, 24 Jun 2019 20:14:06 -0400

Quoted 6 lines

In commit 19e4e768064a8 ("ipv4: Fix raw socket lookup for local traffic"), the dif argument to __raw_v4_lookup() is coming from the returned value of inet_iif() but the change was done only for the first lookup. Subsequent lookups in the while loop still use skb->dev->ifIndex.

Applied and queued up for -stable.

I added the appropriate Fixes: tag, please do so next time.

#3 lore raw
Quoted 8 lines · On Tue, 25 Jun 2019 12:47:38 -0700 (PDT) David Miller <[email protected]>…

From: Stephen Suryaputra <[email protected]>
Date: Mon, 24 Jun 2019 20:14:06 -0400

Quoted 5 lines

In commit 19e4e768064a8 ("ipv4: Fix raw socket lookup for local traffic"), the dif argument to __raw_v4_lookup() is coming from the returned value of inet_iif() but the change was done only for the first lookup. Subsequent lookups in the while loop still use skb->dev->ifIndex.

Quoted 5 lines
Quoted 1 line

Applied and queued up for -stable.

I added the appropriate Fixes: tag, please do so next time.

I was about to point that out, but then I noticed that this doesn't actually fix 19e4e768064a8 ("ipv4: Fix raw socket lookup for local traffic"), it's just related as it fixes the same issue in another (very likely) path in the same function.

I think this should have been:

	Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")

I *guess* for -stable purposes the effect is the same.

Signature · 1 line
Stefano