]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
5.10-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 23 Aug 2022 06:16:39 +0000 (08:16 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 23 Aug 2022 06:16:39 +0000 (08:16 +0200)
added patches:
netfilter-nf_tables-fix-audit-memory-leak-in-nf_tables_commit.patch
netfilter-nftables-fix-a-warning-message-in-nf_tables_commit_audit_collect.patch

queue-5.10/netfilter-nf_tables-fix-audit-memory-leak-in-nf_tables_commit.patch [new file with mode: 0644]
queue-5.10/netfilter-nftables-fix-a-warning-message-in-nf_tables_commit_audit_collect.patch [new file with mode: 0644]
queue-5.10/series

diff --git a/queue-5.10/netfilter-nf_tables-fix-audit-memory-leak-in-nf_tables_commit.patch b/queue-5.10/netfilter-nf_tables-fix-audit-memory-leak-in-nf_tables_commit.patch
new file mode 100644 (file)
index 0000000..250bfde
--- /dev/null
@@ -0,0 +1,74 @@
+From cfbe3650dd3ef2ea9a4420ca89d9a4df98af3fb6 Mon Sep 17 00:00:00 2001
+From: Dongliang Mu <mudongliangabcd@gmail.com>
+Date: Wed, 14 Jul 2021 11:27:03 +0800
+Subject: netfilter: nf_tables: fix audit memory leak in nf_tables_commit
+
+From: Dongliang Mu <mudongliangabcd@gmail.com>
+
+commit cfbe3650dd3ef2ea9a4420ca89d9a4df98af3fb6 upstream.
+
+In nf_tables_commit, if nf_tables_commit_audit_alloc fails, it does not
+free the adp variable.
+
+Fix this by adding nf_tables_commit_audit_free which frees
+the linked list with the head node adl.
+
+backtrace:
+  kmalloc include/linux/slab.h:591 [inline]
+  kzalloc include/linux/slab.h:721 [inline]
+  nf_tables_commit_audit_alloc net/netfilter/nf_tables_api.c:8439 [inline]
+  nf_tables_commit+0x16e/0x1760 net/netfilter/nf_tables_api.c:8508
+  nfnetlink_rcv_batch+0x512/0xa80 net/netfilter/nfnetlink.c:562
+  nfnetlink_rcv_skb_batch net/netfilter/nfnetlink.c:634 [inline]
+  nfnetlink_rcv+0x1fa/0x220 net/netfilter/nfnetlink.c:652
+  netlink_unicast_kernel net/netlink/af_netlink.c:1314 [inline]
+  netlink_unicast+0x2c7/0x3e0 net/netlink/af_netlink.c:1340
+  netlink_sendmsg+0x36b/0x6b0 net/netlink/af_netlink.c:1929
+  sock_sendmsg_nosec net/socket.c:702 [inline]
+  sock_sendmsg+0x56/0x80 net/socket.c:722
+
+Reported-by: syzbot <syzkaller@googlegroups.com>
+Reported-by: kernel test robot <lkp@intel.com>
+Fixes: c520292f29b8 ("audit: log nftables configuration change events once per table")
+Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
+Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ net/netfilter/nf_tables_api.c |   12 ++++++++++++
+ 1 file changed, 12 insertions(+)
+
+--- a/net/netfilter/nf_tables_api.c
++++ b/net/netfilter/nf_tables_api.c
+@@ -7819,6 +7819,16 @@ static int nf_tables_commit_audit_alloc(
+       return 0;
+ }
++static void nf_tables_commit_audit_free(struct list_head *adl)
++{
++      struct nft_audit_data *adp, *adn;
++
++      list_for_each_entry_safe(adp, adn, adl, list) {
++              list_del(&adp->list);
++              kfree(adp);
++      }
++}
++
+ static void nf_tables_commit_audit_collect(struct list_head *adl,
+                                          struct nft_table *table, u32 op)
+ {
+@@ -7882,6 +7892,7 @@ static int nf_tables_commit(struct net *
+               ret = nf_tables_commit_audit_alloc(&adl, trans->ctx.table);
+               if (ret) {
+                       nf_tables_commit_chain_prepare_cancel(net);
++                      nf_tables_commit_audit_free(&adl);
+                       return ret;
+               }
+               if (trans->msg_type == NFT_MSG_NEWRULE ||
+@@ -7891,6 +7902,7 @@ static int nf_tables_commit(struct net *
+                       ret = nf_tables_commit_chain_prepare(net, chain);
+                       if (ret < 0) {
+                               nf_tables_commit_chain_prepare_cancel(net);
++                              nf_tables_commit_audit_free(&adl);
+                               return ret;
+                       }
+               }
diff --git a/queue-5.10/netfilter-nftables-fix-a-warning-message-in-nf_tables_commit_audit_collect.patch b/queue-5.10/netfilter-nftables-fix-a-warning-message-in-nf_tables_commit_audit_collect.patch
new file mode 100644 (file)
index 0000000..7573ce5
--- /dev/null
@@ -0,0 +1,33 @@
+From dadf33c9f6b5f694e842d224a4d071f59ac665ee Mon Sep 17 00:00:00 2001
+From: Dan Carpenter <dan.carpenter@oracle.com>
+Date: Fri, 2 Apr 2021 14:45:44 +0300
+Subject: netfilter: nftables: fix a warning message in nf_tables_commit_audit_collect()
+
+From: Dan Carpenter <dan.carpenter@oracle.com>
+
+commit dadf33c9f6b5f694e842d224a4d071f59ac665ee upstream.
+
+The first argument of a WARN_ONCE() is a condition.  This WARN_ONCE()
+will only print the table name, and is potentially problematic if the
+table name has a %s in it.
+
+Fixes: c520292f29b8 ("audit: log nftables configuration change events once per table")
+Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
+Reviewed-by: Paul Moore <paul@paul-moore.com>
+Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ net/netfilter/nf_tables_api.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/net/netfilter/nf_tables_api.c
++++ b/net/netfilter/nf_tables_api.c
+@@ -7828,7 +7828,7 @@ static void nf_tables_commit_audit_colle
+               if (adp->table == table)
+                       goto found;
+       }
+-      WARN_ONCE("table=%s not expected in commit list", table->name);
++      WARN_ONCE(1, "table=%s not expected in commit list", table->name);
+       return;
+ found:
+       adp->entries++;
index 5037514585d25b413992ca9a76a3ed8ac12d9aad..3ccc3076d9115ac23b9421de68479ac8b87374ba 100644 (file)
@@ -148,3 +148,5 @@ smb3-check-xattr-value-length-earlier.patch
 powerpc-64-init-jump-labels-before-parse_early_param.patch
 video-fbdev-i740fb-check-the-argument-of-i740_calc_v.patch
 mips-tlbex-explicitly-compare-_page_no_exec-against-.patch
+netfilter-nftables-fix-a-warning-message-in-nf_tables_commit_audit_collect.patch
+netfilter-nf_tables-fix-audit-memory-leak-in-nf_tables_commit.patch