mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 01:32:21 +02:00
netfilter: nft_meta_bridge: add validate callback for get operations
Blamed commit added NFT_META_BRI_IIFHWADDR to the set validate callback,
yet this is a get operation.
Add a get validate callback and move the NFT_META_BRI_IIFHWADDR key
there.
AFAICS this is harmless, NFT_META_BRI_IIFHWADDR can deal with a NULL
input device and the set handler ignores a NFT_META_BRI_IIFHWADDR
operation, but it allows to read 4 bytes off bridge skb->cb[].
Fixes: cbd2257dc9 ("netfilter: nft_meta_bridge: introduce NFT_META_BRI_IIFHWADDR support")
Signed-off-by: Florian Westphal <fw@strlen.de>
Reviewed-by: Fernando Fernandez Mancera <fmancera@suse.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
This commit is contained in:
parent
213be32f46
commit
bff1c8b49a
|
|
@ -40,6 +40,8 @@ void nft_meta_set_eval(const struct nft_expr *expr,
|
|||
void nft_meta_set_destroy(const struct nft_ctx *ctx,
|
||||
const struct nft_expr *expr);
|
||||
|
||||
int nft_meta_get_validate(const struct nft_ctx *ctx,
|
||||
const struct nft_expr *expr);
|
||||
int nft_meta_set_validate(const struct nft_ctx *ctx,
|
||||
const struct nft_expr *expr);
|
||||
|
||||
|
|
|
|||
|
|
@ -107,12 +107,30 @@ static int nft_meta_bridge_get_init(const struct nft_ctx *ctx,
|
|||
NULL, NFT_DATA_VALUE, len);
|
||||
}
|
||||
|
||||
static int nft_meta_bridge_get_validate(const struct nft_ctx *ctx,
|
||||
const struct nft_expr *expr)
|
||||
{
|
||||
struct nft_meta *priv = nft_expr_priv(expr);
|
||||
unsigned int hooks;
|
||||
|
||||
switch (priv->key) {
|
||||
case NFT_META_BRI_IIFHWADDR:
|
||||
hooks = 1 << NF_BR_PRE_ROUTING;
|
||||
break;
|
||||
default:
|
||||
return nft_meta_get_validate(ctx, expr);
|
||||
}
|
||||
|
||||
return nft_chain_validate_hooks(ctx->chain, hooks);
|
||||
}
|
||||
|
||||
static struct nft_expr_type nft_meta_bridge_type;
|
||||
static const struct nft_expr_ops nft_meta_bridge_get_ops = {
|
||||
.type = &nft_meta_bridge_type,
|
||||
.size = NFT_EXPR_SIZE(sizeof(struct nft_meta)),
|
||||
.eval = nft_meta_bridge_get_eval,
|
||||
.init = nft_meta_bridge_get_init,
|
||||
.validate = nft_meta_bridge_get_validate,
|
||||
.dump = nft_meta_get_dump,
|
||||
};
|
||||
|
||||
|
|
@ -168,7 +186,6 @@ static int nft_meta_bridge_set_validate(const struct nft_ctx *ctx,
|
|||
|
||||
switch (priv->key) {
|
||||
case NFT_META_BRI_BROUTE:
|
||||
case NFT_META_BRI_IIFHWADDR:
|
||||
hooks = 1 << NF_BR_PRE_ROUTING;
|
||||
break;
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -635,8 +635,8 @@ static int nft_meta_get_validate_xfrm(const struct nft_ctx *ctx)
|
|||
#endif
|
||||
}
|
||||
|
||||
static int nft_meta_get_validate(const struct nft_ctx *ctx,
|
||||
const struct nft_expr *expr)
|
||||
int nft_meta_get_validate(const struct nft_ctx *ctx,
|
||||
const struct nft_expr *expr)
|
||||
{
|
||||
const struct nft_meta *priv = nft_expr_priv(expr);
|
||||
|
||||
|
|
@ -652,6 +652,7 @@ static int nft_meta_get_validate(const struct nft_ctx *ctx,
|
|||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(nft_meta_get_validate);
|
||||
|
||||
int nft_meta_set_validate(const struct nft_ctx *ctx,
|
||||
const struct nft_expr *expr)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user