lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 24 Jan 2022 05:34:55 +0000
From:   kai zhang <zhangkaiheb@....com>
To:     pablo@...filter.org, kadlec@...filter.org, fw@...len.de,
        davem@...emloft.net, yoshfuji@...ux-ipv6.org, dsahern@...nel.org,
        kuba@...nel.org, netfilter-devel@...r.kernel.org,
        coreteam@...filter.org, netdev@...r.kernel.org,
        linux-kernel@...r.kernel.org
Cc:     kai zhang <zhangkaiheb@....com>
Subject: [PATCH] net: fix duplicate logs of iptables TRACE target

Below configuration, mangle,filter and security tables have no rule:

There are 5 logs for incoming ssh packet:

kernel: [ 7018.727278] TRACE: raw:PREROUTING:policy:2 IN=enp9s0 ...
kernel: [ 7018.727304] TRACE: mangle:PREROUTING:policy:1 IN=enp9s0 ...
kernel: [ 7018.727327] TRACE: mangle:INPUT:policy:1 IN=enp9s0 ...
kernel: [ 7018.727343] TRACE: filter:INPUT:policy:1 IN=enp9s0 ...
kernel: [ 7018.727359] TRACE: security:INPUT:policy:1 IN=enp9s0 ...

Signed-off-by: kai zhang <zhangkaiheb@....com>
---
 net/ipv4/netfilter/ip_tables.c  | 4 +++-
 net/ipv6/netfilter/ip6_tables.c | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
index 2ed7c58b4..5f0e6096e 100644
--- a/net/ipv4/netfilter/ip_tables.c
+++ b/net/ipv4/netfilter/ip_tables.c
@@ -304,9 +304,11 @@ ipt_do_table(void *priv,
 
 #if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
 		/* The packet is traced: log it */
-		if (unlikely(skb->nf_trace))
+		if (unlikely(skb->nf_trace)) {
 			trace_packet(state->net, skb, hook, state->in,
 				     state->out, table->name, private, e);
+			nf_reset_trace(skb);
+		}
 #endif
 		/* Standard target? */
 		if (!t->u.kernel.target->target) {
diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
index 2d816277f..ae842a835 100644
--- a/net/ipv6/netfilter/ip6_tables.c
+++ b/net/ipv6/netfilter/ip6_tables.c
@@ -327,9 +327,11 @@ ip6t_do_table(void *priv, struct sk_buff *skb,
 
 #if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
 		/* The packet is traced: log it */
-		if (unlikely(skb->nf_trace))
+		if (unlikely(skb->nf_trace)) {
 			trace_packet(state->net, skb, hook, state->in,
 				     state->out, table->name, private, e);
+			nf_reset_trace(skb);
+		}
 #endif
 		/* Standard target? */
 		if (!t->u.kernel.target->target) {
-- 
2.30.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ