From: Herbert Xu Date: Tue, 26 Jul 2005 22:43:17 +0000 (-0700) Subject: [XFRM]: Fix possible overflow of sock->sk_policy X-Git-Tag: Ubuntu-goldfish-3.4.0-4.27~40131^2 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=a4f1bac62564049ea4718c4624b0fadc9f597c84;p=mirror_ubuntu-zesty-kernel.git [XFRM]: Fix possible overflow of sock->sk_policy Spotted by, and original patch by, Balazs Scheidler. Signed-off-by: Herbert Xu Signed-off-by: David S. Miller --- diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c index ecade4893a13..8da3e25b2c4c 100644 --- a/net/xfrm/xfrm_user.c +++ b/net/xfrm/xfrm_user.c @@ -1350,6 +1350,9 @@ static struct xfrm_policy *xfrm_compile_policy(u16 family, int opt, if (nr > XFRM_MAX_DEPTH) return NULL; + if (p->dir > XFRM_POLICY_OUT) + return NULL; + xp = xfrm_policy_alloc(GFP_KERNEL); if (xp == NULL) { *dir = -ENOBUFS;