* [PATCH] xfrm: NULL dereference on allocation failure
@ 2017-06-14 10:35 Dan Carpenter
2017-06-15 11:57 ` Steffen Klassert
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2017-06-14 10:35 UTC (permalink / raw)
To: Steffen Klassert, Trent Jaeger
Cc: Herbert Xu, David S. Miller, netdev, kernel-janitors
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>
diff --git a/net/key/af_key.c b/net/key/af_key.c
index 86051b5879f2..02e6865421e8 100644
--- a/net/key/af_key.c
+++ b/net/key/af_key.c
@@ -1157,6 +1157,7 @@ static struct xfrm_state * pfkey_msg2xfrm_state(struct net *net,
goto out;
}
+ err = -ENOBUFS;
key = ext_hdrs[SADB_EXT_KEY_AUTH - 1];
if (sa->sadb_sa_auth) {
int keysize = 0;
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] xfrm: NULL dereference on allocation failure
2017-06-14 10:35 [PATCH] xfrm: NULL dereference on allocation failure Dan Carpenter
@ 2017-06-15 11:57 ` Steffen Klassert
0 siblings, 0 replies; 2+ messages in thread
From: Steffen Klassert @ 2017-06-15 11:57 UTC (permalink / raw)
To: Dan Carpenter
Cc: Trent Jaeger, Herbert Xu, David S. Miller, netdev,
kernel-janitors
On Wed, Jun 14, 2017 at 01:35:37PM +0300, Dan Carpenter wrote:
> 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>
Also applied, thanks a lot Dan!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-06-15 11:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-14 10:35 [PATCH] xfrm: NULL dereference on allocation failure Dan Carpenter
2017-06-15 11:57 ` Steffen Klassert
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox