lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190724093509.1676-1-baijiaju1990@gmail.com>
Date:   Wed, 24 Jul 2019 17:35:09 +0800
From:   Jia-Ju Bai <baijiaju1990@...il.com>
To:     steffen.klassert@...unet.com, herbert@...dor.apana.org.au,
        davem@...emloft.net
Cc:     netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
        Jia-Ju Bai <baijiaju1990@...il.com>
Subject: [PATCH] net: key: af_key: Fix possible null-pointer dereferences in pfkey_send_policy_notify()

In pfkey_send_policy_notify(), there is an if statement on line 3081 to
check whether xp is NULL:
    if (xp && xp->type != XFRM_POLICY_TYPE_MAIN)

When xp is NULL, it is used by key_notify_policy() on line 3090:
    key_notify_policy(xp, ...)
        pfkey_xfrm_policy2msg_prep(xp) -- line 2211
            pfkey_xfrm_policy2msg_size(xp) -- line 2046
                for (i=0; i<xp->xfrm_nr; i++) -- line 2026
                t = xp->xfrm_vec + i; -- line 2027
    key_notify_policy(xp, ...)
        xp_net(xp) -- line 2231
            return read_pnet(&xp->xp_net); -- line 534

Thus, possible null-pointer dereferences may occur.

To fix these bugs, xp is checked before calling key_notify_policy().

These bugs are found by a static analysis tool STCheck written by us.

Signed-off-by: Jia-Ju Bai <baijiaju1990@...il.com>
---
 net/key/af_key.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/key/af_key.c b/net/key/af_key.c
index b67ed3a8486c..ced54144d5fd 100644
--- a/net/key/af_key.c
+++ b/net/key/af_key.c
@@ -3087,6 +3087,8 @@ static int pfkey_send_policy_notify(struct xfrm_policy *xp, int dir, const struc
 	case XFRM_MSG_DELPOLICY:
 	case XFRM_MSG_NEWPOLICY:
 	case XFRM_MSG_UPDPOLICY:
+		if (!xp)
+			break;
 		return key_notify_policy(xp, dir, c);
 	case XFRM_MSG_FLUSHPOLICY:
 		if (c->data.type != XFRM_POLICY_TYPE_MAIN)
-- 
2.17.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ