xfrm: NULL dereference on allocation failure
authorDan Carpenter <dan.carpenter@oracle.com>
Wed, 14 Jun 2017 10:35:37 +0000 (13:35 +0300)
committerDanny Wood <danwood76@gmail.com>
Tue, 29 Jan 2019 13:18:30 +0000 (13:18 +0000)
commit7d03b9825e68efd1adbf73230f0ab09ff0e79d85
treeae0e3eb56fc8ae74ab0449fceb34c330964014a6
parent8e07e8184ea64779ee4d7f3b5059b0529daaba78
xfrm: NULL dereference on allocation failure

commit e747f64336fc15e1c823344942923195b800aa1e upstream.

The default error code in pfkey_msg2xfrm_state() is -ENOBUFS.  We
added a new call to security_xfrm_state_alloc() which sets "err" to zero
so there several places where we can return ERR_PTR(0) if kmalloc()
fails.  The caller is expecting error pointers so it leads to a NULL
dereference.

Fixes: df71837d5024 ("[LSM-IPSec]: Security association restriction.")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Willy Tarreau <w@1wt.eu>
net/key/af_key.c