[PATCH] xfrm: state: fix potential null pointer dereference on afinfo

Subsystems: networking [general], networking [ipsec], the rest

STALE3531d

2 messages, 2 authors, 2017-01-16 · open the first message on its own page

[PATCH] xfrm: state: fix potential null pointer dereference on afinfo

From: Colin King <hidden>
Date: 2017-01-13 14:08:10

From: Colin Ian King <redacted>

afinfo is being null checked before a call afinfo->init_tempsel
so afinfo may be potentially null. ifinfo may still be null in
the case were it is not updated when family == tmpl->encap_family,
hence we may hit a null pointer dereference in the call to
afinfo->init_temprop.

Fix this by adding a null ptr check before calling init_temprop.

Signed-off-by: Colin Ian King <redacted>
---
 net/xfrm/xfrm_state.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index a62097e..5083418 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -656,7 +656,8 @@ xfrm_init_tempstate(struct xfrm_state *x, const struct flowi *fl,
 		if (!afinfo)
 			return;
 	}
-	afinfo->init_temprop(x, tmpl, daddr, saddr);
+	if (afinfo)
+		afinfo->init_temprop(x, tmpl, daddr, saddr);
 }
 
 static struct xfrm_state *__xfrm_state_lookup(struct net *net, u32 mark,
-- 
2.10.2

Re: [PATCH] xfrm: state: fix potential null pointer dereference on afinfo

From: Steffen Klassert <steffen.klassert@secunet.com>
Date: 2017-01-16 13:27:17

On Fri, Jan 13, 2017 at 02:07:03PM +0000, Colin King wrote:
From: Colin Ian King <redacted>

afinfo is being null checked before a call afinfo->init_tempsel
so afinfo may be potentially null. ifinfo may still be null in
the case were it is not updated when family == tmpl->encap_family,
hence we may hit a null pointer dereference in the call to
afinfo->init_temprop.

Fix this by adding a null ptr check before calling init_temprop.

Signed-off-by: Colin Ian King <redacted>
I've applied already a fix for this from Florian Westphal.

Thanks a lot anyway!
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help