netfilter: nft_meta_bridge: add validate callback for get operations
Subsystems (3)
Florian Westphal
maintainerPATCH 1/1 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[].
--- include/net/netfilter/nft_meta.h | 2 ++ net/bridge/netfilter/nft_meta_bridge.c | 19 ++++++++++++++++++- net/netfilter/nft_meta.c | 5 +++-- 3 files changed, 23 insertions(+), 3 deletions(-)
include/net/netfilter/nft_meta.h +2 -0
@@ -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);
net/bridge/netfilter/nft_meta_bridge.c +18 -1
@@ -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 :
net/netfilter/nft_meta.c +3 -2
@@ -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)
Signature · 1 line
2.53.0
Quoted 6 lines · Florian Westphal
Blamed commit added
NFT_META_BRI_IIFHWADDRto the set validate callback, yet this is a get operation.Add a get validate callback and move the
NFT_META_BRI_IIFHWADDRkey there.
Quoted 6 lines
AFAICS this is harmless,
NFT_META_BRI_IIFHWADDRcan deal with a NULL input device and the set handler ignores aNFT_META_BRI_IIFHWADDRoperation, but it allows to read 4 bytes off bridge skb->cb[].Fixes cbd2257dc96e ("netfilter: nft_meta_bridge: introduce NFT_META_BRI_IIFHWADDR support")Signed-off-by Florian Westphal <[email protected]>
Thank you Florian, LGTM.