Skip to contentSkip to conversation

vxlan: Wrong type passed to %pIS

PATCH Applied Rasmus Villemoes 4 participants 7 messages Feb 7, 2015 – Feb 9, 2015

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

PATCH 1/1 vxlan: Wrong type passed to %pIS

src_ip is a pointer to a union vxlan_addr, one member of which is a struct sockaddr. Passing a pointer to src_ip is wrong; one should pass the value of src_ip itself. Since %pIS formally expects something of type struct sockaddr*, let's pass a pointer to the appropriate union member, though this of course doesn't change the generated code.

Fixes e4c7ed415387 ("vxlan: add ipv6 support")
---
 drivers/net/vxlan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/vxlan.c +1 -1
index a8c755dcab14..11defbb24183 100644
@@ -991,7 +991,7 @@ static bool vxlan_snoop(struct net_device *dev,
 		if (net_ratelimit())
 			netdev_info(dev,
 				    "%pM migrated from %pIS to %pIS\n",
-				    src_mac, &rdst->remote_ip, &src_ip);
+				    src_mac, &rdst->remote_ip.sa, &src_ip->sa);
 
 		rdst->remote_ip = *src_ip;
 		f->updated = jiffies;
Signature · 1 line
2.1.3
#1 lore raw
Quoted 5 lines · Rasmus Villemoes

src_ip is a pointer to a union vxlan_addr, one member of which is a struct sockaddr. Passing a pointer to src_ip is wrong; one should pass the value of src_ip itself. Since %pIS formally expects something of type struct sockaddr*, let's pass a pointer to the appropriate union member, though this of course doesn't change the generated code.

Hello Rasmus

Are you finding these mismatches by hand or
are you using some tool?

#3 lore raw
In reply to Rasmus Villemoes
Quoted 6 lines · Rasmus Villemoes

src_ip is a pointer to a union vxlan_addr, one member of which is a struct sockaddr. Passing a pointer to src_ip is wrong; one should pass the value of src_ip itself. Since %pIS formally expects something of type struct sockaddr*, let's pass a pointer to the appropriate union member, though this of course doesn't change the generated code.

It is a union, this doesn't harm.

Quoted 11 lines
Fixes e4c7ed415387 ("vxlan: add ipv6 support")
---
 drivers/net/vxlan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/vxlan.c +0 -0
index a8c755dcab14..11defbb24183 100644

drivers/net/vxlan.c static bool vxlan_snoop(struct net_device *dev, · line 997

Quoted 8 lines
drivers/net/vxlan.c +1 -1
@@ -991,7 +991,7 @@ static bool vxlan_snoop(struct net_device *dev,
                if (net_ratelimit())
                        netdev_info(dev,
                                    "%pM migrated from %pIS to %pIS\n",
-                                   src_mac, &rdst->remote_ip, &src_ip);
+                                   src_mac, &rdst->remote_ip.sa, &src_ip->sa);
 
                rdst->remote_ip = *src_ip;
                f->updated = jiffies;

Since you are on it, there is another similar place in vxlan too.

#4 lore raw
Quoted 10 lines · Cong Wang
Quoted 6 lines · Rasmus Villemoes

src_ip is a pointer to a union vxlan_addr, one member of which is a struct sockaddr. Passing a pointer to src_ip is wrong; one should pass the value of src_ip itself. Since %pIS formally expects something of type struct sockaddr*, let's pass a pointer to the appropriate union member, though this of course doesn't change the generated code.

Quoted 2 lines

It is a union, this doesn't harm.

Just to be clear: This fixes a real bug. The minimal fix had been

- src_mac, &rdst->remote_ip, &src_ip);
+ src_mac, &rdst->remote_ip, src_ip);

but I through in the cosmetic improvements while the line needed changing anyway.

Quoted 1 line

Since you are on it, there is another similar place in vxlan too.

... which is why I didn't change that other occurrence.

Rasmus

#2 lore raw
In reply to Joe Perches
Quoted 11 lines · Joe Perches
Quoted 5 lines · Rasmus Villemoes

src_ip is a pointer to a union vxlan_addr, one member of which is a struct sockaddr. Passing a pointer to src_ip is wrong; one should pass the value of src_ip itself. Since %pIS formally expects something of type struct sockaddr*, let's pass a pointer to the appropriate union member, though this of course doesn't change the generated code.

Hello Rasmus

Are you finding these mismatches by hand or
are you using some tool?

I've extended smatch to do format checking (mostly for the %p extensions; gcc already does all the other stuff just fine). I'll try and see if I can get it on github sometime in the coming week.

Rasmus

Acked-by
#5 lore raw
In reply to Rasmus Villemoes
Quoted 20 lines · Rasmus Villemoes
Quoted 10 lines · Cong Wang
Quoted 6 lines · Rasmus Villemoes

src_ip is a pointer to a union vxlan_addr, one member of which is a struct sockaddr. Passing a pointer to src_ip is wrong; one should pass the value of src_ip itself. Since %pIS formally expects something of type struct sockaddr*, let's pass a pointer to the appropriate union member, though this of course doesn't change the generated code.

Quoted 2 lines

It is a union, this doesn't harm.

Just to be clear: This fixes a real bug. The minimal fix had been

(quoted diff) +1 -1
-                     src_mac, &rdst->remote_ip, &src_ip);
+                     src_mac, &rdst->remote_ip, src_ip);
Quoted 3 lines

but I through in the cosmetic improvements while the line needed changing anyway.

Ah, I misread the patch.

Thanks!

maintainer Applied
#6 lore raw
In reply to Rasmus Villemoes

From: Rasmus Villemoes <[email protected]>
Date: Sat, 7 Feb 2015 03:17:31 +0100

Quoted 8 lines

src_ip is a pointer to a union vxlan_addr, one member of which is a struct sockaddr. Passing a pointer to src_ip is wrong; one should pass the value of src_ip itself. Since %pIS formally expects something of type struct sockaddr*, let's pass a pointer to the appropriate union member, though this of course doesn't change the generated code.

Fixes e4c7ed415387 ("vxlan: add ipv6 support")

Applied, thanks.