“6caaa28d926165e9943267b3e8b4f19686f22257”上不存在“drivers/pci/controller/dwc/pci-layerscape.c”
提交 c17b83a7 编写于 作者: P Pablo Neira Ayuso 提交者: Zheng Zengkai

netfilter: nft_payload: report ERANGE for too long offset and length

stable inclusion
from stable-v5.10.140
commit 93a46d6c72b18be6c91b1d11f20310fec5daed37
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I63FTT

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

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

[ Upstream commit 94254f99 ]

Instead of offset and length are truncation to u8, report ERANGE.

Fixes: 96518518 ("netfilter: add nftables")
Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Reviewed-by: NWei Li <liwei391@huawei.com>
上级 3bff57fd
...@@ -733,6 +733,7 @@ nft_payload_select_ops(const struct nft_ctx *ctx, ...@@ -733,6 +733,7 @@ nft_payload_select_ops(const struct nft_ctx *ctx,
{ {
enum nft_payload_bases base; enum nft_payload_bases base;
unsigned int offset, len; unsigned int offset, len;
int err;
if (tb[NFTA_PAYLOAD_BASE] == NULL || if (tb[NFTA_PAYLOAD_BASE] == NULL ||
tb[NFTA_PAYLOAD_OFFSET] == NULL || tb[NFTA_PAYLOAD_OFFSET] == NULL ||
...@@ -758,8 +759,13 @@ nft_payload_select_ops(const struct nft_ctx *ctx, ...@@ -758,8 +759,13 @@ nft_payload_select_ops(const struct nft_ctx *ctx,
if (tb[NFTA_PAYLOAD_DREG] == NULL) if (tb[NFTA_PAYLOAD_DREG] == NULL)
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
offset = ntohl(nla_get_be32(tb[NFTA_PAYLOAD_OFFSET])); err = nft_parse_u32_check(tb[NFTA_PAYLOAD_OFFSET], U8_MAX, &offset);
len = ntohl(nla_get_be32(tb[NFTA_PAYLOAD_LEN])); if (err < 0)
return ERR_PTR(err);
err = nft_parse_u32_check(tb[NFTA_PAYLOAD_LEN], U8_MAX, &len);
if (err < 0)
return ERR_PTR(err);
if (len <= 4 && is_power_of_2(len) && IS_ALIGNED(offset, len) && if (len <= 4 && is_power_of_2(len) && IS_ALIGNED(offset, len) &&
base != NFT_PAYLOAD_LL_HEADER) base != NFT_PAYLOAD_LL_HEADER)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册