Skip to content

Commit c4ab9da

Browse files
Davide Ornaghiummakynes
authored andcommitted
netfilter: nft_inner: validate mandatory meta and payload
Check for mandatory netlink attributes in payload and meta expression when used embedded from the inner expression, otherwise NULL pointer dereference is possible from userspace. Fixes: a150d12 ("netfilter: nft_meta: add inner match support") Fixes: 3a07327 ("netfilter: nft_inner: support for inner tunnel header matching") Signed-off-by: Davide Ornaghi <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent 36534d3 commit c4ab9da

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

net/netfilter/nft_meta.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -839,6 +839,9 @@ static int nft_meta_inner_init(const struct nft_ctx *ctx,
839839
struct nft_meta *priv = nft_expr_priv(expr);
840840
unsigned int len;
841841

842+
if (!tb[NFTA_META_KEY] || !tb[NFTA_META_DREG])
843+
return -EINVAL;
844+
842845
priv->key = ntohl(nla_get_be32(tb[NFTA_META_KEY]));
843846
switch (priv->key) {
844847
case NFT_META_PROTOCOL:

net/netfilter/nft_payload.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,10 @@ static int nft_payload_inner_init(const struct nft_ctx *ctx,
650650
struct nft_payload *priv = nft_expr_priv(expr);
651651
u32 base;
652652

653+
if (!tb[NFTA_PAYLOAD_BASE] || !tb[NFTA_PAYLOAD_OFFSET] ||
654+
!tb[NFTA_PAYLOAD_LEN] || !tb[NFTA_PAYLOAD_DREG])
655+
return -EINVAL;
656+
653657
base = ntohl(nla_get_be32(tb[NFTA_PAYLOAD_BASE]));
654658
switch (base) {
655659
case NFT_PAYLOAD_TUN_HEADER:

0 commit comments

Comments
 (0)