netfilter: nft_log: restrict the log prefix length to 127
authorLiping Zhang <zlpnobody@gmail.com>
Sun, 22 Jan 2017 14:10:32 +0000 (22:10 +0800)
committerRaspbian kernel package updater <root@raspbian.org>
Sun, 23 Jul 2017 02:59:33 +0000 (02:59 +0000)
commit4f68b1c225df86c6543a9f8bf2c79789295160a0
treeff153c71fc831c3f7de159decffb24c859c155b3
parente8ebd6d77f0dcdff8b30c0c9ba508d07885a9353
netfilter: nft_log: restrict the log prefix length to 127

[ Upstream commit 5ce6b04ce96896e8a79e6f60740ced911eaac7a4 ]

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: 96518518cc41 ("netfilter: add nftables")
Signed-off-by: Liping Zhang <zlpnobody@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
include/uapi/linux/netfilter/nf_log.h
net/netfilter/nf_log.c
net/netfilter/nft_log.c