5.15.226-rc1 review
Subsystems (7)
Greg Kroah-Hartman
maintainerPATCH 1772/2214 dmaengine: ste_dma40: Validate fixed physical channel indexes
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 884e01160bc727509b4fdf04e763a86b936df464 ]
Fixed physical memcpy allocation uses dma_cfg.phy_channel directly as an index into phy_res when use_fixed_channel is set. d40_validate_conf() validates dev_type but not the fixed physical channel, allowing an invalid configuration to access memory outside the array.
Validate the fixed physical channel centrally before accepting the channel configuration.
--- drivers/dma/ste_dma40.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/dma/ste_dma40.c +8 -0
@@ -1774,6 +1774,14 @@ static int d40_validate_conf(struct d40_chan *d40c, res = -EINVAL ; } +if (conf->use_fixed_channel && + (conf->phy_channel <0 || + conf->phy_channel >= d40c->base->num_phy_chans)) { +chan_err (d40c,"Invalid physical channel (%d)\n" , + conf->phy_channel); + res = -EINVAL ; + } +if (conf->dir ==DMA_DEV_TO_DEV ) {/* * DMAC HW supports it. Will be added to this driver,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1773/2214 dmaengine: ste_dma40: fix typo in comment
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Julia Lawall <[email protected]>
[ Upstream commit a71da24ce1f8f6844c6378ae394b5c4b31ff5725 ]
Spelling mistake (triple letters) in comment.
Detected with the help of Coccinelle.
Stable-dep-of: 0ac4a90c4805 ("dmaengine: ste_dma40: Validate memcpy configuration")
--- drivers/dma/ste_dma40.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/ste_dma40.c +1 -1
@@ -2060,7 +2060,7 @@ static int d40_config_memcpy(struct d40_chan *d40c) dma_has_cap(DMA_SLAVE, cap)) { d40c->dma_cfg = dma40_memcpy_conf_phy; -/* Generate interrrupt at end of transfer or relink. */ +/* Generate interrupt at end of transfer or relink. */ d40c->dst_def_cfg |=BIT (D40_SREG_CFG_TIM_POS );/* Generate interrupt on error. */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1774/2214 dmaengine: ste_dma40: Validate memcpy configuration
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 0ac4a90c4805b41013044fdefff051ae59a54302 ]
d40_config_memcpy() builds a default memcpy configuration without passing it through d40_validate_conf(). A dev_type supplied through the memcpy-channels device tree property can therefore bypass the bounds checks added for client configurations.
The generic DMA direction enum assigns zero to DMA_MEM_TO_MEM, unlike DMA40's old private enum. Allow memory-to-memory directions in the validator so checking the generated configuration does not reject all memcpy channels.
Validate the generated memcpy configuration before deriving logical channel registers or allocating the channel.
--- drivers/dma/ste_dma40.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/dma/ste_dma40.c +11 -1
@@ -1753,7 +1753,8 @@ static int d40_validate_conf(struct d40_chan *d40c, d40c->base->gen_dmac.num_event_groups) invalid_dev_type = true; -if (!conf->dir) { +if (conf->dir !=DMA_MEM_TO_MEM && + !is_slave_direction (conf->dir)) {chan_err (d40c,"Invalid direction.\n" ); res = -EINVAL ; }
@@ -2048,11 +2049,16 @@ static int d40_allocate_channel(struct d40_chan *d40c, bool *first_phy_user)static int d40_config_memcpy (struct d40_chan *d40c) {dma_cap_mask_t cap = d40c->chan.device->cap_mask; +int ret;if (dma_has_cap (DMA_MEMCPY , cap) && !dma_has_cap (DMA_SLAVE , cap)) { d40c->dma_cfg = dma40_memcpy_conf_log; d40c->dma_cfg.dev_type = dma40_memcpy_channels[d40c->chan.chan_id]; + ret =d40_validate_conf (d40c, &d40c->dma_cfg); +if (ret) +return ret; +d40_log_cfg (&d40c->dma_cfg, &d40c->log_def.lcsp1, &d40c->log_def.lcsp3);
@@ -2060,6 +2066,10 @@ static int d40_config_memcpy(struct d40_chan *d40c) dma_has_cap(DMA_SLAVE, cap)) { d40c->dma_cfg = dma40_memcpy_conf_phy; + ret =d40_validate_conf (d40c, &d40c->dma_cfg); +if (ret) +return ret; +/* Generate interrupt at end of transfer or relink. */ d40c->dst_def_cfg |=BIT (D40_SREG_CFG_TIM_POS );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1775/2214 arm64: dts: allwinner: sun50i-h6: Add missing SRAM region for video engine
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen-Yu Tsai <[email protected]>
[ Upstream commit d7287d940f3cd8d5945009076058a8120281744b ]
The SRAM C region contains a partial alias to the VE SRAM already referenced by the video engine. To avoid access through this alias window, the region should also be claimed by the video engine.
Add a reference to the SRAM C region to the video engine node.
--- arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi +1 -1
@@ -161,7 +161,7 @@ video-codec@1c0e000 { clock-names = "ahb", "mod", "ram"; resets = <&ccu RST_BUS_VE>; interrupts = <GIC_SPI 89 IRQ_TYPE_LEVEL_HIGH>; - allwinner,sram = <&ve_sram 1>; + allwinner,sram = <&ve_sram 1>, <&de2_sram 1>; iommus = <&iommu 3>; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1776/2214 arm64: dts: allwinner: sun50i-h6: Add missing IOMMU for video engine
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen-Yu Tsai <[email protected]>
[ Upstream commit 965a49fc413d996eba9bae2a3132f03f45a2ea1b ]
The video engine on the H6 actually has two IOMMU ports. The one already listed is simply named "VE" in the user manual. The missing one is named "VE_R" and is probably either read-only or used for reference frames. Either way, it should be listed.
Add a reference to the "VE_R" IOMMU port to the video engine node.
--- arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi +1 -1
@@ -162,7 +162,7 @@ video-codec@1c0e000 { resets = <&ccu RST_BUS_VE>; interrupts = <GIC_SPI 89 IRQ_TYPE_LEVEL_HIGH>; allwinner,sram = <&ve_sram 1>, <&de2_sram 1>; - iommus = <&iommu 3>; + iommus = <&iommu 3>, <&iommu 1>; }; gpu: gpu@1800000 {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1777/2214 sh: uaccess: Require offsettable operands for 64-bit user access
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Fuchs <[email protected]>
[ Upstream commit 8b5dba9ea4a3f5ed994f03d6ca7686c49491b426 ]
The 64-bit __get_user_u64()/__put_user_u64() paths address the memory operand as %T2 (base+4). This base+4 requires an offsettable address, but "m" also allows the indexed mode @(R0,Rn) (e.g. for a variable- indexed array element), which has no displacement field for the +4. Depending on optimization this build fails with "invalid 'asm'" or an ICE in GCC's change_address_1.
Require an offsettable memory operand, allowing GCC to reload an unsuitable indexed address into an appropriate form.
--- arch/sh/include/asm/uaccess_32.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/sh/include/asm/uaccess_32.h +4 -4
@@ -92,7 +92,7 @@ __asm__ __volatile__( \ ".long 1b + 2, 3b\n\t" \ ".previous" \ :"=&r" (err), "=&r" (x) \ - :"m" (__m(addr)), "i" (-EFAULT), "0" (err)); }) + :"o" (__m(addr)), "i" (-EFAULT), "0" (err)); })#else #define __get_user_u64 (x, addr, err) \ ({ \
@@ -116,7 +116,7 @@ __asm__ __volatile__( \ ".long 1b + 2, 3b\n\t" \ ".previous" \ :"=&r" (err), "=&r" (x) \ - :"m" (__m(addr)), "i" (-EFAULT), "0" (err)); }) + :"o" (__m(addr)), "i" (-EFAULT), "0" (err)); })#endif #define __put_user_size (x,ptr,size,retval) \
@@ -196,7 +196,7 @@ __asm__ __volatile__( \ ".long 1b, 3b\n\t" \ ".previous" \ : "=r" (retval) \ - : "r" (val), "m" (__m(addr)), "i" (-EFAULT), "0" (retval) \ + : "r" (val), "o" (__m(addr)), "i" (-EFAULT), "0" (retval) \ : "memory"); }) #else #define __put_user_u64(val,addr,retval) \
@@ -218,7 +218,7 @@ __asm__ __volatile__( \ ".long 1b, 3b\n\t" \ ".previous" \ : "=r" (retval) \ - : "r" (val), "m" (__m(addr)), "i" (-EFAULT), "0" (retval) \ + : "r" (val), "o" (__m(addr)), "i" (-EFAULT), "0" (retval) \ : "memory"); }) #endif
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1778/2214 sh: defconfig: Enable the current M66592 UDC symbol
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit 9b65dcd94222c37febf98127b1ac5452c94a16d0 ]
The M66592 UDC provider is built under CONFIG_USB_M66592. Several SuperH defconfigs still enable the removed CONFIG_USB_GADGET_M66592 symbol.
Replace the stale entries with the current provider symbol.
--- arch/sh/configs/migor_defconfig | 2 +- arch/sh/configs/sdk7786_defconfig | 2 +- arch/sh/configs/shx3_defconfig | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
arch/sh/configs/migor_defconfig +1 -1
@@ -75,7 +75,7 @@ CONFIG_LOGO=y # CONFIG_LOGO_SUPERH_MONO is not set # CONFIG_LOGO_SUPERH_CLUT224 is not set CONFIG_USB_GADGET=y -CONFIG_USB_GADGET_M66592=y +CONFIG_USB_M66592=y CONFIG_USB_G_SERIAL=m CONFIG_RTC_CLASS=y CONFIG_RTC_DRV_RS5C372=y
arch/sh/configs/sdk7786_defconfig +1 -1
@@ -152,7 +152,7 @@ CONFIG_USB_MON=y CONFIG_USB_OHCI_HCD=y CONFIG_USB_STORAGE=y CONFIG_USB_GADGET=y -CONFIG_USB_GADGET_M66592=y +CONFIG_USB_M66592=y CONFIG_RTC_CLASS=y CONFIG_RTC_DRV_MAX6900=y CONFIG_RTC_DRV_SH=y
arch/sh/configs/shx3_defconfig +1 -1
@@ -80,7 +80,7 @@ CONFIG_USB=y CONFIG_USB_MON=y CONFIG_USB_R8A66597_HCD=m CONFIG_USB_GADGET=y -CONFIG_USB_GADGET_M66592=y +CONFIG_USB_M66592=y CONFIG_RTC_CLASS=y CONFIG_RTC_DRV_SH=y CONFIG_UIO=m
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1779/2214 spi: spi-sun4i: sun4i_spi_transfer_one(): fix transfers for SUN4I_FIFO_DEPTH
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marc Kleine-Budde <[email protected]>
[ Upstream commit f3ce7a3ca82bd9cda9ef61250aeff65fe6b44809 ]
In commit 6d9fe44bd73d ("spi: sun4i: fix FIFO limit"), the TX-FIFO is filled max to SUN4I_FIFO_DEPTH - 1 (= 63) bytes to work around timeouts observed on A10s SoCs.
Commit 196737912da5 ("spi: sun4i: Allow transfers larger than FIFO size") added support for transfers larger than the FIFO size. But this commit only enabled the TX-FIFO empty interrupt for transfers larger than the FIFO (= 64) bytes.
This breaks transfers with exactly 64 bytes: the TX-FIFO is only filled with 63 bytes but the interrupt to refill the FIFO is not triggered. The problem can be reproduced with the following command:
| spidev_test -D /dev/spidev0.1 -S 64 -s 20000000 -I 1 | | [ 7797.548745] spi_master spi0: spi0.1: timeout transferring 64 bytes@20000000Hz for 110(100)ms | [ 7797.557237] spidev spi0.1: SPI transfer failed: -110 | [ 7797.562308] spi_master spi0: failed to transfer one message from queue | [ 7797.568936] spi_master spi0: noqueue transfer failed
To fix the problem enable the TX-FIFO interrupt if the total TX length is larger than SUN4I_FIFO_DEPTH - 1 (= 63) bytes.
--- drivers/spi/spi-sun4i.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/spi-sun4i.c +1 -1
@@ -321,7 +321,7 @@ static int sun4i_spi_transfer_one(struct spi_master *master,sun4i_spi_enable_interrupt (sspi,SUN4I_INT_CTL_TC |SUN4I_INT_CTL_RF_F34 );/* Only enable Tx FIFO interrupt if we really need it */ -if (tx_len >SUN4I_FIFO_DEPTH ) +if (tx_len >SUN4I_FIFO_DEPTH -1 )sun4i_spi_enable_interrupt (sspi,SUN4I_INT_CTL_TF_E34 );/* Start the transfer */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1780/2214 spi: spi-sun4i: sun4i_spi_fill_fifo(): always apply A10 FIFO fill level workaround
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marc Kleine-Budde <[email protected]>
[ Upstream commit ee109e2bbea0986f6ad34bfbcba90fce36f17538 ]
In commit 6d9fe44bd73d ("spi: sun4i: fix FIFO limit"), the TX FIFO is filled max to SUN4I_FIFO_DEPTH - 1 (= 63) bytes to work around timeouts observed on A10s SoCs.
Commit 196737912da5 ("spi: sun4i: Allow transfers larger than FIFO size") added support for transfers larger than the FIFO size. This commit did not consider the A10 workaround (limit the TX FIFO fill size to SUN4I_FIFO_DEPTH - 1 (= 63) bytes) for refilling the TX FIFO in the IRQ handler.
To apply the workaround independent from where sun4i_spi_fill_fifo() is called, remove the length argument from the function and directly take the max fill level of SUN4I_FIFO_DEPTH - 1 into account when calculating the free space in the FIFO.
Due to the lack of HW this patch has not been tested on an A10 SoC, but on an A20 SoC. It was not possible to reproduce the timeout on the A20.
--- drivers/spi/spi-sun4i.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-)
drivers/spi/spi-sun4i.c +13 -11
@@ -142,15 +142,21 @@ static inline void sun4i_spi_drain_fifo(struct sun4i_spi *sspi, int len) } } -static inline void sun4i_spi_fill_fifo (struct sun4i_spi *sspi,int len) +static inline void sun4i_spi_fill_fifo (struct sun4i_spi *sspi) {u32 cnt; +int len;u8 byte; -/* See how much data we can fit */ - cnt =SUN4I_FIFO_DEPTH -sun4i_spi_get_tx_fifo_count (sspi); +/* +* See how much data we can fit +* +* Filling the FIFO fully causes timeout for some reason +* at least on spi2 on A10s +*/ + cnt =SUN4I_FIFO_DEPTH -1 -sun4i_spi_get_tx_fifo_count (sspi); - len =min3 (len, (int )cnt, sspi->len); + len =min_t (int, cnt, sspi->len);while (len--) { byte = sspi->tx_buf ? *sspi->tx_buf++ :0 ;
@@ -310,12 +316,8 @@ static int sun4i_spi_transfer_one(struct spi_master *master,sun4i_spi_write (sspi,SUN4I_BURST_CNT_REG ,SUN4I_BURST_CNT (tfr->len));sun4i_spi_write (sspi,SUN4I_XMIT_CNT_REG ,SUN4I_XMIT_CNT (tx_len)); -/* -* Fill the TX FIFO -* Filling the FIFO fully causes timeout for some reason -* at least on spi2 on A10s -*/ -sun4i_spi_fill_fifo (sspi,SUN4I_FIFO_DEPTH -1 ); +/* Fill the TX FIFO */ +sun4i_spi_fill_fifo (sspi);/* Enable the interrupts */ sun4i_spi_enable_interrupt(sspi, SUN4I_INT_CTL_TC |
@@ -372,7 +374,7 @@ static irqreturn_t sun4i_spi_handler(int irq, void *dev_id)/* Transmit FIFO 3/4 empty */ if (status &SUN4I_INT_CTL_TF_E34 ) { -sun4i_spi_fill_fifo (sspi,SUN4I_FIFO_DEPTH ); +sun4i_spi_fill_fifo (sspi);if (!sspi->len)/* nothing left to transmit */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1781/2214 nilfs2: fix link count underflow when removing corrupted directory
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ryusuke Konishi <[email protected]>
[ Upstream commit 814f5a53b4724798795b15690ff3d1c1d9ac1eb6 ]
When removing an empty directory with a corrupted link count (e.g., i_nlink is 1 due to filesystem corruption), nilfs_rmdir() calls drop_nlink() via nilfs_do_unlink() and then calls drop_nlink() again on the directory inode. This second call causes an underflow of i_nlink, triggering a kernel WARNING in drop_nlink().
Fix this issue by using clear_nlink() instead of drop_nlink() to finalize the link count reset for the target directory in nilfs_rmdir(). Additionally, log a warning message when i_nlink is not 2 before removing an empty directory to notify about the link count inconsistency.
--- fs/nilfs2/namei.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
fs/nilfs2/namei.c +7 -1
@@ -341,10 +341,16 @@ static int nilfs_rmdir(struct inode *dir, struct dentry *dentry) err = -ENOTEMPTY ;if (nilfs_empty_dir (inode)) { +if (unlikely (inode->i_nlink !=2 )) +nilfs_warn (dir->i_sb, +"inconsistent empty directory link count %u (ino=%llu)" , + inode->i_nlink, + (unsigned long long )inode->i_ino); + err =nilfs_do_unlink (dir, dentry);if (!err) { inode->i_size =0 ; -drop_nlink (inode); +clear_nlink (inode);nilfs_mark_inode_dirty (inode);drop_nlink (dir);nilfs_mark_inode_dirty (dir);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1782/2214 checkpatch: skip CamelCase cache for --no-tree without root
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Petr Vorel <[email protected]>
[ Upstream commit d41ebc7f9e2cc80cb57139c05e71415a79582ab0 ]
Running outside tree (--no-tree) without git root (--root DIR) is not doable because we have no include/ directory which could be cached. But 3445686af721 expected that we are always in Linux tree (w/a git). But --no-tree does not require --root. Therefore skip whole caching in that case.
This fixes perl and find errors when running checkpatch.pl *with* --no-tree --strict and *without* --root:
No structs that should be const will be found - file 'scripts/const_structs.checkpatch': No such file or directory Use of uninitialized value $root in concatenation (.) or string at scripts/checkpatch.pl line 1213.
find: `/include': No such file or directory
--- scripts/checkpatch.pl | 2 ++ 1 file changed, 2 insertions(+)
scripts/checkpatch.pl +2 -0
@@ -1108,6 +1108,8 @@ sub seed_camelcase_includes { my $git_last_include_commit = `${git_command} log --no-merges --pretty=format:"%h%n" -1 -- include`; chomp $git_last_include_commit; $camelcase_cache = ".checkpatch-camelcase.git.$git_last_include_commit"; + } elsif (not defined $root) { + return; } else { my $last_mod_date = 0; $files = `find $root/include -name "*.h"`;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1783/2214 ocfs2: fix deadlock in inline-data truncate transactions
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joseph Qi <[email protected]>
[ Upstream commit c204bf5ac3eeb66648904d0374d6f7b84d843aac ]
Updating an inode xattr can cause an ABBA deadlock with inline file truncation:
ocfs2_truncate_file()
down_write(&oi->ip_alloc_sem)
ocfs2_truncate_inline()
ocfs2_start_trans() ocfs2_xattr_set()
ocfs2_start_trans()
ocfs2_xattr_ibody_set()
down_write(&oi->ip_alloc_sem)The xattr set path starts the merged transaction before the inode-body xattr helper acquires ip_alloc_sem, reversing the ip_alloc_sem -> transaction order used by the allocation and truncate paths. The transaction merge in commit 85db90e77806 ("ocfs2/xattr: Merge xattr set transaction.") introduced this ordering.
Fix it by acquiring ip_alloc_sem once in ocfs2_xattr_set(), before xattr preparation, allocation reservations and ocfs2_start_trans(), and removing the per-helper acquisition from ocfs2_xattr_ibody_find(), ocfs2_xattr_ibody_set() and ocfs2_xattr_create_index_block(). These helpers now assert via lockdep that the caller holds ip_alloc_sem.
ocfs2_xattr_set_handle(), which only sets initial ACL or security xattrs on unpublished inodes inside the create transaction, takes ip_alloc_sem under a dedicated lockdep subclass so that the assertions hold without creating a transaction -> ip_alloc_sem cycle against the ip_alloc_sem -> transaction order. The inode is unpublished, so the acquisition can never contend.
This keeps the established ip_alloc_sem -> transaction order and makes the locking unconditional, so lockdep can verify a single plain ordering instead of conditional acquisitions.
--- fs/ocfs2/xattr.c | 79 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 53 insertions(+), 26 deletions(-)
fs/ocfs2/xattr.c +53 -26
@@ -2683,6 +2683,9 @@ static int ocfs2_xattr_has_space_inline(struct inode *inode,* * Find extended attribute in inode block and * fill search info into struct ocfs2_xattr_search. +* +* The inline free-space check races with truncate and allocation, so +* callers must hold ip_alloc_sem for writing. */ static int ocfs2_xattr_ibody_find(struct inode *inode, int name_index,
@@ -2694,13 +2697,13 @@ static int ocfs2_xattr_ibody_find(struct inode *inode,int ret;int has_space =0 ; +lockdep_assert_held_write (&oi->ip_alloc_sem); +if (inode->i_sb->s_blocksize ==OCFS2_MIN_BLOCKSIZE )return 0 ;if (!(oi->ip_dyn_features &OCFS2_INLINE_XATTR_FL )) { -down_read (&oi->ip_alloc_sem); has_space =ocfs2_xattr_has_space_inline (inode, di); -up_read (&oi->ip_alloc_sem);if (!has_space)return 0 ; }
@@ -2779,6 +2782,7 @@ static int ocfs2_xattr_ibody_init(struct inode *inode,* * Set, replace or remove an extended attribute into inode block. * +* Callers must hold ip_alloc_sem for writing. */ static int ocfs2_xattr_ibody_set(struct inode *inode, struct ocfs2_xattr_info *xi,
@@ -2789,16 +2793,17 @@ static int ocfs2_xattr_ibody_set(struct inode *inode,struct ocfs2_inode_info *oi =OCFS2_I (inode);struct ocfs2_xa_loc loc; +lockdep_assert_held_write (&oi->ip_alloc_sem); +if (inode->i_sb->s_blocksize ==OCFS2_MIN_BLOCKSIZE )return -ENOSPC ; -down_write (&oi->ip_alloc_sem);if (!(oi->ip_dyn_features &OCFS2_INLINE_XATTR_FL )) { ret =ocfs2_xattr_ibody_init (inode, xs->inode_bh, ctxt);if (ret) {if (ret != -ENOSPC )mlog_errno (ret); - goto out; +return ret; } }
@@ -2808,13 +2813,10 @@ static int ocfs2_xattr_ibody_set(struct inode *inode,if (ret) {if (ret != -ENOSPC )mlog_errno (ret); - goto out; +return ret; } xs->here = loc.xl_entry; -out: -up_write (&oi->ip_alloc_sem); -return ret; }
@@ -3472,6 +3474,18 @@ static int __ocfs2_xattr_set_handle(struct inode *inode,return ret; } +/* +* ip_alloc_sem subclass for inodes being initialized before publication. +* ocfs2_xattr_set_handle() runs inside the create transaction, so taking +* ip_alloc_sem there adds a transaction -> ip_alloc_sem order that would +* form a lockdep cycle with the ip_alloc_sem -> transaction order used +* elsewhere, if not for this separate subclass. The inode is unpublished +* so the acquisition can never contend. +*/ +enum { +OCFS2_IP_ALLOC_SEM_UNPUBLISHED =1 , +}; +/* * This helper is only for setting initial ACL or security xattrs on an inode * that is still unpublished, unhashed, and unattached to a dentry.
@@ -3533,6 +3547,13 @@ int ocfs2_xattr_set_handle(handle_t *handle, xis.inode_bh = xbs.inode_bh = di_bh; di = (struct ocfs2_dinode *)di_bh->b_data; +/* +* The inode is unpublished and cannot contend, but take the +* semaphore anyway so the helpers' lockdep assertions hold. +*/ +down_write_nested (&OCFS2_I (inode)->ip_alloc_sem, +OCFS2_IP_ALLOC_SEM_UNPUBLISHED ); + ret =ocfs2_xattr_ibody_find (inode, name_index, name, &xis);if (ret) goto cleanup;
@@ -3545,6 +3566,7 @@ int ocfs2_xattr_set_handle(handle_t *handle, ret =__ocfs2_xattr_set_handle (inode, di, &xi, &xis, &xbs, &ctxt); cleanup: +up_write (&OCFS2_I (inode)->ip_alloc_sem);brelse (xbs.xattr_bh);ocfs2_xattr_bucket_free (xbs.bucket);
@@ -3613,30 +3635,38 @@ int ocfs2_xattr_set(struct inode *inode, di = (struct ocfs2_dinode *)di_bh->b_data;down_write (&OCFS2_I (inode)->ip_xattr_sem); +/* +* The allocation and truncate paths take ip_alloc_sem before +* starting a transaction, so take it here before xattr +* preparation, allocation reservations and ocfs2_start_trans() +* to keep that order. The xattr helpers below no longer take +* it themselves. +*/ +down_write (&OCFS2_I (inode)->ip_alloc_sem);/* * Scan inode and external block to find the same name * extended attribute and collect search information. */ ret =ocfs2_xattr_ibody_find (inode, name_index, name, &xis);if (ret) - goto cleanup; + goto out_free_ac;if (xis.not_found) { ret =ocfs2_xattr_block_find (inode, name_index, name, &xbs);if (ret) - goto cleanup; + goto out_free_ac; }if (xis.not_found && xbs.not_found) { ret = -ENODATA ;if (flags &XATTR_REPLACE ) - goto cleanup; + goto out_free_ac; ret =0 ;if (!value) - goto cleanup; + goto out_free_ac; }else { ret = -EEXIST ;if (flags &XATTR_CREATE ) - goto cleanup; + goto out_free_ac; }/* Check whether the value is refcounted and do some preparation. */
@@ -3647,7 +3677,7 @@ int ocfs2_xattr_set(struct inode *inode, &ref_meta, &ref_credits);if (ret) {mlog_errno (ret); - goto cleanup; + goto out_free_ac; } }
@@ -3658,7 +3688,7 @@ int ocfs2_xattr_set(struct inode *inode,if (ret <0 ) {inode_unlock (tl_inode);mlog_errno (ret); - goto cleanup; + goto out_free_ac; } }inode_unlock (tl_inode);
@@ -3667,7 +3697,7 @@ int ocfs2_xattr_set(struct inode *inode, &xbs, &ctxt, ref_meta, &credits);if (ret) {mlog_errno (ret); - goto cleanup; + goto out_free_ac; }/* we need to update inode's ctime field, so add credit for it. */
@@ -3685,6 +3715,7 @@ int ocfs2_xattr_set(struct inode *inode,ocfs2_commit_trans (osb, ctxt.handle); out_free_ac: +up_write (&OCFS2_I (inode)->ip_alloc_sem);if (ctxt.data_ac)ocfs2_free_alloc_context (ctxt.data_ac);if (ctxt.meta_ac)
@@ -3693,7 +3724,6 @@ int ocfs2_xattr_set(struct inode *inode,ocfs2_schedule_truncate_log_flush (osb,1 );ocfs2_run_deallocs (osb, &ctxt.dealloc); -cleanup:if (ref_tree)ocfs2_unlock_refcount_tree (osb, ref_tree,1 );up_write (&OCFS2_I (inode)->ip_xattr_sem);
@@ -4350,6 +4380,10 @@ static void ocfs2_xattr_update_xattr_search(struct inode *inode, xs->here = xs->header->xh_entries; } +/* +* Caller must hold ip_alloc_sem for writing, since a new xattr block +* is allocated and the xattr block header is rewritten. +*/ static int ocfs2_xattr_create_index_block(struct inode *inode, struct ocfs2_xattr_info *xi, struct ocfs2_xattr_search *xs,
@@ -4366,19 +4400,14 @@ static int ocfs2_xattr_create_index_block(struct inode *inode,struct ocfs2_xattr_tree_root *xr;u16 xb_flags =le16_to_cpu (xb->xb_flags); +lockdep_assert_held_write (&oi->ip_alloc_sem); +trace_ocfs2_xattr_create_index_block_begin ( (unsigned long long )xb_bh->b_blocknr);BUG_ON (xb_flags &OCFS2_XATTR_INDEXED );BUG_ON (!xs->bucket); -/* -* XXX: -* We can use this lock for now, and maybe move to a dedicated mutex -* if performance becomes a problem later. -*/ -down_write (&oi->ip_alloc_sem); - ret =ocfs2_journal_access_xb (handle,INODE_CACHE (inode), xb_bh,OCFS2_JOURNAL_ACCESS_WRITE );if (ret) {
@@ -4440,8 +4469,6 @@ static int ocfs2_xattr_create_index_block(struct inode *inode,ocfs2_journal_dirty (handle, xb_bh); out: -up_write (&oi->ip_alloc_sem); -return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1784/2214 selftests/epoll: fix race condition in multi-waiter wakeup tests
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Schmaus <[email protected]>
[ Upstream commit 4238e66c82b6ee888a768cb298c85083b4566726 ]
In tests with multiple concurrent waiters on edge-triggered epoll instances where an emitter writes to multiple sockets (epoll16, epoll56, epoll58):
When the emitter performs its first write(), ep_poll_callback() fires and wakes up both waiters because one waiter uses epoll_wait() and the other one uses poll(). This translates to different wait queues, ep->wq for epoll and ep->poll_wait for poll/select, which are both awoken by the kernel because of that single write. Next, both waiter threads invoke epoll_wait(), but since there is only one event, only one epoll_wait() will return non-zero because of the edge-triggered mode being used (in level-triggered mode, the kernel would re-queue the event because of remaining unread data).
Since the second waiter sees an empty ready list, it does not increment ctx.count and the test fails spuriously with ctx.count == 1 instead of 2.
Emitter (CPU 0) Thread 0 (CPU 1) Thread 1 (CPU 2)
=============== ================ ================
epoll_wait(e0, -1) poll(e0, -1)
[on e0->wq] [on e0->poll_wait] write(sfd[1])
|
+--(Kernel wakes BOTH e0->wq and e0->poll_wait via callback)--+
| |
| wakes up wakes up |
| epoll_wait() reaps e1 poll() returns 1 |
| (e1 removed via ET) (wants event) |
| e0->rdllist is EMPTY | |
| count++ (count = 1) v |
| epoll_wait(e0, 0) |
| sees EMPTY list! |
| returns 0! |
| thread exits |
v |
write(sfd[3]) |
(event arrives too late!) v
EXPECT_EQ(count, 2) <-- SPURIOUS FAILURE!
Introduce waiter_entry1ap_loop() to retry poll() if the initial epoll_wait(..., 0) yielded no events. This ensures the thread waits for the subsequent write rather than failing immediately. Apply this helper in epoll16, epoll56, and for both waiter threads in epoll58.
--- .../filesystems/epoll/epoll_wakeup_test.c | 32 +++++++++++++------ 1 file changed, 22 insertions(+), 10 deletions(-)
tools/testing/selftests/filesystems/epoll/epoll_wakeup_test.c +22 -10
@@ -74,6 +74,24 @@ static void *waiter_entry1ap(void *data)return NULL ; } +static void *waiter_entry1ap_loop (void *data) +{ +struct pollfd pfd; +struct epoll_event e; +struct epoll_mtcontext *ctx = data; + + pfd.fd = ctx->efd[0 ]; + pfd.events =POLLIN ; +while (poll (&pfd,1 ,2000 ) >0 ) { +if (epoll_wait (ctx->efd[0 ], &e,1 ,0 ) >0 ) { +__sync_fetch_and_add (&ctx->count,1 ); +break ; + } + } + +return NULL ; +} +static void *waiter_entry1o (void *data) {struct epoll_event e;
@@ -809,7 +827,7 @@ TEST(epoll16)ASSERT_EQ (epoll_ctl (ctx.efd[0 ],EPOLL_CTL_ADD , ctx.sfd[2 ], events),0 ); ctx.main =pthread_self (); -ASSERT_EQ (pthread_create (&ctx.waiter,NULL , waiter_entry1ap, &ctx),0 ); +ASSERT_EQ (pthread_create (&ctx.waiter,NULL , waiter_entry1ap_loop, &ctx),0 );ASSERT_EQ (pthread_create (&emitter,NULL , emitter_entry2, &ctx),0 );if (epoll_wait (ctx.efd[0 ], events,1 ,-1 ) >0 )
@@ -2925,7 +2943,7 @@ TEST(epoll56)ASSERT_EQ (epoll_ctl (ctx.efd[0 ],EPOLL_CTL_ADD , ctx.efd[2 ], &e),0 ); ctx.main =pthread_self (); -ASSERT_EQ (pthread_create (&ctx.waiter,NULL , waiter_entry1ap, &ctx),0 ); +ASSERT_EQ (pthread_create (&ctx.waiter,NULL , waiter_entry1ap_loop, &ctx),0 );ASSERT_EQ (pthread_create (&emitter,NULL , emitter_entry2, &ctx),0 );if (epoll_wait (ctx.efd[0 ], &e,1 ,-1 ) >0 )
@@ -3030,7 +3048,6 @@ TEST(epoll57)TEST (epoll58) {pthread_t emitter; -struct pollfd pfd;struct epoll_event e;struct epoll_mtcontext ctx = {0 };
@@ -3061,15 +3078,10 @@ TEST(epoll58)ASSERT_EQ (epoll_ctl (ctx.efd[0 ],EPOLL_CTL_ADD , ctx.efd[2 ], &e),0 ); ctx.main =pthread_self (); -ASSERT_EQ (pthread_create (&ctx.waiter,NULL , waiter_entry1ap, &ctx),0 ); +ASSERT_EQ (pthread_create (&ctx.waiter,NULL , waiter_entry1ap_loop, &ctx),0 );ASSERT_EQ (pthread_create (&emitter,NULL , emitter_entry2, &ctx),0 ); - pfd.fd = ctx.efd[0 ]; - pfd.events =POLLIN ; -if (poll (&pfd,1 ,-1 ) >0 ) { -if (epoll_wait (ctx.efd[0 ], &e,1 ,0 ) >0 ) -__sync_fetch_and_add (&ctx.count,1 ); - } +waiter_entry1ap_loop (&ctx);ASSERT_EQ (pthread_join (ctx.waiter,NULL ),0 );EXPECT_EQ (ctx.count,2 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1785/2214 init/main: fix off-by-one in argv_init cleanup
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wilson Felipe Pereira <[email protected]>
[ Upstream commit b82ed0e3a1dafe41577b095318a3ea6c0eec6f46 ]
Patch series "init: fix array boundary bugs in boot parameter parsing".
This series fixes two distinct boundary logic edge-case bugs in init/main.c related to parsing boot command-line arguments and environment variables. Both bugs have been present since the early git history (Linux-2.6.12-rc2).
1. The first patch fixes an off-by-one error in init_setup() where the final slot of the argv_init array was left uncleared. This allowed a stale kernel parameter to leak into the init process's user-space command line if exactly MAX_INIT_ARGS unknown parameters were passed.
2. The second patch fixes a false-positive kernel panic in unknown_bootoption(). If a user filled the environment variable array up to its exact limit (32) and then attempted to overwrite the final variable, the kernel would panic before evaluating whether it was a harmless duplicate.
Exact QEMU reproduction steps for both edge cases are documented inside their respective commit descriptions.
This patch (of 2):
When cleaning up argv_init in init_setup() and rdinit_setup(), the loop terminates one element early due to using '<' instead of '<='. Since argv_init is sized MAX_INIT_ARGS+2, index MAX_INIT_ARGS is a valid element that should be cleared to NULL.
If exactly MAX_INIT_ARGS unknown arguments are passed before 'init=', the uncleared argv_init[MAX_INIT_ARGS] can act as a ghost argument to /sbin/init or cause a spurious kernel panic when later appended to.
To verify the argument leak, boot a VM into a shell with 32 unknown kernel arguments, the init parameter, and 31 user arguments:
STALE_ARGS=$(for i in {1..32}; do echo -n "stale$i "; done)
USER_ARGS=$(for i in {1..31}; do echo -n "user$i "; done)
qemu-system-x86_64 -kernel bzImage \
-append "$STALE_ARGS init=/bin/sh $USER_ARGS"Running cat /proc/1/cmdline inside the shell reveals that the 32nd kernel argument ('stale32') incorrectly leaked into the init process's command line. This patch zeroes the final slot, cleanly terminating the array.
--- init/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
init/main.c +2 -2
@@ -570,7 +570,7 @@ static int __init init_setup(char *str)* the shell think it should execute a script with such name. * So we ignore all arguments entered _before_ init=... [MJ] */ -for (i =1 ; i <MAX_INIT_ARGS ; i++) +for (i =1 ; i <=MAX_INIT_ARGS ; i++) argv_init[i] =NULL ;return 1 ; }
@@ -582,7 +582,7 @@ static int __init rdinit_setup(char *str) ramdisk_execute_command = str;/* See "auto" comment in init_setup */ -for (i =1 ; i <MAX_INIT_ARGS ; i++) +for (i =1 ; i <=MAX_INIT_ARGS ; i++) argv_init[i] =NULL ;return 1 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1786/2214 init/main: fix false-positive kernel panic on environment variable overwrite
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wilson Felipe Pereira <[email protected]>
[ Upstream commit 51e766bcd35e706d8df29dd0fac98871fdced261 ]
In unknown_bootoption(), the limit checking for environment variables sets panic_later *before* checking if the variable already exists in envp_init.
If a user passes exactly MAX_INIT_ENVS custom variables and then overwrites the final variable by matching its key, it causes a false-positive hard panic on boot despite not actually exceeding the array bounds or increasing the total variable count.
Swapping the order of these checks allows the duplicate check to break out of the loop before the panic flag is erroneously latched.
To verify, boot a VM with 31 custom variables (filling the array up to its limit of 32) and then overwrite the very last variable:
ENV_VARS=$(for i in {1..31}; do echo -n "var$i=$i "; done)
qemu-system-x86_64 -kernel bzImage -append "$ENV_VARS var31=overwrite"Without this patch, the kernel crashes instantly with:
Kernel panic - not syncing: Too many boot env vars at 'var31=overwrite'
With this patch, the kernel safely overwrites the variable and boots.
--- init/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
init/main.c +2 -2
@@ -537,12 +537,12 @@ static int __init unknown_bootoption(char *param, char *val,/* Environment option */ unsigned int i;for (i =0 ; envp_init[i]; i++) { +if (!strncmp (param, envp_init[i], len+1 )) +break ;if (i ==MAX_INIT_ENVS ) { panic_later ="env" ; panic_param = param; } -if (!strncmp (param, envp_init[i], len+1 )) -break ; } envp_init[i] = param; }else {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1787/2214 ocfs2: reject inconsistent xattr bucket during defrag
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joseph Qi <[email protected]>
[ Upstream commit bd40b997f04542869afeabe94f2cf1a016fc9bfa ]
ocfs2_defrag_xattr_bucket() has two mlog_bug_on_msg() checks that assume the name/value pairs in a bucket are disjoint and that xh_free_start is not below the compacted region.
ocfs2_validate_xattr_bucket() only checks each entry in isolation, so a corrupt bucket holding overlapping entries, or one with an inflated xh_free_start, passes validation and then hits BUG() in defrag when a setxattr triggers it.
Defrag works on a linear copy of the bucket and does not touch the real blocks before the copy back, so the checks can return an error instead of calling BUG().
--- fs/ocfs2/xattr.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
fs/ocfs2/xattr.c +11 -5
@@ -4564,16 +4564,22 @@ static int ocfs2_defrag_xattr_bucket(struct inode *inode,memmove (bucket_buf + end - len, bucket_buf + offset, len); xe->xe_name_offset =cpu_to_le16 (end - len); + }else if (end < offset + len) { + ret =ocfs2_error (inode->i_sb, +"Defrag check failed for bucket %llu\n" , + (unsigned long long )blkno); + goto out; } -mlog_bug_on_msg (end < offset + len,"Defrag check failed for " -"bucket %llu\n" , (unsigned long long )blkno); - end -= len; } -mlog_bug_on_msg (xh_free_start > end,"Defrag check failed for " -"bucket %llu\n" , (unsigned long long )blkno); +if (xh_free_start > end) { + ret =ocfs2_error (inode->i_sb, +"Defrag check failed for bucket %llu\n" , + (unsigned long long )blkno); + goto out; + }if (xh_free_start == end) goto out;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1788/2214 PCI/AER: Add optional logging callback for correctable error
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Jiang <[email protected]>
[ Upstream commit 361187e04733eee19778ea9b01cb95a977c14c10 ]
Some new devices such as CXL devices may want to record additional error information on a corrected error. Add a callback to allow the PCI device driver to do additional logging such as providing additional stats for user space RAS monitoring.
For CXL device, this is actually a need due to CXL needing to write to the CXL RAS capability structure correctable error status register in order to clear the unmasked correctable errors. See CXL spec rev3.0 8.2.4.16.
Stable-dep-of: e86ac10110d0 ("PCI/AER: Fix struct pci_dev reference leak in aer_process_err_devices()")
--- Documentation/PCI/pci-error-recovery.rst | 7 +++++++ drivers/pci/pcie/aer.c | 8 +++++++- include/linux/pci.h | 3 +++ 3 files changed, 17 insertions(+), 1 deletion(-)
Documentation/PCI/pci-error-recovery.rst +7 -0
@@ -83,6 +83,7 @@ This structure has the form:: int (*mmio_enabled)(struct pci_dev *dev); int (*slot_reset)(struct pci_dev *dev); void (*resume)(struct pci_dev *dev); + void (*cor_error_detected)(struct pci_dev *dev); }; The possible channel states are::
@@ -422,5 +423,11 @@ That is, the recovery API only requires that: - drivers/net/cxgb3 - drivers/net/s2io.c + The cor_error_detected() callback is invoked in handle_error_source() when + the error severity is "correctable". The callback is optional and allows + additional logging to be done if desired. See example: + + - drivers/cxl/pci.c + The End -------
drivers/pci/pcie/aer.c +7 -1
@@ -956,8 +956,14 @@ static void handle_error_source(struct pci_dev *dev, struct aer_err_info *info)if (aer)pci_write_config_dword (dev, aer +PCI_ERR_COR_STATUS , info->status); -if (pcie_aer_is_native (dev)) +if (pcie_aer_is_native (dev)) { +struct pci_driver *pdrv = dev->driver; + +if (pdrv && pdrv->err_handler && + pdrv->err_handler->cor_error_detected) + pdrv->err_handler->cor_error_detected (dev);pcie_clear_device_status (dev); + } }else if (info->severity ==AER_NONFATAL )pcie_do_recovery (dev, pci_channel_io_normal, aer_root_reset);else if (info->severity ==AER_FATAL )
include/linux/pci.h +3 -0
@@ -849,6 +849,9 @@ struct pci_error_handlers {/* Device driver may resume normal operations */ void (*resume)(struct pci_dev *dev); + +/* Allow device driver to record more details of a correctable error */ +void (*cor_error_detected)(struct pci_dev *dev); };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1789/2214 PCI/AER: Forward RCH downstream port-detected errors to the CXL.mem dev handler
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Robert Richter <[email protected]>
[ Upstream commit 0a867568bb0d203ca3d28634a611a1367d7c892d ]
In Restricted CXL Device (RCD) mode a CXL device is exposed as an RCiEP, but CXL downstream and upstream ports are not enumerated and not visible in the PCIe hierarchy. [1] Protocol and link errors from these non-enumerated ports are signaled as internal AER errors, either Uncorrectable Internal Error (UIE) or Corrected Internal Errors (CIE) via an RCEC.
Restricted CXL host (RCH) downstream port-detected errors have the Requester ID of the RCEC set in the RCEC's AER Error Source ID register. A CXL handler must then inspect the error status in various CXL registers residing in the dport's component register space (CXL RAS capability) or the dport's RCRB (PCIe AER extended capability). [2]
Errors showing up in the RCEC's error handler must be handled and connected to the CXL subsystem. Implement this by forwarding the error to all CXL devices below the RCEC. Since the entire CXL device is controlled only using PCIe Configuration Space of device 0, function 0, only pass it there [3]. The error handling is limited to currently supported devices with the Memory Device class code set (CXL Type 3 Device, PCI_CLASS_MEMORY_CXL, 502h), handle downstream port errors in the device's cxl_pci driver. Support for other CXL Device Types (e.g. a CXL.cache Device) can be added later.
To handle downstream port errors in addition to errors directed to the CXL endpoint device, a handler must also inspect the CXL RAS and PCIe AER capabilities of the CXL downstream port the device is connected to.
Since CXL downstream port errors are signaled using internal errors, the handler requires those errors to be unmasked. This is subject of a follow-on patch.
The reason for choosing this implementation is that the AER service driver claims the RCEC device, but does not allow it to register a custom specific handler to support CXL. Connecting the RCEC hard-wired with a CXL handler does not work, as the CXL subsystem might not be present all the time. The alternative to add an implementation to the portdrv to allow the registration of a custom RCEC error handler isn't worth doing it as CXL would be its only user. Instead, just check for an CXL RCEC and pass it down to the connected CXL device's error handler. With this approach the code can entirely be implemented in the PCIe AER driver and is independent of the CXL subsystem. The CXL driver only provides the handler.
[1] CXL 3.0 spec: 9.11.8 CXL Devices Attached to an RCH
[2] CXL 3.0 spec, 12.2.1.1 RCH Downstream Port-detected Errors
[3] CXL 3.0 spec, 8.1.3 PCIe DVSEC for CXL Devices
Stable-dep-of: e86ac10110d0 ("PCI/AER: Fix struct pci_dev reference leak in aer_process_err_devices()")
--- drivers/pci/pcie/Kconfig | 9 ++++ drivers/pci/pcie/aer.c | 93 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 100 insertions(+), 2 deletions(-)
drivers/pci/pcie/Kconfig +9 -0
@@ -45,6 +45,15 @@ config PCIEAER_INJECT gotten from: https://www.kernel.org/pub/linux/utils/pci/aer-inject/ +config PCIEAER_CXL + bool "PCI Express CXL RAS support" + default y + depends on PCIEAER && CXL_PCI + help + Enables CXL error handling. + + If unsure, say Y. + # # PCI Express ECRC #
drivers/pci/pcie/aer.c +91 -2
111 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1790/2214 PCI/AER: Fix struct pci_dev reference leak in aer_process_err_devices()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Priyank Rathod <[email protected]>
[ Upstream commit e86ac10110d00e6c3801f38bde1863951315222b ]
When an AER error occurs, candidate error-source devices are added to e_info->dev[] by add_error_device(), which takes a reference with pci_dev_get().
A device can be recorded without any error status being present: the Requester ID fast path in is_error_source(),
if (e_info->id == pci_dev_id(dev))
return true;
matches purely on the ID reported by the Root Port and returns true without reading the device's AER status registers.
In aer_process_err_devices(), handle_error_source() is called only if aer_get_device_error_info() returns non-zero, i.e. only if an unmasked error status bit is actually set. It returns 0 if the device has become inaccessible (status and mask both read as all ones, so status & ~mask == 0) or if no unmasked status bit is set.
Because handle_error_source() was responsible for calling pci_dev_put(), skipping it permanently leaks the reference taken in add_error_device().
Decouple reference lifetime from error handling by moving pci_dev_put() out of handle_error_source() and into the aer_process_err_devices() loop, so every recorded device is put exactly once.
handle_error_source() is static and aer_process_err_devices() is its only caller, so no other path is affected.
--- drivers/pci/pcie/aer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/pcie/aer.c +1 -1
@@ -1057,7 +1057,6 @@ static void handle_error_source(struct pci_dev *dev, struct aer_err_info *info) {cxl_rch_handle_error (dev, info);pci_aer_handle_error (dev, info); -pci_dev_put (dev); }#ifdef CONFIG_ACPI_APEI_PCIEAER
@@ -1205,6 +1204,7 @@ static inline void aer_process_err_devices(struct aer_err_info *e_info)for (i =0 ; i < e_info->error_dev_num && e_info->dev[i]; i++) {if (aer_get_device_error_info (e_info->dev[i], e_info))handle_error_source (e_info->dev[i], e_info); +pci_dev_put (e_info->dev[i]); } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1791/2214 ALSA: caiaq: Allow zero-length packet handling for EP1
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit ccfe6ab672c020fca56988e634088bfb7764e2a7 ]
The recent fix to avoid OOB access for malformed packets added a packet length check and returns immediately if it's too short. However, this can be lead to a regression because the completion handler doesn't resubmit the packet, while a zero-length packet itself is valid, per se.
For addressing the potential regression above, change the handling for a zero-length packet to just resubmit without processing the incoming contents.
--- sound/usb/caiaq/device.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
sound/usb/caiaq/device.c +2 -1
@@ -142,7 +142,7 @@ static void usb_ep1_command_reply_dispatch (struct urb* urb)return ; }if (urb->actual_length <1 ) -return ; + goto resubmit; payload_len = urb->actual_length -1 ;
@@ -192,6 +192,7 @@ static void usb_ep1_command_reply_dispatch (struct urb* urb)break ; } + resubmit: cdev->ep1_in_urb->actual_length =0 ; ret =usb_submit_urb (cdev->ep1_in_urb,GFP_ATOMIC );if (ret <0 )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1792/2214 gen_init_cpio: stop parsing on lines with a missing argument list
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leizhen Zhang <[email protected]>
[ Upstream commit c8dd1aa0274d8ad3df82ec1b064065f410ce99ed ]
When a line in the cpio list consists of a file type followed only by whitespace and no newline (e.g. "slink " as the last line of the file), strtok(NULL, "\n") returns NULL. main() prints an error and sets ec, but then carries on and passes the NULL args pointer to the type handler, which hands it to sscanf() and crashes:
AddressSanitizer: SEGV on unknown address 0x000000000000
#4 __isoc99_sscanf
#5 cpio_mkslink_line usr/gen_init_cpio.c:169Break out of the loop as is already done for the other format error, so that the error is reported and gen_init_cpio exits with a failure status.
Found by fuzzing gen_init_cpio built with ASan/UBSan.
Reproducer:
printf 'slink ' > list && usr/gen_init_cpio list
--- usr/gen_init_cpio.c | 1 + 1 file changed, 1 insertion(+)
usr/gen_init_cpio.c +1 -0
@@ -599,6 +599,7 @@ int main (int argc, char *argv[])"ERROR: incorrect format, newline required line %d: '%s'\n" , line_nr, line); ec =-1 ; +break ; }for (type_idx =0 ; file_handler_table[type_idx].type; type_idx++) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1793/2214 pinctrl: sprd: free maps on DT map failure
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit e873c665e503ebfb6dafaf9346c3956695686226 ]
sprd_dt_node_to_map() reserves map storage before adding mux and configuration entries. If a later operation fails, the error path only frees the temporary configurations and leaves the map allocation reachable through the output pointer.
Free the partially built map on failure. The caller ignores the output parameters when the mapping callback returns an error, so they do not need to be reset after freeing the map.
--- drivers/pinctrl/sprd/pinctrl-sprd.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/pinctrl/sprd/pinctrl-sprd.c +3 -0
@@ -327,6 +327,9 @@ static int sprd_dt_node_to_map(struct pinctrl_dev *pctldev, out:kfree (configs); +if (ret <0 ) +pinctrl_utils_free_map (pctldev, *map, *num_maps); +return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1794/2214 wifi: mt76: mt76x02: validate RX padding before use
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit baf375ca58eaa24503f9febac75c056852694c3a ]
The RX descriptor provides L2 and PN padding lengths that are used to locate the CCMP IV and determine how many bytes to remove from the packet. These lengths are not checked against the received skb length before the IV is read or mt76x02_remove_hdr_pad() is called.
Reject frames whose IV does not fit within the skb or whose header padding would extend past the end of the skb.
--- drivers/net/wireless/mediatek/mt76/mt76x02_mac.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76x02_mac.c +9 -2
@@ -818,9 +818,13 @@ int mt76x02_mac_process_rx(struct mt76x02_dev *dev, struct sk_buff *skb, len =FIELD_GET (MT_RXWI_CTL_MPDU_LEN , ctl); pn_len =FIELD_GET (MT_RXINFO_PN_LEN , rxinfo);if (pn_len) { -int offset =ieee80211_get_hdrlen_from_skb (skb) + pad_len; -u8 *data = skb->data + offset; +unsigned int offset =ieee80211_get_hdrlen_from_skb (skb) + pad_len; +u8 *data; +if (offset +8 > skb->len) +return -EINVAL ; + + data = skb->data + offset; status->iv[0 ] = data[7 ]; status->iv[1 ] = data[6 ]; status->iv[2 ] = data[5 ];
@@ -840,6 +844,9 @@ int mt76x02_mac_process_rx(struct mt76x02_dev *dev, struct sk_buff *skb, } } +if (pad_len +ieee80211_get_hdrlen_from_skb (skb) > skb->len) +return -EINVAL ; +mt76x02_remove_hdr_pad (skb, pad_len);if ((rxinfo &MT_RXINFO_BA ) && !(rxinfo &MT_RXINFO_NULL ))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1795/2214 wifi: mt76: usb: fix source overread in mt76u_copy
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit d435130cdd064b901d8ce5ada0322298e6a86a49 ]
mt76u_copy() rounds up len to a multiple of four and uses the rounded length as the bound for memcpy() from the source buffer. When the caller's length is not four-byte aligned, the final copy reads up to three bytes past the source buffer.
Keep the original length for the source copy and zero the remaining bytes in the transmit buffer so that the hardware access width remains four-byte aligned.
--- drivers/net/wireless/mediatek/mt76/usb.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
drivers/net/wireless/mediatek/mt76/usb.c +11 -5
@@ -189,8 +189,10 @@ static void mt76u_copy(struct mt76_dev *dev, u32 offset, {struct mt76_usb *usb = &dev->usb;const u8 *val = data; -int ret;int current_batch_size; +int len_aligned; +int copy_len; +int ret;int i =0 ;/* Assure that always a multiple of 4 bytes are copied,
@@ -198,12 +200,16 @@ static void mt76u_copy(struct mt76_dev *dev, u32 offset,* See: "mt76: round up length on mt76_wr_copy" * Commit 850e8f6fbd5d0003b0 */ - len =round_up (len,4 ); + len_aligned =round_up (len,4 );mutex_lock (&usb->usb_ctrl_mtx); -while (i < len) { - current_batch_size =min_t (int, usb->data_len, len - i); -memcpy (usb->data, val + i, current_batch_size); +while (i < len_aligned) { + current_batch_size =min_t (int, usb->data_len, len_aligned - i); + copy_len =min_t (int, current_batch_size, len - i); +memcpy (usb->data, val + i, copy_len); +if (copy_len < current_batch_size) +memset (usb->data + copy_len,0 , + current_batch_size - copy_len); ret = __mt76u_vendor_request(dev, MT_VEND_MULTI_WRITE, USB_DIR_OUT | USB_TYPE_VENDOR, 0, offset + i, usb->data,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1796/2214 wifi: mt76: mt7615: read MT7663 temperature from the correct offset
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ahmed Naseef <[email protected]>
[ Upstream commit 40217d8e6cba433a6ccb8c73737dd38b54dcc26f ]
On MT7663 the hwmon temp1_input attribute always reads 0.
mt7615_mcu_parse_response() takes the temperature from the first dword of the THERMAL_CTRL response payload, but MT7663 firmware reports it in the second one. On a DASAN H660GM-A (MT7663E, N9 firmware 7663mp1827) the request and its response are:
request: 00 00 00 00
response: 00 00 00 00 2a 00 00 00
0x2a is the reading, 42 degrees, while the driver returns the leading zero. mt7915 and mt7921 already pull sizeof(*rxd) + 4 for this command.
Restrict the extra pull to MT7663, as no MT7615 or MT7622 hardware was available to check whether their firmware uses the same layout.
--- drivers/net/wireless/mediatek/mt76/mt7615/mcu.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7615/mcu.c +2 -0
@@ -191,6 +191,8 @@ int mt7615_mcu_parse_response(struct mt76_dev *mdev, int cmd,break ;case MCU_EXT_CMD_GET_TEMP :skb_pull (skb,sizeof (*rxd)); +if (is_mt7663 (mdev)) +skb_pull (skb,4 ); ret =le32_to_cpu (*(__le32 *)skb->data);break ;case MCU_EXT_CMD_RF_REG_ACCESS |MCU_QUERY_PREFIX :
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1797/2214 ASoC: rockchip: rockchip_i2s: Handle runtime PM resume failures in set_fmt
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit e9eb1854d16136006c6fe94c927b54b2b264b429 ]
rockchip_i2s_set_fmt() calls pm_runtime_get_sync() before accessing hardware registers, but ignores its return value.
If the runtime resume fails, the function continues to perform register accesses while the device state is undefined.
Replace pm_runtime_get_sync() with pm_runtime_resume_and_get() and return early on failure to avoid unpowered register accesses.
--- sound/soc/rockchip/rockchip_i2s.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
sound/soc/rockchip/rockchip_i2s.c +3 -1
@@ -198,7 +198,9 @@ static int rockchip_i2s_set_fmt(struct snd_soc_dai *cpu_dai,unsigned int mask =0 , val =0 ;int ret =0 ; -pm_runtime_get_sync (cpu_dai->dev); + ret =pm_runtime_resume_and_get (cpu_dai->dev); +if (ret) +return ret; mask =I2S_CKR_MSS_MASK ;switch (fmt &SND_SOC_DAIFMT_MASTER_MASK ) {case SND_SOC_DAIFMT_CBS_CFS :
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1798/2214 checkkconfigsymbols.py: Parse Git status output line by line
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ting-Han Hou <[email protected]>
[ Upstream commit 72a61a7fef954152abd9df9def4f94816eb344ca ]
tree_is_dirty() iterates over the string returned by execute() one character at a time. Its status check therefore examines filenames as well as the two status columns.
An otherwise clean tree containing an untracked README is reported as dirty because its name contains letters matched by [URMADC]. This prevents --commit and --diff from running, whereas an untracked notes.txt does not trigger the check.
Split the output into lines before examining the two status columns so that filenames do not affect the dirty-tree check.
--- scripts/checkkconfigsymbols.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/checkkconfigsymbols.py +1 -1
@@ -245,7 +245,7 @@ def tree_is_dirty(): """Return true if the current working tree is dirty (i.e., if any file has been added, deleted, modified, renamed or copied but not committed).""" stdout = execute(["git", "status", "--porcelain"]) - for line in stdout: + for line in stdout.splitlines(): if re.findall(r"[URMADC]{1}", line[:2]): return True return False
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1799/2214 drm/amd/display: assign missing trace entry in amdgpu_dm_dc_clocks_state
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Melissa Wen <[email protected]>
[ Upstream commit ec167063dbf9fc66dc1364b6f9dd220c6742edeb ]
disp_dpp_voltage_level_khz is declared and printed, but never assigned. So when using clock tracepoint the value of this clock is just garbage. Assign clk->disp_dpp_voltage_level_khz since this is stored in dc_clocks as other entries.
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_trace.h | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_trace.h +1 -0
@@ -510,6 +510,7 @@ TRACE_EVENT(amdgpu_dm_dc_clocks_state,TP_fast_assign ( __entry->dispclk_khz = clk->dispclk_khz; __entry->dppclk_khz = clk->dppclk_khz; + __entry->disp_dpp_voltage_level_khz = clk->disp_dpp_voltage_level_khz; __entry->dcfclk_khz = clk->dcfclk_khz; __entry->socclk_khz = clk->socclk_khz; __entry->dcfclk_deep_sleep_khz = clk->dcfclk_deep_sleep_khz;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1800/2214 drm/amd/display: remove duplicated prev_p_state_change_support assignment
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Melissa Wen <[email protected]>
[ Upstream commit 11e8f72b09a6a3c0950b9558abd37559dd098698 ]
The prev_p_state_change_support trace entry is assigned and printed twice, remove the unnecessary duplicates.
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_trace.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_trace.h +2 -4
@@ -520,7 +520,6 @@ TRACE_EVENT(amdgpu_dm_dc_clocks_state, __entry->p_state_change_support = clk->p_state_change_support; __entry->prev_p_state_change_support = clk->prev_p_state_change_support; __entry->pwr_state = clk->pwr_state; - __entry->prev_p_state_change_support = clk->prev_p_state_change_support; __entry->dtm_level = clk->dtm_level; __entry->max_supported_dppclk_khz = clk->max_supported_dppclk_khz; __entry->max_supported_dispclk_khz = clk->max_supported_dispclk_khz;
@@ -530,8 +529,8 @@ TRACE_EVENT(amdgpu_dm_dc_clocks_state, TP_printk("dispclk_khz=%d dppclk_khz=%d disp_dpp_voltage_level_khz=%d dcfclk_khz=%d socclk_khz=%d " "dcfclk_deep_sleep_khz=%d fclk_khz=%d phyclk_khz=%d " "dramclk_khz=%d p_state_change_support=%d " - "prev_p_state_change_support=%d pwr_state=%d prev_p_state_change_support=%d " - "dtm_level=%d max_supported_dppclk_khz=%d max_supported_dispclk_khz=%d " + "prev_p_state_change_support=%d pwr_state=%d dtm_level=%d " + "max_supported_dppclk_khz=%d max_supported_dispclk_khz=%d " "bw_dppclk_khz=%d bw_dispclk_khz=%d ", __entry->dispclk_khz, __entry->dppclk_khz,
@@ -545,7 +544,6 @@ TRACE_EVENT(amdgpu_dm_dc_clocks_state, __entry->p_state_change_support, __entry->prev_p_state_change_support, __entry->pwr_state, - __entry->prev_p_state_change_support, __entry->dtm_level, __entry->max_supported_dppclk_khz, __entry->max_supported_dispclk_khz,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1801/2214 drm/amd/display: use right type for amdgpu_dc_performance event entries
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Melissa Wen <[email protected]>
[ Upstream commit 99858eda764364bae733448c7eb79145d3d043ec ]
Some amdgpu_dc_performance trace event params are passed as unsigned long but stored as uint32_t, cutting them off on 64-bit. Use the right type on entry fields and on printk use unsigned format accordingly.
--- .../drm/amd/display/amdgpu_dm/amdgpu_dm_trace.h | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_trace.h +7 -10
@@ -73,10 +73,10 @@ TRACE_EVENT(amdgpu_dc_performance, const char *func, unsigned int line),TP_ARGS (read_count ,write_count ,last_read ,last_write ,func ,line ),TP_STRUCT__entry ( - __field(uint32_t, reads) -__field (uint32_t ,writes ) -__field (uint32_t, read_delta) -__field (uint32_t, write_delta) + __field(unsigned long, reads) +__field (unsigned long ,writes ) + __field(unsigned long, read_delta) + __field(unsigned long, write_delta)__string (func, func)__field (uint32_t, line) ),
@@ -90,12 +90,9 @@ TRACE_EVENT(amdgpu_dc_performance, *last_read = read_count; *last_write = write_count; ), -TP_printk ("%s:%d reads=%08ld (%08ld total), writes=%08ld (%08ld total)" , -__get_str (func), __entry->line, - (unsigned long )__entry->read_delta, - (unsigned long )__entry->reads, - (unsigned long )__entry->write_delta, - (unsigned long )__entry->writes) +TP_printk ("%s:%u reads=%08lu (%08lu total), writes=%08lu (%08lu total)" , +__get_str (func), __entry->line, __entry->read_delta, + __entry->reads, __entry->write_delta, __entry->writes) ); TRACE_EVENT(amdgpu_dm_connector_atomic_check,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1802/2214 ASoC: mediatek: common: Handle constraint return value in FE startup
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 5fcdb40a4776cc6f8d3179aa9cf9663fc18c7861 ]
snd_pcm_hw_constraint_integer() may return 1, which is then returned from mtk_afe_fe_startup(). ASoC only treats 0 as success when marking the DAI as started, so .shutdown() can be skipped on rollback.
Return 0 explicitly on success.
--- sound/soc/mediatek/common/mtk-afe-fe-dai.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
sound/soc/mediatek/common/mtk-afe-fe-dai.c +5 -3
@@ -75,8 +75,10 @@ int mtk_afe_fe_startup(struct snd_pcm_substream *substream, ret =snd_pcm_hw_constraint_integer (runtime,SNDRV_PCM_HW_PARAM_PERIODS ); -if (ret <0 ) +if (ret <0 ) {dev_err (afe->dev,"snd_pcm_hw_constraint_integer failed\n" ); +return ret; + }/* dynamic allocate irq to memif */ if (memif->irq_usage <0 ) {
@@ -88,10 +90,10 @@ int mtk_afe_fe_startup(struct snd_pcm_substream *substream, }else {dev_err (afe->dev,"%s() error: no more asys irq\n" , __func__); - ret = -EBUSY ; +return -EBUSY ; } } -return ret; +return 0 ; }EXPORT_SYMBOL_GPL (mtk_afe_fe_startup);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1803/2214 PCI/sysfs: Stop reporting _DSM failures as -EPERM
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Wilczyński <[email protected]>
[ Upstream commit 36f9bd09920ed71c1b79db397170412b2de22319 ]
Currently, dsm_get_label() returns the literal -1 on every failure path. The sysfs read path passes that value to userspace as -EPERM. Reading the "label" or "acpi_index" attribute on a platform where the Device Name _DSM returns a malformed result then fails with:
$ cat /sys/bus/pci/devices/0000:00:08.3/label cat: /sys/bus/pci/devices/0000:00:08.3/label: Operation not permitted
Nothing in that path performs a permission check, and the read fails the same way for a privileged reader. The error code points at a cause that does not exist, and tools such as lspci report it on every invocation.
Return -ENODEV when the device has no ACPI companion, and -EIO when the _DSM evaluation fails or returns an object that cannot be parsed. Other _DSM users in the tree report such failures the same way.
The set of reads that succeed, and the bytes they return, stay the same. Only the error code of reads that already fail differs.
--- drivers/pci/pci-label.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/pci/pci-label.c +3 -3
@@ -160,12 +160,12 @@ static int dsm_get_label(struct device *dev, char *buf,int len =0 ;if (!handle) -return -1 ; +return -ENODEV ; obj =acpi_evaluate_dsm (handle, &pci_acpi_dsm_guid,0x2 ,DSM_PCI_DEVICE_NAME ,NULL );if (!obj) -return -1 ; +return -EIO ; tmp = obj->package.elements; if (obj->type == ACPI_TYPE_PACKAGE && obj->package.count == 2 &&
@@ -190,7 +190,7 @@ static int dsm_get_label(struct device *dev, char *buf,ACPI_FREE (obj); -return len >0 ? len :-1 ; +return len >0 ? len : -EIO ; } static ssize_t label_show(struct device *dev, struct device_attribute *attr,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1804/2214 PCI/sysfs: Handle a malformed _DSM result in acpi_attr_is_visible()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Wilczyński <[email protected]>
[ Upstream commit 1832dc1579aa7cc7cd41843770767e7a3ffa8364 ]
Currently, the "label" and "acpi_index" attributes are created whenever the _DSM function 0 bitmap advertises the Device Name function, without evaluating that function. The documented ABI states that each attribute is created only if the firmware has given a name or an instance number to the PCI device.
The bitmap says nothing about the object the function returns. Firmware that advertises the function but returns an object that cannot be parsed therefore produces attributes that exist and fail every read, as in the report below.
Evaluate the Device Name _DSM when deciding attribute visibility and create each attribute only when the element it exports has a type the read path accepts, mirroring the checks performed at read time. The SMBIOS attribute group already follows this pattern by performing the DMI lookup in its is_visible() callback. The read side checks remain in place since the two evaluations happen at different times.
This restores the behaviour from before commit 2fc59fe2ecdc ("PCI /
pci-label: treat PCI label with index 0 as valid label"), which switched visibility from evaluating the function to checking only the function 0 bitmap. The check is now made for each attribute, not once for both.
--- Documentation/ABI/testing/sysfs-bus-pci | 14 ++++++++--- drivers/pci/pci-label.c | 33 ++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 5 deletions(-)
Documentation/ABI/testing/sysfs-bus-pci +10 -4
@@ -211,10 +211,16 @@ Contact: Narendra K <[email protected]>, [email protected] Description: Reading this attribute will provide the firmware given name (SMBIOS type 41 string or ACPI _DSM string) of - the PCI device. The attribute will be created only - if the firmware has given a name to the PCI device. - ACPI _DSM string name will be given priority if the - system firmware provides SMBIOS type 41 string also. + the PCI device. The attribute will be created only if the + firmware naming mechanism is implemented for the device: + a SMBIOS type 41 record with a non-empty reference + designation, or a Device Name _DSM that returns the name + as a string or a buffer. The value read is empty when the + firmware implements the _DSM but gives the device no name, + which per PCI Firmware r3.3, sec 4.6.7 the firmware reports + as a NULL string. ACPI _DSM string name will be given + priority if the system firmware provides SMBIOS type 41 + string also. Users: Userspace applications interested in knowing the firmware assigned name of the PCI device.
drivers/pci/pci-label.c +32 -1
@@ -217,11 +217,42 @@ static umode_t acpi_attr_is_visible(struct kobject *kobj, struct attribute *a, int n) {struct device *dev =kobj_to_dev (kobj); +union acpi_object *obj, *tmp; +umode_t mode =0 ;if (!device_has_acpi_name (dev))return 0 ; -return a->mode; +/* +* The bitmap from _DSM function 0 only advertises function 7, +* and whether the returned object can be parsed is a separate +* question. Evaluate it and expose each attribute only if the +* element it exports has one of the types the read path +* accepts, mirroring the checks in dsm_get_label(). +*/ + obj =acpi_evaluate_dsm (ACPI_HANDLE (dev), &pci_acpi_dsm_guid,0x2 , +DSM_PCI_DEVICE_NAME ,NULL ); +if (!obj) +return 0 ; + +if (obj->type !=ACPI_TYPE_PACKAGE || obj->package.count !=2 ) + goto out; + + tmp = obj->package.elements; +if (tmp[0 ].type !=ACPI_TYPE_INTEGER ) + goto out; + +if (a == &dev_attr_acpi_index.attr) + mode = a->mode; +else if (a == &dev_attr_label.attr && + (tmp[1 ].type ==ACPI_TYPE_STRING || + tmp[1 ].type ==ACPI_TYPE_BUFFER )) + mode = a->mode; + +out: +ACPI_FREE (obj); + +return mode; }const struct attribute_group pci_dev_acpi_attr_group = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1805/2214 ALSA: hda: Fix potential UAF for gating jack
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit 27cee4141c8de82cf051104ca830c3a209816033 ]
snd_hda_jack_set_gating_jack() assigns gated and gating variables from the succeeding calls of snd_hda_jack_tbl_get(). This works normally, but the second call might kick off the reallocation of the jack table, hence the first pointer might become invalid, which leads to a UAF.
For avoiding that pitfall, this patch changes the code to two phases:
the first to only create two entries, and the second phase to get the pointers from the table, so that no relocation can happen any longer.
--- sound/pci/hda/hda_jack.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
sound/pci/hda/hda_jack.c +6 -3
@@ -383,12 +383,15 @@ EXPORT_SYMBOL_GPL(snd_hda_jack_detect_enable);int snd_hda_jack_set_gating_jack (struct hda_codec *codec,hda_nid_t gated_nid,hda_nid_t gating_nid) { -struct hda_jack_tbl *gated =snd_hda_jack_tbl_new (codec, gated_nid,0 ); -struct hda_jack_tbl *gating = -snd_hda_jack_tbl_new (codec, gating_nid,0 ); +struct hda_jack_tbl *gated, *gating;WARN_ON (codec->dp_mst); +if (!snd_hda_jack_tbl_new (codec, gated_nid,0 ) || + !snd_hda_jack_tbl_new (codec, gating_nid,0 )) +return -ENOMEM ; + gated =snd_hda_jack_tbl_get_mst (codec, gated_nid,0 ); + gating =snd_hda_jack_tbl_get_mst (codec, gating_nid,0 );if (!gated || !gating)return -EINVAL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1806/2214 ALSA: usb-audio: Check mixer matrix size for UAC2/3 at parsing
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit 22185ffd7b31885d03fdeb20055a8707779a70f9 ]
The matrix of input/output channels specified in a UAC2/3 mixer unit must fit to the upper limit 256. Add a sanity check and returns an error if an invalid size is detected.
Stable-dep-of: c01fb2ed90c0 ("ALSA: usb-audio: Fix invalid UAC2/3 mixer unit matrix evaluation")
--- sound/usb/mixer.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
sound/usb/mixer.c +10 -0
@@ -2269,6 +2269,16 @@ static int parse_audio_mixer_unit(struct mixer_build *state, int unitid, num_outs = err; input_pins = desc->bNrInPins; +if (state->mixer->protocol ==UAC_VERSION_2 || + state->mixer->protocol ==UAC_VERSION_3 ) { +if (input_pins * num_outs >256 ) { +usb_audio_err (state->chip, +"invalid channels for MIXER UNIT %d: input=%d, output=%d\n" , + unitid, input_pins, num_outs); +return -EINVAL ; + } + } + num_ins =0 ; ich =0 ;for (pin =0 ; pin < input_pins; pin++) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1807/2214 ALSA: usb-audio: Fix invalid UAC2/3 mixer unit matrix evaluation
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit c01fb2ed90c0770560ea9cc1644f205956b26a70 ]
The bitmap matrix in the mixer unit descriptor for UAC2 and UAC3 has rather the size of input-pins x output-pins, while the current USB-audio driver code wrongly assumes the UAC1 bitmap matrix size, which is input-channels x output-pins. That is, when input pins have multiple channels, the column size differs and it leads to the accesses at a wrong position.
This patch corrects the access of the bitmap matrix for UAC2/UAC3. For making the code cleaner, split the parser to UAC1 and UAC2/3, too.
--- sound/usb/mixer.c | 112 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 78 insertions(+), 34 deletions(-)
sound/usb/mixer.c +78 -34
@@ -2165,7 +2165,7 @@ static bool mixer_bitmap_overflow(struct uac_mixer_unit_descriptor *desc,*/ static void build_mixer_unit_ctl (struct mixer_build *state,struct uac_mixer_unit_descriptor *desc, -int in_pin,int in_ch,int num_outs, +int in_ch,int num_outs,int unitid,struct usb_audio_term *iterm) {struct usb_mixer_elem_info *cval;
@@ -2250,34 +2250,13 @@ static int parse_audio_input_terminal(struct mixer_build *state, int unitid,/* * parse a mixer unit */ -static int parse_audio_mixer_unit (struct mixer_build *state,int unitid, -void *raw_desc) +/* UAC1 mixer unit */ +static int parse_audio_mixer_unit_v1 (struct mixer_build *state,int unitid, +int input_pins,int num_outs, +struct uac_mixer_unit_descriptor *desc) { -struct uac_mixer_unit_descriptor *desc = raw_desc;struct usb_audio_term iterm; -int input_pins, num_ins, num_outs; -int pin, ich, err; - - err =uac_mixer_unit_get_channels (state, desc); -if (err <0 ) { -usb_audio_err (state->chip, -"invalid MIXER UNIT descriptor %d\n" , - unitid); -return err; - } - - num_outs = err; - input_pins = desc->bNrInPins; - -if (state->mixer->protocol ==UAC_VERSION_2 || - state->mixer->protocol ==UAC_VERSION_3 ) { -if (input_pins * num_outs >256 ) { -usb_audio_err (state->chip, -"invalid channels for MIXER UNIT %d: input=%d, output=%d\n" , - unitid, input_pins, num_outs); -return -EINVAL ; - } - } +int num_ins, pin, ich, och, err; num_ins =0 ; ich =0 ;
@@ -2296,25 +2275,90 @@ static int parse_audio_mixer_unit(struct mixer_build *state, int unitid, num_ins, num_outs))break ;for (; ich < num_ins; ich++) { -int och, ich_has_controls =0 ; -for (och =0 ; och < num_outs; och++) {__u8 *c =uac_mixer_unit_bmControls (desc, state->mixer->protocol); -if (check_matrix_bitmap (c, ich, och, num_outs)) { - ich_has_controls =1 ; +if (check_matrix_bitmap (c, ich, och, num_outs))break ; - } } -if (ich_has_controls) -build_mixer_unit_ctl (state, desc, pin, ich, num_outs, +if (och < num_outs) +build_mixer_unit_ctl (state, desc, ich, num_outs, unitid, &iterm); } }return 0 ; } +/* UAC2/UAC3 mixer unit */ +static int parse_audio_mixer_unit_v2 (struct mixer_build *state,int unitid, +int input_pins,int num_outs, +struct uac_mixer_unit_descriptor *desc) +{ +struct usb_audio_term iterm; +int pin, och, err; + +if (input_pins * num_outs >256 || +mixer_bitmap_overflow (desc, state->mixer->protocol, + input_pins, num_outs)) { +usb_audio_err (state->chip, +"invalid channels for MIXER UNIT %d: input=%d, output=%d\n" , + unitid, input_pins, num_outs); +return -EINVAL ; + } + +for (pin =0 ; pin < input_pins; pin++) { + err =parse_audio_unit (state, desc->baSourceID[pin]); +if (err <0 ) +continue ; +if (!num_outs) +continue ; + err =check_input_term (state, desc->baSourceID[pin], &iterm); +if (err <0 ) +return err; + +for (och =0 ; och < num_outs; och++) { +__u8 *c =uac_mixer_unit_bmControls (desc, + state->mixer->protocol); + +if (check_matrix_bitmap (c, pin, och, num_outs)) +break ; + } +if (och < num_outs) +build_mixer_unit_ctl (state, desc, pin, num_outs, + unitid, &iterm); + } +return 0 ; +} + +static int parse_audio_mixer_unit (struct mixer_build *state,int unitid, +void *raw_desc) +{ +struct uac_mixer_unit_descriptor *desc = raw_desc; +int num_outs; + + num_outs =uac_mixer_unit_get_channels (state, desc); +if (num_outs <0 ) { +usb_audio_err (state->chip, +"invalid MIXER UNIT descriptor %d\n" , + unitid); +return num_outs; + } + +switch (state->mixer->protocol) { +case UAC_VERSION_1 : +default : +return parse_audio_mixer_unit_v1 (state, unitid, + desc->bNrInPins, num_outs, + desc); +case UAC_VERSION_2 : +case UAC_VERSION_3 : +return parse_audio_mixer_unit_v2 (state, unitid, + desc->bNrInPins, num_outs, + desc); + } +} +/* * Processing Unit / Extension Unit */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1808/2214 ALSA: core: Simplify snd_power_ref_and_wait() with the standard macro
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit 8c0ae778e2874f3742bd619000b791d178c187e2 ]
Use wait_event_cmd() macro and simplify snd_power_ref_wait() implementation. This may also cover possible races in the current open code, too.
Stable-dep-of: a69138357354 ("ALSA: core: Add missing barriers for power_ref vs card->shutdown")
--- sound/core/init.c | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-)
sound/core/init.c +5 -20
@@ -1154,29 +1154,14 @@ EXPORT_SYMBOL(snd_card_file_remove);*/ int snd_power_ref_and_wait (struct snd_card *card) { -wait_queue_entry_t wait; -int result =0 ; -snd_power_ref (card); -/* fastpath */ if (snd_power_get_state (card) ==SNDRV_CTL_POWER_D0 )return 0 ; -init_waitqueue_entry (&wait, current); -add_wait_queue (&card->power_sleep, &wait); -while (1 ) { -if (card->shutdown) { - result = -ENODEV ; -break ; - } -if (snd_power_get_state (card) ==SNDRV_CTL_POWER_D0 ) -break ; -snd_power_unref (card); -set_current_state (TASK_UNINTERRUPTIBLE ); -schedule_timeout (30 *HZ ); -snd_power_ref (card); - } -remove_wait_queue (&card->power_sleep, &wait); -return result; +wait_event_cmd (card->power_sleep, + card->shutdown || +snd_power_get_state (card) ==SNDRV_CTL_POWER_D0 , +snd_power_unref (card),snd_power_ref (card)); +return card->shutdown ? -ENODEV :0 ; }EXPORT_SYMBOL_GPL (snd_power_ref_and_wait);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1809/2214 ALSA: core: Make snd_card_disconnect() return void
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Uwe Kleine-König <[email protected]>
[ Upstream commit 663f922fd7a9e9342dca512db339c7fb2b59b8e6 ]
All callers from other files ignore the return value of this function. And it can only ever return a non-zero value if the parameter card is NULL.
Move the check for card being NULL into snd_card_free_when_closed() to keep the previous behaviour. Note this isn't necessary for snd_card_disconnect_sync() because if card was NULL in there the dereference of card for dev_err() would oops the kernel. Replace this by an oops triggered by the dereference of card for spin_lock_irq().
Stable-dep-of: a69138357354 ("ALSA: core: Add missing barriers for power_ref vs card->shutdown")
--- include/sound/core.h | 2 +- sound/core/init.c | 24 ++++++++---------------- 2 files changed, 9 insertions(+), 17 deletions(-)
include/sound/core.h +1 -1
@@ -280,7 +280,7 @@ int snd_devm_card_new(struct device *parent, int idx, const char *xid, struct module *module, size_t extra_size, struct snd_card **card_ret); -int snd_card_disconnect (struct snd_card *card); +void snd_card_disconnect (struct snd_card *card);void snd_card_disconnect_sync (struct snd_card *card);int snd_card_free (struct snd_card *card);int snd_card_free_when_closed (struct snd_card *card);
sound/core/init.c +8 -16
@@ -479,17 +479,17 @@ static const struct file_operations snd_shutdown_f_ops =* Note: The current implementation replaces all active file->f_op with special * dummy file operations (they do nothing except release). */ -int snd_card_disconnect (struct snd_card *card) +void snd_card_disconnect (struct snd_card *card) {struct snd_monitor_file *mfile;if (!card) -return -EINVAL ; +return ;spin_lock (&card->files_lock);if (card->shutdown) {spin_unlock (&card->files_lock); -return 0 ; +return ; } card->shutdown =1 ;
@@ -545,7 +545,6 @@ int snd_card_disconnect(struct snd_card *card)#ifdef CONFIG_PM snd_power_sync_ref (card);#endif -return 0 ; }EXPORT_SYMBOL (snd_card_disconnect);
@@ -560,15 +559,7 @@ EXPORT_SYMBOL(snd_card_disconnect);*/ void snd_card_disconnect_sync (struct snd_card *card) { -int err; - - err =snd_card_disconnect (card); -if (err <0 ) { -dev_err (card->dev, -"snd_card_disconnect error (%d), skipping sync\n" , - err); -return ; - } +snd_card_disconnect (card);spin_lock_irq (&card->files_lock); wait_event_lock_irq(card->remove_sleep,
@@ -616,9 +607,10 @@ static int snd_card_do_free(struct snd_card *card)*/ int snd_card_free_when_closed (struct snd_card *card) { -int ret =snd_card_disconnect (card); -if (ret) -return ret; +if (!card) +return -EINVAL ; + +snd_card_disconnect (card);put_device (&card->card_dev);return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1810/2214 ALSA: core: Remove superfluous CONFIG_PM
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit da0713fff528112890aac02fea08937b65d5c8ba ]
Since the recent code change, the conditional build with CONFIG_PM is calling only snd_power_sync_ref(). As a dummy function is provided for this function, we can get rid of CONFIG_PM gracefully now.
Stable-dep-of: a69138357354 ("ALSA: core: Add missing barriers for power_ref vs card->shutdown")
--- sound/core/init.c | 2 -- 1 file changed, 2 deletions(-)
sound/core/init.c +0 -2
@@ -542,9 +542,7 @@ void snd_card_disconnect(struct snd_card *card)clear_bit (card->number, snd_cards_lock);mutex_unlock (&snd_card_mutex); -#ifdef CONFIG_PM snd_power_sync_ref (card); -#endif }EXPORT_SYMBOL (snd_card_disconnect);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1811/2214 ALSA: core: Fix unintuitive behavior of snd_power_ref_and_wait()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit b113a891252c3fa4fab11ec8c2894a22ecaf278c ]
snd_power_ref_and_wait() takes the power refcount and doesn't leave it no matter whether it returns an error or not. However, the majority of callers don't expect but just returns without unreferencing in the caller side upon errors.
For addressing the potential refcount unbalance, rather correct the behavior of snd_power_ref_wait() to unreference upon returning an error.
Note that the problem above is likely negligible; the function returns an error only when the sound card is being shutdown, hence it doesn't matter about the power refcount any longer at such a state.
Stable-dep-of: a69138357354 ("ALSA: core: Add missing barriers for power_ref vs card->shutdown")
--- sound/core/init.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
sound/core/init.c +8 -3
@@ -1138,7 +1138,7 @@ EXPORT_SYMBOL(snd_card_file_remove);* typically around calling control ops. * * The caller needs to pull down the refcount via snd_power_unref() later -* no matter whether the error is returned from this function or not. +* when this function returns 0. * * Return: Zero if successful, or a negative error code. */
@@ -1151,7 +1151,11 @@ int snd_power_ref_and_wait(struct snd_card *card) card->shutdown ||snd_power_get_state (card) ==SNDRV_CTL_POWER_D0 , snd_power_unref(card), snd_power_ref(card)); -return card->shutdown ? -ENODEV :0 ; +if (card->shutdown) { +snd_power_unref (card); +return -ENODEV ; + } +return 0 ; }EXPORT_SYMBOL_GPL (snd_power_ref_and_wait);
@@ -1168,7 +1172,8 @@ int snd_power_wait(struct snd_card *card)int ret; ret =snd_power_ref_and_wait (card); -snd_power_unref (card); +if (!ret) +snd_power_unref (card);return ret; }EXPORT_SYMBOL (snd_power_wait);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1812/2214 ALSA: core: Check shutdown flag at D0 power-state, too
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit ad63c5b62843895e8c3cd7291ed07cc659df0355 ]
The snd_power_ref_and_wait() skips the card->shutdown check when the card is already in D0 state and immediately returns as successful, by assuming the all-green in D0. This assumption makes the code after this sync point behaving as if all power is up and ready, even though actually it might have been already at the disconnected state.
Add the missing check of shutdown flag there for the more consistent behavior.
Stable-dep-of: a69138357354 ("ALSA: core: Add missing barriers for power_ref vs card->shutdown")
--- sound/core/init.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
sound/core/init.c +6 -6
@@ -1145,12 +1145,12 @@ EXPORT_SYMBOL(snd_card_file_remove);int snd_power_ref_and_wait (struct snd_card *card) {snd_power_ref (card); -if (snd_power_get_state (card) ==SNDRV_CTL_POWER_D0 ) -return 0 ; -wait_event_cmd (card->power_sleep, - card->shutdown || -snd_power_get_state (card) ==SNDRV_CTL_POWER_D0 , -snd_power_unref (card),snd_power_ref (card)); +if (snd_power_get_state (card) !=SNDRV_CTL_POWER_D0 ) { +wait_event_cmd (card->power_sleep, + card->shutdown || +snd_power_get_state (card) ==SNDRV_CTL_POWER_D0 , +snd_power_unref (card),snd_power_ref (card)); + }if (card->shutdown) {snd_power_unref (card);return -ENODEV ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1813/2214 ALSA: core: Add missing barriers for power_ref vs card->shutdown
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit a6913835735469751f56473f5212eb291a4805e7 ]
snd_power_ref_and_wait() increments card->power_ref and then reads card->shutdown (and the power state) locklessly, while snd_card_disconnect() sets card->shutdown and then waits for power_ref to drop to zero via snd_power_sync_ref(). Due to the missing barrier on both sides, the caller proceeds with shutdown still seen as false, while the disconnect side sees a zero refcount and continues tearing down incorrectly.
For addressing the potential race, add smp_mb__after_atomic() after the refcount increment and smp_mb() before snd_power_sync_ref() in snd_card_disconnect().
--- sound/core/init.c | 4 ++++ 1 file changed, 4 insertions(+)
sound/core/init.c +4 -0
@@ -542,6 +542,8 @@ void snd_card_disconnect(struct snd_card *card)clear_bit (card->number, snd_cards_lock);mutex_unlock (&snd_card_mutex); +/* order card->shutdown store against power_ref read */ +smp_mb ();snd_power_sync_ref (card); }EXPORT_SYMBOL (snd_card_disconnect);
@@ -1145,6 +1147,8 @@ EXPORT_SYMBOL(snd_card_file_remove);int snd_power_ref_and_wait (struct snd_card *card) {snd_power_ref (card); +/* order power_ref increment against card->shutdown read */ +smp_mb__after_atomic ();if (snd_power_get_state (card) !=SNDRV_CTL_POWER_D0 ) { wait_event_cmd(card->power_sleep, card->shutdown ||
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1814/2214 ALSA: hda: Avoid non-operational GPU warning at regular device removal
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit 3af4ed9f927c469f23d03a76e3b438ed09715bd3 ]
When a hda-intel driver is removed manually and it has a GPU with switcheroo, it always gives a warning like "GPU sound probed, but not operational:..." no matter whether GPU has been actually operational or not. This warning was originally put for machines that really suffer from the non-operational GPU HDMI audio, but it's seen at the common path a normal device removal also goes over.
For avoiding a confusing warning, move the check and the warning at the error path of azx_probe_continue() that is the point where the non-functional GPU gets detected and given up.
--- sound/pci/hda/hda_intel.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
sound/pci/hda/hda_intel.c +2 -1
@@ -1375,7 +1375,6 @@ static void azx_free(struct azx *chip)* actually stop the chip) to allow GPU to suspend via * vga_switcheroo, and print a warning. */ -dev_warn (&pci->dev,"GPU sound probed, but not operational: please add a quirk to driver_denylist\n" );pm_runtime_disable (&pci->dev);pm_runtime_set_suspended (&pci->dev);pm_runtime_enable (&pci->dev);
@@ -2377,6 +2376,8 @@ static int azx_probe_continue(struct azx *chip) out_free:if (err <0 ) {pci_set_drvdata (pci,NULL ); +if (hda->vga_switcheroo_registered) +dev_warn (&pci->dev,"GPU sound probed, but not operational: please add a quirk to driver_denylist\n" );snd_card_free (chip->card);return err; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1815/2214 crypto: talitos - allocate channels with main struct
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rosen Penev <[email protected]>
[ Upstream commit 24818f77603b3fcb7f3da5802b28bcc5ac7604aa ]
Use a flexible array member to combine allocations.
Add __counted_by for extra runtime analysis.
Error in case of no channels as they are required.
Stable-dep-of: 666d66df2525 ("crypto: talitos - init tasklets before requesting IRQs")
--- drivers/crypto/talitos.c | 19 +++++++------------ drivers/crypto/talitos.h | 5 +++-- 2 files changed, 10 insertions(+), 14 deletions(-)
drivers/crypto/talitos.c +7 -12
@@ -3342,14 +3342,20 @@ static int talitos_probe(struct platform_device *ofdev)struct device *dev = &ofdev->dev;struct device_node *np = ofdev->dev.of_node;struct talitos_private *priv; +unsigned int num_channels;int i, err;int stride;struct resource *res; - priv =devm_kzalloc (dev,sizeof (struct talitos_private ),GFP_KERNEL ); +if (of_property_read_u32 (np,"fsl,num-channels" , &num_channels)) +return -EINVAL ; + + priv =devm_kzalloc (dev,struct_size (priv, chan, num_channels),GFP_KERNEL );if (!priv)return -ENOMEM ; + priv->num_channels = num_channels; +INIT_LIST_HEAD (&priv->alg_list);dev_set_drvdata (dev, priv);
@@ -3369,7 +3375,6 @@ static int talitos_probe(struct platform_device *ofdev) }/* get SEC version capabilities from device tree */ -of_property_read_u32 (np,"fsl,num-channels" , &priv->num_channels);of_property_read_u32 (np,"fsl,channel-fifo-len" , &priv->chfifo_len);of_property_read_u32 (np,"fsl,exec-units-mask" , &priv->exec_units); of_property_read_u32(np, "fsl,descriptor-types-mask",
@@ -3444,16 +3449,6 @@ static int talitos_probe(struct platform_device *ofdev) } } - priv->chan =devm_kcalloc (dev, - priv->num_channels, -sizeof (struct talitos_channel ), -GFP_KERNEL ); -if (!priv->chan) { -dev_err (dev,"failed to allocate channel management space\n" ); - err = -ENOMEM ; - goto err_out; - } - priv->fifo_len =roundup_pow_of_two (priv->chfifo_len);for (i =0 ; i < priv->num_channels; i++) {
drivers/crypto/talitos.h +3 -2
@@ -139,8 +139,6 @@ struct talitos_private {*/ unsigned int fifo_len; -struct talitos_channel *chan; -/* next channel to be assigned next incoming descriptor */ atomic_t last_chan____cacheline_aligned ;
@@ -153,6 +151,9 @@ struct talitos_private {/* hwrng device */ struct hwrng rng;bool rng_registered; + + struct talitos_channel chan[] __counted_by(num_channels); + };/* .features flag */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1816/2214 crypto: talitos - use devm_platform_ioremap_resource()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rosen Penev <[email protected]>
[ Upstream commit 463be1c718fb9f07bdce3d51363a17eac4522538 ]
platform_get_resource and devm_ioremap effectively open codes this.
The return type of devm_platform_ioremap_resource() is also nice as it has multiple errors that it can return.
Because it internally calls devm_request_mem_region(), reg values and sizes cannot overlap. This was manually verified to be the case for all talitos users.
Stable-dep-of: 666d66df2525 ("crypto: talitos - init tasklets before requesting IRQs")
--- drivers/crypto/talitos.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/crypto/talitos.c +3 -7
@@ -3345,7 +3345,6 @@ static int talitos_probe(struct platform_device *ofdev)unsigned int num_channels;int i, err;int stride; -struct resource *res;if (of_property_read_u32 (np,"fsl,num-channels" , &num_channels))return -EINVAL ;
@@ -3364,13 +3363,10 @@ static int talitos_probe(struct platform_device *ofdev)spin_lock_init (&priv->reg_lock); - res =platform_get_resource (ofdev,IORESOURCE_MEM ,0 ); -if (!res) -return -ENXIO ; - priv->reg =devm_ioremap (dev, res->start,resource_size (res)); -if (!priv->reg) { + priv->reg =devm_platform_ioremap_resource (ofdev,0 ); +if (IS_ERR (priv->reg)) {dev_err (dev,"failed to of_iomap\n" ); - err = -ENOMEM ; + err =PTR_ERR (priv->reg); goto err_out; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1817/2214 crypto: talitos - Use platform_get_irq() to retrieve interrupt
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rosen Penev <[email protected]>
[ Upstream commit 4a1c7518cc31430b96458202b6a5b4064ff0cfa0 ]
Remove the need to call irq_dispose_mapping as needed by irq_of_parse_and_map().
Simplify the function as a result. No need for gotos anymore.
Add a missing free_irq.
Stable-dep-of: 666d66df2525 ("crypto: talitos - init tasklets before requesting IRQs")
--- drivers/crypto/talitos.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-)
drivers/crypto/talitos.c +13 -17
@@ -192,7 +192,7 @@ static int reset_device(struct device *dev) && --timeout)cpu_relax (); -if (priv->irq[1 ]) { +if (priv->irq[1 ] >0 ) { mcr =TALITOS_MCR_RCA1 |TALITOS_MCR_RCA3 ;setbits32 (priv->reg +TALITOS_MCR , mcr); }
@@ -3174,13 +3174,11 @@ static int talitos_remove(struct platform_device *ofdev)talitos_unregister_rng (dev);for (i =0 ; i <2 ; i++) -if (priv->irq[i]) { +if (priv->irq[i] >0 )free_irq (priv->irq[i], dev); -irq_dispose_mapping (priv->irq[i]); - }tasklet_kill (&priv->done_task[0 ]); -if (priv->irq[1 ]) +if (priv->irq[1 ] >0 )tasklet_kill (&priv->done_task[1 ]);return 0 ;
@@ -3286,26 +3284,26 @@ static struct talitos_crypto_alg *talitos_alg_alloc(struct device *dev,static int talitos_probe_irq (struct platform_device *ofdev) {struct device *dev = &ofdev->dev; -struct device_node *np = ofdev->dev.of_node;struct talitos_private *priv =dev_get_drvdata (dev);int err;bool is_sec1 =has_ftr_sec1 (priv); - priv->irq[0 ] =irq_of_parse_and_map (np,0 ); -if (!priv->irq[0 ]) { -dev_err (dev,"failed to map irq\n" ); -return -EINVAL ; - } + priv->irq[0 ] =platform_get_irq (ofdev,0 ); +if (priv->irq[0 ] <0 ) +return priv->irq[0 ]; +if (is_sec1) { err =request_irq (priv->irq[0 ], talitos1_interrupt_4ch,0 ,dev_driver_string (dev), dev); goto primary_out; } - priv->irq[1 ] =irq_of_parse_and_map (np,1 ); + priv->irq[1 ] =platform_get_irq_optional (ofdev,1 ); +if (priv->irq[1 ] == -EPROBE_DEFER ) +return priv->irq[1 ];/* get the primary irq line */ -if (!priv->irq[1 ]) { +if (priv->irq[1 ] <0 ) { err =request_irq (priv->irq[0 ], talitos2_interrupt_4ch,0 ,dev_driver_string (dev), dev); goto primary_out;
@@ -3321,7 +3319,6 @@ static int talitos_probe_irq(struct platform_device *ofdev) dev_driver_string(dev), dev);if (err) {dev_err (dev,"failed to request secondary irq\n" ); -irq_dispose_mapping (priv->irq[1 ]); priv->irq[1 ] =0 ; }
@@ -3330,7 +3327,6 @@ static int talitos_probe_irq(struct platform_device *ofdev) primary_out:if (err) {dev_err (dev,"failed to request primary irq\n" ); -irq_dispose_mapping (priv->irq[0 ]); priv->irq[0 ] =0 ; }
@@ -3431,7 +3427,7 @@ static int talitos_probe(struct platform_device *ofdev)tasklet_init (&priv->done_task[0 ], talitos1_done_4ch, (unsigned long )dev); }else { -if (priv->irq[1 ]) { +if (priv->irq[1 ] >0 ) {tasklet_init (&priv->done_task[0 ], talitos2_done_ch0_2, (unsigned long )dev); tasklet_init(&priv->done_task[1], talitos2_done_ch1_3,
@@ -3449,7 +3445,7 @@ static int talitos_probe(struct platform_device *ofdev)for (i =0 ; i < priv->num_channels; i++) { priv->chan[i].reg = priv->reg + stride * (i +1 ); -if (!priv->irq[1 ] || !(i &1 )) +if (priv->irq[1 ] <0 || !(i &1 )) priv->chan[i].reg +=TALITOS_CH_BASE_OFFSET ;spin_lock_init (&priv->chan[i].head_lock);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1818/2214 crypto: talitos - init tasklets before requesting IRQs
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rosen Penev <[email protected]>
[ Upstream commit 666d66df25253070cb297cb920b0bcfcfe5eb871 ]
The talitos interrupt handlers schedule priv->done_task[] via tasklet_schedule(). Since the second IRQ support, probe has requested the IRQs before calling tasklet_init(), so an interrupt already pending when a line is requested, e.g. engine state left by the bootloader or a kexec'd kernel, would schedule a tasklet with a NULL callback.
Look up the IRQ numbers and map the registers up front, so that -EPROBE_DEFER returns before anything is allocated and the done_task[] selection and reset_device() can see the secondary IRQ. Only request the IRQs once the channel fifos are allocated and init_device() has reset the engine. This matches remove(), which frees the IRQs before killing the tasklets.
remove() frees every IRQ number that is > 0, so make sure that only requested lines are set when it runs from the probe error path: clear both numbers when probe fails before the request, and clear any line talitos_probe_irq() did not request. Previously a failed primary request in the two-IRQ case freed the never-requested secondary line.
--- drivers/crypto/talitos.c | 54 ++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 21 deletions(-)
drivers/crypto/talitos.c +33 -21
@@ -3288,21 +3288,13 @@ static int talitos_probe_irq(struct platform_device *ofdev)int err;bool is_sec1 =has_ftr_sec1 (priv); - priv->irq[0 ] =platform_get_irq (ofdev,0 ); -if (priv->irq[0 ] <0 ) -return priv->irq[0 ]; -if (is_sec1) { err =request_irq (priv->irq[0 ], talitos1_interrupt_4ch,0 ,dev_driver_string (dev), dev); goto primary_out; } - priv->irq[1 ] =platform_get_irq_optional (ofdev,1 ); -if (priv->irq[1 ] == -EPROBE_DEFER ) -return priv->irq[1 ]; - -/* get the primary irq line */ +/* single (or primary) irq line */ if (priv->irq[1 ] <0 ) { err =request_irq (priv->irq[0 ], talitos2_interrupt_4ch,0 ,dev_driver_string (dev), dev);
@@ -3314,7 +3306,7 @@ static int talitos_probe_irq(struct platform_device *ofdev)if (err) goto primary_out; -/* get the secondary irq line */ +/* secondary irq line */ err =request_irq (priv->irq[1 ], talitos2_interrupt_ch1_3,0 ,dev_driver_string (dev), dev);if (err) {
@@ -3327,7 +3319,9 @@ static int talitos_probe_irq(struct platform_device *ofdev) primary_out:if (err) {dev_err (dev,"failed to request primary irq\n" ); +/* neither line is requested, keep remove() from freeing them */ priv->irq[0 ] =0 ; + priv->irq[1 ] =0 ; }return err;
@@ -3339,12 +3333,27 @@ static int talitos_probe(struct platform_device *ofdev)struct device_node *np = ofdev->dev.of_node;struct talitos_private *priv;unsigned int num_channels; +void __iomem *reg;int i, err;int stride; +int irq0; +int irq1;if (of_property_read_u32 (np,"fsl,num-channels" , &num_channels))return -EINVAL ; + irq0 =platform_get_irq (ofdev,0 ); +if (irq0 <0 ) +return irq0; + + irq1 =platform_get_irq_optional (ofdev,1 ); +if (irq1 == -EPROBE_DEFER ) +return irq1; + + reg =devm_platform_ioremap_resource (ofdev,0 ); +if (IS_ERR (reg)) +return PTR_ERR (reg); + priv =devm_kzalloc (dev,struct_size (priv, chan, num_channels),GFP_KERNEL );if (!priv)return -ENOMEM ;
@@ -3359,12 +3368,7 @@ static int talitos_probe(struct platform_device *ofdev)spin_lock_init (&priv->reg_lock); - priv->reg =devm_platform_ioremap_resource (ofdev,0 ); -if (IS_ERR (priv->reg)) { -dev_err (dev,"failed to of_iomap\n" ); - err =PTR_ERR (priv->reg); - goto err_out; - } + priv->reg = reg;/* get SEC version capabilities from device tree */ of_property_read_u32 (np,"fsl,channel-fifo-len" , &priv->chfifo_len);
@@ -3415,9 +3419,7 @@ static int talitos_probe(struct platform_device *ofdev) stride =TALITOS2_CH_STRIDE ; } - err =talitos_probe_irq (ofdev); -if (err) - goto err_out; + priv->irq[0 ] = irq0;if (has_ftr_sec1 (priv)) {if (priv->num_channels ==1 )
@@ -3427,6 +3429,7 @@ static int talitos_probe(struct platform_device *ofdev)tasklet_init (&priv->done_task[0 ], talitos1_done_4ch, (unsigned long )dev); }else { + priv->irq[1 ] = irq1;if (priv->irq[1 ] >0 ) {tasklet_init (&priv->done_task[0 ], talitos2_done_ch0_2, (unsigned long )dev);
@@ -3458,7 +3461,7 @@ static int talitos_probe(struct platform_device *ofdev)if (!priv->chan[i].fifo) {dev_err (dev,"failed to allocate request fifo %d\n" , i); err = -ENOMEM ; - goto err_out; + goto err_noirq; } atomic_set(&priv->chan[i].submit_count,
@@ -3471,9 +3474,14 @@ static int talitos_probe(struct platform_device *ofdev) err =init_device (dev);if (err) {dev_err (dev,"failed to initialize device\n" ); - goto err_out; + goto err_noirq; } +/* enable interrupts once the channel fifos and tasklets are set up */ + err =talitos_probe_irq (ofdev); +if (err) + goto err_out; +/* register the RNG, if available */ if (hw_supports (dev,DESC_HDR_SEL0_RNG )) { err =talitos_register_rng (dev);
@@ -3531,6 +3539,10 @@ static int talitos_probe(struct platform_device *ofdev)return 0 ; +err_noirq: +/* the irq numbers are known, but the lines are not requested yet */ + priv->irq[0 ] =0 ; + priv->irq[1 ] =0 ; err_out:talitos_remove (ofdev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1819/2214 nilfs2: reject non-regular inodes in dsync recovery
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jake Labelle <[email protected]>
[ Upstream commit ef2ccb1554df254eb4066171ce93e6d5fb1af2e3 ]
During roll-forward recovery, nilfs_recover_dsync_blocks() obtains the inode designated by fi_ino of a dsync log without checking its type. If a corrupted image designates a special inode (e.g. a device node) there, the inode's embedded bmap was never initialized:__nilfs_read_inode() calls nilfs_bmap_read() only for regular files, directories and symlinks. The subsequent nilfs_get_block() then dereferences the uninitialized bmap->b_ops and jumps through it, crashing the kernel or worse.
Regular files, directories, and symlinks are the only inode types with data blocks to recover; reject anything else before touching its block mapping.
[ryusuke: conformed AI tag to guidelines]
--- fs/nilfs2/recovery.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
fs/nilfs2/recovery.c +17 -0
@@ -510,6 +510,23 @@ static int nilfs_recover_dsync_blocks(struct the_nilfs *nilfs, goto failed_inode; } +/* +* Regular files, directories, and symlinks are the only +* inode types with data blocks and an initialized bmap; +* a crafted image can reference some other inode type +* here, whose i_bmap_data was never set up by +* __nilfs_read_inode(). +*/ +if (!likely (S_ISREG (inode->i_mode) ||S_ISDIR (inode->i_mode) || +S_ISLNK (inode->i_mode))) { +nilfs_warn (sb, +"%s: invalid inode type (ino=%lu, mode=0%o)" , + __func__, (unsigned long )rb->ino, + inode->i_mode); + err = -EINVAL ; + goto failed_inode; + } + pos = rb->blkoff << inode->i_blkbits; err =block_write_begin (inode->i_mapping, pos, blocksize,0 , &page, nilfs_get_block);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1820/2214 xen/blkback: Prevent missed completion when draining I/O
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gui-Dong Han <[email protected]>
[ Upstream commit 9b4df0baa2aa03d22310e59846ca628f7afd4115 ]
xen_blk_drain_io() sets drain before checking inflight. xen_blkbk_unmap_and_respond_callback() decrements inflight with atomic_dec_and_test() before checking drain.
The pre-wait condition check was added to avoid missing a completion, but atomic_set() is unordered. With one I/O in flight, the drain path can set drain to 1 and read inflight as 1 before the completion decrement. The completion path then decrements inflight to 0 but can still read drain as
0. It skips complete(), so the drain path waits until the timeout despite no I/O remaining.
Add a full barrier between setting drain and reading inflight. atomic_dec_and_test() already provides full ordering on the completion side.
Message-ID: <[email protected]>
--- drivers/block/xen-blkback/blkback.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/block/xen-blkback/blkback.c +7 -0
@@ -1021,6 +1021,13 @@ static void xen_blk_drain_io(struct xen_blkif_ring *ring)struct xen_blkif *blkif = ring->blkif;atomic_set (&blkif->drain,1 ); +/* +* Publish drain before checking inflight. Otherwise, +* xen_blkbk_unmap_and_respond_callback() can decrement inflight with +* atomic_dec_and_test() and still see drain == 0 after this path saw +* inflight > 0, missing the completion. +*/ +smp_mb (); do { if (atomic_read(&ring->inflight) == 0) break;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1821/2214 x86/PVH: dont truncate initrd address/size
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Beulich <[email protected]>
[ Upstream commit fcc43d1d6bf5fbd41e1e308b17187f9b759df56a ]
Consuming merely the lower halves of the provided values isn't very useful. (While generally loaders try to place it below 4G, especially when it's huge it may not fit there.)
Message-ID: <[email protected]>
--- arch/x86/platform/pvh/enlighten.c | 2 ++ 1 file changed, 2 insertions(+)
arch/x86/platform/pvh/enlighten.c +2 -0
@@ -82,7 +82,9 @@ static void __init init_pvh_bootparams(bool xen_guest)struct hvm_modlist_entry *modaddr =__va (pvh_start_info.modlist_paddr); pvh_bootparams.hdr.ramdisk_image = modaddr->paddr; + pvh_bootparams.ext_ramdisk_image = modaddr->paddr >>32 ; pvh_bootparams.hdr.ramdisk_size = modaddr->size; + pvh_bootparams.ext_ramdisk_size = modaddr->size >>32 ; }/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1822/2214 sound: usb: remove third argument of usb_maxpacket()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vincent Mailhol <[email protected]>
[ Upstream commit 80b2b03bacfc071ceaac034fa81d535d27d57b31 ]
The third argument of usb_maxpacket(): in_out has been deprecated because it could be derived from the second argument (e.g. using usb_pipeout(pipe)).
N.B. function usb_maxpacket() was made variadic to accommodate the transition from the old prototype with three arguments to the new one with only two arguments (so that no renaming is needed). The variadic argument is to be removed once all users of usb_maxpacket() get migrated.
Stable-dep-of: e2ef553dfe92 ("ALSA: line6: Reject too small max packet sizes")
--- sound/usb/line6/pcm.c | 4 ++-- sound/usb/midi.c | 4 ++-- sound/usb/usx2y/usb_stream.c | 6 +++--- sound/usb/usx2y/usbusx2yaudio.c | 2 +- sound/usb/usx2y/usx2yhwdeppcm.c | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-)
sound/usb/line6/pcm.c +2 -2
@@ -560,10 +560,10 @@ int line6_init_pcm(struct usb_line6 *line6, line6pcm->max_packet_size_in =usb_maxpacket (line6->usbdev, -usb_rcvisocpipe (line6->usbdev, ep_read),0 ); +usb_rcvisocpipe (line6->usbdev, ep_read)); line6pcm->max_packet_size_out =usb_maxpacket (line6->usbdev, -usb_sndisocpipe (line6->usbdev, ep_write),1 ); +usb_sndisocpipe (line6->usbdev, ep_write));if (!line6pcm->max_packet_size_in || !line6pcm->max_packet_size_out) {dev_err (line6pcm->line6->ifcdev,"cannot get proper max packet size\n" );
sound/usb/midi.c +2 -2
@@ -1361,7 +1361,7 @@ static int snd_usbmidi_in_endpoint_create(struct snd_usb_midi *umidi, pipe =usb_rcvintpipe (umidi->dev, ep_info->in_ep); else pipe =usb_rcvbulkpipe (umidi->dev, ep_info->in_ep); - length =usb_maxpacket (umidi->dev, pipe,0 ); + length =usb_maxpacket (umidi->dev, pipe);for (i =0 ; i <INPUT_URBS ; ++i) { buffer =usb_alloc_coherent (umidi->dev, length,GFP_KERNEL , &ep->urbs[i]->transfer_dma);
@@ -1450,7 +1450,7 @@ static int snd_usbmidi_out_endpoint_create(struct snd_usb_midi *umidi, pipe =usb_sndbulkpipe (umidi->dev, ep_info->out_ep);switch (umidi->usb_id) {default : - ep->max_transfer =usb_maxpacket (umidi->dev, pipe,1 ); + ep->max_transfer =usb_maxpacket (umidi->dev, pipe);break ;/* * Various chips declare a packet size larger than 4 bytes, but
sound/usb/usx2y/usb_stream.c +3 -3
@@ -51,7 +51,7 @@ static int init_pipe_urbs(struct usb_stream_kernel *sk, {int u, p;int maxpacket = use_packsize ? - use_packsize :usb_maxpacket (dev, pipe,usb_pipeout (pipe)); + use_packsize :usb_maxpacket (dev, pipe);int transfer_length = maxpacket * sk->n_o_ps; for (u = 0; u < USB_STREAM_NURBS;
@@ -171,7 +171,7 @@ struct usb_stream *usb_stream_new(struct usb_stream_kernel *sk, out_pipe =usb_sndisocpipe (dev, out_endpoint); max_packsize = use_packsize ? - use_packsize :usb_maxpacket (dev, in_pipe,0 ); + use_packsize :usb_maxpacket (dev, in_pipe);/* t_period = period_frames / sample_rate
@@ -187,7 +187,7 @@ struct usb_stream *usb_stream_new(struct usb_stream_kernel *sk, read_size += packets *USB_STREAM_URBDEPTH * (max_packsize +sizeof (struct usb_stream_packet )); - max_packsize =usb_maxpacket (dev, out_pipe,1 ); + max_packsize =usb_maxpacket (dev, out_pipe); write_size = max_packsize * packets *USB_STREAM_URBDEPTH ;if (read_size >=256 *PAGE_SIZE || write_size >=256 *PAGE_SIZE ) {
sound/usb/usx2y/usbusx2yaudio.c +1 -1
@@ -422,7 +422,7 @@ static int usx2y_urbs_allocate(struct snd_usx2y_substream *subs) pipe = is_playback ?usb_sndisocpipe (dev, subs->endpoint) :usb_rcvisocpipe (dev, subs->endpoint); - subs->maxpacksize =usb_maxpacket (dev, pipe, is_playback); + subs->maxpacksize =usb_maxpacket (dev, pipe);if (!subs->maxpacksize)return -EINVAL ;
sound/usb/usx2y/usx2yhwdeppcm.c +1 -1
@@ -321,7 +321,7 @@ static int usx2y_usbpcm_urbs_allocate(struct snd_usx2y_substream *subs) pipe = is_playback ?usb_sndisocpipe (dev, subs->endpoint) :usb_rcvisocpipe (dev, subs->endpoint); - subs->maxpacksize =usb_maxpacket (dev, pipe, is_playback); + subs->maxpacksize =usb_maxpacket (dev, pipe);if (!subs->maxpacksize)return -EINVAL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1823/2214 ALSA: line6: Reject too small max packet sizes
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit e2ef553dfe923959632e580bcad8583d922868ac ]
Although the LINE6 driver has a sanity check for the given max packet sizes, it still has an implicit requirement of the minimal size being bytes-per-frame; e.g. the impulse test signal assuming the fixed size, and when a too small size is specified by a malformed USB descriptor, this may lead to an OOB access.
Change the sanity check conditions to reject too small max packet sizes for avoiding the scenario above.
--- sound/usb/line6/pcm.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
sound/usb/line6/pcm.c +5 -1
@@ -564,7 +564,11 @@ int line6_init_pcm(struct usb_line6 *line6, line6pcm->max_packet_size_out =usb_maxpacket (line6->usbdev,usb_sndisocpipe (line6->usbdev, ep_write)); -if (!line6pcm->max_packet_size_in || !line6pcm->max_packet_size_out) { +/* reject max packet sizes smaller than bytes-per-frame; +* (the magic number 6 is taken from the playback case) +*/ +if (line6pcm->max_packet_size_in <6 || + line6pcm->max_packet_size_out <6 ) {dev_err (line6pcm->line6->ifcdev,"cannot get proper max packet size\n" );return -EINVAL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1824/2214 ALSA: line6: Fix potential OOB write in line6_capture_copy()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit d69798357b5d562bcda1af488cda3ead4d039f8f ]
line6_capture_copy() copies the data for the original byte size, but the buffer overwrap is checked against the frame size. Because of it, when the data size isn't aligned in frames, the remaining bytes might be still copied above the buffer size.
For avoiding the potential OOB write, correct the copied data size in line6_capture_copy() to be aligned with frames.
--- sound/usb/line6/capture.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
sound/usb/line6/capture.c +2 -1
@@ -129,7 +129,8 @@ void line6_capture_copy(struct snd_line6_pcm *line6pcm, char *fbuf, int fsize) }else {/* copy single chunk */ memcpy (runtime->dma_area + - line6pcm->in.pos_done * bytes_per_frame, fbuf, fsize); + line6pcm->in.pos_done * bytes_per_frame, fbuf, + frames * bytes_per_frame); } line6pcm->in.pos_done += frames;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1825/2214 ALSA: hda: intel: Cancel delayed work at shutdown, too
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit b83b78df0e53d9dd872d24e49a99658815b12770 ]
The shutdown procedure needs to cancel the delayed probe work in case where the probe work stalls or is slow but still possible to reactivated.
--- sound/pci/hda/hda_intel.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
sound/pci/hda/hda_intel.c +6 -1
@@ -2422,12 +2422,17 @@ static void azx_remove(struct pci_dev *pci)static void azx_shutdown (struct pci_dev *pci) {struct snd_card *card =pci_get_drvdata (pci); +struct hda_intel *hda;struct azx *chip;if (!card)return ; chip = card->private_data; -if (chip && chip->running) +if (!chip) +return ; + hda = container_of(chip, struct hda_intel, chip); +cancel_delayed_work_sync (&hda->probe_work); +if (chip->running)__azx_shutdown_chip (chip, true); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1826/2214 wifi: ath6kl: dont take RTNL in del_virtual_intf
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit 97aab70a03df478ffefcf890ed4be258c0240bcb ]
cfg80211 already holds the RTNL here, so this will just deadlock. Remove the extra RTNL acquisition.
Oddly enough this was all true even back when the
locking here was added, so this is just a revert
of a broken ~13 year old commit.
--- drivers/net/wireless/ath/ath6kl/cfg80211.c | 2 -- 1 file changed, 2 deletions(-)
drivers/net/wireless/ath/ath6kl/cfg80211.c +0 -2
@@ -1551,9 +1551,7 @@ static int ath6kl_cfg80211_del_iface(struct wiphy *wiphy,ath6kl_cfg80211_vif_stop (vif,test_bit (WMI_READY , &ar->flag)); -rtnl_lock ();ath6kl_cfg80211_vif_cleanup (vif); -rtnl_unlock ();return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1827/2214 wifi: mac80211: clear fragment cache entry is_protected
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit f3d29dc9224b0881d10d34664456adf113bc4777 ]
In practice, we probably shouldn't end up with a fragmented frame that's protected, filled into the cache, finished or dropped and then the next frame is unprotected, since only unicast data frames can be fragmented.
However, tools complain and it's more correct to be able to do this (e.g. an unencrypted fragmented EAPOL _could_, at least in theory, happen), so clear the flag when the entry is reused.
--- net/mac80211/rx.c | 1 + 1 file changed, 1 insertion(+)
net/mac80211/rx.c +1 -0
@@ -2180,6 +2180,7 @@ ieee80211_reassemble_add(struct ieee80211_fragment_cache *cache, entry->rx_queue = rx_queue; entry->last_frag = frag; entry->check_sequential_pn = false; + entry->is_protected = false; entry->extra_len =0 ;return entry;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1828/2214 wifi: mac80211: mesh: use hlist_add_head_rcu()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit 2ce8b78102e91c9d6536630cdef96491121c84d3 ]
The mesh paths walk list used under RCU, so we must use hlist_add_head_rcu() to publish an entry. Fix one place that didn't do that.
--- net/mac80211/mesh_pathtbl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/mac80211/mesh_pathtbl.c +1 -1
@@ -419,7 +419,7 @@ struct mesh_path *mesh_path_add(struct ieee80211_sub_if_data *sdata, &new_mpath->rhash, mesh_rht_params);if (!mpath) -hlist_add_head (&new_mpath->walk_list, &tbl->walk_head); +hlist_add_head_rcu (&new_mpath->walk_list, &tbl->walk_head);spin_unlock_bh (&tbl->walk_lock);if (mpath) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1829/2214 wifi: mac80211: kill wake_txqs_tasklet on unregistration
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit 8ea4f50c3426aaaf3f4c118ee2c2876326ca5db5 ]
We never kill the wake_txqs_tasklet so it could be running while the hardware is being freed. Kill it, late enough to never be able to restart afterwards.
--- net/mac80211/main.c | 2 ++ 1 file changed, 2 insertions(+)
net/mac80211/main.c +2 -0
@@ -1407,6 +1407,8 @@ void ieee80211_unregister_hw(struct ieee80211_hw *hw)flush_work (&local->sched_scan_stopped_work);flush_work (&local->radar_detected_work); +tasklet_kill (&local->wake_txqs_tasklet); +ieee80211_clear_tx_pending (local);rate_control_deinitialize (local);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1830/2214 wifi: mac80211: init radiotap iter after length checks
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit e3cf8da7e0c560db67ac5ee8c9197514bb298ea7 ]
The radiotap iterator initialization will already parse the presence bitmaps, so it accesses a good part of the header. This might not be present in the linear part of the SKB, we haven't checked it at this point. Check the lengths first.
--- net/mac80211/tx.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
net/mac80211/tx.c +4 -3
@@ -2087,8 +2087,6 @@ bool ieee80211_parse_tx_radiotap(struct sk_buff *skb,struct ieee80211_radiotap_header *rthdr = (struct ieee80211_radiotap_header *) skb->data;struct ieee80211_tx_info *info =IEEE80211_SKB_CB (skb); -int ret =ieee80211_radiotap_iterator_init (&iterator, rthdr, skb->len, -NULL );u16 txflags;u16 rate =0 ;bool rate_found = false;
@@ -2097,11 +2095,14 @@ bool ieee80211_parse_tx_radiotap(struct sk_buff *skb,u8 mcs_known, mcs_flags, mcs_bw;u16 vht_known;u8 vht_mcs =0 , vht_nss =0 ; -int i; +int ret, i;if (!ieee80211_validate_radiotap_len (skb))return false; + ret =ieee80211_radiotap_iterator_init (&iterator, rthdr, skb->len, +NULL ); + info->flags |=IEEE80211_TX_INTFL_DONT_ENCRYPT |IEEE80211_TX_CTL_DONTFRAG ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1831/2214 rtc: abx80x: fix error check after i2c_smbus_read in read_alarm()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Antoni Pokusinski <[email protected]>
[ Upstream commit 07c57022afb3afc0d7c20efef45a4d3c7389b1c0 ]
i2c_smbus_read_i2c_block_data() returns the number of bytes read on success and a negative error code on failure. The existing code treated any non-zero return value as an error.
Fix the error handling by checking only for negative return values.
--- drivers/rtc/rtc-abx80x.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/rtc/rtc-abx80x.c +4 -2
@@ -282,8 +282,10 @@ static int abx80x_read_alarm(struct device *dev, struct rtc_wkalrm *t) err =i2c_smbus_read_i2c_block_data (client,ABX8XX_REG_ASC ,sizeof (buf), buf); -if (err) +if (err <0 )return err; +if (err <ARRAY_SIZE (buf)) +return -EIO ; irq_mask =i2c_smbus_read_byte_data (client,ABX8XX_REG_IRQ );if (irq_mask <0 )
@@ -299,7 +301,7 @@ static int abx80x_read_alarm(struct device *dev, struct rtc_wkalrm *t) t->enabled = !!(irq_mask &ABX8XX_IRQ_AIE ); t->pending = (buf[6 ] &ABX8XX_STATUS_AF ) && t->enabled; -return err; +return 0 ; }static int abx80x_set_alarm (struct device *dev,struct rtc_wkalrm *t)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1832/2214 rtc: abx80x: properly handle shared IRQs
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Antoni Pokusinski <[email protected]>
[ Upstream commit 632916c7bde35495f2f6776d8e335c3ec6e306ec ]
The abx80x RTC driver registers its interrupt handler with IRQF_SHARED, but the handler always returned IRQ_HANDLED and cleared the status register even when no interrupt source from the RTC was active.
This could cause the driver to claim interrupts belonging to other devices sharing the same IRQ line and could also clear unrelated status bits in the RTC status register.
Only handle the interrupt when the alarm or watchdog flags are set, and clear only those interrupt status bits that were handled. Return IRQ_NONE when the interrupt was not generated by the RTC.
--- drivers/rtc/rtc-abx80x.c | 52 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-)
drivers/rtc/rtc-abx80x.c +50 -2
@@ -48,12 +48,18 @@#define ABX8XX_CTRL2_RSVD BIT(5)#define ABX8XX_REG_IRQ 0x12 +#define ABX8XX_IRQ_EX1E BIT(0) +#define ABX8XX_IRQ_EX2E BIT(1)#define ABX8XX_IRQ_AIE BIT(2) +#define ABX8XX_IRQ_TIE BIT(3) +#define ABX8XX_IRQ_BLIE BIT(4)#define ABX8XX_IRQ_IM_1_4 (0x3 << 5)#define ABX8XX_REG_CD_TIMER_CTL 0x18#define ABX8XX_REG_OSC 0x1c +#define ABX8XX_OSC_ACIE BIT(0) +#define ABX8XX_OSC_OFIE BIT(1)#define ABX8XX_OSC_FOS BIT(3)#define ABX8XX_OSC_BOS BIT(4)#define ABX8XX_OSC_ACAL_512 BIT(5)
@@ -249,6 +255,7 @@ static irqreturn_t abx80x_handle_irq(int irq, void *dev_id)struct i2c_client *client = dev_id;struct abx80x_priv *priv =i2c_get_clientdata (client);struct rtc_device *rtc = priv->rtc; +unsigned int status_flags_clear;int status; status =i2c_smbus_read_byte_data (client,ABX8XX_REG_STATUS );
@@ -265,9 +272,15 @@ static irqreturn_t abx80x_handle_irq(int irq, void *dev_id)if (status &ABX8XX_STATUS_WDT )dev_alert (&client->dev,"watchdog timeout interrupt.\n" ); -i2c_smbus_write_byte_data (client,ABX8XX_REG_STATUS ,0 ); + status_flags_clear = status & (ABX8XX_STATUS_AF |ABX8XX_STATUS_WDT ); -return IRQ_HANDLED ; +if (status_flags_clear) { +i2c_smbus_write_byte_data (client,ABX8XX_REG_STATUS , + status & ~status_flags_clear); +return IRQ_HANDLED ; + } + +return IRQ_NONE ; }static int abx80x_read_alarm (struct device *dev,struct rtc_wkalrm *t)
@@ -821,6 +834,41 @@ static int abx80x_probe(struct i2c_client *client,i2c_set_clientdata (client, priv); +/* Disable unused interrupts */ + data =i2c_smbus_read_byte_data (client,ABX8XX_REG_IRQ ); +if (data <0 ) { +dev_err (&client->dev,"Unable to read irq register\n" ); +return -EIO ; + } + + err =i2c_smbus_write_byte_data (client,ABX8XX_REG_IRQ , + data & ~(ABX8XX_IRQ_EX1E | +ABX8XX_IRQ_EX2E | +ABX8XX_IRQ_TIE | +ABX8XX_IRQ_BLIE )); +if (err <0 ) { +dev_err (&client->dev,"Unable to write irq register\n" ); +return -EIO ; + } + + data =i2c_smbus_read_byte_data (client,ABX8XX_REG_OSC ); +if (data <0 ) { +dev_err (&client->dev,"Unable to read Oscillator Control register\n" ); +return -EIO ; + } + +/* Unlock write access to Oscillator Control Register */ +if (abx80x_write_config_key (client,ABX8XX_CFG_KEY_OSC ) <0 ) +return -EIO ; + + err =i2c_smbus_write_byte_data (client,ABX8XX_REG_OSC , + data & ~(ABX8XX_OSC_ACIE | +ABX8XX_OSC_OFIE )); +if (err <0 ) { +dev_err (&client->dev,"Unable to write Oscillator Control register\n" ); +return -EIO ; + } +if (abx80x_caps[part].has_wdog) { err =abx80x_setup_watchdog (priv);if (err)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1833/2214 seq_buf: Add seq_buf_do_printk() helper
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sergey Senozhatsky <[email protected]>
[ Upstream commit 96928d9032a7c34f12a88df879665562bcebf59a ]
Sometimes we use seq_buf to format a string buffer, which we then pass to printk(). However, in certain situations the seq_buf string buffer can get too big, exceeding the PRINTKRB_RECORD_MAX bytes limit, and causing printk() to truncate the string.
Add a new seq_buf helper. This helper prints the seq_buf string buffer line by line, using \n as a delimiter, rather than passing the whole string buffer to printk() at once.
Stable-dep-of: fa291d6429eb ("PCI/P2PDMA: Safely terminate ACS redirect lists")
--- include/linux/seq_buf.h | 2 ++ lib/seq_buf.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+)
include/linux/seq_buf.h +2 -0
@@ -159,4 +159,6 @@ extern int seq_buf_bprintf(struct seq_buf *s, const char *fmt, const u32 *binary);#endif +void seq_buf_do_printk (struct seq_buf *s,const char *lvl); +#endif /* _LINUX_SEQ_BUF_H */
lib/seq_buf.c +32 -0
@@ -93,6 +93,38 @@ int seq_buf_printf(struct seq_buf *s, const char *fmt, ...) }EXPORT_SYMBOL_GPL (seq_buf_printf); +/** +* seq_buf_do_printk - printk seq_buf line by line +* @s: seq_buf descriptor +* @lvl: printk level +* +* printk()-s a multi-line sequential buffer line by line. The function +* makes sure that the buffer in @s is nul terminated and safe to read +* as a string. +*/ +void seq_buf_do_printk (struct seq_buf *s,const char *lvl) +{ +const char *start, *lf; + +if (s->size ==0 || s->len ==0 ) +return ; + +seq_buf_terminate (s); + + start = s->buffer; +while ((lf =strchr (start,'\n' ))) { +int len = lf - start +1 ; + +printk ("%s%.*s" , lvl, len, start); + start = ++lf; + } + +/* No trailing LF */ +if (start < s->buffer + s->len) +printk ("%s%s\n" , lvl, start); +} +EXPORT_SYMBOL_GPL (seq_buf_do_printk); +#ifdef CONFIG_BINARY_PRINTF /** * seq_buf_bprintf - Write the printf string from binary arguments
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1834/2214 tracing: Move readpos from seq_buf to trace_seq
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthew Wilcox (Oracle) <[email protected]>
[ Upstream commit d0ed46b60396cfa7e0056f55e1ce0b43c7db57b6 ]
To make seq_buf more lightweight as a string buf, move the readpos member from seq_buf to its container, trace_seq. That puts the responsibility of maintaining the readpos entirely in the tracing code. If some future users want to package up the readpos with a seq_buf, we can define a new struct then.
Stable-dep-of: fa291d6429eb ("PCI/P2PDMA: Safely terminate ACS redirect lists")
--- include/linux/seq_buf.h | 5 +---- include/linux/trace_seq.h | 2 ++ kernel/trace/trace.c | 10 +++++----- kernel/trace/trace_seq.c | 6 +++++- lib/seq_buf.c | 22 ++++++++++------------ 5 files changed, 23 insertions(+), 22 deletions(-)
include/linux/seq_buf.h +1 -4
@@ -14,19 +14,16 @@* @buffer: pointer to the buffer * @size: size of the buffer * @len: the amount of data inside the buffer -* @readpos: The next position to read in the buffer. */ struct seq_buf {char *buffer;size_t size;size_t len; -loff_t readpos; };static inline void seq_buf_clear (struct seq_buf *s) { s->len =0 ; - s->readpos =0 ; } static inline void
@@ -143,7 +140,7 @@ extern __printf(2, 0)int seq_buf_vprintf (struct seq_buf *s,const char *fmt,va_list args);extern int seq_buf_print_seq (struct seq_file *m,struct seq_buf *s);extern int seq_buf_to_user (struct seq_buf *s,char __user *ubuf, -int cnt); +size_t start,int cnt);extern int seq_buf_puts (struct seq_buf *s,const char *str);extern int seq_buf_putc (struct seq_buf *s,unsigned char c);extern int seq_buf_putmem (struct seq_buf *s,const void *mem,unsigned int len);
include/linux/trace_seq.h +2 -0
@@ -14,6 +14,7 @@struct trace_seq {char buffer[PAGE_SIZE ];struct seq_buf seq; +size_t readpos;int full; };
@@ -22,6 +23,7 @@ trace_seq_init(struct trace_seq *s) {seq_buf_init (&s->seq, s->buffer,PAGE_SIZE ); s->full =0 ; + s->readpos =0 ; }/**
kernel/trace/trace.c +5 -5
@@ -1675,15 +1675,15 @@ static ssize_t trace_seq_to_buffer(struct trace_seq *s, void *buf, size_t cnt) {int len; -if (trace_seq_used (s) <= s->seq.readpos) +if (trace_seq_used (s) <= s->readpos)return -EBUSY ; - len =trace_seq_used (s) - s->seq.readpos; + len =trace_seq_used (s) - s->readpos;if (cnt > len) cnt = len; -memcpy (buf, s->buffer + s->seq.readpos, cnt); +memcpy (buf, s->buffer + s->readpos, cnt); - s->seq.readpos += cnt; + s->readpos += cnt;return cnt; }
@@ -6907,7 +6907,7 @@ tracing_read_pipe(struct file *filp, char __user *ubuf,/* Now copy what we have to the user */ sret =trace_seq_to_user (&iter->seq, ubuf, cnt); -if (iter->seq.seq.readpos >=trace_seq_used (&iter->seq)) +if (iter->seq.readpos >=trace_seq_used (&iter->seq))trace_seq_init (&iter->seq);/*
kernel/trace/trace_seq.c +5 -1
@@ -369,8 +369,12 @@ EXPORT_SYMBOL_GPL(trace_seq_path);*/ int trace_seq_to_user (struct trace_seq *s,char __user *ubuf,int cnt) { +int ret;__trace_seq_init (s); -return seq_buf_to_user (&s->seq, ubuf, cnt); + ret =seq_buf_to_user (&s->seq, ubuf, s->readpos, cnt); +if (ret >0 ) + s->readpos += ret; +return ret; }EXPORT_SYMBOL_GPL (trace_seq_to_user);
lib/seq_buf.c +10 -12
@@ -324,23 +324,24 @@ int seq_buf_path(struct seq_buf *s, const struct path *path, const char *esc)* seq_buf_to_user - copy the sequence buffer to user space * @s: seq_buf descriptor * @ubuf: The userspace memory location to copy to +* @start: The first byte in the buffer to copy * @cnt: The amount to copy * * Copies the sequence buffer into the userspace memory pointed to -* by @ubuf. It starts from the last read position (@s->readpos) -* and writes up to @cnt characters or till it reaches the end of -* the content in the buffer (@s->len), which ever comes first. +* by @ubuf. It starts from @start and writes up to @cnt characters +* or until it reaches the end of the content in the buffer (@s->len), +* whichever comes first. * * On success, it returns a positive number of the number of bytes * it copied. * * On failure it returns -EBUSY if all of the content in the * sequence has been already read, which includes nothing in the -* sequence (@s->len == @s->readpos). +* sequence (@s->len == @start). * * Returns -EFAULT if the copy to userspace fails. */ -int seq_buf_to_user (struct seq_buf *s,char __user *ubuf,int cnt) +int seq_buf_to_user (struct seq_buf *s,char __user *ubuf,size_t start,int cnt) {int len;int ret;
@@ -350,20 +351,17 @@ int seq_buf_to_user(struct seq_buf *s, char __user *ubuf, int cnt) len =seq_buf_used (s); -if (len <= s->readpos) +if (len <= start)return -EBUSY ; - len -= s->readpos; + len -= start;if (cnt > len) cnt = len; - ret =copy_to_user (ubuf, s->buffer + s->readpos, cnt); + ret =copy_to_user (ubuf, s->buffer + start, cnt);if (ret == cnt)return -EFAULT ; - cnt -= ret; - - s->readpos += cnt; -return cnt; +return cnt - ret; }/**
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1835/2214 seq_buf: Introduce DECLARE_SEQ_BUF and seq_buf_str()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kees Cook <[email protected]>
[ Upstream commit dcc4e5728eeaeda84878ca0018758cff1abfca21 ]
Solve two ergonomic issues with struct seq_buf;
1) Too much boilerplate is required to initialize:
struct seq_buf s; char buf[32]; seq_buf_init(s, buf, sizeof(buf));
Instead, we can build this directly on the stack. Provide DECLARE_SEQ_BUF() macro to do this:
DECLARE_SEQ_BUF(s, 32);
2) %NUL termination is fragile and requires 2 steps to get a valid C String (and is a layering violation exposing the "internals" of seq_buf):
seq_buf_terminate(s); do_something(s->buffer);
Instead, we can just return s->buffer directly after terminating it in the refactored seq_buf_terminate(), now known as seq_buf_str():
do_something(seq_buf_str(s));
Stable-dep-of: fa291d6429eb ("PCI/P2PDMA: Safely terminate ACS redirect lists")
--- include/linux/seq_buf.h | 21 +++++++++++++++++---- kernel/trace/trace.c | 11 +---------- lib/seq_buf.c | 4 +--- 3 files changed, 19 insertions(+), 17 deletions(-)
include/linux/seq_buf.h +17 -4
@@ -21,9 +21,18 @@ struct seq_buf {size_t len; }; +#define DECLARE_SEQ_BUF (NAME ,SIZE ) \ + char __ ## NAME ## _buffer[SIZE] = ""; \ + struct seq_buf NAME = { \ + .buffer = &__ ## NAME ## _buffer, \ + .size = SIZE, \ + } +static inline void seq_buf_clear (struct seq_buf *s) { s->len =0 ; +if (s->size) + s->buffer[0 ] ='\0' ; } static inline void
@@ -69,8 +78,8 @@ static inline unsigned int seq_buf_used(struct seq_buf *s) }/** -* seq_buf_terminate - Make sure buffer is nul terminated -* @s: the seq_buf descriptor to terminate. +* seq_buf_str - get %NUL-terminated C string from seq_buf +* @s: the seq_buf handle * * This makes sure that the buffer in @s is nul terminated and * safe to read as a string.
@@ -81,16 +90,20 @@ static inline unsigned int seq_buf_used(struct seq_buf *s)* * After this function is called, s->buffer is safe to use * in string operations. +* +* Returns @s->buf after making sure it is terminated. */ -static inline void seq_buf_terminate (struct seq_buf *s) +static inline const char *seq_buf_str (struct seq_buf *s) {if (WARN_ON (s->size ==0 )) -return ; +return "" ;if (seq_buf_buffer_left (s)) s->buffer[s->len] =0 ;else s->buffer[s->size -1 ] =0 ; + +return s->buffer; }/**
kernel/trace/trace.c +1 -10
@@ -3716,15 +3716,6 @@ static bool trace_safe_str(struct trace_iterator *iter, const char *str,return false; } -static const char *show_buffer (struct trace_seq *s) -{ -struct seq_buf *seq = &s->seq; - -seq_buf_terminate (seq); - -return seq->buffer; -} -static DEFINE_STATIC_KEY_FALSE (trace_no_verify);static int test_can_verify_check (const char *fmt, ...)
@@ -3864,7 +3855,7 @@ void trace_check_vprintf(struct trace_iterator *iter, const char *fmt,*/ if (WARN_ONCE (!trace_safe_str (iter, str, star, len),"fmt: '%s' current_buffer: '%s'" , - fmt,show_buffer (&iter->seq))) { + fmt,seq_buf_str (&iter->seq.seq))) {int ret;/* Try to safely read the string */
lib/seq_buf.c +1 -3
@@ -109,9 +109,7 @@ void seq_buf_do_printk(struct seq_buf *s, const char *lvl)if (s->size ==0 || s->len ==0 )return ; -seq_buf_terminate (s); - - start = s->buffer; + start =seq_buf_str (s);while ((lf =strchr (start,'\n' ))) {int len = lf - start +1 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1836/2214 PCI/P2PDMA: Safely terminate ACS redirect lists
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leon Romanovsky <[email protected]>
[ Upstream commit fa291d6429ebc1efb7fab011f643b842ae5f23f1 ]
seq_buf marks an overflow by setting len to size + 1. The ACS diagnostic path unconditionally writes a terminator to buffer[len - 1], so a path with enough ACS ports to fill the 128-byte buffer writes one byte beyond the buffer when verbose diagnostics are requested.
Use seq_buf_str() to terminate truncated output safely and remove the final semicolon only when the buffer did not overflow.
--- drivers/pci/p2pdma.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/pci/p2pdma.c +4 -2
@@ -515,11 +515,13 @@ calc_map_type_and_dist(struct pci_dev *provider, struct pci_dev *client, }if (verbose) { - acs_list.buffer[acs_list.len-1 ] =0 ;/* drop final semicolon */ +/* Drop the final semicolon; the list is not empty here */ +if (!seq_buf_has_overflowed (&acs_list)) + acs_list.buffer[acs_list.len -1 ] ='\0' ;pci_warn (client,"ACS redirect is set between the client and provider (%s)\n" ,pci_name (provider));pci_warn (client,"to disable ACS redirect for this path, add the kernel parameter: pci=disable_acs_redir=%s\n" , - acs_list.buffer); +seq_buf_str (&acs_list)); } acs_redirects = true;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1837/2214 PCI/P2PDMA: Gate the host bridge whitelist warning on verbose
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leon Romanovsky <[email protected]>
[ Upstream commit 36038f0e8377ef316b723d0d85b1510bc64069ab ]
calc_map_type_and_dist() prints every other diagnostic under its verbose argument, but reaches the "Host bridge not in P2PDMA whitelist" warning through host_bridge_whitelist(), which it hands acs_redirects instead. A caller that asked for a silent answer still gets the warning whenever any port on the path has an ACS redirect bit set, the CPU is not whitelisted by cpu_supports_p2pdma(), and the host bridge is not in pci_p2pdma_whitelist[].
pci_p2pmem_find_many() is such a caller. It sweeps every device with published p2pmem and asks for the distance to each client with verbose=false, and pci_p2pdma_distance_many() recomputes rather than consulting the map_types cache, so the warning repeats on every sweep.
The argument was never meant to say "ACS redirects were found". When commit cf201bfe8cdc ("PCI/P2PDMA: Warn if host bridge not in whitelist") added it, acs_redirects was a bool pointer that the quiet entry point passed as NULL:
if (verbose)
map = calc_map_type_and_dist_warn(provider, pci_client, &distance); else map = calc_map_type_and_dist(provider, pci_client, &distance, NULL, NULL);
so the argument was true on exactly the path that commit describes. Folding the two entry points into one verbose flag turned the pointer into a value and left the call site alone, silently narrowing the warning to paths that carry an ACS redirect.
Pass verbose. This also restores the warning for a verbose caller that takes the host bridge route with no ACS redirect on the path, which until now was told it could not use peer-to-peer DMA without being told which vendor and device would have to be added to the whitelist.
--- drivers/pci/p2pdma.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/pci/p2pdma.c +1 -3
@@ -452,7 +452,6 @@ calc_map_type_and_dist(struct pci_dev *provider, struct pci_dev *client, {enum pci_p2pdma_map_type map_type =PCI_P2PDMA_MAP_THRU_HOST_BRIDGE ;struct pci_dev *a = provider, *b = client, *bb; -bool acs_redirects = false;struct pci_p2pdma *p2pdma;struct seq_buf acs_list;int acs_cnt =0 ;
@@ -523,11 +522,10 @@ calc_map_type_and_dist(struct pci_dev *provider, struct pci_dev *client,pci_warn (client,"to disable ACS redirect for this path, add the kernel parameter: pci=disable_acs_redir=%s\n" ,seq_buf_str (&acs_list)); } - acs_redirects = true; map_through_host_bridge:if (!cpu_supports_p2pdma () && - !host_bridge_whitelist (provider, client, acs_redirects)) { + !host_bridge_whitelist (provider, client, verbose)) {if (verbose)pci_warn (client,"cannot be used for peer-to-peer DMA as the client and provider (%s) do not share an upstream bridge or whitelisted host bridge\n" ,pci_name (provider));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1838/2214 xhci: dbc: lock the minor IDR on registration failure
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sang-Hoon Choi <[email protected]>
[ Upstream commit 47f4e983b5de7616fb11d5f537fc9a605387d136 ]
dbc_tty_minors is protected by dbc_tty_minors_lock when entries are allocated and during normal device removal. The registration error path removes an entry without taking that lock. Different DbC instances have separate event work items, so this removal can race with an IDR update for another instance.
Take the same mutex around the error-path removal.
--- drivers/usb/host/xhci-dbgtty.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/host/xhci-dbgtty.c +2 -0
@@ -474,7 +474,9 @@ static int xhci_dbc_tty_register_device(struct xhci_dbc *dbc) err_free_fifo:kfifo_free (&port->write_fifo); err_exit_port: +mutex_lock (&dbc_tty_minors_lock);idr_remove (&dbc_tty_minors, port->minor); +mutex_unlock (&dbc_tty_minors_lock); err_idr:xhci_dbc_tty_exit_port (port);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1839/2214 mailbox: ti-msgmgr: Read exact number of trailing message bytes
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Beleswar Padhi <[email protected]>
[ Upstream commit 645ae2edd5597501b4af3837a644877fbe194227 ]
ti_msgmgr_send_data() copies the message to the data registers in u32 units. This has been harmless so far because the clients (TI-SCI) always passed its preallocated message buffer, which is sized to the maximum message size (60 or 64 bytes, a multiple of 4), so the extra bytes read were still within the buffer. But, with a later TI-SCI update, the message size can be varying now and not guaranteed to be a multiple of 4, which would trigger KASAN out-of-bounds reports.
Therefore, memcpy() only the trailing bytes into a zeroed u32 before writing it to the register. This is at most 3 bytes, so the overhead is negligible.
--- drivers/mailbox/ti-msgmgr.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/mailbox/ti-msgmgr.c +10 -4
@@ -19,6 +19,7 @@#include <linux/of_irq.h> #include <linux/platform_device.h> #include <linux/soc/ti/ti-msgmgr.h> +#include <linux/string.h> #define Q_DATA_OFFSET (proxy, queue, reg) \ ((0x10000 * (proxy)) + (0x80 * (queue)) + ((reg) * 4))
@@ -380,10 +381,15 @@ static int ti_msgmgr_send_data(struct mbox_chan *chan, void *data) trail_bytes = message->len %sizeof (u32);if (trail_bytes) { -u32 data_trail = *word_data; - -/* Ensure all unused data is 0 */ - data_trail &=0xFFFFFFFF >> (8 * (sizeof (u32) - trail_bytes)); +/* +* Copy only the trailing bytes instead of reading a full u32, +* as the message buffer may end right after them and a u32 +* read would go past the end of it. This also leaves all +* unused data as 0. +*/ +u32 data_trail =0 ; + +memcpy (&data_trail, word_data, trail_bytes);writel (data_trail, data_reg); data_reg +=sizeof (u32); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1840/2214 mailbox: arm_mhuv2: time out if the receiver never comes up
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linkai Gong <[email protected]>
[ Upstream commit 86976f7cc324aac254136a352f74ac17f21e574c ]
mhuv2_tx_init() waits forever for access_ready. Fail probe after 1s instead of hanging boot.
--- drivers/mailbox/arm_mhuv2.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/mailbox/arm_mhuv2.c +7 -2
@@ -27,6 +27,7 @@#include <linux/amba/bus.h> #include <linux/interrupt.h> +#include <linux/iopoll.h> #include <linux/mailbox_controller.h> #include <linux/mailbox/arm_mhuv2_message.h> #include <linux/module.h>
@@ -967,6 +968,7 @@ static int mhuv2_tx_init(struct amba_device *adev, struct mhuv2 *mhu, {struct device *dev = mhu->mbox.dev;int ret, i; +u32 val; mhu->frame =SENDER_FRAME ; mhu->mbox.ops = &mhuv2_sender_ops;
@@ -1010,8 +1012,11 @@ static int mhuv2_tx_init(struct amba_device *adev, struct mhuv2 *mhu, out:/* Wait for receiver to be ready */ writel_relaxed (0x1 , &mhu->send->access_request); -while (!readl_relaxed (&mhu->send->access_ready)) -continue ; +if (readl_relaxed_poll_timeout (&mhu->send->access_ready, val, val, +100 ,1000000 )) { +dev_err (dev,"receiver not ready\n" ); +return -ETIMEDOUT ; + }return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1841/2214 RDMA/mlx5: Cancel deferred page-fault EQ work before teardown
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Prathamesh Deshpande <[email protected]>
[ Upstream commit aea64024ac37d29e99b82b315a56a9145dc0bc23 ]
Page-fault EQ work can remain queued after the notifier is disabled. Destroying the EQ before cancelling that work can let the worker access freed EQ memory.
Cancel the deferred work before destroying the EQ.
--- drivers/infiniband/hw/mlx5/odp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/mlx5/odp.c +1 -1
@@ -1604,8 +1604,8 @@ mlx5_ib_odp_destroy_eq(struct mlx5_ib_dev *dev, struct mlx5_ib_pf_eq *eq)if (!eq->core)return 0 ;mlx5_eq_disable (dev->mdev, eq->core, &eq->irq_nb); - err =mlx5_eq_destroy_generic (dev->mdev, eq->core);cancel_work_sync (&eq->work); + err =mlx5_eq_destroy_generic (dev->mdev, eq->core);destroy_workqueue (eq->wq);mempool_destroy (eq->pool);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1842/2214 RDMA/mlx5: Support driver APIs pre_destroy_cq and post_destroy_cq
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mark Zhang <[email protected]>
[ Upstream commit b5eeb8365d196c95dbb0fd0a5b5a69a44832f16f ]
- pre_destroy_cq: Destroy FW CQ object so that no new CQ event would
be generated;
- post_destroy_cq: Release all resources.
This patch, along with last one, fixes the crash below.
Unable to handle kernel paging request at virtual address ffff8000114b1180 Mem abort info: ESR = 0x96000047 EC = 0x25: DABT (current EL), IL = 32 bits SET = 0, FnV = 0 EA = 0, S1PTW = 0 Data abort info: ISV = 0, ISS = 0x00000047 CM = 0, WnR = 1 swapper pgtable: 4k pages, 48-bit VAs, pgdp=00000000f4582000 [ffff8000114b1180] pgd=00000447fffff003, p4d=00000447fffff003, pud=00000447ffffe003, pmd=00000447ffffb003, pte=0000000000000000 Internal error: Oops: 96000047 [#1] SMP Modules linked in: udp_diag uio_pci_generic uio tcp_diag inet_diag binfmt_misc sn_core_odd(OE) rpcrdma(OE) xprtrdma(OE) ib_isert(OE) ib_iser(OE) ib_srpt(OE) ib_srp(OE) ib_ipoib(OE) kpatch_9658536(OK) kpatch_9322385(OK) kpatch_8843421(OK) kpatch_8636216(OK) vfat fat aes_ce_blk crypto_simd cryptd aes_ce_cipher crct10dif_ce ghash_ce sm4_ce sha2_ce sha256_arm64 sha1_ce sbsa_gwdt sg acpi_ipmi ipmi_si ipmi_msghandler m1_uncore_ddrss_pmu m1_uncore_cmn_pmu team_yosemite9rc6(OE) vnic(OE) ip_tables mlx5_ib(OE) sd_mod ast mlx5_core(OE) i2c_algo_bit drm_vram_helper psample drm_kms_helper mlxdevm(OE) auxiliary(OE) mlxfw(OE) syscopyarea sysfillrect tls sysimgblt fb_sys_fops drm_ttm_helper nvme ttm nvme_core drm t10_pi i2c_designware_platform i2c_designware_core i2c_core ahci libahci libata rdma_ucm(OE) ib_uverbs(OE) rdma_cm(OE) iw_cm(OE) ib_cm(OE) ib_umad(OE) ib_core(OE) ib_ucm(OE) mlx_compat(OE) [last unloaded: ipmi_devintf] CPU: 83 PID: 59375 Comm: kworker/u253:1 Kdump: loaded Tainted: G OE K 5.10.84-004.ali5000.alios7.aarch64 #1 Hardware name: Inspur AliServer-Xuanwu2.0AM-02-2UM1P-5B/AS1221MG1, BIOS 1.2.M1.AL.P.158.00 08/31/2023 Workqueue: ib-comp-unb-wq ib_cq_poll_work [ib_core] pstate: 82c00089 (Nzcv daIf +PAN +UAO +TCO BTYPE=--) pc : native_queued_spin_lock_slowpath+0x1c4/0x31c lr : mlx5_ib_poll_cq+0x18c/0x2f8 [mlx5_ib] sp : ffff80002be1bc80 x29: ffff80002be1bc80 x28: ffff000810e69000 x27: ffff000810e69000 x26: ffff000810e69200 x25: 0000000000000000 x24: ffff8000117db000 x23: ffff04000156b780 x22: 0000000000000000 x21: ffff04000ce6c160 x20: ffff0008196a4000 x19: 0000000000000010 x18: 0000000000000020 x17: 0000000000000000 x16: 0000000000000000 x15: ffff040055a364e8 x14: ffffffffffffffff x13: ffff80002318bda8 x12: ffff0400358836e8 x11: 0000000000000040 x10: 0000000000000eb0 x9 : 0000000000000000 x8 : 0000000000000000 x7 : ffff04477fa20140 x6 : ffff8000114b1140 x5 : ffff04477fa20140 x4 : ffff8000114b1180 x3 : ffff000810e69200 x2 : ffff8000114b1180 x1 : 0000000001500000 x0 : ffff04477fa20148 Call trace: native_queued_spin_lock_slowpath+0x1c4/0x31c __ib_process_cq+0x74/0x1b8 [ib_core] ib_cq_poll_work+0x34/0xa0 [ib_core] process_one_work+0x1d8/0x4b0 worker_thread+0x180/0x440 kthread+0x114/0x120 Code: 910020e0 8b0400c4 f862d929 aa0403e2 (f8296847) ---[ end trace 387be2290557729c ]--- Kernel panic - not syncing: Oops: Fatal exception SMP: stopping secondary CPUs Kernel Offset: disabled CPU features: 0x9850817,7a60aa38 Memory Limit: none Starting crashdump kernel... Bye!
Stable-dep-of: a0ab2bb269e7 ("RDMA/mlx5: Cancel software CQ notifications before teardown")
--- drivers/infiniband/hw/mlx5/cq.c | 19 +++++++++++++++---- drivers/infiniband/hw/mlx5/main.c | 2 ++ drivers/infiniband/hw/mlx5/mlx5_ib.h | 2 ++ 3 files changed, 19 insertions(+), 4 deletions(-)
drivers/infiniband/hw/mlx5/cq.c +15 -4
@@ -1037,20 +1037,31 @@ int mlx5_ib_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,return err; } -int mlx5_ib_destroy_cq (struct ib_cq *cq,struct ib_udata *udata) +int mlx5_ib_pre_destroy_cq (struct ib_cq *cq) {struct mlx5_ib_dev *dev =to_mdev (cq->device);struct mlx5_ib_cq *mcq =to_mcq (cq); + +return mlx5_core_destroy_cq (dev->mdev, &mcq->mcq); +} + +void mlx5_ib_post_destroy_cq (struct ib_cq *cq) +{ +destroy_cq_kernel (to_mdev (cq->device),to_mcq (cq)); +} + +int mlx5_ib_destroy_cq (struct ib_cq *cq,struct ib_udata *udata) +{int ret; - ret =mlx5_core_destroy_cq (dev->mdev, &mcq->mcq); + ret =mlx5_ib_pre_destroy_cq (cq);if (ret)return ret;if (udata) -destroy_cq_user (mcq, udata); +destroy_cq_user (to_mcq (cq), udata);else -destroy_cq_kernel (dev, mcq); +mlx5_ib_post_destroy_cq (cq);return 0 ; }
drivers/infiniband/hw/mlx5/main.c +2 -0
@@ -3799,7 +3799,9 @@ static const struct ib_device_ops mlx5_ib_dev_ops = { .modify_port = mlx5_ib_modify_port, .modify_qp = mlx5_ib_modify_qp, .modify_srq = mlx5_ib_modify_srq, + .pre_destroy_cq = mlx5_ib_pre_destroy_cq, .poll_cq = mlx5_ib_poll_cq, + .post_destroy_cq = mlx5_ib_post_destroy_cq, .post_recv = mlx5_ib_post_recv_nodrain, .post_send = mlx5_ib_post_send_nodrain, .post_srq_recv = mlx5_ib_post_srq_recv,
drivers/infiniband/hw/mlx5/mlx5_ib.h +2 -0
@@ -1251,6 +1251,8 @@ int mlx5_ib_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr, struct ib_udata *udata);int mlx5_ib_destroy_cq (struct ib_cq *cq,struct ib_udata *udata);int mlx5_ib_poll_cq (struct ib_cq *ibcq,int num_entries,struct ib_wc *wc); +int mlx5_ib_pre_destroy_cq (struct ib_cq *cq); +void mlx5_ib_post_destroy_cq (struct ib_cq *cq);int mlx5_ib_arm_cq (struct ib_cq *ibcq,enum ib_cq_notify_flags flags);int mlx5_ib_modify_cq (struct ib_cq *cq,u16 cq_count,u16 cq_period);int mlx5_ib_resize_cq (struct ib_cq *ibcq,int entries,struct ib_udata *udata);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1843/2214 RDMA/mlx5: Cancel software CQ notifications before teardown
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Prathamesh Deshpande <[email protected]>
[ Upstream commit a0ab2bb269e7fd8523f87950b91a42a36c7f8f2a ]
GSI completions queue notify_work to invoke the CQ completion handler. CQ destruction drains hardware events and core polling, but does not cancel this software notifier.
--- drivers/infiniband/hw/mlx5/cq.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/infiniband/hw/mlx5/cq.c +3 -0
@@ -1042,6 +1042,9 @@ int mlx5_ib_pre_destroy_cq(struct ib_cq *cq)struct mlx5_ib_dev *dev =to_mdev (cq->device);struct mlx5_ib_cq *mcq =to_mcq (cq); +if (!cq->uobject) +cancel_work_sync (&mcq->notify_work); +return mlx5_core_destroy_cq (dev->mdev, &mcq->mcq); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1844/2214 drm/panfrost: Explicitly enable MMU interrupts at device init
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adrián Larumbe <[email protected]>
[ Upstream commit 8a597d099b8b2f25df655cbe8e30765013784fed ]
Because the device must be in a position to accept jobs between the time drm_dev_register() is called and autosuspend first kicks in, there's a very narrow window inbetween during which jobs targeting the tiler buffer object would time out, since the device's PM status is 'Active', but no MMU interrupts were enabled at device initialisation time.
--- drivers/gpu/drm/panfrost/panfrost_mmu.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/gpu/drm/panfrost/panfrost_mmu.c +9 -2
@@ -211,6 +211,12 @@ void panfrost_mmu_as_put(struct panfrost_device *pfdev, struct panfrost_mmu *mmuWARN_ON (atomic_read (&mmu->as_count) <0 ); } +static void panfrost_mmu_enable_interrupts (struct panfrost_device *pfdev) +{ +mmu_write (pfdev,MMU_INT_CLEAR , ~0 ); +mmu_write (pfdev,MMU_INT_MASK , ~0 ); +} +void panfrost_mmu_reset (struct panfrost_device *pfdev) {struct panfrost_mmu *mmu, *mmu_tmp;
@@ -228,8 +234,7 @@ void panfrost_mmu_reset(struct panfrost_device *pfdev)spin_unlock (&pfdev->as_lock); -mmu_write (pfdev,MMU_INT_CLEAR , ~0 ); -mmu_write (pfdev,MMU_INT_MASK , ~0 ); +panfrost_mmu_enable_interrupts (pfdev); }static size_t get_pgsize (u64 addr,size_t size)
@@ -733,6 +738,8 @@ int panfrost_mmu_init(struct panfrost_device *pfdev)return err; } +panfrost_mmu_enable_interrupts (pfdev); +return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1845/2214 ACPI: PCI: pci_link: clear driver_data before free
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit 691c33289b4d7a50b6fe1e03918bfbc21d4641c5 ]
acpi_pci_link_remove() frees the link object without clearing the ACPI device's driver_data pointer. The ACPI device survives hot-removal and can later be retrieved by acpi_fetch_acpi_dev(), leaving callers with a dangling pointer.
Clear driver_data before freeing the link.
--- drivers/acpi/pci_link.c | 1 + 1 file changed, 1 insertion(+)
drivers/acpi/pci_link.c +1 -0
@@ -782,6 +782,7 @@ static void acpi_pci_link_remove(struct acpi_device *device)list_del (&link->list);mutex_unlock (&acpi_link_lock); + device->driver_data =NULL ;kfree (link); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1846/2214 btrfs: fix off by one super block end offset calculation when writing super blocks
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <[email protected]>
[ Upstream commit 7884a8f3279c28ff990e2eacd5c2479bb1c930d0 ]
We are skipping the write of a super block mirror if its end offset matches exactly the device's end offset. This happens because we are using a greater than or equals comparison instead of just a greater than comparison.
--- fs/btrfs/disk-io.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
fs/btrfs/disk-io.c +2 -4
@@ -3832,8 +3832,7 @@ static int write_dev_supers(struct btrfs_device *device, errors++;continue ; } -if (bytenr +BTRFS_SUPER_INFO_SIZE >= - device->commit_total_bytes) +if (bytenr +BTRFS_SUPER_INFO_SIZE > device->commit_total_bytes)break ;btrfs_set_super_bytenr (sb, bytenr_orig);
@@ -3916,8 +3915,7 @@ static int wait_dev_supers(struct btrfs_device *device, int max_mirrors) primary_failed = true;continue ; } -if (bytenr +BTRFS_SUPER_INFO_SIZE >= - device->commit_total_bytes) +if (bytenr +BTRFS_SUPER_INFO_SIZE > device->commit_total_bytes)break ; page = find_get_page(device->bdev->bd_inode->i_mapping,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1847/2214 btrfs: qgroup: do not treat "ret > 0" as error when deleting a qgroup
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qu Wenruo <[email protected]>
[ Upstream commit dd906477cc2c33c82ec17e6301bd4be4ea588565 ]
[BUG]
There is a bug report that when removing a child qgroup, if removing the qgroup requires a rescan, it will delete the on-disk relation and qgroup items but not the in-memory qgroup rb entry.
This makes all later qgroup rescan to fail.
[CAUSE]
The call chain looks like the following:
btrfs_remove_qgroup()
|- __del_qgroup_relation() | |- quick_update_accounting() | Which returns 1, showing this operation will require | a qgroup rescan |- if (ret) goto out;
Which skips the del_qgroup_rb() call, leaving the in-memory qgroup rb entry still intact.
Then later qgroup rescan/update will always fail and mark qgroup inconsistent:
btrfs_run_qgroups()
|- update_qgroup_info_item() | |- btrfs_search_slot() | Which returns -ENOENT, as the qgroup info item is already | deleted. |- qgroup_mark_inconsistent() |- return -ENOENT;
[FIX]
Do not treat "ret > 0" as an error.
--- fs/btrfs/qgroup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/qgroup.c +1 -1
@@ -1661,7 +1661,7 @@ int btrfs_remove_qgroup(struct btrfs_trans_handle *trans, u64 qgroupid) struct btrfs_qgroup_list, next_group); ret =__del_qgroup_relation (trans, qgroupid, list->group->qgroupid); -if (ret) +if (ret <0 ) goto out; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1848/2214 btrfs: qgroup: fix swapped blocks existence check when tracing after COW
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <[email protected]>
[ Upstream commit 0388b5bd3a6eb8bcb20208c3b6dbee96fd30bbe0 ]
In btrfs_qgroup_trace_subtree_after_cow(), after we erase the swapped block, iterate over all possible tree levels to check if we sill have other swapped blocks. However the check is wrong, it considers that there are other swapped blocks if any rbtree for any level is empty, instead of not empty. As a consequence we set blocks->swapped to true basically every time since we always find an empty rbtree at least at level 7, since in practice it's nearly impossible to find such a huge btree. This makes every future call to btrfs_qgroup_trace_subtree_after_cow() do an unnecessary rbtree search instead of returning immediately.
Fix this by updating the condition to set swapped to true if we find an rbtree that is not empty.
--- fs/btrfs/ctree.h | 2 +- fs/btrfs/qgroup.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
fs/btrfs/ctree.h +1 -1
@@ -1138,7 +1138,7 @@ static inline void btrfs_wake_unfinished_drop(struct btrfs_fs_info *fs_info)*/ struct btrfs_qgroup_swapped_blocks {spinlock_t lock; -/* RM_EMPTY_ROOT() of above blocks[] */ +/* True if any of the rbtrees in the blocks array below is not empty. */ bool swapped;struct rb_root blocks[BTRFS_MAX_LEVEL ]; };
fs/btrfs/qgroup.c +1 -1
@@ -4327,7 +4327,7 @@ int btrfs_qgroup_trace_subtree_after_cow(struct btrfs_trans_handle *trans,/* Found one, remove it from @blocks first and update blocks->swapped */ rb_erase (&block->node, &blocks->blocks[level]);for (i =0 ; i <BTRFS_MAX_LEVEL ; i++) { -if (RB_EMPTY_ROOT (&blocks->blocks[i])) { +if (!RB_EMPTY_ROOT (&blocks->blocks[i])) { swapped = true;break ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1849/2214 power: supply: generic-adc-battery: convert to managed resources
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Reichel <[email protected]>
[ Upstream commit 93297ef6920f071ed109cbdcf640edfc693d0456 ]
Convert driver to use managed resources to simplify driver code.
Stable-dep-of: 36b0abe904ac ("power: supply: generic-adc-battery: Propagate charged GPIO errors")
--- drivers/power/supply/generic-adc-battery.c | 81 ++++++---------------- 1 file changed, 23 insertions(+), 58 deletions(-)
drivers/power/supply/generic-adc-battery.c +23 -58
@@ -23,6 +23,7 @@#include <linux/iio/consumer.h> #include <linux/iio/types.h> #include <linux/power/generic-adc-battery.h> +#include <linux/devm-helpers.h> #define JITTER_DEFAULT 10/* hope 10ms is enough */
@@ -269,14 +270,13 @@ static int gab_probe(struct platform_device *pdev)* copying the static properties and allocating extra memory for holding * the extra configurable properties received from platform data. */ - properties =kcalloc (ARRAY_SIZE (gab_props) + -ARRAY_SIZE (gab_chan_name), -sizeof (*properties), -GFP_KERNEL ); -if (!properties) { - ret = -ENOMEM ; - goto first_mem_fail; - } + properties =devm_kcalloc (&pdev->dev, +ARRAY_SIZE (gab_props) + +ARRAY_SIZE (gab_chan_name), +sizeof (*properties), +GFP_KERNEL ); +if (!properties) +return -ENOMEM ;memcpy (properties, gab_props,sizeof (gab_props));
@@ -285,12 +285,13 @@ static int gab_probe(struct platform_device *pdev)* based on the channel supported by consumer device. */ for (chan =0 ; chan <ARRAY_SIZE (gab_chan_name); chan++) { - adc_bat->channel[chan] =iio_channel_get (&pdev->dev, - gab_chan_name[chan]); + adc_bat->channel[chan] =devm_iio_channel_get (&pdev->dev, gab_chan_name[chan]);if (IS_ERR (adc_bat->channel[chan])) { ret =PTR_ERR (adc_bat->channel[chan]); +if (ret != -ENODEV ) +return dev_err_probe (&pdev->dev, ret,"Failed to get ADC channel %s\n" , gab_chan_name[chan]); adc_bat->channel[chan] =NULL ; - }else { + }else if (adc_bat->channel[chan]) {/* copying properties for supported channels only */ int index2;
@@ -305,10 +306,8 @@ static int gab_probe(struct platform_device *pdev) }/* none of the channels are supported so let's bail out */ -if (!any) { - ret = -ENODEV ; - goto second_mem_fail; - } +if (!any) +return dev_err_probe (&pdev->dev, -ENODEV ,"Failed to get any ADC channel\n" );/* * Total number of properties is equal to static properties
@@ -319,25 +318,24 @@ static int gab_probe(struct platform_device *pdev) psy_desc->properties = properties; psy_desc->num_properties = index; - adc_bat->psy =power_supply_register (&pdev->dev, psy_desc, &psy_cfg); -if (IS_ERR (adc_bat->psy)) { - ret =PTR_ERR (adc_bat->psy); - goto err_reg_fail; - } + adc_bat->psy =devm_power_supply_register (&pdev->dev, psy_desc, &psy_cfg); +if (IS_ERR (adc_bat->psy)) +return dev_err_probe (&pdev->dev,PTR_ERR (adc_bat->psy),"Failed to register power-supply device\n" ); -INIT_DELAYED_WORK (&adc_bat->bat_work, gab_work); + ret =devm_delayed_work_autocancel (&pdev->dev, &adc_bat->bat_work, gab_work); +if (ret) +return dev_err_probe (&pdev->dev, ret,"Failed to register delayed work\n" ); - adc_bat->charge_finished =devm_gpiod_get_optional (&pdev->dev, -"charged" ,GPIOD_IN ); + adc_bat->charge_finished =devm_gpiod_get_optional (&pdev->dev,"charged" ,GPIOD_IN );if (adc_bat->charge_finished) {int irq; irq =gpiod_to_irq (adc_bat->charge_finished); - ret =request_any_context_irq (irq, gab_charged, + ret =devm_request_any_context_irq (&pdev->dev, irq, gab_charged,IRQF_TRIGGER_RISING |IRQF_TRIGGER_FALLING ,"battery charged" , adc_bat);if (ret <0 ) - goto gpio_req_fail; +return dev_err_probe (&pdev->dev, ret,"Failed to register irq\n" ); }platform_set_drvdata (pdev, adc_bat);
@@ -346,38 +344,6 @@ static int gab_probe(struct platform_device *pdev)schedule_delayed_work (&adc_bat->bat_work,msecs_to_jiffies (0 ));return 0 ; - -gpio_req_fail: -power_supply_unregister (adc_bat->psy); -err_reg_fail: -for (chan =0 ; chan <ARRAY_SIZE (gab_chan_name); chan++) { -if (adc_bat->channel[chan]) -iio_channel_release (adc_bat->channel[chan]); - } -second_mem_fail: -kfree (properties); -first_mem_fail: -return ret; -} - -static int gab_remove (struct platform_device *pdev) -{ -int chan; -struct gab *adc_bat =platform_get_drvdata (pdev); - -power_supply_unregister (adc_bat->psy); - -if (adc_bat->charge_finished) -free_irq (gpiod_to_irq (adc_bat->charge_finished), adc_bat); - -for (chan =0 ; chan <ARRAY_SIZE (gab_chan_name); chan++) { -if (adc_bat->channel[chan]) -iio_channel_release (adc_bat->channel[chan]); - } - -kfree (adc_bat->psy_desc.properties); -cancel_delayed_work_sync (&adc_bat->bat_work); -return 0 ; }static int __maybe_unused gab_suspend (struct device *dev)
@@ -411,7 +377,6 @@ static struct platform_driver gab_driver = { .pm = &gab_pm_ops, }, .probe = gab_probe, - .remove = gab_remove, };module_platform_driver (gab_driver);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1850/2214 power: supply: generic-adc-battery: Propagate charged GPIO errors
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 36b0abe904ac9cbdce6161d9c7c0bcac963bb3fe ]
devm_gpiod_get_optional() may return an error pointer such as -EPROBE_DEFER, but gab_probe() only checks for NULL. The error pointer is then passed to gpiod_to_irq() and the original error, including -EPROBE_DEFER, is lost.
Check the return value and propagate errors from the charged GPIO lookup.
--- drivers/power/supply/generic-adc-battery.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/power/supply/generic-adc-battery.c +3 -0
@@ -327,6 +327,9 @@ static int gab_probe(struct platform_device *pdev)return dev_err_probe (&pdev->dev, ret,"Failed to register delayed work\n" ); adc_bat->charge_finished =devm_gpiod_get_optional (&pdev->dev,"charged" ,GPIOD_IN ); +if (IS_ERR (adc_bat->charge_finished)) +return dev_err_probe (&pdev->dev,PTR_ERR (adc_bat->charge_finished), +"failed to get charged GPIO\n" );if (adc_bat->charge_finished) {int irq;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1851/2214 mtd: rawnand: pl353: fix clk reference leak in pl35x_nfc_setup_interface()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haotian Zhang <[email protected]>
[ Upstream commit 1ce45f0e74d60e8279ed380c97047e6c351aee1b ]
pl35x_nfc_setup_interface() obtains a reference to the SMC "memclk" with of_clk_get_by_name() and only uses it to read the clock rate. The reference is never released: the function has many early return paths and no clk_put() call anywhere, so the clock reference is leaked.
The hook is invoked repeatedly by the NAND core (nand_reset(), nand_setup_interface() and the NAND_DATA_IFACE_CHECK_ONLY mode probing loops), so the reference count keeps growing.
Release the clock reference with clk_put() as soon as its rate has been read.
--- drivers/mtd/nand/raw/pl35x-nand-controller.c | 1 + 1 file changed, 1 insertion(+)
drivers/mtd/nand/raw/pl35x-nand-controller.c +1 -0
@@ -809,6 +809,7 @@ static int pl35x_nfc_setup_interface(struct nand_chip *chip, int cs,* macro to convert from one to the other. */ period_ns =NSEC_PER_SEC /clk_get_rate (mclk); +clk_put (mclk);/* * PL35X SMC needs one extra read cycle in SDR Mode 5. This is not
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1852/2214 nfs: set gencount on protocol-specific remove
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Roberto Bergantinos Corpas <[email protected]>
[ Upstream commit 8c955dacf45f8964b98f26910ffecb5e26c02e31 ]
commit bd4928ec799b ("NFS: Avoid changing nlink when file removes and attribute updates race") avoids races on attribute cache with any inflight RPC that may modify inode attributes (and gencount) during i.e. REMOVE.
However it does not take into account that REMOVE may trigger a delegation return which also advances gencount (via the attribute refresh during delegation return), and in that case the gencount mismatch is not due to an inflight RPC that already reflected the removal.
Push the setting of gencount under each version-specific layer, reordering correctly for nfsv4 case after the delegation returns.
This fixes LTP/inotify04 failure after bd4928ec799b.
--- fs/nfs/dir.c | 13 +++---------- fs/nfs/internal.h | 1 + fs/nfs/nfs3proc.c | 8 ++++++++ fs/nfs/nfs4proc.c | 5 +++++ fs/nfs/proc.c | 8 ++++++++ 5 files changed, 25 insertions(+), 10 deletions(-)
fs/nfs/dir.c +3 -10
@@ -1738,7 +1738,7 @@ static int nfs_dentry_delete(const struct dentry *dentry) }/* Ensure that we revalidate inode->i_nlink */ -static void nfs_drop_nlink (struct inode *inode,unsigned long gencount) +void nfs_drop_nlink (struct inode *inode,unsigned long gencount) {struct nfs_inode *nfsi =NFS_I (inode);
@@ -1752,6 +1752,7 @@ static void nfs_drop_nlink(struct inode *inode, unsigned long gencount) NFS_INO_INVALID_NLINK);spin_unlock (&inode->i_lock); } +EXPORT_SYMBOL_GPL (nfs_drop_nlink);/* * Called when the dentry loses inode.
@@ -2301,7 +2302,6 @@ EXPORT_SYMBOL_GPL(nfs_rmdir);static int nfs_safe_remove (struct dentry *dentry) {struct inode *dir =d_inode (dentry->d_parent); -struct inode *inode =d_inode (dentry);int error = -EBUSY ;dfprintk (VFS ,"NFS: safe_remove(%pd2)\n" , dentry);
@@ -2313,14 +2313,7 @@ static int nfs_safe_remove(struct dentry *dentry) }trace_nfs_remove_enter (dir, dentry); -if (inode !=NULL ) { -unsigned long gencount =READ_ONCE (NFS_I (inode)->attr_gencount); - - error =NFS_PROTO (dir)->remove (dir, dentry); -if (error ==0 ) -nfs_drop_nlink (inode, gencount); - }else - error =NFS_PROTO (dir)->remove (dir, dentry); + error =NFS_PROTO (dir)->remove (dir, dentry);if (error == -ENOENT )nfs_dentry_handle_enoent (dentry);trace_nfs_remove_exit (dir, dentry, error);
fs/nfs/internal.h +1 -0
@@ -383,6 +383,7 @@ extern unsigned long nfs_access_cache_count(struct shrinker *shrink, struct shrink_control *sc);extern unsigned long nfs_access_cache_scan (struct shrinker *shrink,struct shrink_control *sc); +extern void nfs_drop_nlink (struct inode *inode,unsigned long gencount);struct dentry *nfs_lookup (struct inode *,struct dentry *,unsigned int );int nfs_create (struct user_namespace *,struct inode *,struct dentry *,umode_t ,bool );
fs/nfs/nfs3proc.c +8 -0
@@ -443,13 +443,21 @@ nfs3_proc_remove(struct inode *dir, struct dentry *dentry) .rpc_resp = &res, };int status = -ENOMEM ; +struct inode *inode =d_inode (dentry); +unsigned long gencount;dprintk ("NFS call remove %pd2\n" , dentry); res.dir_attr =nfs_alloc_fattr ();if (res.dir_attr ==NULL ) goto out; +if (inode) + gencount =READ_ONCE (NFS_I (inode)->attr_gencount); + status =rpc_call_sync (NFS_CLIENT (dir), &msg,0 ); +if (status ==0 && inode) +nfs_drop_nlink (inode, gencount); +nfs_post_op_update_inode (dir, res.dir_attr);nfs_free_fattr (res.dir_attr); out:
fs/nfs/nfs4proc.c +5 -0
@@ -4758,12 +4758,14 @@ static int nfs4_proc_remove(struct inode *dir, struct dentry *dentry) };struct inode *inode =d_inode (dentry);int err; +unsigned long gencount;if (inode) {if (inode->i_nlink ==1 )nfs4_inode_return_delegation (inode);else nfs4_inode_make_writeable (inode); + gencount =READ_ONCE (NFS_I (inode)->attr_gencount); } do { err = _nfs4_proc_remove(dir, &dentry->d_name, NF4REG);
@@ -4771,6 +4773,9 @@ static int nfs4_proc_remove(struct inode *dir, struct dentry *dentry) err =nfs4_handle_exception (NFS_SERVER (dir), err, &exception); }while (exception.retry); + +if (err ==0 && inode) +nfs_drop_nlink (inode, gencount);return err; }
fs/nfs/proc.c +8 -0
@@ -324,9 +324,17 @@ nfs_proc_remove(struct inode *dir, struct dentry *dentry) .rpc_argp = &arg, };int status; +struct inode *inode =d_inode (dentry); +unsigned long gencount;dprintk ("NFS call remove %pd2\n" ,dentry); +if (inode) + gencount =READ_ONCE (NFS_I (inode)->attr_gencount); + status =rpc_call_sync (NFS_CLIENT (dir), &msg,0 ); +if (status ==0 && inode) +nfs_drop_nlink (inode, gencount); +nfs_mark_for_revalidate (dir);dprintk ("NFS reply remove: %d\n" , status);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1853/2214 ASoC: codecs: rt5659: propagate GPIO errors
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit c1e321bd5ce6ae3702db65837cfe0c792634d603 ]
devm_gpiod_get_optional() may return an error pointer, including -EPROBE_DEFER, but rt5659_i2c_probe() does not handle these errors for the ldo1-en GPIO and does not check for errors for the reset GPIO.
Check the return values and propagate GPIO lookup errors.
--- sound/soc/codecs/rt5659.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
sound/soc/codecs/rt5659.c +5 -1
@@ -4115,10 +4115,14 @@ static int rt5659_i2c_probe(struct i2c_client *i2c, rt5659->gpiod_ldo1_en =devm_gpiod_get_optional (&i2c->dev,"ldo1-en" ,GPIOD_OUT_HIGH );if (IS_ERR (rt5659->gpiod_ldo1_en)) -dev_warn (&i2c->dev,"Request ldo1-en GPIO failed\n" ); +return dev_err_probe (&i2c->dev,PTR_ERR (rt5659->gpiod_ldo1_en), +"failed to get ldo1-en GPIO\n" ); rt5659->gpiod_reset =devm_gpiod_get_optional (&i2c->dev,"reset" ,GPIOD_OUT_HIGH ); +if (IS_ERR (rt5659->gpiod_reset)) +return dev_err_probe (&i2c->dev,PTR_ERR (rt5659->gpiod_reset), +"failed to get reset GPIO\n" );/* Sleep for 300 ms miniumum */ msleep (300 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1854/2214 rcutorture: Fix divide-by-zero with fwd_progress_div=1
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kunwu Chan <[email protected]>
[ Upstream commit 5b748d8aa6833f2dec3f545311be69a2064bc6d1 ]
When fwd_progress_div=1, the forward-progress test computes:
sd4 = (sd + div - 1) / div = sd
dur = sd4 + torture_random(&trs) % (sd - sd4) = sd4 + % 0
The modulo operation with a zero divisor triggers an integer division by zero (undefined behavior at the C level, #DE trap on x86), causing a kernel Oops and panic. On x86_64, this manifests as:
rcu_torture_fwd_prog_nr: Starting forward-progress test 0
Oops: divide error: 0000 [#1] SMP PTI RIP: 0010:rcu_torture_fwd_prog+0x90b/0x1160 R12: 0000000000000000
The existing guard only handles non-positive values. However, fwd_progress_div=1 also makes the random range empty because sd4 == sd.
Change the guard to reject values below 2. The forward-progress test only reaches this calculation when stall_dur() is positive, so sd = stall_dur() + 1 >= 2. For fwd_progress_div >= 2, sd4 < sd, ensuring that sd - sd4 is at least 1.
Keep the existing fallback to the default value of 4 for invalid values.
Verified with QEMU/KVM: a 138-second run with fwd_progress_div=1 completed 81 forward-progress test cycles without a crash.
--- kernel/rcu/rcutorture.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/rcu/rcutorture.c +1 -1
@@ -2499,7 +2499,7 @@ static int __init rcu_torture_fwd_prog_init(void) }if (fwd_progress_holdoff <=0 ) fwd_progress_holdoff =1 ; -if (fwd_progress_div <=0 ) +if (fwd_progress_div <2 ) fwd_progress_div =4 ; rfp =kzalloc (sizeof (*rfp),GFP_KERNEL );if (!rfp)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1855/2214 wifi: ath10k: avoid IDR mutation during TX cleanup
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit 1c1a208e65a08191901cfded3bbccc4a54e4a75c ]
ath10k_htt_flush_tx_queue() walks pending_tx with idr_for_each(). Its callback calls ath10k_txrx_tx_unref(), which removes the current entry from pending_tx through ath10k_htt_tx_free_msdu_id().
idr_for_each() keeps radix-tree iterator state across the callback. Removing the current entry can therefore invalidate that state and make the remaining walk unsafe.
Use idr_for_each_entry(), which starts a fresh lookup after each callback. The current entry can then be removed safely, while the following idr_destroy() continues to release the IDR itself.
--- drivers/net/wireless/ath/ath10k/htt_tx.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/net/wireless/ath/ath10k/htt_tx.c +7 -5
@@ -504,9 +504,8 @@ int ath10k_htt_tx_start(struct ath10k_htt *htt)return ret; } -static int ath10k_htt_tx_clean_up_pending (int msdu_id,void *skb,void *ctx) +static void ath10k_htt_tx_clean_up_pending (int msdu_id,struct ath10k *ar) { -struct ath10k *ar = ctx;struct ath10k_htt *htt = &ar->htt;struct htt_tx_done tx_done = {0 };
@@ -516,8 +515,6 @@ static int ath10k_htt_tx_clean_up_pending(int msdu_id, void *skb, void *ctx) tx_done.status =HTT_TX_COMPL_STATE_DISCARD ;ath10k_txrx_tx_unref (htt, &tx_done); - -return 0 ; }void ath10k_htt_tx_destroy (struct ath10k_htt *htt)
@@ -534,8 +531,13 @@ void ath10k_htt_tx_destroy(struct ath10k_htt *htt)static void ath10k_htt_flush_tx_queue (struct ath10k_htt *htt) { +struct sk_buff *msdu; +int msdu_id; +ath10k_htc_stop_hl (htt->ar); -idr_for_each (&htt->pending_tx, ath10k_htt_tx_clean_up_pending, htt->ar); + +idr_for_each_entry (&htt->pending_tx, msdu, msdu_id) +ath10k_htt_tx_clean_up_pending (msdu_id, htt->ar); }void ath10k_htt_tx_stop (struct ath10k_htt *htt)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1856/2214 wifi: ath11k: avoid IDR mutation during pending mgmt TX cleanup
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit 3e7f5d362b2b3a21b3adb4b860aad14b69a896ad ]
The pending management TX cleanup walks txmgmt_idr with idr_for_each(), and its callback removes the current entry. This can invalidate the radix-tree iterator retained by idr_for_each().
Use idr_for_each_entry() so every iteration starts with a fresh lookup. Continue to remove each entry under txmgmt_idr_lock before freeing its skb, preventing concurrent TX completion from finding a stale skb pointer.
--- drivers/net/wireless/ath/ath11k/core.c | 3 +-- drivers/net/wireless/ath/ath11k/mac.c | 12 ++++++------ drivers/net/wireless/ath/ath11k/mac.h | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-)
drivers/net/wireless/ath/ath11k/core.c +1 -2
@@ -1017,8 +1017,7 @@ static void ath11k_core_restart(struct work_struct *work)complete (&ar->thermal.wmi_sync);wake_up (&ar->dp.tx_empty_waitq); -idr_for_each (&ar->txmgmt_idr, - ath11k_mac_tx_mgmt_pending_free, ar); +ath11k_mac_tx_mgmt_pending_free (ar);idr_destroy (&ar->txmgmt_idr); }
drivers/net/wireless/ath/ath11k/mac.c +6 -6
@@ -4177,13 +4177,13 @@ static void ath11k_mac_tx_mgmt_free(struct ath11k *ar, int buf_id)ieee80211_free_txskb (ar->hw, msdu); } -int ath11k_mac_tx_mgmt_pending_free (int buf_id,void *skb,void *ctx) +void ath11k_mac_tx_mgmt_pending_free (struct ath11k *ar) { -struct ath11k *ar = ctx; - -ath11k_mac_tx_mgmt_free (ar, buf_id); +struct sk_buff *msdu; +int buf_id; -return 0 ; +idr_for_each_entry (&ar->txmgmt_idr, msdu, buf_id) +ath11k_mac_tx_mgmt_free (ar, buf_id); }static int ath11k_mac_vif_txmgmt_idr_remove (int buf_id,void *skb,void *ctx)
@@ -6462,7 +6462,7 @@ static void __ath11k_mac_unregister(struct ath11k *ar)ieee80211_unregister_hw (ar->hw); -idr_for_each (&ar->txmgmt_idr, ath11k_mac_tx_mgmt_pending_free, ar); +ath11k_mac_tx_mgmt_pending_free (ar);idr_destroy (&ar->txmgmt_idr);kfree (ar->mac.sbands[NL80211_BAND_2GHZ ].channels);
drivers/net/wireless/ath/ath11k/mac.h +1 -1
@@ -146,7 +146,7 @@ struct ath11k *ath11k_mac_get_ar_by_pdev_id(struct ath11k_base *ab, u32 pdev_id)void ath11k_mac_drain_tx (struct ath11k *ar);void ath11k_mac_peer_cleanup_all (struct ath11k *ar); -int ath11k_mac_tx_mgmt_pending_free (int buf_id,void *skb,void *ctx); +void ath11k_mac_tx_mgmt_pending_free (struct ath11k *ar);u8 ath11k_mac_bw_to_mac80211_bw (u8 bw);enum ath11k_supported_bw ath11k_mac_mac80211_bw_to_ath11k_bw (enum rate_info_bw bw);enum hal_encrypt_type ath11k_dp_tx_get_encrypt_type (u32 cipher);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1857/2214 wifi: ath11k: avoid IDR mutation during vif mgmt TX cleanup
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit dc29226dada34a6d19af77b4b51e90f8a3a8de34 ]
ath11k_mac_op_remove_interface() walks txmgmt_idr with idr_for_each(), and its callback removes each entry belonging to the interface. Removing the current entry can invalidate the radix-tree iterator retained by idr_for_each().
Move the walk into a helper that uses idr_for_each_entry(). It performs a fresh lookup for every iteration, so each matching entry can be removed through the locked removal helper without retaining iterator state across the removal.
--- drivers/net/wireless/ath/ath11k/mac.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-)
drivers/net/wireless/ath/ath11k/mac.c +11 -10
@@ -4186,16 +4186,18 @@ void ath11k_mac_tx_mgmt_pending_free(struct ath11k *ar)ath11k_mac_tx_mgmt_free (ar, buf_id); } -static int ath11k_mac_vif_txmgmt_idr_remove (int buf_id,void *skb,void *ctx) +static void ath11k_mac_vif_txmgmt_cleanup (struct ath11k *ar, +struct ieee80211_vif *vif) { -struct ieee80211_vif *vif = ctx; -struct ath11k_skb_cb *skb_cb =ATH11K_SKB_CB ((struct sk_buff *)skb); -struct ath11k *ar = skb_cb->ar; - -if (skb_cb->vif == vif) -ath11k_mac_tx_mgmt_free (ar, buf_id); +struct ath11k_skb_cb *skb_cb; +struct sk_buff *skb; +int buf_id; -return 0 ; +idr_for_each_entry (&ar->txmgmt_idr, skb, buf_id) { + skb_cb =ATH11K_SKB_CB (skb); +if (skb_cb->vif == vif) +ath11k_mac_tx_mgmt_free (ar, buf_id); + } } static int ath11k_mac_mgmt_tx_wmi(struct ath11k *ar, struct ath11k_vif *arvif,
@@ -4988,8 +4990,7 @@ static void ath11k_mac_op_remove_interface(struct ieee80211_hw *hw,ath11k_peer_cleanup (ar, arvif->vdev_id); -idr_for_each (&ar->txmgmt_idr, - ath11k_mac_vif_txmgmt_idr_remove, vif); +ath11k_mac_vif_txmgmt_cleanup (ar, vif);for (i =0 ; i <DP_TCL_NUM_RING_MAX ; i++) {spin_lock_bh (&ab->dp.tx_ring[i].tx_idr_lock);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1858/2214 mm/hmm/test: reject overflowing page counts
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit b59925301211ccc351d98d70b11f6d1b2c63150f ]
The number of pages comes directly from userspace. Shifting a value larger than ULONG_MAX >> PAGE_SHIFT discards its high bits before the existing end-address check. A request for a huge number of pages can therefore be accepted and processed as a much smaller request.
Reject page counts that cannot be represented as a byte size before performing the shift.
So far as ChatGPT and I can tell this doesn't cause an issue in practice but preventing this integer overflow is the correct thing to do.
--- lib/test_hmm.c | 2 ++ 1 file changed, 2 insertions(+)
lib/test_hmm.c +2 -0
@@ -1049,6 +1049,8 @@ static long dmirror_fops_unlocked_ioctl(struct file *filp,if (cmd.addr & ~PAGE_MASK )return -EINVAL ; +if (cmd.npages >ULONG_MAX >>PAGE_SHIFT ) +return -EINVAL ;if (cmd.addr >= (cmd.addr + (cmd.npages <<PAGE_SHIFT )))return -EINVAL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1859/2214 platform/x86: intel_telemetry: initialize default trace verbosity
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aleksandrova Alyona <[email protected]>
[ Upstream commit 1b55ec81926eb7f6e4fad692fa4040a569e9daf7 ]
telemetry_def_get_trace_verbosity() returns success without initializing the output verbosity value.
The default telemetry operations are installed when the core driver is initialized and again by telemetry_clear_pltdata() when the platform driver is removed. The telemetry debugfs files can remain available after the platform driver removal.
A subsequent read of pss_trace_verbosity or ioss_trace_verbosity calls telemetry_get_trace_verbosity(), which may use the default callback and return success without setting verbosity. The uninitialized value is then passed to seq_printf().
Validate the output pointer and initialize the default verbosity to zero so callers never use an uninitialized value after a successful call.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/platform/x86/intel/telemetry/core.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/platform/x86/intel/telemetry/core.c +4 -0
@@ -51,6 +51,10 @@ static int telemetry_def_get_eventconfig(static int telemetry_def_get_trace_verbosity (enum telemetry_unit telem_unit,u32 *verbosity) { +if (!verbosity) +return -EINVAL ; + + *verbosity =0 ;return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1860/2214 platform/olpc: Reserve space for a string terminator
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit 1fe88b1741ff655bb59e4fd78178fe2c557b9185 ]
ec_dbgfs_cmd_write() copies user input into a zero-initialized stack buffer and passes it to sscanf(). A write that overwrites the entire buffer leaves no terminator, so the subsequent parsing can read beyond the buffer.
Limit the copy to leave room for the trailing NUL.
--- drivers/platform/olpc/olpc-ec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/olpc/olpc-ec.c +1 -1
@@ -269,7 +269,7 @@ static ssize_t ec_dbgfs_cmd_write(struct file *file, const char __user *buf,mutex_lock (&ec_dbgfs_lock); - size =simple_write_to_buffer (cmdbuf,sizeof (cmdbuf), ppos, buf, size); + size =simple_write_to_buffer (cmdbuf,sizeof (cmdbuf) -1 , ppos, buf, size); m = sscanf(cmdbuf, "%x:%u %x %x %x %x %x", &ec_cmd_int[0], &ec_dbgfs_resp_bytes, &ec_cmd_int[1], &ec_cmd_int[2],
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1861/2214 fbdev: gxt4500: Release WC setup on probe failure
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
[ Upstream commit b71e0bb7ad40c005b167e9b48be3af5a3fa51974 ]
gxt4500_probe() adds a write-combining range before allocating the cmap and registering the framebuffer. If a later step fails, the range is not released. Add the missing cleanup before unmapping the framebuffer, matching the successful remove path.
This issue was identified during our ongoing static-analysis research while reviewing kernel code.
--- drivers/video/fbdev/gxt4500.c | 1 + 1 file changed, 1 insertion(+)
drivers/video/fbdev/gxt4500.c +1 -0
@@ -717,6 +717,7 @@ static int gxt4500_probe(struct pci_dev *pdev, const struct pci_device_id *ent) err_free_cmap:fb_dealloc_cmap (&info->cmap); err_unmap_all: +arch_phys_wc_del (par->wc_cookie);iounmap (info->screen_base); err_unmap_regs:iounmap (par->regs);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1862/2214 ALSA: rawmidi: Drain input work before freeing the runtime
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit 8c3529f0a8faaac7d73333486f69da1617ecc579 ]
The input runtime embeds event_work, so the work must be drained before close_substream() frees the runtime. The cancellation in snd_rawmidi_input_trigger() runs before close clears substream->opened, leaving a window for snd_rawmidi_receive() to enqueue more work.
With a sequencer subscription to a USB MIDI input port, an in-flight completion can overlap the last subscription's midisynth_unsubscribe():
1. snd_usbmidi_input_data() observes input_triggered and is delayed before calling snd_rawmidi_receive().
2. Unsubscribe enters close_substream(), clears input_triggered through the provider trigger callback and returns from cancel_work_sync(). The substream is still opened.
3. The completion resumes. snd_rawmidi_receive() takes substream->lock, sees opened set and queues runtime->event_work before dropping the lock.
4. Close clears opened under that lock, closes the provider and frees the runtime. Stopping USB URBs does not drain the raw-MIDI work.
5. The queued work runs and snd_rawmidi_input_event_work() reads event or substream from the freed runtime, causing a use-after-free.
Cancel input event_work again after clearing opened, before closing the provider or releasing the runtime's private data. Receive holds substream->lock through its opened check and work enqueue, so once close has cleared opened under that lock, no further receive can queue work. The final cancellation therefore drains any late work before the runtime is freed. Keep it outside the spinlock so a running callback can finish.
--- sound/core/rawmidi.c | 3 +++ 1 file changed, 3 insertions(+)
sound/core/rawmidi.c +3 -0
@@ -522,6 +522,9 @@ static void close_substream(struct snd_rawmidi *rmidi,snd_rawmidi_output_trigger (substream,0 ); } } +/* Drain input work queued after the earlier cancellation. */ +if (substream->stream ==SNDRV_RAWMIDI_STREAM_INPUT ) +cancel_work_sync (&substream->runtime->event_work); substream->ops->close (substream);if (substream->runtime->private_free) substream->runtime->private_free (substream);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1863/2214 calipso: hash the cache key, not the option start, in calipso_cache_add()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joas Antonio dos Santos <[email protected]>
[ Upstream commit d538cc3ec0bc4cb7b40981b3213a6c6671959ed5 ]
calipso_cache_add() stores calipso_ptr + 2 as the cache key, but computes entry->hash over calipso_ptr, i.e. starting two bytes earlier at the option type and length. calipso_opt_getattr() looks entries up with calipso_cache_check(calipso + 2, calipso[1], ...), which hashes the key itself.
The two hashes only match on a jhash collision, so the CALIPSO label cache never hits and every labelled packet takes the full DOI lookup and category conversion path. The memcmp() on the key keeps lookups correct, so this is a performance bug only.
Hash the stored key, as cipso_v4_cache_add() does for CIPSO.
--- net/ipv6/calipso.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv6/calipso.c +1 -1
@@ -284,7 +284,7 @@ static int calipso_cache_add(const unsigned char *calipso_ptr, goto cache_add_failure; } entry->key_len = calipso_ptr_len; - entry->hash =calipso_map_cache_hash (calipso_ptr, calipso_ptr_len); + entry->hash =calipso_map_cache_hash (entry->key, calipso_ptr_len);refcount_inc (&secattr->cache->refcount); entry->lsm_data = secattr->cache;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1864/2214 clocksource/drivers/timer-mediatek: Fix random crash at boot
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luca Leonardo Scorcia <[email protected]>
[ Upstream commit 8496a1d234e8cf9cb15c4282cb3a11c6550bd242 ]
MediaTek bootloaders generally enable APXGPT timers at boot. This means that a timer IRQ can sometimes happen between the IRQ line request and the configuration of the clock event handler. This leads to a hard crash with an instruction abort, branch to pc 0x0 in mtk_gpt_interrupt handler as clkevt is null.
To avoid this issue request the IRQ with IRQF_NO_AUTOEN and enable it explicitly after the clock event is configured.
Issue was reported and fix tested on the Lenovo Tab E7 (TB-7104F, mt8167).
--- drivers/clocksource/timer-mediatek.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/clocksource/timer-mediatek.c +3 -1
@@ -277,7 +277,7 @@ static struct timer_of to = { }, .of_irq = { - .flags = IRQF_TIMER | IRQF_IRQPOLL, + .flags = IRQF_TIMER | IRQF_IRQPOLL | IRQF_NO_AUTOEN, }, };
@@ -298,6 +298,7 @@ static int __init mtk_syst_init(struct device_node *node)clockevents_config_and_register (&to.clkevt,timer_of_rate (&to),TIMER_SYNC_TICKS ,0xffffffff ); +enable_irq (timer_of_irq (&to));return 0 ; }
@@ -334,6 +335,7 @@ static int __init mtk_gpt_init(struct device_node *node) TIMER_SYNC_TICKS, 0xffffffff);mtk_gpt_enable_irq (&to,TIMER_CLK_EVT ); +enable_irq (timer_of_irq (&to));return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1865/2214 RDMA/siw: Enforce IB_ACCESS_REMOTE_READ for read responses
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haitam Lazaar <[email protected]>
[ Upstream commit f74eac4fc6c56274fb96c2c44ffad8f01c325f17 ]
When generating an RDMA READ response (SIW_OP_READ_RESPONSE), siw_check_sgl_tx() unconditionally passes 0 as the required permission mask:
/* Reference memory to be tx'd w/o checking access for LOCAL_READ */
rv = siw_check_sgl_tx(qp->pd, wqe, 0);Because perms is 0, siw_check_mem()'s authorization test:
if ((mem->perms & perms) < perms)
evaluates to (mem->perms & 0) < 0, which is always false. Consequently, an untrusted remote peer can issue an RDMA Read targeting any valid STag in the Protection Domain, even if the memory was registered strictly as write-only (IB_ACCESS_REMOTE_WRITE) without IB_ACCESS_REMOTE_READ.
Enforce that the target memory region was granted IB_ACCESS_REMOTE_READ when answering SIW_OP_READ_RESPONSE work queue entries, while preserving perms = 0 for standard local sends.
--- drivers/infiniband/sw/siw/siw_qp_tx.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)
drivers/infiniband/sw/siw/siw_qp_tx.c +11 -7
@@ -813,17 +813,21 @@ static int siw_qp_sq_proc_tx(struct siw_qp *qp, struct siw_wqe *wqe)if (wqe->wr_status ==SIW_WR_QUEUED ) {if (!(wqe->sqe.flags &SIW_WQE_INLINE )) { -if (tx_type (wqe) ==SIW_OP_READ_RESPONSE ) - wqe->sqe.num_sge =1 ; -if (tx_type (wqe) !=SIW_OP_READ &&tx_type (wqe) !=SIW_OP_READ_LOCAL_INV ) { +enum ib_access_flags perms =0 ; +/* -* Reference memory to be tx'd w/o checking -* access for LOCAL_READ permission, since -* not defined in RDMA core. +* Local READ permission doesn't exist in RDMA core. +* A READ RESPONSE source is read by the remote peer, +* so it must be checked for REMOTE_READ permission. */ - rv =siw_check_sgl_tx (qp->pd, wqe,0 ); +if (tx_type (wqe) ==SIW_OP_READ_RESPONSE ) { + perms =IB_ACCESS_REMOTE_READ ; + wqe->sqe.num_sge =1 ; + } + + rv =siw_check_sgl_tx (qp->pd, wqe, perms);if (rv <0 ) {if (tx_type (wqe) ==SIW_OP_READ_RESPONSE )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1866/2214 wifi: mac80211: fix encryption tailroom
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chien Wong <[email protected]>
[ Upstream commit c49f54fd2abff08964677db8fdc1674c713ab42c ]
BIP-CMAC-256 and BIP-GMAC append a 26-byte MME but mac80211 currently reserves only 18 bytes of encryption tailroom.
Generating 26-byte MME may happen to work because the actual skb tailroom can exceed the requested amount. For example, dev_alloc_skb() rounds the allocation to kmalloc size buckets or alignment boundaries, and the extra space may cover the 8-byte shortfall.
Reserve enough tailroom for the 26-byte MME.
--- net/mac80211/ieee80211_i.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/mac80211/ieee80211_i.h +1 -1
@@ -49,7 +49,7 @@ struct ieee80211_local;/* Required encryption head and tailroom */ #define IEEE80211_ENCRYPT_HEADROOM 8 -#define IEEE80211_ENCRYPT_TAILROOM 18 +#define IEEE80211_ENCRYPT_TAILROOM 26/* current max: GMAC/CMAC-256 MME */ /* power level hasn't been configured (or set to automatic) */ #define IEEE80211_UNSET_POWER_LEVEL INT_MIN
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1867/2214 tcp_bic: fix divide by zero on max_increment == 0
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiayuan Chen <[email protected]>
[ Upstream commit 8edbf6c23363563e508a61f3f26f4e4b6eec9dd5 ]
max_increment is how many packets cwnd can grow per RTT, so 0 makes no sense, and bictcp_update() divides by it.
Reject values below 1 when the parameter is written.
--- net/ipv4/tcp_bic.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
net/ipv4/tcp_bic.c +12 -2
@@ -27,15 +27,25 @@*/ static int fast_convergence =1 ; -static int max_increment =16 ; +static unsigned int max_increment =16 ;static int low_window =14 ;static int beta =819 ;/* = 819/1024 (BICTCP_BETA_SCALE) */ static int initial_ssthresh;static int smooth_part =20 ; +static int max_increment_set (const char *val,const struct kernel_param *kp) +{ +return param_set_uint_minmax (val, kp,1 ,INT_MAX ); +} + +static const struct kernel_param_ops max_increment_ops = { + .set = max_increment_set, + .get = param_get_uint, +}; +module_param (fast_convergence, int,0644 );MODULE_PARM_DESC (fast_convergence,"turn on/off fast convergence" ); -module_param (max_increment, int,0644 ); +module_param_cb (max_increment, &max_increment_ops, &max_increment,0644 );MODULE_PARM_DESC (max_increment,"Limit on increment allowed during binary search" );module_param (low_window, int,0644 );MODULE_PARM_DESC (low_window,"lower bound on congestion window (for TCP friendliness)" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1868/2214 tcp_hybla: fix divide by zero on rtt0 == 0
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiayuan Chen <[email protected]>
[ Upstream commit f09eb97322b16a6f709a47599c95b62f786905f9 ]
rtt0 is the reference RTT in ms, so 0 makes no sense, and hybla_recalc_param() divides by it right from hybla_init().
Reject values below 1 when the parameter is written. Also cap it at U32_MAX / USEC_PER_MSEC, since rtt0 * USEC_PER_MSEC can wrap to 0 on 32-bit. An rtt0 above that (about 71 minutes) makes no sense anyway.
--- net/ipv4/tcp_hybla.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
net/ipv4/tcp_hybla.c +14 -2
@@ -26,8 +26,20 @@ struct hybla { };/* Hybla reference round trip time (default= 1/40 sec = 25 ms), in ms */ -static int rtt0 =25 ; -module_param (rtt0, int,0644 ); +static unsigned int rtt0 =25 ; + +static int rtt0_set (const char *val,const struct kernel_param *kp) +{ +/* avoid rtt0 * USEC_PER_MSEC overflow */ +return param_set_uint_minmax (val, kp,1 ,U32_MAX /USEC_PER_MSEC ); +} + +static const struct kernel_param_ops rtt0_ops = { + .set = rtt0_set, + .get = param_get_uint, +}; + +module_param_cb (rtt0, &rtt0_ops, &rtt0,0644 );MODULE_PARM_DESC (rtt0,"reference rout trip time (ms)" );/* This is called to refresh values for hybla parameters */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1869/2214 serial: max310x: dont clobber the TX break bit in set_termios
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tapio Reijonen <[email protected]>
[ Upstream commit 3b2de448ec0332c1cb8c38b4c5ff0c8e860befbc ]
A TX break asserted with TIOCSBRK ends early, with no error reported, as soon as any termios change lands on the port: a break is a state that must hold until TIOCCBRK, but max310x_set_termios() overwrites the whole LCR register, and LCR also carries the TX break bit that break_ctl() drives. No concurrency is required - a baud or parity change from the same process ends the break just as well, and break-led protocols lose their break with nothing in the logs.
Update only the LCR bits that are derived from termios and leave the TX break and RTS pin control bits untouched. Since nothing clears a break when a port is closed with the break still asserted - the tty core sends no break-off on release, and the unconditional write here was the accidental recovery - clear TXBREAK in startup(), the same way 8250 does.
--- drivers/tty/serial/max310x.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
drivers/tty/serial/max310x.c +15 -2
@@ -152,6 +152,8 @@#define MAX310X_LCR_FORCEPARITY_BIT (1 << 5)/* 9-bit multidrop parity */ #define MAX310X_LCR_TXBREAK_BIT (1 << 6)/* TX break enable */ #define MAX310X_LCR_RTS_BIT (1 << 7)/* RTS pin control */ +/* LCR bits owned by termios; TX break and RTS are driven elsewhere */ +#define MAX310X_LCR_TERMIOS_MASK GENMASK(5, 0)/* IRDA register bits */ #define MAX310X_IRDA_IRDAEN_BIT (1 << 0)/* IRDA mode enable */
@@ -940,8 +942,12 @@ static void max310x_set_termios(struct uart_port *port,if (termios->c_cflag &CSTOPB ) lcr |=MAX310X_LCR_STOPLEN_BIT ;/* 2 stops */ -/* Update LCR register */ -max310x_port_write (port,MAX310X_LCR_REG , lcr); +/* +* Update LCR register. Leave the TX break bit alone: it is driven by +* break_ctl(), and a whole-register write here would end a break in +* progress. +*/ +max310x_port_update (port,MAX310X_LCR_REG ,MAX310X_LCR_TERMIOS_MASK , lcr);/* Set read status mask */ port->read_status_mask =MAX310X_LSR_RXOVR_BIT ;
@@ -1061,6 +1067,13 @@ static int max310x_startup(struct uart_port *port) s->devtype->power (port,1 ); +/* +* Clear a latched break: nothing clears TXBREAK when a port is +* closed with a break still asserted, and set_termios() no longer +* rewrites it. +*/ +max310x_port_update (port,MAX310X_LCR_REG ,MAX310X_LCR_TXBREAK_BIT ,0 ); +/* Configure MODE1 register */ max310x_port_update (port,MAX310X_MODE1_REG ,MAX310X_MODE1_TRNSCVCTRL_BIT ,0 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1870/2214 net: alacritech: fix dma_free_coherent() in error path
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Fourier <[email protected]>
[ Upstream commit 05b5019b01fb9443b09ae4ed34af1135a80a84c8 ]
In slic_init_stat_queue(), a series of coherent buffers is allocated with the length size. The size is then stored in stq->mem_size for normal deallocation. However, in the error path, stq->mem_size is also used but is not initialized. This error may leave the freed buffers mapped, leaking a resource and allowing the device to access freed memory.
Change the length in error path to size.
--- drivers/net/ethernet/alacritech/slicoss.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/alacritech/slicoss.c +1 -1
@@ -813,7 +813,7 @@ static int slic_init_stat_queue(struct slic_device *sdev) free_descs:while (i--) { -dma_free_coherent (&sdev->pdev->dev, stq->mem_size, +dma_free_coherent (&sdev->pdev->dev, size, stq->descs[i] - stq->addr_offset[i], stq->paddr[i] - stq->addr_offset[i]); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1871/2214 comedi: comedi_parport: validate the IRQ supplied by userspace
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yogesh Gaur <[email protected]>
[ Upstream commit 790ea6844593bcd03b0379986fc821d8c511746e ]
comedi boards are configured through the COMEDI_DEVCONFIG ioctl, so it->options[1] is a number chosen by userspace. comedi_parport passes it to request_irq() without checking it first, which lets an interrupt owned by another irqdomain -- a PCI device's IO-APIC GSI, for instance -- be claimed for this board. When the owner of that interrupt is later released the descriptor is freed while this driver's handler is still installed on it.
A parallel port asserts a legacy ISA interrupt, so the ISA range is the right bound; it is also sufficient, because mp_chip_data->isa_irq is set only by alloc_isa_irq_from_domain() and mp_unmap_irq() returns early when it is set.
syzbot hit this one:
remove_proc_entry: removing non-empty directory 'irq/20', leaking at least 'comedi_parport' WARNING: fs/proc/generic.c:747 at remove_proc_entry+0x4e7/0x610 fs/proc/generic.c:747 Call Trace: <TASK> unregister_irq_proc+0x206/0x2a0 kernel/irq/proc.c:406 free_desc+0x89/0x330 kernel/irq/irqdesc.c:482 irq_free_descs+0x84/0xc0 kernel/irq/irqdesc.c:865 irq_domain_free_irqs+0x46a/0x5c0 kernel/irq/irqdomain.c:1917 mp_unmap_irq+0xf8/0x130 arch/x86/kernel/apic/io_apic.c:1061 acpi_unregister_gsi_ioapic+0x40/0x60 arch/x86/kernel/acpi/boot.c:722 acpi_pci_irq_disable+0x275/0x360 drivers/acpi/pci_irq.c:517 pci_disable_device+0x130/0x270 drivers/pci/pci.c:2206 pci_device_remove+0xb2/0x1d0 drivers/pci/pci-driver.c:512 device_release_driver_internal+0x44e/0x620 drivers/base/dd.c:1372 unbind_store+0xf8/0x110 drivers/base/bus.c:244 </TASK>
The leaked /proc entry the warning names is the mild part. mp_chip_data->count tracks GSI mappings rather than request_irq() users, and __setup_irq() takes no reference on the descriptor, so the irq_desc is freed with the comedi irqaction still attached to it.
Bound the value before requesting it, as das16m1.c already does. An out-of-range value is ignored rather than rejected, so the board still attaches without interrupt support, exactly as it does today when request_irq() fails.
--- drivers/comedi/drivers/comedi_parport.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/comedi/drivers/comedi_parport.c +2 -1
@@ -242,7 +242,8 @@ static int parport_attach(struct comedi_device *dev,outb (0 , dev->iobase +PARPORT_DATA_REG );outb (0 , dev->iobase +PARPORT_CTRL_REG ); -if (it->options[1 ]) { +/* only ISA interrupts are valid on a parallel port */ +if (it->options[1 ] >=1 && it->options[1 ] <=15 ) { ret =request_irq (it->options[1 ], parport_interrupt,0 , dev->board_name, dev);if (ret ==0 )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1872/2214 comedi: ni_atmio16d: validate the IRQ supplied by userspace
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yogesh Gaur <[email protected]>
[ Upstream commit 71424db0ebb5f484fa3f386910f8ce9da95b8b2e ]
comedi boards are configured through the COMEDI_DEVCONFIG ioctl, so it->options[1] is a number chosen by userspace. ni_atmio16d passes it to request_irq() without checking it first, which lets an interrupt owned by another irqdomain -- a PCI device's IO-APIC GSI, for instance -- be claimed for this board. When the owner of that interrupt is later released the descriptor is freed while this driver's handler is still installed on it.
The driver already documents which interrupts the board can assert -- "0 == no irq; or 3,4,5,6,7,9,10,11,12,14,15" -- so use exactly that set rather than the whole ISA range.
Bound the value before requesting it, as das16m1.c already does. An out-of-range value is ignored rather than rejected, so the board still attaches without interrupt support, exactly as it does today when request_irq() fails.
--- drivers/comedi/drivers/ni_atmio16d.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/comedi/drivers/ni_atmio16d.c +3 -1
@@ -593,7 +593,9 @@ static int atmio16d_attach(struct comedi_device *dev,/* reset the atmio16d hardware */ reset_atmio16d (dev); -if (it->options[1 ]) { +/* only irqs 3, 4, 5, 6, 7, 9, 10, 11, 12, 14, and 15 are valid */ +if (it->options[1 ] >=3 && it->options[1 ] <=15 && + (1 << it->options[1 ]) &0xdef8 ) { ret =request_irq (it->options[1 ], atmio16d_interrupt,0 , dev->board_name, dev);if (ret ==0 )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1873/2214 comedi: dt2814: validate the IRQ supplied by userspace
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yogesh Gaur <[email protected]>
[ Upstream commit 81026c2b3f9096cdfdfa02918f94865629fb7f90 ]
comedi boards are configured through the COMEDI_DEVCONFIG ioctl, so it->options[1] is a number chosen by userspace. dt2814 passes it to request_irq() without checking it first, which lets an interrupt owned by another irqdomain -- a PCI device's IO-APIC GSI, for instance -- be claimed for this board. When the owner of that interrupt is later released the descriptor is freed while this driver's handler is still installed on it.
Every interrupt this board can assert is a legacy ISA one, so the ISA range is the right bound; it is also sufficient, because mp_chip_data->isa_irq is set only by alloc_isa_irq_from_domain() and mp_unmap_irq() returns early when it is set.
Bound the value before requesting it, as das16m1.c already does. An out-of-range value is ignored rather than rejected, so the board still attaches without interrupt support, exactly as it does today when request_irq() fails.
--- drivers/comedi/drivers/dt2814.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/comedi/drivers/dt2814.c +2 -1
@@ -316,7 +316,8 @@ static int dt2814_attach(struct comedi_device *dev, struct comedi_devconfig *it)return -EIO ; } -if (it->options[1 ]) { +/* only ISA interrupts are valid on this board */ +if (it->options[1 ] >=1 && it->options[1 ] <=15 ) { ret =request_irq (it->options[1 ], dt2814_interrupt,0 , dev->board_name, dev);if (ret ==0 )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1874/2214 comedi: dmm32at: validate the IRQ supplied by userspace
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yogesh Gaur <[email protected]>
[ Upstream commit 797d56d7f90864e67424f8e82639a9b3aedf37e0 ]
comedi boards are configured through the COMEDI_DEVCONFIG ioctl, so it->options[1] is a number chosen by userspace. dmm32at passes it to request_irq() without checking it first, which lets an interrupt owned by another irqdomain -- a PCI device's IO-APIC GSI, for instance -- be claimed for this board. When the owner of that interrupt is later released the descriptor is freed while this driver's handler is still installed on it.
Every interrupt this board can assert is a legacy ISA one, so the ISA range is the right bound; it is also sufficient, because mp_chip_data->isa_irq is set only by alloc_isa_irq_from_domain() and mp_unmap_irq() returns early when it is set.
Bound the value before requesting it, as das16m1.c already does. An out-of-range value is ignored rather than rejected, so the board still attaches without interrupt support, exactly as it does today when request_irq() fails.
--- drivers/comedi/drivers/dmm32at.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/comedi/drivers/dmm32at.c +2 -1
@@ -585,7 +585,8 @@ static int dmm32at_attach(struct comedi_device *dev,return ret; } -if (it->options[1 ]) { +/* only ISA interrupts are valid on this board */ +if (it->options[1 ] >=1 && it->options[1 ] <=15 ) { ret =request_irq (it->options[1 ], dmm32at_isr,0 , dev->board_name, dev);if (ret ==0 )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1875/2214 comedi: pcmmio: validate the IRQ supplied by userspace
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yogesh Gaur <[email protected]>
[ Upstream commit 23c6fc62e754f8bc412ceb5c0d9aaa14f2c9ff31 ]
comedi boards are configured through the COMEDI_DEVCONFIG ioctl, so it->options[1] is a number chosen by userspace. pcmmio passes it to request_irq() without checking it first, which lets an interrupt owned by another irqdomain -- a PCI device's IO-APIC GSI, for instance -- be claimed for this board. When the owner of that interrupt is later released the descriptor is freed while this driver's handler is still installed on it.
The board's interrupt is routed in software rather than jumpered, and the driver notes that "any IRQ from 1-15 is OK", so the ISA range is exactly the right bound.
Bound the value before requesting it, as das16m1.c already does. An out-of-range value is ignored rather than rejected, so the board still attaches without interrupt support, exactly as it does today when request_irq() fails.
--- drivers/comedi/drivers/pcmmio.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/comedi/drivers/pcmmio.c +2 -1
@@ -684,7 +684,8 @@ static int pcmmio_attach(struct comedi_device *dev, struct comedi_devconfig *it)pcmmio_reset (dev); -if (it->options[1 ]) { +/* the irq is configured in software, so any ISA irq is OK */ +if (it->options[1 ] >=1 && it->options[1 ] <=15 ) { ret =request_irq (it->options[1 ], interrupt_pcmmio,0 , dev->board_name, dev);if (ret ==0 ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1876/2214 comedi: pcmuio: validate the IRQs supplied by userspace
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yogesh Gaur <[email protected]>
[ Upstream commit 9c325b21bba99e597771137fc11b9427c86618d8 ]
comedi boards are configured through the COMEDI_DEVCONFIG ioctl, so it->options[1] is a number chosen by userspace. pcmuio passes it to request_irq() without checking it first, which lets an interrupt owned by another irqdomain -- a PCI device's IO-APIC GSI, for instance -- be claimed for this board. When the owner of that interrupt is later released the descriptor is freed while this driver's handler is still installed on it.
Every interrupt this board can assert is a legacy ISA one, so the ISA range is the right bound; it is also sufficient, because mp_chip_data->isa_irq is set only by alloc_isa_irq_from_domain() and mp_unmap_irq() returns early when it is set.
Bound the value before requesting it, as das16m1.c already does. An out-of-range value is ignored rather than rejected, so the board still attaches without interrupt support, exactly as it does today when request_irq() fails.
This board takes two interrupts, one per ASIC, so options[1] and options[2] both need the check. The existing options[2] == dev->irq case is left alone: it covers both ASICs sharing one interrupt and neither having one, and by then options[1] has already been validated.
--- drivers/comedi/drivers/pcmuio.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/comedi/drivers/pcmuio.c +3 -2
@@ -546,7 +546,8 @@ static int pcmuio_attach(struct comedi_device *dev, struct comedi_devconfig *it)pcmuio_reset (dev); -if (it->options[1 ]) { +/* only ISA interrupts are valid on this board */ +if (it->options[1 ] >=1 && it->options[1 ] <=15 ) {/* request the irq for the 1st asic */ ret =request_irq (it->options[1 ], pcmuio_interrupt,0 , dev->board_name, dev);
@@ -558,7 +559,7 @@ static int pcmuio_attach(struct comedi_device *dev, struct comedi_devconfig *it)if (it->options[2 ] == dev->irq) {/* the same irq (or none) is used by both asics */ devpriv->irq2 = it->options[2 ]; - }else if (it->options[2 ]) { + }else if (it->options[2 ] >=1 && it->options[2 ] <=15 ) {/* request the irq for the 2nd asic */ ret =request_irq (it->options[2 ], pcmuio_interrupt,0 , dev->board_name, dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1877/2214 thermal/drivers/ti-soc-thermal: Cancel pending alert work on remove
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weigang He <[email protected]>
[ Upstream commit aaa6c8dec49339710f9fd2a2af5646cf4111dbd4 ]
On a threshold crossing, the talert IRQ handler calls ti_thermal_report_sensor_temperature(), which queues the work embedded in the sensor's ti_thermal_data on the system workqueue. Nothing ever cancels or flushes that work.
ti_bandgap_remove() frees the talert IRQ last. free_irq() waits for a running handler, but not for the work the handler has queued. When remove returns, devres unregisters and frees the thermal zones and then frees the devm-allocated ti_thermal_data, so a work item that is still pending runs ti_thermal_work() on freed memory:
ti_thermal_work() data = container_of(work, struct ti_thermal_data, thermal_wq); thermal_zone_device_update(data->ti_thermal, ...);
Free the talert IRQ before removing the sensors, so that no new work can be queued, and cancel the work in ti_thermal_remove_sensor().
This needs an OMAP4460/4470 or OMAP5 SoC (DRA7 has TALERT but no ->report_temperature, so it never queues the work), a threshold crossing just before the driver is unbound or unloaded, and the work still pending when devres frees the data.
Found by static analysis tool CodeQL.
--- drivers/thermal/ti-soc-thermal/ti-bandgap.c | 7 ++++--- drivers/thermal/ti-soc-thermal/ti-thermal-common.c | 4 ++++ 2 files changed, 8 insertions(+), 3 deletions(-)
drivers/thermal/ti-soc-thermal/ti-bandgap.c +4 -3
@@ -1077,6 +1077,10 @@ int ti_bandgap_remove(struct platform_device *pdev)if (!soc_device_match (soc_no_cpu_notifier))cpu_pm_unregister_notifier (&bgp->nb); +/* Stop the alerts first: they queue work on the sensors' data */ +if (TI_BANDGAP_HAS (bgp,TALERT )) +free_irq (bgp->irq, bgp); +/* Remove sensor interfaces */ for (i =0 ; i < bgp->conf->sensor_count; i++) {if (bgp->conf->sensors[i].unregister_cooling)
@@ -1093,9 +1097,6 @@ int ti_bandgap_remove(struct platform_device *pdev)clk_put (bgp->fclock);clk_put (bgp->div_clk); -if (TI_BANDGAP_HAS (bgp,TALERT )) -free_irq (bgp->irq, bgp); -if (TI_BANDGAP_HAS (bgp,TSHUT ))free_irq (gpiod_to_irq (bgp->tshut_gpiod),NULL );
drivers/thermal/ti-soc-thermal/ti-thermal-common.c +4 -0
@@ -198,6 +198,10 @@ int ti_thermal_remove_sensor(struct ti_bandgap *bgp, int id) data =ti_bandgap_get_sensor_data (bgp, id); +/* Work queued by the talert IRQ must not outlive the data */ +if (!IS_ERR_OR_NULL (data)) +cancel_work_sync (&data->thermal_wq); +if (!IS_ERR_OR_NULL (data) && data->ti_thermal) {if (data->our_zone)thermal_zone_device_unregister (data->ti_thermal);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1878/2214 char: scx200_gpio: check cdev_add() return value
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linkai Gong <[email protected]>
[ Upstream commit fe26c195c265c033e474d015061a0183c7a02193 ]
cdev_add() can fail. The driver currently ignores the return value and reports probe success even when the cdev was not registered, leaving a chrdev region allocated with no working file operations.
Check the return value, emit an error, and unwind the chrdev region and platform device on failure.
--- drivers/char/scx200_gpio.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/char/scx200_gpio.c +7 -1
@@ -108,10 +108,16 @@ static int __init scx200_gpio_init(void) }cdev_init (&scx200_gpio_cdev, &scx200_gpio_fileops); -cdev_add (&scx200_gpio_cdev, devid,MAX_PINS ); + rc =cdev_add (&scx200_gpio_cdev, devid,MAX_PINS ); +if (rc) { +dev_err (&pdev->dev,"cdev_add err: %d\n" , rc); + goto undo_chrdev_region; + }return 0 ;/* succeed */ +undo_chrdev_region: +unregister_chrdev_region (devid,MAX_PINS ); undo_platform_device_add:platform_device_del (pdev); undo_malloc:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1879/2214 bus: arm-cci: Drop CPU node reference in cci_ace_init_ports()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuho Choi <[email protected]>
[ Upstream commit 41d6c0fcd4d75bf78c304c6660d60fcf757885ce ]
cci_ace_init_ports() looks up each possible CPU's node with of_get_cpu_node(), which returns the node with its reference count raised, but never releases it: neither when the CPU has no ACE port nor after the port has been recorded. Before the commit below the loop used for_each_child_of_node(), which manages the references itself.
The node is only needed for the port lookup, so drop the reference right after __cci_ace_get_port().
--- drivers/bus/arm-cci.c | 1 + 1 file changed, 1 insertion(+)
drivers/bus/arm-cci.c +1 -0
@@ -199,6 +199,7 @@ static void cci_ace_init_ports(void)continue ; port =__cci_ace_get_port (cpun,ACE_PORT ); +of_node_put (cpun);if (port <0 )continue ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1880/2214 bus: arm-cci: Drop cci-control-port node reference in __cci_ace_get_port()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuho Choi <[email protected]>
[ Upstream commit 810ccc792193909ba9bbb4246e0eb0de14dad724 ]
__cci_ace_get_port() looks up the device's "cci-control-port" node with of_parse_phandle(), which returns the node with its reference count raised, and only compares the pointer against the probed ports. Neither the match nor the no-match return releases it.
Drop the reference on both paths once the comparison is done.
--- drivers/bus/arm-cci.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/bus/arm-cci.c +4 -1
@@ -167,9 +167,12 @@ static int __cci_ace_get_port(struct device_node *dn, int type) cci_portn =of_parse_phandle (dn,"cci-control-port" ,0 );for (i =0 ; i < nb_cci_ports; i++) { ace_match = ports[i].type == type; -if (ace_match && cci_portn == ports[i].dn) +if (ace_match && cci_portn == ports[i].dn) { +of_node_put (cci_portn);return i; + } } +of_node_put (cci_portn);return -ENODEV ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1881/2214 clk: qcom: mmcc-msm8996: Fix FD AHB clock register offset
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abel Vesa <[email protected]>
[ Upstream commit 7cb2d65286b817d8d7e26f454a9c374d65e87072 ]
The FD AHB clock branch register is at offset 0x3b74, not 0x3ba74. The incorrect offset exceeds the regmap maximum of 0xb008, so regmap rejects accesses to it and the clock cannot be enabled.
Correct both the enable and halt register offsets so the driver can enable the branch and check its status.
--- drivers/clk/qcom/mmcc-msm8996.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/clk/qcom/mmcc-msm8996.c +2 -2
@@ -2883,9 +2883,9 @@ static struct clk_branch fd_core_uar_clk = { };static struct clk_branch fd_ahb_clk = { - .halt_reg =0x3ba74 , + .halt_reg =0x3b74 , .clkr = { - .enable_reg =0x3ba74 , + .enable_reg =0x3b74 , .enable_mask =BIT (0 ), .hw.init = &(struct clk_init_data ){ .name ="fd_ahb_clk" ,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1882/2214 clk: qcom: mmcc-sdm660: Fix MDSS AHB clock HWCG register offset
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abel Vesa <[email protected]>
[ Upstream commit c5f338329a2d0d60f7874aa7a1addaa0e4e75a3b ]
The MDSS AHB clock HWCG bit resides in the same register as the branch enable and halt status bits, at offset 0x2308. The current HWCG register offset of 0x8a004 exceeds the regmap maximum of 0x40000, so regmap rejects the read in clk_branch_in_hwcg_mode(). Since the read error is ignored, the helper uses an uninitialized value to decide whether to skip the halt status check.
Correct the HWCG register offset so the helper reads the actual hardware clock gating state.
--- drivers/clk/qcom/mmcc-sdm660.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/qcom/mmcc-sdm660.c +1 -1
@@ -2022,7 +2022,7 @@ static struct clk_branch csiphy_ahb2crif_clk = {static struct clk_branch mdss_ahb_clk = { .halt_reg =0x2308 , .halt_check =BRANCH_HALT , - .hwcg_reg =0x8a004 , + .hwcg_reg =0x2308 , .hwcg_bit =1 , .clkr = { .enable_reg =0x2308 ,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1883/2214 clk: qcom: rcg2: Propagate force-enable status errors
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Konrad Dybcio <[email protected]>
[ Upstream commit 8c0f93e10fa9e34009817bd37bb75c1b5a691fa2 ]
clk_rcg2_is_enabled() returns either a hardware status or a negative regmap error. The force-enable polling loop treats every nonzero return as an enabled clock, so a failed status read is incorrectly reported as success and clock reconfiguration can continue with unknown hardware state.
Check for negative returns before testing the enabled status and propagate the read error to the caller.
--- drivers/clk/qcom/clk-rcg2.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/clk/qcom/clk-rcg2.c +4 -1
@@ -933,7 +933,10 @@ static int clk_rcg2_set_force_enable(struct clk_hw *hw)/* wait for RCG to turn ON */ for (count =500 ; count >0 ; count--) { -if (clk_rcg2_is_enabled (hw)) + ret =clk_rcg2_is_enabled (hw); +if (ret <0 ) +return ret; +if (ret)return 0 ;udelay (1 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1884/2214 clk: qcom: rcg2: Clear force enable after rate failure
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Konrad Dybcio <[email protected]>
[ Upstream commit d4e8c6b9aef42d06cf5755543ad10097b2217990 ]
Shared RCG rate changes assert force-enable before programming the new configuration. If programming fails, the function returns without clearing force-enable, leaving the root running while CCF can release temporary parent and resource references.
Attempt to clear force-enable on the configuration error path before returning the original programming error. This restores the same cleanup performed after a successful configuration while preserving the primary failure for callers.
--- drivers/clk/qcom/clk-rcg2.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/clk/qcom/clk-rcg2.c +3 -1
@@ -965,8 +965,10 @@ clk_rcg2_shared_force_enable_clear(struct clk_hw *hw, const struct freq_tbl *f)return ret; ret =clk_rcg2_configure (rcg, f); -if (ret) +if (ret) { +clk_rcg2_clear_force_enable (hw);return ret; + }return clk_rcg2_clear_force_enable (hw); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1885/2214 s390/uprobes: Fix off-by-one bug in emulated PER handling
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiko Carstens <[email protected]>
[ Upstream commit 2ba01cf7b2598571486425a0605f1434909b532d ]
The uprobes code emulates some instructions, and with that also PER storage-alteration handling, in case a debugger is attached.
The PER storage-alteration handling contains an off-by-one bug, which may lead to PER traps which should not happen. Adjust the comparison in sim_stor_event() to fix that.
--- arch/s390/kernel/uprobes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/s390/kernel/uprobes.c +1 -1
@@ -254,7 +254,7 @@ static void sim_stor_event(struct pt_regs *regs, void *addr, int len)return ;if (!(current->thread.per_user.control &PER_EVENT_STORE ))return ; -if ((void *)current->thread.per_user.start > (addr + len)) +if ((void *)current->thread.per_user.start > (addr + len -1 ))return ;if ((void *)current->thread.per_user.end < addr)return ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1886/2214 nvme: tcp: split controller bringup handling
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Keith Busch <[email protected]>
[ Upstream commit 10fd7fb676d71482b64bc61f5058b1011133f984 ]
Drivers must call nvme_uninit_ctrl after a successful nvme_init_ctrl. Split the allocation side out to make the error handling boundary easier to navigate. The nvme tcp driver's error handling had different returns in the error goto label's, which harm readability.
Stable-dep-of: 87a1ac965502 ("nvme-tcp: store and use the caller's network namespace")
--- drivers/nvme/host/tcp.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-)
drivers/nvme/host/tcp.c +19 -6
@@ -2627,7 +2627,7 @@ nvme_tcp_existing_controller(struct nvmf_ctrl_options *opts)return found; } -static struct nvme_ctrl *nvme_tcp_create_ctrl (struct device *dev, +static struct nvme_tcp_ctrl *nvme_tcp_alloc_ctrl (struct device *dev,struct nvmf_ctrl_options *opts) {struct nvme_tcp_ctrl *ctrl;
@@ -2703,6 +2703,24 @@ static struct nvme_ctrl *nvme_tcp_create_ctrl(struct device *dev,if (ret) goto out_kfree_queues; +return ctrl; +out_kfree_queues: +kfree (ctrl->queues); +out_free_ctrl: +kfree (ctrl); +return ERR_PTR (ret); +} + +static struct nvme_ctrl *nvme_tcp_create_ctrl (struct device *dev, +struct nvmf_ctrl_options *opts) +{ +struct nvme_tcp_ctrl *ctrl; +int ret; + + ctrl =nvme_tcp_alloc_ctrl (dev, opts); +if (IS_ERR (ctrl)) +return ERR_CAST (ctrl); +if (!nvme_change_ctrl_state (&ctrl->ctrl,NVME_CTRL_CONNECTING )) {WARN_ON_ONCE (1 ); ret = -EINTR ;
@@ -2728,11 +2746,6 @@ static struct nvme_ctrl *nvme_tcp_create_ctrl(struct device *dev,if (ret >0 ) ret = -EIO ;return ERR_PTR (ret); -out_kfree_queues: -kfree (ctrl->queues); -out_free_ctrl: -kfree (ctrl); -return ERR_PTR (ret); }static struct nvmf_transport_ops nvme_tcp_transport = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1887/2214 nvme-tcp: fix selinux denied when calling sock_sendmsg
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peijie Shao <[email protected]>
[ Upstream commit 1be52169c3488ef98582ed553ab35cefa3978817 ]
In a SELinux enabled kernel, socket_create() initializes the security label of the socket using the security label of the calling process, this typically works well.
However, in a containerized environment like Kubernetes, problem arises when a privileged container(domain spc_t) connects to an NVMe target and mounts the NVMe as persistent storage for unprivileged containers(domain container_t).
This is because the container_t domain cannot access resources labeled with spc_t, resulting in socket_sendmsg returning -EACCES.
The solution is to use socket_create_kern() instead of socket_create(), which labels the socket context to kernel_t. Access control will then be handled by the VFS layer rather than the socket itself.
Stable-dep-of: 87a1ac965502 ("nvme-tcp: store and use the caller's network namespace")
--- drivers/nvme/host/tcp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/nvme/host/tcp.c +2 -1
@@ -1504,7 +1504,8 @@ static int nvme_tcp_alloc_queue(struct nvme_ctrl *nctrl, queue->cmnd_capsule_len =sizeof (struct nvme_command ) +NVME_TCP_ADMIN_CCSZ ; - ret =sock_create (ctrl->addr.ss_family,SOCK_STREAM , + ret =sock_create_kern (current->nsproxy->net_ns, + ctrl->addr.ss_family,SOCK_STREAM ,IPPROTO_TCP , &queue->sock);if (ret) { dev_err(nctrl->device,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1888/2214 nvme-tcp: store and use the callers network namespace
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Surabhi Gogte <[email protected]>
[ Upstream commit 87a1ac965502858f9207153a92c3aef8ecf6d4ae ]
nvme_tcp_alloc_queue() creates each socket using current->nsproxy->net_ns, which is correct for the initial connect that runs in userspace context. However, the reconnect and error recovery paths run from a workqueue where current netns is a kernel thread in init_net, so sockets created during reconnect end up in a different namespace than the one the controller was originally connected from.
Fix this by capturing the caller's network namespace at controller allocation time. Use ctrl->net for all socket creation so that every queue, on initial connect, reset, or reconnect, is created in the same namespace.
--- drivers/nvme/host/tcp.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/nvme/host/tcp.c +6 -1
@@ -168,6 +168,7 @@ struct nvme_tcp_ctrl {struct delayed_work connect_work;struct nvme_tcp_request async_req;u32 io_queues[HCTX_MAX_TYPES ]; +struct net *net; };static LIST_HEAD (nvme_tcp_ctrl_list);
@@ -1504,7 +1505,7 @@ static int nvme_tcp_alloc_queue(struct nvme_ctrl *nctrl, queue->cmnd_capsule_len =sizeof (struct nvme_command ) +NVME_TCP_ADMIN_CCSZ ; - ret =sock_create_kern (current->nsproxy->net_ns, + ret =sock_create_kern (ctrl->net, ctrl->addr.ss_family,SOCK_STREAM ,IPPROTO_TCP , &queue->sock);if (ret) {
@@ -2295,6 +2296,7 @@ static void nvme_tcp_free_ctrl(struct nvme_ctrl *nctrl)nvmf_free_options (nctrl->opts); free_ctrl: +put_net (ctrl->net);kfree (ctrl->queues);kfree (ctrl); }
@@ -2700,12 +2702,15 @@ static struct nvme_tcp_ctrl *nvme_tcp_alloc_ctrl(struct device *dev, goto out_free_ctrl; } + ctrl->net =get_net (current->nsproxy->net_ns); + ret =nvme_init_ctrl (&ctrl->ctrl, dev, &nvme_tcp_ctrl_ops,0 );if (ret) goto out_kfree_queues;return ctrl; out_kfree_queues: +put_net (ctrl->net);kfree (ctrl->queues); out_free_ctrl:kfree (ctrl);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1889/2214 nvmet-fc: dont drop the last assoc reference in nvmet_fc_delete_ctrl()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Palla Raghunath <[email protected]>
[ Upstream commit 165301b5e2fd765fa05ea1044bbca8ba79820197 ]
syzbot hit a recursive locking report on subsys->lock when a subsystem is unlinked from an FC port.
nvmet_port_del_ctrls() holds subsys->lock while it calls ->delete_ctrl() for each controller. nvmet_fc_delete_ctrl() grabs a reference on the association, queues del_work and then drops the reference. If del_work gets to run to completion before that put, ours is the last reference. Freeing the assoc tears down the queues, the last nvmet_cq_put() drops the last ctrl reference, and nvmet_ctrl_free() goes for subsys->lock again:
WARNING: possible recursive locking detected
...
nvmet_ctrl_free+0xa6/0x8e0 drivers/nvme/target/core.c:1766 nvmet_cq_put+0x158/0x200 drivers/nvme/target/core.c:848 nvmet_fc_target_assoc_free+0x418/0x2220 drivers/nvme/target/fc.c:1173 nvmet_fc_delete_ctrl+0x717/0x7e0 drivers/nvme/target/fc.c:1581 nvmet_port_del_ctrls+0xfb/0x150 drivers/nvme/target/core.c:311 nvmet_port_subsys_drop_link+0x1e8/0x310 drivers/nvme/target/configfs.c:1119
It's a real hang, not only a lockdep warning. I reproduced it with fcloop by putting an msleep() before the put: rm on the configfs link gets stuck in D state for good.
I don't think we need that reference at all. del_work does list_del_rcu() and synchronize_rcu() before it drops the initial reference, so an assoc we find on assoc_list can't go away before rcu_read_unlock(). nvmet_fc_schedule_delete_assoc() doesn't sleep, so just call it inside the RCU section and get rid of the get/put. If the assoc is already being deleted, terminating is set and the call is a no-op, which matches what happened before when the get failed.
With the same msleep() in place the patched kernel unlinks cleanly and the assoc is freed from the workqueue.
--- drivers/nvme/target/fc.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/nvme/target/fc.c +9 -6
@@ -1575,8 +1575,14 @@ nvmet_fc_delete_ctrl(struct nvmet_ctrl *ctrl)list_for_each_entry_rcu (assoc, &tgtport->assoc_list, a_list) { queue = assoc->queues[0 ];if (queue && queue->nvme_sq.ctrl == ctrl) { -if (nvmet_fc_tgt_a_get (assoc)) - found_ctrl = true; +/* +* No assoc reference here: we're called with +* subsys->lock held, and if del_work beat us, +* our put would free the ctrl under that lock. +* RCU keeps the assoc alive until unlock. +*/ +nvmet_fc_schedule_delete_assoc (assoc); + found_ctrl = true;break ; } }
@@ -1584,11 +1590,8 @@ nvmet_fc_delete_ctrl(struct nvmet_ctrl *ctrl)nvmet_fc_tgtport_put (tgtport); -if (found_ctrl) { -nvmet_fc_schedule_delete_assoc (assoc); -nvmet_fc_tgt_a_put (assoc); +if (found_ctrl)return ; - }spin_lock_irqsave (&nvmet_fc_tgtlock, flags); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1890/2214 ASoC: amd: raven: Fix acp3x_dma_close() being skipped on rollback
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 37ceef26df57c4a86a5e984b1951995aa96d4342 ]
snd_pcm_hw_constraint_integer() may return 1, which is then returned from acp3x_dma_open(). ASoC only marks the component as opened when .open() returns 0, so .close() can be skipped on rollback.
Return 0 explicitly on success.
--- sound/soc/amd/raven/acp3x-pcm-dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/amd/raven/acp3x-pcm-dma.c +1 -1
@@ -237,7 +237,7 @@ static int acp3x_dma_open(struct snd_soc_component *component, i2s_data->acp3x_base = adata->acp3x_base; runtime->private_data = i2s_data; -return ret; +return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1891/2214 ASoC: amd: renoir: Fix acp_pdm_dma_close() being skipped on rollback
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit a92571113ef297840270e4d8d4263a842302c9c4 ]
snd_pcm_hw_constraint_integer() may return 1, which is then returned from acp_pdm_dma_open(). ASoC only marks the component as opened when .open() returns 0, so .close() can be skipped on rollback.
Return 0 explicitly on success.
--- sound/soc/amd/renoir/acp3x-pdm-dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/amd/renoir/acp3x-pdm-dma.c +1 -1
@@ -227,7 +227,7 @@ static int acp_pdm_dma_open(struct snd_soc_component *component, pdm_data->acp_base = adata->acp_base; runtime->private_data = pdm_data; -return ret; +return 0 ; } static int acp_pdm_dma_hw_params(struct snd_soc_component *component,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1892/2214 ASoC: amd: vangogh: Fix acp5x_dma_close() being skipped on rollback
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 38559fcd1c518a33055ef0a2cf7c04b57bfa9215 ]
snd_pcm_hw_constraint_integer() may return 1, which is then returned from acp5x_dma_open(). ASoC only marks the component as opened when .open() returns 0, so .close() can be skipped on rollback.
Return 0 explicitly on success.
--- sound/soc/amd/vangogh/acp5x-pcm-dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/amd/vangogh/acp5x-pcm-dma.c +1 -1
@@ -231,7 +231,7 @@ static int acp5x_dma_open(struct snd_soc_component *component, } i2s_data->acp5x_base = adata->acp5x_base; runtime->private_data = i2s_data; -return ret; +return 0 ; } static int acp5x_dma_hw_params(struct snd_soc_component *component,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1893/2214 ASoC: atmel: atmel-pcm-pdc: Fix atmel_pcm_close() being skipped on rollback
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 50aaca643038774b6779c911c4f96bc7e0d607e9 ]
snd_pcm_hw_constraint_integer() may return 1, which is then returned from atmel_pcm_open(). ASoC only marks the component as opened when .open() returns 0, so .close() can be skipped on rollback.
Return 0 explicitly on success.
--- sound/soc/atmel/atmel-pcm-pdc.c | 2 ++ 1 file changed, 2 insertions(+)
sound/soc/atmel/atmel-pcm-pdc.c +2 -0
@@ -295,6 +295,8 @@ static int atmel_pcm_open(struct snd_soc_component *component, } runtime->private_data = prtd; +return 0 ; + out:return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1894/2214 ASoC: imx-pcm-rpmsg: Fix imx_rpmsg_pcm_close() being skipped on rollback
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 85e56c3bbb7e8ea4626f8653afaef0d79d9cb7ba ]
snd_pcm_hw_constraint_integer() may return 1, which is then returned from imx_rpmsg_pcm_open(). ASoC only marks the component as opened when .open() returns 0, so .close() can be skipped on rollback.
Return 0 explicitly on success.
--- sound/soc/fsl/imx-pcm-rpmsg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/fsl/imx-pcm-rpmsg.c +1 -1
@@ -274,7 +274,7 @@ static int imx_rpmsg_pcm_open(struct snd_soc_component *component, info->stream_timer[substream->stream].substream = substream;timer_setup (&info->stream_timer[substream->stream].timer, imx_rpmsg_timer_callback,0 ); -return ret; +return 0 ; } static int imx_rpmsg_pcm_close(struct snd_soc_component *component,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1895/2214 ASoC: atmel-i2s: fix MCK generator error handling
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 2e2da92de9bffd2cdbb9a2558fe60de7f1bb09e3 ]
Disable the gclk and reset the MCK configuration when an error occurs while enabling the MCK generator.
This prevents the gclk from remaining enabled after a failed clock configuration.
--- sound/soc/atmel/atmel-i2s.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
sound/soc/atmel/atmel-i2s.c +13 -3
@@ -466,11 +466,21 @@ static int atmel_i2s_switch_mck_generator(struct atmel_i2s_dev *dev, mr |=ATMEL_I2SC_MR_IMCKMODE_I2SMCK ; ret =regmap_update_bits (dev->regmap,ATMEL_I2SC_MR , mr_mask, mr);if (ret) -return ret; + goto err_disable_gclk;/* Finally enable the I2S Master Clock generator. */ -return regmap_write (dev->regmap,ATMEL_I2SC_CR , -ATMEL_I2SC_CR_CKEN ); + ret =regmap_write (dev->regmap,ATMEL_I2SC_CR ,ATMEL_I2SC_CR_CKEN ); +if (ret) + goto err_reset_mr; + +return 0 ; + +err_reset_mr: +regmap_update_bits (dev->regmap,ATMEL_I2SC_MR , mr_mask,0 ); +err_disable_gclk: +clk_disable_unprepare (dev->gclk); + +return ret; } static int atmel_i2s_trigger(struct snd_pcm_substream *substream, int cmd,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1896/2214 ASoC: atmel-i2s: use optional API for muxclk
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit be952abd69c1f2c845e42e72147751e4c910cd81 ]
The muxclk is an optional clock according to the device tree binding.
Use devm_clk_get_optional() to handle the optional muxclk instead of handling the missing clock explicitly.
When muxclk is not available, devm_clk_get_optional() returns NULL. clk_set_parent() returns 0 when passed NULL, preserving the existing behavior.
Unlike the existing code, errors other than -EPROBE_DEFER are now returned instead of being silently ignored.
--- sound/soc/atmel/atmel-i2s.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-)
sound/soc/atmel/atmel-i2s.c +5 -11
@@ -584,21 +584,15 @@ static int atmel_i2s_sama5d2_mck_init(struct atmel_i2s_dev *dev, struct device_node *np) {struct clk *muxclk; -int err;if (!dev->gclk)return 0 ; -/* muxclk is optional, so we return error for probe defer only */ - muxclk =devm_clk_get (dev->dev,"muxclk" ); -if (IS_ERR (muxclk)) { - err =PTR_ERR (muxclk); -if (err == -EPROBE_DEFER ) -return -EPROBE_DEFER ; -dev_dbg (dev->dev, -"failed to get the I2S clock control: %d\n" , err); -return 0 ; - } +/* muxclk is optional */ + muxclk =devm_clk_get_optional (dev->dev,"muxclk" ); +if (IS_ERR (muxclk)) +return dev_err_probe (dev->dev,PTR_ERR (muxclk), +"failed to get the I2S clock control\n" );return clk_set_parent (muxclk, dev->gclk); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1897/2214 ASoC: atmel-i2s: use optional API for gclk
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit b431a055fb7688c0d3725fa3c55aeef852991178 ]
The gclk is an optional clock according to the device tree binding.
Use devm_clk_get_optional() to handle the optional gclk directly.
Unlike the existing code, errors other than -EPROBE_DEFER are now returned instead of being silently ignored.
--- sound/soc/atmel/atmel-i2s.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
sound/soc/atmel/atmel-i2s.c +4 -7
@@ -665,13 +665,10 @@ static int atmel_i2s_probe(struct platform_device *pdev) }/* Get audio clock to generate the I2S Master Clock (I2S_MCK) */ - dev->gclk =devm_clk_get (&pdev->dev,"gclk" ); -if (IS_ERR (dev->gclk)) { -if (PTR_ERR (dev->gclk) == -EPROBE_DEFER ) -return -EPROBE_DEFER ; -/* Master Mode not supported */ - dev->gclk =NULL ; - } + dev->gclk =devm_clk_get_optional (&pdev->dev,"gclk" ); +if (IS_ERR (dev->gclk)) +return PTR_ERR (dev->gclk); + dev->dev = &pdev->dev; dev->regmap = regmap;platform_set_drvdata (pdev, dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1898/2214 sh: sh7785lcr: Register the PCA9564 controller as I2C bus 0
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 3b8386ffc0c33b6b5a6a8e64e1487c1adec57dc9 ]
Before commit 44454baa7ca7 ("i2c: Dynamically assign adapter id if it wasn't explictly specified"), a negative ID was replaced by zero, and I2C bus zero was instantiated. Since that commit, a negative ID is passed verbatim, instantiating an I2C bus with a dynamic number. As SH boards still use i2c_register_board_info(0, ...) to register I2C devices, they rely on the I2C bus being bus zero.
The SH7785LCR is the only SH board whose I2C adapter has a negative ID and its PCA9564 controller becomes i2c-1, causing registration of the R2025S/D RTC to fail and hwclock not detecting /dev/rtc0.
Set the platform device ID to 0 so that the adapter is registered as bus zero again.
--- arch/sh/boards/board-sh7785lcr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/sh/boards/board-sh7785lcr.c +1 -1
@@ -256,7 +256,7 @@ static struct i2c_pca9564_pf_platform_data i2c_platform_data = {static struct platform_device i2c_device = { .name ="i2c-pca-platform" , - .id =-1 , + .id =0 , .dev = { .platform_data = &i2c_platform_data, },
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1899/2214 lib: validate in-memory LZ4 chunk length
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhiling Zou <[email protected]>
[ Upstream commit 138a84817df01eda67bb23032ab49c23fe2ffc16 ]
We found and validated an issue in lib/decompress_unlz4.c. The bug is reachable by a root user through kexec_file_load() with a crafted external initrd.
unlz4() reads the compressed chunk length from an in-memory initrd and passes it to LZ4_decompress_safe(). It only checks the chunk length against the allocation size when the input is filled by a callback.
Reject an in-memory chunk that extends past the remaining input before calling the LZ4 decoder. This prevents malformed initrds from making the decoder read past the mapped archive.
--- lib/decompress_unlz4.c | 4 ++++ 1 file changed, 4 insertions(+)
lib/decompress_unlz4.c +4 -0
@@ -139,6 +139,10 @@ STATIC inline int INIT unlz4(u8 *input, long in_len,if (!fill) { inp +=4 ; size -=4 ; +if (chunksize > size) { +error ("data corrupted" ); + goto exit_2; + } }else {if (chunksize >LZ4_compressBound (uncomp_chunksize)) {error ("chunk length is longer than allocated" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1900/2214 ocfs2: retain all security xattrs during inode creation
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joseph Qi <[email protected]>
[ Upstream commit d637475617d8468c2740a3436428681bcc8d3572 ]
When creating a new inode, ocfs2_init_security_get() stores the security xattr returned by the LSM framework in ocfs2_security_xattr_info so that it can be written later within the same transaction. But ocfs2_initxattrs() only ever looks at the first element of the xattr array, and it keeps the name as a bare pointer into memory owned by the security layer instead of copying it. The value, by contrast, is already duplicated with kmemdup().
With stacked LSMs, security_inode_init_security() provides one xattr per LSM, so all labels but the first are silently dropped and never written to disk, leaving newly created files without the security xattrs the other LSMs rely on.
The borrowed name is not an outright bug with the LSMs in tree today:security_inode_init_security() frees only ->value once the callback returns, and documents ->name as the attribute name suffix, so the pointer stays valid for as long as ocfs2 uses it. It is fragile though, as an LSM that allocates the name together with the value would turn it into a use-after-free, so the rework below copies the names as well.
Fix this by storing copies of all the security xattrs: allocate an array in ocfs2_initxattrs(), copy the names and values, account for all of them in the credit calculations, and write each one in ocfs2_init_security_set().
While at it, switch the allocations from GFP_KERNEL to GFP_NOFS. The callback runs in the inode creation path with the parent directory locked, and the security layer allocates the very same xattr array with GFP_NOFS, so direct reclaim must not be allowed to recurse into the filesystem from here.
--- fs/ocfs2/namei.c | 6 +-- fs/ocfs2/xattr.c | 133 +++++++++++++++++++++++++++++++++++++---------- fs/ocfs2/xattr.h | 12 +++-- 3 files changed, 116 insertions(+), 35 deletions(-)
fs/ocfs2/namei.c +2 -4
@@ -244,7 +244,6 @@ static int ocfs2_mknod(struct user_namespace *mnt_userns,int want_meta =0 ;int xattr_credits =0 ;struct ocfs2_security_xattr_info si = { - .name =NULL , .enable =1 , };int did_quota_inode =0 ;
@@ -471,7 +470,7 @@ static int ocfs2_mknod(struct user_namespace *mnt_userns,brelse (new_fe_bh);brelse (parent_fe_bh); -kfree (si.value); +ocfs2_free_security_xattrs (&si);ocfs2_acl_init_release (&acl_state);
@@ -1814,7 +1813,6 @@ static int ocfs2_symlink(struct user_namespace *mnt_userns,int want_clusters =0 ;int xattr_credits =0 ;struct ocfs2_security_xattr_info si = { - .name =NULL , .enable =1 , };int did_quota =0 , did_quota_inode =0 ;
@@ -2046,7 +2044,7 @@ static int ocfs2_symlink(struct user_namespace *mnt_userns,brelse (new_fe_bh);brelse (parent_fe_bh); -kfree (si.value); +ocfs2_free_security_xattrs (&si);ocfs2_free_dir_lookup_result (&lookup);if (inode_ac)ocfs2_free_alloc_context (inode_ac);
fs/ocfs2/xattr.c +105 -28
193 lines not on this page · raw message
fs/ocfs2/xattr.h +9 -3
@@ -20,13 +20,18 @@ enum ocfs2_xattr_type { OCFS2_XATTR_MAX }; -struct ocfs2_security_xattr_info { -int enable; -const char *name; +struct ocfs2_security_xattr { +char *name;void *value;size_t value_len; }; +struct ocfs2_security_xattr_info { +int enable; +struct ocfs2_security_xattr *xattrs; +int count; +}; +extern const struct xattr_handler ocfs2_xattr_user_handler;extern const struct xattr_handler ocfs2_xattr_trusted_handler;extern const struct xattr_handler ocfs2_xattr_security_handler;
@@ -47,6 +52,7 @@ int ocfs2_xattr_remove(struct inode *, struct buffer_head *);int ocfs2_init_security_get (struct inode *,struct inode *,const struct qstr *,struct ocfs2_security_xattr_info *); +void ocfs2_free_security_xattrs (struct ocfs2_security_xattr_info *); int ocfs2_init_security_set(handle_t *, struct inode *, struct buffer_head *, struct ocfs2_security_xattr_info *,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1901/2214 ocfs2: fix possible deadlock between nfs_sync_rwlock and fs_reclaim
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joseph Qi <[email protected]>
[ Upstream commit 169bc4d16a8efa7852b101fdaa4c028505cd6750 ]
syzbot detected a circular locking dependency on &osb->nfs_sync_rwlock:
CPU0 CPU1
---- ----
lock(fs_reclaim);
lock(&ocfs2_sysfile_lock_key[INODE_ALLOC_SYSTEM_INODE]);
lock(fs_reclaim); rlock(&osb->nfs_sync_rwlock);
*** DEADLOCK ***
Chain exists of: &osb->nfs_sync_rwlock --> &ocfs2_sysfile_lock_key[INODE_ALLOC_SYSTEM_INODE] --> fs_reclaim
CPU0 is kswapd. The dentry shrinker runs under fs_reclaim and reaches ocfs2_delete_inode() through ->evict_inode():
kswapd
balance_pgdat
shrink_node
shrink_slab
super_cache_scan
prune_dcache_sb
shrink_dentry_list
dentry_kill
ocfs2_dentry_iput
evict
ocfs2_evict_inode
ocfs2_delete_inode
ocfs2_nfs_sync_lock
down_read(&osb->nfs_sync_rwlock) //C0: grabbingCPU1 is a task deleting an inode. It takes nfs_sync_rwlock first, then the orphan dir and inode alloc system inode i_rwsems, and allocates the metadata reservation with GFP_KERNEL while holding them:
evict
ocfs2_evict_inode
ocfs2_delete_inode
+ ocfs2_nfs_sync_lock
| down_read(&osb->nfs_sync_rwlock) //C1: hold
+ ocfs2_wipe_inode
+ inode_lock(orphan_dir_inode) //C1: hold
+ ocfs2_truncate_for_delete
| ocfs2_commit_truncate
| ocfs2_remove_btree_range
| ocfs2_reserve_blocks_for_rec_trunc
| ocfs2_reserve_new_metadata_blocks
| kzalloc_obj() //C1: grabbing
| // GFP_KERNEL -> might_alloc -> fs_reclaim_acquire
+ ocfs2_remove_inode
inode_lock(inode_alloc_inode)
jbd2 pins allocations to GFP_NOFS for the lifetime of a transaction handle, but these reservations are made before ocfs2_start_trans(), so fs_reclaim is acquired with ocfs2 locks still held and the cycle closes.
The same cycle is reachable from ocfs2_get_dentry() and ocfs2_get_parent(), which hold nfs_sync_rwlock for write across ocfs2_test_inode_bit() and ocfs2_iget().
This is more than a lockdep artifact. A GFP_KERNEL allocation under the orphan dir i_rwsem enters direct reclaim, which runs the shrinkers, which can evict another ocfs2 inode and re-enter ocfs2_wipe_inode() on the same task; the second inode_lock() on the singleton orphan dir inode then self-deadlocks, since i_rwsem is not recursive.
Establish a GFP_NOFS allocation context for the whole nfs_sync_rwlock critical section so that nothing holding it can recurse into filesystem reclaim. Do it in ocfs2_nfs_sync_lock()/ocfs2_nfs_sync_unlock() rather than at the call sites, so that future callers cannot forget it.
--- fs/ocfs2/dlmglue.c | 29 +++++++++++++++++++++++++---- fs/ocfs2/dlmglue.h | 5 +++-- fs/ocfs2/export.c | 10 ++++++---- fs/ocfs2/inode.c | 5 +++-- 4 files changed, 37 insertions(+), 12 deletions(-)
fs/ocfs2/dlmglue.c +25 -4
@@ -19,6 +19,7 @@#include <linux/time.h> #include <linux/delay.h> #include <linux/quotaops.h> +#include <linux/sched/mm.h> #include <linux/sched/signal.h> #define MLOG_MASK_PREFIX ML_DLM_GLUE
@@ -2853,21 +2854,34 @@ void ocfs2_rename_unlock(struct ocfs2_super *osb)ocfs2_cluster_unlock (osb, lockres,DLM_LOCK_EX ); } -int ocfs2_nfs_sync_lock (struct ocfs2_super *osb,int ex) +int ocfs2_nfs_sync_lock (struct ocfs2_super *osb,int ex,unsigned int *nofs_flag) {int status; +unsigned int flags;struct ocfs2_lock_res *lockres = &osb->osb_nfs_sync_lockres;if (ocfs2_is_hard_readonly (osb))return -EROFS ; +/* +* ocfs2_delete_inode() takes this lock from ->evict_inode(), which the +* dentry shrinker reaches while holding fs_reclaim. Anything allocated +* under the lock must therefore stay out of filesystem reclaim, or +* reclaim recurses back into the shrinker and tries to take this lock +* again. Cover the whole critical section, including the cluster lock +* and the sysfile inode locks the callers take below it. +*/ + flags =memalloc_nofs_save (); +if (ex)down_write (&osb->nfs_sync_rwlock);else down_read (&osb->nfs_sync_rwlock); -if (ocfs2_mount_local (osb)) +if (ocfs2_mount_local (osb)) { + *nofs_flag = flags;return 0 ; + } status =ocfs2_cluster_lock (osb, lockres, ex ?LKM_EXMODE :LKM_PRMODE ,0 ,0 );
@@ -2878,12 +2892,17 @@ int ocfs2_nfs_sync_lock(struct ocfs2_super *osb, int ex)up_write (&osb->nfs_sync_rwlock); else up_read(&osb->nfs_sync_rwlock); +memalloc_nofs_restore (flags); +return status; } -return status; + *nofs_flag = flags; + +return 0 ; } -void ocfs2_nfs_sync_unlock (struct ocfs2_super *osb,int ex) +void ocfs2_nfs_sync_unlock (struct ocfs2_super *osb,int ex, +unsigned int nofs_flag) {struct ocfs2_lock_res *lockres = &osb->osb_nfs_sync_lockres;
@@ -2894,6 +2913,8 @@ void ocfs2_nfs_sync_unlock(struct ocfs2_super *osb, int ex)up_write (&osb->nfs_sync_rwlock); else up_read(&osb->nfs_sync_rwlock); + +memalloc_nofs_restore (nofs_flag); } int ocfs2_trim_fs_lock(struct ocfs2_super *osb,
fs/ocfs2/dlmglue.h +3 -2
@@ -163,8 +163,9 @@ void ocfs2_orphan_scan_unlock(struct ocfs2_super *osb, u32 seqno);int ocfs2_rename_lock (struct ocfs2_super *osb);void ocfs2_rename_unlock (struct ocfs2_super *osb); -int ocfs2_nfs_sync_lock (struct ocfs2_super *osb,int ex); -void ocfs2_nfs_sync_unlock (struct ocfs2_super *osb,int ex); +int ocfs2_nfs_sync_lock (struct ocfs2_super *osb,int ex,unsigned int *nofs_flag); +void ocfs2_nfs_sync_unlock (struct ocfs2_super *osb,int ex, +unsigned int nofs_flag);void ocfs2_trim_fs_lock_res_init (struct ocfs2_super *osb);void ocfs2_trim_fs_lock_res_uninit (struct ocfs2_super *osb); int ocfs2_trim_fs_lock(struct ocfs2_super *osb,
fs/ocfs2/export.c +6 -4
@@ -37,6 +37,7 @@ static struct dentry *ocfs2_get_dentry(struct super_block *sb,struct inode *inode;struct ocfs2_super *osb =OCFS2_SB (sb);u64 blkno = handle->ih_blkno; +unsigned int nofs_flag =0 ;int status, set;struct dentry *result;
@@ -59,7 +60,7 @@ static struct dentry *ocfs2_get_dentry(struct super_block *sb,* This will synchronize us against ocfs2_delete_inode() on * all nodes */ - status =ocfs2_nfs_sync_lock (osb,1 ); + status =ocfs2_nfs_sync_lock (osb,1 , &nofs_flag);if (status <0 ) {mlog (ML_ERROR ,"getting nfs sync lock(EX) failed %d\n" , status); goto check_err;
@@ -89,7 +90,7 @@ static struct dentry *ocfs2_get_dentry(struct super_block *sb, inode =ocfs2_iget (osb, blkno,0 ,0 ); unlock_nfs_sync: -ocfs2_nfs_sync_unlock (osb,1 ); +ocfs2_nfs_sync_unlock (osb,1 , nofs_flag); check_err:if (status <0 ) {
@@ -132,12 +133,13 @@ static struct dentry *ocfs2_get_parent(struct dentry *child)u64 blkno;struct dentry *parent;struct inode *dir =d_inode (child); +unsigned int nofs_flag =0 ;int set;trace_ocfs2_get_parent (child, child->d_name.len, child->d_name.name, (unsigned long long )OCFS2_I (dir)->ip_blkno); - status =ocfs2_nfs_sync_lock (OCFS2_SB (dir->i_sb),1 ); + status =ocfs2_nfs_sync_lock (OCFS2_SB (dir->i_sb),1 , &nofs_flag);if (status <0 ) {mlog (ML_ERROR ,"getting nfs sync lock(EX) failed %d\n" , status); parent =ERR_PTR (status);
@@ -181,7 +183,7 @@ static struct dentry *ocfs2_get_parent(struct dentry *child)ocfs2_inode_unlock (dir,0 ); unlock_nfs_sync: -ocfs2_nfs_sync_unlock (OCFS2_SB (dir->i_sb),1 ); +ocfs2_nfs_sync_unlock (OCFS2_SB (dir->i_sb),1 , nofs_flag); bail:trace_ocfs2_get_parent_end (parent);
fs/ocfs2/inode.c +3 -2
@@ -1026,6 +1026,7 @@ static void ocfs2_delete_inode(struct inode *inode) {int wipe, status;sigset_t oldset; +unsigned int nofs_flag =0 ;struct buffer_head *di_bh =NULL ;struct ocfs2_dinode *di =NULL ;
@@ -1060,7 +1061,7 @@ static void ocfs2_delete_inode(struct inode *inode)* shared mode so that all nodes can still concurrently * process deletes. */ - status =ocfs2_nfs_sync_lock (OCFS2_SB (inode->i_sb),0 ); + status =ocfs2_nfs_sync_lock (OCFS2_SB (inode->i_sb),0 , &nofs_flag);if (status <0 ) {mlog (ML_ERROR ,"getting nfs sync lock(PR) failed %d\n" , status);ocfs2_cleanup_delete_inode (inode,0 );
@@ -1132,7 +1133,7 @@ static void ocfs2_delete_inode(struct inode *inode)brelse (di_bh); bail_unlock_nfs_sync: -ocfs2_nfs_sync_unlock (OCFS2_SB (inode->i_sb),0 ); +ocfs2_nfs_sync_unlock (OCFS2_SB (inode->i_sb),0 , nofs_flag); bail_unblock:ocfs2_unblock_signals (&oldset);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1902/2214 ocfs2: validate chunk and block counts of the local quota file
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nguyen Ngoc Thang <[email protected]>
[ Upstream commit b10ef5d2c2083ea4c40e963c10a73a154793c5d4 ]
ocfs2_local_read_info() trusts dqi_chunks and dqi_blocks from the local quota file header. If dqi_blocks is too small, ocfs2_extend_local_quota_file() computes a bogus chunk length, extends the file, and maps logical block dqi_blocks, which is already in the inode's metadata cache (the header or a chunk header read at mount). sb_getblk() returns that cached buffer and ocfs2_set_new_buffer_uptodate() hits BUG_ON(ocfs2_buffer_cached()):
kernel BUG at fs/ocfs2/uptodate.c:509!
ocfs2_extend_local_quota_file+0x45c/0x1100 ocfs2_create_local_dquot+0x8ac/0xb50 ocfs2_acquire_dquot+0x614/0xae0 ocfs2_get_init_inode+0xe9/0x1b0 ocfs2_mkdir+0x174/0x430
ocfs2_local_quota_add_chunk() has the same exposure.
Reject a header whose counts don't fit the chunk layout or exceed i_size.
Reproduced with a crafted image (dqi_blocks = 1, chunk 0 dqc_free = 0); syzbot has no reproducer for this report.
--- fs/ocfs2/quota_local.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
fs/ocfs2/quota_local.c +24 -0
@@ -245,6 +245,25 @@ static void ocfs2_release_local_quota_bitmaps(struct list_head *head) } } +/* Check that the on-disk chunk and block counts match the file layout */ +static int ocfs2_check_local_quota_info (struct inode *inode, +unsigned int chunks, +unsigned int blocks) +{ +u64 chunk_len =ol_chunk_blocks (inode->i_sb) +1 ; +u64 min_blocks = chunks ?1 + chunk_len * (chunks -1 ) +1 :1 ; +u64 max_blocks =1 + chunk_len * chunks; + +if (blocks >= min_blocks && blocks <= max_blocks && + blocks <=i_size_read (inode) >> inode->i_sb->s_blocksize_bits) +return 0 ; + +return ocfs2_error (inode->i_sb, +"Quota file %llu has bad info: %u chunks, %u blocks\n" , + (unsigned long long )OCFS2_I (inode)->ip_blkno, + chunks, blocks); +} +/* Load quota bitmaps into memory */ static int ocfs2_load_local_quota_bitmaps(struct inode *inode, struct ocfs2_local_disk_dqinfo *ldinfo,
@@ -730,6 +749,11 @@ static int ocfs2_local_read_info(struct super_block *sb, int type) oinfo->dqi_blocks =le32_to_cpu (ldinfo->dqi_blocks); oinfo->dqi_libh = bh; + status =ocfs2_check_local_quota_info (lqinode, oinfo->dqi_chunks, + oinfo->dqi_blocks); +if (status <0 ) + goto out_err; +/* We crashed when using local quota file? */ if (!(oinfo->dqi_flags &OLQF_CLEAN )) { rec =OCFS2_SB (sb)->quota_rec;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1903/2214 ALSA: pcm: Fix driver_tstamp value reporting
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Amadeusz Sławiński <[email protected]>
[ Upstream commit 8ff1161ac5aa02f3261e00f07d6212be2b12384b ]
In some cases (system32 and compat64) due to incorrect assignment wrong value is being reported. Fix it.
--- sound/core/pcm_compat.c | 4 ++-- sound/core/pcm_native.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
sound/core/pcm_compat.c +2 -2
@@ -219,8 +219,8 @@ static int snd_pcm_status_user_compat64(struct snd_pcm_substream *substream, .audio_tstamp_data = status.audio_tstamp_data, .audio_tstamp_sec = status.audio_tstamp_sec, .audio_tstamp_nsec = status.audio_tstamp_nsec, - .driver_tstamp_sec = status.audio_tstamp_sec, - .driver_tstamp_nsec = status.audio_tstamp_nsec, + .driver_tstamp_sec = status.driver_tstamp_sec, + .driver_tstamp_nsec = status.driver_tstamp_nsec, .audio_tstamp_accuracy = status.audio_tstamp_accuracy, };
sound/core/pcm_native.c +2 -2
@@ -1154,8 +1154,8 @@ static int snd_pcm_status_user32(struct snd_pcm_substream *substream, .audio_tstamp_data = status64.audio_tstamp_data, .audio_tstamp_sec = status64.audio_tstamp_sec, .audio_tstamp_nsec = status64.audio_tstamp_nsec, - .driver_tstamp_sec = status64.audio_tstamp_sec, - .driver_tstamp_nsec = status64.audio_tstamp_nsec, + .driver_tstamp_sec = status64.driver_tstamp_sec, + .driver_tstamp_nsec = status64.driver_tstamp_nsec, .audio_tstamp_accuracy = status64.audio_tstamp_accuracy, };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1904/2214 ALSA: jack: Fix kctl free at error in snd_jack_kctl_new()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit f421be924fec67f74bb0b6988ea8f0a3480df2a7 ]
When an error happens in snd_jack_kctl_new(), it tries to free the new kcontrol element via snd_ctl_free_one(). But snd_ctl_free_one() releases only the memories, and the internal linked list and hash entries still remain, which may lead to bogus accesses to user.
Replace with the correct destructor, snd_ctl_remove(), for clearing the whole resources of the given kcontrol, instead.
--- sound/core/jack.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/core/jack.c +1 -1
@@ -452,7 +452,7 @@ static struct snd_jack_kctl * snd_jack_kctl_new(struct snd_card *card, const chareturn jack_kctl; error: -snd_ctl_free_one (kctl); +snd_ctl_remove (card, kctl);return NULL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1905/2214 ALSA: line6: Use kzalloc() for PCM buffer allocation
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit 9ec633573c1d162bfc82cae52d14c220c875612f ]
LINE6 driver allocates the PCM buffer via kmalloc(), and this might leave some bytes uninitialized that are out of the actual ring buffer size, while it's still exposed via mmap.
For avoiding the leak of the uninitialized kernel memory, simply replace it with kzalloc().
--- sound/usb/line6/pcm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/usb/line6/pcm.c +1 -1
@@ -155,7 +155,7 @@ static int line6_buffer_acquire(struct snd_line6_pcm *line6pcm,/* Invoked multiple times in a row so allocate once only */ if (!test_and_set_bit (type, &pstr->opened) && !pstr->buffer) { pstr->buffer = -kmalloc (array3_size (line6pcm->line6->iso_buffers, +kzalloc (array3_size (line6pcm->line6->iso_buffers,LINE6_ISO_PACKETS , pkt_size),GFP_KERNEL );if (!pstr->buffer)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1906/2214 ALSA: vmaster: Serialize hook registration with control callbacks
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit 6215cf3ff5b0ff1ca5ab66b79021f9e28b02eae1 ]
An HDA virtual-master hook must have its private argument initialized before a control callback can invoke it. snd_hda_add_vmaster_hook() installs the trampoline through snd_ctl_add_vmaster_hook(), which stores master->hook before master->hook_private_data without serialization.
When a codec with a vmaster mute hook binds to an already registered card, snd_hda_gen_build_controls() publishes and initializes the Master Playback Switch before installing the hook. A native write that changes the switch can then run in the following order:
1. The codec bind path publishes and initializes the master control in __snd_hda_add_vmaster(), then calls snd_hda_add_vmaster_hook().
2. The hook setter stores master->hook, but has not yet stored its private argument.
3. SNDRV_CTL_IOCTL_ELEM_WRITE takes controls_rwsem and calls master_put() while the setter remains between those stores.
4. master_put() sees the callback and invokes vmaster_hook() with a NULL argument. The trampoline dereferences it before the setter can complete publication.
The write lock held by snd_ctl_elem_write() does not exclude the hook setter, so this can cause a NULL pointer dereference. Take the same controls_rwsem for writing inside snd_ctl_add_vmaster_hook() so the callback and its argument are installed together with respect to native control callbacks. Pass the card into the helper and update the HDA caller, keeping the lock in the ALSA core. Release it when registration returns, before the caller synchronizes the hook.
KASAN report as below:
Oops: general protection fault, probably for non-canonical address 0xdffffc0000000001: 0000 [#1] SMP KASAN NOPTI
KASAN: null-ptr-deref in range [0x0000000000000008-0x000000000000000f]
CPU: 1 UID: 0 PID: 499 Comm: alsa-vmaster-tr Not tainted 7.2.0-rc6-pmb-bt-functional-v1+ #1 PREEMPT(lazy)
Hardware name: QEMU Ubuntu 24.04 PC v2 (i440FX + PIIX, arch_caps fix, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
RIP: 0010:vmaster_hook+0x35/0xb0
Code: f5 53 48 89 fb 48 83 ec 08 e8 57 f0 9a fc eb 50 e8 50 f0 9a fc 48 8d 7b 08 48 b8 00 00 00 00 00 fc ff df 48 89 fa 48 c1 ea 03 <80> 3c 02 00 75 59 48 8d 7b 10 48 8b 43 08 48 ba 00 00 00 00 00 fc
RSP: 0018:ffff888117647cd0 EFLAGS: 00010212
RAX: dffffc0000000000 RBX: 0000000000000000 RCX: ffffffff84e9ff50
RDX: 0000000000000001 RSI: 0000000000000000 RDI: 0000000000000008
RBP: 0000000000000001 R08: 0000000000000001 R09: 0000000000000001
R10: ffffffff89427457 R11: ffff888115ad1d00 R12: ffffffff84e9ff30
R13: ffff888114943ca0 R14: 0000000000000000 R15: 0000000000000001
FS: 00007fe8167b3780(0000) GS:ffff88826b7e3000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000557c8c2842a8 CR3: 000000011579f005 CR4: 0000000000770ef0
PKRU: 55555554
Call Trace:
<TASK>
master_put+0x20e/0x2b0
snd_ctl_elem_write+0x37f/0x5e0
snd_ctl_ioctl+0x997/0xdd0
? __pfx_snd_ctl_ioctl+0x10/0x10
? srso_alias_return_thunk+0x5/0xfbef5
? selinux_file_ioctl+0xaa/0x280
? __pfx_snd_ctl_ioctl+0x10/0x10
__x64_sys_ioctl+0x163/0x1d0
do_syscall_64+0x115/0x6a0
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7fe8168c291b
Code: 00 48 89 44 24 18 31 c0 48 8d 44 24 60 c7 04 24 10 00 00 00 48 89 44 24 08 48 8d 44 24 20 48 89 44 24 10 b8 10 00 00 00 0f 05 <89> c2 3d 00 f0 ff ff 77 1c 48 8b 44 24 18 64 48 2b 04 25 28 00 00
RSP: 002b:00007fffab0cb150 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 00007fe8168c291b
RDX: 00007fffab0cb310 RSI: 00000000c4c85513 RDI: 0000000000000003
RBP: 00007fffab0cb310 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000001
R13: 00007fffab0cb1c0 R14: 0000000000000001 R15: 0000557c4f71fd10
</TASK>
Modules linked in:
---[ end trace 0000000000000000 ]------ include/sound/control.h | 2 +- sound/core/vmaster.c | 7 ++++++- sound/pci/hda/hda_codec.c | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-)
include/sound/control.h +1 -1
@@ -260,7 +260,7 @@ snd_ctl_add_follower_uncached(struct snd_kcontrol *master,return _snd_ctl_add_follower (master, follower,SND_CTL_FOLLOWER_NEED_UPDATE ); } -int snd_ctl_add_vmaster_hook (struct snd_kcontrol *kctl, +int snd_ctl_add_vmaster_hook (struct snd_card *card,struct snd_kcontrol *kctl,void (*hook)(void *private_data,int ),void *private_data);void snd_ctl_sync_vmaster (struct snd_kcontrol *kctl,bool hook_only);
sound/core/vmaster.c +6 -1
@@ -435,6 +435,7 @@ EXPORT_SYMBOL(snd_ctl_make_virtual_master);/** * snd_ctl_add_vmaster_hook - Add a hook to a vmaster control +* @card: the card instance * @kcontrol: vmaster kctl element * @hook: the hook function * @private_data: the private_data pointer to be saved
@@ -442,13 +443,17 @@ EXPORT_SYMBOL(snd_ctl_make_virtual_master);* Adds the given hook to the vmaster control element so that it's called * at each time when the value is changed. * +* Takes the card's controls_rwsem lock internally. +* * Return: Zero. */ -int snd_ctl_add_vmaster_hook (struct snd_kcontrol *kcontrol, +int snd_ctl_add_vmaster_hook (struct snd_card *card,struct snd_kcontrol *kcontrol,void (*hook)(void *private_data,int ),void *private_data) {struct link_master *master =snd_kcontrol_chip (kcontrol); + +guard (rwsem_write)(&card->controls_rwsem); master->hook = hook; master->hook_private_data = private_data;return 0 ;
sound/pci/hda/hda_codec.c +1 -1
@@ -2036,7 +2036,7 @@ int snd_hda_add_vmaster_hook(struct hda_codec *codec,if (!hook->hook || !hook->sw_kctl)return 0 ; hook->codec = codec; -snd_ctl_add_vmaster_hook (hook->sw_kctl, vmaster_hook, hook); +snd_ctl_add_vmaster_hook (codec->card, hook->sw_kctl, vmaster_hook, hook);return 0 ; }EXPORT_SYMBOL_GPL (snd_hda_add_vmaster_hook);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1907/2214 ALSA: usb-audio: Use fixed control index for us16x08 mixer elements
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit a68a688ce220f1b359bec53fa38d1504314dc70f ]
The callbacks for us16x08 mixer elements assume that id.index points to the channel to be operated, and the assumption is correct for now. However, since the kctls are added via snd_usb_mixer_add_control() and it looks for the empty slot if the same control name is already present, in theory, the index can become more than the channel numbers (if a conflicting name really happens).
Since the mixer code in us16x08 doesn't need the search for an empty slot but requires the fixed index, this patch changes slightly how to assign the kcontrols. Now, a new argument is added to snd_usb_mixer_add_list() in order to disable the empty slot search, and use it in us16x08's add_new_ctl() helper function, instead.
--- sound/usb/mixer.c | 13 +++++++++---- sound/usb/mixer.h | 5 +++-- sound/usb/mixer_quirks.c | 2 +- sound/usb/mixer_us16x08.c | 3 ++- 4 files changed, 15 insertions(+), 8 deletions(-)
sound/usb/mixer.c +9 -4
@@ -582,20 +582,25 @@ static int check_matrix_bitmap(unsigned char *bmap,/* * add an alsa control element -* search and increment the index until an empty slot is found. +* when @look_for_empty is set, search and increment the index until an empty +* slot is found. * * if failed, give up and free the control instance. */ int snd_usb_mixer_add_list (struct usb_mixer_elem_list *list,struct snd_kcontrol *kctl, -bool is_std_info) +bool is_std_info, +bool look_for_empty) {struct usb_mixer_interface *mixer = list->mixer;int err; -while (snd_ctl_find_id (mixer->chip->card, &kctl->id)) - kctl->id.index++; +if (look_for_empty) { +while (snd_ctl_find_id (mixer->chip->card, &kctl->id)) + kctl->id.index++; + } + err =snd_ctl_add (mixer->chip->card, kctl);if (err <0 ) { usb_audio_dbg(mixer->chip, "cannot add control (err = %d)\n",
sound/usb/mixer.h +3 -2
@@ -107,10 +107,11 @@ int snd_usb_mixer_set_ctl_value(struct usb_mixer_elem_info *cval,int snd_usb_mixer_add_list (struct usb_mixer_elem_list *list,struct snd_kcontrol *kctl, -bool is_std_info); +bool is_std_info, +bool look_for_empty);#define snd_usb_mixer_add_control (list, kctl) \ - snd_usb_mixer_add_list(list, kctl, true) + snd_usb_mixer_add_list(list, kctl, true, true) void snd_usb_mixer_elem_init_std(struct usb_mixer_elem_list *list, struct usb_mixer_interface *mixer,
sound/usb/mixer_quirks.c +1 -1
@@ -162,7 +162,7 @@ static int add_single_ctl_with_resume(struct usb_mixer_interface *mixer, } kctl->private_free = snd_usb_mixer_elem_free;/* don't use snd_usb_mixer_add_control() here, this is a special list element */ -return snd_usb_mixer_add_list (list, kctl, false); +return snd_usb_mixer_add_list (list, kctl, false, true); }/*
sound/usb/mixer_us16x08.c +2 -1
@@ -1112,7 +1112,8 @@ static int add_new_ctl(struct usb_mixer_interface *mixer,strscpy (kctl->id.name, name,sizeof (kctl->id.name)); - err =snd_usb_mixer_add_control (&elem->head, kctl); +/* look_for_empty=false, as we want the fixed id.index as channel */ + err =snd_usb_mixer_add_list (&elem->head, kctl, true, false);if (err <0 )return err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1908/2214 thermal/drivers/sprd: validate the sensor id from the device tree
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weigang He <[email protected]>
[ Upstream commit b17d799ce49bfaad68be5ff3df995b3bd021a9d7 ]
sprd_thm_probe() reads each sensor child node's "reg" property into sen->id and uses it without validation: to compute the sensor's register offsets in sprd_thm_sensor_init(), as the thermal zone id, and finally as an index into thm->sensor[], which has SPRD_THM_MAX_SENSOR
(8) entries:
ret = of_property_read_u32(sen_child, "reg", &sen->id); ... thm->sensor[sen->id] = sen;
Only the number of sensor nodes is checked against SPRD_THM_MAX_SENSOR. A "reg" value of 8 or more, or one that is negative once stored in the int sen->id, makes the register offsets point outside the sensor range and the final store land outside thm->sensor[], overwriting the fields that follow it in struct sprd_thermal_data or other memory.
Reject an out-of-range id right after reading it, before it is used.
This does not address sparse ids, such as a single sensor with id 7:
they leave holes in thm->sensor[] that the later loops over 0..nr_sensors-1 dereference. That needs a separate fix.
Found by static analysis tool CodeQL.
--- drivers/thermal/sprd_thermal.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/thermal/sprd_thermal.c +6 -0
@@ -400,6 +400,12 @@ static int sprd_thm_probe(struct platform_device *pdev) goto of_put; } +if (sen->id <0 || sen->id >=SPRD_THM_MAX_SENSOR ) { +dev_err (&pdev->dev,"invalid sensor id %d\n" , sen->id); + ret = -EINVAL ; + goto of_put; + } + ret =sprd_thm_sensor_calibration (sen_child, thm, sen);if (ret) {dev_err (&pdev->dev,"efuse cal analysis failed" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1909/2214 tools/thermal/tmon: Fix string truncation warning in optarg copy
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Fainelli <[email protected]>
[ Upstream commit 602da762f7a7c494a95cb204ac005965b214e556 ]
GCC warns about possible string truncation with -Wstringop-truncation:
tmon.c: In function ‘main’:
tmon.c:233:25: warning: ‘__builtin_strncpy’ specified bound 20 equals
destination size [-Wstringop-truncation]
233 | strncpy(ctrl_cdev, optarg,
CDEV_NAME_SIZE);
|^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Replace strncpy() with snprintf() to guarantee NUL-termination and silence the compiler warning.
--- tools/thermal/tmon/tmon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/thermal/tmon/tmon.c +1 -1
@@ -230,7 +230,7 @@ int main(int argc, char **argv)switch (c) {case 'c' : no_control =0 ; -strncpy (ctrl_cdev, optarg,CDEV_NAME_SIZE ); +snprintf (ctrl_cdev,sizeof (ctrl_cdev),"%s" , optarg);break ;case 'd' :start_daemon_mode ();
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1910/2214 thermal: ti-soc-thermal: Fix the return value in ti_bandgap_get_sensor_data() kernel-doc
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 82bb005cd9cf5a9df4cfe4a52db90346ac5fd17a ]
ti_bandgap_get_sensor_data() returns an ERR_PTR() if the bandgap instance or sensor ID is invalid. Otherwise it returns the stored sensor data, which can be NULL if no data has been set or the stored value has been cleared.
This mismatch was already present in omap_bandgap_get_sensor_data() when the driver was introduced in staging.
Document the validation errors while retaining NULL as a possible stored value.
--- drivers/thermal/ti-soc-thermal/ti-bandgap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/thermal/ti-soc-thermal/ti-bandgap.c +2 -1
@@ -576,7 +576,8 @@ int ti_bandgap_set_sensor_data(struct ti_bandgap *bgp, int id, void *data)* @bgp: pointer to bandgap instance * @id: sensor id * -* Return: data stored by set function with sensor id on success or NULL +* Return: the stored sensor data, which may be %NULL, or an ERR_PTR() +* if @bgp or @id is invalid. */ void *ti_bandgap_get_sensor_data (struct ti_bandgap *bgp,int id) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1911/2214 ipvs: fix buffer overflow when sending sync messages
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Julian Anastasov <[email protected]>
[ Upstream commit 3e3fe49e8678c1a3d535ed02f32a9a6e80674263 ]
Sashiko reports for possible heap buffer overflow when generating sync message for the v0 and v1 message formats. We should read the cp->flags only once because another CPU can concurrently set the SEQ_MASK between the two reads.
Note that IPVS does not set the SEQ_MASK anymore for the ip_vs_ftp.c helper starting from commit 7f1c40757951 ("IPVS: make FTP work with full NAT support") (2.6.36+), so the problem should not be reproducible.
--- net/netfilter/ipvs/ip_vs_sync.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-)
net/netfilter/ipvs/ip_vs_sync.c +14 -9
@@ -544,13 +544,15 @@ static void ip_vs_sync_conn_v0(struct netns_ipvs *ipvs, struct ip_vs_conn *cp,struct ip_vs_sync_conn_v0 *s;struct ip_vs_sync_buff *buff;struct ipvs_master_sync_state *ms; -int id; +u32 flags, seq_mask;unsigned int len; +int id;if (unlikely (cp->af !=AF_INET ))return ; + flags =READ_ONCE (cp->flags);/* Do not sync ONE PACKET */ -if (cp->flags &IP_VS_CONN_F_ONE_PACKET ) +if (flags &IP_VS_CONN_F_ONE_PACKET )return ;if (!ip_vs_sync_conn_needed (ipvs, cp, pkts))
@@ -565,8 +567,8 @@ static void ip_vs_sync_conn_v0(struct netns_ipvs *ipvs, struct ip_vs_conn *cp, id =select_master_thread_id (ipvs, cp); ms = &ipvs->ms[id]; buff = ms->sync_buff; - len = (cp->flags &IP_VS_CONN_F_SEQ_MASK ) ?FULL_CONN_SIZE : -SIMPLE_CONN_SIZE ; + seq_mask = flags &IP_VS_CONN_F_SEQ_MASK ; + len = seq_mask ?FULL_CONN_SIZE :SIMPLE_CONN_SIZE ;if (buff) { m = (struct ip_vs_sync_mesg_v0 *) buff->mesg;/* Send buffer if it is for v1 */
@@ -598,9 +600,9 @@ static void ip_vs_sync_conn_v0(struct netns_ipvs *ipvs, struct ip_vs_conn *cp, s->caddr = cp->caddr.ip; s->vaddr = cp->vaddr.ip; s->daddr = cp->daddr.ip; - s->flags =htons (cp->flags & ~IP_VS_CONN_F_HASHED ); + s->flags =htons (flags & ~IP_VS_CONN_F_HASHED ); s->state =htons (cp->state); -if (cp->flags &IP_VS_CONN_F_SEQ_MASK ) { +if (seq_mask) {struct ip_vs_sync_conn_options *opt = (struct ip_vs_sync_conn_options *)&s[1 ];memcpy (opt, &cp->sync_conn_opt,sizeof (*opt));
@@ -636,6 +638,7 @@ void ip_vs_sync_conn(struct netns_ipvs *ipvs, struct ip_vs_conn *cp, int pkts)int id;__u8 *p;unsigned int len, pe_name_len, pad; +u32 flags, seq_mask;/* Handle old version of the protocol */ if (sysctl_sync_ver (ipvs) ==0 ) {
@@ -648,6 +651,7 @@ void ip_vs_sync_conn(struct netns_ipvs *ipvs, struct ip_vs_conn *cp, int pkts) sloop:if (!ip_vs_sync_conn_needed (ipvs, cp, pkts)) goto control; + flags =READ_ONCE (cp->flags);/* Sanity checks */ pe_name_len =0 ;
@@ -675,7 +679,8 @@ void ip_vs_sync_conn(struct netns_ipvs *ipvs, struct ip_vs_conn *cp, int pkts)#endif len =sizeof (struct ip_vs_sync_v4 ); -if (cp->flags &IP_VS_CONN_F_SEQ_MASK ) + seq_mask = flags &IP_VS_CONN_F_SEQ_MASK ; +if (seq_mask) len +=sizeof (struct ip_vs_sync_conn_options ) +2 ;if (cp->pe_data_len)
@@ -721,7 +726,7 @@ void ip_vs_sync_conn(struct netns_ipvs *ipvs, struct ip_vs_conn *cp, int pkts)/* Set message type & copy members */ s->v4.type = (cp->af ==AF_INET6 ?STYPE_F_INET6 :0 ); s->v4.ver_size =htons (len &SVER_MASK );/* Version 0 */ - s->v4.flags =htonl (cp->flags & ~IP_VS_CONN_F_HASHED ); + s->v4.flags =htonl (flags & ~IP_VS_CONN_F_HASHED ); s->v4.state =htons (cp->state); s->v4.protocol = cp->protocol; s->v4.cport = cp->cport;
@@ -745,7 +750,7 @@ void ip_vs_sync_conn(struct netns_ipvs *ipvs, struct ip_vs_conn *cp, int pkts) s->v4.vaddr = cp->vaddr.ip; s->v4.daddr = cp->daddr.ip; } -if (cp->flags &IP_VS_CONN_F_SEQ_MASK ) { +if (seq_mask) { *(p++) =IPVS_OPT_SEQ_DATA ; *(p++) =sizeof (struct ip_vs_sync_conn_options );hton_seq (&cp->in_seq, (struct ip_vs_seq *)p);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1912/2214 ALSA: pcm: Unlink substreams before releasing them
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit d1e57f8fb7a6b6d32a4aaa31fd6fc4c77339608f ]
A closing PCM substream can remain in its linked group after the driver close callback has freed its private data. With two configured dummy capture substreams on the same PCM device, linked with LINK, PREPARE on the surviving substream can still visit the closing member:
Final close of A PREPARE on linked B
---------------- -------------------
snd_pcm_drop(): group -> SETUP
do_hw_free(A)
dummy_pcm_close(A): free dpcm
Take snd_pcm_link_rwsem for reading Walk the group, including A dummy_pcm_prepare(A)
Read freed timer_ops
pcm_release_private(A)
snd_pcm_unlink(A)
Unlink at the start of final substream release, before dropping the stream or releasing driver resources. The link write lock waits for an existing group PREPARE, and unlink removes the closing member from later group actions. Keep the existing stop synchronization in do_hw_free() before the driver resources are freed.
Make unlink independent of the pcm_release callback so OSS substreams are covered too. Remove the native-only unlink callback and its registration, while retaining the callback hook for OSS cleanup.
The existing KASAN report below records the freed timer_ops read in dummy_pcm_prepare().
KASAN report as below:
BUG: KASAN: slab-use-after-free in dummy_pcm_prepare+0xb7/0xc0
Read of size 8 at addr ffff888106b35f00 by task alsa_pcm_fixtur/491
Call Trace:
<TASK>
dump_stack_lvl+0x93/0xd0
print_report+0xce/0x630
? dummy_pcm_prepare+0xb7/0xc0
? srso_alias_return_thunk+0x5/0xfbef5
? __virt_addr_valid+0x20d/0x410
? dummy_pcm_prepare+0xb7/0xc0
kasan_report+0xe0/0x110
? dummy_pcm_prepare+0xb7/0xc0
dummy_pcm_prepare+0xb7/0xc0
snd_pcm_do_prepare+0x71/0xb0
snd_pcm_action_group+0x505/0xb30
snd_pcm_action_nonatomic+0xab/0x150
snd_pcm_common_ioctl+0x1bf5/0x3a50
? srso_alias_return_thunk+0x5/0xfbef5
? do_vfs_ioctl+0x1f5/0x1280
? __pfx_do_vfs_ioctl+0x10/0x10
? ioctl_has_perm.constprop.0.isra.0+0x34f/0x500
? __pfx_snd_pcm_common_ioctl+0x10/0x10
? __fput+0x5ba/0xa60
? srso_alias_return_thunk+0x5/0xfbef5
snd_pcm_ioctl+0x76/0xb0
? __pfx_snd_pcm_ioctl+0x10/0x10
__x64_sys_ioctl+0x163/0x1d0
do_syscall_64+0x115/0x6a0
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x41ee8d
Code: 04 25 28 00 00 00 48 89 45 c8 31 c0 48 8d 45 10 c7 45 b0 10 00 00 00 48 89 45 b8 48 8d 45 d0 48 89 45 c0 b8 10 00 00 00 0f 05 <89> c2 3d 00 f0 ff ff 77 1a 48 8b 45 c8 64 48 2b 04 25 28 00 00 00
RSP: 002b:00007ffcfa72fb60 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 0000000000000004 RCX: 000000000041ee8d
RDX: 0000000000000000 RSI: 0000000000004140 RDI: 0000000000000004
RBP: 00007ffcfa72fbb0 R08: 00007ffcfa72fb98 R09: 0000000000000110
R10: 0000000000000001 R11: 0000000000000246 R12: 00007ffcfa72fcd8
R13: 00007ffcfa72fcf0 R14: 00000000004a8f28 R15: 0000000000000001
</TASK>
Allocated by task 488:
kasan_save_stack+0x33/0x60
kasan_save_track+0x14/0x30
__kasan_kmalloc+0xaa/0xb0
__kmalloc_cache_noprof+0x251/0x610
dummy_hrtimer_create+0x4a/0x170
dummy_pcm_open+0xe7/0x730
snd_pcm_open_substream+0x926/0x1580
snd_pcm_open+0x28d/0x6d0
snd_pcm_capture_open+0x82/0xe0
snd_open+0x1ec/0x3e0
chrdev_open+0x21f/0x660
do_dentry_open+0x5c8/0x1300
vfs_open+0x87/0x390
path_openat+0x2460/0x3cd0
do_file_open+0x21e/0x470
do_sys_openat2+0xf4/0x1b0
__x64_sys_openat+0x136/0x1e0
do_syscall_64+0x115/0x6a0
entry_SYSCALL_64_after_hwframe+0x77/0x7f
Freed by task 490:
kasan_save_stack+0x33/0x60
kasan_save_track+0x14/0x30
kasan_save_free_info+0x3b/0x60
__kasan_slab_free+0x5f/0x80
kfree+0x307/0x580
dummy_hrtimer_free+0x72/0xe0
dummy_pcm_close+0x9f/0xd0
snd_pcm_release_substream.part.0+0x104/0x310
snd_pcm_release+0x106/0x240
__fput+0x39f/0xa60
fput_close_sync+0xff/0x200
__x64_sys_close+0x8c/0xf0
do_syscall_64+0x115/0x6a0
entry_SYSCALL_64_after_hwframe+0x77/0x7f
==================================================================--- sound/core/pcm_native.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
sound/core/pcm_native.c +2 -8
@@ -2737,18 +2737,14 @@ static int snd_pcm_hw_constraints_complete(struct snd_pcm_substream *substream)return 0 ; } -static void pcm_release_private (struct snd_pcm_substream *substream) -{ -if (snd_pcm_stream_linked (substream)) -snd_pcm_unlink (substream); -} -void snd_pcm_release_substream (struct snd_pcm_substream *substream) { substream->ref_count--;if (substream->ref_count >0 )return ; +snd_pcm_unlink (substream); +snd_pcm_drop (substream);if (substream->hw_opened) {if (substream->runtime->state !=SNDRV_PCM_STATE_OPEN )
@@ -2825,8 +2821,6 @@ static int snd_pcm_open_file(struct file *file,return -ENOMEM ; } pcm_file->substream = substream; -if (substream->ref_count ==1 ) - substream->pcm_release = pcm_release_private; file->private_data = pcm_file;return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1913/2214 serial: pmac_zilog: report received breaks
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tim Douglas <[email protected]>
[ Upstream commit 8db79ea07a67b126c773da6efdc00066000daeb8 ]
pmz_status_handle() sets PMACZILOG_FLAG_BREAK from RR0, and pmz_receive_chars() clears it on the null character that ends the break without marking that character, then tests BRK_ABRT in RR1, where the SCC does not set it in asynchronous mode. Breaks therefore arrive as plain NULs: brk is never counted and BRKINT, PARMRK and SysRq never see them.
Set BRK_ABRT in r1 for that character, as sunzilog does.
--- drivers/tty/serial/pmac_zilog.c | 1 + 1 file changed, 1 insertion(+)
drivers/tty/serial/pmac_zilog.c +1 -0
@@ -240,6 +240,7 @@ static bool pmz_receive_chars(struct uart_pmac_port *uap) ch &= uap->parity_mask;if (ch ==0 && uap->flags &PMACZILOG_FLAG_BREAK ) { uap->flags &= ~PMACZILOG_FLAG_BREAK ; + r1 |=BRK_ABRT ; }#if defined(CONFIG_MAGIC_SYSRQ ) && defined(CONFIG_SERIAL_CORE_CONSOLE )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1914/2214 ASoC: codecs: wm8990: Fix definition of right input PGA controls
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit 5bd6d05197affaf5a2d7fae0e06e7373fd839b7c ]
The right input PGA boost (R12MNBST, R34MNBST) and routing (R12MNB, R34MNB) bits are in Input Mixer4 (R42), not in Input Mixer3 (R41), where these controls write the left channel bits.
--- sound/soc/codecs/wm8990.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
sound/soc/codecs/wm8990.c +4 -4
@@ -97,8 +97,8 @@ static const struct snd_kcontrol_new wm8990_snd_controls[] = {SOC_SINGLE ("LIN12 PGA Boost" ,WM8990_INPUT_MIXER3 ,WM8990_L12MNBST_BIT ,1 ,0 ),SOC_SINGLE ("LIN34 PGA Boost" ,WM8990_INPUT_MIXER3 ,WM8990_L34MNBST_BIT ,1 ,0 ),/* INMIXR */ -SOC_SINGLE ("RIN12 PGA Boost" ,WM8990_INPUT_MIXER3 ,WM8990_R12MNBST_BIT ,1 ,0 ), -SOC_SINGLE ("RIN34 PGA Boost" ,WM8990_INPUT_MIXER3 ,WM8990_R34MNBST_BIT ,1 ,0 ), +SOC_SINGLE ("RIN12 PGA Boost" ,WM8990_INPUT_MIXER4 ,WM8990_R12MNBST_BIT ,1 ,0 ), +SOC_SINGLE ("RIN34 PGA Boost" ,WM8990_INPUT_MIXER4 ,WM8990_R34MNBST_BIT ,1 ,0 ),/* LOMIX */ SOC_SINGLE_TLV("LOMIX LIN3 Bypass Volume", WM8990_OUTPUT_MIXER3,
@@ -377,9 +377,9 @@ SOC_DAPM_SINGLE_TLV("Record Right Volume", WM8990_INPUT_MIXER4, WM8990_RDBVOL_SHIFT, WM8990_RDBVOL_MASK, 0, in_mix_tlv),SOC_DAPM_SINGLE_TLV ("RIN2 Volume" ,WM8990_INPUT_MIXER6 ,WM8990_RI2BVOL_SHIFT ,7 ,0 , in_mix_tlv), -SOC_DAPM_SINGLE ("RINPGA12 Switch" ,WM8990_INPUT_MIXER3 ,WM8990_L12MNB_BIT , +SOC_DAPM_SINGLE ("RINPGA12 Switch" ,WM8990_INPUT_MIXER4 ,WM8990_R12MNB_BIT ,1 ,0 ), -SOC_DAPM_SINGLE ("RINPGA34 Switch" ,WM8990_INPUT_MIXER3 ,WM8990_L34MNB_BIT , +SOC_DAPM_SINGLE ("RINPGA34 Switch" ,WM8990_INPUT_MIXER4 ,WM8990_R34MNB_BIT , 1, 0), };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1915/2214 ASoC: codecs: wm8990: Fix definition of LOMIX AINLMUX Bypass Volume control
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit 75e0b607e3456c9eb15dfb783984f814a89cbcaf ]
The LOMIX AINLMUX bypass volume (LLBLOVOL) is at bits 2:0 of Output Mixer5, not at bits 5:3, which hold the AINRMUX bypass volume (LRBLOVOL).
--- sound/soc/codecs/wm8990.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/wm8990.c +1 -1
@@ -112,7 +112,7 @@ SOC_SINGLE_TLV("LOMIX RIN3 Bypass Volume", WM8990_OUTPUT_MIXER5,SOC_SINGLE_TLV ("LOMIX AINRMUX Bypass Volume" ,WM8990_OUTPUT_MIXER5 ,WM8990_LRBLOVOL_SHIFT ,WM8990_LRBLOVOL_MASK ,1 , out_mix_tlv),SOC_SINGLE_TLV ("LOMIX AINLMUX Bypass Volume" ,WM8990_OUTPUT_MIXER5 , -WM8990_LRBLOVOL_SHIFT ,WM8990_LRBLOVOL_MASK ,1 , out_mix_tlv), +WM8990_LLBLOVOL_SHIFT ,WM8990_LLBLOVOL_MASK ,1 , out_mix_tlv),/* ROMIX */ SOC_SINGLE_TLV("ROMIX RIN3 Bypass Volume", WM8990_OUTPUT_MIXER4,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1916/2214 ASoC: codecs: wm8991: Fix definition of right input PGA controls
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit 2dfecdc25d4937a36675c0c36ee0addc99e1e7f9 ]
The right input PGA boost (R12MNBST, R34MNBST) and routing (R12MNB, R34MNB) bits are in Input Mixer4 (R42), not in Input Mixer3 (R41), where these controls write the left channel bits.
--- sound/soc/codecs/wm8991.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
sound/soc/codecs/wm8991.c +4 -4
@@ -169,8 +169,8 @@ static const struct snd_kcontrol_new wm8991_snd_controls[] = {SOC_SINGLE ("LIN12 PGA Boost" ,WM8991_INPUT_MIXER3 ,WM8991_L12MNBST_BIT ,1 ,0 ),SOC_SINGLE ("LIN34 PGA Boost" ,WM8991_INPUT_MIXER3 ,WM8991_L34MNBST_BIT ,1 ,0 ),/* INMIXR */ -SOC_SINGLE ("RIN12 PGA Boost" ,WM8991_INPUT_MIXER3 ,WM8991_R12MNBST_BIT ,1 ,0 ), -SOC_SINGLE ("RIN34 PGA Boost" ,WM8991_INPUT_MIXER3 ,WM8991_R34MNBST_BIT ,1 ,0 ), +SOC_SINGLE ("RIN12 PGA Boost" ,WM8991_INPUT_MIXER4 ,WM8991_R12MNBST_BIT ,1 ,0 ), +SOC_SINGLE ("RIN34 PGA Boost" ,WM8991_INPUT_MIXER4 ,WM8991_R34MNBST_BIT ,1 ,0 ),/* LOMIX */ SOC_SINGLE_TLV("LOMIX LIN3 Bypass Volume", WM8991_OUTPUT_MIXER3,
@@ -446,9 +446,9 @@ static const struct snd_kcontrol_new wm8991_dapm_inmixr_controls[] = { WM8991_RDBVOL_SHIFT, WM8991_RDBVOL_MASK, 0, in_mix_tlv),SOC_DAPM_SINGLE_TLV ("RIN2 Volume" ,WM8991_INPUT_MIXER6 ,WM8991_RI2BVOL_SHIFT ,7 ,0 , in_mix_tlv), -SOC_DAPM_SINGLE ("RINPGA12 Switch" ,WM8991_INPUT_MIXER3 ,WM8991_L12MNB_BIT , +SOC_DAPM_SINGLE ("RINPGA12 Switch" ,WM8991_INPUT_MIXER4 ,WM8991_R12MNB_BIT ,1 ,0 ), -SOC_DAPM_SINGLE ("RINPGA34 Switch" ,WM8991_INPUT_MIXER3 ,WM8991_L34MNB_BIT , +SOC_DAPM_SINGLE ("RINPGA34 Switch" ,WM8991_INPUT_MIXER4 ,WM8991_R34MNB_BIT , 1, 0), };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1917/2214 ASoC: codecs: wm8991: Fix definition of LOMIX AINLMUX Bypass Volume control
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit fee722db39c2a1f18c944f747271fd1e131910a6 ]
The LOMIX AINLMUX bypass volume (LLBLOVOL) is at bits 2:0 of Output Mixer5, not at bits 5:3, which hold the AINRMUX bypass volume (LRBLOVOL).
--- sound/soc/codecs/wm8991.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/wm8991.c +1 -1
@@ -184,7 +184,7 @@ static const struct snd_kcontrol_new wm8991_snd_controls[] = {SOC_SINGLE_TLV ("LOMIX AINRMUX Bypass Volume" ,WM8991_OUTPUT_MIXER5 ,WM8991_LRBLOVOL_SHIFT ,WM8991_LRBLOVOL_MASK ,1 , out_mix_tlv),SOC_SINGLE_TLV ("LOMIX AINLMUX Bypass Volume" ,WM8991_OUTPUT_MIXER5 , -WM8991_LRBLOVOL_SHIFT ,WM8991_LRBLOVOL_MASK ,1 , out_mix_tlv), +WM8991_LLBLOVOL_SHIFT ,WM8991_LLBLOVOL_MASK ,1 , out_mix_tlv),/* ROMIX */ SOC_SINGLE_TLV("ROMIX RIN3 Bypass Volume", WM8991_OUTPUT_MIXER4,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1918/2214 ASoC: codecs: wm8983: Fix definition of ADC 128x Oversampling control
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit c1af9e2272f025ff75be76e03413074d5e7801c9 ]
ADC 128x oversampling (ADCOSR128) is at bit 3 of ADC Control, not at bit 8, which is the high pass filter enable (HPFEN).
--- sound/soc/codecs/wm8983.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/wm8983.c +1 -1
@@ -234,7 +234,7 @@ static const struct snd_kcontrol_new wm8983_snd_controls[] = { 8, 1, 0, pga_boost_tlv),SOC_DOUBLE ("ADC Inversion Switch" ,WM8983_ADC_CONTROL ,0 ,1 ,1 ,0 ), -SOC_SINGLE ("ADC 128x Oversampling Switch" ,WM8983_ADC_CONTROL ,8 ,1 ,0 ), +SOC_SINGLE ("ADC 128x Oversampling Switch" ,WM8983_ADC_CONTROL ,3 ,1 ,0 ),SOC_DOUBLE_R_TLV ("Playback Volume" ,WM8983_LEFT_DAC_DIGITAL_VOL , WM8983_RIGHT_DAC_DIGITAL_VOL, 0, 255, 0, dac_tlv),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1919/2214 ASoC: codecs: wm8985: Fix definition of ADC 128x Oversampling control
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit a747ec6e12cf7a71e42567a479af18b930890d9d ]
ADC 128x oversampling (ADCOSR128) is at bit 3 of ADC Control, not at bit 8, which is the high pass filter enable (HPFEN).
--- sound/soc/codecs/wm8985.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/wm8985.c +1 -1
@@ -327,7 +327,7 @@ static const struct snd_kcontrol_new wm8985_common_snd_controls[] = { 8, 1, 0, pga_boost_tlv),SOC_DOUBLE ("ADC Inversion Switch" ,WM8985_ADC_CONTROL ,0 ,1 ,1 ,0 ), -SOC_SINGLE ("ADC 128x Oversampling Switch" ,WM8985_ADC_CONTROL ,8 ,1 ,0 ), +SOC_SINGLE ("ADC 128x Oversampling Switch" ,WM8985_ADC_CONTROL ,3 ,1 ,0 ),SOC_DOUBLE_R_TLV ("Playback Volume" ,WM8985_LEFT_DAC_DIGITAL_VOL , WM8985_RIGHT_DAC_DIGITAL_VOL, 0, 255, 0, dac_tlv),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1920/2214 ASoC: codecs: wm8994: Fix definition of WM8958 noise gate hold time controls
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit 291d81d628f3453026b029507a26b856056e4fdc ]
The noise gate hold time (NG_HLD) is at bits 6:5 of each WM8958 DAC noise gate register, not at bits 3:1, which hold the threshold (NG_THR).
--- sound/soc/codecs/wm8994.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
sound/soc/codecs/wm8994.c +3 -3
@@ -700,17 +700,17 @@ static const char *wm8958_ng_text[] = { static SOC_ENUM_SINGLE_DECL(wm8958_aif1dac1_ng_hold, WM8958_AIF1_DAC1_NOISE_GATE, - WM8958_AIF1DAC1_NG_THR_SHIFT, + WM8958_AIF1DAC1_NG_HLD_SHIFT, wm8958_ng_text); static SOC_ENUM_SINGLE_DECL(wm8958_aif1dac2_ng_hold, WM8958_AIF1_DAC2_NOISE_GATE, - WM8958_AIF1DAC2_NG_THR_SHIFT, + WM8958_AIF1DAC2_NG_HLD_SHIFT, wm8958_ng_text); static SOC_ENUM_SINGLE_DECL(wm8958_aif2dac_ng_hold, WM8958_AIF2_DAC_NOISE_GATE, - WM8958_AIF2DAC_NG_THR_SHIFT, + WM8958_AIF2DAC_NG_HLD_SHIFT, wm8958_ng_text);static const struct snd_kcontrol_new wm8958_snd_controls[] = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1921/2214 ASoC: codecs: wm8955: Fix definition of Treble Cutoff control
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit 71911bf5bb3fe97da2124d17fc1dd3dbb9379e03 ]
Treble cutoff (TC) is at bit 6 of Treble Control, not at bit 2, which is part of the treble volume (TRBL[3:0]).
--- sound/soc/codecs/wm8955.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/wm8955.c +1 -1
@@ -426,7 +426,7 @@ static const char *treble_cutoff_text[] = {"High" ,"Low" }; -static SOC_ENUM_SINGLE_DECL(treble_cutoff, WM8955_TREBLE_CONTROL, 2, +static SOC_ENUM_SINGLE_DECL(treble_cutoff, WM8955_TREBLE_CONTROL, 6, treble_cutoff_text); static const DECLARE_TLV_DB_SCALE(digital_tlv, -12750, 50, 1);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1922/2214 ASoC: codecs: wm_hubs: Fix definition of MIXINR to MIXOUTR volume control
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit 22bfcedd3febd6acc63ecf8bfd9638210e4b9a5e ]
The Right Output Mixer Right Input Volume (MIXINR_MIXOUTR_VOL) is at bits 2:0 of Output Mixer6, not at bits 8:6, which hold the IN2LN volume (IN2LN_MIXOUTR_VOL).
--- sound/soc/codecs/wm_hubs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/wm_hubs.c +1 -1
@@ -426,7 +426,7 @@ SOC_SINGLE_TLV("Right Output Mixer IN2RP Volume",SOC_SINGLE_TLV ("Right Output Mixer Left Input Volume" ,WM8993_OUTPUT_MIXER6 ,3 ,7 ,1 , outmix_tlv),SOC_SINGLE_TLV ("Right Output Mixer Right Input Volume" , -WM8993_OUTPUT_MIXER6 ,6 ,7 ,1 , outmix_tlv), +WM8993_OUTPUT_MIXER6 ,0 ,7 ,1 , outmix_tlv),SOC_SINGLE_TLV ("Right Output Mixer DAC Volume" , WM8993_OUTPUT_MIXER6, 9, 7, 1, outmix_tlv),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1923/2214 ASoC: codecs: wm8737: Fix definition of zero cross switches
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit 121963197200ca89050f05a704f53c281702ec16 ]
The mic (xMZC) and PGA (xPZC) zero cross bits are bits 3 and 2 of each channel's Audio Path register. SOC_DOUBLE takes one register and two shifts, so both controls only write the left register. Use SOC_DOUBLE_R, as the Mic Boost Switch next to them does.
--- sound/soc/codecs/wm8737.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
sound/soc/codecs/wm8737.c +4 -4
@@ -149,13 +149,13 @@ SOC_DOUBLE_R_TLV("Mic Boost Volume", WM8737_AUDIO_PATH_L, WM8737_AUDIO_PATH_R, 6, 3, 0, micboost_tlv),SOC_DOUBLE_R ("Mic Boost Switch" ,WM8737_AUDIO_PATH_L ,WM8737_AUDIO_PATH_R ,4 ,1 ,0 ), -SOC_DOUBLE ("Mic ZC Switch" ,WM8737_AUDIO_PATH_L ,WM8737_AUDIO_PATH_R , -3 ,1 ,0 ), +SOC_DOUBLE_R ("Mic ZC Switch" ,WM8737_AUDIO_PATH_L ,WM8737_AUDIO_PATH_R , +3 ,1 ,0 ),SOC_DOUBLE_R_TLV ("Capture Volume" ,WM8737_LEFT_PGA_VOLUME ,WM8737_RIGHT_PGA_VOLUME ,0 ,255 ,0 , pga_tlv), -SOC_DOUBLE ("Capture ZC Switch" ,WM8737_AUDIO_PATH_L ,WM8737_AUDIO_PATH_R , -2 ,1 ,0 ), +SOC_DOUBLE_R ("Capture ZC Switch" ,WM8737_AUDIO_PATH_L ,WM8737_AUDIO_PATH_R , +2 ,1 ,0 ), SOC_DOUBLE("INPUT1 DC Bias Switch", WM8737_MISC_BIAS_CONTROL, 0, 1, 1, 0),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1924/2214 ASoC: codecs: wm5100: Fix definition of EQ3 Band 1 Volume control
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit 96d30816a9a4fa6b3cc470f82d0f53e8a6425ab9 ]
The EQ3 band 1 gain is in WM5100_EQ3_1, not in WM5100_EQ1_1, which holds the EQ1 band 1 gain.
--- sound/soc/codecs/wm5100.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/wm5100.c +1 -1
@@ -655,7 +655,7 @@ SOC_SINGLE_TLV("EQ2 Band 4 Volume", WM5100_EQ2_2, WM5100_EQ2_B4_GAIN_SHIFT,SOC_SINGLE_TLV ("EQ2 Band 5 Volume" ,WM5100_EQ2_2 ,WM5100_EQ2_B5_GAIN_SHIFT ,24 ,0 , eq_tlv), -SOC_SINGLE_TLV ("EQ3 Band 1 Volume" ,WM5100_EQ1_1 ,WM5100_EQ3_B1_GAIN_SHIFT , +SOC_SINGLE_TLV ("EQ3 Band 1 Volume" ,WM5100_EQ3_1 ,WM5100_EQ3_B1_GAIN_SHIFT ,24 ,0 , eq_tlv),SOC_SINGLE_TLV ("EQ3 Band 2 Volume" ,WM5100_EQ3_1 ,WM5100_EQ3_B2_GAIN_SHIFT , 24, 0, eq_tlv),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1925/2214 ASoC: codecs: wm8750: Fix definition of ALC Capture NG Type control
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit 8c299077c787c151c5c88928467d8e8d85cebdb7 ]
The noise gate type is wm8750_enum[7], bit 1 of WM8750_NGATE, not wm8750_enum[4], which is the 3D upper cut-off.
--- sound/soc/codecs/wm8750.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/wm8750.c +1 -1
@@ -171,7 +171,7 @@ SOC_SINGLE("ALC Capture Hold Time", WM8750_ALC2, 0, 15, 0),SOC_SINGLE ("ALC Capture Decay Time" ,WM8750_ALC3 ,4 ,15 ,0 ),SOC_SINGLE ("ALC Capture Attack Time" ,WM8750_ALC3 ,0 ,15 ,0 ),SOC_SINGLE ("ALC Capture NG Threshold" ,WM8750_NGATE ,3 ,31 ,0 ), -SOC_ENUM ("ALC Capture NG Type" , wm8750_enum[4 ]), +SOC_ENUM ("ALC Capture NG Type" , wm8750_enum[7 ]),SOC_SINGLE ("ALC Capture NG Switch" ,WM8750_NGATE ,0 ,1 ,0 ), SOC_SINGLE("Left ADC Capture Volume", WM8750_LADC, 0, 255, 0),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1926/2214 ASoC: codecs: wm8510: Fix definition of ADC Inversion Switch control
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit 22d50113078dfbeff0d005d64fd9cc680249831c ]
ADC polarity is bit 0 of WM8510_ADC, not bit 0 of WM8510_COMP, which is the loopback enable. wm8974, which has the same register layout, already uses WM8974_ADC for this control.
--- sound/soc/codecs/wm8510.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/wm8510.c +1 -1
@@ -135,7 +135,7 @@ SOC_SINGLE("Master Playback Volume", WM8510_DACVOL, 0, 127, 0),SOC_SINGLE ("High Pass Filter Switch" ,WM8510_ADC ,8 ,1 ,0 ),SOC_SINGLE ("High Pass Cut Off" ,WM8510_ADC ,4 ,7 ,0 ), -SOC_SINGLE ("ADC Inversion Switch" ,WM8510_COMP ,0 ,1 ,0 ), +SOC_SINGLE ("ADC Inversion Switch" ,WM8510_ADC ,0 ,1 ,0 ), SOC_SINGLE("Capture Volume", WM8510_ADCVOL, 0, 127, 0),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1927/2214 rpmsg: mtk: release channel OF node on device teardown
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Avi Weiss <[email protected]>
[ Upstream commit 00e100cfbf7bc159e462df16832cddeaf2cab770 ]
mtk_rpmsg_match_device_subnode() returns a referenced OF child node, which is stored in rpdev->dev.of_node.
mtk_rpmsg_release_device() later frees the containing allocation without dropping that ref.
Release the OF node when the RPMsg device is destroyed.
--- drivers/rpmsg/mtk_rpmsg.c | 1 + 1 file changed, 1 insertion(+)
drivers/rpmsg/mtk_rpmsg.c +1 -0
@@ -168,6 +168,7 @@ static void mtk_rpmsg_release_device(struct device *dev)struct rpmsg_device *rpdev =to_rpmsg_device (dev);struct mtk_rpmsg_device *mdev =to_mtk_rpmsg_device (rpdev); +of_node_put (dev->of_node);kfree (mdev); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1928/2214 rpmsg: core: add API to get MTU
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnaud Pouliquen <[email protected]>
[ Upstream commit e279317e9aeb11d8670e0a5acb10d50566eea9c9 ]
Return the rpmsg buffer MTU for sending message, so rpmsg users can split a long message in several sub rpmsg buffers.
Stable-dep-of: 7dd4cffdf4c2 ("rpmsg: virtio: fix error handling in TX buffer wait")
--- drivers/rpmsg/rpmsg_core.c | 21 +++++++++++++++++++++ drivers/rpmsg/rpmsg_internal.h | 2 ++ drivers/rpmsg/virtio_rpmsg_bus.c | 10 ++++++++++ include/linux/rpmsg.h | 10 ++++++++++ 4 files changed, 43 insertions(+)
drivers/rpmsg/rpmsg_core.c +21 -0
@@ -327,6 +327,27 @@ int rpmsg_trysend_offchannel(struct rpmsg_endpoint *ept, u32 src, u32 dst, }EXPORT_SYMBOL (rpmsg_trysend_offchannel); +/** +* rpmsg_get_mtu() - get maximum transmission buffer size for sending message. +* @ept: the rpmsg endpoint +* +* This function returns maximum buffer size available for a single outgoing message. +* +* Return: the maximum transmission size on success and an appropriate error +* value on failure. +*/ + +ssize_t rpmsg_get_mtu (struct rpmsg_endpoint *ept) +{ +if (WARN_ON (!ept)) +return -EINVAL ; +if (!ept->ops->get_mtu) +return -ENOTSUPP ; + +return ept->ops->get_mtu (ept); +} +EXPORT_SYMBOL (rpmsg_get_mtu); +/* * match a rpmsg channel with a channel info struct. * this is used to make sure we're not creating rpmsg devices for channels
drivers/rpmsg/rpmsg_internal.h +2 -0
@@ -53,6 +53,7 @@ struct rpmsg_device_ops {* @trysendto: see @rpmsg_trysendto(), optional * @trysend_offchannel: see @rpmsg_trysend_offchannel(), optional * @poll: see @rpmsg_poll(), optional +* @get_mtu: see @rpmsg_get_mtu(), optional * * Indirection table for the operations that a rpmsg backend should implement. * In addition to @destroy_ept, the backend must at least implement @send and
@@ -72,6 +73,7 @@ struct rpmsg_endpoint_ops { void *data, int len);__poll_t (*poll)(struct rpmsg_endpoint *ept,struct file *filp,poll_table *wait); +ssize_t (*get_mtu)(struct rpmsg_endpoint *ept); }; struct device *rpmsg_find_device(struct device *parent,
drivers/rpmsg/virtio_rpmsg_bus.c +10 -0
@@ -149,6 +149,7 @@ static int virtio_rpmsg_trysendto(struct rpmsg_endpoint *ept, void *data, int len, u32 dst);static int virtio_rpmsg_trysend_offchannel (struct rpmsg_endpoint *ept,u32 src,u32 dst,void *data,int len); +static ssize_t virtio_rpmsg_get_mtu (struct rpmsg_endpoint *ept);static struct rpmsg_device *__rpmsg_create_channel (struct virtproc_info *vrp,struct rpmsg_channel_info *chinfo);
@@ -160,6 +161,7 @@ static const struct rpmsg_endpoint_ops virtio_endpoint_ops = { .trysend = virtio_rpmsg_trysend, .trysendto = virtio_rpmsg_trysendto, .trysend_offchannel = virtio_rpmsg_trysend_offchannel, + .get_mtu = virtio_rpmsg_get_mtu, };/**
@@ -697,6 +699,14 @@ static int virtio_rpmsg_trysend_offchannel(struct rpmsg_endpoint *ept, u32 src,return rpmsg_send_offchannel_raw (rpdev, src, dst, data, len, false); } +static ssize_t virtio_rpmsg_get_mtu (struct rpmsg_endpoint *ept) +{ +struct rpmsg_device *rpdev = ept->rpdev; +struct virtio_rpmsg_channel *vch =to_virtio_rpmsg_channel (rpdev); + +return vch->vrp->buf_size -sizeof (struct rpmsg_hdr ); +} +static int rpmsg_recv_single (struct virtproc_info *vrp,struct device *dev,struct rpmsg_hdr *msg,unsigned int len) {
include/linux/rpmsg.h +10 -0
@@ -190,6 +190,8 @@ int rpmsg_trysend_offchannel(struct rpmsg_endpoint *ept, u32 src, u32 dst,__poll_t rpmsg_poll (struct rpmsg_endpoint *ept,struct file *filp,poll_table *wait); +ssize_t rpmsg_get_mtu (struct rpmsg_endpoint *ept); +#else static inline int rpmsg_register_device_override(struct rpmsg_device *rpdev,
@@ -306,6 +308,14 @@ static inline __poll_t rpmsg_poll(struct rpmsg_endpoint *ept, return 0; } +static inline ssize_t rpmsg_get_mtu (struct rpmsg_endpoint *ept) +{ +/* This shouldn't be possible */ +WARN_ON (1 ); + +return -ENXIO ; +} +#endif /* IS_ENABLED(CONFIG_RPMSG) */ /* use a macro to avoid include chaining to get THIS_MODULE */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1929/2214 rpmsg: virtio: Remove uncallable offchannel functions
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dr. David Alan Gilbert <[email protected]>
[ Upstream commit 68decaf24d4d24f4f8708a248e65e9d77ea19b85 ]
The virtio_rpmsg_send_offchannel() and virtio_rpmsg_trysend_offchannel() are wired up to the send_offchannel and trysend_offchannel members of rpmsg_endpoint_ops, the only dereference of those was by the unused, and now removed rpmsg_send_offchannel() and rpmsg_trysend_offchannel() functions.
Remove them.
Stable-dep-of: 7dd4cffdf4c2 ("rpmsg: virtio: fix error handling in TX buffer wait")
--- drivers/rpmsg/virtio_rpmsg_bus.c | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-)
drivers/rpmsg/virtio_rpmsg_bus.c +1 -23
@@ -142,13 +142,9 @@ static void virtio_rpmsg_destroy_ept(struct rpmsg_endpoint *ept);static int virtio_rpmsg_send (struct rpmsg_endpoint *ept,void *data,int len);static int virtio_rpmsg_sendto (struct rpmsg_endpoint *ept,void *data,int len,u32 dst); -static int virtio_rpmsg_send_offchannel (struct rpmsg_endpoint *ept,u32 src, -u32 dst,void *data,int len);static int virtio_rpmsg_trysend (struct rpmsg_endpoint *ept,void *data,int len);static int virtio_rpmsg_trysendto (struct rpmsg_endpoint *ept,void *data,int len,u32 dst); -static int virtio_rpmsg_trysend_offchannel (struct rpmsg_endpoint *ept,u32 src, -u32 dst,void *data,int len);static ssize_t virtio_rpmsg_get_mtu (struct rpmsg_endpoint *ept);static struct rpmsg_device *__rpmsg_create_channel (struct virtproc_info *vrp,struct rpmsg_channel_info *chinfo);
@@ -157,10 +153,8 @@ static const struct rpmsg_endpoint_ops virtio_endpoint_ops = { .destroy_ept = virtio_rpmsg_destroy_ept, .send = virtio_rpmsg_send, .sendto = virtio_rpmsg_sendto, - .send_offchannel = virtio_rpmsg_send_offchannel, .trysend = virtio_rpmsg_trysend, .trysendto = virtio_rpmsg_trysendto, - .trysend_offchannel = virtio_rpmsg_trysend_offchannel, .get_mtu = virtio_rpmsg_get_mtu, };
@@ -546,7 +540,7 @@ static void rpmsg_downref_sleepers(struct virtproc_info *vrp)* the function will immediately fail, and -ENOMEM will be returned. * * Normally drivers shouldn't use this function directly; instead, drivers -* should use the appropriate rpmsg_{try}send{to, _offchannel} API +* should use the appropriate rpmsg_{try}send{to} API * (see include/linux/rpmsg.h). * * Returns 0 on success and an appropriate error value on failure.
@@ -666,14 +660,6 @@ static int virtio_rpmsg_sendto(struct rpmsg_endpoint *ept, void *data, int len,return rpmsg_send_offchannel_raw (rpdev, src, dst, data, len, true); } -static int virtio_rpmsg_send_offchannel (struct rpmsg_endpoint *ept,u32 src, -u32 dst,void *data,int len) -{ -struct rpmsg_device *rpdev = ept->rpdev; - -return rpmsg_send_offchannel_raw (rpdev, src, dst, data, len, true); -} -static int virtio_rpmsg_trysend (struct rpmsg_endpoint *ept,void *data,int len) {struct rpmsg_device *rpdev = ept->rpdev;
@@ -691,14 +677,6 @@ static int virtio_rpmsg_trysendto(struct rpmsg_endpoint *ept, void *data,return rpmsg_send_offchannel_raw (rpdev, src, dst, data, len, false); } -static int virtio_rpmsg_trysend_offchannel (struct rpmsg_endpoint *ept,u32 src, -u32 dst,void *data,int len) -{ -struct rpmsg_device *rpdev = ept->rpdev; - -return rpmsg_send_offchannel_raw (rpdev, src, dst, data, len, false); -} -static ssize_t virtio_rpmsg_get_mtu (struct rpmsg_endpoint *ept) {struct rpmsg_device *rpdev = ept->rpdev;
Signature · 1 line
2.53.0