af_key: Fix slab-out-of-bounds in pfkey_compile_policy.
authorSteffen Klassert <steffen.klassert@secunet.com>
Fri, 5 May 2017 05:40:42 +0000 (07:40 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 13 Apr 2018 17:47:51 +0000 (19:47 +0200)
commita587acdbb01fa549b9fdc272d079398379b0e25e
treef9c2047af15e3f72eced849f0ff0ea5b233ce71c
parent84284968156340dce4e942b1cebea66c3d4f8146
af_key: Fix slab-out-of-bounds in pfkey_compile_policy.

[ Upstream commit d90c902449a7561f1b1d58ba5a0d11728ce8b0b2 ]

The sadb_x_sec_len is stored in the unit 'byte divided by eight'.
So we have to multiply this value by eight before we can do
size checks. Otherwise we may get a slab-out-of-bounds when
we memcpy the user sec_ctx.

Fixes: df71837d502 ("[LSM-IPSec]: Security association restriction.")
Reported-by: Andrey Konovalov <andreyknvl@google.com>
Tested-by: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/key/af_key.c