Commit 18bbc321 authored by Florian Westphal's avatar Florian Westphal

netfilter: nft_tproxy: restrict to prerouting hook

TPROXY is only allowed from prerouting, but nft_tproxy doesn't check this.
This fixes a crash (null dereference) when using tproxy from e.g. output.

Fixes: 4ed8eb65 ("netfilter: nf_tables: Add native tproxy support")
Reported-by: default avatarShell Chen <xierch@gmail.com>
Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
parent cf97769c
...@@ -312,6 +312,13 @@ static int nft_tproxy_dump(struct sk_buff *skb, ...@@ -312,6 +312,13 @@ static int nft_tproxy_dump(struct sk_buff *skb,
return 0; return 0;
} }
static int nft_tproxy_validate(const struct nft_ctx *ctx,
const struct nft_expr *expr,
const struct nft_data **data)
{
return nft_chain_validate_hooks(ctx->chain, 1 << NF_INET_PRE_ROUTING);
}
static struct nft_expr_type nft_tproxy_type; static struct nft_expr_type nft_tproxy_type;
static const struct nft_expr_ops nft_tproxy_ops = { static const struct nft_expr_ops nft_tproxy_ops = {
.type = &nft_tproxy_type, .type = &nft_tproxy_type,
...@@ -321,6 +328,7 @@ static const struct nft_expr_ops nft_tproxy_ops = { ...@@ -321,6 +328,7 @@ static const struct nft_expr_ops nft_tproxy_ops = {
.destroy = nft_tproxy_destroy, .destroy = nft_tproxy_destroy,
.dump = nft_tproxy_dump, .dump = nft_tproxy_dump,
.reduce = NFT_REDUCE_READONLY, .reduce = NFT_REDUCE_READONLY,
.validate = nft_tproxy_validate,
}; };
static struct nft_expr_type nft_tproxy_type __read_mostly = { static struct nft_expr_type nft_tproxy_type __read_mostly = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment