mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-12 13:55:32 +00:00
netfilter: nf_tables: restrict anonymous set and map names to 16 bytes
[ Upstream commitb462579b2b
] nftables has two types of sets/maps, one where userspace defines the name, and anonymous sets/maps, where userspace defines a template name. For the latter, kernel requires presence of exactly one "%d". nftables uses "__set%d" and "__map%d" for this. The kernel will expand the format specifier and replaces it with the smallest unused number. As-is, userspace could define a template name that allows to move the set name past the 256 bytes upperlimit (post-expansion). I don't see how this could be a problem, but I would prefer if userspace cannot do this, so add a limit of 16 bytes for the '%d' template name. 16 bytes is the old total upper limit for set names that existed when nf_tables was merged initially. Fixes:387454901b
("netfilter: nf_tables: Allow set names of up to 255 chars") Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
9882495d02
commit
2989f1c4c2
1 changed files with 4 additions and 0 deletions
|
@ -24,6 +24,7 @@
|
|||
#include <net/sock.h>
|
||||
|
||||
#define NFT_MODULE_AUTOLOAD_LIMIT (MODULE_NAME_LEN - sizeof("nft-expr-255-"))
|
||||
#define NFT_SET_MAX_ANONLEN 16
|
||||
|
||||
unsigned int nf_tables_net_id __read_mostly;
|
||||
|
||||
|
@ -4351,6 +4352,9 @@ static int nf_tables_set_alloc_name(struct nft_ctx *ctx, struct nft_set *set,
|
|||
if (p[1] != 'd' || strchr(p + 2, '%'))
|
||||
return -EINVAL;
|
||||
|
||||
if (strnlen(name, NFT_SET_MAX_ANONLEN) >= NFT_SET_MAX_ANONLEN)
|
||||
return -EINVAL;
|
||||
|
||||
inuse = (unsigned long *)get_zeroed_page(GFP_KERNEL);
|
||||
if (inuse == NULL)
|
||||
return -ENOMEM;
|
||||
|
|
Loading…
Reference in a new issue