From: Sasha Levin Date: Tue, 30 Jul 2024 13:55:23 +0000 (-0400) Subject: Fixes for 5.10 X-Git-Tag: v6.1.103~15^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c9fa64f4dfefa2815c0484913f5b5477fac6963b;p=thirdparty%2Fkernel%2Fstable-queue.git Fixes for 5.10 Signed-off-by: Sasha Levin --- diff --git a/queue-5.10/apparmor-fix-null-pointer-deref-when-receiving-skb-d.patch b/queue-5.10/apparmor-fix-null-pointer-deref-when-receiving-skb-d.patch new file mode 100644 index 00000000000..471b473378c --- /dev/null +++ b/queue-5.10/apparmor-fix-null-pointer-deref-when-receiving-skb-d.patch @@ -0,0 +1,111 @@ +From 4e55e278f81719c523108febf13d83cfeb7e5cc4 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sat, 2 Sep 2023 08:48:38 +0800 +Subject: apparmor: Fix null pointer deref when receiving skb during sock + creation + +From: Xiao Liang + +[ Upstream commit fce09ea314505a52f2436397608fa0a5d0934fb1 ] + +The panic below is observed when receiving ICMP packets with secmark set +while an ICMP raw socket is being created. SK_CTX(sk)->label is updated +in apparmor_socket_post_create(), but the packet is delivered to the +socket before that, causing the null pointer dereference. +Drop the packet if label context is not set. + + BUG: kernel NULL pointer dereference, address: 000000000000004c + #PF: supervisor read access in kernel mode + #PF: error_code(0x0000) - not-present page + PGD 0 P4D 0 + Oops: 0000 [#1] PREEMPT SMP NOPTI + CPU: 0 PID: 407 Comm: a.out Not tainted 6.4.12-arch1-1 #1 3e6fa2753a2d75925c34ecb78e22e85a65d083df + Hardware name: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform, BIOS 6.00 05/28/2020 + RIP: 0010:aa_label_next_confined+0xb/0x40 + Code: 00 00 48 89 ef e8 d5 25 0c 00 e9 66 ff ff ff 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 66 0f 1f 00 0f 1f 44 00 00 89 f0 <8b> 77 4c 39 c6 7e 1f 48 63 d0 48 8d 14 d7 eb 0b 83 c0 01 48 83 c2 + RSP: 0018:ffffa92940003b08 EFLAGS: 00010246 + RAX: 0000000000000000 RBX: 0000000000000000 RCX: 000000000000000e + RDX: ffffa92940003be8 RSI: 0000000000000000 RDI: 0000000000000000 + RBP: ffff8b57471e7800 R08: ffff8b574c642400 R09: 0000000000000002 + R10: ffffffffbd820eeb R11: ffffffffbeb7ff00 R12: ffff8b574c642400 + R13: 0000000000000001 R14: 0000000000000001 R15: 0000000000000000 + FS: 00007fb092ea7640(0000) GS:ffff8b577bc00000(0000) knlGS:0000000000000000 + CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 + CR2: 000000000000004c CR3: 00000001020f2005 CR4: 00000000007706f0 + PKRU: 55555554 + Call Trace: + + ? __die+0x23/0x70 + ? page_fault_oops+0x171/0x4e0 + ? exc_page_fault+0x7f/0x180 + ? asm_exc_page_fault+0x26/0x30 + ? aa_label_next_confined+0xb/0x40 + apparmor_secmark_check+0xec/0x330 + security_sock_rcv_skb+0x35/0x50 + sk_filter_trim_cap+0x47/0x250 + sock_queue_rcv_skb_reason+0x20/0x60 + raw_rcv+0x13c/0x210 + raw_local_deliver+0x1f3/0x250 + ip_protocol_deliver_rcu+0x4f/0x2f0 + ip_local_deliver_finish+0x76/0xa0 + __netif_receive_skb_one_core+0x89/0xa0 + netif_receive_skb+0x119/0x170 + ? __netdev_alloc_skb+0x3d/0x140 + vmxnet3_rq_rx_complete+0xb23/0x1010 [vmxnet3 56a84f9c97178c57a43a24ec073b45a9d6f01f3a] + vmxnet3_poll_rx_only+0x36/0xb0 [vmxnet3 56a84f9c97178c57a43a24ec073b45a9d6f01f3a] + __napi_poll+0x28/0x1b0 + net_rx_action+0x2a4/0x380 + __do_softirq+0xd1/0x2c8 + __irq_exit_rcu+0xbb/0xf0 + common_interrupt+0x86/0xa0 + + + asm_common_interrupt+0x26/0x40 + RIP: 0010:apparmor_socket_post_create+0xb/0x200 + Code: 08 48 85 ff 75 a1 eb b1 0f 1f 80 00 00 00 00 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 f3 0f 1e fa 0f 1f 44 00 00 41 54 <55> 48 89 fd 53 45 85 c0 0f 84 b2 00 00 00 48 8b 1d 80 56 3f 02 48 + RSP: 0018:ffffa92940ce7e50 EFLAGS: 00000286 + RAX: ffffffffbc756440 RBX: 0000000000000000 RCX: 0000000000000001 + RDX: 0000000000000003 RSI: 0000000000000002 RDI: ffff8b574eaab740 + RBP: 0000000000000001 R08: 0000000000000000 R09: 0000000000000000 + R10: ffff8b57444cec70 R11: 0000000000000000 R12: 0000000000000003 + R13: 0000000000000002 R14: ffff8b574eaab740 R15: ffffffffbd8e4748 + ? __pfx_apparmor_socket_post_create+0x10/0x10 + security_socket_post_create+0x4b/0x80 + __sock_create+0x176/0x1f0 + __sys_socket+0x89/0x100 + __x64_sys_socket+0x17/0x20 + do_syscall_64+0x5d/0x90 + ? do_syscall_64+0x6c/0x90 + ? do_syscall_64+0x6c/0x90 + ? do_syscall_64+0x6c/0x90 + entry_SYSCALL_64_after_hwframe+0x72/0xdc + +Fixes: ab9f2115081a ("apparmor: Allow filtering based on secmark policy") +Signed-off-by: Xiao Liang +Signed-off-by: John Johansen +Signed-off-by: Sasha Levin +--- + security/apparmor/lsm.c | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c +index 052f1b920e43f..37aa1650c74eb 100644 +--- a/security/apparmor/lsm.c ++++ b/security/apparmor/lsm.c +@@ -1048,6 +1048,13 @@ static int apparmor_socket_sock_rcv_skb(struct sock *sk, struct sk_buff *skb) + if (!skb->secmark) + return 0; + ++ /* ++ * If reach here before socket_post_create hook is called, in which ++ * case label is null, drop the packet. ++ */ ++ if (!ctx->label) ++ return -EACCES; ++ + return apparmor_secmark_check(ctx->label, OP_RECVMSG, AA_MAY_RECEIVE, + skb->secmark, sk); + } +-- +2.43.0 + diff --git a/queue-5.10/asoc-intel-use-soc_intel_is_byt_cr-only-when-iosf_mb.patch b/queue-5.10/asoc-intel-use-soc_intel_is_byt_cr-only-when-iosf_mb.patch new file mode 100644 index 00000000000..397d79cb5ca --- /dev/null +++ b/queue-5.10/asoc-intel-use-soc_intel_is_byt_cr-only-when-iosf_mb.patch @@ -0,0 +1,54 @@ +From 52238840f46a00c580bb889e202e38c65b4dcdfc Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 22 Jul 2024 10:30:02 +0200 +Subject: ASoC: Intel: use soc_intel_is_byt_cr() only when IOSF_MBI is + reachable +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Pierre-Louis Bossart + +[ Upstream commit 9931f7d5d251882a147cc5811060097df43e79f5 ] + +the Intel kbuild bot reports a link failure when IOSF_MBI is built-in +but the Merrifield driver is configured as a module. The +soc-intel-quirks.h is included for Merrifield platforms, but IOSF_MBI +is not selected for that platform. + +ld.lld: error: undefined symbol: iosf_mbi_read +>>> referenced by atom.c +>>> sound/soc/sof/intel/atom.o:(atom_machine_select) in archive vmlinux.a + +This patch forces the use of the fallback static inline when IOSF_MBI is not reachable. + +Fixes: 536cfd2f375d ("ASoC: Intel: use common helpers to detect CPUs") +Reported-by: kernel test robot +Closes: https://lore.kernel.org/oe-kbuild-all/202407160704.zpdhJ8da-lkp@intel.com/ +Suggested-by: Takashi Iwai +Signed-off-by: Pierre-Louis Bossart +Reviewed-by: Péter Ujfalusi +Reviewed-by: Bard Liao +Link: https://patch.msgid.link/20240722083002.10800-1-pierre-louis.bossart@linux.intel.com +Signed-off-by: Mark Brown +Signed-off-by: Sasha Levin +--- + sound/soc/intel/common/soc-intel-quirks.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/sound/soc/intel/common/soc-intel-quirks.h b/sound/soc/intel/common/soc-intel-quirks.h +index de4e550c5b34d..42bd51456b945 100644 +--- a/sound/soc/intel/common/soc-intel-quirks.h ++++ b/sound/soc/intel/common/soc-intel-quirks.h +@@ -11,7 +11,7 @@ + + #include + +-#if IS_ENABLED(CONFIG_X86) ++#if IS_REACHABLE(CONFIG_IOSF_MBI) + + #include + #include +-- +2.43.0 + diff --git a/queue-5.10/bpf-fix-a-segment-issue-when-downgrading-gso_size.patch b/queue-5.10/bpf-fix-a-segment-issue-when-downgrading-gso_size.patch new file mode 100644 index 00000000000..4e249f3d424 --- /dev/null +++ b/queue-5.10/bpf-fix-a-segment-issue-when-downgrading-gso_size.patch @@ -0,0 +1,57 @@ +From e6b6a8b7aea9ffd36250a60b30318422fb9d084c Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 19 Jul 2024 10:46:53 +0800 +Subject: bpf: Fix a segment issue when downgrading gso_size + +From: Fred Li + +[ Upstream commit fa5ef655615a01533035c6139248c5b33aa27028 ] + +Linearize the skb when downgrading gso_size because it may trigger a +BUG_ON() later when the skb is segmented as described in [1,2]. + +Fixes: 2be7e212d5419 ("bpf: add bpf_skb_adjust_room helper") +Signed-off-by: Fred Li +Signed-off-by: Daniel Borkmann +Reviewed-by: Willem de Bruijn +Acked-by: Daniel Borkmann +Link: https://lore.kernel.org/all/20240626065555.35460-2-dracodingfly@gmail.com [1] +Link: https://lore.kernel.org/all/668d5cf1ec330_1c18c32947@willemb.c.googlers.com.notmuch [2] +Link: https://lore.kernel.org/bpf/20240719024653.77006-1-dracodingfly@gmail.com +Signed-off-by: Sasha Levin +--- + net/core/filter.c | 15 +++++++++++---- + 1 file changed, 11 insertions(+), 4 deletions(-) + +diff --git a/net/core/filter.c b/net/core/filter.c +index a3101cdfd47b9..99fdd8afeeda3 100644 +--- a/net/core/filter.c ++++ b/net/core/filter.c +@@ -3535,13 +3535,20 @@ static int bpf_skb_net_grow(struct sk_buff *skb, u32 off, u32 len_diff, + if (skb_is_gso(skb)) { + struct skb_shared_info *shinfo = skb_shinfo(skb); + +- /* Due to header grow, MSS needs to be downgraded. */ +- if (!(flags & BPF_F_ADJ_ROOM_FIXED_GSO)) +- skb_decrease_gso_size(shinfo, len_diff); +- + /* Header must be checked, and gso_segs recomputed. */ + shinfo->gso_type |= gso_type; + shinfo->gso_segs = 0; ++ ++ /* Due to header growth, MSS needs to be downgraded. ++ * There is a BUG_ON() when segmenting the frag_list with ++ * head_frag true, so linearize the skb after downgrading ++ * the MSS. ++ */ ++ if (!(flags & BPF_F_ADJ_ROOM_FIXED_GSO)) { ++ skb_decrease_gso_size(shinfo, len_diff); ++ if (shinfo->frag_list) ++ return skb_linearize(skb); ++ } + } + + return 0; +-- +2.43.0 + diff --git a/queue-5.10/ceph-fix-incorrect-kmalloc-size-of-pagevec-mempool.patch b/queue-5.10/ceph-fix-incorrect-kmalloc-size-of-pagevec-mempool.patch new file mode 100644 index 00000000000..9c8b282d974 --- /dev/null +++ b/queue-5.10/ceph-fix-incorrect-kmalloc-size-of-pagevec-mempool.patch @@ -0,0 +1,38 @@ +From 1fed4f2057be7e4c2ccc264e50290c5a2ab05f85 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 11 Jul 2024 14:47:56 +0800 +Subject: ceph: fix incorrect kmalloc size of pagevec mempool + +From: ethanwu + +[ Upstream commit 03230edb0bd831662a7c08b6fef66b2a9a817774 ] + +The kmalloc size of pagevec mempool is incorrectly calculated. +It misses the size of page pointer and only accounts the number for the array. + +Fixes: a0102bda5bc0 ("ceph: move sb->wb_pagevec_pool to be a global mempool") +Signed-off-by: ethanwu +Reviewed-by: Xiubo Li +Signed-off-by: Ilya Dryomov +Signed-off-by: Sasha Levin +--- + fs/ceph/super.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/fs/ceph/super.c b/fs/ceph/super.c +index f2aff97348bc9..4e09d8e066473 100644 +--- a/fs/ceph/super.c ++++ b/fs/ceph/super.c +@@ -783,7 +783,8 @@ static int __init init_caches(void) + if (!ceph_mds_request_cachep) + goto bad_mds_req; + +- ceph_wb_pagevec_pool = mempool_create_kmalloc_pool(10, CEPH_MAX_WRITE_SIZE >> PAGE_SHIFT); ++ ceph_wb_pagevec_pool = mempool_create_kmalloc_pool(10, ++ (CEPH_MAX_WRITE_SIZE >> PAGE_SHIFT) * sizeof(struct page *)); + if (!ceph_wb_pagevec_pool) + goto bad_pagevec_pool; + +-- +2.43.0 + diff --git a/queue-5.10/dma-fix-call-order-in-dmam_free_coherent.patch b/queue-5.10/dma-fix-call-order-in-dmam_free_coherent.patch new file mode 100644 index 00000000000..67411615290 --- /dev/null +++ b/queue-5.10/dma-fix-call-order-in-dmam_free_coherent.patch @@ -0,0 +1,52 @@ +From 21a5aa3b5b825d2cde5e5920b7c5078977661324 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 18 Jul 2024 14:38:24 +0000 +Subject: dma: fix call order in dmam_free_coherent + +From: Lance Richardson + +[ Upstream commit 28e8b7406d3a1f5329a03aa25a43aa28e087cb20 ] + +dmam_free_coherent() frees a DMA allocation, which makes the +freed vaddr available for reuse, then calls devres_destroy() +to remove and free the data structure used to track the DMA +allocation. Between the two calls, it is possible for a +concurrent task to make an allocation with the same vaddr +and add it to the devres list. + +If this happens, there will be two entries in the devres list +with the same vaddr and devres_destroy() can free the wrong +entry, triggering the WARN_ON() in dmam_match. + +Fix by destroying the devres entry before freeing the DMA +allocation. + +Tested: + kokonut //net/encryption + http://sponge2/b9145fe6-0f72-4325-ac2f-a84d81075b03 + +Fixes: 9ac7849e35f7 ("devres: device resource management") +Signed-off-by: Lance Richardson +Signed-off-by: Christoph Hellwig +Signed-off-by: Sasha Levin +--- + kernel/dma/mapping.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/kernel/dma/mapping.c b/kernel/dma/mapping.c +index 51bb8fa8eb894..453c0fbe87ff4 100644 +--- a/kernel/dma/mapping.c ++++ b/kernel/dma/mapping.c +@@ -60,8 +60,8 @@ void dmam_free_coherent(struct device *dev, size_t size, void *vaddr, + { + struct dma_devres match_data = { size, vaddr, dma_handle }; + +- dma_free_coherent(dev, size, vaddr, dma_handle); + WARN_ON(devres_destroy(dev, dmam_release, dmam_match, &match_data)); ++ dma_free_coherent(dev, size, vaddr, dma_handle); + } + EXPORT_SYMBOL(dmam_free_coherent); + +-- +2.43.0 + diff --git a/queue-5.10/f2fs-fix-start-segno-of-large-section.patch b/queue-5.10/f2fs-fix-start-segno-of-large-section.patch new file mode 100644 index 00000000000..8c071545015 --- /dev/null +++ b/queue-5.10/f2fs-fix-start-segno-of-large-section.patch @@ -0,0 +1,40 @@ +From 3a5ed3fd277ed08e16acc5451c82abca7b123c66 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 8 Jul 2024 20:04:07 +0800 +Subject: f2fs: fix start segno of large section + +From: Sheng Yong + +[ Upstream commit 8c409989678e92e4a737e7cd2bb04f3efb81071a ] + +get_ckpt_valid_blocks() checks valid ckpt blocks in current section. +It counts all vblocks from the first to the last segment in the +large section. However, START_SEGNO() is used to get the first segno +in an SIT block. This patch fixes that to get the correct start segno. + +Fixes: 61461fc921b7 ("f2fs: fix to avoid touching checkpointed data in get_victim()") +Signed-off-by: Sheng Yong +Reviewed-by: Chao Yu +Signed-off-by: Jaegeuk Kim +Signed-off-by: Sasha Levin +--- + fs/f2fs/segment.h | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h +index 979296b835b5a..665e0e186687d 100644 +--- a/fs/f2fs/segment.h ++++ b/fs/f2fs/segment.h +@@ -371,7 +371,8 @@ static inline unsigned int get_ckpt_valid_blocks(struct f2fs_sb_info *sbi, + unsigned int segno, bool use_section) + { + if (use_section && __is_large_section(sbi)) { +- unsigned int start_segno = START_SEGNO(segno); ++ unsigned int secno = GET_SEC_FROM_SEG(sbi, segno); ++ unsigned int start_segno = GET_SEG_FROM_SEC(sbi, secno); + unsigned int blocks = 0; + int i; + +-- +2.43.0 + diff --git a/queue-5.10/fs-don-t-allow-non-init-s_user_ns-for-filesystems-wi.patch b/queue-5.10/fs-don-t-allow-non-init-s_user_ns-for-filesystems-wi.patch new file mode 100644 index 00000000000..3dd5a85b6ab --- /dev/null +++ b/queue-5.10/fs-don-t-allow-non-init-s_user_ns-for-filesystems-wi.patch @@ -0,0 +1,65 @@ +From 18800ae6bf19f313fe09c066a95791cecc6ebf0c Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 24 Jul 2024 09:53:59 -0500 +Subject: fs: don't allow non-init s_user_ns for filesystems without + FS_USERNS_MOUNT + +From: Seth Forshee (DigitalOcean) + +[ Upstream commit e1c5ae59c0f22f7fe5c07fb5513a29e4aad868c9 ] + +Christian noticed that it is possible for a privileged user to mount +most filesystems with a non-initial user namespace in sb->s_user_ns. +When fsopen() is called in a non-init namespace the caller's namespace +is recorded in fs_context->user_ns. If the returned file descriptor is +then passed to a process priviliged in init_user_ns, that process can +call fsconfig(fd_fs, FSCONFIG_CMD_CREATE), creating a new superblock +with sb->s_user_ns set to the namespace of the process which called +fsopen(). + +This is problematic. We cannot assume that any filesystem which does not +set FS_USERNS_MOUNT has been written with a non-initial s_user_ns in +mind, increasing the risk for bugs and security issues. + +Prevent this by returning EPERM from sget_fc() when FS_USERNS_MOUNT is +not set for the filesystem and a non-initial user namespace will be +used. sget() does not need to be updated as it always uses the user +namespace of the current context, or the initial user namespace if +SB_SUBMOUNT is set. + +Fixes: cb50b348c71f ("convenience helpers: vfs_get_super() and sget_fc()") +Reported-by: Christian Brauner +Signed-off-by: Seth Forshee (DigitalOcean) +Link: https://lore.kernel.org/r/20240724-s_user_ns-fix-v1-1-895d07c94701@kernel.org +Reviewed-by: Alexander Mikhalitsyn +Signed-off-by: Christian Brauner +Signed-off-by: Sasha Levin +--- + fs/super.c | 11 +++++++++++ + 1 file changed, 11 insertions(+) + +diff --git a/fs/super.c b/fs/super.c +index f9795e72e3bf8..282aa36901eb1 100644 +--- a/fs/super.c ++++ b/fs/super.c +@@ -518,6 +518,17 @@ struct super_block *sget_fc(struct fs_context *fc, + struct user_namespace *user_ns = fc->global ? &init_user_ns : fc->user_ns; + int err; + ++ /* ++ * Never allow s_user_ns != &init_user_ns when FS_USERNS_MOUNT is ++ * not set, as the filesystem is likely unprepared to handle it. ++ * This can happen when fsconfig() is called from init_user_ns with ++ * an fs_fd opened in another user namespace. ++ */ ++ if (user_ns != &init_user_ns && !(fc->fs_type->fs_flags & FS_USERNS_MOUNT)) { ++ errorfc(fc, "VFS: Mounting from non-initial user namespace is not allowed"); ++ return ERR_PTR(-EPERM); ++ } ++ + retry: + spin_lock(&sb_lock); + if (test) { +-- +2.43.0 + diff --git a/queue-5.10/ipv4-fix-incorrect-source-address-in-record-route-op.patch b/queue-5.10/ipv4-fix-incorrect-source-address-in-record-route-op.patch new file mode 100644 index 00000000000..2c90e7040ac --- /dev/null +++ b/queue-5.10/ipv4-fix-incorrect-source-address-in-record-route-op.patch @@ -0,0 +1,49 @@ +From 99683297ee4b0e6543284c4796d66c2ece4339be Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 18 Jul 2024 15:34:07 +0300 +Subject: ipv4: Fix incorrect source address in Record Route option + +From: Ido Schimmel + +[ Upstream commit cc73bbab4b1fb8a4f53a24645871dafa5f81266a ] + +The Record Route IP option records the addresses of the routers that +routed the packet. In the case of forwarded packets, the kernel performs +a route lookup via fib_lookup() and fills in the preferred source +address of the matched route. + +The lookup is performed with the DS field of the forwarded packet, but +using the RT_TOS() macro which only masks one of the two ECN bits. If +the packet is ECT(0) or CE, the matched route might be different than +the route via which the packet was forwarded as the input path masks +both of the ECN bits, resulting in the wrong address being filled in the +Record Route option. + +Fix by masking both of the ECN bits. + +Fixes: 8e36360ae876 ("ipv4: Remove route key identity dependencies in ip_rt_get_source().") +Signed-off-by: Ido Schimmel +Reviewed-by: Guillaume Nault +Link: https://patch.msgid.link/20240718123407.434778-1-idosch@nvidia.com +Signed-off-by: Paolo Abeni +Signed-off-by: Sasha Levin +--- + net/ipv4/route.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/net/ipv4/route.c b/net/ipv4/route.c +index b3b49d8b386d8..1eb1e4316ed6d 100644 +--- a/net/ipv4/route.c ++++ b/net/ipv4/route.c +@@ -1302,7 +1302,7 @@ void ip_rt_get_source(u8 *addr, struct sk_buff *skb, struct rtable *rt) + struct flowi4 fl4 = { + .daddr = iph->daddr, + .saddr = iph->saddr, +- .flowi4_tos = RT_TOS(iph->tos), ++ .flowi4_tos = iph->tos & IPTOS_RT_MASK, + .flowi4_oif = rt->dst.dev->ifindex, + .flowi4_iif = skb->dev->ifindex, + .flowi4_mark = skb->mark, +-- +2.43.0 + diff --git a/queue-5.10/jfs-fix-array-index-out-of-bounds-in-difree.patch b/queue-5.10/jfs-fix-array-index-out-of-bounds-in-difree.patch new file mode 100644 index 00000000000..abb73b2ee98 --- /dev/null +++ b/queue-5.10/jfs-fix-array-index-out-of-bounds-in-difree.patch @@ -0,0 +1,46 @@ +From d6354356d843582348b7d0f479d351bc33a02423 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 30 May 2024 22:28:09 +0900 +Subject: jfs: Fix array-index-out-of-bounds in diFree + +From: Jeongjun Park + +[ Upstream commit f73f969b2eb39ad8056f6c7f3a295fa2f85e313a ] + +Reported-by: syzbot+241c815bda521982cb49@syzkaller.appspotmail.com +Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") +Signed-off-by: Jeongjun Park +Signed-off-by: Dave Kleikamp +Signed-off-by: Sasha Levin +--- + fs/jfs/jfs_imap.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/fs/jfs/jfs_imap.c b/fs/jfs/jfs_imap.c +index b0965f3ef1865..36ed756820648 100644 +--- a/fs/jfs/jfs_imap.c ++++ b/fs/jfs/jfs_imap.c +@@ -292,7 +292,7 @@ int diSync(struct inode *ipimap) + int diRead(struct inode *ip) + { + struct jfs_sb_info *sbi = JFS_SBI(ip->i_sb); +- int iagno, ino, extno, rc; ++ int iagno, ino, extno, rc, agno; + struct inode *ipimap; + struct dinode *dp; + struct iag *iagp; +@@ -341,8 +341,11 @@ int diRead(struct inode *ip) + + /* get the ag for the iag */ + agstart = le64_to_cpu(iagp->agstart); ++ agno = BLKTOAG(agstart, JFS_SBI(ip->i_sb)); + + release_metapage(mp); ++ if (agno >= MAXAG || agno < 0) ++ return -EIO; + + rel_inode = (ino & (INOSPERPAGE - 1)); + pageno = blkno >> sbi->l2nbperpage; +-- +2.43.0 + diff --git a/queue-5.10/kdb-address-wformat-security-warnings.patch b/queue-5.10/kdb-address-wformat-security-warnings.patch new file mode 100644 index 00000000000..f0ffd99aba6 --- /dev/null +++ b/queue-5.10/kdb-address-wformat-security-warnings.patch @@ -0,0 +1,58 @@ +From 52f28df35c86e2b0bf7fe9d6471c8382db14cf75 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 28 May 2024 14:11:48 +0200 +Subject: kdb: address -Wformat-security warnings + +From: Arnd Bergmann + +[ Upstream commit 70867efacf4370b6c7cdfc7a5b11300e9ef7de64 ] + +When -Wformat-security is not disabled, using a string pointer +as a format causes a warning: + +kernel/debug/kdb/kdb_io.c: In function 'kdb_read': +kernel/debug/kdb/kdb_io.c:365:36: error: format not a string literal and no format arguments [-Werror=format-security] + 365 | kdb_printf(kdb_prompt_str); + | ^~~~~~~~~~~~~~ +kernel/debug/kdb/kdb_io.c: In function 'kdb_getstr': +kernel/debug/kdb/kdb_io.c:456:20: error: format not a string literal and no format arguments [-Werror=format-security] + 456 | kdb_printf(kdb_prompt_str); + | ^~~~~~~~~~~~~~ + +Use an explcit "%s" format instead. + +Signed-off-by: Arnd Bergmann +Fixes: 5d5314d6795f ("kdb: core for kgdb back end (1 of 2)") +Reviewed-by: Douglas Anderson +Link: https://lore.kernel.org/r/20240528121154.3662553-1-arnd@kernel.org +Signed-off-by: Daniel Thompson +Signed-off-by: Sasha Levin +--- + kernel/debug/kdb/kdb_io.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/kernel/debug/kdb/kdb_io.c b/kernel/debug/kdb/kdb_io.c +index a3b4b55d2e2e1..a4256e558a701 100644 +--- a/kernel/debug/kdb/kdb_io.c ++++ b/kernel/debug/kdb/kdb_io.c +@@ -358,7 +358,7 @@ static char *kdb_read(char *buffer, size_t bufsize) + if (i >= dtab_count) + kdb_printf("..."); + kdb_printf("\n"); +- kdb_printf(kdb_prompt_str); ++ kdb_printf("%s", kdb_prompt_str); + kdb_printf("%s", buffer); + if (cp != lastchar) + kdb_position_cursor(kdb_prompt_str, buffer, cp); +@@ -450,7 +450,7 @@ char *kdb_getstr(char *buffer, size_t bufsize, const char *prompt) + { + if (prompt && kdb_prompt_str != prompt) + strscpy(kdb_prompt_str, prompt, CMD_BUFLEN); +- kdb_printf(kdb_prompt_str); ++ kdb_printf("%s", kdb_prompt_str); + kdb_nextline = 1; /* Prompt and input resets line number */ + return kdb_read(buffer, bufsize); + } +-- +2.43.0 + diff --git a/queue-5.10/kdb-use-the-passed-prompt-in-kdb_position_cursor.patch b/queue-5.10/kdb-use-the-passed-prompt-in-kdb_position_cursor.patch new file mode 100644 index 00000000000..89975de0bbf --- /dev/null +++ b/queue-5.10/kdb-use-the-passed-prompt-in-kdb_position_cursor.patch @@ -0,0 +1,42 @@ +From 7e988a53073edec2600e8b37cbc4a4d27daf876b Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 28 May 2024 07:11:48 -0700 +Subject: kdb: Use the passed prompt in kdb_position_cursor() + +From: Douglas Anderson + +[ Upstream commit e2e821095949cde46256034975a90f88626a2a73 ] + +The function kdb_position_cursor() takes in a "prompt" parameter but +never uses it. This doesn't _really_ matter since all current callers +of the function pass the same value and it's a global variable, but +it's a bit ugly. Let's clean it up. + +Found by code inspection. This patch is expected to functionally be a +no-op. + +Fixes: 09b35989421d ("kdb: Use format-strings rather than '\0' injection in kdb_read()") +Signed-off-by: Douglas Anderson +Link: https://lore.kernel.org/r/20240528071144.1.I0feb49839c6b6f4f2c4bf34764f5e95de3f55a66@changeid +Signed-off-by: Daniel Thompson +Signed-off-by: Sasha Levin +--- + kernel/debug/kdb/kdb_io.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/kernel/debug/kdb/kdb_io.c b/kernel/debug/kdb/kdb_io.c +index a4256e558a701..b28b8a5ef6381 100644 +--- a/kernel/debug/kdb/kdb_io.c ++++ b/kernel/debug/kdb/kdb_io.c +@@ -194,7 +194,7 @@ char kdb_getchar(void) + */ + static void kdb_position_cursor(char *prompt, char *buffer, char *cp) + { +- kdb_printf("\r%s", kdb_prompt_str); ++ kdb_printf("\r%s", prompt); + if (cp > buffer) + kdb_printf("%.*s", (int)(cp - buffer), buffer); + } +-- +2.43.0 + diff --git a/queue-5.10/libbpf-fix-no-args-func-prototype-btf-dumping-syntax.patch b/queue-5.10/libbpf-fix-no-args-func-prototype-btf-dumping-syntax.patch new file mode 100644 index 00000000000..5e73232cff1 --- /dev/null +++ b/queue-5.10/libbpf-fix-no-args-func-prototype-btf-dumping-syntax.patch @@ -0,0 +1,96 @@ +From 62b3196bbfbef269c25f7ea2999a570d6f5831a0 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 12 Jul 2024 15:44:42 -0700 +Subject: libbpf: Fix no-args func prototype BTF dumping syntax + +From: Andrii Nakryiko + +[ Upstream commit 189f1a976e426011e6a5588f1d3ceedf71fe2965 ] + +For all these years libbpf's BTF dumper has been emitting not strictly +valid syntax for function prototypes that have no input arguments. + +Instead of `int (*blah)()` we should emit `int (*blah)(void)`. + +This is not normally a problem, but it manifests when we get kfuncs in +vmlinux.h that have no input arguments. Due to compiler internal +specifics, we get no BTF information for such kfuncs, if they are not +declared with proper `(void)`. + +The fix is trivial. We also need to adjust a few ancient tests that +happily assumed `()` is correct. + +Fixes: 351131b51c7a ("libbpf: add btf_dump API for BTF-to-C conversion") +Reported-by: Tejun Heo +Signed-off-by: Andrii Nakryiko +Signed-off-by: Daniel Borkmann +Acked-by: Stanislav Fomichev +Link: https://lore.kernel.org/bpf/20240712224442.282823-1-andrii@kernel.org +Signed-off-by: Sasha Levin +--- + tools/lib/bpf/btf_dump.c | 8 +++++--- + .../selftests/bpf/progs/btf_dump_test_case_multidim.c | 4 ++-- + .../selftests/bpf/progs/btf_dump_test_case_syntax.c | 4 ++-- + 3 files changed, 9 insertions(+), 7 deletions(-) + +diff --git a/tools/lib/bpf/btf_dump.c b/tools/lib/bpf/btf_dump.c +index 61aa2c47fbd5e..2342aec3c5a3e 100644 +--- a/tools/lib/bpf/btf_dump.c ++++ b/tools/lib/bpf/btf_dump.c +@@ -1426,10 +1426,12 @@ static void btf_dump_emit_type_chain(struct btf_dump *d, + * Clang for BPF target generates func_proto with no + * args as a func_proto with a single void arg (e.g., + * `int (*f)(void)` vs just `int (*f)()`). We are +- * going to pretend there are no args for such case. ++ * going to emit valid empty args (void) syntax for ++ * such case. Similarly and conveniently, valid ++ * no args case can be special-cased here as well. + */ +- if (vlen == 1 && p->type == 0) { +- btf_dump_printf(d, ")"); ++ if (vlen == 0 || (vlen == 1 && p->type == 0)) { ++ btf_dump_printf(d, "void)"); + return; + } + +diff --git a/tools/testing/selftests/bpf/progs/btf_dump_test_case_multidim.c b/tools/testing/selftests/bpf/progs/btf_dump_test_case_multidim.c +index ba97165bdb282..a657651eba523 100644 +--- a/tools/testing/selftests/bpf/progs/btf_dump_test_case_multidim.c ++++ b/tools/testing/selftests/bpf/progs/btf_dump_test_case_multidim.c +@@ -14,9 +14,9 @@ typedef int *ptr_arr_t[6]; + + typedef int *ptr_multiarr_t[7][8][9][10]; + +-typedef int * (*fn_ptr_arr_t[11])(); ++typedef int * (*fn_ptr_arr_t[11])(void); + +-typedef int * (*fn_ptr_multiarr_t[12][13])(); ++typedef int * (*fn_ptr_multiarr_t[12][13])(void); + + struct root_struct { + arr_t _1; +diff --git a/tools/testing/selftests/bpf/progs/btf_dump_test_case_syntax.c b/tools/testing/selftests/bpf/progs/btf_dump_test_case_syntax.c +index fe43556e1a611..956b24ce81456 100644 +--- a/tools/testing/selftests/bpf/progs/btf_dump_test_case_syntax.c ++++ b/tools/testing/selftests/bpf/progs/btf_dump_test_case_syntax.c +@@ -67,7 +67,7 @@ typedef void (*printf_fn_t)(const char *, ...); + * `int -> char *` function and returns pointer to a char. Equivalent: + * typedef char * (*fn_input_t)(int); + * typedef char * (*fn_output_outer_t)(fn_input_t); +- * typedef const fn_output_outer_t (* fn_output_inner_t)(); ++ * typedef const fn_output_outer_t (* fn_output_inner_t)(void); + * typedef const fn_output_inner_t fn_ptr_arr2_t[5]; + */ + /* ----- START-EXPECTED-OUTPUT ----- */ +@@ -94,7 +94,7 @@ typedef void (* (*signal_t)(int, void (*)(int)))(int); + + typedef char * (*fn_ptr_arr1_t[10])(int **); + +-typedef char * (* (* const fn_ptr_arr2_t[5])())(char * (*)(int)); ++typedef char * (* (* const fn_ptr_arr2_t[5])(void))(char * (*)(int)); + + struct struct_w_typedefs { + int_t a; +-- +2.43.0 + diff --git a/queue-5.10/lirc-rc_dev_get_from_fd-fix-file-leak.patch b/queue-5.10/lirc-rc_dev_get_from_fd-fix-file-leak.patch new file mode 100644 index 00000000000..67c9fa0f1e1 --- /dev/null +++ b/queue-5.10/lirc-rc_dev_get_from_fd-fix-file-leak.patch @@ -0,0 +1,37 @@ +From 08198aeda7b6d4068ca40e677806214baa6599d2 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 30 May 2024 23:58:26 -0400 +Subject: lirc: rc_dev_get_from_fd(): fix file leak + +From: Al Viro + +[ Upstream commit bba1f6758a9ec90c1adac5dcf78f8a15f1bad65b ] + +missing fdput() on a failure exit + +Fixes: 6a9d552483d50 "media: rc: bpf attach/detach requires write permission" # v6.9 +Signed-off-by: Al Viro +Signed-off-by: Sasha Levin +--- + drivers/media/rc/lirc_dev.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/drivers/media/rc/lirc_dev.c b/drivers/media/rc/lirc_dev.c +index 14243ce03b46e..c59601487334c 100644 +--- a/drivers/media/rc/lirc_dev.c ++++ b/drivers/media/rc/lirc_dev.c +@@ -840,8 +840,10 @@ struct rc_dev *rc_dev_get_from_fd(int fd, bool write) + return ERR_PTR(-EINVAL); + } + +- if (write && !(f.file->f_mode & FMODE_WRITE)) ++ if (write && !(f.file->f_mode & FMODE_WRITE)) { ++ fdput(f); + return ERR_PTR(-EPERM); ++ } + + fh = f.file->private_data; + dev = fh->rc; +-- +2.43.0 + diff --git a/queue-5.10/mips-smp-cps-fix-address-for-gcr_access-register-for.patch b/queue-5.10/mips-smp-cps-fix-address-for-gcr_access-register-for.patch new file mode 100644 index 00000000000..ef7fa26a1b8 --- /dev/null +++ b/queue-5.10/mips-smp-cps-fix-address-for-gcr_access-register-for.patch @@ -0,0 +1,66 @@ +From 8f0bb50cdaede0c697c2606eb080296d8d9c07d1 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 22 Jul 2024 15:15:39 +0200 +Subject: MIPS: SMP-CPS: Fix address for GCR_ACCESS register for CM3 and later + +From: Gregory CLEMENT + +[ Upstream commit a263e5f309f32301e1f3ad113293f4e68a82a646 ] + +When the CM block migrated from CM2.5 to CM3.0, the address offset for +the Global CSR Access Privilege register was modified. We saw this in +the "MIPS64 I6500 Multiprocessing System Programmer's Guide," it is +stated that "the Global CSR Access Privilege register is located at +offset 0x0120" in section 5.4. It is at least the same for I6400. + +This fix allows to use the VP cores in SMP mode if the reset values +were modified by the bootloader. + +Based on the work of Vladimir Kondratiev + and the feedback from Jiaxun Yang +. + +Fixes: 197e89e0984a ("MIPS: mips-cm: Implement mips_cm_revision") +Signed-off-by: Gregory CLEMENT +Reviewed-by: Jiaxun Yang +Signed-off-by: Thomas Bogendoerfer +Signed-off-by: Sasha Levin +--- + arch/mips/include/asm/mips-cm.h | 4 ++++ + arch/mips/kernel/smp-cps.c | 5 ++++- + 2 files changed, 8 insertions(+), 1 deletion(-) + +diff --git a/arch/mips/include/asm/mips-cm.h b/arch/mips/include/asm/mips-cm.h +index 23c67c0871b17..696b40beb774f 100644 +--- a/arch/mips/include/asm/mips-cm.h ++++ b/arch/mips/include/asm/mips-cm.h +@@ -228,6 +228,10 @@ GCR_ACCESSOR_RO(32, 0x0d0, gic_status) + GCR_ACCESSOR_RO(32, 0x0f0, cpc_status) + #define CM_GCR_CPC_STATUS_EX BIT(0) + ++/* GCR_ACCESS - Controls core/IOCU access to GCRs */ ++GCR_ACCESSOR_RW(32, 0x120, access_cm3) ++#define CM_GCR_ACCESS_ACCESSEN GENMASK(7, 0) ++ + /* GCR_L2_CONFIG - Indicates L2 cache configuration when Config5.L2C=1 */ + GCR_ACCESSOR_RW(32, 0x130, l2_config) + #define CM_GCR_L2_CONFIG_BYPASS BIT(20) +diff --git a/arch/mips/kernel/smp-cps.c b/arch/mips/kernel/smp-cps.c +index f659adb681bc3..02ae0b29e6888 100644 +--- a/arch/mips/kernel/smp-cps.c ++++ b/arch/mips/kernel/smp-cps.c +@@ -229,7 +229,10 @@ static void boot_core(unsigned int core, unsigned int vpe_id) + write_gcr_co_reset_ext_base(CM_GCR_Cx_RESET_EXT_BASE_UEB); + + /* Ensure the core can access the GCRs */ +- set_gcr_access(1 << core); ++ if (mips_cm_revision() < CM_REV_CM3) ++ set_gcr_access(1 << core); ++ else ++ set_gcr_access_cm3(1 << core); + + if (mips_cpc_present()) { + /* Reset the core */ +-- +2.43.0 + diff --git a/queue-5.10/misdn-fix-a-use-after-free-in-hfcmulti_tx.patch b/queue-5.10/misdn-fix-a-use-after-free-in-hfcmulti_tx.patch new file mode 100644 index 00000000000..39a04afdf3a --- /dev/null +++ b/queue-5.10/misdn-fix-a-use-after-free-in-hfcmulti_tx.patch @@ -0,0 +1,55 @@ +From 1f885b43c7b976c5332a77ac12b6baa5e39b08d6 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 24 Jul 2024 11:08:18 -0500 +Subject: mISDN: Fix a use after free in hfcmulti_tx() + +From: Dan Carpenter + +[ Upstream commit 61ab751451f5ebd0b98e02276a44e23a10110402 ] + +Don't dereference *sp after calling dev_kfree_skb(*sp). + +Fixes: af69fb3a8ffa ("Add mISDN HFC multiport driver") +Signed-off-by: Dan Carpenter +Reviewed-by: Simon Horman +Link: https://patch.msgid.link/8be65f5a-c2dd-4ba0-8a10-bfe5980b8cfb@stanley.mountain +Signed-off-by: Jakub Kicinski +Signed-off-by: Sasha Levin +--- + drivers/isdn/hardware/mISDN/hfcmulti.c | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +diff --git a/drivers/isdn/hardware/mISDN/hfcmulti.c b/drivers/isdn/hardware/mISDN/hfcmulti.c +index 4c5b6772562dc..a0697d64aab3c 100644 +--- a/drivers/isdn/hardware/mISDN/hfcmulti.c ++++ b/drivers/isdn/hardware/mISDN/hfcmulti.c +@@ -1931,7 +1931,7 @@ hfcmulti_dtmf(struct hfc_multi *hc) + static void + hfcmulti_tx(struct hfc_multi *hc, int ch) + { +- int i, ii, temp, len = 0; ++ int i, ii, temp, tmp_len, len = 0; + int Zspace, z1, z2; /* must be int for calculation */ + int Fspace, f1, f2; + u_char *d; +@@ -2152,14 +2152,15 @@ hfcmulti_tx(struct hfc_multi *hc, int ch) + HFC_wait_nodebug(hc); + } + ++ tmp_len = (*sp)->len; + dev_kfree_skb(*sp); + /* check for next frame */ + if (bch && get_next_bframe(bch)) { +- len = (*sp)->len; ++ len = tmp_len; + goto next_frame; + } + if (dch && get_next_dframe(dch)) { +- len = (*sp)->len; ++ len = tmp_len; + goto next_frame; + } + +-- +2.43.0 + diff --git a/queue-5.10/net-bonding-correctly-annotate-rcu-in-bond_should_no.patch b/queue-5.10/net-bonding-correctly-annotate-rcu-in-bond_should_no.patch new file mode 100644 index 00000000000..fb8b0906d73 --- /dev/null +++ b/queue-5.10/net-bonding-correctly-annotate-rcu-in-bond_should_no.patch @@ -0,0 +1,53 @@ +From 47bf163408382f75b3ae837fc8e106c89852c5bd Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 19 Jul 2024 09:41:18 -0700 +Subject: net: bonding: correctly annotate RCU in bond_should_notify_peers() + +From: Johannes Berg + +[ Upstream commit 3ba359c0cd6eb5ea772125a7aededb4a2d516684 ] + +RCU use in bond_should_notify_peers() looks wrong, since it does +rcu_dereference(), leaves the critical section, and uses the +pointer after that. + +Luckily, it's called either inside a nested RCU critical section +or with the RTNL held. + +Annotate it with rcu_dereference_rtnl() instead, and remove the +inner RCU critical section. + +Fixes: 4cb4f97b7e36 ("bonding: rebuild the lock use for bond_mii_monitor()") +Reviewed-by: Jiri Pirko +Signed-off-by: Johannes Berg +Acked-by: Jay Vosburgh +Link: https://patch.msgid.link/20240719094119.35c62455087d.I68eb9c0f02545b364b79a59f2110f2cf5682a8e2@changeid +Signed-off-by: Paolo Abeni +Signed-off-by: Sasha Levin +--- + drivers/net/bonding/bond_main.c | 7 ++----- + 1 file changed, 2 insertions(+), 5 deletions(-) + +diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c +index 50fabba042488..c07b9bac1a6a0 100644 +--- a/drivers/net/bonding/bond_main.c ++++ b/drivers/net/bonding/bond_main.c +@@ -1052,13 +1052,10 @@ static struct slave *bond_find_best_slave(struct bonding *bond) + return bestslave; + } + ++/* must be called in RCU critical section or with RTNL held */ + static bool bond_should_notify_peers(struct bonding *bond) + { +- struct slave *slave; +- +- rcu_read_lock(); +- slave = rcu_dereference(bond->curr_active_slave); +- rcu_read_unlock(); ++ struct slave *slave = rcu_dereference_rtnl(bond->curr_active_slave); + + if (!slave || !bond->send_peer_notif || + bond->send_peer_notif % +-- +2.43.0 + diff --git a/queue-5.10/net-nexthop-initialize-all-fields-in-dumped-nexthops.patch b/queue-5.10/net-nexthop-initialize-all-fields-in-dumped-nexthops.patch new file mode 100644 index 00000000000..fed8de13c1c --- /dev/null +++ b/queue-5.10/net-nexthop-initialize-all-fields-in-dumped-nexthops.patch @@ -0,0 +1,55 @@ +From baa8a08e2692d4cd28cfec8d581b2267808c5f99 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 23 Jul 2024 18:04:16 +0200 +Subject: net: nexthop: Initialize all fields in dumped nexthops + +From: Petr Machata + +[ Upstream commit 6d745cd0e9720282cd291d36b9db528aea18add2 ] + +struct nexthop_grp contains two reserved fields that are not initialized by +nla_put_nh_group(), and carry garbage. This can be observed e.g. with +strace (edited for clarity): + + # ip nexthop add id 1 dev lo + # ip nexthop add id 101 group 1 + # strace -e recvmsg ip nexthop get id 101 + ... + recvmsg(... [{nla_len=12, nla_type=NHA_GROUP}, + [{id=1, weight=0, resvd1=0x69, resvd2=0x67}]] ...) = 52 + +The fields are reserved and therefore not currently used. But as they are, they +leak kernel memory, and the fact they are not just zero complicates repurposing +of the fields for new ends. Initialize the full structure. + +Fixes: 430a049190de ("nexthop: Add support for nexthop groups") +Signed-off-by: Petr Machata +Reviewed-by: Ido Schimmel +Reviewed-by: Eric Dumazet +Signed-off-by: David S. Miller +Signed-off-by: Sasha Levin +--- + net/ipv4/nexthop.c | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +diff --git a/net/ipv4/nexthop.c b/net/ipv4/nexthop.c +index 7a0102a4b1de7..a508fd94b8be0 100644 +--- a/net/ipv4/nexthop.c ++++ b/net/ipv4/nexthop.c +@@ -210,9 +210,10 @@ static int nla_put_nh_group(struct sk_buff *skb, struct nh_group *nhg) + + p = nla_data(nla); + for (i = 0; i < nhg->num_nh; ++i) { +- p->id = nhg->nh_entries[i].nh->id; +- p->weight = nhg->nh_entries[i].weight - 1; +- p += 1; ++ *p++ = (struct nexthop_grp) { ++ .id = nhg->nh_entries[i].nh->id, ++ .weight = nhg->nh_entries[i].weight - 1, ++ }; + } + + return 0; +-- +2.43.0 + diff --git a/queue-5.10/net-stmmac-correct-byte-order-of-perfect_match.patch b/queue-5.10/net-stmmac-correct-byte-order-of-perfect_match.patch new file mode 100644 index 00000000000..6a2d31c64d9 --- /dev/null +++ b/queue-5.10/net-stmmac-correct-byte-order-of-perfect_match.patch @@ -0,0 +1,110 @@ +From ee0ab393545990568b7641b36024eae5873ce368 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 23 Jul 2024 14:29:27 +0100 +Subject: net: stmmac: Correct byte order of perfect_match + +From: Simon Horman + +[ Upstream commit e9dbebae2e3c338122716914fe105458f41e3a4a ] + +The perfect_match parameter of the update_vlan_hash operation is __le16, +and is correctly converted from host byte-order in the lone caller, +stmmac_vlan_update(). + +However, the implementations of this caller, dwxgmac2_update_vlan_hash() +and dwxgmac2_update_vlan_hash(), both treat this parameter as host byte +order, using the following pattern: + + u32 value = ... + ... + writel(value | perfect_match, ...); + +This is not correct because both: +1) value is host byte order; and +2) writel expects a host byte order value as it's first argument + +I believe that this will break on big endian systems. And I expect it +has gone unnoticed by only being exercised on little endian systems. + +The approach taken by this patch is to update the callback, and it's +caller to simply use a host byte order value. + +Flagged by Sparse. +Compile tested only. + +Fixes: c7ab0b8088d7 ("net: stmmac: Fallback to VLAN Perfect filtering if HASH is not available") +Signed-off-by: Simon Horman +Reviewed-by: Maxime Chevallier +Signed-off-by: David S. Miller +Signed-off-by: Sasha Levin +--- + drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 2 +- + drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c | 2 +- + drivers/net/ethernet/stmicro/stmmac/hwif.h | 2 +- + drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 ++-- + 4 files changed, 5 insertions(+), 5 deletions(-) + +diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +index 5c6073d95f023..c315e0605baa9 100644 +--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c ++++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +@@ -938,7 +938,7 @@ static void dwmac4_set_mac_loopback(void __iomem *ioaddr, bool enable) + } + + static void dwmac4_update_vlan_hash(struct mac_device_info *hw, u32 hash, +- __le16 perfect_match, bool is_double) ++ u16 perfect_match, bool is_double) + { + void __iomem *ioaddr = hw->pcsr; + u32 value; +diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c +index 86f70ea9a520c..357762ce23ff9 100644 +--- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c ++++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c +@@ -581,7 +581,7 @@ static int dwxgmac2_rss_configure(struct mac_device_info *hw, + } + + static void dwxgmac2_update_vlan_hash(struct mac_device_info *hw, u32 hash, +- __le16 perfect_match, bool is_double) ++ u16 perfect_match, bool is_double) + { + void __iomem *ioaddr = hw->pcsr; + +diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h +index 8b7ec2457eba2..d7ea2fd944ee6 100644 +--- a/drivers/net/ethernet/stmicro/stmmac/hwif.h ++++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h +@@ -368,7 +368,7 @@ struct stmmac_ops { + struct stmmac_rss *cfg, u32 num_rxq); + /* VLAN */ + void (*update_vlan_hash)(struct mac_device_info *hw, u32 hash, +- __le16 perfect_match, bool is_double); ++ u16 perfect_match, bool is_double); + void (*enable_vlan)(struct mac_device_info *hw, u32 type); + int (*add_hw_vlan_rx_fltr)(struct net_device *dev, + struct mac_device_info *hw, +diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +index 8416a186cd7f3..b8581a711514c 100644 +--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c ++++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +@@ -4660,7 +4660,7 @@ static u32 stmmac_vid_crc32_le(__le16 vid_le) + static int stmmac_vlan_update(struct stmmac_priv *priv, bool is_double) + { + u32 crc, hash = 0; +- __le16 pmatch = 0; ++ u16 pmatch = 0; + int count = 0; + u16 vid = 0; + +@@ -4675,7 +4675,7 @@ static int stmmac_vlan_update(struct stmmac_priv *priv, bool is_double) + if (count > 2) /* VID = 0 always passes filter */ + return -EOPNOTSUPP; + +- pmatch = cpu_to_le16(vid); ++ pmatch = vid; + hash = 0; + } + +-- +2.43.0 + diff --git a/queue-5.10/netfilter-nft_set_pipapo_avx2-disable-softinterrupts.patch b/queue-5.10/netfilter-nft_set_pipapo_avx2-disable-softinterrupts.patch new file mode 100644 index 00000000000..5d7ec25eb6e --- /dev/null +++ b/queue-5.10/netfilter-nft_set_pipapo_avx2-disable-softinterrupts.patch @@ -0,0 +1,71 @@ +From 24640af7ec36202c4089f149a4fd9a12241feba2 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 19 Jul 2024 13:19:26 +0200 +Subject: netfilter: nft_set_pipapo_avx2: disable softinterrupts + +From: Florian Westphal + +[ Upstream commit a16909ae9982e931841c456061cb57fbaec9c59e ] + +We need to disable softinterrupts, else we get following problem: + +1. pipapo_avx2 called from process context; fpu usable +2. preempt_disable() called, pcpu scratchmap in use +3. softirq handles rx or tx, we re-enter pipapo_avx2 +4. fpu busy, fallback to generic non-avx version +5. fallback reuses scratch map and index, which are in use + by the preempted process + +Handle this same way as generic version by first disabling +softinterrupts while the scratchmap is in use. + +Fixes: f0b3d338064e ("netfilter: nft_set_pipapo_avx2: Add irq_fpu_usable() check, fallback to non-AVX2 version") +Cc: Stefano Brivio +Signed-off-by: Florian Westphal +Reviewed-by: Stefano Brivio +Signed-off-by: Pablo Neira Ayuso +Signed-off-by: Sasha Levin +--- + net/netfilter/nft_set_pipapo_avx2.c | 12 ++++++++++-- + 1 file changed, 10 insertions(+), 2 deletions(-) + +diff --git a/net/netfilter/nft_set_pipapo_avx2.c b/net/netfilter/nft_set_pipapo_avx2.c +index 60fb8bc0fdcc9..13c7e22c93842 100644 +--- a/net/netfilter/nft_set_pipapo_avx2.c ++++ b/net/netfilter/nft_set_pipapo_avx2.c +@@ -1129,8 +1129,14 @@ bool nft_pipapo_avx2_lookup(const struct net *net, const struct nft_set *set, + bool map_index; + int i, ret = 0; + +- if (unlikely(!irq_fpu_usable())) +- return nft_pipapo_lookup(net, set, key, ext); ++ local_bh_disable(); ++ ++ if (unlikely(!irq_fpu_usable())) { ++ bool fallback_res = nft_pipapo_lookup(net, set, key, ext); ++ ++ local_bh_enable(); ++ return fallback_res; ++ } + + m = rcu_dereference(priv->match); + +@@ -1140,6 +1146,7 @@ bool nft_pipapo_avx2_lookup(const struct net *net, const struct nft_set *set, + scratch = *raw_cpu_ptr(m->scratch); + if (unlikely(!scratch)) { + kernel_fpu_end(); ++ local_bh_enable(); + return false; + } + +@@ -1220,6 +1227,7 @@ bool nft_pipapo_avx2_lookup(const struct net *net, const struct nft_set *set, + if (i % 2) + scratch->map_index = !map_index; + kernel_fpu_end(); ++ local_bh_enable(); + + return ret >= 0; + } +-- +2.43.0 + diff --git a/queue-5.10/nvme-pci-add-missing-condition-check-for-existence-o.patch b/queue-5.10/nvme-pci-add-missing-condition-check-for-existence-o.patch new file mode 100644 index 00000000000..c6036edd475 --- /dev/null +++ b/queue-5.10/nvme-pci-add-missing-condition-check-for-existence-o.patch @@ -0,0 +1,39 @@ +From 5c38c506494c91f2ed422c692367c63cda46fce6 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 24 Jul 2024 13:31:14 +0300 +Subject: nvme-pci: add missing condition check for existence of mapped data + +From: Leon Romanovsky + +[ Upstream commit c31fad1470389666ac7169fe43aa65bf5b7e2cfd ] + +nvme_map_data() is called when request has physical segments, hence +the nvme_unmap_data() should have same condition to avoid dereference. + +Fixes: 4aedb705437f ("nvme-pci: split metadata handling from nvme_map_data / nvme_unmap_data") +Signed-off-by: Leon Romanovsky +Reviewed-by: Christoph Hellwig +Reviewed-by: Nitesh Shetty +Signed-off-by: Keith Busch +Signed-off-by: Sasha Levin +--- + drivers/nvme/host/pci.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c +index 1436aee1f861d..4a4b7aa748354 100644 +--- a/drivers/nvme/host/pci.c ++++ b/drivers/nvme/host/pci.c +@@ -942,7 +942,8 @@ static blk_status_t nvme_queue_rq(struct blk_mq_hw_ctx *hctx, + spin_unlock(&nvmeq->sq_lock); + return BLK_STS_OK; + out_unmap_data: +- nvme_unmap_data(dev, req); ++ if (blk_rq_nr_phys_segments(req)) ++ nvme_unmap_data(dev, req); + out_free_cmd: + nvme_cleanup_cmd(req); + return ret; +-- +2.43.0 + diff --git a/queue-5.10/nvme-split-command-copy-into-a-helper.patch b/queue-5.10/nvme-split-command-copy-into-a-helper.patch new file mode 100644 index 00000000000..eaa63c8ddda --- /dev/null +++ b/queue-5.10/nvme-split-command-copy-into-a-helper.patch @@ -0,0 +1,81 @@ +From b8c6d6a18e6e0d7beb7df13aac6ff86879c47f88 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 29 Oct 2021 14:32:44 -0600 +Subject: nvme: split command copy into a helper + +From: Jens Axboe + +[ Upstream commit 3233b94cf842984ea7e208d5be1ad2f2af02d495 ] + +We'll need it for batched submit as well. Since we now have a copy +helper, get rid of the nvme_submit_cmd() wrapper. + +Reviewed-by: Chaitanya Kulkarni +Reviewed-by: Hannes Reinecke +Reviewed-by: Max Gurtovoy +Reviewed-by: Christoph Hellwig +Signed-off-by: Jens Axboe +Stable-dep-of: c31fad147038 ("nvme-pci: add missing condition check for existence of mapped data") +Signed-off-by: Sasha Levin +--- + drivers/nvme/host/pci.c | 26 ++++++++++++-------------- + 1 file changed, 12 insertions(+), 14 deletions(-) + +diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c +index a7131f4752e28..1436aee1f861d 100644 +--- a/drivers/nvme/host/pci.c ++++ b/drivers/nvme/host/pci.c +@@ -486,22 +486,13 @@ static inline void nvme_write_sq_db(struct nvme_queue *nvmeq, bool write_sq) + nvmeq->last_sq_tail = nvmeq->sq_tail; + } + +-/** +- * nvme_submit_cmd() - Copy a command into a queue and ring the doorbell +- * @nvmeq: The queue to use +- * @cmd: The command to send +- * @write_sq: whether to write to the SQ doorbell +- */ +-static void nvme_submit_cmd(struct nvme_queue *nvmeq, struct nvme_command *cmd, +- bool write_sq) ++static inline void nvme_sq_copy_cmd(struct nvme_queue *nvmeq, ++ struct nvme_command *cmd) + { +- spin_lock(&nvmeq->sq_lock); + memcpy(nvmeq->sq_cmds + (nvmeq->sq_tail << nvmeq->sqes), +- cmd, sizeof(*cmd)); ++ absolute_pointer(cmd), sizeof(*cmd)); + if (++nvmeq->sq_tail == nvmeq->q_depth) + nvmeq->sq_tail = 0; +- nvme_write_sq_db(nvmeq, write_sq); +- spin_unlock(&nvmeq->sq_lock); + } + + static void nvme_commit_rqs(struct blk_mq_hw_ctx *hctx) +@@ -945,7 +936,10 @@ static blk_status_t nvme_queue_rq(struct blk_mq_hw_ctx *hctx, + } + + blk_mq_start_request(req); +- nvme_submit_cmd(nvmeq, cmnd, bd->last); ++ spin_lock(&nvmeq->sq_lock); ++ nvme_sq_copy_cmd(nvmeq, &iod->cmd); ++ nvme_write_sq_db(nvmeq, bd->last); ++ spin_unlock(&nvmeq->sq_lock); + return BLK_STS_OK; + out_unmap_data: + nvme_unmap_data(dev, req); +@@ -1120,7 +1114,11 @@ static void nvme_pci_submit_async_event(struct nvme_ctrl *ctrl) + memset(&c, 0, sizeof(c)); + c.common.opcode = nvme_admin_async_event; + c.common.command_id = NVME_AQ_BLK_MQ_DEPTH; +- nvme_submit_cmd(nvmeq, &c, true); ++ ++ spin_lock(&nvmeq->sq_lock); ++ nvme_sq_copy_cmd(nvmeq, &c); ++ nvme_write_sq_db(nvmeq, true); ++ spin_unlock(&nvmeq->sq_lock); + } + + static int adapter_delete_queue(struct nvme_dev *dev, u8 opcode, u16 id) +-- +2.43.0 + diff --git a/queue-5.10/powerpc-fix-a-file-leak-in-kvm_vcpu_ioctl_enable_cap.patch b/queue-5.10/powerpc-fix-a-file-leak-in-kvm_vcpu_ioctl_enable_cap.patch new file mode 100644 index 00000000000..3c653685c8c --- /dev/null +++ b/queue-5.10/powerpc-fix-a-file-leak-in-kvm_vcpu_ioctl_enable_cap.patch @@ -0,0 +1,37 @@ +From cf12ba4b23a382302f43ff3447ed4e1de61aada1 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 30 May 2024 23:54:55 -0400 +Subject: powerpc: fix a file leak in kvm_vcpu_ioctl_enable_cap() + +From: Al Viro + +[ Upstream commit b4cf5fc01ce83e5c0bcf3dbb9f929428646b9098 ] + +missing fdput() on one of the failure exits + +Fixes: eacc56bb9de3e # v5.2 +Signed-off-by: Al Viro +Signed-off-by: Sasha Levin +--- + arch/powerpc/kvm/powerpc.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c +index ef8077a739b88..0f5ebec660a78 100644 +--- a/arch/powerpc/kvm/powerpc.c ++++ b/arch/powerpc/kvm/powerpc.c +@@ -1956,8 +1956,10 @@ static int kvm_vcpu_ioctl_enable_cap(struct kvm_vcpu *vcpu, + break; + + r = -ENXIO; +- if (!xive_enabled()) ++ if (!xive_enabled()) { ++ fdput(f); + break; ++ } + + r = -EPERM; + dev = kvm_device_from_filp(f.file); +-- +2.43.0 + diff --git a/queue-5.10/s390-pci-allow-allocation-of-more-than-1-msi-interru.patch b/queue-5.10/s390-pci-allow-allocation-of-more-than-1-msi-interru.patch new file mode 100644 index 00000000000..1e8df0ebb4e --- /dev/null +++ b/queue-5.10/s390-pci-allow-allocation-of-more-than-1-msi-interru.patch @@ -0,0 +1,170 @@ +From c26c953fc6df0ce006d600b53b9bee728af3be83 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 11 Jul 2024 15:45:27 +0200 +Subject: s390/pci: Allow allocation of more than 1 MSI interrupt + +From: Gerd Bayer + +[ Upstream commit ab42fcb511fd9d241bbab7cc3ca04e34e9fc0666 ] + +On a PCI adapter that provides up to 8 MSI interrupt sources the s390 +implementation of PCI interrupts rejected to accommodate them, although +the underlying hardware is able to support that. + +For MSI-X it is sufficient to allocate a single irq_desc per msi_desc, +but for MSI multiple irq descriptors are attached to and controlled by +a single msi descriptor. Add the appropriate loops to maintain multiple +irq descriptors and tie/untie them to/from the appropriate AIBV bit, if +a device driver allocates more than 1 MSI interrupt. + +Common PCI code passes on requests to allocate a number of interrupt +vectors based on the device drivers' demand and the PCI functions' +capabilities. However, the root-complex of s390 systems support just a +limited number of interrupt vectors per PCI function. +Produce a kernel log message to inform about any architecture-specific +capping that might be done. + +With this change, we had a PCI adapter successfully raising +interrupts to its device driver via all 8 sources. + +Fixes: a384c8924a8b ("s390/PCI: Fix single MSI only check") +Signed-off-by: Gerd Bayer +Reviewed-by: Niklas Schnelle +Signed-off-by: Vasily Gorbik +Signed-off-by: Sasha Levin +--- + arch/s390/pci/pci_irq.c | 62 ++++++++++++++++++++++++++++------------- + 1 file changed, 42 insertions(+), 20 deletions(-) + +diff --git a/arch/s390/pci/pci_irq.c b/arch/s390/pci/pci_irq.c +index b36f5ef34a6c1..690f6999287bc 100644 +--- a/arch/s390/pci/pci_irq.c ++++ b/arch/s390/pci/pci_irq.c +@@ -262,8 +262,8 @@ static int __alloc_airq(struct zpci_dev *zdev, int msi_vecs, + + int arch_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type) + { ++ unsigned int hwirq, msi_vecs, irqs_per_msi, i, cpu; + struct zpci_dev *zdev = to_zpci(pdev); +- unsigned int hwirq, msi_vecs, cpu; + struct msi_desc *msi; + struct msi_msg msg; + unsigned long bit; +@@ -273,30 +273,46 @@ int arch_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type) + zdev->aisb = -1UL; + zdev->msi_first_bit = -1U; + +- if (type == PCI_CAP_ID_MSI && nvec > 1) +- return 1; + msi_vecs = min_t(unsigned int, nvec, zdev->max_msi); ++ if (msi_vecs < nvec) { ++ pr_info("%s requested %d irqs, allocate system limit of %d", ++ pci_name(pdev), nvec, zdev->max_msi); ++ } + + rc = __alloc_airq(zdev, msi_vecs, &bit); + if (rc < 0) + return rc; + +- /* Request MSI interrupts */ ++ /* ++ * Request MSI interrupts: ++ * When using MSI, nvec_used interrupt sources and their irq ++ * descriptors are controlled through one msi descriptor. ++ * Thus the outer loop over msi descriptors shall run only once, ++ * while two inner loops iterate over the interrupt vectors. ++ * When using MSI-X, each interrupt vector/irq descriptor ++ * is bound to exactly one msi descriptor (nvec_used is one). ++ * So the inner loops are executed once, while the outer iterates ++ * over the MSI-X descriptors. ++ */ + hwirq = bit; + msi_for_each_desc(msi, &pdev->dev, MSI_DESC_NOTASSOCIATED) { +- rc = -EIO; + if (hwirq - bit >= msi_vecs) + break; +- irq = __irq_alloc_descs(-1, 0, 1, 0, THIS_MODULE, +- (irq_delivery == DIRECTED) ? +- msi->affinity : NULL); ++ irqs_per_msi = min_t(unsigned int, msi_vecs, msi->nvec_used); ++ irq = __irq_alloc_descs(-1, 0, irqs_per_msi, 0, THIS_MODULE, ++ (irq_delivery == DIRECTED) ? ++ msi->affinity : NULL); + if (irq < 0) + return -ENOMEM; +- rc = irq_set_msi_desc(irq, msi); +- if (rc) +- return rc; +- irq_set_chip_and_handler(irq, &zpci_irq_chip, +- handle_percpu_irq); ++ ++ for (i = 0; i < irqs_per_msi; i++) { ++ rc = irq_set_msi_desc_off(irq, i, msi); ++ if (rc) ++ return rc; ++ irq_set_chip_and_handler(irq + i, &zpci_irq_chip, ++ handle_percpu_irq); ++ } ++ + msg.data = hwirq - bit; + if (irq_delivery == DIRECTED) { + if (msi->affinity) +@@ -309,19 +325,22 @@ int arch_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type) + msg.address_lo |= (cpu_addr << 8); + + for_each_possible_cpu(cpu) { +- airq_iv_set_data(zpci_ibv[cpu], hwirq, irq); ++ for (i = 0; i < irqs_per_msi; i++) ++ airq_iv_set_data(zpci_ibv[cpu], ++ hwirq + i, irq + i); + } + } else { + msg.address_lo = zdev->msi_addr & 0xffffffff; +- airq_iv_set_data(zdev->aibv, hwirq, irq); ++ for (i = 0; i < irqs_per_msi; i++) ++ airq_iv_set_data(zdev->aibv, hwirq + i, irq + i); + } + msg.address_hi = zdev->msi_addr >> 32; + pci_write_msi_msg(irq, &msg); +- hwirq++; ++ hwirq += irqs_per_msi; + } + + zdev->msi_first_bit = bit; +- zdev->msi_nr_irqs = msi_vecs; ++ zdev->msi_nr_irqs = hwirq - bit; + + if (irq_delivery == DIRECTED) + rc = zpci_set_directed_irq(zdev); +@@ -330,13 +349,14 @@ int arch_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type) + if (rc) + return rc; + +- return (msi_vecs == nvec) ? 0 : msi_vecs; ++ return (zdev->msi_nr_irqs == nvec) ? 0 : zdev->msi_nr_irqs; + } + + void arch_teardown_msi_irqs(struct pci_dev *pdev) + { + struct zpci_dev *zdev = to_zpci(pdev); + struct msi_desc *msi; ++ unsigned int i; + int rc; + + /* Disable interrupts */ +@@ -349,8 +369,10 @@ void arch_teardown_msi_irqs(struct pci_dev *pdev) + + /* Release MSI interrupts */ + msi_for_each_desc(msi, &pdev->dev, MSI_DESC_ASSOCIATED) { +- irq_set_msi_desc(msi->irq, NULL); +- irq_free_desc(msi->irq); ++ for (i = 0; i < msi->nvec_used; i++) { ++ irq_set_msi_desc(msi->irq + i, NULL); ++ irq_free_desc(msi->irq + i); ++ } + msi->msg.address_lo = 0; + msi->msg.address_hi = 0; + msi->msg.data = 0; +-- +2.43.0 + diff --git a/queue-5.10/s390-pci-do-not-mask-msi-x-entries-on-teardown.patch b/queue-5.10/s390-pci-do-not-mask-msi-x-entries-on-teardown.patch new file mode 100644 index 00000000000..290abf2d0e2 --- /dev/null +++ b/queue-5.10/s390-pci-do-not-mask-msi-x-entries-on-teardown.patch @@ -0,0 +1,83 @@ +From 7cbb9a9ab70f146b53b00446a761930c412745a1 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 29 Jul 2021 23:51:51 +0200 +Subject: s390/pci: Do not mask MSI[-X] entries on teardown + +From: Thomas Gleixner + +[ Upstream commit 3998527d2e3ee2bfdf710a45b7b90968ff87babc ] + +The PCI core already ensures that the MSI[-X] state is correct when MSI[-X] +is disabled. For MSI the reset state is all entries unmasked and for MSI-X +all vectors are masked. + +S390 masks all MSI entries and masks the already masked MSI-X entries +again. Remove it and let the device in the correct state. + +Signed-off-by: Thomas Gleixner +Tested-by: Niklas Schnelle +Tested-by: Marc Zyngier +Reviewed-by: Marc Zyngier +Acked-by: Niklas Schnelle +Link: https://lore.kernel.org/r/20210729222542.939798136@linutronix.de +Stable-dep-of: ab42fcb511fd ("s390/pci: Allow allocation of more than 1 MSI interrupt") +Signed-off-by: Sasha Levin +--- + arch/s390/pci/pci_irq.c | 4 ---- + drivers/pci/msi.c | 4 ++-- + include/linux/msi.h | 2 -- + 3 files changed, 2 insertions(+), 8 deletions(-) + +diff --git a/arch/s390/pci/pci_irq.c b/arch/s390/pci/pci_irq.c +index 75217fb63d7b3..5036e00b7ec1b 100644 +--- a/arch/s390/pci/pci_irq.c ++++ b/arch/s390/pci/pci_irq.c +@@ -341,10 +341,6 @@ void arch_teardown_msi_irqs(struct pci_dev *pdev) + for_each_pci_msi_entry(msi, pdev) { + if (!msi->irq) + continue; +- if (msi->msi_attrib.is_msix) +- __pci_msix_desc_mask_irq(msi, 1); +- else +- __pci_msi_desc_mask_irq(msi, 1, 1); + irq_set_msi_desc(msi->irq, NULL); + irq_free_desc(msi->irq); + msi->msg.address_lo = 0; +diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c +index 27377f2f9e84b..935969ea3ea07 100644 +--- a/drivers/pci/msi.c ++++ b/drivers/pci/msi.c +@@ -171,7 +171,7 @@ static inline __attribute_const__ u32 msi_mask(unsigned x) + * reliably as devices without an INTx disable bit will then generate a + * level IRQ which will never be cleared. + */ +-void __pci_msi_desc_mask_irq(struct msi_desc *desc, u32 mask, u32 flag) ++static void __pci_msi_desc_mask_irq(struct msi_desc *desc, u32 mask, u32 flag) + { + raw_spinlock_t *lock = &desc->dev->msi_lock; + unsigned long flags; +@@ -208,7 +208,7 @@ static void __iomem *pci_msix_desc_addr(struct msi_desc *desc) + * file. This saves a few milliseconds when initialising devices with lots + * of MSI-X interrupts. + */ +-u32 __pci_msix_desc_mask_irq(struct msi_desc *desc, u32 flag) ++static u32 __pci_msix_desc_mask_irq(struct msi_desc *desc, u32 flag) + { + u32 mask_bits = desc->masked; + void __iomem *desc_addr; +diff --git a/include/linux/msi.h b/include/linux/msi.h +index 70c910b23e131..8647f5f214297 100644 +--- a/include/linux/msi.h ++++ b/include/linux/msi.h +@@ -193,8 +193,6 @@ void free_msi_entry(struct msi_desc *entry); + void __pci_read_msi_msg(struct msi_desc *entry, struct msi_msg *msg); + void __pci_write_msi_msg(struct msi_desc *entry, struct msi_msg *msg); + +-u32 __pci_msix_desc_mask_irq(struct msi_desc *desc, u32 flag); +-void __pci_msi_desc_mask_irq(struct msi_desc *desc, u32 mask, u32 flag); + void pci_msi_mask_irq(struct irq_data *data); + void pci_msi_unmask_irq(struct irq_data *data); + +-- +2.43.0 + diff --git a/queue-5.10/s390-pci-refactor-arch_setup_msi_irqs.patch b/queue-5.10/s390-pci-refactor-arch_setup_msi_irqs.patch new file mode 100644 index 00000000000..595efb25ee7 --- /dev/null +++ b/queue-5.10/s390-pci-refactor-arch_setup_msi_irqs.patch @@ -0,0 +1,106 @@ +From 3cfd2896b57bc84076e6027d9bb481a6356f4066 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 11 Jul 2024 15:45:26 +0200 +Subject: s390/pci: Refactor arch_setup_msi_irqs() + +From: Gerd Bayer + +[ Upstream commit 5fd11b96b43708f2f6e3964412c301c1bd20ec0f ] + +Factor out adapter interrupt allocation from arch_setup_msi_irqs() in +preparation for enabling registration of multiple MSIs. Code movement +only, no change of functionality intended. + +Signed-off-by: Gerd Bayer +Reviewed-by: Niklas Schnelle +Signed-off-by: Vasily Gorbik +Stable-dep-of: ab42fcb511fd ("s390/pci: Allow allocation of more than 1 MSI interrupt") +Signed-off-by: Sasha Levin +--- + arch/s390/pci/pci_irq.c | 54 ++++++++++++++++++++++++----------------- + 1 file changed, 32 insertions(+), 22 deletions(-) + +diff --git a/arch/s390/pci/pci_irq.c b/arch/s390/pci/pci_irq.c +index 9ed76fa9391cb..b36f5ef34a6c1 100644 +--- a/arch/s390/pci/pci_irq.c ++++ b/arch/s390/pci/pci_irq.c +@@ -232,33 +232,20 @@ static void zpci_floating_irq_handler(struct airq_struct *airq, bool floating) + } + } + +-int arch_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type) ++static int __alloc_airq(struct zpci_dev *zdev, int msi_vecs, ++ unsigned long *bit) + { +- struct zpci_dev *zdev = to_zpci(pdev); +- unsigned int hwirq, msi_vecs, cpu; +- unsigned long bit; +- struct msi_desc *msi; +- struct msi_msg msg; +- int cpu_addr; +- int rc, irq; +- +- zdev->aisb = -1UL; +- zdev->msi_first_bit = -1U; +- if (type == PCI_CAP_ID_MSI && nvec > 1) +- return 1; +- msi_vecs = min_t(unsigned int, nvec, zdev->max_msi); +- + if (irq_delivery == DIRECTED) { + /* Allocate cpu vector bits */ +- bit = airq_iv_alloc(zpci_ibv[0], msi_vecs); +- if (bit == -1UL) ++ *bit = airq_iv_alloc(zpci_ibv[0], msi_vecs); ++ if (*bit == -1UL) + return -EIO; + } else { + /* Allocate adapter summary indicator bit */ +- bit = airq_iv_alloc_bit(zpci_sbv); +- if (bit == -1UL) ++ *bit = airq_iv_alloc_bit(zpci_sbv); ++ if (*bit == -1UL) + return -EIO; +- zdev->aisb = bit; ++ zdev->aisb = *bit; + + /* Create adapter interrupt vector */ + zdev->aibv = airq_iv_create(msi_vecs, AIRQ_IV_DATA | AIRQ_IV_BITLOCK); +@@ -266,10 +253,33 @@ int arch_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type) + return -ENOMEM; + + /* Wire up shortcut pointer */ +- zpci_ibv[bit] = zdev->aibv; ++ zpci_ibv[*bit] = zdev->aibv; + /* Each function has its own interrupt vector */ +- bit = 0; ++ *bit = 0; + } ++ return 0; ++} ++ ++int arch_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type) ++{ ++ struct zpci_dev *zdev = to_zpci(pdev); ++ unsigned int hwirq, msi_vecs, cpu; ++ struct msi_desc *msi; ++ struct msi_msg msg; ++ unsigned long bit; ++ int cpu_addr; ++ int rc, irq; ++ ++ zdev->aisb = -1UL; ++ zdev->msi_first_bit = -1U; ++ ++ if (type == PCI_CAP_ID_MSI && nvec > 1) ++ return 1; ++ msi_vecs = min_t(unsigned int, nvec, zdev->max_msi); ++ ++ rc = __alloc_airq(zdev, msi_vecs, &bit); ++ if (rc < 0) ++ return rc; + + /* Request MSI interrupts */ + hwirq = bit; +-- +2.43.0 + diff --git a/queue-5.10/s390-pci-rework-msi-descriptor-walk.patch b/queue-5.10/s390-pci-rework-msi-descriptor-walk.patch new file mode 100644 index 00000000000..c4b5402b823 --- /dev/null +++ b/queue-5.10/s390-pci-rework-msi-descriptor-walk.patch @@ -0,0 +1,49 @@ +From f0f721e12908a17446ff1fcb546c6516d06b6ba8 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 6 Dec 2021 23:51:23 +0100 +Subject: s390/pci: Rework MSI descriptor walk + +From: Thomas Gleixner + +[ Upstream commit 2ca5e908d0f4cde61d9d3595e8314adca5d914a1 ] + +Replace the about to vanish iterators and make use of the filtering. + +Signed-off-by: Thomas Gleixner +Tested-by: Niklas Schnelle +Reviewed-by: Jason Gunthorpe +Acked-by: Niklas Schnelle +Link: https://lore.kernel.org/r/20211206210748.305656158@linutronix.de +Stable-dep-of: ab42fcb511fd ("s390/pci: Allow allocation of more than 1 MSI interrupt") +Signed-off-by: Sasha Levin +--- + arch/s390/pci/pci_irq.c | 6 ++---- + 1 file changed, 2 insertions(+), 4 deletions(-) + +diff --git a/arch/s390/pci/pci_irq.c b/arch/s390/pci/pci_irq.c +index 5036e00b7ec1b..9ed76fa9391cb 100644 +--- a/arch/s390/pci/pci_irq.c ++++ b/arch/s390/pci/pci_irq.c +@@ -273,7 +273,7 @@ int arch_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type) + + /* Request MSI interrupts */ + hwirq = bit; +- for_each_pci_msi_entry(msi, pdev) { ++ msi_for_each_desc(msi, &pdev->dev, MSI_DESC_NOTASSOCIATED) { + rc = -EIO; + if (hwirq - bit >= msi_vecs) + break; +@@ -338,9 +338,7 @@ void arch_teardown_msi_irqs(struct pci_dev *pdev) + return; + + /* Release MSI interrupts */ +- for_each_pci_msi_entry(msi, pdev) { +- if (!msi->irq) +- continue; ++ msi_for_each_desc(msi, &pdev->dev, MSI_DESC_ASSOCIATED) { + irq_set_msi_desc(msi->irq, NULL); + irq_free_desc(msi->irq); + msi->msg.address_lo = 0; +-- +2.43.0 + diff --git a/queue-5.10/series b/queue-5.10/series index 06fb86f30b1..2ae838bc315 100644 --- a/queue-5.10/series +++ b/queue-5.10/series @@ -186,3 +186,31 @@ bluetooth-btusb-add-realtek-rtl8852be-support-id-0x13d3-0x3591.patch nilfs2-handle-inconsistent-state-in-nilfs_btnode_create_block.patch io_uring-io-wq-limit-retrying-worker-initialisation.patch kernel-rerun-task_work-while-freezing-in-get_signal.patch +kdb-address-wformat-security-warnings.patch +kdb-use-the-passed-prompt-in-kdb_position_cursor.patch +jfs-fix-array-index-out-of-bounds-in-difree.patch +um-time-travel-fix-time-travel-start-option.patch +f2fs-fix-start-segno-of-large-section.patch +libbpf-fix-no-args-func-prototype-btf-dumping-syntax.patch +dma-fix-call-order-in-dmam_free_coherent.patch +mips-smp-cps-fix-address-for-gcr_access-register-for.patch +ipv4-fix-incorrect-source-address-in-record-route-op.patch +net-bonding-correctly-annotate-rcu-in-bond_should_no.patch +netfilter-nft_set_pipapo_avx2-disable-softinterrupts.patch +tipc-return-non-zero-value-from-tipc_udp_addr2str-on.patch +net-stmmac-correct-byte-order-of-perfect_match.patch +net-nexthop-initialize-all-fields-in-dumped-nexthops.patch +bpf-fix-a-segment-issue-when-downgrading-gso_size.patch +misdn-fix-a-use-after-free-in-hfcmulti_tx.patch +apparmor-fix-null-pointer-deref-when-receiving-skb-d.patch +powerpc-fix-a-file-leak-in-kvm_vcpu_ioctl_enable_cap.patch +lirc-rc_dev_get_from_fd-fix-file-leak.patch +asoc-intel-use-soc_intel_is_byt_cr-only-when-iosf_mb.patch +ceph-fix-incorrect-kmalloc-size-of-pagevec-mempool.patch +s390-pci-do-not-mask-msi-x-entries-on-teardown.patch +s390-pci-rework-msi-descriptor-walk.patch +s390-pci-refactor-arch_setup_msi_irqs.patch +s390-pci-allow-allocation-of-more-than-1-msi-interru.patch +nvme-split-command-copy-into-a-helper.patch +nvme-pci-add-missing-condition-check-for-existence-o.patch +fs-don-t-allow-non-init-s_user_ns-for-filesystems-wi.patch diff --git a/queue-5.10/tipc-return-non-zero-value-from-tipc_udp_addr2str-on.patch b/queue-5.10/tipc-return-non-zero-value-from-tipc_udp_addr2str-on.patch new file mode 100644 index 00000000000..f20eb52215d --- /dev/null +++ b/queue-5.10/tipc-return-non-zero-value-from-tipc_udp_addr2str-on.patch @@ -0,0 +1,43 @@ +From a8ac0c889c6b7016c98d1a7316775cbc152a51df Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 16 Jul 2024 11:09:05 +0900 +Subject: tipc: Return non-zero value from tipc_udp_addr2str() on error + +From: Shigeru Yoshida + +[ Upstream commit fa96c6baef1b5385e2f0c0677b32b3839e716076 ] + +tipc_udp_addr2str() should return non-zero value if the UDP media +address is invalid. Otherwise, a buffer overflow access can occur in +tipc_media_addr_printf(). Fix this by returning 1 on an invalid UDP +media address. + +Fixes: d0f91938bede ("tipc: add ip/udp media type") +Signed-off-by: Shigeru Yoshida +Reviewed-by: Tung Nguyen +Signed-off-by: David S. Miller +Signed-off-by: Sasha Levin +--- + net/tipc/udp_media.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/net/tipc/udp_media.c b/net/tipc/udp_media.c +index 3e47501f024fd..ec6d7730b8522 100644 +--- a/net/tipc/udp_media.c ++++ b/net/tipc/udp_media.c +@@ -129,8 +129,11 @@ static int tipc_udp_addr2str(struct tipc_media_addr *a, char *buf, int size) + snprintf(buf, size, "%pI4:%u", &ua->ipv4, ntohs(ua->port)); + else if (ntohs(ua->proto) == ETH_P_IPV6) + snprintf(buf, size, "%pI6:%u", &ua->ipv6, ntohs(ua->port)); +- else ++ else { + pr_err("Invalid UDP media address\n"); ++ return 1; ++ } ++ + return 0; + } + +-- +2.43.0 + diff --git a/queue-5.10/um-time-travel-fix-time-travel-start-option.patch b/queue-5.10/um-time-travel-fix-time-travel-start-option.patch new file mode 100644 index 00000000000..2d396863ad3 --- /dev/null +++ b/queue-5.10/um-time-travel-fix-time-travel-start-option.patch @@ -0,0 +1,40 @@ +From 3e612270b86b04669b9fd63e539dbbabdfc6a5b9 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 17 Apr 2024 10:27:45 +0200 +Subject: um: time-travel: fix time-travel-start option + +From: Johannes Berg + +[ Upstream commit 7d0a8a490aa3a2a82de8826aaf1dfa38575cb77a ] + +We need to have the = as part of the option so that the +value can be parsed properly. Also document that it must +be given in nanoseconds, not seconds. + +Fixes: 065038706f77 ("um: Support time travel mode") +Link: https://patch.msgid.link/20240417102744.14b9a9d4eba0.Ib22e9136513126b2099d932650f55f193120cd97@changeid +Signed-off-by: Johannes Berg +Signed-off-by: Sasha Levin +--- + arch/um/kernel/time.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/arch/um/kernel/time.c b/arch/um/kernel/time.c +index 8dafc3f2add42..9a0fcafafd00b 100644 +--- a/arch/um/kernel/time.c ++++ b/arch/um/kernel/time.c +@@ -756,9 +756,9 @@ int setup_time_travel_start(char *str) + return 1; + } + +-__setup("time-travel-start", setup_time_travel_start); ++__setup("time-travel-start=", setup_time_travel_start); + __uml_help(setup_time_travel_start, +-"time-travel-start=\n" ++"time-travel-start=\n" + "Configure the UML instance's wall clock to start at this value rather than\n" + "the host's wall clock at the time of UML boot.\n"); + #endif +-- +2.43.0 +