[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <1551671259-21311-1-git-send-email-suyj.fnst@cn.fujitsu.com>
Date:   Sun, 3 Mar 2019 22:47:39 -0500
From:   Su Yanjun <suyj.fnst@...fujitsu.com>
To:     <steffen.klassert@...unet.com>, <herbert@...dor.apana.org.au>,
        <davem@...emloft.net>, <netdev@...r.kernel.org>,
        <linux-kernel@...r.kernel.org>
CC:     <suyj.fnst@...fujitsu.com>
Subject: [PATCH] net: xfrm: Fix potential oops in xfrm_user_rcv_msg and array out of bounds
When i review xfrm_user.c code, i found some potentical bug in it.
In xfrm_user_rcvmsg if type parameter from user space is set to
XFRM_MSG_MAX or  XFRM_MSG_NEWSADINFO or XFRM_MSG_NEWSPDINFO. It will cause
xfrm_user_rcv_msg  referring to null entry in xfrm_dispatch array.
Signed-off-by: Su Yanjun <suyj.fnst@...fujitsu.com>
---
 net/xfrm/xfrm_user.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index a131f9f..d832783 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -2630,11 +2630,13 @@ static int xfrm_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh,
 		return -EOPNOTSUPP;
 
 	type = nlh->nlmsg_type;
-	if (type > XFRM_MSG_MAX)
+	if (type >= XFRM_MSG_MAX)
 		return -EINVAL;
 
 	type -= XFRM_MSG_BASE;
 	link = &xfrm_dispatch[type];
+	if (!link)
+		return -EOPNOTSUPP;
 
 	/* All operations require privileges, even GET */
 	if (!netlink_net_capable(skb, CAP_NET_ADMIN))
-- 
2.7.4
Powered by blists - more mailing lists
 
