]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
Fixes for 5.15
authorSasha Levin <sashal@kernel.org>
Sat, 28 Dec 2024 23:39:30 +0000 (18:39 -0500)
committerSasha Levin <sashal@kernel.org>
Sat, 28 Dec 2024 23:39:30 +0000 (18:39 -0500)
Signed-off-by: Sasha Levin <sashal@kernel.org>
queue-5.15/bpf-check-validity-of-link-type-in-bpf_link_show_fdi.patch [new file with mode: 0644]
queue-5.15/mips-probe-toolchain-support-of-msym32.patch [new file with mode: 0644]
queue-5.15/series
queue-5.15/vmalloc-fix-accounting-with-i915.patch [new file with mode: 0644]

diff --git a/queue-5.15/bpf-check-validity-of-link-type-in-bpf_link_show_fdi.patch b/queue-5.15/bpf-check-validity-of-link-type-in-bpf_link_show_fdi.patch
new file mode 100644 (file)
index 0000000..ca7a8e2
--- /dev/null
@@ -0,0 +1,60 @@
+From ee9f0443b129c3f50d6b792e5160fe4e2647da2a Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 27 Dec 2024 14:04:35 +0800
+Subject: bpf: Check validity of link->type in bpf_link_show_fdinfo()
+
+From: Hou Tao <houtao1@huawei.com>
+
+commit 8421d4c8762bd022cb491f2f0f7019ef51b4f0a7 upstream.
+
+If a newly-added link type doesn't invoke BPF_LINK_TYPE(), accessing
+bpf_link_type_strs[link->type] may result in an out-of-bounds access.
+
+To spot such missed invocations early in the future, checking the
+validity of link->type in bpf_link_show_fdinfo() and emitting a warning
+when such invocations are missed.
+
+Signed-off-by: Hou Tao <houtao1@huawei.com>
+Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
+Link: https://lore.kernel.org/bpf/20241024013558.1135167-3-houtao@huaweicloud.com
+[ shung-hsi.yu: break up existing seq_printf() call since commit 68b04864ca42
+  ("bpf: Create links for BPF struct_ops maps.") is not present ]
+Signed-off-by: Shung-Hsi Yu <shung-hsi.yu@suse.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ kernel/bpf/syscall.c | 13 +++++++++----
+ 1 file changed, 9 insertions(+), 4 deletions(-)
+
+diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
+index d4b4a47081b5..37aa1e319165 100644
+--- a/kernel/bpf/syscall.c
++++ b/kernel/bpf/syscall.c
+@@ -2522,16 +2522,21 @@ static void bpf_link_show_fdinfo(struct seq_file *m, struct file *filp)
+ {
+       const struct bpf_link *link = filp->private_data;
+       const struct bpf_prog *prog = link->prog;
++      enum bpf_link_type type = link->type;
+       char prog_tag[sizeof(prog->tag) * 2 + 1] = { };
++      if (type < ARRAY_SIZE(bpf_link_type_strs) && bpf_link_type_strs[type]) {
++              seq_printf(m, "link_type:\t%s\n", bpf_link_type_strs[type]);
++      } else {
++              WARN_ONCE(1, "missing BPF_LINK_TYPE(...) for link type %u\n", type);
++              seq_printf(m, "link_type:\t<%u>\n", type);
++      }
++      seq_printf(m, "link_id:\t%u\n", link->id);
++
+       bin2hex(prog_tag, prog->tag, sizeof(prog->tag));
+       seq_printf(m,
+-                 "link_type:\t%s\n"
+-                 "link_id:\t%u\n"
+                  "prog_tag:\t%s\n"
+                  "prog_id:\t%u\n",
+-                 bpf_link_type_strs[link->type],
+-                 link->id,
+                  prog_tag,
+                  prog->aux->id);
+       if (link->ops->show_fdinfo)
+-- 
+2.39.5
+
diff --git a/queue-5.15/mips-probe-toolchain-support-of-msym32.patch b/queue-5.15/mips-probe-toolchain-support-of-msym32.patch
new file mode 100644 (file)
index 0000000..24fe2d1
--- /dev/null
@@ -0,0 +1,38 @@
+From a365084cae349e6fc93d48bb697673b54ddca665 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 24 Dec 2024 14:09:18 +0800
+Subject: MIPS: Probe toolchain support of -msym32
+
+From: Jiaxun Yang <jiaxun.yang@flygoat.com>
+
+[ Upstream commit 18ca63a2e23c5e170d2d7552b64b1f5ad019cd9b ]
+
+msym32 is not supported by LLVM toolchain.
+Workaround by probe toolchain support of msym32 for KBUILD_SYM32
+feature.
+
+Link: https://github.com/ClangBuiltLinux/linux/issues/1544
+Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
+Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
+Signed-off-by: WangYuli <wangyuli@uniontech.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/mips/Makefile | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/arch/mips/Makefile b/arch/mips/Makefile
+index 3830217fab41..37048fbffdb7 100644
+--- a/arch/mips/Makefile
++++ b/arch/mips/Makefile
+@@ -275,7 +275,7 @@ drivers-$(CONFIG_PCI)              += arch/mips/pci/
+ ifdef CONFIG_64BIT
+   ifndef KBUILD_SYM32
+     ifeq ($(shell expr $(load-y) \< 0xffffffff80000000), 0)
+-      KBUILD_SYM32 = y
++      KBUILD_SYM32 = $(call cc-option-yn, -msym32)
+     endif
+   endif
+-- 
+2.39.5
+
index ea560749d8d81e7421cc69c47229df357382e7d0..5138ce8cf412a1f1d9609855a96337ce186124c9 100644 (file)
@@ -82,3 +82,6 @@ platform-x86-asus-nb-wmi-ignore-unknown-event-0xcf.patch
 scsi-mpt3sas-diag-reset-when-doorbell-in-use-bit-is-.patch
 scsi-storvsc-do-not-flag-maintenance_in-return-of-sr.patch
 virtio-blk-don-t-keep-queue-frozen-during-system-sus.patch
+vmalloc-fix-accounting-with-i915.patch
+mips-probe-toolchain-support-of-msym32.patch
+bpf-check-validity-of-link-type-in-bpf_link_show_fdi.patch
diff --git a/queue-5.15/vmalloc-fix-accounting-with-i915.patch b/queue-5.15/vmalloc-fix-accounting-with-i915.patch
new file mode 100644 (file)
index 0000000..95b9604
--- /dev/null
@@ -0,0 +1,51 @@
+From 5409233e1990be3d57f8faeb0fa5570cad12c2d8 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 23 Dec 2024 20:18:00 +0000
+Subject: vmalloc: fix accounting with i915
+
+From: Matthew Wilcox (Oracle) <willy@infradead.org>
+
+[ Upstream commit a2e740e216f5bf49ccb83b6d490c72a340558a43 ]
+
+If the caller of vmap() specifies VM_MAP_PUT_PAGES (currently only the
+i915 driver), we will decrement nr_vmalloc_pages and MEMCG_VMALLOC in
+vfree().  These counters are incremented by vmalloc() but not by vmap() so
+this will cause an underflow.  Check the VM_MAP_PUT_PAGES flag before
+decrementing either counter.
+
+Link: https://lkml.kernel.org/r/20241211202538.168311-1-willy@infradead.org
+Fixes: b944afc9d64d ("mm: add a VM_MAP_PUT_PAGES flag for vmap")
+Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
+Acked-by: Johannes Weiner <hannes@cmpxchg.org>
+Reviewed-by: Shakeel Butt <shakeel.butt@linux.dev>
+Reviewed-by: Balbir Singh <balbirs@nvidia.com>
+Acked-by: Michal Hocko <mhocko@suse.com>
+Cc: Christoph Hellwig <hch@lst.de>
+Cc: Muchun Song <muchun.song@linux.dev>
+Cc: Roman Gushchin <roman.gushchin@linux.dev>
+Cc: "Uladzislau Rezki (Sony)" <urezki@gmail.com>
+Cc: <stable@vger.kernel.org>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ mm/vmalloc.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/mm/vmalloc.c b/mm/vmalloc.c
+index cd434f0ec47f..3cb1f59d1b53 100644
+--- a/mm/vmalloc.c
++++ b/mm/vmalloc.c
+@@ -2621,7 +2621,8 @@ static void __vunmap(const void *addr, int deallocate_pages)
+                       __free_pages(page, page_order);
+                       cond_resched();
+               }
+-              atomic_long_sub(area->nr_pages, &nr_vmalloc_pages);
++              if (!(area->flags & VM_MAP_PUT_PAGES))
++                      atomic_long_sub(area->nr_pages, &nr_vmalloc_pages);
+               kvfree(area->pages);
+       }
+-- 
+2.39.5
+