ipv6: Initialize the neighbour pointer of rt6_info on allocation
Subsystems (3)
PATCH 1/1 ipv6: Initialize the neighbour pointer of rt6_info on allocation
git commit 97cac082 (ipv6: Store route neighbour in rt6_info struct) added a neighbour pointer to rt6_info. Currently we don't initialize this pointer at allocation time. We assume this pointer to be valid if it is not a null pointer, so initialize it on allocation.
--- net/ipv6/route.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
net/ipv6/route.c +1 -1
@@ -273,7 +273,7 @@ static inline struct rt6_info *ip6_dst_alloc(struct net *net, 0, 0, flags);if (rt) { -memset (&rt->rt6i_table,0 , +memset (&rt->n,0 ,sizeof (*rt) -sizeof (struct dst_entry ));rt6_init_peer (rt, table ? &table->tb6_peers : net->ipv6.peers); }
Signature · 1 line
1.7.0.4
Quoted 15 lines · Steffen Klassert
git commit
97cac082(ipv6: Store route neighbour inrt6_infostruct) added a neighbour pointer tort6_info. Currently we don't initialize this pointer at allocation time. We assume this pointer to be valid if it is not a null pointer, so initialize it on allocation.Signed-off-by Steffen Klassert <[email protected]>--- net/ipv6/route.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)net/ipv6/route.c +0
-0
net/ipv6/route.c static inline struct rt6_info *ip6_dst_alloc(struct net *net, · line 279
Quoted 8 lines
net/ipv6/route.c +1
-1@@ -273,7 +273,7 @@ static inline struct rt6_info *ip6_dst_alloc(struct net *net, 0, 0, flags);if (rt) { -memset (&rt->rt6i_table,0 , +memset (&rt->n,0 ,sizeof (*rt) -sizeof (struct dst_entry ));rt6_init_peer (rt, table ? &table->tb6_peers : net->ipv6.peers); }
Hmm, could we find a way to avoid this for future changes ?
We know dst_entry is the first field, so maybe :
if (rt) {
struct dst_entry *dst = (struct dst_entry *)rt;
memset(dst + 1, 0, sizeof(*rt) - sizeof(*dst));From: Steffen Klassert <[email protected]>
Date: Thu, 5 Jul 2012 15:18:28 +0200
Quoted 6 lines
git commit
97cac082(ipv6: Store route neighbour inrt6_infostruct) added a neighbour pointer tort6_info. Currently we don't initialize this pointer at allocation time. We assume this pointer to be valid if it is not a null pointer, so initialize it on allocation.Signed-off-by Steffen Klassert <[email protected]>
Applied, but as Eric said we need to find a way to avoid having to make changes like this every time we simply want to add a struct member to rt6_info.
Quoted 11 lines · Eric Dumazet
net/ipv6/route.c static inline struct rt6_info *ip6_dst_alloc(struct net *net, · line 279
Quoted 7 lines · Steffen Klassert
net/ipv6/route.c +1
-1if (rt) { -memset (&rt->rt6i_table,0 , +memset (&rt->n,0 ,sizeof (*rt) -sizeof (struct dst_entry ));rt6_init_peer (rt, table ? &table->tb6_peers : net->ipv6.peers); }Hmm, could we find a way to avoid this for future changes ?
Quoted 7 lines
We know
dst_entryis the first field, so maybe :if (rt) { struct dst_entry *dst = (struct dst_entry *)rt; memset(dst + 1, 0, sizeof(*rt) - sizeof(*dst));
Yes, I think we need to do something like this.
I've just noticed that ip6_blackhole_route, xfrm_alloc_dst, dn_route_output_slow and dn_route_input_slow have the same issue.
Quoted 9 lines · Steffen Klassert
Quoted 8 lines · Eric Dumazet
Hmm, could we find a way to avoid this for future changes ?
We know
dst_entryis the first field, so maybe :if (rt) { struct dst_entry *dst = (struct dst_entry *)rt;
Quoted 7 lines
Quoted 2 lines
memset(dst + 1, 0, sizeof(*rt) - sizeof(*dst));Yes, I think we need to do something like this.
I've just noticed that
ip6_blackhole_route,xfrm_alloc_dst,dn_route_output_slowanddn_route_input_slowhave the same issue.
Actually, decnet is ok. So I'll send patches with the change you suggested for ipv6 and xfrm.