Skip to content

Commit 5ce6b04

Browse files
Liping Zhangummakynes
authored andcommitted
netfilter: nft_log: restrict the log prefix length to 127
First, log prefix will be truncated to NF_LOG_PREFIXLEN-1, i.e. 127, at nf_log_packet(), so the extra part is useless. Second, after adding a log rule with a very very long prefix, we will fail to dump the nft rules after this _special_ one, but acctually, they do exist. For example: # name_65000=$(printf "%0.sQ" {1..65000}) # nft add rule filter output log prefix "$name_65000" # nft add rule filter output counter # nft add rule filter output counter # nft list chain filter output table ip filter { chain output { type filter hook output priority 0; policy accept; } } So now, restrict the log prefix length to NF_LOG_PREFIXLEN-1. Fixes: 9651851 ("netfilter: add nftables") Signed-off-by: Liping Zhang <zlpnobody@gmail.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
1 parent b2fbd04 commit 5ce6b04

3 files changed

Lines changed: 4 additions & 2 deletions

File tree

include/uapi/linux/netfilter/nf_log.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,6 @@
99
#define NF_LOG_MACDECODE 0x20 /* Decode MAC header */
1010
#define NF_LOG_MASK 0x2f
1111

12+
#define NF_LOG_PREFIXLEN 128
13+
1214
#endif /* _NETFILTER_NF_LOG_H */

net/netfilter/nf_log.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
/* Internal logging interface, which relies on the real
1414
LOG target modules */
1515

16-
#define NF_LOG_PREFIXLEN 128
1716
#define NFLOGGER_NAME_LEN 64
1817

1918
static struct nf_logger __rcu *loggers[NFPROTO_NUMPROTO][NF_LOG_TYPE_MAX] __read_mostly;

net/netfilter/nft_log.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ static void nft_log_eval(const struct nft_expr *expr,
3939

4040
static const struct nla_policy nft_log_policy[NFTA_LOG_MAX + 1] = {
4141
[NFTA_LOG_GROUP] = { .type = NLA_U16 },
42-
[NFTA_LOG_PREFIX] = { .type = NLA_STRING },
42+
[NFTA_LOG_PREFIX] = { .type = NLA_STRING,
43+
.len = NF_LOG_PREFIXLEN - 1 },
4344
[NFTA_LOG_SNAPLEN] = { .type = NLA_U32 },
4445
[NFTA_LOG_QTHRESHOLD] = { .type = NLA_U16 },
4546
[NFTA_LOG_LEVEL] = { .type = NLA_U32 },

0 commit comments

Comments
 (0)