All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 1/2] ipv6: Initialize the struct rt6_info behind the dst_enty field
@ 2012-07-06  9:37 Steffen Klassert
  2012-07-06  9:39 ` [PATCH net-next 2/2] xfrm: Initialize the struct xfrm_dst " Steffen Klassert
  2012-07-06 10:57 ` [PATCH net-next 1/2] ipv6: Initialize the struct rt6_info " David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Steffen Klassert @ 2012-07-06  9:37 UTC (permalink / raw)
  To: David Miller, Eric Dumazet; +Cc: netdev

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.

Suggested-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
---
 net/ipv6/route.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 6cc6c88..1d8459b 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -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;
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH net-next 2/2] xfrm: Initialize the struct xfrm_dst behind the dst_enty field
  2012-07-06  9:37 [PATCH net-next 1/2] ipv6: Initialize the struct rt6_info behind the dst_enty field Steffen Klassert
@ 2012-07-06  9:39 ` Steffen Klassert
  2012-07-06 10:57 ` [PATCH net-next 1/2] ipv6: Initialize the struct rt6_info " David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Steffen Klassert @ 2012-07-06  9:39 UTC (permalink / raw)
  To: David Miller, Eric Dumazet; +Cc: netdev

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.

Suggested-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
---
 net/xfrm/xfrm_policy.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index 6e97855..79c498b 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -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);
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next 1/2] ipv6: Initialize the struct rt6_info behind the dst_enty field
  2012-07-06  9:37 [PATCH net-next 1/2] ipv6: Initialize the struct rt6_info behind the dst_enty field Steffen Klassert
  2012-07-06  9:39 ` [PATCH net-next 2/2] xfrm: Initialize the struct xfrm_dst " Steffen Klassert
@ 2012-07-06 10:57 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2012-07-06 10:57 UTC (permalink / raw)
  To: steffen.klassert; +Cc: eric.dumazet, netdev

From: Steffen Klassert <steffen.klassert@secunet.com>
Date: Fri, 6 Jul 2012 11:37:09 +0200

> +		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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-07-06 10:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-06  9:37 [PATCH net-next 1/2] ipv6: Initialize the struct rt6_info behind the dst_enty field Steffen Klassert
2012-07-06  9:39 ` [PATCH net-next 2/2] xfrm: Initialize the struct xfrm_dst " Steffen Klassert
2012-07-06 10:57 ` [PATCH net-next 1/2] ipv6: Initialize the struct rt6_info " David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.