Commit c9212ea5 authored by Lin Ma's avatar Lin Ma Committed by sanglipeng
Browse files

net: af_key: fix sadb_x_filter validation

stable inclusion
from stable-v5.10.192
commit 8b92d03cfcec3cfa1c1d4e0d19e07434992bd4c0
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I933RF

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=8b92d03cfcec3cfa1c1d4e0d19e07434992bd4c0



--------------------------------

[ Upstream commit 75065a89 ]

When running xfrm_state_walk_init(), the xfrm_address_filter being used
is okay to have a splen/dplen that equals to sizeof(xfrm_address_t)<<3.
This commit replaces >= to > to make sure the boundary checking is
correct.

Fixes: 37bd2242 ("af_key: pfkey_dump needs parameter validation")
Signed-off-by: default avatarLin Ma <linma@zju.edu.cn>
Signed-off-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarsanglipeng <sanglipeng1@jd.com>
parent f9a17232
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1852,9 +1852,9 @@ static int pfkey_dump(struct sock *sk, struct sk_buff *skb, const struct sadb_ms
	if (ext_hdrs[SADB_X_EXT_FILTER - 1]) {
		struct sadb_x_filter *xfilter = ext_hdrs[SADB_X_EXT_FILTER - 1];

		if ((xfilter->sadb_x_filter_splen >=
		if ((xfilter->sadb_x_filter_splen >
			(sizeof(xfrm_address_t) << 3)) ||
		    (xfilter->sadb_x_filter_dplen >=
		    (xfilter->sadb_x_filter_dplen >
			(sizeof(xfrm_address_t) << 3))) {
			mutex_unlock(&pfk->dump_lock);
			return -EINVAL;