diff options
author | Liping Zhang <liping.zhang@spreadtrum.com> | 2016-09-06 22:33:37 +0800 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2016-09-09 15:54:48 +0200 |
commit | fe01111d23810c0cf6830ce5af1c14c6d3df6dc5 (patch) | |
tree | dc44e6b3a6ad4f87b2b198914718ae0815feac4a /net/netfilter | |
parent | 1bcabc81ee94c0a65989128258f8c1d3e1c1b0ea (diff) | |
download | op-kernel-dev-fe01111d23810c0cf6830ce5af1c14c6d3df6dc5.zip op-kernel-dev-fe01111d23810c0cf6830ce5af1c14c6d3df6dc5.tar.gz |
netfilter: nft_queue: check the validation of queues_total and queuenum
Although the validation of queues_total and queuenum is checked in nft
utility, but user can add nft rules via nfnetlink, so it is necessary
to check the validation at the nft_queue expr init routine too.
Tested by run ./nft-test.py any/queue.t:
any/queue.t: 6 unit tests, 0 error, 0 warning
Signed-off-by: Liping Zhang <liping.zhang@spreadtrum.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'net/netfilter')
-rw-r--r-- | net/netfilter/nft_queue.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/net/netfilter/nft_queue.c b/net/netfilter/nft_queue.c index 61d216e..d16d599 100644 --- a/net/netfilter/nft_queue.c +++ b/net/netfilter/nft_queue.c @@ -65,6 +65,7 @@ static int nft_queue_init(const struct nft_ctx *ctx, const struct nlattr * const tb[]) { struct nft_queue *priv = nft_expr_priv(expr); + u32 maxid; if (tb[NFTA_QUEUE_NUM] == NULL) return -EINVAL; @@ -74,6 +75,16 @@ static int nft_queue_init(const struct nft_ctx *ctx, if (tb[NFTA_QUEUE_TOTAL] != NULL) priv->queues_total = ntohs(nla_get_be16(tb[NFTA_QUEUE_TOTAL])); + else + priv->queues_total = 1; + + if (priv->queues_total == 0) + return -EINVAL; + + maxid = priv->queues_total - 1 + priv->queuenum; + if (maxid > U16_MAX) + return -ERANGE; + if (tb[NFTA_QUEUE_FLAGS] != NULL) { priv->flags = ntohs(nla_get_be16(tb[NFTA_QUEUE_FLAGS])); if (priv->flags & ~NFT_QUEUE_FLAG_MASK) |