Skip to content

Commit

Permalink
netfilter: nf_tables_offload: check for register data length mismatches
Browse files Browse the repository at this point in the history
Make sure register data length does not mismatch immediate data length,
otherwise hit EOPNOTSUPP.

Fixes: c9626a2 ("netfilter: nf_tables: add hardware offload support")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
  • Loading branch information
ummakynes committed Nov 4, 2019
1 parent 1204c70 commit de2a605
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions net/netfilter/nft_bitwise.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,13 @@ static int nft_bitwise_offload(struct nft_offload_ctx *ctx,
const struct nft_expr *expr)
{
const struct nft_bitwise *priv = nft_expr_priv(expr);
struct nft_offload_reg *reg = &ctx->regs[priv->dreg];

if (memcmp(&priv->xor, &zero, sizeof(priv->xor)) ||
priv->sreg != priv->dreg)
priv->sreg != priv->dreg || priv->len != reg->len)
return -EOPNOTSUPP;

memcpy(&ctx->regs[priv->dreg].mask, &priv->mask, sizeof(priv->mask));
memcpy(&reg->mask, &priv->mask, sizeof(priv->mask));

return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion net/netfilter/nft_cmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ static int __nft_cmp_offload(struct nft_offload_ctx *ctx,
u8 *mask = (u8 *)&flow->match.mask;
u8 *key = (u8 *)&flow->match.key;

if (priv->op != NFT_CMP_EQ)
if (priv->op != NFT_CMP_EQ || reg->len != priv->len)
return -EOPNOTSUPP;

memcpy(key + reg->offset, &priv->data, priv->len);
Expand Down

0 comments on commit de2a605

Please sign in to comment.