]> git.baikalelectronics.ru Git - kernel.git/commit
xfrm: fix uctx len check in verify_sec_ctx_len
authorXin Long <lucien.xin@gmail.com>
Sun, 9 Feb 2020 13:15:29 +0000 (21:15 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 1 Apr 2020 09:02:06 +0000 (11:02 +0200)
commit054a35507a258e15bd7c4ca63d8822d300078829
treefe45b6c6ea6a8802641763b518a93ddccd349656
parent0711edc522f1be6f4e9c2c56b9ac5898b144e35c
xfrm: fix uctx len check in verify_sec_ctx_len

commit 4fe980e0ef8ed1cf0c0e5aa548ca9fd824ba2489 upstream.

It's not sufficient to do 'uctx->len != (sizeof(struct xfrm_user_sec_ctx) +
uctx->ctx_len)' check only, as uctx->len may be greater than nla_len(rt),
in which case it will cause slab-out-of-bounds when accessing uctx->ctx_str
later.

This patch is to fix it by return -EINVAL when uctx->len > nla_len(rt).

Fixes: 263946b16eff ("[LSM-IPSec]: Security association restriction.")
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/xfrm/xfrm_user.c