aboutsummaryrefslogtreecommitdiffstats
path: root/net/xfrm/xfrm_user.c
diff options
context:
space:
mode:
authorMathias Krause <minipli@googlemail.com>2012-09-19 07:33:41 -0400
committerDavid S. Miller <davem@davemloft.net>2012-09-20 18:08:40 -0400
commit1f86840f897717f86d523a13e99a447e6a5d2fa5 (patch)
tree03c775c5e0db9f885d7dd24fd7f4d8ebf0caf2eb /net/xfrm/xfrm_user.c
parent7b789836f434c87168eab067cfbed1ec4783dffd (diff)
xfrm_user: fix info leak in copy_to_user_tmpl()
The memory used for the template copy is a local stack variable. As struct xfrm_user_tmpl contains multiple holes added by the compiler for alignment, not initializing the memory will lead to leaking stack bytes to userland. Add an explicit memset(0) to avoid the info leak. Initial version of the patch by Brad Spengler. Cc: Brad Spengler <spender@grsecurity.net> Signed-off-by: Mathias Krause <minipli@googlemail.com> Acked-by: Steffen Klassert <steffen.klassert@secunet.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/xfrm/xfrm_user.c')
-rw-r--r--net/xfrm/xfrm_user.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index 84dd85ceeee..8024b3dea8c 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -1425,6 +1425,7 @@ static int copy_to_user_tmpl(struct xfrm_policy *xp, struct sk_buff *skb)
1425 struct xfrm_user_tmpl *up = &vec[i]; 1425 struct xfrm_user_tmpl *up = &vec[i];
1426 struct xfrm_tmpl *kp = &xp->xfrm_vec[i]; 1426 struct xfrm_tmpl *kp = &xp->xfrm_vec[i];
1427 1427
1428 memset(up, 0, sizeof(*up));
1428 memcpy(&up->id, &kp->id, sizeof(up->id)); 1429 memcpy(&up->id, &kp->id, sizeof(up->id));
1429 up->family = kp->encap_family; 1430 up->family = kp->encap_family;
1430 memcpy(&up->saddr, &kp->saddr, sizeof(up->saddr)); 1431 memcpy(&up->saddr, &kp->saddr, sizeof(up->saddr));