Skip to content

Commit

Permalink
netfilter: nft_payload: cancel register tracking after payload update
Browse files Browse the repository at this point in the history
The payload expression might mangle the packet, cancel register tracking
since any payload data in the registers is stale.

Finer grain register tracking cancellation by inspecting the payload
base, offset and length on the register is also possible.

Signed-off-by: Pablo Neira Ayuso <[email protected]>
  • Loading branch information
ummakynes committed Jan 9, 2022
1 parent be5650f commit cc003c7
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions net/netfilter/nft_payload.c
Original file line number Diff line number Diff line change
Expand Up @@ -798,12 +798,33 @@ static int nft_payload_set_dump(struct sk_buff *skb, const struct nft_expr *expr
return -1;
}

static bool nft_payload_set_reduce(struct nft_regs_track *track,
const struct nft_expr *expr)
{
int i;

for (i = 0; i < NFT_REG32_NUM; i++) {
if (!track->regs[i].selector)
continue;

if (track->regs[i].selector->ops != &nft_payload_ops &&
track->regs[i].selector->ops != &nft_payload_fast_ops)
continue;

track->regs[i].selector = NULL;
track->regs[i].bitwise = NULL;
}

return false;
}

static const struct nft_expr_ops nft_payload_set_ops = {
.type = &nft_payload_type,
.size = NFT_EXPR_SIZE(sizeof(struct nft_payload_set)),
.eval = nft_payload_set_eval,
.init = nft_payload_set_init,
.dump = nft_payload_set_dump,
.reduce = nft_payload_set_reduce,
};

static const struct nft_expr_ops *
Expand Down

0 comments on commit cc003c7

Please sign in to comment.