IPv6: Fix NULL dereference in ipv6_del_addr()
Subsystems (3)
PATCH 1/1 IPv6: Fix NULL dereference in ipv6_del_addr()
Quoted 1 line
From
07ed0369cca6ef51013a63664b09ef402e79af9eMon Sep 17 00:00:00 2001
From: Ville Nuorvala <[email protected]>
Date: Fri, 17 Nov 2006 14:05:45 +0200
Subject: [PATCH] IPv6: Fix NULL dereference in ipv6_del_addr()
--- net/ipv6/addrconf.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
net/ipv6/addrconf.c +2 -1
@@ -749,7 +749,8 @@ static void ipv6_del_addr(struct inet6_i rt->rt6i_flags |=RTF_EXPIRES ; } } -dst_release (&rt->u.dst); +if (rt) +dst_release (&rt->u.dst); }in6_ifa_put (ifp);
Signature · 1 line
1.4.3.5
In article <[email protected]> (at Fri, 17 Nov 2006 15:26:28 +0200), Ville Nuorvala <[email protected]> says:
net/ipv6/addrconf.c static void ipv6_del_addr(struct inet6_i · line 754
Quoted 4 lines
net/ipv6/addrconf.c +2
-1-dst_release (&rt->u.dst); +if (rt) +dst_release (&rt->u.dst); }
I disagree. This does NOT fix any bugs.
(void *)&rt->u.dst is ever equal to (void*)rt, and dst_release() checks if the argument is NULL.
--yoshfuji
Quoted 10 lines · YOSHIFUJI Hideaki
In article <[email protected]> (at Fri, 17 Nov 2006 15:26:28 +0200), Ville Nuorvala <[email protected]> says:
net/ipv6/addrconf.c static void ipv6_del_addr(struct inet6_i · line 754
Quoted 4 lines
net/ipv6/addrconf.c +2
-1-dst_release (&rt->u.dst); +if (rt) +dst_release (&rt->u.dst); }I disagree. This does NOT fix any bugs.
Quoted 2 lines
(void *)&rt->u.dst is ever equal to (void*)rt, and
dst_release()checks if the argument is NULL.
As the check is unnecessary you probably want to clean up the other places where rt is checked before &rt->u.dst is passed, as well ;-) This is done at least in addrconf.c, ndisc.c and route.c...
Seriously though, you are probably right about the pointer being equal to NULL in this case, but does the C language actually guarantee that the pointer to the structure and its first element are equal, or is it implementation dependent? I don't have my K&R here, so I can't check.
Regards,
Ville
David Miller
maintainerFrom: Ville Nuorvala <[email protected]>
Date: Fri, 17 Nov 2006 21:27:21 +0200
Quoted 14 lines
Quoted 10 lines · YOSHIFUJI Hideaki
In article <[email protected]> (at Fri, 17 Nov 2006 15:26:28 +0200), Ville Nuorvala <[email protected]> says:
net/ipv6/addrconf.c static void ipv6_del_addr(struct inet6_i · line 754
Quoted 4 lines
net/ipv6/addrconf.c +2
-1-dst_release (&rt->u.dst); +if (rt) +dst_release (&rt->u.dst); }I disagree. This does NOT fix any bugs.
Quoted 2 lines
(void *)&rt->u.dst is ever equal to (void*)rt, and
dst_release()checks if the argument is NULL.
Quoted 8 lines
As the check is unnecessary you probably want to clean up the other places where rt is checked before
&rt->u.dstis passed, as well ;-) This is done at least inaddrconf.c,ndisc.candroute.c...Seriously though, you are probably right about the pointer being equal to NULL in this case, but does the C language actually guarantee that the pointer to the structure and its first element are equal, or is it implementation dependent? I don't have my K&R here, so I can't check.
I would imagine that it does. We rely on similar struct layout semantics in other areas of the networking.
Also, in the past I've been told by GCC folks that the only way to guarentee that two objects appear together, one after another, in the .data segment is to place them into a structure :)
I don't think, therefore, that this will ever break.