diff options
author | Phil Sutter <phil@nwl.cc> | 2019-07-23 09:27:52 -0400 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2019-07-25 02:37:20 -0400 |
commit | cb81572e8cb50c5fb98b0b962cdfe48fff71fd37 (patch) | |
tree | a6d4fa40c2d04babdc5fd076295d0144f664979d /net/bridge | |
parent | 15a78ba1844a8e052c1226f930133de4cef4e7ad (diff) |
netfilter: nf_tables: Make nft_meta expression more robust
nft_meta_get_eval()'s tendency to bail out setting NFT_BREAK verdict in
situations where required data is missing leads to unexpected behaviour
with inverted checks like so:
| meta iifname != eth0 accept
This rule will never match if there is no input interface (or it is not
known) which is not intuitive and, what's worse, breaks consistency of
iptables-nft with iptables-legacy.
Fix this by falling back to placing a value in dreg which never matches
(avoiding accidental matches), i.e. zero for interface index and an
empty string for interface name.
Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'net/bridge')
-rw-r--r-- | net/bridge/netfilter/nft_meta_bridge.c | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/net/bridge/netfilter/nft_meta_bridge.c b/net/bridge/netfilter/nft_meta_bridge.c index bed66f536b34..a98dec2cf0cf 100644 --- a/net/bridge/netfilter/nft_meta_bridge.c +++ b/net/bridge/netfilter/nft_meta_bridge.c | |||
@@ -30,13 +30,9 @@ static void nft_meta_bridge_get_eval(const struct nft_expr *expr, | |||
30 | switch (priv->key) { | 30 | switch (priv->key) { |
31 | case NFT_META_BRI_IIFNAME: | 31 | case NFT_META_BRI_IIFNAME: |
32 | br_dev = nft_meta_get_bridge(in); | 32 | br_dev = nft_meta_get_bridge(in); |
33 | if (!br_dev) | ||
34 | goto err; | ||
35 | break; | 33 | break; |
36 | case NFT_META_BRI_OIFNAME: | 34 | case NFT_META_BRI_OIFNAME: |
37 | br_dev = nft_meta_get_bridge(out); | 35 | br_dev = nft_meta_get_bridge(out); |
38 | if (!br_dev) | ||
39 | goto err; | ||
40 | break; | 36 | break; |
41 | case NFT_META_BRI_IIFPVID: { | 37 | case NFT_META_BRI_IIFPVID: { |
42 | u16 p_pvid; | 38 | u16 p_pvid; |
@@ -64,7 +60,7 @@ static void nft_meta_bridge_get_eval(const struct nft_expr *expr, | |||
64 | goto out; | 60 | goto out; |
65 | } | 61 | } |
66 | 62 | ||
67 | strncpy((char *)dest, br_dev->name, IFNAMSIZ); | 63 | strncpy((char *)dest, br_dev ? br_dev->name : "", IFNAMSIZ); |
68 | return; | 64 | return; |
69 | out: | 65 | out: |
70 | return nft_meta_get_eval(expr, regs, pkt); | 66 | return nft_meta_get_eval(expr, regs, pkt); |