Patch "netfilter: nf_tables: Fix entries val in rule reset audit log" has been added to the 6.5-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    netfilter: nf_tables: Fix entries val in rule reset audit log

to the 6.5-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     netfilter-nf_tables-fix-entries-val-in-rule-reset-au.patch
and it can be found in the queue-6.5 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 25ef742469301b36a1f280bde9355dd6a5cdc9c1
Author: Phil Sutter <phil@xxxxxx>
Date:   Wed Sep 13 15:51:36 2023 +0200

    netfilter: nf_tables: Fix entries val in rule reset audit log
    
    [ Upstream commit 7fb818f248cff996180b7cdcdcb86b6b4f6e44e2 ]
    
    The value in idx and the number of rules handled in that particular
    __nf_tables_dump_rules() call is not identical. The former is a cursor
    to pick up from if multiple netlink messages are needed, so its value is
    ever increasing. Fixing this is not just a matter of subtracting s_idx
    from it, though: When resetting rules in multiple chains,
    __nf_tables_dump_rules() is called for each and cb->args[0] is not
    adjusted in between. Introduce a dedicated counter to record the number
    of rules reset in this call in a less confusing way.
    
    While being at it, prevent the direct return upon buffer exhaustion: Any
    rules previously dumped into that skb would evade audit logging
    otherwise.
    
    Fixes: 9b5ba5c9c5109 ("netfilter: nf_tables: Unbreak audit log reset")
    Signed-off-by: Phil Sutter <phil@xxxxxx>
    Reviewed-by: Florian Westphal <fw@xxxxxxxxx>
    Signed-off-by: Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index 018cf368f6a5f..3e6839c03bccc 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -3451,6 +3451,8 @@ static int __nf_tables_dump_rules(struct sk_buff *skb,
 	struct net *net = sock_net(skb->sk);
 	const struct nft_rule *rule, *prule;
 	unsigned int s_idx = cb->args[0];
+	unsigned int entries = 0;
+	int ret = 0;
 	u64 handle;
 
 	prule = NULL;
@@ -3473,9 +3475,11 @@ static int __nf_tables_dump_rules(struct sk_buff *skb,
 					NFT_MSG_NEWRULE,
 					NLM_F_MULTI | NLM_F_APPEND,
 					table->family,
-					table, chain, rule, handle, reset) < 0)
-			return 1;
-
+					table, chain, rule, handle, reset) < 0) {
+			ret = 1;
+			break;
+		}
+		entries++;
 		nl_dump_check_consistent(cb, nlmsg_hdr(skb));
 cont:
 		prule = rule;
@@ -3483,10 +3487,10 @@ static int __nf_tables_dump_rules(struct sk_buff *skb,
 		(*idx)++;
 	}
 
-	if (reset && *idx)
-		audit_log_rule_reset(table, cb->seq, *idx);
+	if (reset && entries)
+		audit_log_rule_reset(table, cb->seq, entries);
 
-	return 0;
+	return ret;
 }
 
 static int nf_tables_dump_rules(struct sk_buff *skb,



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux