From: Greg Kroah-Hartman Date: Mon, 22 May 2023 18:08:01 +0000 (+0100) Subject: 5.15-stable patches X-Git-Tag: v6.3.4~19 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0676759701f7f32b41f765b017c0e6bdc23b30f5;p=thirdparty%2Fkernel%2Fstable-queue.git 5.15-stable patches added patches: nilfs2-fix-use-after-free-bug-of-nilfs_root-in-nilfs_evict_inode.patch powerpc-64s-radix-fix-soft-dirty-tracking.patch powerpc-iommu-incorrect-ddw-table-is-referenced-for-sr-iov-device.patch s390-qdio-fix-do_sqbs-inline-assembly-constraint.patch tpm-tpm_tis-disable-interrupts-for-more-lenovo-devices.patch --- diff --git a/queue-5.15/nilfs2-fix-use-after-free-bug-of-nilfs_root-in-nilfs_evict_inode.patch b/queue-5.15/nilfs2-fix-use-after-free-bug-of-nilfs_root-in-nilfs_evict_inode.patch new file mode 100644 index 00000000000..57cc39839cf --- /dev/null +++ b/queue-5.15/nilfs2-fix-use-after-free-bug-of-nilfs_root-in-nilfs_evict_inode.patch @@ -0,0 +1,65 @@ +From 9b5a04ac3ad9898c4745cba46ea26de74ba56a8e Mon Sep 17 00:00:00 2001 +From: Ryusuke Konishi +Date: Wed, 10 May 2023 00:29:56 +0900 +Subject: nilfs2: fix use-after-free bug of nilfs_root in nilfs_evict_inode() + +From: Ryusuke Konishi + +commit 9b5a04ac3ad9898c4745cba46ea26de74ba56a8e upstream. + +During unmount process of nilfs2, nothing holds nilfs_root structure after +nilfs2 detaches its writer in nilfs_detach_log_writer(). However, since +nilfs_evict_inode() uses nilfs_root for some cleanup operations, it may +cause use-after-free read if inodes are left in "garbage_list" and +released by nilfs_dispose_list() at the end of nilfs_detach_log_writer(). + +Fix this issue by modifying nilfs_evict_inode() to only clear inode +without additional metadata changes that use nilfs_root if the file system +is degraded to read-only or the writer is detached. + +Link: https://lkml.kernel.org/r/20230509152956.8313-1-konishi.ryusuke@gmail.com +Signed-off-by: Ryusuke Konishi +Reported-by: syzbot+78d4495558999f55d1da@syzkaller.appspotmail.com +Closes: https://lkml.kernel.org/r/00000000000099e5ac05fb1c3b85@google.com +Tested-by: Ryusuke Konishi +Cc: +Signed-off-by: Andrew Morton +Signed-off-by: Greg Kroah-Hartman +--- + fs/nilfs2/inode.c | 18 ++++++++++++++++++ + 1 file changed, 18 insertions(+) + +--- a/fs/nilfs2/inode.c ++++ b/fs/nilfs2/inode.c +@@ -921,6 +921,7 @@ void nilfs_evict_inode(struct inode *ino + struct nilfs_transaction_info ti; + struct super_block *sb = inode->i_sb; + struct nilfs_inode_info *ii = NILFS_I(inode); ++ struct the_nilfs *nilfs; + int ret; + + if (inode->i_nlink || !ii->i_root || unlikely(is_bad_inode(inode))) { +@@ -933,6 +934,23 @@ void nilfs_evict_inode(struct inode *ino + + truncate_inode_pages_final(&inode->i_data); + ++ nilfs = sb->s_fs_info; ++ if (unlikely(sb_rdonly(sb) || !nilfs->ns_writer)) { ++ /* ++ * If this inode is about to be disposed after the file system ++ * has been degraded to read-only due to file system corruption ++ * or after the writer has been detached, do not make any ++ * changes that cause writes, just clear it. ++ * Do this check after read-locking ns_segctor_sem by ++ * nilfs_transaction_begin() in order to avoid a race with ++ * the writer detach operation. ++ */ ++ clear_inode(inode); ++ nilfs_clear_inode(inode); ++ nilfs_transaction_abort(sb); ++ return; ++ } ++ + /* TODO: some of the following operations may fail. */ + nilfs_truncate_bmap(ii, 0); + nilfs_mark_inode_dirty(inode); diff --git a/queue-5.15/powerpc-64s-radix-fix-soft-dirty-tracking.patch b/queue-5.15/powerpc-64s-radix-fix-soft-dirty-tracking.patch new file mode 100644 index 00000000000..92181735bbd --- /dev/null +++ b/queue-5.15/powerpc-64s-radix-fix-soft-dirty-tracking.patch @@ -0,0 +1,56 @@ +From 66b2ca086210732954a7790d63d35542936fc664 Mon Sep 17 00:00:00 2001 +From: Michael Ellerman +Date: Thu, 11 May 2023 21:42:24 +1000 +Subject: powerpc/64s/radix: Fix soft dirty tracking +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Michael Ellerman + +commit 66b2ca086210732954a7790d63d35542936fc664 upstream. + +It was reported that soft dirty tracking doesn't work when using the +Radix MMU. + +The tracking is supposed to work by clearing the soft dirty bit for a +mapping and then write protecting the PTE. If/when the page is written +to, a page fault occurs and the soft dirty bit is added back via +pte_mkdirty(). For example in wp_page_reuse(): + + entry = maybe_mkwrite(pte_mkdirty(entry), vma); + if (ptep_set_access_flags(vma, vmf->address, vmf->pte, entry, 1)) + update_mmu_cache(vma, vmf->address, vmf->pte); + +Unfortunately on radix _PAGE_SOFTDIRTY is being dropped by +radix__ptep_set_access_flags(), called from ptep_set_access_flags(), +meaning the soft dirty bit is not set even though the page has been +written to. + +Fix it by adding _PAGE_SOFTDIRTY to the set of bits that are able to be +changed in radix__ptep_set_access_flags(). + +Fixes: b0b5e9b13047 ("powerpc/mm/radix: Add radix pte #defines") +Cc: stable@vger.kernel.org # v4.7+ +Reported-by: Dan Horák +Link: https://lore.kernel.org/r/20230511095558.56663a50f86bdc4cd97700b7@danny.cz +Signed-off-by: Michael Ellerman +Link: https://msgid.link/20230511114224.977423-1-mpe@ellerman.id.au +Signed-off-by: Greg Kroah-Hartman +--- + arch/powerpc/mm/book3s64/radix_pgtable.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/arch/powerpc/mm/book3s64/radix_pgtable.c ++++ b/arch/powerpc/mm/book3s64/radix_pgtable.c +@@ -1045,8 +1045,8 @@ void radix__ptep_set_access_flags(struct + pte_t entry, unsigned long address, int psize) + { + struct mm_struct *mm = vma->vm_mm; +- unsigned long set = pte_val(entry) & (_PAGE_DIRTY | _PAGE_ACCESSED | +- _PAGE_RW | _PAGE_EXEC); ++ unsigned long set = pte_val(entry) & (_PAGE_DIRTY | _PAGE_SOFT_DIRTY | ++ _PAGE_ACCESSED | _PAGE_RW | _PAGE_EXEC); + + unsigned long change = pte_val(entry) ^ pte_val(*ptep); + /* diff --git a/queue-5.15/powerpc-iommu-incorrect-ddw-table-is-referenced-for-sr-iov-device.patch b/queue-5.15/powerpc-iommu-incorrect-ddw-table-is-referenced-for-sr-iov-device.patch new file mode 100644 index 00000000000..4e842d67f43 --- /dev/null +++ b/queue-5.15/powerpc-iommu-incorrect-ddw-table-is-referenced-for-sr-iov-device.patch @@ -0,0 +1,90 @@ +From 1f7aacc5eb9ed2cc17be7a90da5cd559effb9d59 Mon Sep 17 00:00:00 2001 +From: Gaurav Batra +Date: Fri, 5 May 2023 13:47:01 -0500 +Subject: powerpc/iommu: Incorrect DDW Table is referenced for SR-IOV device + +From: Gaurav Batra + +commit 1f7aacc5eb9ed2cc17be7a90da5cd559effb9d59 upstream. + +For an SR-IOV device, while enabling DDW, a new table is created and +added at index 1 in the group. In the below 2 scenarios, the table is +incorrectly referenced at index 0 (which is where the table is for +default DMA window). + +1. When adding DDW + + This issue is exposed with "slub_debug". Error thrown out from + dma_iommu_dma_supported() + + Warning: IOMMU offset too big for device mask + mask: 0xffffffff, table offset: 0x800000000000000 + +2. During Dynamic removal of the PCI device. + + Error is from iommu_tce_table_put() since a NULL table pointer is + passed in. + +Fixes: 381ceda88c4c ("powerpc/pseries/iommu: Make use of DDW for indirect mapping") +Cc: stable@vger.kernel.org # v5.15+ +Signed-off-by: Gaurav Batra +Reviewed-by: Brian King +Signed-off-by: Michael Ellerman +Link: https://msgid.link/20230505184701.91613-1-gbatra@linux.vnet.ibm.com +Signed-off-by: Greg Kroah-Hartman +--- + arch/powerpc/kernel/dma-iommu.c | 4 +++- + arch/powerpc/platforms/pseries/iommu.c | 13 +++++++++---- + 2 files changed, 12 insertions(+), 5 deletions(-) + +--- a/arch/powerpc/kernel/dma-iommu.c ++++ b/arch/powerpc/kernel/dma-iommu.c +@@ -144,7 +144,7 @@ static bool dma_iommu_bypass_supported(s + /* We support DMA to/from any memory page via the iommu */ + int dma_iommu_dma_supported(struct device *dev, u64 mask) + { +- struct iommu_table *tbl = get_iommu_table_base(dev); ++ struct iommu_table *tbl; + + if (dev_is_pci(dev) && dma_iommu_bypass_supported(dev, mask)) { + /* +@@ -162,6 +162,8 @@ int dma_iommu_dma_supported(struct devic + return 1; + } + ++ tbl = get_iommu_table_base(dev); ++ + if (!tbl) { + dev_err(dev, "Warning: IOMMU dma not supported: mask 0x%08llx, table unavailable\n", mask); + return 0; +--- a/arch/powerpc/platforms/pseries/iommu.c ++++ b/arch/powerpc/platforms/pseries/iommu.c +@@ -85,19 +85,24 @@ static struct iommu_table_group *iommu_p + static void iommu_pseries_free_group(struct iommu_table_group *table_group, + const char *node_name) + { +- struct iommu_table *tbl; +- + if (!table_group) + return; + +- tbl = table_group->tables[0]; + #ifdef CONFIG_IOMMU_API + if (table_group->group) { + iommu_group_put(table_group->group); + BUG_ON(table_group->group); + } + #endif +- iommu_tce_table_put(tbl); ++ ++ /* Default DMA window table is at index 0, while DDW at 1. SR-IOV ++ * adapters only have table on index 1. ++ */ ++ if (table_group->tables[0]) ++ iommu_tce_table_put(table_group->tables[0]); ++ ++ if (table_group->tables[1]) ++ iommu_tce_table_put(table_group->tables[1]); + + kfree(table_group); + } diff --git a/queue-5.15/s390-qdio-fix-do_sqbs-inline-assembly-constraint.patch b/queue-5.15/s390-qdio-fix-do_sqbs-inline-assembly-constraint.patch new file mode 100644 index 00000000000..3283a0ffb70 --- /dev/null +++ b/queue-5.15/s390-qdio-fix-do_sqbs-inline-assembly-constraint.patch @@ -0,0 +1,66 @@ +From 2862a2fdfae875888e3c1c3634e3422e01d98147 Mon Sep 17 00:00:00 2001 +From: Heiko Carstens +Date: Thu, 11 May 2023 17:04:41 +0200 +Subject: s390/qdio: fix do_sqbs() inline assembly constraint + +From: Heiko Carstens + +commit 2862a2fdfae875888e3c1c3634e3422e01d98147 upstream. + +Use "a" constraint instead of "d" constraint to pass the state parameter to +the do_sqbs() inline assembly. This prevents that general purpose register +zero is used for the state parameter. + +If the compiler would select general purpose register zero this would be +problematic for the used instruction in rsy format: the register used for +the state parameter is a base register. If the base register is general +purpose register zero the contents of the register are unexpectedly ignored +when the instruction is executed. + +This only applies to z/VM guests using QIOASSIST with dedicated (pass through) +QDIO-based devices such as FCP [zfcp driver] as well as real OSA or +HiperSockets [qeth driver]. + +A possible symptom for this case using zfcp is the following repeating kernel +message pattern: + +zfcp : A QDIO problem occurred +zfcp : A QDIO problem occurred +zfcp : qdio: ZFCP on SC using AI:1 QEBSM:1 PRI:1 TDD:1 SIGA: W +zfcp : A QDIO problem occurred +zfcp : A QDIO problem occurred + +Each of the qdio problem message can be accompanied by the following entries +for the affected subchannel in +/sys/kernel/debug/s390dbf/qdio_error/hex_ascii for zfcp or qeth: + + ccq: 69.... + SQBS ERROR. + +Reviewed-by: Benjamin Block +Cc: Steffen Maier +Fixes: 8129ee164267 ("[PATCH] s390: qdio V=V pass-through") +Cc: +Signed-off-by: Heiko Carstens +Signed-off-by: Alexander Gordeev +Signed-off-by: Greg Kroah-Hartman +--- + drivers/s390/cio/qdio.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/s390/cio/qdio.h b/drivers/s390/cio/qdio.h +index 5ea6249d8180..641f0dbb65a9 100644 +--- a/drivers/s390/cio/qdio.h ++++ b/drivers/s390/cio/qdio.h +@@ -95,7 +95,7 @@ static inline int do_sqbs(u64 token, unsigned char state, int queue, + " lgr 1,%[token]\n" + " .insn rsy,0xeb000000008a,%[qs],%[ccq],0(%[state])" + : [ccq] "+&d" (_ccq), [qs] "+&d" (_queuestart) +- : [state] "d" ((unsigned long)state), [token] "d" (token) ++ : [state] "a" ((unsigned long)state), [token] "d" (token) + : "memory", "cc", "1"); + *count = _ccq & 0xff; + *start = _queuestart & 0xff; +-- +2.40.1 + diff --git a/queue-5.15/series b/queue-5.15/series index b0fcf050ce0..ba3879f7a8a 100644 --- a/queue-5.15/series +++ b/queue-5.15/series @@ -193,3 +193,8 @@ serial-qcom-geni-fix-enabling-deactivated-interrupt.patch thunderbolt-clear-registers-properly-when-auto-clear-isn-t-in-use.patch vc_screen-reload-load-of-struct-vc_data-pointer-in-vcs_write-to-avoid-uaf.patch ceph-force-updating-the-msg-pointer-in-non-split-case.patch +powerpc-iommu-incorrect-ddw-table-is-referenced-for-sr-iov-device.patch +tpm-tpm_tis-disable-interrupts-for-more-lenovo-devices.patch +powerpc-64s-radix-fix-soft-dirty-tracking.patch +nilfs2-fix-use-after-free-bug-of-nilfs_root-in-nilfs_evict_inode.patch +s390-qdio-fix-do_sqbs-inline-assembly-constraint.patch diff --git a/queue-5.15/tpm-tpm_tis-disable-interrupts-for-more-lenovo-devices.patch b/queue-5.15/tpm-tpm_tis-disable-interrupts-for-more-lenovo-devices.patch new file mode 100644 index 00000000000..6079b63c8e8 --- /dev/null +++ b/queue-5.15/tpm-tpm_tis-disable-interrupts-for-more-lenovo-devices.patch @@ -0,0 +1,49 @@ +From e7d3e5c4b1dd50a70b31524c3228c62bb41bbab2 Mon Sep 17 00:00:00 2001 +From: Jerry Snitselaar +Date: Wed, 10 May 2023 17:54:03 -0700 +Subject: tpm/tpm_tis: Disable interrupts for more Lenovo devices + +From: Jerry Snitselaar + +commit e7d3e5c4b1dd50a70b31524c3228c62bb41bbab2 upstream. + +The P360 Tiny suffers from an irq storm issue like the T490s, so add +an entry for it to tpm_tis_dmi_table, and force polling. There also +previously was a report from the previous attempt to enable interrupts +that involved a ThinkPad L490. So an entry is added for it as well. + +Cc: stable@vger.kernel.org +Reported-by: Peter Zijlstra # P360 Tiny +Closes: https://lore.kernel.org/linux-integrity/20230505130731.GO83892@hirez.programming.kicks-ass.net/ +Signed-off-by: Jerry Snitselaar +Signed-off-by: Jarkko Sakkinen +Signed-off-by: Greg Kroah-Hartman +--- + drivers/char/tpm/tpm_tis.c | 16 ++++++++++++++++ + 1 file changed, 16 insertions(+) + +--- a/drivers/char/tpm/tpm_tis.c ++++ b/drivers/char/tpm/tpm_tis.c +@@ -83,6 +83,22 @@ static const struct dmi_system_id tpm_ti + DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad T490s"), + }, + }, ++ { ++ .callback = tpm_tis_disable_irq, ++ .ident = "ThinkStation P360 Tiny", ++ .matches = { ++ DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), ++ DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkStation P360 Tiny"), ++ }, ++ }, ++ { ++ .callback = tpm_tis_disable_irq, ++ .ident = "ThinkPad L490", ++ .matches = { ++ DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), ++ DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad L490"), ++ }, ++ }, + {} + }; +