netfilter: nf_tables: Introduce NFTA_DEVICE_PREFIX
Subsystems (2)
Phil Sutter
reviewerPATCH 1/1 netfilter: nf_tables: Introduce NFTA_DEVICE_PREFIX
This new attribute is supposed to be used instead of NFTA_DEVICE_NAME for simple wildcard interface specs. It holds a NUL-terminated string representing an interface name prefix to match on.
While kernel code to distinguish full names from prefixes in NFTA_DEVICE_NAME is simpler than this solution, reusing the existing attribute with different semantics leads to confusion between different versions of kernel and user space though:
* With old kernels, wildcards submitted by user space are accepted yet silently treated as regular names.
* With old user space, wildcards submitted by kernel may cause crashes since libnftnl expects NUL-termination when there is none.
Using a distinct attribute type sanitizes these situations as the receiving part detects and rejects the unexpected attribute nested in *_HOOK_DEVS attributes.
--- include/uapi/linux/netfilter/nf_tables.h | 2 ++ net/netfilter/nf_tables_api.c | 42 +++++++++++++++++------- 2 files changed, 33 insertions(+), 11 deletions(-)
include/uapi/linux/netfilter/nf_tables.h +2 -0
@@ -1784,10 +1784,12 @@ enum nft_synproxy_attributes {* enum nft_device_attributes - nf_tables device netlink attributes * * @NFTA_DEVICE_NAME: name of this device (NLA_STRING) +* @NFTA_DEVICE_PREFIX: device name prefix, a simple wildcard (NLA_STRING) */ enum nft_devices_attributes {NFTA_DEVICE_UNSPEC ,NFTA_DEVICE_NAME , +NFTA_DEVICE_PREFIX , __NFTA_DEVICE_MAX };#define NFTA_DEVICE_MAX (__NFTA_DEVICE_MAX - 1)
net/netfilter/nf_tables_api.c +31 -11
96 lines not on this page · raw message
Signature · 1 line
2.49.0