diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2019-12-06 22:09:14 +0100 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2019-12-09 13:14:03 +0100 |
commit | 0d2c96af797ba149e559c5875c0151384ab6dd14 (patch) | |
tree | f7bdfa04d63e35348b2b8160841518207119975b /net/netfilter/nft_range.c | |
parent | bffc124b6fe37d0ae9b428d104efb426403bb5c9 (diff) | |
download | linux-0d2c96af797ba149e559c5875c0151384ab6dd14.tar.gz linux-0d2c96af797ba149e559c5875c0151384ab6dd14.tar.bz2 linux-0d2c96af797ba149e559c5875c0151384ab6dd14.zip |
netfilter: nf_tables: validate NFT_DATA_VALUE after nft_data_init()
Userspace might bogusly sent NFT_DATA_VERDICT in several netlink
attributes that assume NFT_DATA_VALUE. Moreover, make sure that error
path invokes nft_data_release() to decrement the reference count on the
chain object.
Fixes: 96518518cc41 ("netfilter: add nftables")
Fixes: 0f3cd9b36977 ("netfilter: nf_tables: add range expression")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'net/netfilter/nft_range.c')
-rw-r--r-- | net/netfilter/nft_range.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/net/netfilter/nft_range.c b/net/netfilter/nft_range.c index 4701fa8a45e7..89efcc5a533d 100644 --- a/net/netfilter/nft_range.c +++ b/net/netfilter/nft_range.c @@ -66,11 +66,21 @@ static int nft_range_init(const struct nft_ctx *ctx, const struct nft_expr *expr if (err < 0) return err; + if (desc_from.type != NFT_DATA_VALUE) { + err = -EINVAL; + goto err1; + } + err = nft_data_init(NULL, &priv->data_to, sizeof(priv->data_to), &desc_to, tb[NFTA_RANGE_TO_DATA]); if (err < 0) goto err1; + if (desc_to.type != NFT_DATA_VALUE) { + err = -EINVAL; + goto err2; + } + if (desc_from.len != desc_to.len) { err = -EINVAL; goto err2; |