diff options
author | Ben Hutchings <ben@decadent.org.uk> | 2017-12-09 19:24:58 +0000 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2018-01-01 20:50:59 +0000 |
commit | 43ce9bf0770f22048156e7b36fe812a3352da842 (patch) | |
tree | c3ee449684b84d938c90460822d795ecc8fc2fae | |
parent | 64eb21a3bd16b4627823947ac786dcb00c0f34b1 (diff) |
ipsec: Fix aborted xfrm policy dump crash
commit 1137b5e2529a8f5ca8ee709288ecba3e68044df2 upstream.
This is a fix for CVE-2017-16939 suitable for older stable branches.
The upstream fix is commit 1137b5e2529a8f5ca8ee709288ecba3e68044df2,
from which the following explanation is taken:
An independent security researcher, Mohamed Ghannam, has reported
this vulnerability to Beyond Security's SecuriTeam Secure Disclosure
program.
The xfrm_dump_policy_done function expects xfrm_dump_policy to
have been called at least once or it will crash. This can be
triggered if a dump fails because the target socket's receive
buffer is full.
It was not possible to define a 'start' callback for netlink dumps
until Linux 4.5, so instead add a check for the initialisation flag in
the 'done' callback.
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
-rw-r--r-- | net/xfrm/xfrm_user.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c index 963222e89dbe..6723bb2810e5 100644 --- a/net/xfrm/xfrm_user.c +++ b/net/xfrm/xfrm_user.c @@ -1530,7 +1530,8 @@ static int xfrm_dump_policy_done(struct netlink_callback *cb) { struct xfrm_policy_walk *walk = (struct xfrm_policy_walk *) &cb->args[1]; - xfrm_policy_walk_done(walk); + if (cb->args[0]) + xfrm_policy_walk_done(walk); return 0; } |