ipv6: Initialize the struct rt6_info behind the dst_enty field
Subsystems (4)
Steffen Klassert
maintainerPATCH 1/2 ipv6: Initialize the struct rt6_info behind the dst_enty field
We start initializing the struct rt6_info at the first field behind the struct dst_enty. This is error prone because it might leave a new field uninitialized. So start initializing the struct rt6_info right behind the dst_entry.
--- net/ipv6/route.c | 11 ++++++----- 1 files changed, 6 insertions(+), 5 deletions(-)
net/ipv6/route.c +6 -5
@@ -273,8 +273,9 @@ static inline struct rt6_info *ip6_dst_alloc(struct net *net, 0, 0, flags);if (rt) { -memset (&rt->n,0 , -sizeof (*rt) -sizeof (struct dst_entry )); +struct dst_entry *dst = (struct dst_entry *)rt; + +memset (dst +1 ,0 ,sizeof (*rt) -sizeof (*dst));rt6_init_peer (rt, table ? &table->tb6_peers : net->ipv6.peers); }return rt;
@@ -975,10 +976,10 @@ struct dst_entry *ip6_blackhole_route(struct net *net, struct dst_entry *dst_ori rt =dst_alloc (&ip6_dst_blackhole_ops, ort->dst.dev,1 ,0 ,0 );if (rt) { -memset (&rt->rt6i_table,0 ,sizeof (*rt) -sizeof (struct dst_entry )); -rt6_init_peer (rt, net->ipv6.peers); + new = (struct dst_entry *)rt; - new = &rt->dst; +memset (new +1 ,0 ,sizeof (*rt) -sizeof (*new)); +rt6_init_peer (rt, net->ipv6.peers); new->__use =1 ; new->input = dst_discard;
Signature · 1 line
1.7.0.4
Steffen Klassert
maintainerPATCH 2/2 xfrm: Initialize the struct xfrm_dst behind the dst_enty field
We start initializing the struct xfrm_dst at the first field behind the struct dst_enty. This is error prone because it might leave a new field uninitialized. So start initializing the struct xfrm_dst right behind the dst_entry.
--- net/xfrm/xfrm_policy.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)
net/xfrm/xfrm_policy.c +3 -2
@@ -1353,8 +1353,9 @@ static inline struct xfrm_dst *xfrm_alloc_dst(struct net *net, int family) xdst =dst_alloc (dst_ops,NULL ,0 ,0 ,0 );if (likely (xdst)) { -memset (&xdst->u.rt6.rt6i_table,0 , -sizeof (*xdst) -sizeof (struct dst_entry )); +struct dst_entry *dst = (struct dst_entry *)xdst; + +memset (dst +1 ,0 ,sizeof (*xdst) -sizeof (*dst)); xdst->flo.ops = &xfrm_bundle_fc_ops; }else xdst =ERR_PTR (-ENOBUFS );
Signature · 1 line
1.7.0.4
David Miller
maintainerFrom: Steffen Klassert <[email protected]>
Date: Fri, 6 Jul 2012 11:37:09 +0200
net/ipv6/route.c struct dst_entry *ip6_blackhole_route(struct net *net, struct dst_entry *dst_ori · line 981
Quoted 3 lines
net/ipv6/route.c +1
-1+ new = (struct dst_entry *)rt; - new = &rt->dst;
Please do not fight the typing system, the existing "net = &rt->dst;" assignment is the correct way to do this.
The same issue should be fixed in patch #2 as well.
Thank you.