Skip to content

Commit fe01111

Browse files
Liping Zhangummakynes
authored andcommitted
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 <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent 1bcabc8 commit fe01111

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

net/netfilter/nft_queue.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ static int nft_queue_init(const struct nft_ctx *ctx,
6565
const struct nlattr * const tb[])
6666
{
6767
struct nft_queue *priv = nft_expr_priv(expr);
68+
u32 maxid;
6869

6970
if (tb[NFTA_QUEUE_NUM] == NULL)
7071
return -EINVAL;
@@ -74,6 +75,16 @@ static int nft_queue_init(const struct nft_ctx *ctx,
7475

7576
if (tb[NFTA_QUEUE_TOTAL] != NULL)
7677
priv->queues_total = ntohs(nla_get_be16(tb[NFTA_QUEUE_TOTAL]));
78+
else
79+
priv->queues_total = 1;
80+
81+
if (priv->queues_total == 0)
82+
return -EINVAL;
83+
84+
maxid = priv->queues_total - 1 + priv->queuenum;
85+
if (maxid > U16_MAX)
86+
return -ERANGE;
87+
7788
if (tb[NFTA_QUEUE_FLAGS] != NULL) {
7889
priv->flags = ntohs(nla_get_be16(tb[NFTA_QUEUE_FLAGS]));
7990
if (priv->flags & ~NFT_QUEUE_FLAG_MASK)

0 commit comments

Comments
 (0)