Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

netfilter: nft_osf: use NFT_OSF_MAXGENRELEN instead of IFNAMSIZ

As no "genre" on pf.os exceed 16 bytes of length, we reduce
NFT_OSF_MAXGENRELEN parameter to 16 bytes and use it instead of IFNAMSIZ.

Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>

authored by

Fernando Fernandez Mancera and committed by
Pablo Neira Ayuso
35a8a3bd 98146703

+4 -5
+1
include/uapi/linux/netfilter/nf_tables.h
··· 8 8 #define NFT_SET_MAXNAMELEN NFT_NAME_MAXLEN 9 9 #define NFT_OBJ_MAXNAMELEN NFT_NAME_MAXLEN 10 10 #define NFT_USERDATA_MAXLEN 256 11 + #define NFT_OSF_MAXGENRELEN 16 11 12 12 13 /** 13 14 * enum nft_registers - nf_tables registers
+3 -5
net/netfilter/nft_osf.c
··· 4 4 #include <net/netfilter/nf_tables.h> 5 5 #include <linux/netfilter/nfnetlink_osf.h> 6 6 7 - #define OSF_GENRE_SIZE 32 8 - 9 7 struct nft_osf { 10 8 enum nft_registers dreg:8; 11 9 }; ··· 35 37 36 38 os_name = nf_osf_find(skb, nf_osf_fingers); 37 39 if (!os_name) 38 - strncpy((char *)dest, "unknown", IFNAMSIZ); 40 + strncpy((char *)dest, "unknown", NFT_OSF_MAXGENRELEN); 39 41 else 40 - strncpy((char *)dest, os_name, IFNAMSIZ); 42 + strncpy((char *)dest, os_name, NFT_OSF_MAXGENRELEN); 41 43 } 42 44 43 45 static int nft_osf_init(const struct nft_ctx *ctx, ··· 49 51 50 52 priv->dreg = nft_parse_register(tb[NFTA_OSF_DREG]); 51 53 err = nft_validate_register_store(ctx, priv->dreg, NULL, 52 - NFTA_DATA_VALUE, OSF_GENRE_SIZE); 54 + NFTA_DATA_VALUE, NFT_OSF_MAXGENRELEN); 53 55 if (err < 0) 54 56 return err; 55 57