6.18.65-rc1 review
Greg Kroah-Hartman
maintainerPATCH 1468/2151 ASoC: mediatek: mt8365: Fix out-of-bounds read in get_iir_coef()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Priyanka Mani <[email protected]>
[ Upstream commit e913917febd31998e3d0b9e8c861e538a6185045 ]
get_iir_coef() looks up a resampling coefficient set by reading an index "k" from iir_coef_tbl_matrix[][] and using it to index iir_coef_tbl_list[], which has 8 entries (valid indices 0..7).
Before the lookup, "k" is only rejected when it is >= IIR_NO_NEED (11), or equal to IIR_RATIOVER (9) or IIR_INV_COEF (10). The value 8 is neither a sentinel nor a valid table index, so it falls through to the else branch and iir_coef_tbl_list[8] is read one element past the end of the array. The bogus coef pointer and count are then returned to mt8365_dai_set_config(), which dereferences coef.
The current matrix never produces 8, so this cannot be triggered today, but the bounds check is wrong: it relies on the matrix contents instead of the size of the array it guards. Bound the lookup with the actual array size so only valid indices reach the table.
This was found by Smatch:
sound/soc/mediatek/mt8365/mt8365-dai-i2s.c:271 get_iir_coef()
error: buffer overflow 'iir_coef_tbl_list' 8 <= 8
--- sound/soc/mediatek/mt8365/mt8365-dai-i2s.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/mediatek/mt8365/mt8365-dai-i2s.c +1 -1
@@ -267,7 +267,7 @@ static const u32 *get_iir_coef(unsigned int input_fs,if (k >=IIR_NO_NEED ) { }else if (k ==IIR_RATIOVER ) { }else if (k ==IIR_INV_COEF ) { - }else { + }else if (k <ARRAY_SIZE (iir_coef_tbl_list)) { coef = iir_coef_tbl_list[k].coef; cnt = iir_coef_tbl_list[k].cnt; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1469/2151 ASoC: codecs: wcd937x: request watchdog IRQs without devm
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Runyu Xiao <[email protected]>
[ Upstream commit b3f17433a1eb9f89b79f8459d7661207abce0b9c ]
The watchdog IRQs are requested from the codec component probe and released from its remove callback. Use the same non-devm lifetime for both operations.
Use request_threaded_irq() and keep free_irq() in the component remove callback. Return errors from each request and unwind only IRQs that were successfully requested, including failures later in component probe.
--- sound/soc/codecs/wcd937x.c | 44 +++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 17 deletions(-)
sound/soc/codecs/wcd937x.c +27 -17
@@ -2524,23 +2524,23 @@ static int wcd937x_soc_codec_probe(struct snd_soc_component *component) WCD937X_IRQ_AUX_PDM_WD_INT);/* Request for watchdog interrupt */ - ret =devm_request_threaded_irq (dev, wcd937x->hphr_pdm_wd_int,NULL , wcd937x_wd_handle_irq, -IRQF_ONESHOT |IRQF_TRIGGER_RISING , -"HPHR PDM WDOG INT" , wcd937x); + ret =request_threaded_irq (wcd937x->hphr_pdm_wd_int,NULL , wcd937x_wd_handle_irq, +IRQF_ONESHOT |IRQF_TRIGGER_RISING , +"HPHR PDM WDOG INT" , wcd937x);if (ret) -dev_err (dev,"Failed to request HPHR watchdog interrupt (%d)\n" , ret); + goto err_free_clsh; - ret =devm_request_threaded_irq (dev, wcd937x->hphl_pdm_wd_int,NULL , wcd937x_wd_handle_irq, -IRQF_ONESHOT |IRQF_TRIGGER_RISING , -"HPHL PDM WDOG INT" , wcd937x); + ret =request_threaded_irq (wcd937x->hphl_pdm_wd_int,NULL , wcd937x_wd_handle_irq, +IRQF_ONESHOT |IRQF_TRIGGER_RISING , +"HPHL PDM WDOG INT" , wcd937x);if (ret) -dev_err (dev,"Failed to request HPHL watchdog interrupt (%d)\n" , ret); + goto err_free_hphr_irq; - ret =devm_request_threaded_irq (dev, wcd937x->aux_pdm_wd_int,NULL , wcd937x_wd_handle_irq, -IRQF_ONESHOT |IRQF_TRIGGER_RISING , -"AUX PDM WDOG INT" , wcd937x); + ret =request_threaded_irq (wcd937x->aux_pdm_wd_int,NULL , wcd937x_wd_handle_irq, +IRQF_ONESHOT |IRQF_TRIGGER_RISING , +"AUX PDM WDOG INT" , wcd937x);if (ret) -dev_err (dev,"Failed to request Aux watchdog interrupt (%d)\n" , ret); + goto err_free_hphl_irq;/* Disable watchdog interrupt for HPH and AUX */ disable_irq_nosync (wcd937x->hphr_pdm_wd_int);
@@ -2552,23 +2552,33 @@ static int wcd937x_soc_codec_probe(struct snd_soc_component *component) ARRAY_SIZE(wcd9375_dapm_widgets));if (ret <0 ) {dev_err (component->dev,"Failed to add snd_ctls\n" ); -wcd_clsh_ctrl_free (wcd937x->clsh_info); -return ret; + goto err_free_irqs; } ret =snd_soc_dapm_add_routes (dapm, wcd9375_audio_map,ARRAY_SIZE (wcd9375_audio_map));if (ret <0 ) {dev_err (component->dev,"Failed to add routes\n" ); -wcd_clsh_ctrl_free (wcd937x->clsh_info); -return ret; + goto err_free_irqs; } } ret =wcd937x_mbhc_init (component); -if (ret) +if (ret) {dev_err (component->dev,"mbhc initialization failed\n" ); + goto err_free_irqs; + } + +return ret; +err_free_irqs: +free_irq (wcd937x->aux_pdm_wd_int, wcd937x); +err_free_hphl_irq: +free_irq (wcd937x->hphl_pdm_wd_int, wcd937x); +err_free_hphr_irq: +free_irq (wcd937x->hphr_pdm_wd_int, wcd937x); +err_free_clsh: +wcd_clsh_ctrl_free (wcd937x->clsh_info);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1470/2151 spi: meson-spicc: fix invalid DMA unmap on mapping failure
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hongjian Dai <[email protected]>
[ Upstream commit 9d71f9fe5b5de916bded51343138b09b1eb103ed ]
meson_spicc_dma_unmap() decided whether a buffer had to be unmapped by testing its DMA address for non-zero. On a mapping failure dma_map_single() returns DMA_MAPPING_ERROR (typically non-zero), so the error path in meson_spicc_transfer_one() passed that error value to dma_unmap_single(), unmapping an address which was never mapped. The same happened for t->rx_dma on TX mapping failure, which is not written at all.
Initialize both addresses to DMA_MAPPING_ERROR before mapping and use dma_mapping_error() to decide, so only buffers which were actually mapped are unmapped.
--- drivers/spi/spi-meson-spicc.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/spi/spi-meson-spicc.c +9 -2
@@ -235,6 +235,13 @@ static int meson_spicc_dma_map(struct meson_spicc_device *spicc, {struct device *dev = spicc->host->dev.parent; +/* +* Mark the DMA addresses as invalid so that meson_spicc_dma_unmap() +* will not try to unmap a buffer which was not (successfully) mapped. +*/ + t->tx_dma =DMA_MAPPING_ERROR ; + t->rx_dma =DMA_MAPPING_ERROR ; +if (!(t->tx_buf && t->rx_buf))return -EINVAL ;
@@ -257,9 +264,9 @@ static void meson_spicc_dma_unmap(struct meson_spicc_device *spicc, {struct device *dev = spicc->host->dev.parent; -if (t->tx_dma) +if (!dma_mapping_error (dev, t->tx_dma))dma_unmap_single (dev, t->tx_dma, t->len,DMA_TO_DEVICE ); -if (t->rx_dma) +if (!dma_mapping_error (dev, t->rx_dma))dma_unmap_single (dev, t->rx_dma, t->len,DMA_FROM_DEVICE ); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1471/2151 scsi: scsi_debug: Fix a locking bug in resp_write_same()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bart Van Assche <[email protected]>
[ Upstream commit 2f50ca3d46b4d5916874ba19612498c0a9c1f5f9 ]
If fetch_to_dev_buffer() fails in resp_write_same(), the function jumps to 'out' without releasing the data write lock acquired earlier via sdeb_data_write_lock(). Jump to 'unlock' instead so that sdeb_data_write_unlock() is called on the error path. This bug has been discovered by building the scsi_debug driver with Clang and modified lock context annotations. The modified lock context annotations are available in patch "scsi: scsi_debug: Improve lock context annotations".
--- drivers/scsi/scsi_debug.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/scsi/scsi_debug.c +3 -2
@@ -5286,7 +5286,7 @@ static int resp_write_same(struct scsi_cmnd *scp, u64 lba, u32 num,if (-1 == ret) { ret =DID_ERROR <<16 ; - goto out; + goto unlock; }else if (sdebug_verbose && !ndob && (ret < lb_size)) sdev_printk(KERN_INFO, scp->device, "%s: %s: lb size=%u, IO sent=%d bytes\n",
@@ -5303,8 +5303,9 @@ static int resp_write_same(struct scsi_cmnd *scp, u64 lba, u32 num,/* If ZBC zone then bump its write pointer */ if (sdebug_dev_is_zoned (devip))zbc_inc_wp (devip, lba, num); -sdeb_data_write_unlock (sip); ret =0 ; +unlock: +sdeb_data_write_unlock (sip); out:if (meta_data_locked)sdeb_meta_write_unlock (sip);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1472/2151 lib: validate in-memory LZ4 chunk length
In reply to Greg Kroah-Hartman6.18-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 1473/2151 ocfs2: retain all security xattrs during inode creation
In reply to Greg Kroah-Hartman6.18-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
@@ -247,7 +247,6 @@ static int ocfs2_mknod(struct mnt_idmap *idmap,int want_meta =0 ;int xattr_credits =0 ;struct ocfs2_security_xattr_info si = { - .name =NULL , .enable =1 , };int did_quota_inode =0 ;
@@ -474,7 +473,7 @@ static int ocfs2_mknod(struct mnt_idmap *idmap,brelse (new_fe_bh);brelse (parent_fe_bh); -kfree (si.value); +ocfs2_free_security_xattrs (&si);ocfs2_acl_init_release (&acl_state);
@@ -1829,7 +1828,6 @@ static int ocfs2_symlink(struct mnt_idmap *idmap,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 ;
@@ -2061,7 +2059,7 @@ static int ocfs2_symlink(struct mnt_idmap *idmap,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 1474/2151 ocfs2: fix possible deadlock between nfs_sync_rwlock and fs_reclaim
In reply to Greg Kroah-Hartman6.18-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> #include <linux/string_choices.h>
@@ -2854,21 +2855,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 );
@@ -2879,12 +2893,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;
@@ -2895,6 +2914,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
@@ -161,8 +161,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
@@ -1108,6 +1108,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 ;
@@ -1142,7 +1143,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 );
@@ -1214,7 +1215,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 1475/2151 ocfs2: validate chunk and block counts of the local quota file
In reply to Greg Kroah-Hartman6.18-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,
@@ -733,6 +752,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 1476/2151 resource, kunit: stop selecting GET_FREE_REGION
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 7c3f4d699f34535285d0ceb184927d71543d0064 ]
RESOURCE_KUNIT_TEST selects GET_FREE_REGION even when no other option needs it. Remove the selection to follow the dependency rule in Documentation/dev-tools/kunit/style.rst.
Skip resource_test_region_intersects() when GET_FREE_REGION is disabled. GET_FREE_REGION has no prompt, so configurations without a production consumer cannot enable it. Most configurations will therefore skip this case; this is intentional. The union and intersection tests remain available.
Since kunit_skip() does not return, the compiler drops the reference to the unavailable alloc_free_mem_region(), as in the CONFIG_OF_ADDRESS check in drivers/of/of_test.c.
--- kernel/resource_kunit.c | 3 +++ lib/Kconfig.debug | 1 - 2 files changed, 3 insertions(+), 1 deletion(-)
kernel/resource_kunit.c +3 -0
@@ -225,6 +225,9 @@ static void resource_test_region_intersects(struct kunit *test)struct resource *parent;resource_size_t start; +if (!IS_ENABLED (CONFIG_GET_FREE_REGION )) +kunit_skip (test,"CONFIG_GET_FREE_REGION is disabled" ); +/* Find an iomem_resource hole to hold test resources */ parent =alloc_free_mem_region (&iomem_resource,RES_TEST_TOTAL_SIZE ,SZ_1M ,"test resources" );
lib/Kconfig.debug +0 -1
@@ -2698,7 +2698,6 @@ config RESOURCE_KUNIT_TEST tristate "KUnit test for resource API" if !KUNIT_ALL_TESTS depends on KUNIT default KUNIT_ALL_TESTS - select GET_FREE_REGION help This builds the resource API unit test. Tests the logic of API provided by resource.c and ioport.h.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1477/2151 kcov: report spurious PCs in the interrupt selftest
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 5d9f31ed855fa89e533b222d0365da81ad3b10cc ]
The KCOV interrupt selftest enables KCOV_MODE_TRACE_PC without a coverage area so that spurious coverage causes a fault. If the fault path is instrumented, the coverage callback faults recursively. Observed failure modes include a stack overflow on x86_64 and arm32 getting stuck in abort handling, neither of which identifies the original coverage event.
The recursive failure is not new, but commit 9a79524d1420 ("kcov: use WRITE_ONCE() for selftest mode stores") made the selftest effective on configurations where the compiler had previously removed the mode store, exposing it more broadly.
Replace the open-coded kcov_mode stores with kcov_start() and kcov_stop(), passing a 16-word buffer that records up to 15 spurious PCs, with the first word holding the count. Keep KCOV enabled for the original 300 ms window, then disable it, print all recorded PCs and panic if any were recorded. Once the buffer fills, further PCs are discarded by the existing coverage callback. This preserves the selftest's hard failure while avoiding the recursive fault path.
Add decanonicalize_ip() as the inverse of canonicalize_ip(), which subtracts kaslr_offset() from recorded PCs. Restore that offset before printing the PCs with %pB, since KCOV records return addresses.
--- kernel/kcov.c | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-)
kernel/kcov.c +29 -6
@@ -198,6 +198,16 @@ static notrace unsigned long canonicalize_ip(unsigned long ip)return ip; } +#ifdef CONFIG_KCOV_SELFTEST +static unsigned long __init decanonicalize_ip (unsigned long ip) +{ +#ifdef CONFIG_RANDOMIZE_BASE + ip +=kaslr_offset (); +#endif +return ip; +} +#endif +/* * Entry point from instrumented code. * This is called once per basic-block/edge.
@@ -1083,9 +1093,11 @@ u64 kcov_common_handle(void)EXPORT_SYMBOL (kcov_common_handle);#ifdef CONFIG_KCOV_SELFTEST +static unsigned long selftest_area[16 ]__initdata ; +static void __init selftest (void ) { -unsigned long start; +unsigned long start, i, ip, count;pr_err ("running self test\n" );/*
@@ -1095,15 +1107,26 @@ static void __init selftest(void)* leaks out of that section and leads to spurious coverage. * It's hard to call the actual interrupt handler directly, * so we just loop here for a bit waiting for a timer interrupt. -* We set kcov_mode to enable tracing, but don't setup the area, -* so any attempt to trace will crash. Note: we must not call any +* A small coverage area records the PCs of any leaks. The first word +* holds the count, leaving room for 15 PCs. Note: we must not call any * potentially traced functions in this region. */ +kcov_start (current,NULL ,ARRAY_SIZE (selftest_area), + selftest_area,KCOV_MODE_TRACE_PC ,0 ); start = jiffies; -WRITE_ONCE (current->kcov_mode,KCOV_MODE_TRACE_PC );while ((jiffies - start) *MSEC_PER_SEC /HZ <300 ) - ; -WRITE_ONCE (current->kcov_mode,0 ); +cpu_relax (); +kcov_stop (current); + + count =READ_ONCE (selftest_area[0 ]); +if (count) { +pr_err ("spurious coverage detected during interrupt selftest:\n" ); +for (i =1 ; i <= count; i++) { + ip =decanonicalize_ip (selftest_area[i]); +pr_err (" %pB\n" , (void *)ip); + } +panic ("kcov: interrupt selftest detected spurious coverage" ); + } pr_err("done running self test\n"); }#endif
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1478/2151 watchdog/perf: one digit too short in the raw event config copy
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bradley Morgan <[email protected]>
[ Upstream commit b682d597aa273cad6e99e665e0fd2a7eb8aa2cef ]
Commit 6164be01f179 ("watchdog/perf: optimize bytes copied and remove manual NUL-termination") swapped strscpy(buf, str, sizeof(buf)) plus a manual buf[len] = 0 for strscpy(buf, str, len), and that count is one short. strscpy() keeps the last byte of the destination for the NUL, so the config loses its final digit, nmi_watchdog=r300,panic for example ends up with buf = "30" and arms the raw event with the wrong config.
The empty case falls over too, strscpy() with a zero count writes nothing at all, so nmi_watchdog=r,1 leaves buf uninitialized and kstrtoull() reads whatever stack garbage is sitting there.
The old code was safe on both by accident, it filled the whole buffer first and buf[len] = 0 then stomped the comma position, so the worst you got was a truncated parse failure.
Pass len + 1 so the copy includes the character the NUL replaces, and reject len >= sizeof(buf) like it was before the optimization, which also turns an empty config back into a clean parse failure.
--- kernel/watchdog_perf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/watchdog_perf.c +2 -2
@@ -295,10 +295,10 @@ void __init hardlockup_config_perf_event(const char *str) }else {unsigned int len = comma - str; -if (len >sizeof (buf)) +if (len >=sizeof (buf))return ; -strscpy (buf, str, len); +strscpy (buf, str, len +1 );if (kstrtoull (buf,16 , &config))return ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1479/2151 ALSA: pcm: Fix driver_tstamp value reporting
In reply to Greg Kroah-Hartman6.18-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
@@ -1173,8 +1173,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 1480/2151 ALSA: jack: Fix kctl free at error in snd_jack_kctl_new()
In reply to Greg Kroah-Hartman6.18-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
@@ -456,7 +456,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 1481/2151 ALSA: pcm: Protect delay DMA sync in forward and rewind, too
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit d5096bb9beacb448091c1c9541432021dd5c1fcd ]
Like the previous fix for snd_pcm_delay() (in the commit 50f413b83b31 "ALSA: pcm: Protect delay DMA sync against concurrent HW_FREE"), the snd_pcm_dma_buffer_sync() call in snd_pcm_forward() and snd_pcm_rewind() needs the similar protection against the concurrent hw_free action for avoiding potential UAFs.
--- sound/core/pcm_native.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
sound/core/pcm_native.c +10 -0
@@ -3037,11 +3037,15 @@ static snd_pcm_sframes_t rewind_appl_ptr(struct snd_pcm_substream *substream,static snd_pcm_sframes_t snd_pcm_rewind (struct snd_pcm_substream *substream,snd_pcm_uframes_t frames) { +struct snd_pcm_runtime *runtime = substream->runtime;snd_pcm_sframes_t ret;if (frames ==0 )return 0 ; +/* Keep the DMA buffer alive through the sync below. */ +if (!atomic_inc_unless_negative (&runtime->buffer_accessing)) +return -EBUSY ; scoped_guard(pcm_stream_lock_irq, substream) { ret =do_pcm_hwsync (substream);if (!ret)
@@ -3050,17 +3054,22 @@ static snd_pcm_sframes_t snd_pcm_rewind(struct snd_pcm_substream *substream, }if (ret >=0 )snd_pcm_dma_buffer_sync (substream,SNDRV_DMA_SYNC_DEVICE ); +atomic_dec (&runtime->buffer_accessing);return ret; }static snd_pcm_sframes_t snd_pcm_forward (struct snd_pcm_substream *substream,snd_pcm_uframes_t frames) { +struct snd_pcm_runtime *runtime = substream->runtime;snd_pcm_sframes_t ret;if (frames ==0 )return 0 ; +/* Keep the DMA buffer alive through the sync below. */ +if (!atomic_inc_unless_negative (&runtime->buffer_accessing)) +return -EBUSY ; scoped_guard(pcm_stream_lock_irq, substream) { ret =do_pcm_hwsync (substream);if (!ret)
@@ -3069,6 +3078,7 @@ static snd_pcm_sframes_t snd_pcm_forward(struct snd_pcm_substream *substream, }if (ret >=0 )snd_pcm_dma_buffer_sync (substream,SNDRV_DMA_SYNC_DEVICE ); +atomic_dec (&runtime->buffer_accessing);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1482/2151 ALSA: line6: Use kzalloc() for PCM buffer allocation
In reply to Greg Kroah-Hartman6.18-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 1483/2151 ALSA: vmaster: Serialize hook registration with control callbacks
In reply to Greg Kroah-Hartman6.18-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/hda/common/codec.c | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-)
include/sound/control.h +1 -1
@@ -286,7 +286,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
@@ -464,6 +464,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
@@ -471,13 +472,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/hda/common/codec.c +1 -1
@@ -2029,7 +2029,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 1484/2151 ALSA: usb-audio: Use fixed control index for us16x08 mixer elements
In reply to Greg Kroah-Hartman6.18-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
@@ -572,20 +572,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
@@ -110,10 +110,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
@@ -166,7 +166,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
@@ -1127,7 +1127,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 1485/2151 thermal/drivers/sprd: validate the sensor id from the device tree
In reply to Greg Kroah-Hartman6.18-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
@@ -396,6 +396,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 1486/2151 tools/thermal/tmon: Fix string truncation warning in optarg copy
In reply to Greg Kroah-Hartman6.18-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 1487/2151 thermal: ti-soc-thermal: Fix the return value in ti_bandgap_get_sensor_data() kernel-doc
In reply to Greg Kroah-Hartman6.18-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 1488/2151 thermal/drivers/rzg3e: Propagate reset assertion failure from suspend
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit 2dc1f296b5754dd2441fc8b6613a362a47f6b98f ]
rzg3e_thermal_suspend() powers off an active sensor and then ignores failure to assert its reset. System sleep can therefore continue without the clean reset state expected by resume.
Return the reset error and, when the sensor had been active, try to restore power before failing suspend. This is best-effort recovery:
reset assertion failure may leave partial hardware state, so restoring power is not guaranteed to succeed. Preserve the original reset error.
The issue was found by our static-analysis tool and manually reviewed.
--- drivers/thermal/renesas/rzg3e_thermal.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/thermal/renesas/rzg3e_thermal.c +7 -3
@@ -501,15 +501,19 @@ static int rzg3e_thermal_runtime_resume(struct device *dev)static int rzg3e_thermal_suspend (struct device *dev) {struct rzg3e_thermal_priv *priv =dev_get_drvdata (dev); +bool active =pm_runtime_active (dev); +int ret;/* If device is active, power it off */ -if (pm_runtime_active (dev)) +if (active)rzg3e_thermal_power_off (priv);/* Assert reset to ensure clean state after resume */ -reset_control_assert (priv->rstc); + ret =reset_control_assert (priv->rstc); +if (ret && active) +rzg3e_thermal_power_on (priv); -return 0 ; +return ret; }static int rzg3e_thermal_resume (struct device *dev)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1489/2151 mm/slab: Mark the kmem_buckets_create() context as a Context: section
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kees Cook <[email protected]>
[ Upstream commit 655668f0caf32a42fef10aaf31137e52f46a0260 ]
kmem_buckets_create() had the same sentence about calling context as kmem_cache_create(), but lacked the "Context:" prefix, so kernel-doc rendered in the body instead of as a "context" section.
Give it the missing prefix. Additionally fix the "a interrupt" typo __kmem_cache_create_args() had.
--- mm/slab_common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
mm/slab_common.c +2 -2
@@ -308,7 +308,7 @@ __kmem_cache_alias(const char *name, unsigned int size, slab_flags_t flags,* &SLAB_TYPESAFE_BY_RCU - Slab page (not individual objects) freeing delayed * by a grace period - see the full description before using. * -* Context: Cannot be called within a interrupt, but can be interrupted. +* Context: Cannot be called within an interrupt, but can be interrupted. * * Return: a pointer to the cache on success, NULL on failure. */
@@ -405,7 +405,7 @@ static struct kmem_cache *kmem_buckets_cache __ro_after_init;* to/from userspace. * @ctor: A constructor for the objects, run when new allocations are made. * -* Cannot be called within an interrupt, but can be interrupted. +* Context: Cannot be called within an interrupt, but can be interrupted. * * Return: a pointer to the cache on success, NULL on failure. When * CONFIG_SLAB_BUCKETS is not enabled, ZERO_SIZE_PTR is returned, and
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1490/2151 module: Fix uninitialized count read of unloaded taint tracking record
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Binbin Deng <[email protected]>
[ Upstream commit 7a5c13cfdfcb1871050fdbe00ac223993f8925fa ]
try_add_tainted_module() allocates the tracking record without zeroing it and initializes the fields in this order:
mod_taint = kmalloc_obj(*mod_taint); strscpy(mod_taint->name, mod->name, MODULE_NAME_LEN); mod_taint->taints = mod->taints; list_add_rcu(&mod_taint->list, &unloaded_tainted_modules); mod_taint->count = 1;
The record is published by list_add_rcu() before the count field is written. The readers, unloaded_tainted_modules_seq_show() (debugfs, under rcu_read_lock()) and print_unloaded_tainted_modules() (panic path, under guard(rcu)), traverse the list under RCU and read mod_taint->count. module_mutex, which the writer holds, does not exclude RCU readers.
A reader that observes the new node between the list_add_rcu() and the count store reads an uninitialized u64 left over from previous slab use. This is a data race and leaks kernel heap residue through the debugfs file and the panic message.
The race window is two adjacent instructions; it is reachable when a tainted module is unloaded (rmmod) concurrently with a read of /sys/kernel/debug/module/unloaded_tainted, or with the module list printout of an oops on another CPU.
Fix this by initializing count before the record is published.
Found during a static-analysis-assisted audit: candidate sites were surfaced by a Coccinelle rule, and the reader/writer paths were confirmed by LLM-assisted (GLM-5.3) code inspection. The issue was not observed at runtime; it is identified by code inspection only.
--- kernel/module/tracking.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/module/tracking.c +1 -1
@@ -38,8 +38,8 @@ int try_add_tainted_module(struct module *mod)return -ENOMEM ;strscpy (mod_taint->name, mod->name,MODULE_NAME_LEN ); mod_taint->taints = mod->taints; -list_add_rcu (&mod_taint->list, &unloaded_tainted_modules); mod_taint->count =1 ; +list_add_rcu (&mod_taint->list, &unloaded_tainted_modules); out:return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1491/2151 wifi: iwlwifi: mvm: move rate conversions to utils.c
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit eade5cacc95c3d8b2e88a694a6a0a42dc0dc1819 ]
These aren't really related to rate scaling, they're just firmware API functions. Try to keep rs.c more for scaling and move these out.
Stable-dep-of: a2f60db1c151 ("wifi: iwlwifi: mvm: fix the VHT MCS sent to a v1 firmware")
--- drivers/net/wireless/intel/iwlwifi/mvm/mvm.h | 5 + drivers/net/wireless/intel/iwlwifi/mvm/rs.c | 164 ------------------ drivers/net/wireless/intel/iwlwifi/mvm/rs.h | 3 - .../net/wireless/intel/iwlwifi/mvm/utils.c | 164 ++++++++++++++++++ 4 files changed, 169 insertions(+), 167 deletions(-)
drivers/net/wireless/intel/iwlwifi/mvm/mvm.h +5 -0
@@ -2894,4 +2894,9 @@ iwl_mvm_send_ap_tx_power_constraint_cmd(struct iwl_mvm *mvm,void iwl_mvm_smps_workaround (struct iwl_mvm *mvm,struct ieee80211_vif *vif,bool update); + +/* rate_n_flags conversion */ +u32 iwl_mvm_v3_rate_from_fw (__le32 rate,u8 rate_ver); +__le32 iwl_mvm_v3_rate_to_fw (u32 rate,u8 rate_ver); +#endif /* __IWL_MVM_H__ */
drivers/net/wireless/intel/iwlwifi/mvm/rs.c +0 -164
167 lines not on this page · raw message
drivers/net/wireless/intel/iwlwifi/mvm/rs.h +0 -3
@@ -425,9 +425,6 @@ void iwl_mvm_rate_control_unregister(void);struct iwl_mvm_sta ; -u32 iwl_mvm_v3_rate_from_fw (__le32 rate,u8 rate_ver); -__le32 iwl_mvm_v3_rate_to_fw (u32 rate,u8 rate_ver); -int iwl_mvm_tx_protection (struct iwl_mvm *mvm,struct iwl_mvm_sta *mvmsta,bool enable);
drivers/net/wireless/intel/iwlwifi/mvm/utils.c +164 -0
167 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1492/2151 wifi: iwlwifi: mvm: fix the VHT MCS sent to a v1 firmware
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Emmanuel Grumbach <[email protected]>
[ Upstream commit a2f60db1c1514c7d083b5c0c8b9510b1adf0cc2c ]
When converting a v3 rate to the v1 format, the MCS index was read from the mask of the NSS field and written into the mask of the MCS field. This is obviously wrong, we must not mix the NSS and the MCS.
--- drivers/net/wireless/intel/iwlwifi/mvm/utils.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/intel/iwlwifi/mvm/utils.c +2 -2
@@ -1372,8 +1372,8 @@ __le32 iwl_mvm_v3_rate_to_fw(u32 rate, u8 rate_ver)case RATE_MCS_MOD_TYPE_VHT : result =RATE_MCS_VHT_MSK_V1 ; result |=u32_encode_bits (u32_get_bits (rate, -RATE_VHT_MCS_NSS_MSK ), -RATE_MCS_CODE_MSK ); +RATE_MCS_CODE_MSK ), +RATE_VHT_MCS_RATE_CODE_MSK ); result |=u32_encode_bits (u32_get_bits (rate,RATE_MCS_NSS_MSK ),RATE_VHT_MCS_NSS_MSK );break ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1493/2151 wifi: iwlwifi: mld: include VI packets in low latency detection
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Endrik Einberg <[email protected]>
[ Upstream commit 3627924ed81fd7783394fb2555ea179c6606a231 ]
iwl_mld_is_vo_vi_pkt() checks whether the mapped access category is less than IEEE80211_AC_VI.
Since mac80211 defines IEEE80211_AC_VO as 0 and IEEE80211_AC_VI as 1, this only matches voice traffic and excludes video traffic.
Synthetic video-priority UDP traffic does not automatically activate low-latency mode, whereas voice-priority traffic does
Include IEEE80211_AC_VI as intended.
--- drivers/net/wireless/intel/iwlwifi/mld/low_latency.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/intel/iwlwifi/mld/low_latency.c +2 -1
@@ -254,7 +254,8 @@ static bool iwl_mld_is_vo_vi_pkt(struct ieee80211_hdr *hdr)if (tid >=IWL_MAX_TID_COUNT )return false; -return tid_to_mac80211_ac[tid] <IEEE80211_AC_VI ; +return tid_to_mac80211_ac[tid] ==IEEE80211_AC_VI || + tid_to_mac80211_ac[tid] ==IEEE80211_AC_VO ; } void iwl_mld_low_latency_update_counters(struct iwl_mld *mld,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1494/2151 ipvs: fix buffer overflow when sending sync messages
In reply to Greg Kroah-Hartman6.18-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 1495/2151 wifi: cfg80211: track SSID regardless of country data
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit 577f690ce5dc641d9d8646d15bb8e99ff4a8280e ]
If the country data cannot be found, the function exits and then doesn't track the SSID. Move the SSID tracking up to fix that.
--- net/wireless/sme.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-)
net/wireless/sme.c +19 -19
@@ -872,6 +872,25 @@ void __cfg80211_connect_result(struct net_device *dev,cfg80211_upload_connect_keys (wdev); +if (!wdev->u.client.ssid_len) { +rcu_read_lock (); +for_each_valid_link (cr, link) { +u32 ssid_len; + + ssid =ieee80211_bss_get_elem (cr->links[link].bss, +WLAN_EID_SSID ); + +if (!ssid || !ssid->datalen) +continue ; + + ssid_len =min (ssid->datalen,IEEE80211_MAX_SSID_LEN ); +memcpy (wdev->u.client.ssid, ssid->data, ssid_len); + wdev->u.client.ssid_len = ssid_len; +break ; + } +rcu_read_unlock (); + } +rcu_read_lock ();for_each_valid_link (cr, link) { country_elem =
@@ -897,25 +916,6 @@ void __cfg80211_connect_result(struct net_device *dev, country_data, country_datalen);kfree (country_data); -if (!wdev->u.client.ssid_len) { -rcu_read_lock (); -for_each_valid_link (cr, link) { -u32 ssid_len; - - ssid =ieee80211_bss_get_elem (cr->links[link].bss, -WLAN_EID_SSID ); - -if (!ssid || !ssid->datalen) -continue ; - - ssid_len =min (ssid->datalen,IEEE80211_MAX_SSID_LEN ); -memcpy (wdev->u.client.ssid, ssid->data, ssid_len); - wdev->u.client.ssid_len = ssid_len; -break ; - } -rcu_read_unlock (); - } -return ; out:for_each_valid_link (cr, link)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1496/2151 arm64: rsi: Correct type of realm_config::hash_algo
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kohei Enju <[email protected]>
[ Upstream commit c83237edf0adb8f8cbd9859841bbca5acc00fc11 ]
The RMM specification (DEN0137, B5.5.10 and B5.5.19) defines RsiHashAlgorithm as an 8-bit enumeration, stored at offset 0x8 of RsiRealmConfig, with the unused bits of the structure being MBZ. However, realm_config::hash_algo is declared as unsigned long.
For an RMM that zeroes the unused bits, the wider type gives the same value. An RMM that only writes the low byte (as TF-RMM currently does) leaves bytes 1-7 with whatever the guest buffer contained, so a comparison of the 64-bit field against RSI_HASH_SHA_* can fail. Nothing in mainline reads the field yet, but the proposed Realm measurement register support does.
Declare the field as u8 so the guest only depends on the byte the specification defines. The struct size and the offsets of the other fields do not change.
--- arch/arm64/include/asm/rsi_smc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/include/asm/rsi_smc.h +1 -1
@@ -128,7 +128,7 @@ struct realm_config {union {struct {unsigned long ipa_bits;/* Width of IPA in bits */ -unsigned long hash_algo;/* Hash algorithm */ +u8 hash_algo;/* Hash algorithm */ };u8 pad[0x200 ]; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1497/2151 ALSA: pcm: Unlink substreams before releasing them
In reply to Greg Kroah-Hartman6.18-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
@@ -2753,18 +2753,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 )
@@ -2848,8 +2844,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 1498/2151 platform/x86: hp-bioscfg: fix off-by-one in password length check
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Muhammad Bilal <[email protected]>
[ Upstream commit 0c22178524864af85ea380be4b2d36078c0edc9c ]
current_password and new_password hold MAX_PASSWD_SIZE bytes including the NUL, but validate_password_input() accepts a password of exactly MAX_PASSWD_SIZE characters when the firmware limits allow it. strscpy() then truncates it and fails with -E2BIG, which store_password_instance() ignores, so the write reports success with a truncated password stored.
For example, with a max_password_length of 64 or more, writing 64 characters succeeds but only 63 are stored.
Reject lengths of MAX_PASSWD_SIZE or more.
Compile tested only.
--- drivers/platform/x86/hp/hp-bioscfg/passwdobj-attributes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/x86/hp/hp-bioscfg/passwdobj-attributes.c +1 -1
@@ -74,7 +74,7 @@ static int validate_password_input(int instance_id, const char *buf,if (is_current && !length)return 0 ; -if (length >MAX_PASSWD_SIZE ) +if (length >=MAX_PASSWD_SIZE )return -E2BIG ; if (password_data->min_password_length > length ||
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1499/2151 platform/x86: hp-bioscfg: validate SPM state returned by firmware
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Muhammad Bilal <[email protected]>
[ Upstream commit 35fb43f1576e1352077afc33a535007e0568480c ]
status_show() indexes the 3-entry spm_state_types[] with the state byte returned by firmware. update_spm_state() stores the same byte, which key_mechanism_show() uses to index the 3-entry spm_mechanism_types[]. Neither is range checked, so a state above 2 makes the world-readable status and key_mechanism files print a string from a pointer read past the array.
Return -EIO for an out of range state.
Compile tested only.
--- drivers/platform/x86/hp/hp-bioscfg/spmobj-attributes.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/platform/x86/hp/hp-bioscfg/spmobj-attributes.c +7 -0
@@ -6,6 +6,7 @@* Copyright (c) 2022 HP Development Company, L.P. */ +#include <linux/array_size.h> #include "bioscfg.h" static const char *const spm_state_types[] = {
@@ -115,6 +116,9 @@ static ssize_t update_spm_state(void)if (ret <0 )return ret; +if (data.state >=ARRAY_SIZE (spm_mechanism_types)) +return -EIO ; + bioscfg_drv.spm_data.mechanism = data.state;if (bioscfg_drv.spm_data.mechanism) bioscfg_drv.spm_data.is_enabled =1 ;
@@ -150,6 +154,9 @@ static ssize_t status_show(struct kobject *kobj, struct kobj_attributeif (ret <0 )return ret; +if (data.state >=ARRAY_SIZE (spm_state_types)) +return -EIO ; +/* * 'status' is a read-only file that returns ASCII text in * JSON format reporting the status information.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1500/2151 platform/x86: hp-bioscfg: fix oops on short integer attribute buffer
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Muhammad Bilal <[email protected]>
[ Upstream commit fd7545cd398adc09ec2f9b603d72671560ee6bf9 ]
hp_populate_integer_elements_from_buffer() ignores the return value of hp_get_string_from_buffer(). When fewer than 2 bytes are left in the buffer, dst_size is 0, kcalloc() returns ZERO_SIZE_PTR and hp_get_string_from_buffer() fails without writing to it, so kstrtoint() faults on address 0x10.
Return the error instead.
Compile tested only.
--- drivers/platform/x86/hp/hp-bioscfg/int-attributes.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/platform/x86/hp/hp-bioscfg/int-attributes.c +6 -1
@@ -331,7 +331,12 @@ static int hp_populate_integer_elements_from_buffer(u8 *buffer_ptr, u32 *buffer_// VALUE: integer_data->current_value =0 ; -hp_get_string_from_buffer (&buffer_ptr, buffer_size, dst, dst_size); + ret =hp_get_string_from_buffer (&buffer_ptr, buffer_size, dst, dst_size); +if (ret <0 ) { +kfree (dst); +return ret; + } + ret =kstrtoint (dst,10 , &integer_data->current_value);if (ret)pr_warn ("Unable to convert string to integer: %s\n" , dst);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1501/2151 serial: ma35d1: Do not force-enable an unselected console
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 171bb8a67cc1af7c88a65961adfb028430e0b783 ]
When another console is selected and there is no matching ttyNVT console argument, the core accepts the MA35D1 console without calling its setup function because it has CON_ENABLED set before registration. Its index remains -1 and printk repeatedly reports an invalid port, flooding the console and preventing boot.
Let the console core enable it after successful setup.
--- drivers/tty/serial/ma35d1_serial.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/ma35d1_serial.c +1 -1
@@ -639,7 +639,7 @@ static struct console ma35d1serial_console = { .write = ma35d1serial_console_write, .device = uart_console_device, .setup = ma35d1serial_console_setup, - .flags = CON_PRINTBUFFER | CON_ENABLED, + .flags = CON_PRINTBUFFER, .index = -1, .data = &ma35d1serial_reg, };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1502/2151 serial: pmac_zilog: report received breaks
In reply to Greg Kroah-Hartman6.18-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
@@ -233,6 +233,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 1503/2151 ASoC: codecs: wm8990: Fix definition of right input PGA controls
In reply to Greg Kroah-Hartman6.18-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 1504/2151 ASoC: codecs: wm8990: Fix definition of LOMIX AINLMUX Bypass Volume control
In reply to Greg Kroah-Hartman6.18-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 1505/2151 ASoC: codecs: wm8991: Fix definition of right input PGA controls
In reply to Greg Kroah-Hartman6.18-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 1506/2151 ASoC: codecs: wm8991: Fix definition of LOMIX AINLMUX Bypass Volume control
In reply to Greg Kroah-Hartman6.18-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 1507/2151 ASoC: codecs: wm8983: Fix definition of ADC 128x Oversampling control
In reply to Greg Kroah-Hartman6.18-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 1508/2151 ASoC: codecs: wm8985: Fix definition of ADC 128x Oversampling control
In reply to Greg Kroah-Hartman6.18-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 1509/2151 ASoC: codecs: wm8994: Fix definition of WM8958 noise gate hold time controls
In reply to Greg Kroah-Hartman6.18-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 1510/2151 ASoC: codecs: wm8955: Fix definition of Treble Cutoff control
In reply to Greg Kroah-Hartman6.18-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 1511/2151 ASoC: codecs: wm_hubs: Fix definition of MIXINR to MIXOUTR volume control
In reply to Greg Kroah-Hartman6.18-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
@@ -427,7 +427,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 1512/2151 ASoC: codecs: wm8737: Fix definition of zero cross switches
In reply to Greg Kroah-Hartman6.18-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 1513/2151 ASoC: codecs: wm5100: Fix definition of EQ3 Band 1 Volume control
In reply to Greg Kroah-Hartman6.18-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
@@ -658,7 +658,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 1514/2151 ASoC: codecs: wm8750: Fix definition of ALC Capture NG Type control
In reply to Greg Kroah-Hartman6.18-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 1515/2151 ASoC: codecs: wm8510: Fix definition of ADC Inversion Switch control
In reply to Greg Kroah-Hartman6.18-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 1516/2151 rpmsg: mtk: release channel OF node on device teardown
In reply to Greg Kroah-Hartman6.18-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 1517/2151 rpmsg: virtio: EPOLLOUT support
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Patrick Oppenlander <[email protected]>
[ Upstream commit c38d8b66c82c585199e2ad67282295f21cfa489f ]
Previously, polling an rpmsg endpoint (e.g. /dev/ttyRPMSGx) would generate EPOLLIN events but no EPOLLOUT events.
Unfortunately, poll support means that we can no longer disable tx-complete interrupts as there is no way to know whether a poller is waiting in sendq, so we always need notifications.
Stable-dep-of: 7dd4cffdf4c2 ("rpmsg: virtio: fix error handling in TX buffer wait")
--- drivers/rpmsg/virtio_rpmsg_bus.c | 101 ++++++++++--------------------- 1 file changed, 32 insertions(+), 69 deletions(-)
drivers/rpmsg/virtio_rpmsg_bus.c +32 -69
@@ -41,13 +41,12 @@* @buf_size: size of one rx or tx buffer * @last_sbuf: index of last tx buffer used * @bufs_dma: dma base addr of the buffers -* @tx_lock: protects svq, sbufs and sleepers, to allow concurrent senders. +* @tx_lock: protects svq and sbufs, to allow concurrent senders. * sending a message might require waking up a dozing remote * processor, which involves sleeping, hence the mutex. * @endpoints: idr of local endpoints, allows fast retrieval * @endpoints_lock: lock of the endpoints set * @sendq: wait queue of sending contexts waiting for a tx buffers -* @sleepers: number of senders that are waiting for a tx buffer * * This structure stores the rpmsg state of a given virtio remote processor * device (there might be several virtio proc devices for each physical
@@ -65,7 +64,6 @@ struct virtproc_info {struct idr endpoints;struct mutex endpoints_lock;wait_queue_head_t sendq; -atomic_t sleepers; };/* The feature bitmap for virtio rpmsg */
@@ -144,6 +142,8 @@ static int virtio_rpmsg_sendto(struct rpmsg_endpoint *ept, 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 __poll_t virtio_rpmsg_poll (struct rpmsg_endpoint *ept,struct file *filp, +poll_table *wait);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);
@@ -154,6 +154,7 @@ static const struct rpmsg_endpoint_ops virtio_endpoint_ops = { .sendto = virtio_rpmsg_sendto, .trysend = virtio_rpmsg_trysend, .trysendto = virtio_rpmsg_trysendto, + .poll = virtio_rpmsg_poll, .get_mtu = virtio_rpmsg_get_mtu, };
@@ -435,7 +436,6 @@ static void *get_a_tx_buf(struct virtproc_info *vrp)unsigned int len;void *ret; -/* support multiple concurrent senders */ mutex_lock (&vrp->tx_lock);/*
@@ -453,62 +453,6 @@ static void *get_a_tx_buf(struct virtproc_info *vrp)return ret; } -/** -* rpmsg_upref_sleepers() - enable "tx-complete" interrupts, if needed -* @vrp: virtual remote processor state -* -* This function is called before a sender is blocked, waiting for -* a tx buffer to become available. -* -* If we already have blocking senders, this function merely increases -* the "sleepers" reference count, and exits. -* -* Otherwise, if this is the first sender to block, we also enable -* virtio's tx callbacks, so we'd be immediately notified when a tx -* buffer is consumed (we rely on virtio's tx callback in order -* to wake up sleeping senders as soon as a tx buffer is used by the -* remote processor). -*/ -static void rpmsg_upref_sleepers (struct virtproc_info *vrp) -{ -/* support multiple concurrent senders */ -mutex_lock (&vrp->tx_lock); - -/* are we the first sleeping context waiting for tx buffers ? */ -if (atomic_inc_return (&vrp->sleepers) ==1 ) -/* enable "tx-complete" interrupts before dozing off */ -virtqueue_enable_cb (vrp->svq); - -mutex_unlock (&vrp->tx_lock); -} - -/** -* rpmsg_downref_sleepers() - disable "tx-complete" interrupts, if needed -* @vrp: virtual remote processor state -* -* This function is called after a sender, that waited for a tx buffer -* to become available, is unblocked. -* -* If we still have blocking senders, this function merely decreases -* the "sleepers" reference count, and exits. -* -* Otherwise, if there are no more blocking senders, we also disable -* virtio's tx callbacks, to avoid the overhead incurred with handling -* those (now redundant) interrupts. -*/ -static void rpmsg_downref_sleepers (struct virtproc_info *vrp) -{ -/* support multiple concurrent senders */ -mutex_lock (&vrp->tx_lock); - -/* are we the last sleeping context waiting for tx buffers ? */ -if (atomic_dec_and_test (&vrp->sleepers)) -/* disable "tx-complete" interrupts */ -virtqueue_disable_cb (vrp->svq); - -mutex_unlock (&vrp->tx_lock); -} -/** * rpmsg_send_offchannel_raw() - send a message across to the remote processor * @rpdev: the rpmsg channel
@@ -581,9 +525,6 @@ static int rpmsg_send_offchannel_raw(struct rpmsg_device *rpdev,/* no free buffer ? wait for one (but bail after 15 seconds) */ while (!msg) { -/* enable "tx-complete" interrupts, if not already enabled */ -rpmsg_upref_sleepers (vrp); -/* * sleep until a free buffer is available or 15 secs elapse. * the timeout period is not configurable because there's
@@ -594,9 +535,6 @@ static int rpmsg_send_offchannel_raw(struct rpmsg_device *rpdev, (msg =get_a_tx_buf (vrp)), msecs_to_jiffies(15000)); -/* disable "tx-complete" interrupts if we're the last sleeper */ -rpmsg_downref_sleepers (vrp); -/* timeout ? */ if (!err) {dev_err (dev,"timeout waiting for a tx buffer\n" );
@@ -675,6 +613,34 @@ static int virtio_rpmsg_trysendto(struct rpmsg_endpoint *ept, void *data,return rpmsg_send_offchannel_raw (rpdev, src, dst, data, len, false); } +static __poll_t virtio_rpmsg_poll (struct rpmsg_endpoint *ept,struct file *filp, +poll_table *wait) +{ +struct rpmsg_device *rpdev = ept->rpdev; +struct virtio_rpmsg_channel *vch =to_virtio_rpmsg_channel (rpdev); +struct virtproc_info *vrp = vch->vrp; +__poll_t mask =0 ; + +poll_wait (filp, &vrp->sendq, wait); + +/* support multiple concurrent senders */ +mutex_lock (&vrp->tx_lock); + +/* +* check for a free buffer, either: +* - we haven't used all of the available transmit buffers (half of the +* allocated buffers are used for transmit, hence num_bufs / 2), or, +* - we ask the virtqueue if there's a buffer available +*/ +if (vrp->last_sbuf < vrp->num_bufs /2 || + !virtqueue_enable_cb (vrp->svq)) + mask |=EPOLLOUT ; + +mutex_unlock (&vrp->tx_lock); + +return mask; +} +static ssize_t virtio_rpmsg_get_mtu (struct rpmsg_endpoint *ept) {struct rpmsg_device *rpdev = ept->rpdev;
@@ -921,9 +887,6 @@ static int rpmsg_probe(struct virtio_device *vdev)WARN_ON (err);/* sanity check; this can't really happen */ } -/* suppress "tx-complete" interrupts */ -virtqueue_disable_cb (vrp->svq); - vdev->priv = vrp; rpdev_ctrl =rpmsg_virtio_add_ctrl_dev (vdev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1518/2151 rpmsg: virtio: fix error handling in TX buffer wait
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Atul Akella <[email protected]>
[ Upstream commit 7dd4cffdf4c2a496ccf783303a03d687a2127baf ]
The TX buffer wait loop in rpmsg_send_offchannel_raw() ignores the possibility of wait_event_interruptible_timeout() returning a negative value, which happens when the wait is interrupted by a signal. In that case the loop spins back around and re-arms the wait instead of propagating the signal, which can stall a task that is trying to be killed.
Separately, on a genuine timeout (return value 0) the function returns -ERESTARTSYS, which is reserved for signal-interrupted syscalls that the kernel may restart. A timeout is not a signal and should not be treated as restartable; return -ETIMEDOUT instead.
Handle both cases explicitly: return err directly when negative, and return -ETIMEDOUT on timeout.
--- drivers/rpmsg/virtio_rpmsg_bus.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/rpmsg/virtio_rpmsg_bus.c +4 -1
@@ -535,10 +535,13 @@ static int rpmsg_send_offchannel_raw(struct rpmsg_device *rpdev, (msg =get_a_tx_buf (vrp)), msecs_to_jiffies(15000)); +if (err <0 ) +return err; +/* timeout ? */ if (!err) {dev_err (dev,"timeout waiting for a tx buffer\n" ); -return -ERESTARTSYS ; +return -ETIMEDOUT ; } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1519/2151 ARM: 9486/1: set !LPAE MAX_PHYSMEM_BITS to 32 and remove supersection mappings
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 787a3446cafee59e31deaec662d74f86bff38999 ]
An ARM randconfig with CONFIG_GET_FREE_REGION=y and CONFIG_WERROR=y fails to build:
include/linux/minmax.h:86:37: error: conversion from 'long long unsigned int' to 'resource_size_t' {aka 'unsigned int'} changes value from '68719476735' to '4294967295' [-Werror=overflow]
Commit 14b80582c43e ("resource: Introduce alloc_free_mem_region()") made kernel/resource.c clamp against
(1ULL << MAX_PHYSMEM_BITS) - 1. resource_size_t is 32-bit without LPAE, but ARM's default MAX_PHYSMEM_BITS is 36.
That default was added by commit db57f88e4ccb ("ARM: 8411/1: Add default SPARSEMEM settings") because several platforms needed at least 36 physical address bits. !LPAE could map addresses above 32 bits only through supersections.
CONFIG_IO_36, added by commit 23bdf86aa06e ("[ARM] 3377/2: add support for intel xsc3 core"), enabled these for XSC3 I/O. IXP23xx placed static I/O mappings above 4GiB until its removal in 2012, and IOP13xx ioremap()ed its PCIe windows there until its removal in 2019. The only remaining XSC3 platform, PXA3xx, has nothing above 4GiB.
Supersection address bits overlap the descriptor domain field, so IO_36 also renumbered the domains to make DOMAIN_IO zero. Remove IO_36, the alternate domain numbering, and ioremap()'s supersection path. Reject !LPAE ioremap ranges extending past 4GiB before phys_addr_t truncation, drop the now-unneeded high static-mapping exclusion, and reduce ioremap alignment from 16MiB to the 2MiB covered by a PMD's pair of sections.
The other supersection user, create_36bit_mapping(), was added by commit 0b7cd62ecdc1 ("[ARM] 3017/1: Add support for 36-bit addresses to create_mapping()") for IXP2350 and carried IXP23xx's high static mappings. Before this change, its only remaining call path was efi_create_mapping() -> create_mapping_late(), for an EFI runtime region above 4GiB.
No real-world user of this !LPAE path is known. AArch32 UEFI requires RAM described by its memory map to be identity-mapped during boot services, which a 32-bit virtual address space cannot provide above 4GiB. Systems needing wider physical addressing are expected to use LPAE.
Remove create_36bit_mapping() and the supersection definitions. If firmware nevertheless advertises such a region on !LPAE, efi_create_mapping() rejects it before __pfn_to_phys() truncates its address to a low alias. EFI runtime services remain disabled, but the kernel continues to boot. LPAE kernels are unaffected.
With no remaining !LPAE mappings above 4GiB, set MAX_PHYSMEM_BITS to 32 for !LPAE and retain 36 for LPAE, where phys_addr_t is 64-bit.
--- arch/arm/include/asm/domain.h | 17 ----- arch/arm/include/asm/memory.h | 4 +- arch/arm/include/asm/pgtable-2level-hwdef.h | 1 - arch/arm/include/asm/pgtable-2level.h | 7 -- arch/arm/include/asm/sparsemem.h | 4 ++ arch/arm/kernel/efi.c | 13 ++++ arch/arm/mm/Kconfig | 7 -- arch/arm/mm/ioremap.c | 53 ++------------ arch/arm/mm/mmu.c | 76 +-------------------- 9 files changed, 27 insertions(+), 155 deletions(-)
arch/arm/include/asm/domain.h +0 -17
@@ -18,27 +18,10 @@* DOMAIN_IO - domain 2 includes all IO only * DOMAIN_USER - domain 1 includes all user memory only * DOMAIN_KERNEL - domain 0 includes all kernel memory only -* -* The domain numbering depends on whether we support 36 physical -* address for I/O or not. Addresses above the 32 bit boundary can -* only be mapped using supersections and supersections can only -* be set for domain 0. We could just default to DOMAIN_IO as zero, -* but there may be systems with supersection support and no 36-bit -* addressing. In such cases, we want to map system memory with -* supersections to reduce TLB misses and footprint. -* -* 36-bit addressing and supersections are only available on -* CPUs based on ARMv6+ or the Intel XSC3 core. */ -#ifndef CONFIG_IO_36 #define DOMAIN_KERNEL 0#define DOMAIN_USER 1#define DOMAIN_IO 2 -#else -#define DOMAIN_KERNEL 2 -#define DOMAIN_USER 1 -#define DOMAIN_IO 0 -#endif #define DOMAIN_VECTORS 3/*
arch/arm/include/asm/memory.h +2 -2
@@ -89,9 +89,9 @@#if !defined(CONFIG_SMP ) && !defined(CONFIG_ARM_LPAE )/* -* Allow 16MB-aligned ioremap pages +* Allow 2MB-aligned ioremap pages */ -#define IOREMAP_MAX_ORDER 24 +#define IOREMAP_MAX_ORDER 21#endif #define VECTORS_BASE UL(0xffff0000)
arch/arm/include/asm/pgtable-2level-hwdef.h +0 -1
@@ -35,7 +35,6 @@#define PMD_SECT_APX (_AT(pmdval_t, 1) << 15)/* v6 */ #define PMD_SECT_S (_AT(pmdval_t, 1) << 16)/* v6 */ #define PMD_SECT_nG (_AT(pmdval_t, 1) << 17)/* v6 */ -#define PMD_SECT_SUPER (_AT(pmdval_t, 1) << 18)/* v6 */ #define PMD_SECT_AF (_AT(pmdval_t, 0))#define PMD_SECT_UNCACHED (_AT(pmdval_t, 0))
arch/arm/include/asm/pgtable-2level.h +0 -7
@@ -96,13 +96,6 @@#define SECTION_SIZE (1UL << SECTION_SHIFT)#define SECTION_MASK (~(SECTION_SIZE-1)) -/* -* ARMv6 supersection address mask and size definitions. -*/ -#define SUPERSECTION_SHIFT 24 -#define SUPERSECTION_SIZE (1UL << SUPERSECTION_SHIFT) -#define SUPERSECTION_MASK (~(SUPERSECTION_SIZE-1)) -#define USER_PTRS_PER_PGD (TASK_SIZE / PGDIR_SIZE)/*
arch/arm/include/asm/sparsemem.h +4 -0
@@ -19,7 +19,11 @@* These can be overridden in your mach/memory.h. */ #if !defined(MAX_PHYSMEM_BITS ) || !defined(SECTION_SIZE_BITS ) +#ifdef CONFIG_ARM_LPAE #define MAX_PHYSMEM_BITS 36 +#else +#define MAX_PHYSMEM_BITS 32 +#endif #define SECTION_SIZE_BITS 28#endif
arch/arm/kernel/efi.c +13 -0
@@ -6,6 +6,7 @@#include <linux/efi.h> #include <linux/memblock.h> #include <linux/screen_info.h> +#include <linux/sizes.h> #include <asm/efi.h> #include <asm/mach/map.h>
@@ -54,6 +55,18 @@ int __init efi_create_mapping(struct mm_struct *mm, efi_memory_desc_t *md) .length = md->num_pages * EFI_PAGE_SIZE, }; +/* +* Non-LPAE page tables cannot map EFI runtime regions extending +* beyond the 32-bit physical address space. +*/ +if (!IS_ENABLED (CONFIG_ARM_LPAE ) && + (md->phys_addr >=SZ_4G || + md->num_pages > (SZ_4G - md->phys_addr) /EFI_PAGE_SIZE )) { +pr_warn ("EFI runtime region at 0x%llx exceeds 32-bit physical address space\n" , + md->phys_addr); +return -ERANGE ; + } +/* * Order is important here: memory regions may have all of the * bits below set (and usually do), so we check them in order of
arch/arm/mm/Kconfig +0 -7
@@ -328,7 +328,6 @@ config CPU_XSC3 select CPU_PABRT_LEGACY select CPU_THUMB_CAPABLE select CPU_TLB_V4WBI if MMU - select IO_36 # Marvell PJ1 (Mohawk) config CPU_MOHAWK
@@ -652,12 +651,6 @@ config CPU_V7M_NUM_IRQ If unsure, keep default value. -# -# CPU supports 36-bit I/O -# -config IO_36 - bool - comment "Processor Features" config ARM_LPAE
arch/arm/mm/ioremap.c +7 -46
89 lines not on this page · raw message
arch/arm/mm/mmu.c +1 -75
94 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1520/2151 ARM: 9492/1: alignment: fix LSR #32 and ASR #32 offset decoding
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 9f878a6c2207f0c12f34a715a6a05cfc95f47460 ]
The register-offset form of LDR/STR may apply a shift to Rm. Per DecodeImmShift() (ARM ARM DDI0406C section A8.4.3, "Pseudocode details of instruction-specified shifts and rotates"), an imm5 of 0 encodes a shift of 32 for LSR and ASR; only LSL treats 0 as "no shift", and ROR with 0 encodes RRX.
do_alignment() special-cases RRX but not LSR or ASR, and IS_SHIFT() does not filter these encodings out, so the block is entered with shiftval == 0 and the offset becomes Rm instead of 0 (LSR #32) or the replicated sign of Rm (ASR #32).
do_alignment_finish_ldst() applies the offset to the base-register writeback of the post-indexed form, so the emulated access itself uses the correct faulting address but Rn is left holding the wrong value.
Reproduced on ARM926EJ-S (versatile_defconfig, CONFIG_ALIGNMENT_TRAP=y, gcc 13.3.0) with a misaligned base and Rm = 0x1000:
ldr r0, [r1], r2, lsr #32 Rn advanced by 0x1000, must be unchanged ldr r0, [r1], r2, asr #32 Rn advanced by 0x1000, must be unchanged ldr r0, [r1], r2, asr #32 with Rm negative, Rn must decrease by 1
All three are correct with the patch applied, while a lsr #1 control case is emulated correctly both before and after.
--- arch/arm/mm/alignment.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
arch/arm/mm/alignment.c +8 -2
@@ -915,11 +915,17 @@ do_alignment(unsigned long addr, unsigned int fsr, struct pt_regs *regs)break ;case SHIFT_LSR : - offset.un >>= shiftval; +if (shiftval ==0 ) + offset.un =0 ; +else + offset.un >>= shiftval;break ;case SHIFT_ASR : - offset.sn >>= shiftval; +if (shiftval ==0 ) + offset.sn >>=31 ; +else + offset.sn >>= shiftval;break ;case SHIFT_RORRRX :
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1521/2151 ARM: 9519/1: dma-mapping: Fix wrong free function in __iommu_alloc_simple() error path
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Szyprowski <[email protected]>
[ Upstream commit 74f79365839720bdb0c6bb4fe85c5b2a929ff5d1 ]
In __iommu_alloc_simple(), when IOMMU mapping creation fails, the error path unconditionally called __free_from_pool() regardless of the allocation path taken.
For the COHERENT case, memory is allocated via __alloc_simple_buffer(), which does not use the atomic pool. Calling __free_from_pool() on such memory silently returns without freeing, causing a page memory leak.
Fix this by matching the free function to the allocation path:
- COHERENT: use __dma_free_buffer(virt_to_page(addr), size)
- non-COHERENT: use __free_from_pool(addr, size)
--- arch/arm/mm/dma-mapping.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
arch/arm/mm/dma-mapping.c +4 -1
@@ -1058,7 +1058,10 @@ static void *__iommu_alloc_simple(struct device *dev, size_t size, gfp_t gfp,return addr; err_mapping: -__free_from_pool (addr, size); +if (coherent_flag ==COHERENT ) +__dma_free_buffer (virt_to_page (addr), size); +else +__free_from_pool (addr, size);return NULL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1522/2151 PCI: Fix out-of-bounds MMIO read in nvme_disable_and_flr()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mohamad Raizudeen <[email protected]>
[ Upstream commit 6aaa3f42e3410ea8e26c857477260159f724cb1d ]
In nvme_disable_and_flr(), the PCI bar is mapped using NVME_REG_CC + sizeof(cfg) which is (0x14 + 4 = 0x18 bytes)
However, the function later reads the controller status from NVME_REG_CSTS - offset 0x1C, which is outside the mapped 0x18 byte boundary. This violates the API contract.
Fix this by increasing the mapping size to include NVME_REG_CSTS. Also change sizeof(cfg) to sizeof(u32) to make the intent clearer.
--- drivers/pci/quirks.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/quirks.c +1 -1
@@ -4116,7 +4116,7 @@ static int nvme_disable_and_flr(struct pci_dev *dev, bool probe)if (probe)return 0 ; - bar =pci_iomap (dev,0 ,NVME_REG_CC +sizeof (cfg)); + bar =pci_iomap (dev,0 ,NVME_REG_CSTS +sizeof (u32));if (!bar)return -ENOTTY ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1523/2151 Bluetooth: btmtksdio: Remove redundant firmware filename override
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Lu <[email protected]>
[ Upstream commit 8c947cd1c27d6493ed7e6630e168222454f53edb ]
btmtksdio_setup() derives the firmware filename with btmtk_fw_get_filename() and then overwrites it with an snprintf() that open-codes that helper's fallback format. Commit 7f935b21bee4 ("Bluetooth:
btmtk: apply the common btmtk_fw_get_filename") added the helper call without removing the snprintf() it was meant to replace.
None of the device ids the helper special-cases can appear here: 0x6639, 0x7925 and the flavored 0x7961 belong to parts with no SDIO interface, and btmtksdio_setup() passes a flavor of 0 accordingly. The helper always falls through to the snprintf()'s own format, so both produce the same string and removing it is a no-op.
Remove it anyway, since it silently defeats the helper for any device id the helper special-cases.
Stable-dep-of: a2bb734c3687 ("Bluetooth: btmtksdio: Pass the hardware device id to mt79xx_setup()")
--- drivers/bluetooth/btmtksdio.c | 3 --- 1 file changed, 3 deletions(-)
drivers/bluetooth/btmtksdio.c +0 -3
@@ -1155,9 +1155,6 @@ static int btmtksdio_setup(struct hci_dev *hdev)btmtk_fw_get_filename (fwname,sizeof (fwname), dev_id, fw_version,0 ); -snprintf (fwname,sizeof (fwname), -"mediatek/BT_RAM_CODE_MT%04x_1_%x_hdr.bin" , - dev_id &0xffff , (fw_version &0xff ) +1 ); err =mt79xx_setup (hdev, fwname);if (err <0 )return err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1524/2151 Bluetooth: btmtksdio: Pass the hardware device id to mt79xx_setup()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Lu <[email protected]>
[ Upstream commit a2bb734c368766a2499ed00590ea838cac13c76e ]
mt79xx_setup() passes a hardcoded 0 to btmtk_setup_firmware_79xx(), discarding the device id that btmtksdio_setup() has just read from register 0x70010200. That argument only gates the section filtering for MT6639, which has no SDIO interface, so this is a no-op on supported hardware and carries no Fixes: tag.
Pass the value that has already been read, matching the USB path. Declare dev_id as u32 while at it, since that is what btmtksdio_mtk_reg_read() writes through the pointer.
--- drivers/bluetooth/btmtksdio.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/bluetooth/btmtksdio.c +5 -5
@@ -892,14 +892,14 @@ static int mt76xx_setup(struct hci_dev *hdev, const char *fwname)return 0 ; } -static int mt79xx_setup (struct hci_dev *hdev,const char *fwname) +static int mt79xx_setup (struct hci_dev *hdev,const char *fwname,u32 dev_id) {struct btmtksdio_dev *bdev =hci_get_drvdata (hdev);struct btmtk_hci_wmt_params wmt_params;u8 param =0x1 ;int err; - err =btmtk_setup_firmware_79xx (hdev, fwname, mtk_hci_wmt_sync,0 ); + err =btmtk_setup_firmware_79xx (hdev, fwname, mtk_hci_wmt_sync, dev_id);if (err <0 ) {bt_dev_err (hdev,"Failed to setup 79xx firmware (%d)" , err);return err;
@@ -1112,8 +1112,8 @@ static int btmtksdio_setup(struct hci_dev *hdev)ktime_t calltime, delta, rettime;unsigned long long duration;char fwname[64 ]; -int err, dev_id; -u32 fw_version =0 , val; +int err; +u32 dev_id, fw_version =0 , val; calltime =ktime_get ();set_bit (BTMTKSDIO_HW_TX_READY , &bdev->tx_state);
@@ -1155,7 +1155,7 @@ static int btmtksdio_setup(struct hci_dev *hdev)btmtk_fw_get_filename (fwname,sizeof (fwname), dev_id, fw_version,0 ); - err =mt79xx_setup (hdev, fwname); + err =mt79xx_setup (hdev, fwname, dev_id);if (err <0 )return err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1525/2151 Bluetooth: L2CAP: take chan->lock for l2cap_chan_add/ready/del
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pauli Virtanen <[email protected]>
[ Upstream commit 385c0829e09e7a6380ae67998ac6ef6f4dfd5303 ]
chan->lock must be held for __l2cap_chan_add as eg. calls to l2cap_chan_close assume chan->conn writes are guarded by it.
It must be held for l2cap_chan_del() due to l2cap_sock.c:l2cap_chan_conn, l2cap_monitor_timeout, etc.
Similarly it should be held for l2cap_ops::ready (assumed in 6lowpan.c). Also teardown usually has chan->lock held, it should always have it held to have the same locking context.
The lock is not correctly held by l2cap_core in several places.
Add the missing locks for l2cap_chan_del/add/ready(), except in l2cap_ecred_rsp_defer() which needs separate fix as it needs lock nesting.
--- include/net/bluetooth/l2cap.h | 3 ++- net/bluetooth/l2cap_core.c | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-)
include/net/bluetooth/l2cap.h +2 -1
@@ -974,7 +974,8 @@ int l2cap_chan_check_security(struct l2cap_chan *chan, bool initiator);void l2cap_chan_set_defaults (struct l2cap_chan *chan,struct l2cap_chan *pchan);int l2cap_ertm_init (struct l2cap_chan *chan);void l2cap_chan_add (struct l2cap_conn *conn,struct l2cap_chan *chan); -void __l2cap_chan_add (struct l2cap_conn *conn,struct l2cap_chan *chan); +void __l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan) + __must_hold(&chan->lock);typedef void (*l2cap_chan_func_t )(struct l2cap_chan *chan,void *data);void l2cap_chan_list (struct l2cap_conn *conn,l2cap_chan_func_t func,void *data);
net/bluetooth/l2cap_core.c +15 -0
@@ -706,7 +706,9 @@ void __l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan)void l2cap_chan_add (struct l2cap_conn *conn,struct l2cap_chan *chan) {mutex_lock (&conn->lock); +l2cap_chan_lock (chan);__l2cap_chan_add (conn, chan); +l2cap_chan_unlock (chan);mutex_unlock (&conn->lock); }
@@ -4135,6 +4137,8 @@ static struct l2cap_chan *l2cap_new_connection(struct l2cap_conn *conn,if (!chan)return NULL ; +l2cap_chan_lock (chan); +l2cap_chan_set_defaults (chan, pchan); chan->ops = pchan->ops;
@@ -4143,10 +4147,13 @@ static struct l2cap_chan *l2cap_new_connection(struct l2cap_conn *conn,if (pchan->ops->new_connection && pchan->ops->new_connection (pchan, chan) <0 ) {l2cap_chan_del (chan,0 ); +l2cap_chan_unlock (chan);l2cap_chan_put (chan);return NULL ; } +l2cap_chan_unlock (chan); +return chan; }
@@ -5137,6 +5144,8 @@ static int l2cap_le_connect_req(struct l2cap_conn *conn, goto response_unlock; } +l2cap_chan_lock (chan); +bacpy (&chan->src, &conn->hcon->src);bacpy (&chan->dst, &conn->hcon->dst); chan->src_type =bdaddr_src_type (conn->hcon);
@@ -5170,6 +5179,8 @@ static int l2cap_le_connect_req(struct l2cap_conn *conn, result =L2CAP_CR_LE_SUCCESS ; } +l2cap_chan_unlock (chan); + response_unlock:l2cap_chan_unlock (pchan);l2cap_chan_put (pchan);
@@ -5360,6 +5371,8 @@ static inline int l2cap_ecred_conn_req(struct l2cap_conn *conn,continue ; } +l2cap_chan_lock (chan); +bacpy (&chan->src, &conn->hcon->src);bacpy (&chan->dst, &conn->hcon->dst); chan->src_type =bdaddr_src_type (conn->hcon);
@@ -5392,6 +5405,8 @@ static inline int l2cap_ecred_conn_req(struct l2cap_conn *conn, }else {l2cap_chan_ready (chan); } + +l2cap_chan_unlock (chan); } unlock:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1526/2151 Bluetooth: L2CAP: hold l2cap_conn::lock in l2cap_connect_cfm()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pauli Virtanen <[email protected]>
[ Upstream commit 115e6a21c88a5f708b2b025f7567ab78a782a74f ]
l2cap_new_connection() -> __l2cap_chan_add() modifies l2cap_conn::chan_l, which is guarded by l2cap_conn::lock. The lock is not held in l2cap_connect_cfm().
Fix by holding conn->lock in l2cap_connect_cfm() to make the locking systematic.
--- net/bluetooth/l2cap_core.c | 4 ++++ 1 file changed, 4 insertions(+)
net/bluetooth/l2cap_core.c +4 -0
@@ -7670,6 +7670,8 @@ static void l2cap_connect_cfm(struct hci_conn *hcon, u8 status)* we left off, because the list lock would prevent calling the * potentially sleeping l2cap_chan_lock() function. */ +mutex_lock (&conn->lock); + pchan =l2cap_global_fixed_chan (NULL , hcon);while (pchan) {struct l2cap_chan *chan, *next;
@@ -7694,6 +7696,8 @@ static void l2cap_connect_cfm(struct hci_conn *hcon, u8 status) pchan = next; } +mutex_unlock (&conn->lock); +l2cap_conn_ready (conn); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1527/2151 Bluetooth: L2CAP: hold chan in l2cap_ecred_conn_rsp()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pauli Virtanen <[email protected]>
[ Upstream commit b508a2a2d846ccc4c8f691e4e3dfca6f97dfe85a ]
l2cap_chan_del() calls l2cap_chan_put() to drop the conn->chan_l reference. If this was the last reference, UAF follows.
l2cap_ecred_conn_rsp() iterates chan_l list and calls l2cap_chan_del() on some members, without holding chan reference.
Fix by holding refcount while using chan after l2cap_chan_del().
Since orig is looked up by dcid provided by remote, it's also possible orig == chan, so reference needs to be held also after orig use.
--- net/bluetooth/l2cap_core.c | 5 +++++ 1 file changed, 5 insertions(+)
net/bluetooth/l2cap_core.c +5 -0
@@ -5458,12 +5458,14 @@ static inline int l2cap_ecred_conn_rsp(struct l2cap_conn *conn, chan->state == BT_CONNECTED)continue ; +l2cap_chan_hold (chan);l2cap_chan_lock (chan);/* Check that there is a dcid for each pending channel */ if (cmd_len <sizeof (dcid)) {l2cap_chan_del (chan,ECONNREFUSED );l2cap_chan_unlock (chan); +l2cap_chan_put (chan);continue ; }
@@ -5502,6 +5504,8 @@ static inline int l2cap_ecred_conn_rsp(struct l2cap_conn *conn,__set_chan_timer (orig,0 );l2cap_chan_unlock (orig); } + +l2cap_chan_put (chan);continue ; }
@@ -5547,6 +5551,7 @@ static inline int l2cap_ecred_conn_rsp(struct l2cap_conn *conn, }l2cap_chan_unlock (chan); +l2cap_chan_put (chan); }return err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1528/2151 Bluetooth: btmtk: Validate the firmware layout before parsing it
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Lu <[email protected]>
[ Upstream commit 760ac9d02dce001f2e20c17deb18e7bb63d8355e ]
btmtk_setup_firmware_79xx() reads the section count out of the firmware's global descriptor, then walks a 64-byte section map per section and hands each section's file-supplied offset and length to the WMT download path. None of that is checked against fw->size, so a truncated or corrupted file makes the driver read past the end of request_firmware()'s buffer. On 32-bit the section count can also wrap the section map size calculation.
Add btmtk_fw_validate_layout() to check that the header, global descriptor and section map array all fit, and btmtk_fw_validate_section() to check one section's offset and length, both written so the size arithmetic cannot wrap. A section count of zero is rejected as well: it passes every size check but leaves the download loop with nothing to do, so the function would report success on hardware it never programmed. They are helpers rather than open-coded because the MT7928 CBMCU download path added later needs the same arithmetic.
This is hardening against a corrupted /lib/firmware rather than a bug an unprivileged user can trigger, hence bluetooth-next and no Fixes: tag. Well-formed firmware files are unaffected.
--- drivers/bluetooth/btmtk.c | 74 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 71 insertions(+), 3 deletions(-)
drivers/bluetooth/btmtk.c +71 -3
@@ -6,6 +6,7 @@#include <linux/firmware.h> #include <linux/usb.h> #include <linux/iopoll.h> +#include <linux/overflow.h> #include <linux/unaligned.h> #include <net/bluetooth/bluetooth.h>
@@ -59,6 +60,67 @@ struct btmtk_section_map { }; } __packed; +/* Reject a firmware image whose header, global descriptor or section map +* array does not fit in the file, and hand back the validated section +* count, so that the section map walks stay inside the firmware buffer. +*/ +static int btmtk_fw_validate_layout (struct hci_dev *hdev, +const struct firmware *fw, +u32 *section_num) +{ +const struct btmtk_global_desc *globaldesc; +size_t need; + +if (fw->size <MTK_FW_ROM_PATCH_HEADER_SIZE +MTK_FW_ROM_PATCH_GD_SIZE ) { +bt_dev_err (hdev,"Firmware too small: %zu bytes, need at least %u" , + fw->size, +MTK_FW_ROM_PATCH_HEADER_SIZE +MTK_FW_ROM_PATCH_GD_SIZE ); +return -EINVAL ; + } + + globaldesc = (const struct btmtk_global_desc *)(fw->data + +MTK_FW_ROM_PATCH_HEADER_SIZE ); + *section_num =le32_to_cpu (globaldesc->section_num); + +if (!*section_num) { +bt_dev_err (hdev,"Firmware declares no sections" ); +return -EINVAL ; + } + +if (check_mul_overflow ((size_t )MTK_FW_ROM_PATCH_SEC_MAP_SIZE , + (size_t )*section_num, &need) || +check_add_overflow (need, + (size_t )(MTK_FW_ROM_PATCH_HEADER_SIZE + +MTK_FW_ROM_PATCH_GD_SIZE ), + &need)) { +bt_dev_err (hdev,"Firmware section count too large: %u" , + *section_num); +return -EINVAL ; + } + +if (fw->size < need) { +bt_dev_err (hdev,"Firmware truncated: %zu bytes, need %zu for %u sections" , + fw->size, need, *section_num); +return -EINVAL ; + } + +return 0 ; +} + +/* Reject a section whose payload does not lie within the firmware file. */ +static int btmtk_fw_validate_section (struct hci_dev *hdev, +const struct firmware *fw,int index, +u32 offset,u32 size) +{ +if (offset > fw->size || size > fw->size - offset) { +bt_dev_err (hdev,"Firmware section %d out of bounds: offset=%u, size=%u, fw_size=%zu" , + index, offset, size, fw->size); +return -EINVAL ; + } + +return 0 ; +} +static void btmtk_coredump (struct hci_dev *hdev) {int err;
@@ -137,7 +199,6 @@ int btmtk_setup_firmware_79xx(struct hci_dev *hdev, const char *fwname, {struct btmtk_hci_wmt_params wmt_params;struct btmtk_patch_header *hdr; -struct btmtk_global_desc *globaldesc =NULL ;struct btmtk_section_map *sectionmap;const struct firmware *fw;const u8 *fw_ptr;
@@ -153,11 +214,13 @@ int btmtk_setup_firmware_79xx(struct hci_dev *hdev, const char *fwname,return err; } + err =btmtk_fw_validate_layout (hdev, fw, §ion_num); +if (err <0 ) + goto err_release_fw; + fw_ptr = fw->data; fw_bin_ptr = fw_ptr; hdr = (struct btmtk_patch_header *)fw_ptr; - globaldesc = (struct btmtk_global_desc *)(fw_ptr +MTK_FW_ROM_PATCH_HEADER_SIZE ); - section_num =le32_to_cpu (globaldesc->section_num);bt_dev_info (hdev,"HW/SW Version: 0x%04x%04x, Build Time: %s" ,le16_to_cpu (hdr->hwver),le16_to_cpu (hdr->swver), hdr->datetime);
@@ -180,6 +243,11 @@ int btmtk_setup_firmware_79xx(struct hci_dev *hdev, const char *fwname,continue ;if (dl_size >0 ) { + err =btmtk_fw_validate_section (hdev, fw, i, + section_offset, dl_size); +if (err <0 ) + goto err_release_fw; + retry =20 ;while (retry >0 ) { cmd[0 ] =0 ;/* 0 means legacy dl mode. */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1529/2151 Bluetooth: btmtk: Improve BT firmware logging
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Lu <[email protected]>
[ Upstream commit 046fa20e9c7abbafb166b431fe446c49b71cb15a ]
The firmware log line in btmtk_setup_firmware_79xx() never says which file was requested, which matters because btmtk_fw_get_filename() derives the name from the device id and firmware version at runtime. It reports the firmware's own hwver field as the HW version, when the device id the driver read from the chip is the more useful value and is already available as dev_id. And it prints datetime, a u8[16] with no guaranteed NUL terminator, with %s.
Log the filename before the image is parsed, so a file that fails validation still says which file it was, report dev_id as the HW version, and bound datetime with %.16s.
The datetime change is hardening rather than a fix, hence no Fixes: tag:
every file in linux-firmware terminates the field, and provoking the over-read needs a malformed file in /lib/firmware.
Log output on MT7922 after the change:
[ 365.245951] Bluetooth: hci0: Loading BT firmware: mediatek/BT_RAM_CODE_MT7922_1_1_hdr.bin [ 365.245956] Bluetooth: hci0: BT HW ver: 0x7922, SW ver: 0x008a, Build Time: 20260605203811
--- drivers/bluetooth/btmtk.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/bluetooth/btmtk.c +4 -2
@@ -214,6 +214,8 @@ int btmtk_setup_firmware_79xx(struct hci_dev *hdev, const char *fwname,return err; } +bt_dev_info (hdev,"Loading BT firmware: %s" , fwname); + err =btmtk_fw_validate_layout (hdev, fw, §ion_num);if (err <0 ) goto err_release_fw;
@@ -222,8 +224,8 @@ int btmtk_setup_firmware_79xx(struct hci_dev *hdev, const char *fwname, fw_bin_ptr = fw_ptr; hdr = (struct btmtk_patch_header *)fw_ptr; -bt_dev_info (hdev,"HW/SW Version: 0x%04x%04x, Build Time: %s" , -le16_to_cpu (hdr->hwver),le16_to_cpu (hdr->swver), hdr->datetime); +bt_dev_info (hdev,"BT HW ver: 0x%04x, SW ver: 0x%04x, Build Time: %.16s" , + dev_id &0xffff ,le16_to_cpu (hdr->swver), hdr->datetime);for (i =0 ; i < section_num; i++) { first_block =1 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1530/2151 Bluetooth: btusb: Make btusb_recv_{event,acl}() take struct hci_dev *
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zijun Hu <[email protected]>
[ Upstream commit d6d15018c8e1527841e39a6a80c60997e594ca70 ]
Both helpers currently take struct btusb_data *, which is private to btusb.c, as parameter type as below:
int btusb_recv_event(struct btusb_data *data, struct sk_buff *skb) int btusb_recv_acl(struct btusb_data *data, struct sk_buff *skb)
To allow vendor USB-transport-specific source files to share them as well, change the type to struct hci_dev *.
Stable-dep-of: fa96916cfd05 ("Bluetooth: btusb: Preserve event and ACL packet ordering")
--- drivers/bluetooth/btusb.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/bluetooth/btusb.c +10 -6
@@ -1214,14 +1214,16 @@ static inline void btusb_free_frags(struct btusb_data *data)spin_unlock_irqrestore (&data->rxlock, flags); } -static int btusb_recv_event (struct btusb_data *data,struct sk_buff *skb) +static int btusb_recv_event (struct hci_dev *hdev,struct sk_buff *skb) { +struct btusb_data *data =hci_get_drvdata (hdev); +if (data->intr_interval) {/* Trigger dequeue immediately if an event is received */ schedule_delayed_work (&data->rx_work,0 ); } -return data->recv_event (data->hdev, skb); +return data->recv_event (hdev, skb); }static int btusb_recv_intr (struct btusb_data *data,void *buffer,int count)
@@ -1281,7 +1283,7 @@ static int btusb_recv_intr(struct btusb_data *data, void *buffer, int count) }/* Complete frame */ -btusb_recv_event (data, skb); +btusb_recv_event (data->hdev, skb); skb =NULL ; } }
@@ -1292,13 +1294,15 @@ static int btusb_recv_intr(struct btusb_data *data, void *buffer, int count)return err; } -static int btusb_recv_acl (struct btusb_data *data,struct sk_buff *skb) +static int btusb_recv_acl (struct hci_dev *hdev,struct sk_buff *skb) { +struct btusb_data *data =hci_get_drvdata (hdev); +/* Only queue ACL packet if intr_interval is set as it means * force_poll_sync has been enabled. */ if (!data->intr_interval) -return data->recv_acl (data->hdev, skb); +return data->recv_acl (hdev, skb);skb_queue_tail (&data->acl_q, skb);schedule_delayed_work (&data->rx_work, data->intr_interval);
@@ -1353,7 +1357,7 @@ static int btusb_recv_bulk(struct btusb_data *data, void *buffer, int count)if (!hci_skb_expect (skb)) {/* Complete frame */ -btusb_recv_acl (data, skb); +btusb_recv_acl (data->hdev, skb); skb =NULL ; } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1531/2151 Bluetooth: btusb: Preserve event and ACL packet ordering
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kiran K <[email protected]>
[ Upstream commit fa96916cfd05ceb1c26af0b2ea73daf5481cad2d ]
When force_poll_sync is enabled, commit 800fe5ec302e ("Bluetooth:
btusb: Add support for queuing during polling interval") defers ACL delivery to the RX worker. The event path currently wakes that worker before delivering the event, so queued ACL data can reach HCI first.
Deliver the event before waking the worker. This preserves the intended event-first ordering and the event callback's return value.
--- drivers/bluetooth/btusb.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/bluetooth/btusb.c +4 -1
@@ -1217,13 +1217,16 @@ static inline void btusb_free_frags(struct btusb_data *data)static int btusb_recv_event (struct hci_dev *hdev,struct sk_buff *skb) {struct btusb_data *data =hci_get_drvdata (hdev); +int err; + + err = data->recv_event (hdev, skb);if (data->intr_interval) {/* Trigger dequeue immediately if an event is received */ schedule_delayed_work (&data->rx_work,0 ); } -return data->recv_event (hdev, skb); +return err; }static int btusb_recv_intr (struct btusb_data *data,void *buffer,int count)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1532/2151 Bluetooth: hci_sync: fix mesh adv timeout units
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pauli Virtanen <[email protected]>
[ Upstream commit 8a8d51eeedebfa5aaaae7720f2fb2aa1a67b8587 ]
Mesh adv instance timeout and duration are in milliseconds, see mesh_send_sync, hci_add_adv_instance. hci_schedule_adv_instance_sync() and hci_enable_ext_advertising_sync() ignore this, and scale the timeout wrong.
Fix for mesh instances by using msecs_to_jiffies() in hci_schedule_adv_instance_sync and fixing the scaling in hci_enable_ext_advertising_sync.
Fixes BlueZ "Mesh - Send cancel" test failures.
--- net/bluetooth/hci_sync.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
net/bluetooth/hci_sync.c +4 -2
@@ -1694,7 +1694,8 @@ int hci_enable_ext_advertising_sync(struct hci_dev *hdev, u8 instance)* scheduling it. */ if (adv && adv->timeout) { -u16 duration = adv->timeout *MSEC_PER_SEC ; +u16 duration = adv->mesh ? adv->timeout : + adv->timeout *MSEC_PER_SEC ;/* Time = N * 10 ms */ set->duration =cpu_to_le16 (duration /10 );
@@ -2124,7 +2125,8 @@ int hci_schedule_adv_instance_sync(struct hci_dev *hdev, u8 instance, hdev->adv_instance_timeout = timeout;queue_delayed_work (hdev->req_workqueue, &hdev->adv_instance_expire, -secs_to_jiffies (timeout)); + adv->mesh ?msecs_to_jiffies (timeout) : +secs_to_jiffies (timeout)); }/* If we're just re-scheduling the same instance again then do not
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1533/2151 Bluetooth: MGMT: Fix advertising instances with Global Advertising
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luiz Augusto von Dentz <[email protected]>
[ Upstream commit 0ad48c88a2ed3b58164fa771977868503b0abac3 ]
Global Advertising, enabled with MGMT_OP_SET_ADVERTISING, uses instance 0 and with extended advertising it has its own advertising set, but instances were still being treated as if they shared the same set:
- Add Advertising and Add Extended Advertising Data would return success without ever enabling the instance.
- Removing the last instance would disable all advertising sets, stopping Global Advertising while leaving its setting enabled.
- Disabling Global Advertising would disable all sets, including active instances.
Fix this by only overriding instances that share the advertising set of Global Advertising, and by tracking HCI_LE_ADV_0 rather than HCI_LE_ADV to determine the state of Global Advertising.
--- include/net/bluetooth/hci_sync.h | 1 + net/bluetooth/hci_event.c | 11 ++++- net/bluetooth/hci_sync.c | 2 +- net/bluetooth/mgmt.c | 83 +++++++++++++++++++++++++++----- 4 files changed, 83 insertions(+), 14 deletions(-)
include/net/bluetooth/hci_sync.h +1 -0
@@ -124,6 +124,7 @@ int hci_disable_per_advertising_sync(struct hci_dev *hdev, u8 instance);int hci_remove_advertising_sync (struct hci_dev *hdev,struct sock *sk,u8 instance,bool force);int hci_disable_advertising_sync (struct hci_dev *hdev); +int hci_disable_ext_adv_legacy_instance_sync (struct hci_dev *hdev);int hci_clear_adv_instance_sync (struct hci_dev *hdev,struct sock *sk,u8 instance,bool force);int hci_update_passive_scan_sync (struct hci_dev *hdev);
net/bluetooth/hci_event.c +9 -2
@@ -1631,15 +1631,22 @@ static u8 hci_cc_le_set_ext_adv_enable(struct hci_dev *hdev, void *data,hci_dev_clear_flag (hdev,HCI_LE_ADV_0 );/* If just one instance was disabled check if there are -* any other instance enabled before clearing HCI_LE_ADV +* any other instance enabled, including instance 0, +* before clearing HCI_LE_ADV */ +if (hci_dev_test_flag (hdev,HCI_LE_ADV_0 )) + goto unlock; +list_for_each_entry_safe (adv, n, &hdev->adv_instances, list) {if (adv->enabled) goto unlock; } }else { -/* All instances shall be considered disabled */ +/* All instances shall be considered disabled, except +* instance 0 whose state is preserved so it can be +* re-enabled by hci_resume_advertising_sync. +*/ list_for_each_entry_safe (adv, n, &hdev->adv_instances, list) adv->enabled = false;
net/bluetooth/hci_sync.c +1 -1
@@ -1184,7 +1184,7 @@ int hci_update_random_address_sync(struct hci_dev *hdev, bool require_privacy,return 0 ; } -static int hci_disable_ext_adv_legacy_instance_sync (struct hci_dev *hdev) +int hci_disable_ext_adv_legacy_instance_sync (struct hci_dev *hdev) {struct hci_cp_le_set_ext_adv_enable *cp;struct hci_cp_ext_adv_set *set;
net/bluetooth/mgmt.c +72 -11
135 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1534/2151 Bluetooth: HCI: Fix tracking of instances sharing handle 0x00
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luiz Augusto von Dentz <[email protected]>
[ Upstream commit 1bfecdbd031711e5205ae78f3b8c296e5a53bc55 ]
When the controller supports a single advertising set, instance 1 uses handle 0x00 which is the same handle used by instance 0 (Global Advertising), but hci_cc_le_set_ext_adv_enable would lookup the instance using the handle as instance identifier, marking instance 0 as enabled/disabled instead of instance 1, leaving its state out of sync.
Fix this by matching instances by handle and, for handle 0x00, using hdev->cur_adv_instance, now set when enabling an instance, to determine which instance owns the set. Also disable the instance sharing the advertising set of instance 0 before overriding it.
--- net/bluetooth/hci_event.c | 47 ++++++++++++++++++++++++++++++--------- net/bluetooth/hci_sync.c | 35 ++++++++++++++++++++++++++++- 2 files changed, 70 insertions(+), 12 deletions(-)
net/bluetooth/hci_event.c +36 -11
@@ -1584,6 +1584,39 @@ static u8 hci_cc_le_set_adv_enable(struct hci_dev *hdev, void *data,return rp->status; } +/* Update the enabled state of the instance(s) using the advertising set +* identified by handle. +* +* Instances may share handle 0x00 with instance 0 (Global Advertising), e.g. +* when the controller supports a single advertising set, in which case the +* set is owned by the instance last enabled (hdev->cur_adv_instance) and any +* other instance sharing it shall be considered disabled. +*/ +static void hci_le_ext_adv_set_enabled (struct hci_dev *hdev,u8 handle, +bool enable) +{ +struct adv_info *adv; +bool owned = false; + +list_for_each_entry (adv, &hdev->adv_instances, list) { +if (adv->handle != handle) +continue ; + + adv->enabled = enable && + (handle || + adv->instance == hdev->cur_adv_instance); + owned |= adv->enabled; + } + +if (handle) +return ; + +if (enable && !owned) +hci_dev_set_flag (hdev,HCI_LE_ADV_0 ); +else +hci_dev_clear_flag (hdev,HCI_LE_ADV_0 ); +} +static u8 hci_cc_le_set_ext_adv_enable (struct hci_dev *hdev,void *data,struct sk_buff *skb) {
@@ -1605,18 +1638,13 @@ static u8 hci_cc_le_set_ext_adv_enable(struct hci_dev *hdev, void *data,hci_dev_lock (hdev); -if (cp->num_of_sets) - adv =hci_find_adv_instance (hdev, set->handle); -if (cp->enable) {struct hci_conn *conn;hci_dev_set_flag (hdev,HCI_LE_ADV ); -if (adv) - adv->enabled = true; -else if (!set->handle) -hci_dev_set_flag (hdev,HCI_LE_ADV_0 ); +if (cp->num_of_sets) +hci_le_ext_adv_set_enabled (hdev, set->handle, true); conn =hci_lookup_le_connect (hdev);if (conn)
@@ -1625,10 +1653,7 @@ static u8 hci_cc_le_set_ext_adv_enable(struct hci_dev *hdev, void *data, conn->conn_timeout); }else {if (cp->num_of_sets) { -if (adv) - adv->enabled = false; -else if (!set->handle) -hci_dev_clear_flag (hdev,HCI_LE_ADV_0 ); +hci_le_ext_adv_set_enabled (hdev, set->handle, false);/* If just one instance was disabled check if there are * any other instance enabled, including instance 0,
net/bluetooth/hci_sync.c +34 -1
@@ -1184,6 +1184,30 @@ int hci_update_random_address_sync(struct hci_dev *hdev, bool require_privacy,return 0 ; } +/* Check if the advertising set with handle 0x00 is in use, either by instance +* 0 or by an instance sharing its advertising set. +*/ +static bool hci_ext_adv_handle_0_enabled (struct hci_dev *hdev) +{ +struct adv_info *adv; +bool enabled; + +hci_dev_lock (hdev); + + enabled =hci_dev_test_flag (hdev,HCI_LE_ADV_0 ); + +list_for_each_entry (adv, &hdev->adv_instances, list) { +if (!adv->handle && adv->enabled) { + enabled = true; +break ; + } + } + +hci_dev_unlock (hdev); + +return enabled; +} +int hci_disable_ext_adv_legacy_instance_sync (struct hci_dev *hdev) {struct hci_cp_le_set_ext_adv_enable *cp;
@@ -1191,7 +1215,7 @@ int hci_disable_ext_adv_legacy_instance_sync(struct hci_dev *hdev)u8 data[sizeof (*cp) +sizeof (*set) *1 ];u8 size; -if (!hci_dev_test_flag (hdev,HCI_LE_ADV_0 )) +if (!hci_ext_adv_handle_0_enabled (hdev))return 0 ;memset (data,0 ,sizeof (data));
@@ -1435,6 +1459,9 @@ int hci_setup_ext_adv_instance_sync(struct hci_dev *hdev, u8 instance)return -EINVAL ; } }else { +/* Disable the advertising set with handle 0x00, including any +* instance sharing it, since it is going to be overridden. +*/ err =hci_disable_ext_adv_legacy_instance_sync (hdev);if (err)return err;
@@ -1701,6 +1728,12 @@ int hci_enable_ext_advertising_sync(struct hci_dev *hdev, u8 instance) set->duration =cpu_to_le16 (duration /10 ); } +/* Track which instance owns the advertising set since the handle +* alone is ambiguous when instances share handle 0x00, see +* hci_cc_le_set_ext_adv_enable. +*/ + hdev->cur_adv_instance = instance; + return __hci_cmd_sync_status(hdev, HCI_OP_LE_SET_EXT_ADV_ENABLE, sizeof(*cp) + sizeof(*set) * cp->num_of_sets,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1535/2151 Bluetooth: MGMT: Fix pending state of instances added without HCI traffic
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luiz Augusto von Dentz <[email protected]>
[ Upstream commit 5548fb51aa3cc24545029a286882d261a8e77d8a ]
When Add Advertising completes without HCI communication, e.g. when the device is not powered or the instance is overridden by Global Advertising, the instance is left marked as pending, so a subsequent failure in add_adv_complete would remove it despite it having been successfully added.
Fix this by clearing the pending state before completing the command.
--- net/bluetooth/mgmt.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/bluetooth/mgmt.c +6 -0
@@ -9039,6 +9039,12 @@ static int add_advertising(struct sock *sk, struct hci_dev *hdev,if (!hdev_is_powered (hdev) ||adv_overridden_by_global (hdev, adv) || !schedule_instance) { +/* Instance has been accepted so it shall no longer be +* considered pending, otherwise a later failure in +* add_adv_complete would remove it. +*/ + adv->pending = false; + rp.instance = cp->instance; err =mgmt_cmd_complete (sk, hdev->id,MGMT_OP_ADD_ADVERTISING ,MGMT_STATUS_SUCCESS , &rp,sizeof (rp));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1536/2151 Bluetooth: MGMT: Fix leaking instance on Add Extended Advertising Parameters
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luiz Augusto von Dentz <[email protected]>
[ Upstream commit f7f0d0a9eb6e4616c0b3a2a95498b5204c5543c9 ]
If queueing the command fails the instance is never removed, despite it having already been added or modified by hci_add_adv_instance, so remove it as it is done by add_ext_adv_params_complete on failure, signaling it has been removed if it was previously added.
--- net/bluetooth/mgmt.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
net/bluetooth/mgmt.c +16 -3
@@ -9227,14 +9227,15 @@ static int add_ext_adv_params(struct sock *sk, struct hci_dev *hdev, data, data_len);if (!cmd) { err = -ENOMEM ; -hci_remove_adv_instance (hdev, cp->instance); - goto unlock; + goto remove; } err =hci_cmd_sync_queue (hdev, add_ext_adv_params_sync, cmd, add_ext_adv_params_complete); -if (err <0 ) +if (err <0 ) {mgmt_pending_free (cmd); + goto remove; + } }else { rp.instance = cp->instance; rp.tx_power =HCI_ADV_TX_POWER_NO_PREFERENCE ;
@@ -9245,6 +9246,18 @@ static int add_ext_adv_params(struct sock *sk, struct hci_dev *hdev, MGMT_STATUS_SUCCESS, &rp, sizeof(rp)); } + goto unlock; + +remove: +/* The instance may have been modified already so remove it, like it +* is done in add_ext_adv_params_complete, signaling it has been +* removed if it was previously added. +*/ +if (!adv->pending) +mgmt_advertising_removed (sk, hdev, cp->instance); + +hci_remove_adv_instance (hdev, cp->instance); + unlock:hci_dev_unlock (hdev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1537/2151 Bluetooth: 6LoWPAN: Use RCU-safe device list removal
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit 8c27d7d06e21ba9455ddae4e14f364c57f095cba ]
RCU readers of bt_6lowpan_devices must be able to follow an adapter's forward link until their read-side critical section ends. The entries are published with list_add_rcu(), but device_event() removes an entry on NETDEV_UNREGISTER with list_del(), poisoning that link.
When an adapter is being unregistered and 6LoWPAN is enabled, a 6lowpan_control debugfs write with an existing LE L2CAP connection can enter lookup_peer() after unregister's first synchronize_net(). If the connection has no peer on that adapter, the reader must advance to the next list entry. Neither RTNL nor devices_lock excludes this RCU reader.
The last peer's chan_close_cb() schedules delete_netdev(), which reaches unregister_netdevice_many_notify() through unregister_dev() and lowpan_unregister_netdev(). The following ordering is possible:
Unregister worker Control writer
----------------- --------------
synchronize_net() returns
lowpan_control_write() lookup_peer(): rcu_read_lock() reach adapter; no matching peer
device_event(): devices_lock
list_del(&entry->list)
spin_unlock(&devices_lock)
follow poisoned next link read invalid adapter address
post-notifier synchronize_net()
waits for the reader
This invalid pointer access can fault in lookup_peer(). The first grace period drains existing readers but permits new ones to start, and the later grace period cannot prevent the intervening poisoned-link access.
Use list_del_rcu() under the existing devices_lock to preserve the forward link for readers that already reached the adapter. The existing post-notifier synchronize_net() waits for those readers before netdevice teardown frees the private storage containing lowpan_btle_dev.
KASAN report as below:
[...]
[ 45.867526] Oops: general protection fault, probably for non-canonical address 0xfbd59c0000000023: 0000 [#1] SMP KASAN NOPTI
[ 45.869489] KASAN: maybe wild-memory-access in range [0xdead000000000118-0xdead00000000011f]
[ 45.870981] CPU: 1 UID: 0 PID: 646 Comm: sh Not tainted 7.2.0-rc6-pmb-bt-functional-v1+ #4 PREEMPT(lazy)
[ 45.872609] 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
[ 45.874380] RIP: 0010:lookup_peer+0x1ba/0x320
[ 45.875067] Code: 48 89 d9 ba 04 00 00 00 4c 89 fe bf a0 06 00 00 e8 2b e8 ad fb e9 56 ff ff ff e8 01 1e c3 fb 49 8d 7f 18 48 89 f8 48 c1 e8 03 <80> 3c 28 00 0f 85 4a 01 00 00 4d 8b 47 18 4c 89 f1 ba 04 00 00 00
[ 45.878206] RSP: 0018:ffff888114d67b90 EFLAGS: 00010212
[ 45.879106] RAX: 1bd5a00000000023 RBX: 0000000000000000 RCX: ffffffff85c1d19f
[ 45.880334] RDX: ffff88810dc35700 RSI: 0000000000000000 RDI: dead000000000118
[ 45.881455] RBP: dffffc0000000000 R08: 0000000000000001 R09: 0000000000000001
[ 45.882546] R10: ffffffff893d3057 R11: ffff88810dc35700 R12: ffff88810a690000
[ 45.883839] R13: ffff888115451038 R14: ffff88810a690000 R15: dead000000000100
[ 45.885186] FS: 00007fa889bac780(0000) GS:ffff8881fd852000(0000) knlGS:0000000000000000
[ 45.886539] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 45.887527] CR2: 00007ffe304f2f80 CR3: 0000000104f64005 CR4: 0000000000770ef0
[ 45.888687] PKRU: 55555554
[ 45.889183] Call Trace:
[ 45.889666] <TASK>
[ 45.890061] lowpan_control_write+0x445/0x9e0
[ 45.890854] ? __pfx_lowpan_control_write+0x10/0x10
[ 45.891738] ? srso_alias_return_thunk+0x5/0xfbef5
[ 45.892603] ? srso_alias_return_thunk+0x5/0xfbef5
[ 45.893383] ? __debugfs_file_get+0x1bd/0x7f0
[ 45.894057] ? srso_alias_return_thunk+0x5/0xfbef5
[ 45.894902] ? lock_acquire+0x17b/0x2f0
[ 45.895593] ? ksys_write+0x111/0x200
[ 45.896290] full_proxy_write+0x11f/0x180
[ 45.896991] vfs_write+0x25a/0x1010
[ 45.897642] ? __pfx_full_proxy_write+0x10/0x10
[ 45.898440] ? __pfx_vfs_write+0x10/0x10
[ 45.899178] ? lock_release+0x11f/0x280
[ 45.899855] ksys_write+0x111/0x200
[ 45.900435] ? __pfx_ksys_write+0x10/0x10
[ 45.901074] ? irqentry_exit+0xbe/0x820
[ 45.901722] ? srso_alias_return_thunk+0x5/0xfbef5
[ 45.902489] do_syscall_64+0x115/0x6a0
[ 45.903064] entry_SYSCALL_64_after_hwframe+0x77/0x7f
[ 45.903813] RIP: 0033:0x7fa889c3e687
[ 45.904359] Code: 48 89 fa 4c 89 df e8 58 b3 00 00 8b 93 08 03 00 00 59 5e 48 83 f8 fc 74 1a 5b c3 0f 1f 84 00 00 00 00 00 48 8b 44 24 10 0f 05 <5b> c3 0f 1f 80 00 00 00 00 83 e2 39 83 fa 08 75 de e8 23 ff ff ff
[ 45.906981] RSP: 002b:00007ffd7651b960 EFLAGS: 00000202 ORIG_RAX: 0000000000000001
[ 45.908070] RAX: ffffffffffffffda RBX: 00007fa889bac780 RCX: 00007fa889c3e687
[ 45.909102] RDX: 000000000000001c RSI: 00005570f25e8d10 RDI: 0000000000000001
[ 45.910133] RBP: 00005570f25e8d10 R08: 0000000000000000 R09: 0000000000000000
[ 45.911162] R10: 0000000000000000 R11: 0000000000000202 R12: 0000000000000001
[ 45.912190] R13: 000000000000001c R14: 0000000000000000 R15: 00005570f25e8a78
[ 45.913208] </TASK>
[ 45.913530] Modules linked in:
[ 45.914022] ---[ end trace 0000000000000000 ]---
[ 45.914709] RIP: 0010:lookup_peer+0x1ba/0x320
[ 45.915436] Code: 48 89 d9 ba 04 00 00 00 4c 89 fe bf a0 06 00 00 e8 2b e8 ad fb e9 56 ff ff ff e8 01 1e c3 fb 49 8d 7f 18 48 89 f8 48 c1 e8 03 <80> 3c 28 00 0f 85 4a 01 00 00 4d 8b 47 18 4c 89 f1 ba 04 00 00 00
[ 45.919191] RSP: 0018:ffff888114d67b90 EFLAGS: 00010212
[ 45.920046] RAX: 1bd5a00000000023 RBX: 0000000000000000 RCX: ffffffff85c1d19f
[ 45.921129] RDX: ffff88810dc35700 RSI: 0000000000000000 RDI: dead000000000118
[ 45.922553] RBP: dffffc0000000000 R08: 0000000000000001 R09: 0000000000000001
[ 45.923653] R10: ffffffff893d3057 R11: ffff88810dc35700 R12: ffff88810a690000
[ 45.925119] R13: ffff888115451038 R14: ffff88810a690000 R15: dead000000000100
[ 45.926180] FS: 00007fa889bac780(0000) GS:ffff8881fd852000(0000) knlGS:0000000000000000
[ 45.927817] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 45.928726] CR2: 00007ffe304f2f80 CR3: 0000000104f64005 CR4: 0000000000770ef0
[ 45.930069] PKRU: 55555554
[ 45.930456] Kernel panic - not syncing: Fatal exception
[ 45.931542] Kernel Offset: disabled
[ 45.932040] Rebooting in 1 seconds..--- net/bluetooth/6lowpan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/bluetooth/6lowpan.c +1 -1
@@ -1268,7 +1268,7 @@ static int device_event(struct notifier_block *unused,if (entry->netdev == netdev) {BT_DBG ("Unregistered netdev %s %p" , netdev->name, netdev); -list_del (&entry->list); +list_del_rcu (&entry->list);break ; } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1538/2151 Bluetooth: Add missing newline to bt_dev_{err,warn}_ratelimited()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hitalo Souza <[email protected]>
[ Upstream commit f51ee3bb5fbe9c2019c31befe330bddd3aee39c2 ]
bt_dev_err_ratelimited() and bt_dev_warn_ratelimited() pass the format string to bt_err_ratelimited()/bt_warn_ratelimited() without appending a newline, unlike bt_dev_err() and bt_dev_warn(), which go through BT_ERR()/BT_WARN() and add one. Only 2 of the 22 in-tree callers (both in virtio_bt) put the newline in their own format string.
A printk record without a trailing newline is stored with prb_commit() instead of prb_final_commit(), and readers of the log buffer (/dev/kmsg, syslog) do not see it until it is finalized, which only happens when the next record is reserved. These messages therefore stay invisible until some unrelated message is printed, and journald, which timestamps a record when it reads it, logs them with the time of that later message.
This was observed with a MediaTek MT7921 controller (USB 04ca:3802):
when an eSCO link is closed, the host still receives a few SCO packets for the handle after Disconnection Complete, so hci_scodata_packet() logs "SCO packet for unknown connection handle". Comparing the record's kernel timestamp (_SOURCE_MONOTONIC_TIMESTAMP) with the time journald received it, over one capture:
emitted logged delay 15:36:52.896 15:37:00.214 7.3 s 15:37:03.410 15:39:05.574 122.2 s 15:39:05.574 15:39:12.506 6.9 s 15:39:19.791 15:40:54.109 94.3 s 15:41:22.021 15:41:24.647 2.6 s
Each message showed up together with the next kernel message; the 94 s one looked as if it had been logged in the middle of a later, healthy eSCO connection.
bt_dev_err_ratelimited() lost its newline in commit 657cc646475b ("Bluetooth: Remove usage of BT_ERR_RATELIMITED macro"), which replaced BT_ERR_RATELIMITED(), the variant that appended "\n", with a direct call to bt_err_ratelimited(). bt_dev_warn_ratelimited() never had one.
Append the newline in both macros, as BT_ERR() and BT_WARN() do, and drop it from the two virtio_bt format strings so that their messages do not gain an empty line.
--- drivers/bluetooth/virtio_bt.c | 4 ++-- include/net/bluetooth/bluetooth.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/bluetooth/virtio_bt.c +2 -2
@@ -228,7 +228,7 @@ static void virtbt_rx_handle(struct virtio_bluetooth *vbt, struct sk_buff *skb)if (skb->len < min_hdr) {bt_dev_err_ratelimited (vbt->hdev, -"rx pkt_type 0x%02x payload %u < hdr %zu\n" , +"rx pkt_type 0x%02x payload %u < hdr %zu" , pkt_type, skb->len, min_hdr);kfree_skb (skb);return ;
@@ -251,7 +251,7 @@ static void virtbt_rx_work(struct work_struct *work)if (!len || len >VIRTBT_RX_BUF_SIZE ) {bt_dev_err_ratelimited (vbt->hdev, -"rx reply len %u outside [1, %u]\n" , +"rx reply len %u outside [1, %u]" , len,VIRTBT_RX_BUF_SIZE );kfree_skb (skb); }else {
include/net/bluetooth/bluetooth.h +2 -2
@@ -290,9 +290,9 @@ void bt_err_ratelimited(const char *fmt, ...); BT_DBG("%s: " fmt, bt_dev_name(hdev), ##__VA_ARGS__)#define bt_dev_warn_ratelimited (hdev, fmt, ...) \ - bt_warn_ratelimited("%s: " fmt, bt_dev_name(hdev), ##__VA_ARGS__) + bt_warn_ratelimited("%s: " fmt "\n", bt_dev_name(hdev), ##__VA_ARGS__)#define bt_dev_err_ratelimited (hdev, fmt, ...) \ - bt_err_ratelimited("%s: " fmt, bt_dev_name(hdev), ##__VA_ARGS__) + bt_err_ratelimited("%s: " fmt "\n", bt_dev_name(hdev), ##__VA_ARGS__)/* Connection and socket states */ enum bt_sock_state {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1539/2151 Bluetooth: hci_core: Keep RCU protection through LTK filtering
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit 817cbcab91fe870e5b69c835cbd708242c9f8c8e ]
The LTK selected by hci_find_ltk() must remain allocated while its value is checked against the blocked-key list. The finder releases RCU before passing k->val to hci_is_blocked_key(). The helper's own RCU section protects the blocked-key list, but the selected LTK may already have been reclaimed before that section starts.
An LE ATT socket security request can reach smp_ltk_encrypt() without holding hdev->lock. With a matching stored LTK and an LTK-type blocked-key entry present, a concurrent MGMT_OP_LOAD_LONG_TERM_KEYS can remove the selected LTK in the following order:
Socket security Management / RCU reclamation
hci_find_ltk()
rcu_read_lock()
select k
rcu_read_unlock()
load_long_term_keys()
hci_dev_lock(hdev)
hci_smp_ltks_clear(hdev)
list_del_rcu(&k->list)
kfree_rcu(k, rcu)
grace period ends; k is freed
hci_is_blocked_key(..., k->val)
memcmp(b->val, val, ...)The final comparison reads freed LTK bytes. Entering a new RCU section in hci_is_blocked_key() cannot protect a pointer obtained before the completed grace period.
Keep the finder's RCU read-side section active through the blocked-key comparison and the warning that reads k->bdaddr. Release it before returning on either matched-key path. This delays reclamation until the finder has finished using the selected record, following the existing IRK lookup pattern.
KFENCE report as below:
==================================================================
BUG: KFENCE: use-after-free read in hci_is_blocked_key+0xdf/0x240
Use-after-free read at 0x00000000b9ee38e4 (in kfence-#249):
hci_is_blocked_key+0xdf/0x240
blocked_key_wrapper+0xc5/0x140 [pmbd_ltk_probe]
hci_find_ltk+0x1aa/0x3e0
smp_ltk_encrypt.isra.0+0xad/0x340
smp_conn_security+0x3b8/0x8c0
l2cap_sock_setsockopt+0x1c4b/0x2270
do_sock_setsockopt+0x1fb/0x430
__sys_setsockopt+0x106/0x180
__x64_sys_setsockopt+0xc2/0x160
do_syscall_64+0x115/0x6a0
entry_SYSCALL_64_after_hwframe+0x77/0x7f
kfence-#249: 0x00000000121f2ad9-0x000000005b5bfb3d, size=72, cache=kmalloc-96
allocated by task 495 on cpu 0 at 36.722380s (2.603973s ago):
hci_add_ltk+0x1f5/0x3a0
load_long_term_keys+0x6d0/0x860
hci_sock_sendmsg+0x128b/0x22e0
__sys_sendto+0x425/0x470
__x64_sys_sendto+0xe5/0x1c0
do_syscall_64+0x115/0x6a0
entry_SYSCALL_64_after_hwframe+0x77/0x7f
freed by task 533 on cpu 0 at 36.993097s (2.339769s ago):
__rcu_free_sheaf_prepare+0x261/0x2a0
rcu_free_sheaf+0x1f/0xe0
rcu_core+0x661/0x1d10
handle_softirqs+0x201/0x930
__irq_exit_rcu+0x110/0x1e0
irq_exit_rcu+0xe/0x20
sysvec_apic_timer_interrupt+0x6c/0x80
asm_sysvec_apic_timer_interrupt+0x1a/0x20
srso_alias_return_thunk+0x0/0xfbef5
__asan_memcpy+0x23/0x60
create_monitor_ctrl_event+0x1a2/0x460
mgmt_cmd_complete+0x2da/0x580
load_long_term_keys+0x741/0x860
hci_sock_sendmsg+0x128b/0x22e0
__sys_sendto+0x425/0x470
__x64_sys_sendto+0xe5/0x1c0
do_syscall_64+0x115/0x6a0
entry_SYSCALL_64_after_hwframe+0x77/0x7f
CPU: 1 UID: 0 PID: 495 Comm: python3 Tainted: G O 7.2.0-rc6-pmb-bt-functional-v1+ #1 PREEMPT(lazy)
Tainted: [O]=OOT_MODULE
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
==================================================================--- net/bluetooth/hci_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/bluetooth/hci_core.c +2 -2
@@ -1189,16 +1189,16 @@ struct smp_ltk *hci_find_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr,continue ;if (smp_ltk_is_sc (k) ||ltk_role (k->type) == role) { -rcu_read_unlock (); -if (hci_is_blocked_key (hdev,HCI_BLOCKED_KEY_TYPE_LTK , k->val)) {bt_dev_warn_ratelimited (hdev,"LTK blocked for %pMR" , &k->bdaddr); +rcu_read_unlock ();return NULL ; } +rcu_read_unlock ();return k; } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1540/2151 Bluetooth: hci_sync: Serialize devcoredump reset during device open
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit 6d91353f6dbcc5c4fbb47bbd0c7f885453cfc939 ]
An ACTIVE devcoredump's buffer cursors must remain valid from the packet handler's state check through its copy. hci_devcd_rx() holds hdev->lock across that interval, and hci_devcd_reset() requires the same lock. However, hci_dev_open_sync() invokes reset without taking it.
A registered VHCI controller can collect a dump through its debugfs interface while the controller is down. If a successful open overlaps with handling a nonempty dump packet, reset can run after the receiver's ACTIVE check and before its copy:
hci_devcd_rx() hci_dev_open_sync()
dequeue nonempty skb
hci_dev_lock(hdev)
handler observes ACTIVE
hdev->open(hdev) succeeds hci_devcd_reset(hdev)
dump.tail = NULL dump.state = IDLE
hci_devcd_copy()
compare against old dump.end
memcpy(NULL, ..., skb->len)
hci_dev_unlock(hdev)
Reset leaves dump.end pointing at the old buffer and purges only queued packets, so it cannot discard the skb already dequeued by the receiver. The bounds check can pass with a NULL tail, leading to a nonempty copy to address zero. KASAN reported a 24-byte NULL write in hci_devcd_rx().
Take hdev->lock around the open-time reset. The receiver then finishes its state check and copy using valid cursors before reset, or observes IDLE after reset and skips the copy.
KASAN report as below:
BUG: KASAN: null-ptr-deref in hci_devcd_rx+0x5d5/0x1a80
Write of size 24 at addr 0000000000000000 by task kworker/u17:0/496
CPU: 0 UID: 0 PID: 496 Comm: kworker/u17:0 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
Workqueue: hci0 hci_devcd_rx
Call Trace:
<TASK>
dump_stack_lvl+0x93/0xd0
kasan_report+0xe0/0x110
? hci_devcd_rx+0x5d5/0x1a80
kasan_check_range+0x105/0x1b0
__asan_memcpy+0x3c/0x60
hci_devcd_rx+0x5d5/0x1a80
? srso_alias_return_thunk+0x5/0xfbef5
? __pfx_hci_devcd_rx+0x10/0x10
? srso_alias_return_thunk+0x5/0xfbef5
? lock_release+0xc8/0x280
? srso_alias_return_thunk+0x5/0xfbef5
process_one_work+0x908/0x19c0
? __pfx_process_one_work+0x10/0x10
? srso_alias_return_thunk+0x5/0xfbef5
? lock_is_held_type+0x8f/0x100
? srso_alias_return_thunk+0x5/0xfbef5
worker_thread+0x65c/0xe40
? __pfx_worker_thread+0x10/0x10
kthread+0x34f/0x460
? srso_alias_return_thunk+0x5/0xfbef5
? __pfx_kthread+0x10/0x10
ret_from_fork+0x659/0x940
? __pfx_ret_from_fork+0x10/0x10
? srso_alias_return_thunk+0x5/0xfbef5
? __switch_to+0x74f/0xf80
? __pfx_kthread+0x10/0x10
ret_from_fork_asm+0x1a/0x30
</TASK>
==================================================================
Disabling lock debugging due to kernel taint--- net/bluetooth/hci_sync.c | 2 ++ 1 file changed, 2 insertions(+)
net/bluetooth/hci_sync.c +2 -0
@@ -5347,7 +5347,9 @@ int hci_dev_open_sync(struct hci_dev *hdev) goto done; } +hci_dev_lock (hdev);hci_devcd_reset (hdev); +hci_dev_unlock (hdev);set_bit (HCI_RUNNING , &hdev->flags);hci_sock_dev_event (hdev,HCI_DEV_OPEN );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1541/2151 Bluetooth: ISO: Hold the listener during disconnect notification
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit b4a00dedc5cc6f6f98c07ec1b54d24a817d9fc88 ]
An ISO listener must remain alive until a queued child's disconnect notification completes. bt_accept_enqueue() retains only the child and stores a raw parent pointer; iso_conn_ready() drops its temporary listener reference after setup. iso_chan_del() saves that pointer, unlinks the child and then calls parent->sk_data_ready() without holding a listener reference.
With an incoming CIS child still queued, disconnect and listener release can proceed in this order:
HCI disconnect Listener release
iso_conn_del(): lock child
iso_chan_del(): save parent bt_accept_unlink(child)
iso_sock_cleanup_listen():
drain empty accept queue
iso_sock_release():
orphan and kill listener final sock_put(listener)
parent->sk_data_ready(parent)
After unlink, listener cleanup no longer has to take the child socket lock. The listener can therefore be freed before iso_chan_del() reads sk_data_ready, causing a use-after-free.
Take a temporary parent reference before bt_accept_unlink() and drop it after the notification. The child lock excludes accept dequeue while the child is still queued, so listener cleanup cannot complete before sock_hold(). The reference then keeps the listener alive across unlink and through the callback without changing lock order.
KASAN report as below:
==================================================================
BUG: KASAN: slab-use-after-free in iso_chan_del+0x302/0x320
Read of size 8 at addr ffff888105ca2188 by task kworker/2:1/50
CPU: 2 UID: 0 PID: 50 Comm: kworker/2:1 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
Workqueue: events iso_fixture_disconnect_work
Call Trace:
<TASK>
dump_stack_lvl+0x93/0xd0
print_report+0xce/0x630
? iso_chan_del+0x302/0x320
? srso_alias_return_thunk+0x5/0xfbef5
? __virt_addr_valid+0x20d/0x410
? iso_chan_del+0x302/0x320
kasan_report+0xe0/0x110
? iso_chan_del+0x302/0x320
iso_chan_del+0x302/0x320
iso_conn_del+0x19d/0x3c0
? __pfx_iso_disconn_cfm+0x10/0x10
iso_disconn_cfm+0x78/0x120
hci_disconn_complete_evt+0x319/0xa30
? find_held_lock+0x2b/0x80
hci_test_iso_disconn_event+0x85/0xb0
? __pfx_hci_test_iso_disconn_event+0x10/0x10
? srso_alias_return_thunk+0x5/0xfbef5
? srso_alias_return_thunk+0x5/0xfbef5
? _raw_read_unlock+0x23/0x40
? srso_alias_return_thunk+0x5/0xfbef5
? __hci_dev_get+0x15d/0x280
iso_fixture_disconnect_work+0x67/0x290
process_one_work+0x908/0x19c0
? __pfx_process_one_work+0x10/0x10
? srso_alias_return_thunk+0x5/0xfbef5
? lock_is_held_type+0x8f/0x100
? srso_alias_return_thunk+0x5/0xfbef5
worker_thread+0x65c/0xe40
? srso_alias_return_thunk+0x5/0xfbef5
? __kthread_parkme+0x175/0x220
? srso_alias_return_thunk+0x5/0xfbef5
? __pfx_worker_thread+0x10/0x10
kthread+0x34f/0x460
? srso_alias_return_thunk+0x5/0xfbef5
? __pfx_kthread+0x10/0x10
ret_from_fork+0x659/0x940
? __pfx_ret_from_fork+0x10/0x10
? srso_alias_return_thunk+0x5/0xfbef5
? __switch_to+0x74f/0xf80
? __pfx_kthread+0x10/0x10
ret_from_fork_asm+0x1a/0x30
</TASK>
Allocated by task 521:
kasan_save_stack+0x33/0x60
kasan_save_track+0x14/0x30
__kasan_kmalloc+0xaa/0xb0
__kmalloc_noprof+0x2d7/0x770
sk_prot_alloc+0x13e/0x260
sk_alloc+0x37/0xb40
bt_sock_alloc+0x40/0x3b0
iso_sock_alloc.constprop.0+0x3a/0x360
iso_sock_create+0xc7/0x160
bt_sock_create+0x171/0x330
__sock_create+0x2c4/0x730
__sys_socket+0x141/0x210
__x64_sys_socket+0x77/0xc0
do_syscall_64+0x115/0x6a0
entry_SYSCALL_64_after_hwframe+0x77/0x7f
Freed by task 521:
kasan_save_stack+0x33/0x60
kasan_save_track+0x14/0x30
kasan_save_free_info+0x3b/0x60
__kasan_slab_free+0x5f/0x80
kfree+0x307/0x580
__sk_destruct+0x64f/0x790
sk_destruct+0xb3/0xd0
__sk_free+0xdd/0x370
sk_free+0x51/0x80
iso_sock_release+0x46d/0x5b0
__sock_release+0xb8/0x270
sock_close+0x21/0x30
__fput+0x39f/0xa60
task_work_run+0x144/0x230
do_exit+0x834/0x2830
do_group_exit+0xc7/0x280
get_signal+0x20a9/0x2400
arch_do_signal_or_restart+0x94/0x6f0
exit_to_user_mode_loop+0xcf/0x570
do_syscall_64+0x4f0/0x6a0
entry_SYSCALL_64_after_hwframe+0x77/0x7f
The buggy address belongs to the object at ffff888105ca2000
which
belongs to the cache kmalloc-2k of size
2048
The buggy address is located 392 bytes inside of
freed
2048-byte region [ffff888105ca2000,
ffff888105ca2800)
The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000
index:0xffff888105ca5000 pfn:0x105ca0
head: order:3 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0
flags: 0x200000000000240(workingset|head|node=0|zone=2)
page_type: f5(slab)
raw: 0200000000000240 ffff888100042f00 ffffea00042cd010
ffffea00042c9210
raw: ffff888105ca5000 0000000000080005 00000000f5000000
0000000000000000
head: 0200000000000240 ffff888100042f00 ffffea00042cd010
ffffea00042c9210
head: ffff888105ca5000 0000000000080005 00000000f5000000
0000000000000000
head: 0200000000000003 fffffffffffffe01 00000000ffffffff
00000000ffffffff
head: ffff888105ca1000 0000000000000000 00000000ffffffff
0000000000000000
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff888105ca2080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888105ca2100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888105ca2180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff888105ca2200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888105ca2280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================--- net/bluetooth/iso.c | 3 +++ 1 file changed, 3 insertions(+)
net/bluetooth/iso.c +3 -0
@@ -257,8 +257,11 @@ static void iso_chan_del(struct sock *sk, int err) parent =bt_sk (sk)->parent;if (parent) { +/* Unlinking the child allows the parent to be freed. */ +sock_hold (parent);bt_accept_unlink (sk); parent->sk_data_ready (parent); +sock_put (parent); }else { sk->sk_state_change (sk); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1542/2151 Bluetooth: MGMT: Reject quality report requests during unregister
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit 213e7a99bea19e2f29f394321b86c792eec73a24 ]
A quality report request must not call a driver callback after its module text has been released. hci_mgmt_cmd() holds an hci_dev reference through set_exp_feature(), but that reference only preserves the device allocation. set_quality_report_func() takes req_lock and invokes hdev->set_quality_report without checking HCI_UNREGISTER.
This is unsafe when a SET_EXP_FEATURE request for an Intel controller would change HCI_QUALITY_REPORT and is delayed before taking req_lock while the controller is removed. With btintel_pcie and btintel built as modules and no other btintel dependents, the following order is possible:
Management request Removal and module unload
------------------ -------------------------
hci_mgmt_cmd(): retain hdev
hci_unregister_dev():
set HCI_UNREGISTER remove hdev from lookup close under req_lock release req_lock
btintel_pcie_remove(): return unload btintel_pcie, then btintel
set_quality_report_func():
take req_lock
call hdev->set_quality_reportWhen the request resumes after btintel unload, the indirect call targets released module text and can cause an instruction-fetch page fault. The close operation serializes with a running callback but does not prevent a delayed management handler from invoking it afterwards.
Check HCI_UNREGISTER immediately after acquiring the existing req_lock and return MGMT_STATUS_INVALID_INDEX via the common unlock path. If unregister passed its close section first, the request now rejects the removed controller before accessing the callback. If the request passes the check first, hci_dev_do_close() must wait for req_lock until the callback has returned, so unregister cannot finish before the use.
Oops report as below:
BUG: unable to handle page fault for address: ffffffffc0408e10
#PF: supervisor instruction fetch in kernel mode
#PF: error_code(0x0010) - not-present page
PGD 80a9067 P4D 80a9067 PUD 80ab067 PMD 0
Oops: Oops: 0010 [#1] SMP KASAN NOPTI
CPU: 1 UID: 0 PID: 439 Comm: btmgmt Tainted: G O 7.2.0-rc6-pmb-bt-functional-v1+ #1 PREEMPT(lazy)
Tainted: [O]=OOT_MODULE
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:0xffffffffc0408e10
Code: Unable to access opcode bytes at 0xffffffffc0408de6.
RSP: 0018:ffff888110927838 EFLAGS: 00010293
RAX: 0000000000000000 RBX: 1ffff11022124f0c RCX: ffffffff85b1a1b6
RDX: ffff888117511d00 RSI: 0000000000000001 RDI: ffff888117598000
RBP: ffff888110927950 R08: 0000000000000001 R09: 0000000000000001
R10: ffffffff893d3057 R11: ffff888117511d00 R12: ffff888117598000
R13: 0000000000000001 R14: ffffffffc0408e10 R15: ffff888117599970
FS: 00007f15453f2040(0000) GS:ffff8881fd852000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: ffffffffc0408de6 CR3: 000000010b832005 CR4: 0000000000770ef0
PKRU: 55555554
Call Trace:
<TASK>
? set_quality_report_func+0x232/0x660
? __pfx_set_quality_report_func+0x10/0x10
? pmbd_gate_maybe+0x47/0x60
? srso_alias_return_thunk+0x5/0xfbef5
? pmbd_probe_hit_cookie+0xe7/0x1c0
? srso_alias_return_thunk+0x5/0xfbef5
? pmbd_probe_hit_cookie+0xee/0x1c0
set_exp_feature+0xf7/0x260
? set_exp_feature+0xf7/0x260
? hci_sock_sendmsg+0x12b2/0x2400
? __pfx_hci_sock_sendmsg+0x10/0x10
? srso_alias_return_thunk+0x5/0xfbef5
? selinux_socket_sendmsg+0x160/0x280
? sock_write_iter+0x4c0/0x550
? __pfx_hci_sock_sendmsg+0x10/0x10
? __pfx_sock_write_iter+0x10/0x10
? __file_has_perm+0x25e/0x420
? __pfx___file_has_perm+0x10/0x10
? do_iter_readv_writev+0x59c/0x860
? __pfx_do_iter_readv_writev+0x10/0x10
? srso_alias_return_thunk+0x5/0xfbef5
? security_file_permission+0x26/0x80
? vfs_writev+0x30e/0xc10
? __pfx_vfs_writev+0x10/0x10
? __pfx_do_epoll_wait+0x10/0x10
? __pfx_do_epoll_ctl+0x10/0x10
? do_writev+0x241/0x2f0
? srso_alias_return_thunk+0x5/0xfbef5
? do_writev+0x241/0x2f0
? __pfx_do_writev+0x10/0x10
? irqentry_exit+0xbe/0x820
? do_syscall_64+0x115/0x6a0
? entry_SYSCALL_64_after_hwframe+0x77/0x7f
</TASK>
Modules linked in: [last unloaded: btintel(O)]
CR2: ffffffffc0408e10
---[ end trace 0000000000000000 ]---
RIP: 0010:0xffffffffc0408e10
Code: Unable to access opcode bytes at 0xffffffffc0408de6.
RSP: 0018:ffff888110927838 EFLAGS: 00010293
RAX: 0000000000000000 RBX: 1ffff11022124f0c RCX: ffffffff85b1a1b6
RDX: ffff888117511d00 RSI: 0000000000000001 RDI: ffff888117598000
RBP: ffff888110927950 R08: 0000000000000001 R09: 0000000000000001
R10: ffffffff893d3057 R11: ffff888117511d00 R12: ffff888117598000
R13: 0000000000000001 R14: ffffffffc0408e10 R15: ffff888117599970
FS: 00007f15453f2040(0000) GS:ffff8881fd852000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: ffffffffc0408de6 CR3: 000000010b832005 CR4: 0000000000770ef0
PKRU: 55555554
Kernel panic - not syncing: Fatal exception
Kernel Offset: disabled
Rebooting in 1 seconds..--- net/bluetooth/mgmt.c | 7 +++++++ 1 file changed, 7 insertions(+)
net/bluetooth/mgmt.c +7 -0
@@ -4901,6 +4901,13 @@ static int set_quality_report_func(struct sock *sk, struct hci_dev *hdev,hci_req_sync_lock (hdev); +if (hci_dev_test_flag (hdev,HCI_UNREGISTER )) { + err =mgmt_cmd_status (sk, hdev->id, +MGMT_OP_SET_EXP_FEATURE , +MGMT_STATUS_INVALID_INDEX ); + goto unlock_quality_report; + } + val = !!cp->param[0 ]; changed = (val !=hci_dev_test_flag (hdev,HCI_QUALITY_REPORT ));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1543/2151 Bluetooth: msft: Lock failed probe cleanup against feature readers
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit 21895f20fedc4504474bcb1022850b532ea4358e ]
The MSFT data must remain allocated while msft_get_features() reads its features. read_adv_mon_features() protects that access with hdev->lock, but msft_do_open() clears hdev->msft_data and frees the object without that lock when read_supported_features() fails.
After a successful probe, the data survives a normal close. A later open can fail the probe while a management feature request is running. hci_mgmt_cmd() permits requests during HCI_INIT, and the opener's hdev->req_lock does not serialize the management reader:
Management feature request HCI open
hold hdev->req_lock
msft_do_open()
hold hdev->lock
msft_get_features(): save msft
read_supported_features() fails
hdev->msft_data = NULL
kfree(msft) read msft->features
release hdev->lock release hdev->req_lock
The saved pointer then refers to freed memory, causing a use-after-free read. Advertisement reporting through mgmt_device_found() also reads the features with hdev->lock held.
Take hdev->lock around clearing and freeing msft_data in the failure branch. An existing feature reader finishes before the free, while a reader starting after cleanup sees NULL. Keep the synchronous probe outside this critical section, following the existing req_lock to hdev->lock ordering.
KASAN report as below:
==================================================================
BUG: KASAN: slab-use-after-free in msft_monitor_supported+0xa9/0xb0
Read of size 8 at addr ffff88811573ee00 by task mgmt-read-adv-m/532
CPU: 2 UID: 0 PID: 532 Comm: mgmt-read-adv-m 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
Call Trace:
<TASK>
dump_stack_lvl+0x93/0xd0
print_report+0xce/0x630
? msft_monitor_supported+0xa9/0xb0
? srso_alias_return_thunk+0x5/0xfbef5
? __virt_addr_valid+0x20d/0x410
? msft_monitor_supported+0xa9/0xb0
kasan_report+0xe0/0x110
? msft_monitor_supported+0xa9/0xb0
msft_monitor_supported+0xa9/0xb0
read_adv_mon_features+0xdf/0x640
? trace_hardirqs_on+0x18/0x160
? srso_alias_return_thunk+0x5/0xfbef5
? __pfx_read_adv_mon_features+0x10/0x10
? srso_alias_return_thunk+0x5/0xfbef5
? srso_alias_return_thunk+0x5/0xfbef5
? do_raw_read_unlock+0x49/0xe0
? srso_alias_return_thunk+0x5/0xfbef5
? _raw_read_unlock+0x23/0x40
hci_sock_sendmsg+0x12b5/0x2270
? __pfx_hci_sock_sendmsg+0x10/0x10
? srso_alias_return_thunk+0x5/0xfbef5
? selinux_socket_sendmsg+0x160/0x280
__sys_sendto+0x425/0x470
? __pfx_hci_sock_sendmsg+0x10/0x10
? __pfx___sys_sendto+0x10/0x10
? srso_alias_return_thunk+0x5/0xfbef5
? srso_alias_return_thunk+0x5/0xfbef5
? srso_alias_return_thunk+0x5/0xfbef5
? __sys_setsockopt+0x119/0x180
__x64_sys_sendto+0xe5/0x1c0
? lockdep_hardirqs_on_prepare+0xea/0x1a0
? srso_alias_return_thunk+0x5/0xfbef5
? trace_hardirqs_on+0x18/0x160
do_syscall_64+0x115/0x6a0
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f9ceb04a687
Code: 48 89 fa 4c 89 df e8 58 b3 00 00 8b 93 08 03 00 00 59 5e 48
83 f8 fc 74 1a 5b c3 0f 1f 84 00 00 00 00 00 48 8b 44 24 10 0f 05 <5b>
c3 0f 1f 80 00 00 00 00 83 e2 39 83 fa 08 75 de e8 23 ff ff ff
RSP: 002b:00007ffe6ab96a70 EFLAGS: 00000202 ORIG_RAX: 000000000000002c
RAX: ffffffffffffffda RBX: 00007f9ceafb8780 RCX: 00007f9ceb04a687
RDX: 0000000000000006 RSI: 00007ffe6ab96aea RDI: 0000000000000003
RBP: 0000000000000002 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000202 R12: 0000000000000003
R13: 00007ffe6ab96d50 R14: 00007f9ceb1f6000 R15: 00005625e427dd68
</TASK>
Allocated by task 506:
kasan_save_stack+0x33/0x60
kasan_save_track+0x14/0x30
__kasan_kmalloc+0xaa/0xb0
__kmalloc_cache_noprof+0x251/0x610
msft_register+0x54/0x260
hci_register_dev+0x6b7/0xc80
__vhci_create_device+0x330/0x840
vhci_write+0x287/0x440
vfs_write+0x637/0x1010
ksys_write+0x111/0x200
do_syscall_64+0x115/0x6a0
entry_SYSCALL_64_after_hwframe+0x77/0x7f
Freed by task 529:
kasan_save_stack+0x33/0x60
kasan_save_track+0x14/0x30
kasan_save_free_info+0x3b/0x60
__kasan_slab_free+0x5f/0x80
kfree+0x307/0x580
msft_do_open+0x604/0x9e0
hci_dev_open_sync+0x94a/0x2110
hci_dev_do_open+0x2f/0xb0
hci_dev_open+0x17d/0x300
hci_sock_ioctl+0x3c6/0x710
sock_do_ioctl+0x120/0x2b0
sock_ioctl+0x41b/0x670
__x64_sys_ioctl+0x163/0x1d0
do_syscall_64+0x115/0x6a0
entry_SYSCALL_64_after_hwframe+0x77/0x7f
The buggy address belongs to the object at ffff88811573ee00
which belongs to the cache kmalloc-256 of size 256
The buggy address is located 0 bytes inside of
freed 256-byte region [ffff88811573ee00, ffff88811573ef00)
The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0
pfn:0x11573e
head: order:1 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0
flags: 0x200000000000040(head|node=0|zone=2)
page_type: f5(slab)
raw: 0200000000000040 ffff888100042b40 dead000000000100
dead000000000122
raw: 0000000000000000 0000000000100010 00000000f5000000
0000000000000000
head: 0200000000000040 ffff888100042b40 dead000000000100
dead000000000122
head: 0000000000000000 0000000000100010 00000000f5000000
0000000000000000
head: 0200000000000001 ffffffffffffff81 00000000ffffffff
00000000ffffffff
head: 0000000000000000 0000000000000000 00000000ffffffff
0000000000000000
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff88811573ed00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff88811573ed80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff88811573ee00: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88811573ee80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88811573ef00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================--- net/bluetooth/msft.c | 2 ++ 1 file changed, 2 insertions(+)
net/bluetooth/msft.c +2 -0
@@ -654,8 +654,10 @@ void msft_do_open(struct hci_dev *hdev) msft->features =0 ;if (!read_supported_features (hdev, msft)) { +hci_dev_lock (hdev); hdev->msft_data =NULL ;kfree (msft); +hci_dev_unlock (hdev);return ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1544/2151 Bluetooth: 6lowpan: Drain RCU readers on registration failure
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit ebba800d140b580540ad55f670d943e4a7edaffd ]
A lowpan_btle_dev is embedded in its net_device allocation and must remain alive until readers of bt_6lowpan_devices have left their RCU sections. setup_netdev() publishes it before registration, but its error path only unlinks it before calling free_netdev().
If a second controller's registration fails while multicast is sent on an existing 6LoWPAN interface, send_mcast_pkt() can already have selected the new entry. It reads entry->netdev before checking which interface owns it. An early failure, such as allocating the device's name node, leaves NETREG_UNINITIALIZED, so free_netdev() releases the storage immediately.
The following ordering frees the selected entry before the reader loads its netdev field:
Adapter creation (controller B) Multicast on controller A
setup_netdev()
list_add_rcu()
rcu_read_lock()
select B's entry
lowpan_register_netdev() fails
list_del_rcu()
free_netdev()
read entry->netdev
rcu_read_unlock()Removing the list node does not wait for that reader, and devices_lock does not serialize the multicast reader. The subsequent field load is a use-after-free, reported by KASAN in bt_xmit().
Wait for an RCU grace period after dropping devices_lock and before free_netdev(). This keeps the failed adapter allocated until traversals that could have selected it complete. The callback is already sleepable, and the wait happens outside the list spinlock.
KASAN report as below:
==================================================================
BUG: KASAN: slab-use-after-free in bt_xmit+0x1d06/0x21e0
Read of size 8 at addr ffff88810ef45030 by task python3/556
Call Trace:
<TASK>
dump_stack_lvl+0x93/0xd0
print_report+0xce/0x630
? bt_xmit+0x1d06/0x21e0
? srso_alias_return_thunk+0x5/0xfbef5
? __virt_addr_valid+0x20d/0x410
? bt_xmit+0x1d06/0x21e0
kasan_report+0xe0/0x110
? bt_xmit+0x1d06/0x21e0
bt_xmit+0x1d06/0x21e0
? __pfx_bt_xmit+0x10/0x10
? srso_alias_return_thunk+0x5/0xfbef5
? lock_acquire+0x17b/0x2f0
? srso_alias_return_thunk+0x5/0xfbef5
? lock_is_held_type+0x8f/0x100
? dev_hard_start_xmit+0x187/0x660
? __pfx_bt_xmit+0x10/0x10
dev_hard_start_xmit+0x187/0x660
sch_direct_xmit+0x153/0x850
? srso_alias_return_thunk+0x5/0xfbef5
? __pfx_sch_direct_xmit+0x10/0x10
? do_raw_spin_lock+0x130/0x270
? __pfx_do_raw_spin_lock+0x10/0x10
? lock_is_held_type+0x8f/0x100
__dev_queue_xmit+0x3111/0x3aa0
? srso_alias_return_thunk+0x5/0xfbef5
? look_up_lock_class+0x59/0x130
? register_lock_class+0x41/0x790
? __pfx___dev_queue_xmit+0x10/0x10
? __lock_acquire+0x466/0x2260
? find_held_lock+0x2b/0x80
? ___neigh_create+0x1690/0x2540
? __local_bh_enable_ip+0xa6/0x120
? srso_alias_return_thunk+0x5/0xfbef5
? lockdep_hardirqs_on_prepare+0xea/0x1a0
? srso_alias_return_thunk+0x5/0xfbef5
? lock_acquire+0x17b/0x2f0
? srso_alias_return_thunk+0x5/0xfbef5
? find_held_lock+0x2b/0x80
? ip6_finish_output2+0x8be/0x1840
? srso_alias_return_thunk+0x5/0xfbef5
? neigh_connected_output+0x39f/0x4e0
? srso_alias_return_thunk+0x5/0xfbef5
neigh_connected_output+0x33f/0x4e0
ip6_finish_output2+0x8be/0x1840
ip6_finish_output+0x424/0xd50
ip6_output+0x210/0x640
? __pfx_ip6_mr_output+0x10/0x10
ip6_local_out+0x193/0x1c0
ip6_send_skb+0xfb/0x3e0
udp_v6_send_skb+0x6e1/0x1180
udpv6_sendmsg+0x1f9b/0x2a00
? get_random_u32+0xaf/0x640
? __pfx_udpv6_sendmsg+0x10/0x10
? lock_release+0xc8/0x280
? srso_alias_return_thunk+0x5/0xfbef5
? lockdep_hardirqs_on_prepare+0xea/0x1a0
? srso_alias_return_thunk+0x5/0xfbef5
? trace_hardirqs_on+0x18/0x160
? srso_alias_return_thunk+0x5/0xfbef5
? __local_bh_enable_ip+0xa6/0x120
? srso_alias_return_thunk+0x5/0xfbef5
? __pfx_udpv6_sendmsg+0x10/0x10
? inet6_sendmsg+0xff/0x140
inet6_sendmsg+0xff/0x140
__sys_sendto+0x320/0x470
? __pfx___sys_sendto+0x10/0x10
? exc_page_fault+0x5c/0xc0
? srso_alias_return_thunk+0x5/0xfbef5
? lock_release+0xc8/0x280
? handle_mm_fault+0x12e/0x580
__x64_sys_sendto+0xe5/0x1c0
? lockdep_hardirqs_on_prepare+0xea/0x1a0
? srso_alias_return_thunk+0x5/0xfbef5
? trace_hardirqs_on+0x18/0x160
do_syscall_64+0x115/0x6a0
entry_SYSCALL_64_after_hwframe+0x77/0x7f
Allocated by task 502:
kasan_save_stack+0x33/0x60
kasan_save_track+0x14/0x30
__kasan_kmalloc+0xaa/0xb0
__kvmalloc_node_noprof+0x353/0x930
alloc_netdev_mqs+0xa0/0x1250
chan_ready_cb+0x198/0x1110
l2cap_recv_frame+0x6dc0/0x8830
l2cap_recv_acldata+0xe9f/0x10e0
hci_rx_work+0x5a6/0xf00
process_one_work+0x908/0x19c0
worker_thread+0x65c/0xe40
kthread+0x34f/0x460
ret_from_fork+0x659/0x940
ret_from_fork_asm+0x1a/0x30
Freed by task 502:
kasan_save_stack+0x33/0x60
kasan_save_track+0x14/0x30
kasan_save_free_info+0x3b/0x60
__kasan_slab_free+0x5f/0x80
kfree+0x307/0x580
free_netdev+0x6ca/0x8f0
chan_ready_cb+0xd91/0x1110
l2cap_recv_frame+0x6dc0/0x8830
l2cap_recv_acldata+0xe9f/0x10e0
hci_rx_work+0x5a6/0xf00
process_one_work+0x908/0x19c0
worker_thread+0x65c/0xe40
kthread+0x34f/0x460
ret_from_fork+0x659/0x940
ret_from_fork_asm+0x1a/0x30
The buggy address belongs to the object at ffff88810ef44000
which
belongs to the cache kmalloc-8k of size
8192
The buggy address is located 4144 bytes inside of
freed
8192-byte region [ffff88810ef44000,
ffff88810ef46000)
The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0
pfn:0x10ef40
head: order:3 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0
flags: 0x200000000000040(head|node=0|zone=2)
page_type: f5(slab)
raw: 0200000000000040 ffff888100043180 dead000000000100
dead000000000122
raw: 0000000000000000 0000000000020002 00000000f5000000
0000000000000000
head: 0200000000000040 ffff888100043180 dead000000000100
dead000000000122
head: 0000000000000000 0000000000020002 00000000f5000000
0000000000000000
head: 0200000000000003 fffffffffffffe01 00000000ffffffff
00000000ffffffff
head: ffff88810ef41a80 0000000000000000 00000000ffffffff
0000000000000000
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff88810ef44f00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88810ef44f80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88810ef45000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88810ef45080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88810ef45100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
Disabling lock debugging due to kernel taint--- net/bluetooth/6lowpan.c | 1 + 1 file changed, 1 insertion(+)
net/bluetooth/6lowpan.c +1 -0
@@ -706,6 +706,7 @@ static int setup_netdev(struct l2cap_chan *chan, struct lowpan_btle_dev **dev)spin_lock (&devices_lock);list_del_rcu (&(*dev)->list);spin_unlock (&devices_lock); +synchronize_rcu ();free_netdev (netdev); goto out; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1545/2151 Bluetooth: btmtk: fix skb double free on ISO padding failure
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 491d2212ea0f0f6a3abbd67729df0c6a3ec9c58a ]
btmtk_isopkt_pad() uses skb_pad(), which frees the skb on failure.
The error is propagated by alloc_mtk_intr_urb() and btusb_send_frame_mtk() up to hci_send_frame(), which frees the skb a second time:
err = hdev->send(hdev, skb);
if (err < 0) {
bt_dev_err(hdev, "sending frame failed (%d)", err);
kfree_skb(skb);
return err;
}Use __skb_put_padto(skb, MTK_ISO_THRESHOLD, false) so that the skb is left to the caller on error. This also replaces the open-coded skb_pad() + __skb_put() sequence.
--- drivers/bluetooth/btmtk.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/bluetooth/btmtk.c +2 -6
@@ -1081,12 +1081,8 @@ static int btmtk_isopkt_pad(struct hci_dev *hdev, struct sk_buff *skb)if (skb->len >MTK_ISO_THRESHOLD )return -EINVAL ; -if (skb_pad (skb,MTK_ISO_THRESHOLD - skb->len)) -return -ENOMEM ; - -__skb_put (skb,MTK_ISO_THRESHOLD - skb->len); - -return 0 ; +/* On error, the skb is freed by hci_send_frame(). */ +return __skb_put_padto (skb,MTK_ISO_THRESHOLD , false); }static int __set_mtk_intr_interface (struct hci_dev *hdev)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1546/2151 Bluetooth: hci_sync: Protect IRK identity reads with RCU
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit 4b76fa362110cf1b74a0263c14406b71de99894c ]
hci_le_set_privacy_mode_sync() needs the IRK returned by hci_find_irk_by_addr() to remain allocated until its identity address and type have been copied into the command. The finder drops its RCU read lock before returning this borrowed pointer, leaving the later field reads unprotected.
When a privacy-capable controller has a pending peer with address resolution and device privacy enabled, accept-list programming can reach this helper while management reloads the IRKs. The request worker holds hdev->req_lock, whereas load_irks() takes hdev->lock, allowing the following ordering:
Request worker Management / RCU reclaim
hci_le_set_privacy_mode_sync()
hci_find_irk_by_addr()
rcu_read_lock()
find matching IRK
rcu_read_unlock()
return borrowed IRK
load_irks()
hci_dev_lock(hdev)
hci_smp_irks_clear()
list_del_rcu()
kfree_rcu()
hci_dev_unlock(hdev)
RCU grace period and IRK free
read irk->addr_type
copy irk->bdaddrThe request then accesses a freed IRK. KASAN reports a one-byte use-after-free read of addr_type on this path.
Keep an outer RCU read-side critical section across the lookup and both identity-field copies. The finder's nested unlock then leaves the IRK protected until the caller finishes copying it. Release RCU on a lookup miss and after copying the fields, before the synchronous HCI command can sleep.
KASAN report as below:
==================================================================
BUG: KASAN: slab-use-after-free in
hci_le_add_accept_list_sync+0x90f/0x940
Read of size 1 at addr ffff88810aa6072c by task kworker/u17:0/493
Workqueue: hci0 hci_cmd_sync_work
Call Trace:
<TASK>
dump_stack_lvl+0x93/0xd0
print_report+0xce/0x630
? hci_le_add_accept_list_sync+0x90f/0x940
? srso_alias_return_thunk+0x5/0xfbef5
? __virt_addr_valid+0x20d/0x410
? hci_le_add_accept_list_sync+0x90f/0x940
kasan_report+0xe0/0x110
? hci_le_add_accept_list_sync+0x90f/0x940
hci_le_add_accept_list_sync+0x90f/0x940
? __pfx_hci_le_add_accept_list_sync+0x10/0x10
? srso_alias_return_thunk+0x5/0xfbef5
? conn_params_copy+0x3a0/0x650
hci_passive_scan_sync+0x8c9/0x1e80
? __pfx_hci_passive_scan_sync+0x10/0x10
? find_held_lock+0x2b/0x80
? hci_lookup_le_connect+0x181/0x3c0
? srso_alias_return_thunk+0x5/0xfbef5
? find_held_lock+0x2b/0x80
? hci_update_passive_scan_sync+0x437/0x950
? srso_alias_return_thunk+0x5/0xfbef5
? lock_release+0xc8/0x280
hci_update_passive_scan_sync+0x461/0x950
hci_cmd_sync_work+0x1b3/0x450
? srso_alias_return_thunk+0x5/0xfbef5
process_one_work+0x908/0x19c0
? __pfx_process_one_work+0x10/0x10
? srso_alias_return_thunk+0x5/0xfbef5
? lock_is_held_type+0x8f/0x100
? srso_alias_return_thunk+0x5/0xfbef5
worker_thread+0x65c/0xe40
? __pfx_worker_thread+0x10/0x10
kthread+0x34f/0x460
? srso_alias_return_thunk+0x5/0xfbef5
? __pfx_kthread+0x10/0x10
ret_from_fork+0x659/0x940
? __pfx_ret_from_fork+0x10/0x10
? srso_alias_return_thunk+0x5/0xfbef5
? __switch_to+0x74f/0xf80
? __pfx_kthread+0x10/0x10
ret_from_fork_asm+0x1a/0x30
</TASK>
Allocated by task 507:
kasan_save_stack+0x33/0x60
kasan_save_track+0x14/0x30
__kasan_kmalloc+0xaa/0xb0
__kmalloc_cache_noprof+0x251/0x610
hci_add_irk+0xb6/0x220
load_irks+0x5ef/0x7e0
hci_sock_sendmsg+0x128b/0x22e0
__sys_sendto+0x425/0x470
__x64_sys_sendto+0xe5/0x1c0
do_syscall_64+0x115/0x6a0
entry_SYSCALL_64_after_hwframe+0x77/0x7f
Freed by task 0:
kasan_save_stack+0x33/0x60
kasan_save_track+0x14/0x30
kasan_save_free_info+0x3b/0x60
__kasan_slab_free+0x5f/0x80
__rcu_free_sheaf_prepare+0x65/0x2a0
rcu_free_sheaf+0x1f/0xe0
rcu_core+0x661/0x1d10
handle_softirqs+0x201/0x930
__irq_exit_rcu+0x110/0x1e0
irq_exit_rcu+0xe/0x20
sysvec_apic_timer_interrupt+0x6c/0x80
asm_sysvec_apic_timer_interrupt+0x1a/0x20
The buggy address belongs to the object at ffff88810aa60700
which belongs to the cache kmalloc-64 of size 64
The buggy address is located 44 bytes inside of
freed 64-byte region [ffff88810aa60700, ffff88810aa60740)
The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0
pfn:0x10aa60
flags: 0x200000000000000(node=0|zone=2)
page_type: f5(slab)
raw: 0200000000000000 ffff8881000428c0 dead000000000100
dead000000000122
raw: 0000000000000000 0000000000200020 00000000f5000000
0000000000000000
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff88810aa60600: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
ffff88810aa60680: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
>ffff88810aa60700: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
^
ffff88810aa60780: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
ffff88810aa60800: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
==================================================================
Disabling lock debugging due to kernel taint--- net/bluetooth/hci_sync.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
net/bluetooth/hci_sync.c +7 -1
@@ -2612,13 +2612,19 @@ static int hci_le_set_privacy_mode_sync(struct hci_dev *hdev,if (!(params->flags &HCI_CONN_FLAG_DEVICE_PRIVACY ))return 0 ; +rcu_read_lock (); + irk =hci_find_irk_by_addr (hdev, ¶ms->addr, params->addr_type); -if (!irk) +if (!irk) { +rcu_read_unlock ();return 0 ; + }memset (&cp,0 ,sizeof (cp)); cp.bdaddr_type = irk->addr_type;bacpy (&cp.bdaddr, &irk->bdaddr); +rcu_read_unlock (); + cp.mode =HCI_DEVICE_PRIVACY ;/* Note: params->privacy_mode is not updated since it is a copy */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1547/2151 Bluetooth: btintel: propagate version TLV parsing errors
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Laxman Acharya Padhya <[email protected]>
[ Upstream commit 3a74624b5deae7f5e2b98e638687fbf9594a9781 ]
btintel_read_version_tlv() ignores the parser return value, so setup continues with partially initialized version data after a malformed TLV causes parsing to stop.
Return the parser error to the caller so an invalid response fails setup instead of being treated as successful. Keep this behavioral change separate from the bounds checks so it can be reverted independently if an existing controller sends malformed data.
Stable-dep-of: cf87709d7ff8 ("Bluetooth: btintel: Zero version data before parsing TLVs")
--- drivers/bluetooth/btintel.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/bluetooth/btintel.c +3 -2
@@ -713,6 +713,7 @@ static int btintel_read_version_tlv(struct hci_dev *hdev, {struct sk_buff *skb;const u8 param[1 ] = {0xFF }; +int err;if (!version)return -EINVAL ;
@@ -731,10 +732,10 @@ static int btintel_read_version_tlv(struct hci_dev *hdev,return -EIO ; } -btintel_parse_version_tlv (hdev, version, skb); + err =btintel_parse_version_tlv (hdev, version, skb);kfree_skb (skb); -return 0 ; +return err; }/* ------- REGMAP IBT SUPPORT ------- */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1548/2151 Bluetooth: btintel: Zero version data before parsing TLVs
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kiran K <[email protected]>
[ Upstream commit cf87709d7ff83b4de5d42b61e4a9806fe374cb9d ]
Firmware may omit optional TLVs, leaving their corresponding fields unset in the caller-supplied struct intel_version_tlv. Since the structure is typically stack-allocated and not cleared beforehand, fields for which no TLV is received retain uninitialized stack memory. This stale data can be logged via btintel_version_info_tlv() and copied back to the caller, leaking kernel stack contents.
Clear the structure in btintel_read_version_tlv() before parsing so that fields with no corresponding TLV are deterministically zero instead of containing garbage.
--- drivers/bluetooth/btintel.c | 1 + 1 file changed, 1 insertion(+)
drivers/bluetooth/btintel.c +1 -0
@@ -732,6 +732,7 @@ static int btintel_read_version_tlv(struct hci_dev *hdev,return -EIO ; } +memset (version,0 ,sizeof (*version)); err =btintel_parse_version_tlv (hdev, version, skb);kfree_skb (skb);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1549/2151 Bluetooth: MSFT: Serialize handle map cleanup with event processing
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit 56e20c3d8ad340bbfc90221c4aae1c870485fb57 ]
MSFT monitor handle mappings must remain valid while vendor events look up and use them under hdev->lock. msft_do_close() removes and frees the mappings without that lock.
hci_dev_close_sync() clears HCI_UP and drains the RX workqueue before MSFT cleanup. However, a transport callback that already passed hci_recv_frame()'s state check can queue a vendor event after the drain returns, if no earlier shutdown callback has quiesced reception. The driver close callback runs after MSFT cleanup, so event processing can overlap the unlocked removal. msft_monitor_device_evt() can then traverse freed list entries or read handle_data->mgmt_handle after it is freed.
Take hdev->lock while resetting monitor states and removing handle mappings in msft_do_close(), as normal monitor cancellation already does. An active event reader then finishes before its mapping is freed, and later lookups see an empty handle map.
An instrumented kernel produced this KASAN report (timestamps removed and unrelated frames omitted):
BUG: KASAN: slab-use-after-free in msft_vendor_evt+0x1906/0x1990
Read of size 2 at addr ffff888104df3602 by task kworker/u17:2/502
Workqueue: hci0 hci_rx_work
Call Trace:
[...]
msft_vendor_evt+0x1906/0x1990
hci_vendor_evt+0x6f/0x90
hci_event_packet+0x894/0xc70
[...]
hci_rx_work+0x3f8/0xfa0
[...]
Allocated by task 499:
[...]
msft_add_monitor_sync+0x6a8/0x10a0
msft_add_monitor_pattern+0x7f/0xb0
hci_add_adv_monitor+0x1fa/0x2e0
[...]
Freed by task 499:
[...]
kfree+0x307/0x580
msft_do_close+0x238/0x750
hci_dev_close_sync+0x546/0x1380
[...]
The buggy address belongs to the object at ffff888104df3600
which belongs to the cache kmalloc-32 of size 32
The buggy address is located 2 bytes inside of
freed 32-byte region [ffff888104df3600, ffff888104df3620)
[...]--- net/bluetooth/msft.c | 4 ++++ 1 file changed, 4 insertions(+)
net/bluetooth/msft.c +4 -0
@@ -683,6 +683,8 @@ void msft_do_close(struct hci_dev *hdev)bt_dev_dbg (hdev,"Cleanup of MSFT extension" ); +hci_dev_lock (hdev); +/* The controller will silently remove all monitors on power off. * Therefore, remove handle_data mapping and reset monitor state. */
@@ -697,6 +699,8 @@ void msft_do_close(struct hci_dev *hdev)kfree (handle_data); } +hci_dev_unlock (hdev); +mutex_lock (&msft->filter_lock);list_for_each_entry_safe (address_filter, n, &msft->address_filters, list) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1550/2151 Bluetooth: hci_sync: scan unfiltered for host-resolved RPAs
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kyle Pepper <[email protected]>
[ Upstream commit 397464709a204da9b8dc3b01d6ea42539d951cd2 ]
Restore unfiltered scanning for pending IRK peers when the controller cannot resolve private addresses. Keep accept-list filtering while suspended and when forced by periodic advertising synchronization.
--- net/bluetooth/hci_sync.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
net/bluetooth/hci_sync.c +9 -4
@@ -2639,7 +2639,7 @@ static int hci_le_set_privacy_mode_sync(struct hci_dev *hdev,*/ static int hci_le_add_accept_list_sync (struct hci_dev *hdev,struct conn_params *params, -u8 *num_entries) +u8 *num_entries,bool force_filter) {struct hci_cp_le_add_to_accept_list cp;int err;
@@ -2652,6 +2652,11 @@ static int hci_le_add_accept_list_sync(struct hci_dev *hdev,return 0 ; } +/* Host-resolved peers need unfiltered scanning while awake. */ +if (!force_filter && !hdev->suspended && !ll_privacy_capable (hdev) && +hci_find_irk_by_addr (hdev, ¶ms->addr, params->addr_type)) +return -EINVAL ; +/* Select filter policy to accept all advertising */ if (*num_entries >= hdev->le_accept_list_size)return -ENOSPC ;
@@ -2983,7 +2988,7 @@ static u8 hci_update_accept_list_sync(struct hci_dev *hdev) num_entries =1 ; err =hci_le_add_accept_list_sync (hdev, &pa, - &num_entries); + &num_entries, true); goto done; }else {rcu_read_unlock ();
@@ -3047,7 +3052,7 @@ static u8 hci_update_accept_list_sync(struct hci_dev *hdev)for (i =0 ; i < n; ++i) { err =hci_le_add_accept_list_sync (hdev, ¶ms[i], - &num_entries); + &num_entries, false);if (err) {kvfree (params); goto done;
@@ -3069,7 +3074,7 @@ static u8 hci_update_accept_list_sync(struct hci_dev *hdev)for (i =0 ; i < n; ++i) { err =hci_le_add_accept_list_sync (hdev, ¶ms[i], - &num_entries); + &num_entries, false);if (err) {kvfree (params); goto done;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1551/2151 clocksource/drivers/timer-ti-dm: Handle runtime resume failure
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit c40b76c8cf580466d9e56223f7f74beecc165480 ]
omap_dm_timer_write_counter() accesses timer registers and updates the saved counter value after requesting a runtime PM reference. If runtime resume fails, the timer remains inaccessible and no reference is acquired, but the function still writes the register, drops a reference, updates the cached value, and reports success.
Check the return value and propagate an error before touching the timer state.
--- drivers/clocksource/timer-ti-dm.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/clocksource/timer-ti-dm.c +5 -1
@@ -1076,6 +1076,7 @@ static int omap_dm_timer_write_counter(struct omap_dm_timer *cookie, unsigned in {struct dmtimer *timer;struct device *dev; +int ret; timer =to_dmtimer (cookie);if (unlikely (!timer)) {
@@ -1085,7 +1086,10 @@ static int omap_dm_timer_write_counter(struct omap_dm_timer *cookie, unsigned in dev = &timer->pdev->dev; -pm_runtime_resume_and_get (dev); + ret =pm_runtime_resume_and_get (dev); +if (ret <0 ) +return ret; +dmtimer_write (timer,OMAP_TIMER_COUNTER_REG , value);pm_runtime_put_sync (dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1552/2151 net: selftests: use skb_share_check() in the loopback receive hook
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolai Buchwitz <[email protected]>
[ Upstream commit fbd3a301b1378423a5cfc23a42e3c0b04e26192c ]
The loopback hook gets a shared skb when another ETH_P_IP handler is bound to the device. skb_unshare() does not unshare it, so skb_linearize() on a non-linear frame hits BUG_ON(skb_shared()).
Use skb_share_check() instead.
--- net/core/selftests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/selftests.c +1 -1
@@ -205,7 +205,7 @@ static int net_test_loopback_validate(struct sk_buff *skb,struct tcphdr *thdr;struct iphdr *ihdr; - skb =skb_unshare (skb,GFP_ATOMIC ); + skb =skb_share_check (skb,GFP_ATOMIC );if (!skb) goto out;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1553/2151 net: stmmac: selftests: use skb_share_check() in the loopback receive hook
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolai Buchwitz <[email protected]>
[ Upstream commit a7a89019bac0e8810bde7f1419f4adf9adc23d41 ]
The loopback hook gets a shared skb when another ETH_P_IP handler is bound to the device. skb_unshare() does not unshare it, so skb_linearize() on a non-linear frame hits BUG_ON(skb_shared()).
Use skb_share_check() instead.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c +1 -1
@@ -262,7 +262,7 @@ static int stmmac_test_loopback_validate(struct sk_buff *skb,struct tcphdr *thdr;struct iphdr *ihdr; - skb =skb_unshare (skb,GFP_ATOMIC ); + skb =skb_share_check (skb,GFP_ATOMIC );if (!skb) goto out;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1554/2151 net/mlx5e: use skb_share_check() in the loopback selftest hook
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolai Buchwitz <[email protected]>
[ Upstream commit 16fb7aa6955a0af9f67ca42a61d9be58dfc9382a ]
The loopback hook gets a shared skb when another ETH_P_IP handler is bound to the device. skb_linearize() on a non-linear frame then hits BUG_ON(skb_shared()).
Call skb_share_check() before linearizing the skb.
--- drivers/net/ethernet/mellanox/mlx5/core/en_selftest.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/en_selftest.c +4 -0
@@ -166,6 +166,10 @@ mlx5e_test_loopback_validate(struct sk_buff *skb,struct udphdr *udph;struct iphdr *iph; + skb =skb_share_check (skb,GFP_ATOMIC ); +if (!skb) + goto out; +if (skb_linearize (skb)) goto out;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1555/2151 selftests/nolibc: scope custom flags to the nolibc-test target
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Weißschuh <[email protected]>
[ Upstream commit 20c72de1f8a9e338531579bd784371aba4b7dd2c ]
A new target for 'libc-test' is going to be added which should not be affected by these options.
Stable-dep-of: f9532b372e41 ("selftests/nolibc: use the configured kernel header directory")
--- tools/testing/selftests/nolibc/Makefile | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
tools/testing/selftests/nolibc/Makefile +2 -6
@@ -9,14 +9,10 @@ cc-option = $(call __cc-option, $(CC),,$(1),$(2)) include Makefile.include -CFLAGS = -nostdlib -nostdinc -static \ +$(OUTPUT)/nolibc-test: CFLAGS = -nostdlib -nostdinc -static \ -isystem $(top_srcdir)/tools/include/nolibc -isystem $(top_srcdir)/usr/include \ $(CFLAGS_NOLIBC_TEST) - -ifeq ($(LLVM),) -LDLIBS := -lgcc -endif - +$(OUTPUT)/nolibc-test: LDLIBS = $(if $(LLVM),,-lgcc) $(OUTPUT)/nolibc-test: nolibc-test.c nolibc-test-linkage.c | headers help:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1556/2151 selftests/nolibc: use the configured kernel header directory
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit f9532b372e415e8198287ce010efa22f337857b5 ]
The freestanding build hardcodes the source tree's usr/include even when selftests exports KHDR_INCLUDES for an output-directory build. Use the exported header location while preserving -nostdlib, -nostdinc and static linkage. GCC 14 and Clang 21 builds then find the generated UAPI headers.
--- tools/testing/selftests/nolibc/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/nolibc/Makefile +1 -1
@@ -10,7 +10,7 @@ cc-option = $(call __cc-option, $(CC),,$(1),$(2)) include Makefile.include $(OUTPUT)/nolibc-test: CFLAGS = -nostdlib -nostdinc -static \ - -isystem $(top_srcdir)/tools/include/nolibc -isystem $(top_srcdir)/usr/include \ + -isystem $(top_srcdir)/tools/include/nolibc $(KHDR_INCLUDES) \ $(CFLAGS_NOLIBC_TEST) $(OUTPUT)/nolibc-test: LDLIBS = $(if $(LLVM),,-lgcc) $(OUTPUT)/nolibc-test: nolibc-test.c nolibc-test-linkage.c | headers
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1557/2151 iommufd: Keep reserved IOVA ranges when a replace within one IOAS fails
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Donggeun Yoo <[email protected]>
[ Upstream commit 1e67cca28490f897788c128c650a6f2cbb565403 ]
iommufd_device_do_replace() installs the group's reserved IOVA ranges in the new hwpt's IOAS only when it differs from the old hwpt's IOAS. If the replace fails in iommufd_device_do_replace() or iommufd_group_do_replace_reserved_iova(), the error paths remove the ranges from the new hwpt's IOAS whether or not the IOAS is shared between the old and new hwpt, which removes the ranges that the old hwpt still needs.
For example, on x86 with intel-iommu, after a replace within a shared IOAS fails with -ENODEV, IOMMU_IOAS_IOVA_RANGES goes from
0x0-0xfedfffff
0xfef00000-0xffffffffffff
to
0x0-0xffffffffffff
and IOMMU_IOAS_MAP at 0xfee00000 succeeds.
Remove the ranges on failure only when the replace installed them, and look up the old hwpt_paging before the replace so that the error path can compare the IOAS.
--- drivers/iommu/iommufd/device.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/iommu/iommufd/device.c +5 -3
@@ -766,7 +766,8 @@ iommufd_group_do_replace_reserved_iova(struct iommufd_group *igroup,return 0 ; err_unresv: -iommufd_group_remove_reserved_iova (igroup, hwpt_paging); +if (!old_hwpt_paging || hwpt_paging->ioas != old_hwpt_paging->ioas) +iommufd_group_remove_reserved_iova (igroup, hwpt_paging);return rc; }
@@ -805,6 +806,7 @@ iommufd_device_do_replace(struct iommufd_device *idev, ioasid_t pasid,return NULL ; } + old_hwpt_paging =find_hwpt_paging (old_hwpt);if (attach_resv) { rc =iommufd_group_do_replace_reserved_iova (igroup, hwpt_paging);if (rc)
@@ -815,7 +817,6 @@ iommufd_device_do_replace(struct iommufd_device *idev, ioasid_t pasid,if (rc) goto err_unresv; - old_hwpt_paging =find_hwpt_paging (old_hwpt);if (old_hwpt_paging && pasid ==IOMMU_NO_PASID && (!hwpt_paging || hwpt_paging->ioas != old_hwpt_paging->ioas))iommufd_group_remove_reserved_iova (igroup, old_hwpt_paging);
@@ -836,7 +837,8 @@ iommufd_device_do_replace(struct iommufd_device *idev, ioasid_t pasid,/* Caller must destroy old_hwpt */ return old_hwpt; err_unresv: -if (attach_resv) +if (attach_resv && + (!old_hwpt_paging || hwpt_paging->ioas != old_hwpt_paging->ioas))iommufd_group_remove_reserved_iova (igroup, hwpt_paging); err_unlock:mutex_unlock (&igroup->lock);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1558/2151 scsi: libsas: Fix out-of-bounds memcpy() in sas_ssp_task_response()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xingui Yang <[email protected]>
[ Upstream commit 4d7f9c3fdce773f6c69d17c1d4a05bd5e17f4b99 ]
The min_t(int, ...) clamp of the device-provided sense_data_len turns negative for values >= 0x80000000 and is then used as the memcpy() length, reading and writing out of bounds. Compare as u32 instead. Well-formed responses are unaffected.
--- drivers/scsi/libsas/sas_task.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/libsas/sas_task.c +1 -1
@@ -25,7 +25,7 @@ void sas_ssp_task_response(struct device *dev, struct sas_task *task,case SAS_DATAPRES_SENSE_DATA : tstat->stat =SAS_SAM_STAT_CHECK_CONDITION ; tstat->buf_valid_size = -min_t (int,SAS_STATUS_BUF_SIZE , +min_t (u32,SAS_STATUS_BUF_SIZE ,be32_to_cpu (iu->sense_data_len));memcpy (tstat->buf, iu->sense_data, tstat->buf_valid_size);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1559/2151 scsi: hisi_sas: Fix incorrect delay values from magic-number cleanup
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xingui Yang <[email protected]>
[ Upstream commit 7307109c92f702434669bfcd29fb8058ccc07b45 ]
Commit 4ca7fe99fc84 ("scsi: hisi_sas: Use macro instead of magic number") replaced several delay constants with a single macro of value
100. However, three sites originally used different values:
- reset_hw_v3_hw: udelay(50) -> udelay(100) [doubled]
- disable_phy_v3_hw: mdelay(50) -> mdelay(100) [doubled]
- disable_host_v3_hw: mdelay(10) -> mdelay(100) [10x longer]
The overly long delays on the PHY disable and host shutdown paths increase boot and shutdown time for all local PHYs.
Add separate macros for each delay to restore the original values while still avoiding magic numbers.
--- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +6 -3
@@ -547,6 +547,9 @@ struct hisi_sas_err_record_v3 {#define IRQ_AXI_INDEX 11#define DELAY_FOR_RESET_HW 100 +#define STOP_PHY_DELAY_US 50 +#define DISABLE_PHY_DELAY_MS 50 +#define DISABLE_HOST_PHY_DELAY_MS 10#define HDR_SG_MOD 0x2#define LUN_SIZE 8#define ATTR_PRIO_REGION 9
@@ -983,7 +986,7 @@ static int reset_hw_v3_hw(struct hisi_hba *hisi_hba)/* Disable all of the PHYs */ hisi_sas_stop_phys (hisi_hba); -udelay (HISI_SAS_DELAY_FOR_PHY_DISABLE ); +udelay (STOP_PHY_DELAY_US );/* Ensure axi bus idle */ ret = hisi_sas_read32_poll_timeout(AXI_CFG, val, !val,
@@ -1072,7 +1075,7 @@ static void disable_phy_v3_hw(struct hisi_hba *hisi_hba, int phy_no) cfg &= ~PHY_CFG_ENA_MSK ;hisi_sas_phy_write32 (hisi_hba, phy_no,PHY_CFG , cfg); -mdelay (HISI_SAS_DELAY_FOR_PHY_DISABLE ); +mdelay (DISABLE_PHY_DELAY_MS ); state =hisi_sas_read32 (hisi_hba,PHY_STATE );if (state &BIT (phy_no)) {
@@ -2755,7 +2758,7 @@ static int disable_host_v3_hw(struct hisi_hba *hisi_hba)hisi_sas_stop_phys (hisi_hba); -mdelay (HISI_SAS_DELAY_FOR_PHY_DISABLE ); +mdelay (DISABLE_HOST_PHY_DELAY_MS ); reg_val =hisi_sas_read32 (hisi_hba,AXI_MASTER_CFG_BASE +AM_CTRL_GLOBAL );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1560/2151 scsi: scsi_debug: move ASC and ASCQ definitions to scsi_proto.h
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Damien Le Moal <[email protected]>
[ Upstream commit 7c8b3f6578bb874ba9d334aef0e51fe931ce6c04 ]
The scsi_debug driver internally defines lots of SCSI additional sense codes (ASC) and additional sense code qualifiers (ASCQ). Move these definitions to include/scsi/scsi_proto.h so that they can be reused elsewhere in the SCSI and ATA code. This also makes the scsi_debug.c file a little smaller.
Stable-dep-of: 92821c2358c7 ("scsi: hisi_sas: Fix spinup failure for SAS SSP devices in Active_Wait state")
--- drivers/scsi/scsi_debug.c | 46 ----------------------------------- include/scsi/scsi_proto.h | 51 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 46 deletions(-)
drivers/scsi/scsi_debug.c +0 -46
@@ -67,52 +67,6 @@ static const char *sdebug_version_date = "20210520";#define MY_NAME "scsi_debug" -/* Additional Sense Code (ASC) */ -#define NO_ADDITIONAL_SENSE 0x0 -#define OVERLAP_ATOMIC_COMMAND_ASC 0x0 -#define OVERLAP_ATOMIC_COMMAND_ASCQ 0x23 -#define FILEMARK_DETECTED_ASCQ 0x1 -#define EOP_EOM_DETECTED_ASCQ 0x2 -#define BEGINNING_OF_P_M_DETECTED_ASCQ 0x4 -#define EOD_DETECTED_ASCQ 0x5 -#define LOGICAL_UNIT_NOT_READY 0x4 -#define LOGICAL_UNIT_COMMUNICATION_FAILURE 0x8 -#define UNRECOVERED_READ_ERR 0x11 -#define PARAMETER_LIST_LENGTH_ERR 0x1a -#define INVALID_OPCODE 0x20 -#define LBA_OUT_OF_RANGE 0x21 -#define INVALID_FIELD_IN_CDB 0x24 -#define INVALID_FIELD_IN_PARAM_LIST 0x26 -#define WRITE_PROTECTED 0x27 -#define UA_READY_ASC 0x28 -#define UA_RESET_ASC 0x29 -#define UA_CHANGED_ASC 0x2a -#define TOO_MANY_IN_PARTITION_ASC 0x3b -#define TARGET_CHANGED_ASC 0x3f -#define LUNS_CHANGED_ASCQ 0x0e -#define INSUFF_RES_ASC 0x55 -#define INSUFF_RES_ASCQ 0x3 -#define POWER_ON_RESET_ASCQ 0x0 -#define POWER_ON_OCCURRED_ASCQ 0x1 -#define BUS_RESET_ASCQ 0x2/* scsi bus reset occurred */ -#define MODE_CHANGED_ASCQ 0x1/* mode parameters changed */ -#define CAPACITY_CHANGED_ASCQ 0x9 -#define SAVING_PARAMS_UNSUP 0x39 -#define TRANSPORT_PROBLEM 0x4b -#define THRESHOLD_EXCEEDED 0x5d -#define LOW_POWER_COND_ON 0x5e -#define MISCOMPARE_VERIFY_ASC 0x1d -#define MICROCODE_CHANGED_ASCQ 0x1/* with TARGET_CHANGED_ASC */ -#define MICROCODE_CHANGED_WO_RESET_ASCQ 0x16 -#define WRITE_ERROR_ASC 0xc -#define UNALIGNED_WRITE_ASCQ 0x4 -#define WRITE_BOUNDARY_ASCQ 0x5 -#define READ_INVDATA_ASCQ 0x6 -#define READ_BOUNDARY_ASCQ 0x7 -#define ATTEMPT_ACCESS_GAP 0x9 -#define INSUFF_ZONE_ASCQ 0xe -/* see drivers/scsi/sense_codes.h */ -/* Additional Sense Code Qualifier (ASCQ) */ #define ACK_NAK_TO 0x3
include/scsi/scsi_proto.h +51 -0
57 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1561/2151 scsi: core: Define all additional sense codes and their qualifiers
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Damien Le Moal <[email protected]>
[ Upstream commit 72c54bd0cbb2e0c35f4acd056e91c596469edc5f ]
Introduce the file include/scsi/scsi_sense.h to define all existing additional sense codes and their combinations with additional sense code qualifiers, according to the most current T10 list available at
https://www.t10.org/lists/asc-num.txt.
Additional sense codes (ASCs) are individually defined as an 8-bit value with the ASC_ name prefix. The combination of all ASCs with T10 defined possible code qualifiers are defined as 16-bit values without any name prefix. The 16-bit value for ASCs with a zero ASCQ are defined together with the ASC 8-code using the ASC() macro. For names that may potentially create conflicts with other subsystems (e.g. WARNING or WRITE_ERROR), the SSC_ prefix is added to the sense code name.
The sense key macro definitions in include/scsi/scsi_proto.h are also moved into this new file and scsi_sense.h is included in scsi_proto.h. The helper function scsi_sense_code() is defined to facilitate generating a 16-bit sense code from the 8-bit ASC and ASCQ. The accessors scsi_sense_code_asc() and scsi_sense_code_ascq() are defined for the reverse operations, that is, to respectively extract an ASC and an ASCQ from a 16-bit sense code.
Stable-dep-of: 92821c2358c7 ("scsi: hisi_sas: Fix spinup failure for SAS SSP devices in Active_Wait state")
--- include/scsi/scsi_proto.h | 20 +- include/scsi/scsi_sense.h | 950 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 951 insertions(+), 19 deletions(-) create mode 100644 include/scsi/scsi_sense.h
include/scsi/scsi_proto.h +1 -19
@@ -12,6 +12,7 @@#include <linux/build_bug.h> #include <linux/types.h> +#include <scsi/scsi_sense.h> /* * SCSI opcodes
@@ -214,25 +215,6 @@ enum sam_status {#define STATUS_MASK 0xfe -/* -* SENSE KEYS -*/ -#define NO_SENSE 0x00 -#define RECOVERED_ERROR 0x01 -#define NOT_READY 0x02 -#define MEDIUM_ERROR 0x03 -#define HARDWARE_ERROR 0x04 -#define ILLEGAL_REQUEST 0x05 -#define UNIT_ATTENTION 0x06 -#define DATA_PROTECT 0x07 -#define BLANK_CHECK 0x08 -#define VENDOR_SPECIFIC 0x09 -#define COPY_ABORTED 0x0a -#define ABORTED_COMMAND 0x0b -#define VOLUME_OVERFLOW 0x0d -#define MISCOMPARE 0x0e -#define COMPLETED 0x0f -/* * Additional Sense Codes (ASC). */
include/scsi/scsi_sense.h new file +950 -0
950 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1562/2151 scsi: core: Rename sense field of struct scsi_failure
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Damien Le Moal <[email protected]>
[ Upstream commit 45cdf8164237277e52af5d8aa4218c3cb6199bf2 ]
Rename the sense field of struct scsi_failure to sense_key. This makes it clear that this field stores the sense key, and also unifies this structure field names with the names used in struct scsi_sense_hdr.
To be consistent with this change, the macro SCMD_FAILURE_SENSE_ANY is renamed SCMD_FAILURE_SENSE_KEY_ANY.
Of note is that the definition of the array any_sense_failure_defs in scsi_lib_test_any_sense() is modified to change the initialization of the result field to use SCMD_FAILURE_RESULT_ANY and add the .sense_key field initialization to SCMD_FAILURE_SENSE_KEY_ANY to match the test target case.
Stable-dep-of: 92821c2358c7 ("scsi: hisi_sas: Fix spinup failure for SAS SSP devices in Active_Wait state")
--- drivers/scsi/ch.c | 2 +- drivers/scsi/device_handler/scsi_dh_hp_sw.c | 4 ++-- drivers/scsi/device_handler/scsi_dh_rdac.c | 10 ++++----- drivers/scsi/scsi_lib.c | 6 ++--- drivers/scsi/scsi_lib_test.c | 25 +++++++++++---------- drivers/scsi/scsi_scan.c | 8 +++---- drivers/scsi/scsi_transport_spi.c | 2 +- drivers/scsi/sd.c | 20 ++++++++--------- drivers/scsi/ses.c | 8 +++---- include/scsi/scsi_device.h | 12 +++++----- 10 files changed, 49 insertions(+), 48 deletions(-)
drivers/scsi/ch.c +1 -1
@@ -190,7 +190,7 @@ ch_do_scsi(scsi_changer *ch, unsigned char *cmd, int cmd_len,struct scsi_sense_hdr sshdr;struct scsi_failure failure_defs[] = { { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =SCMD_FAILURE_ASC_ANY , .ascq =SCMD_FAILURE_ASCQ_ANY , .allowed =3 ,
drivers/scsi/device_handler/scsi_dh_hp_sw.c +2 -2
@@ -84,7 +84,7 @@ static int hp_sw_tur(struct scsi_device *sdev, struct hp_sw_dh_data *h)REQ_FAILFAST_TRANSPORT |REQ_FAILFAST_DRIVER ;struct scsi_failure failure_defs[] = { { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =SCMD_FAILURE_ASC_ANY , .ascq =SCMD_FAILURE_ASCQ_ANY , .allowed =SCMD_FAILURE_NO_LIMIT ,
@@ -138,7 +138,7 @@ static int hp_sw_start_stop(struct hp_sw_dh_data *h)* * Switch-over in progress, retry. */ - .sense = NOT_READY, + .sense_key = NOT_READY, .asc = 0x04, .ascq = 0x03, .allowed = HP_SW_RETRIES,
drivers/scsi/device_handler/scsi_dh_rdac.c +5 -5
@@ -514,33 +514,33 @@ static void send_mode_select(struct work_struct *work)REQ_FAILFAST_TRANSPORT |REQ_FAILFAST_DRIVER ;struct scsi_failure failure_defs[] = { { - .sense =NO_SENSE , + .sense_key =NO_SENSE , .asc =SCMD_FAILURE_ASC_ANY , .ascq =SCMD_FAILURE_ASCQ_ANY , .result =SAM_STAT_CHECK_CONDITION , }, { - .sense =ABORTED_COMMAND , + .sense_key =ABORTED_COMMAND , .asc =SCMD_FAILURE_ASC_ANY , .ascq =SCMD_FAILURE_ASCQ_ANY , .result =SAM_STAT_CHECK_CONDITION , }, { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =SCMD_FAILURE_ASC_ANY , .ascq =SCMD_FAILURE_ASCQ_ANY , .result =SAM_STAT_CHECK_CONDITION , },/* LUN Not Ready and is in the Process of Becoming Ready */ { - .sense =NOT_READY , + .sense_key =NOT_READY , .asc =0x04 , .ascq =0x01 , .result =SAM_STAT_CHECK_CONDITION , },/* Command Lock contention */ { - .sense =ILLEGAL_REQUEST , + .sense_key =ILLEGAL_REQUEST , .asc =0x91 , .ascq =0x36 , .allowed =SCMD_FAILURE_NO_LIMIT ,
drivers/scsi/scsi_lib.c +3 -3
@@ -241,13 +241,13 @@ static int scsi_check_passthrough(struct scsi_cmnd *scmd,continue ;if (status_byte (failure->result) !=SAM_STAT_CHECK_CONDITION || - failure->sense ==SCMD_FAILURE_SENSE_ANY ) + failure->sense_key ==SCMD_FAILURE_SENSE_KEY_ANY ) goto maybe_retry;if (!scsi_command_normalize_sense (scmd, &sshdr))return 0 ; -if (failure->sense != sshdr.sense_key) +if (failure->sense_key != sshdr.sense_key)continue ;if (failure->asc ==SCMD_FAILURE_ASC_ANY )
@@ -2374,7 +2374,7 @@ scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage, int subpage,struct scsi_sense_hdr my_sshdr;struct scsi_failure failure_defs[] = { { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =SCMD_FAILURE_ASC_ANY , .ascq =SCMD_FAILURE_ASCQ_ANY , .allowed = retries,
drivers/scsi/scsi_lib_test.c +13 -12
@@ -17,40 +17,40 @@ static void scsi_lib_test_multiple_sense(struct kunit *test) {struct scsi_failure multiple_sense_failure_defs[] = { { - .sense =DATA_PROTECT , + .sense_key =DATA_PROTECT , .asc =0x1 , .ascq =0x1 , .result =SAM_STAT_CHECK_CONDITION , }, { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =0x11 , .ascq =0x0 , .allowed =SCSI_LIB_TEST_MAX_ALLOWED , .result =SAM_STAT_CHECK_CONDITION , }, { - .sense =NOT_READY , + .sense_key =NOT_READY , .asc =0x11 , .ascq =0x22 , .allowed =SCSI_LIB_TEST_MAX_ALLOWED , .result =SAM_STAT_CHECK_CONDITION , }, { - .sense =ABORTED_COMMAND , + .sense_key =ABORTED_COMMAND , .asc =0x11 , .ascq =SCMD_FAILURE_ASCQ_ANY , .allowed =SCSI_LIB_TEST_MAX_ALLOWED , .result =SAM_STAT_CHECK_CONDITION , }, { - .sense =HARDWARE_ERROR , + .sense_key =HARDWARE_ERROR , .asc =SCMD_FAILURE_ASC_ANY , .allowed =SCSI_LIB_TEST_MAX_ALLOWED , .result =SAM_STAT_CHECK_CONDITION , }, { - .sense =ILLEGAL_REQUEST , + .sense_key =ILLEGAL_REQUEST , .asc =0x91 , .ascq =0x36 , .allowed =SCSI_LIB_TEST_MAX_ALLOWED ,
@@ -116,8 +116,9 @@ static void scsi_lib_test_any_sense(struct kunit *test) {struct scsi_failure any_sense_failure_defs[] = { { - .result =SCMD_FAILURE_SENSE_ANY , + .sense_key =SCMD_FAILURE_SENSE_KEY_ANY , .allowed =SCSI_LIB_TEST_MAX_ALLOWED , + .result =SCMD_FAILURE_RESULT_ANY , }, {} };
@@ -129,7 +130,7 @@ static void scsi_lib_test_any_sense(struct kunit *test) .sense_buffer = sense, }; -/* Match using SCMD_FAILURE_SENSE_ANY */ +/* Match using SCMD_FAILURE_SENSE_KEY_ANY */ failures.failure_definitions = any_sense_failure_defs;scsi_build_sense (&sc,0 ,MEDIUM_ERROR ,0x11 ,0x22 );KUNIT_EXPECT_EQ (test, -EAGAIN ,scsi_check_passthrough (&sc, &failures));
@@ -215,14 +216,14 @@ static void scsi_lib_test_total_allowed(struct kunit *test) {struct scsi_failure total_allowed_defs[] = { { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =SCMD_FAILURE_ASC_ANY , .ascq =SCMD_FAILURE_ASCQ_ANY , .result =SAM_STAT_CHECK_CONDITION , },/* Fail all CCs except the UA above */ { - .sense =SCMD_FAILURE_SENSE_ANY , + .sense_key =SCMD_FAILURE_SENSE_KEY_ANY , .result =SAM_STAT_CHECK_CONDITION , },/* Retry any other errors not listed above */
@@ -259,12 +260,12 @@ static void scsi_lib_test_mixed_total(struct kunit *test) {struct scsi_failure mixed_total_defs[] = { { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =0x28 , .result =SAM_STAT_CHECK_CONDITION , }, { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =0x29 , .result =SAM_STAT_CHECK_CONDITION , },
drivers/scsi/scsi_scan.c +4 -4
@@ -658,12 +658,12 @@ static int scsi_probe_lun(struct scsi_device *sdev, unsigned char *inq_result,* so anyway. */ { - .sense = UNIT_ATTENTION, + .sense_key = UNIT_ATTENTION, .asc = 0x28, .result = SAM_STAT_CHECK_CONDITION, }, { - .sense = UNIT_ATTENTION, + .sense_key = UNIT_ATTENTION, .asc = 0x29, .result = SAM_STAT_CHECK_CONDITION, },
@@ -1440,14 +1440,14 @@ static int scsi_report_lun_scan(struct scsi_target *starget, blist_flags_t bflagstruct Scsi_Host *shost =dev_to_shost (&starget->dev);struct scsi_failure failure_defs[] = { { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =SCMD_FAILURE_ASC_ANY , .ascq =SCMD_FAILURE_ASCQ_ANY , .result =SAM_STAT_CHECK_CONDITION , },/* Fail all CCs except the UA above */ { - .sense =SCMD_FAILURE_SENSE_ANY , + .sense_key =SCMD_FAILURE_SENSE_KEY_ANY , .result =SAM_STAT_CHECK_CONDITION , },/* Retry any other errors not listed above */
drivers/scsi/scsi_transport_spi.c +1 -1
@@ -112,7 +112,7 @@ static int spi_execute(struct scsi_device *sdev, const void *cmd,REQ_FAILFAST_DRIVER ;struct scsi_failure failure_defs[] = { { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =SCMD_FAILURE_ASC_ANY , .ascq =SCMD_FAILURE_ASCQ_ANY , .allowed =DV_RETRIES ,
drivers/scsi/sd.c +10 -10
@@ -1950,7 +1950,7 @@ static int sd_pr_in_command(struct block_device *bdev, u8 sa,u8 cmd[10 ] = {PERSISTENT_RESERVE_IN , sa };struct scsi_failure failure_defs[] = { { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =SCMD_FAILURE_ASC_ANY , .ascq =SCMD_FAILURE_ASCQ_ANY , .allowed =5 ,
@@ -2052,7 +2052,7 @@ static int sd_pr_out_command(struct block_device *bdev, u8 sa, u64 key,struct scsi_sense_hdr sshdr;struct scsi_failure failure_defs[] = { { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =SCMD_FAILURE_ASC_ANY , .ascq =SCMD_FAILURE_ASCQ_ANY , .allowed =5 ,
@@ -2416,13 +2416,13 @@ sd_spinup_disk(struct scsi_disk *sdkp)struct scsi_failure failure_defs[] = {/* Do not retry Medium Not Present */ { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =0x3A , .ascq =SCMD_FAILURE_ASCQ_ANY , .result =SAM_STAT_CHECK_CONDITION , }, { - .sense =NOT_READY , + .sense_key =NOT_READY , .asc =0x3A , .ascq =SCMD_FAILURE_ASCQ_ANY , .result =SAM_STAT_CHECK_CONDITION ,
@@ -2739,18 +2739,18 @@ static int read_capacity_10(struct scsi_disk *sdkp, struct scsi_device *sdp,struct scsi_failure failure_defs[] = {/* Do not retry Medium Not Present */ { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =0x3A , .result =SAM_STAT_CHECK_CONDITION , }, { - .sense =NOT_READY , + .sense_key =NOT_READY , .asc =0x3A , .result =SAM_STAT_CHECK_CONDITION , },/* Device reset might occur several times so retry a lot */ { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =0x29 , .allowed =READ_CAPACITY_RETRIES_ON_RESET , .result =SAM_STAT_CHECK_CONDITION ,
@@ -4104,21 +4104,21 @@ static int sd_start_stop_device(struct scsi_disk *sdkp, int start)struct scsi_failure failure_defs[] = { {/* Power on, reset, or bus device reset occurred */ - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =0x29 , .ascq =0 , .result =SAM_STAT_CHECK_CONDITION , }, {/* Power on occurred */ - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =0x29 , .ascq =1 , .result =SAM_STAT_CHECK_CONDITION , }, {/* SCSI bus reset */ - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =0x29 , .ascq =2 , .result =SAM_STAT_CHECK_CONDITION ,
drivers/scsi/ses.c +4 -4
@@ -89,14 +89,14 @@ static int ses_recv_diag(struct scsi_device *sdev, int page_code,unsigned char recv_page_code;struct scsi_failure failure_defs[] = { { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =0x29 , .ascq =SCMD_FAILURE_ASCQ_ANY , .allowed =SES_RETRIES , .result =SAM_STAT_CHECK_CONDITION , }, { - .sense =NOT_READY , + .sense_key =NOT_READY , .asc =SCMD_FAILURE_ASC_ANY , .ascq =SCMD_FAILURE_ASCQ_ANY , .allowed =SES_RETRIES ,
@@ -146,14 +146,14 @@ static int ses_send_diag(struct scsi_device *sdev, int page_code, };struct scsi_failure failure_defs[] = { { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =0x29 , .ascq =SCMD_FAILURE_ASCQ_ANY , .allowed =SES_RETRIES , .result =SAM_STAT_CHECK_CONDITION , }, { - .sense =NOT_READY , + .sense_key =NOT_READY , .asc =SCMD_FAILURE_ASC_ANY , .ascq =SCMD_FAILURE_ASCQ_ANY , .allowed =SES_RETRIES ,
include/scsi/scsi_device.h +6 -6
@@ -508,18 +508,18 @@ extern void scsi_sanitize_inquiry_string(unsigned char *s, int len);*/ #define SCMD_FAILURE_STAT_ANY 0xff/* -* The following can be set to the scsi_failure sense, asc and ascq fields to -* match on any sense, ASC, or ASCQ value. +* The following can be set to the scsi_failure sense key, asc and ascq fields +* to match any sense key, ASC, and ASCQ value. */ -#define SCMD_FAILURE_SENSE_ANY 0xff -#define SCMD_FAILURE_ASC_ANY 0xff -#define SCMD_FAILURE_ASCQ_ANY 0xff +#define SCMD_FAILURE_SENSE_KEY_ANY 0xff +#define SCMD_FAILURE_ASC_ANY 0xff +#define SCMD_FAILURE_ASCQ_ANY 0xff/* Always retry a matching failure. */ #define SCMD_FAILURE_NO_LIMIT -1struct scsi_failure {int result; -u8 sense; +u8 sense_key;u8 asc;u8 ascq;/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1563/2151 scsi: core: Prepare for using combined sense codes
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Damien Le Moal <[email protected]>
[ Upstream commit ec5562d3ea803ec45831477129c626b2a22d2e2c ]
In preparation for handling sense codes and their qualifers as a single 16-bit sense code field, with the values defined as macros in include/scsi/scsi_sense.h, modify the definition of the structures scsi_failure and scsi_sense_hdr to introduce a 16-bit sense_code field as a union with the existing 8-bit asc and ascq fields.
This temporary modification allows accessing either the asc and ascq fields individually, or their combination as the 16-bit sense_code field.
The helper functions scsi_sense_asc(), scsi_sense_ascq() are defined to allow accessing the 8-bit ASC and ASCQ values from the sense_code filed of struct scsi_sense_hdr. The helper functions scsi_failure_asc() and scsi_failure_ascq() provide the same for the sense code field of struct scsi_failure.
The helper functions scsi_set_sense_buffer() and scsi_set_sense() are also added to wrap calls to scsi_build_sense_buffer() and scsi_build_sense() using a 16-bit sense code argument instead of the 8-bit ASC and ASCQ arguments.
Stable-dep-of: 92821c2358c7 ("scsi: hisi_sas: Fix spinup failure for SAS SSP devices in Active_Wait state")
--- include/scsi/scsi_cmnd.h | 7 +++++++ include/scsi/scsi_common.h | 31 +++++++++++++++++++++++++++++-- include/scsi/scsi_device.h | 25 +++++++++++++++++++++++-- 3 files changed, 59 insertions(+), 4 deletions(-)
include/scsi/scsi_cmnd.h +7 -0
@@ -394,6 +394,13 @@ static inline unsigned scsi_transfer_length(struct scsi_cmnd *scmd)extern void scsi_build_sense (struct scsi_cmnd *scmd,int desc,u8 key,u8 asc,u8 ascq); +static inline void scsi_set_sense (struct scsi_cmnd *scmd,int desc, +u8 key,u16 code) +{ +scsi_build_sense (scmd, desc, key,scsi_sense_code_asc (code), +scsi_sense_code_ascq (code)); +} +struct request *scsi_alloc_request (struct request_queue *q,blk_opf_t opf,blk_mq_req_flags_t flags);
include/scsi/scsi_common.h +29 -2
@@ -63,8 +63,18 @@ extern u64 scsilun_to_int(struct scsi_lun *);struct scsi_sense_hdr {/* See SPC-3 section 4.5 */ u8 response_code;/* permit: 0x0, 0x70, 0x71, 0x72, 0x73 */ u8 sense_key; -u8 asc; -u8 ascq; +union { +struct { +#if defined(__BIG_ENDIAN) +u8 asc; +u8 ascq; +#elif defined(__LITTLE_ENDIAN) +u8 ascq; +u8 asc; +#endif + }; +u16 sense_code; + };u8 byte4;u8 byte5;u8 byte6;
@@ -79,10 +89,27 @@ static inline bool scsi_sense_valid(const struct scsi_sense_hdr *sshdr)return (sshdr->response_code &0x70 ) ==0x70 ; } +static inline u8 scsi_sense_asc (const struct scsi_sense_hdr *sshdr) +{ +return scsi_sense_code_asc (sshdr->sense_code); +} + +static inline u8 scsi_sense_ascq (const struct scsi_sense_hdr *sshdr) +{ +return scsi_sense_code_ascq (sshdr->sense_code); +} +extern bool scsi_normalize_sense (const u8 *sense_buffer,int sb_len,struct scsi_sense_hdr *sshdr);extern void scsi_build_sense_buffer (int desc,u8 *buf,u8 key,u8 asc,u8 ascq); + +static inline void scsi_set_sense_buffer (int desc,u8 *buf,u8 key,u16 code) +{ +scsi_build_sense_buffer (desc, buf, key,scsi_sense_code_asc (code), +scsi_sense_code_ascq (code)); +} +int scsi_set_sense_information (u8 *buf,int buf_len,u64 info);int scsi_set_sense_field_pointer (u8 *buf,int buf_len,u16 fp,u8 bp,bool cd); extern const u8 * scsi_sense_desc_find(const u8 * sense_buffer, int sb_len,
include/scsi/scsi_device.h +23 -2
@@ -512,6 +512,7 @@ extern void scsi_sanitize_inquiry_string(unsigned char *s, int len);* to match any sense key, ASC, and ASCQ value. */ #define SCMD_FAILURE_SENSE_KEY_ANY 0xff +#define SCMD_FAILURE_SENSE_CODE_ANY 0xffff#define SCMD_FAILURE_ASC_ANY 0xff#define SCMD_FAILURE_ASCQ_ANY 0xff/* Always retry a matching failure. */
@@ -520,8 +521,18 @@ extern void scsi_sanitize_inquiry_string(unsigned char *s, int len);struct scsi_failure {int result;u8 sense_key; -u8 asc; -u8 ascq; +union { +struct { +#if defined(__BIG_ENDIAN) +u8 asc; +u8 ascq; +#elif defined(__LITTLE_ENDIAN) +u8 ascq; +u8 asc; +#endif + }; +u16 sense_code; + };/* * Number of times scsi_execute_cmd will retry the failure. It does * not count for the total_allowed.
@@ -531,6 +542,16 @@ struct scsi_failure {s8 retries; }; +static inline u8 scsi_failure_asc (const struct scsi_failure *failure) +{ +return scsi_sense_code_asc (failure->sense_code); +} + +static inline u8 scsi_failure_ascq (const struct scsi_failure *failure) +{ +return scsi_sense_code_ascq (failure->sense_code); +} +struct scsi_failures {/* * If a scsi_failure does not have a retry limit setup this limit will
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1564/2151 scsi: hisi_sas: Fix spinup failure for SAS SSP devices in Active_Wait state
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xingui Yang <[email protected]>
[ Upstream commit 92821c2358c78345909889793918af8763808bd4 ]
SAS HDDs powered up with RNOT=1 wait in Active_Wait state for a NOTIFY(ENABLE SPINUP) primitive and keep returning NOT_READY with ASC/ASCQ 0x04/0x11, causing endless mid-layer retries and spinup failure.
Parse the sense data in the slot completion path and, when LU_NOT_READY_NOTIFY_REQUIRED is returned by a directly-attached SSP device, queue work that sends the primitive from process context (sl_notify_ssp() contains msleep()). The work takes a runtime PM reference with pm_runtime_get_if_active(), pairing with pm_runtime_put_sync() in the work, so the controller stays resumed until the primitive is sent.
--- drivers/scsi/hisi_sas/hisi_sas.h | 3 ++ drivers/scsi/hisi_sas/hisi_sas_main.c | 43 ++++++++++++++++++++++++++ drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 4 +++ drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 4 +++ drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 4 +++ 5 files changed, 58 insertions(+)
drivers/scsi/hisi_sas/hisi_sas.h +3 -0
@@ -163,6 +163,7 @@ enum hisi_sas_phy_event {HISI_PHYE_PHY_UP =0U ,HISI_PHYE_LINK_RESET ,HISI_PHYE_PHY_UP_PM , +HISI_PHYE_SPINUP_NOTIFY , HISI_PHYES_NUM, };
@@ -689,4 +690,6 @@ extern void hisi_sas_sync_cqs(struct hisi_hba *hisi_hba);extern void hisi_sas_sync_poll_cqs (struct hisi_hba *hisi_hba);extern void hisi_sas_controller_reset_prepare (struct hisi_hba *hisi_hba);extern void hisi_sas_controller_reset_done (struct hisi_hba *hisi_hba); +extern void hisi_sas_spinup_notify (struct hisi_hba *hisi_hba, +struct sas_task *task);#endif
drivers/scsi/hisi_sas/hisi_sas_main.c +43 -0
59 lines not on this page · raw message
drivers/scsi/hisi_sas/hisi_sas_v1_hw.c +4 -0
@@ -1272,6 +1272,10 @@ static void slot_complete_v1_hw(struct hisi_hba *hisi_hba, &status_buffer->iu[0 ];sas_ssp_task_response (dev, task, iu); +if (unlikely (ts->stat ==SAS_SAM_STAT_CHECK_CONDITION && + !dev_parent_is_expander (device))) +hisi_sas_spinup_notify (hisi_hba, task); +break ; }case SAS_PROTOCOL_SMP :
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +4 -0
@@ -2427,6 +2427,10 @@ static void slot_complete_v2_hw(struct hisi_hba *hisi_hba, &status_buffer->iu[0 ];sas_ssp_task_response (dev, task, iu); +if (unlikely (ts->stat ==SAS_SAM_STAT_CHECK_CONDITION && + !dev_parent_is_expander (device))) +hisi_sas_spinup_notify (hisi_hba, task); +break ; }case SAS_PROTOCOL_SMP :
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +4 -0
@@ -2435,6 +2435,10 @@ static void slot_complete_v3_hw(struct hisi_hba *hisi_hba,sizeof (struct hisi_sas_err_record );sas_ssp_task_response (dev, task, iu); +if (unlikely (ts->stat ==SAS_SAM_STAT_CHECK_CONDITION && + !dev_parent_is_expander (device))) +hisi_sas_spinup_notify (hisi_hba, task); +break ; }case SAS_PROTOCOL_SMP : {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1565/2151 spmi: pmic-arb: return 0 in spmi_pmic_arb_register_buses() on success
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fenglin Wu <[email protected]>
[ Upstream commit 82f4c1948a4f951d7d501757a31c6a10eccd37ae ]
The "ret" could be returned with an uninitialized value. Fix it.
--- drivers/spmi/spmi-pmic-arb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spmi/spmi-pmic-arb.c +1 -1
@@ -1777,7 +1777,7 @@ static int spmi_pmic_arb_register_buses(struct spmi_pmic_arb *pmic_arb, } } -return ret; +return 0 ; }static void spmi_pmic_arb_deregister_buses (struct spmi_pmic_arb *pmic_arb)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1566/2151 dt-bindings: vendor-prefixes: add Ambarella
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Long Zhao <[email protected]>
[ Upstream commit 5ef299ffb56531b3a4f2b311000da76beed403ee ]
Document the Ambarella, Inc. vendor prefix so Ambarella DT bindings can be applied without waiting for the SoC series.
--- Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++ 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/vendor-prefixes.yaml +2 -0
@@ -108,6 +108,8 @@ patternProperties: description: Amarula Solutions "^amazon,.*": description: Amazon.com, Inc. + "^ambarella,.*": + description: Ambarella, Inc. "^amcc,.*": description: Applied Micro Circuits Corporation (APM, formally AMCC) "^amd,.*":
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1567/2151 ata: libahci: re-enable FBS after error handling on a port multiplier
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kyrylo Biryuk <[email protected]>
[ Upstream commit 23eab9e877497397a0e2394ee9174d576816209e ]
ahci_do_softreset() disables FBS before resetting a device behind a port multiplier, as required by AHCI 1.2 section 9.3.9, and re-enables it only when that softreset succeeds. If it fails, for example because a hot-plugged drive is still spinning up ("softreset failed (device not ready)"), EH escalates to a hardreset of the PMP link, and nothing turns FBS back on: only ahci_pmp_attach() does, which runs at the next boot. The port keeps working with command-based switching until then.
Seen on a Marvell 88SE9235 (1b4b:9235) with Marvell 88SM9705 port multipliers (1b4b:9705, in a Synology DX1222 expansion unit): after hot-plugging a drive, the kernel logged "FBS is disabled" followed by "softreset failed (device not ready)" and a PMP hardreset, and never "FBS is enabled" again (twice, on two different ports).
At the end of ahci_error_handler(), re-enable FBS if a PMP is still attached and FBS is supported but disabled.
--- drivers/ata/libahci.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
drivers/ata/libahci.c +15 -0
@@ -2236,6 +2236,21 @@ void ahci_error_handler(struct ata_port *ap)sata_pmp_error_handler (ap); +/* +* ahci_do_softreset() turns FBS off before resetting a fan-out link +* and turns it back on only if that reset succeeds. When it fails +* (e.g. a hot-plugged drive is still spinning up), EH escalates to a +* PMP hardreset, which never re-enables FBS, so the port would keep +* command-based switching until the PMP is attached again (reboot). +* Restore FBS once recovery is done and the PMP is still attached. +*/ +if (sata_pmp_attached (ap) &&ata_dev_enabled (ap->link.device)) { +struct ahci_port_priv *pp = ap->private_data; + +if (pp->fbs_supported && !pp->fbs_enabled) +ahci_enable_fbs (ap); + } +if (!ata_dev_enabled (ap->link.device)) hpriv->stop_engine (ap); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1568/2151 net: axienet: free outstanding TX buffers in axienet_dma_bd_release()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sagi Maimon <[email protected]>
[ Upstream commit 0c20cb4cfb40cf270d6c4c2c2ff5e5d72322644a ]
axienet_dma_bd_release() walks the RX ring to unmap and free every receive buffer before releasing it, but frees the TX descriptor ring with dma_free_coherent() alone. Any descriptor that axienet_free_tx_chain() had not yet reclaimed still holds its skb and its streaming DMA mapping, and both are lost.
axienet_stop() disables TX NAPI and stops the DMA engine before calling it, so nothing reclaims those descriptors afterwards. Bringing the interface down while frames are in flight therefore leaks up to lp->tx_bd_num skbs and mappings each time.
axienet_dma_err_handler() already walks the TX ring this way before it restarts the DMA engine: it unmaps every descriptor whose cntrl is still set - axienet_free_tx_chain() clears it on reclaim - frees any skb still attached, and clears the descriptor. Move that loop into a helper, axienet_free_tx_bufs(), and call it from axienet_dma_bd_release() too. This relies on axienet_stop() having stopped the DMA engine first, as the RX walk in the same function already does. The helper frees the skbs with dev_kfree_skb_any(), as drops: in the error handler, which runs from a workqueue, that frees them directly rather than deferring them to softirq as dev_kfree_skb_irq() did.
The walk must not run on a ring that is not there. axienet_open() does not check the result of the reset that runs axienet_dma_bd_init(), so when that reset fails tx_bd_v is either still NULL or, after an earlier close, points at the ring that close freed. Clear tx_bd_v and rx_bd_v once their rings are freed, and skip the walk when tx_bd_v is NULL. That also ends the second dma_free_coherent() of a stale ring which the same path already did. On the axienet_dma_bd_init() error path the TX ring has just been allocated zeroed, so the walk does nothing.
This was reported by the Sashiko AI review bot.
Tested on the AXI Ethernet MAC of an ADVA TimeCard X2 (PCIe card, with the built-in AXI DMA): traffic passes, and after each of ten down/up cycles and five module reloads, all made with traffic running and each running axienet_dma_bd_release(), traffic resumes and nothing is logged. The leak itself was not measured, and neither the failed-reset paths nor axienet_dma_err_handler() were exercised.
--- .../net/ethernet/xilinx/xilinx_axienet_main.c | 74 +++++++++++++------ 1 file changed, 50 insertions(+), 24 deletions(-)
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +50 -24
@@ -173,6 +173,46 @@ static dma_addr_t desc_get_phys_addr(struct axienet_local *lp,return ret; } +/** +* axienet_free_tx_bufs - Release the buffers still held by the TX ring +* @lp: Pointer to the axienet_local structure +* +* Unmap every descriptor whose mapping is still live, free any skb still +* attached, and clear the descriptor for reuse. axienet_free_tx_chain() +* clears cntrl when it reclaims a descriptor, so a non-zero value means +* the mapping is live. The DMA engine must be stopped. +*/ +static void axienet_free_tx_bufs (struct axienet_local *lp) +{ +struct axidma_bd *cur_p; +u32 i; + +for (i =0 ; i < lp->tx_bd_num; i++) { + cur_p = &lp->tx_bd_v[i]; +if (cur_p->cntrl) { +dma_addr_t addr =desc_get_phys_addr (lp, cur_p); + +dma_unmap_single (lp->dev, addr, + (cur_p->cntrl & +XAXIDMA_BD_CTRL_LENGTH_MASK ), +DMA_TO_DEVICE ); + } +/* not reclaimed by axienet_free_tx_chain(), so a drop */ +if (cur_p->skb) +dev_kfree_skb_any (cur_p->skb); + cur_p->phys =0 ; + cur_p->phys_msb =0 ; + cur_p->cntrl =0 ; + cur_p->status =0 ; + cur_p->app0 =0 ; + cur_p->app1 =0 ; + cur_p->app2 =0 ; + cur_p->app3 =0 ; + cur_p->app4 =0 ; + cur_p->skb =NULL ; + } +} +/** * axienet_dma_bd_release - Release buffer descriptor rings * @ndev: Pointer to the net_device structure
@@ -186,11 +226,18 @@ static void axienet_dma_bd_release(struct net_device *ndev)int i;struct axienet_local *lp =netdev_priv (ndev); -/* If we end up here, tx_bd_v must have been DMA allocated. */ +/* tx_bd_v is NULL if axienet_dma_bd_init() did not get as far as +* allocating it, and is cleared below once the ring is freed; +* dma_free_coherent() accepts NULL. +*/ +if (lp->tx_bd_v) +axienet_free_tx_bufs (lp); +dma_free_coherent (lp->dev,sizeof (*lp->tx_bd_v) * lp->tx_bd_num, lp->tx_bd_v, lp->tx_bd_p); + lp->tx_bd_v =NULL ;if (!lp->rx_bd_v)return ;
@@ -221,6 +268,7 @@ static void axienet_dma_bd_release(struct net_device *ndev)sizeof (*lp->rx_bd_v) * lp->rx_bd_num, lp->rx_bd_v, lp->rx_bd_p); + lp->rx_bd_v =NULL ; }static u64 axienet_dma_rate (struct axienet_local *lp)
@@ -2732,29 +2780,7 @@ static void axienet_dma_err_handler(struct work_struct *work)axienet_dma_stop (lp);netdev_reset_queue (ndev); -for (i =0 ; i < lp->tx_bd_num; i++) { - cur_p = &lp->tx_bd_v[i]; -if (cur_p->cntrl) { -dma_addr_t addr =desc_get_phys_addr (lp, cur_p); - -dma_unmap_single (lp->dev, addr, - (cur_p->cntrl & -XAXIDMA_BD_CTRL_LENGTH_MASK ), -DMA_TO_DEVICE ); - } -if (cur_p->skb) -dev_kfree_skb_irq (cur_p->skb); - cur_p->phys =0 ; - cur_p->phys_msb =0 ; - cur_p->cntrl =0 ; - cur_p->status =0 ; - cur_p->app0 =0 ; - cur_p->app1 =0 ; - cur_p->app2 =0 ; - cur_p->app3 =0 ; - cur_p->app4 =0 ; - cur_p->skb =NULL ; - } +axienet_free_tx_bufs (lp);for (i =0 ; i < lp->rx_bd_num; i++) { cur_p = &lp->rx_bd_v[i];
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1569/2151 ata: libata: Move quirk flags to their own enum
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Niklas Cassel <[email protected]>
[ Upstream commit a42b71d49945aac0b943987cbdec1d1c805caab3 ]
The anonymous enum in include/linux/libata.h that is used to store various global constants can currently be backed by type int. (It contains both negative and positive constants.)
__ATA_QUIRK_MAX is currently 31.
The quirk flags in the various global constants enum are defined as "1U << quirk_flag_bit".
Thus if we simply add an additional quirk, the quirk flag will be 1 << 31, which is a value that is too large to be represented by a signed int. The various global constants enum will thus therefore be backed by type long.
This will lead to error prints like e.g.:
ata_port_err(ap, "EH pending after %d tries, giving up\n",
ATA_EH_MAX_TRIES);
now failing to build, with build error:
error: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘long int’ [-Werror=format=]
This is because all constants in the various global constants enum now has to be printed as a long, as that is now the backing type of the enum.
Since the compiler will use the smallest possible backing type for an enum, it is good practice to not mix unrelated things in a single enum.
Move the quirk flags to a separate enum, so that we don't need to change the printf specifier for all other constants in the "various global constants" enum when adding an additional quirk.
Stable-dep-of: 4153718a215e ("ata: libata-core: Fix NO_FUA quirks shadowed by earlier quirk entries")
--- include/linux/libata.h | 74 ++++++++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 36 deletions(-)
include/linux/libata.h +38 -36
@@ -85,6 +85,44 @@ enum ata_quirks { __ATA_QUIRK_MAX, }; +/* +* Quirk flags: may be set by libata or controller drivers on drives. +* Some quirks may be drive/controller pair dependent. +*/ +enum { +ATA_QUIRK_DIAGNOSTIC = (1U << __ATA_QUIRK_DIAGNOSTIC), +ATA_QUIRK_NODMA = (1U << __ATA_QUIRK_NODMA), +ATA_QUIRK_NONCQ = (1U << __ATA_QUIRK_NONCQ), +ATA_QUIRK_MAX_SEC_128 = (1U << __ATA_QUIRK_MAX_SEC_128), +ATA_QUIRK_BROKEN_HPA = (1U << __ATA_QUIRK_BROKEN_HPA), +ATA_QUIRK_DISABLE = (1U << __ATA_QUIRK_DISABLE), +ATA_QUIRK_HPA_SIZE = (1U << __ATA_QUIRK_HPA_SIZE), +ATA_QUIRK_IVB = (1U << __ATA_QUIRK_IVB), +ATA_QUIRK_STUCK_ERR = (1U << __ATA_QUIRK_STUCK_ERR), +ATA_QUIRK_BRIDGE_OK = (1U << __ATA_QUIRK_BRIDGE_OK), +ATA_QUIRK_ATAPI_MOD16_DMA = (1U << __ATA_QUIRK_ATAPI_MOD16_DMA), +ATA_QUIRK_FIRMWARE_WARN = (1U << __ATA_QUIRK_FIRMWARE_WARN), +ATA_QUIRK_1_5_GBPS = (1U << __ATA_QUIRK_1_5_GBPS), +ATA_QUIRK_NOSETXFER = (1U << __ATA_QUIRK_NOSETXFER), +ATA_QUIRK_BROKEN_FPDMA_AA = (1U << __ATA_QUIRK_BROKEN_FPDMA_AA), +ATA_QUIRK_DUMP_ID = (1U << __ATA_QUIRK_DUMP_ID), +ATA_QUIRK_MAX_SEC_LBA48 = (1U << __ATA_QUIRK_MAX_SEC_LBA48), +ATA_QUIRK_ATAPI_DMADIR = (1U << __ATA_QUIRK_ATAPI_DMADIR), +ATA_QUIRK_NO_NCQ_TRIM = (1U << __ATA_QUIRK_NO_NCQ_TRIM), +ATA_QUIRK_NOLPM = (1U << __ATA_QUIRK_NOLPM), +ATA_QUIRK_WD_BROKEN_LPM = (1U << __ATA_QUIRK_WD_BROKEN_LPM), +ATA_QUIRK_ZERO_AFTER_TRIM = (1U << __ATA_QUIRK_ZERO_AFTER_TRIM), +ATA_QUIRK_NO_DMA_LOG = (1U << __ATA_QUIRK_NO_DMA_LOG), +ATA_QUIRK_NOTRIM = (1U << __ATA_QUIRK_NOTRIM), +ATA_QUIRK_MAX_SEC_1024 = (1U << __ATA_QUIRK_MAX_SEC_1024), +ATA_QUIRK_MAX_TRIM_128M = (1U << __ATA_QUIRK_MAX_TRIM_128M), +ATA_QUIRK_NO_NCQ_ON_ATI = (1U << __ATA_QUIRK_NO_NCQ_ON_ATI), +ATA_QUIRK_NO_LPM_ON_ATI = (1U << __ATA_QUIRK_NO_LPM_ON_ATI), +ATA_QUIRK_NO_ID_DEV_LOG = (1U << __ATA_QUIRK_NO_ID_DEV_LOG), +ATA_QUIRK_NO_LOG_DIR = (1U << __ATA_QUIRK_NO_LOG_DIR), +ATA_QUIRK_NO_FUA = (1U << __ATA_QUIRK_NO_FUA), +}; +enum {/* various global constants */ LIBATA_MAX_PRD =ATA_MAX_PRD /2 ,
@@ -391,42 +429,6 @@ enum {*/ ATA_EH_CMD_TIMEOUT_TABLE_SIZE =9 , -/* -* Quirk flags: may be set by libata or controller drivers on drives. -* Some quirks may be drive/controller pair dependent. -*/ -ATA_QUIRK_DIAGNOSTIC = (1U << __ATA_QUIRK_DIAGNOSTIC), -ATA_QUIRK_NODMA = (1U << __ATA_QUIRK_NODMA), -ATA_QUIRK_NONCQ = (1U << __ATA_QUIRK_NONCQ), -ATA_QUIRK_MAX_SEC_128 = (1U << __ATA_QUIRK_MAX_SEC_128), -ATA_QUIRK_BROKEN_HPA = (1U << __ATA_QUIRK_BROKEN_HPA), -ATA_QUIRK_DISABLE = (1U << __ATA_QUIRK_DISABLE), -ATA_QUIRK_HPA_SIZE = (1U << __ATA_QUIRK_HPA_SIZE), -ATA_QUIRK_IVB = (1U << __ATA_QUIRK_IVB), -ATA_QUIRK_STUCK_ERR = (1U << __ATA_QUIRK_STUCK_ERR), -ATA_QUIRK_BRIDGE_OK = (1U << __ATA_QUIRK_BRIDGE_OK), -ATA_QUIRK_ATAPI_MOD16_DMA = (1U << __ATA_QUIRK_ATAPI_MOD16_DMA), -ATA_QUIRK_FIRMWARE_WARN = (1U << __ATA_QUIRK_FIRMWARE_WARN), -ATA_QUIRK_1_5_GBPS = (1U << __ATA_QUIRK_1_5_GBPS), -ATA_QUIRK_NOSETXFER = (1U << __ATA_QUIRK_NOSETXFER), -ATA_QUIRK_BROKEN_FPDMA_AA = (1U << __ATA_QUIRK_BROKEN_FPDMA_AA), -ATA_QUIRK_DUMP_ID = (1U << __ATA_QUIRK_DUMP_ID), -ATA_QUIRK_MAX_SEC_LBA48 = (1U << __ATA_QUIRK_MAX_SEC_LBA48), -ATA_QUIRK_ATAPI_DMADIR = (1U << __ATA_QUIRK_ATAPI_DMADIR), -ATA_QUIRK_NO_NCQ_TRIM = (1U << __ATA_QUIRK_NO_NCQ_TRIM), -ATA_QUIRK_NOLPM = (1U << __ATA_QUIRK_NOLPM), -ATA_QUIRK_WD_BROKEN_LPM = (1U << __ATA_QUIRK_WD_BROKEN_LPM), -ATA_QUIRK_ZERO_AFTER_TRIM = (1U << __ATA_QUIRK_ZERO_AFTER_TRIM), -ATA_QUIRK_NO_DMA_LOG = (1U << __ATA_QUIRK_NO_DMA_LOG), -ATA_QUIRK_NOTRIM = (1U << __ATA_QUIRK_NOTRIM), -ATA_QUIRK_MAX_SEC_1024 = (1U << __ATA_QUIRK_MAX_SEC_1024), -ATA_QUIRK_MAX_TRIM_128M = (1U << __ATA_QUIRK_MAX_TRIM_128M), -ATA_QUIRK_NO_NCQ_ON_ATI = (1U << __ATA_QUIRK_NO_NCQ_ON_ATI), -ATA_QUIRK_NO_LPM_ON_ATI = (1U << __ATA_QUIRK_NO_LPM_ON_ATI), -ATA_QUIRK_NO_ID_DEV_LOG = (1U << __ATA_QUIRK_NO_ID_DEV_LOG), -ATA_QUIRK_NO_LOG_DIR = (1U << __ATA_QUIRK_NO_LOG_DIR), -ATA_QUIRK_NO_FUA = (1U << __ATA_QUIRK_NO_FUA), -/* User visible DMA mask for DMA control. DO NOT renumber. */ ATA_DMA_MASK_ATA = (1 <<0 ),/* DMA on ATA Disk */ ATA_DMA_MASK_ATAPI = (1 << 1), /* DMA on ATAPI */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1570/2151 ata: libata-core: Quirk DELLBOSS VD max_sectors
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Niklas Cassel <[email protected]>
[ Upstream commit 2e983271363108b3813b38754eb96d9b1cb252bb ]
Commit 9b8b84879d4a ("block: Increase BLK_DEF_MAX_SECTORS_CAP") increased the default max_sectors_kb from 1280 KiB to 4096 KiB.
DELLBOSS VD with FW rev MV.R00-0 times out when sending I/Os of size 4096 KiB.
Enable ATA_QUIRK_MAX_SEC, with value 8191 (sectors) for this device, since any I/O with more sectors than that lead to I/O timeouts.
With this, the DELLBOSS VD SATA controller is usable again.
Stable-dep-of: 4153718a215e ("ata: libata-core: Fix NO_FUA quirks shadowed by earlier quirk entries")
--- drivers/ata/libata-core.c | 11 +++++++++++ include/linux/ata.h | 1 + include/linux/libata.h | 2 ++ 3 files changed, 14 insertions(+)
drivers/ata/libata-core.c +11 -0
@@ -3203,6 +3203,10 @@ int ata_dev_configure(struct ata_device *dev) dev->max_sectors = min_t(unsigned int, ATA_MAX_SECTORS_1024, dev->max_sectors); +if (dev->quirks &ATA_QUIRK_MAX_SEC_8191 ) + dev->max_sectors = min_t(unsigned int, ATA_MAX_SECTORS_8191, + dev->max_sectors); +if (dev->quirks &ATA_QUIRK_MAX_SEC_LBA48 ) dev->max_sectors =ATA_MAX_SECTORS_LBA48 ;
@@ -4055,6 +4059,7 @@ static const char * const ata_quirk_names[] = { [__ATA_QUIRK_NO_DMA_LOG] = "nodmalog", [__ATA_QUIRK_NOTRIM] = "notrim", [__ATA_QUIRK_MAX_SEC_1024] = "maxsec1024", + [__ATA_QUIRK_MAX_SEC_8191] = "maxsec8191", [__ATA_QUIRK_MAX_TRIM_128M] = "maxtrim128m", [__ATA_QUIRK_NO_NCQ_ON_ATI] = "noncqonati", [__ATA_QUIRK_NO_LPM_ON_ATI] = "nolpmonati",
@@ -4161,6 +4166,12 @@ static const struct ata_dev_quirks_entry __ata_dev_quirks[] = { { "LITEON CX1-JB*-HP", NULL, ATA_QUIRK_MAX_SEC_1024 }, { "LITEON EP1-*", NULL, ATA_QUIRK_MAX_SEC_1024 }, +/* +* These devices time out with higher max sects. +* https://bugzilla.kernel.org/show_bug.cgi?id=220693 +*/ + { "DELLBOSS VD", "MV.R00-0", ATA_QUIRK_MAX_SEC_8191 }, +/* Devices we expect to fail diagnostics */ /* Devices where NCQ should be avoided */
include/linux/ata.h +1 -0
@@ -29,6 +29,7 @@ enum {ATA_MAX_SECTORS_128 =128 ,ATA_MAX_SECTORS =256 ,ATA_MAX_SECTORS_1024 =1024 , +ATA_MAX_SECTORS_8191 =8191 ,ATA_MAX_SECTORS_LBA48 =65535 ,/* avoid count to be 0000h */ ATA_MAX_SECTORS_TAPE =65535 , ATA_MAX_TRIM_RNUM = 64, /* 512-byte payload / (6-byte LBA + 2-byte range per entry) */
include/linux/libata.h +2 -0
@@ -75,6 +75,7 @@ enum ata_quirks { __ATA_QUIRK_NO_DMA_LOG,/* Do not use DMA for log read */ __ATA_QUIRK_NOTRIM,/* Do not use TRIM */ __ATA_QUIRK_MAX_SEC_1024,/* Limit max sects to 1024 */ + __ATA_QUIRK_MAX_SEC_8191,/* Limit max sects to 8191 */ __ATA_QUIRK_MAX_TRIM_128M,/* Limit max trim size to 128M */ __ATA_QUIRK_NO_NCQ_ON_ATI,/* Disable NCQ on ATI chipset */ __ATA_QUIRK_NO_LPM_ON_ATI, /* Disable LPM on ATI chipset */
@@ -115,6 +116,7 @@ enum {ATA_QUIRK_NO_DMA_LOG = (1U << __ATA_QUIRK_NO_DMA_LOG),ATA_QUIRK_NOTRIM = (1U << __ATA_QUIRK_NOTRIM),ATA_QUIRK_MAX_SEC_1024 = (1U << __ATA_QUIRK_MAX_SEC_1024), +ATA_QUIRK_MAX_SEC_8191 = (1U << __ATA_QUIRK_MAX_SEC_8191),ATA_QUIRK_MAX_TRIM_128M = (1U << __ATA_QUIRK_MAX_TRIM_128M),ATA_QUIRK_NO_NCQ_ON_ATI = (1U << __ATA_QUIRK_NO_NCQ_ON_ATI), ATA_QUIRK_NO_LPM_ON_ATI = (1U << __ATA_QUIRK_NO_LPM_ON_ATI),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1571/2151 ata: libata: Add ATA_QUIRK_MAX_SEC and convert all device quirks
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Niklas Cassel <[email protected]>
[ Upstream commit 59b7bb3d48333889adb1dd2aac3ab0cf26714390 ]
Add a new quirk ATA_QUIRK_MAX_SEC, which has a separate table with device specific values.
Convert all existing ATA_QUIRK_MAX_SEC_XXX device quirks in __ata_dev_quirks to the new format.
Quirks ATA_QUIRK_MAX_SEC_128 and ATA_QUIRK_MAX_SEC_1024 cannot be removed yet, since they are also used by libata.force, which functionally, is a separate user of the quirks. The quirks will be removed once all users have been converted to use the new format.
The quirk ATA_QUIRK_MAX_SEC_8191 can be removed since it has no equivalent libata.force parameter.
Stable-dep-of: 4153718a215e ("ata: libata-core: Fix NO_FUA quirks shadowed by earlier quirk entries")
--- drivers/ata/libata-core.c | 68 +++++++++++++++++++++++++++++++++------ include/linux/ata.h | 1 - include/linux/libata.h | 4 +-- 3 files changed, 61 insertions(+), 12 deletions(-)
drivers/ata/libata-core.c +59 -9
@@ -77,6 +77,7 @@ static unsigned int ata_dev_init_params(struct ata_device *dev,static unsigned int ata_dev_set_xfermode (struct ata_device *dev);static void ata_dev_xfermask (struct ata_device *dev);static unsigned int ata_dev_quirks (const struct ata_device *dev); +static u64 ata_dev_get_quirk_value (struct ata_device *dev,unsigned int quirk);static DEFINE_IDA (ata_ida);
@@ -3203,9 +3204,10 @@ int ata_dev_configure(struct ata_device *dev) dev->max_sectors = min_t(unsigned int, ATA_MAX_SECTORS_1024, dev->max_sectors); -if (dev->quirks &ATA_QUIRK_MAX_SEC_8191 ) - dev->max_sectors = min_t(unsigned int, ATA_MAX_SECTORS_8191, - dev->max_sectors); +if (dev->quirks &ATA_QUIRK_MAX_SEC ) + dev->max_sectors = min_t(unsigned int, dev->max_sectors, +ata_dev_get_quirk_value (dev, +ATA_QUIRK_MAX_SEC ));if (dev->quirks &ATA_QUIRK_MAX_SEC_LBA48 ) dev->max_sectors =ATA_MAX_SECTORS_LBA48 ;
@@ -4059,7 +4061,7 @@ static const char * const ata_quirk_names[] = { [__ATA_QUIRK_NO_DMA_LOG] = "nodmalog", [__ATA_QUIRK_NOTRIM] = "notrim", [__ATA_QUIRK_MAX_SEC_1024] = "maxsec1024", - [__ATA_QUIRK_MAX_SEC_8191] = "maxsec8191", + [__ATA_QUIRK_MAX_SEC] = "maxsec", [__ATA_QUIRK_MAX_TRIM_128M] = "maxtrim128m", [__ATA_QUIRK_NO_NCQ_ON_ATI] = "noncqonati", [__ATA_QUIRK_NO_LPM_ON_ATI] = "nolpmonati",
@@ -4104,6 +4106,21 @@ static void ata_dev_print_quirks(const struct ata_device *dev,kfree (str); } +struct ata_dev_quirk_value { +const char *model_num; +const char *model_rev; +u64 val; +}; + +static const struct ata_dev_quirk_value __ata_dev_max_sec_quirks[] = { + {"TORiSAN DVD-ROM DRD-N216" ,NULL ,128 }, + {"ST380013AS" ,"3.20" ,1024 }, + {"LITEON CX1-JB*-HP" ,NULL ,1024 }, + {"LITEON EP1-*" ,NULL ,1024 }, + {"DELLBOSS VD" ,"MV.R00-0" ,8191 }, + { }, +}; +struct ata_dev_quirks_entry {const char *model_num;const char *model_rev;
@@ -4148,7 +4165,7 @@ static const struct ata_dev_quirks_entry __ata_dev_quirks[] = { { "ASMT109x- Config", NULL, ATA_QUIRK_DISABLE },/* Weird ATAPI devices */ - { "TORiSAN DVD-ROM DRD-N216", NULL, ATA_QUIRK_MAX_SEC_128 }, + { "TORiSAN DVD-ROM DRD-N216", NULL, ATA_QUIRK_MAX_SEC }, { "QUANTUM DAT DAT72-000", NULL, ATA_QUIRK_ATAPI_MOD16_DMA }, { "Slimtype DVD A DS8A8SH", NULL, ATA_QUIRK_MAX_SEC_LBA48 }, { "Slimtype DVD A DS8A9SH", NULL, ATA_QUIRK_MAX_SEC_LBA48 },
@@ -4157,20 +4174,20 @@ static const struct ata_dev_quirks_entry __ata_dev_quirks[] = {* Causes silent data corruption with higher max sects. * http://lkml.kernel.org/g/[email protected] */ - { "ST380013AS", "3.20", ATA_QUIRK_MAX_SEC_1024 }, + { "ST380013AS", "3.20", ATA_QUIRK_MAX_SEC },/* * These devices time out with higher max sects. * https://bugzilla.kernel.org/show_bug.cgi?id=121671 */ - { "LITEON CX1-JB*-HP", NULL, ATA_QUIRK_MAX_SEC_1024 }, - { "LITEON EP1-*", NULL, ATA_QUIRK_MAX_SEC_1024 }, + { "LITEON CX1-JB*-HP", NULL, ATA_QUIRK_MAX_SEC }, + { "LITEON EP1-*", NULL, ATA_QUIRK_MAX_SEC },/* * These devices time out with higher max sects. * https://bugzilla.kernel.org/show_bug.cgi?id=220693 */ - { "DELLBOSS VD", "MV.R00-0", ATA_QUIRK_MAX_SEC_8191 }, + { "DELLBOSS VD", "MV.R00-0", ATA_QUIRK_MAX_SEC }, /* Devices we expect to fail diagnostics */
@@ -4441,6 +4458,39 @@ static unsigned int ata_dev_quirks(const struct ata_device *dev)return 0 ; } +static u64 ata_dev_get_max_sec_quirk_value (struct ata_device *dev) +{ +unsigned char model_num[ATA_ID_PROD_LEN +1 ]; +unsigned char model_rev[ATA_ID_FW_REV_LEN +1 ]; +const struct ata_dev_quirk_value *ad = __ata_dev_max_sec_quirks; +u64 val =0 ; + +ata_id_c_string (dev->id, model_num,ATA_ID_PROD ,sizeof (model_num)); +ata_id_c_string (dev->id, model_rev,ATA_ID_FW_REV ,sizeof (model_rev)); + +while (ad->model_num) { +if (glob_match (ad->model_num, model_num) && + (!ad->model_rev ||glob_match (ad->model_rev, model_rev))) { + val = ad->val; +break ; + } + ad++; + } + +ata_dev_warn (dev,"%s quirk is using value: %llu\n" , + ata_quirk_names[__ATA_QUIRK_MAX_SEC], val); + +return val; +} + +static u64 ata_dev_get_quirk_value (struct ata_device *dev,unsigned int quirk) +{ +if (quirk ==ATA_QUIRK_MAX_SEC ) +return ata_dev_get_max_sec_quirk_value (dev); + +return 0 ; +} +static bool ata_dev_nodma (const struct ata_device *dev) {/*
include/linux/ata.h +0 -1
@@ -29,7 +29,6 @@ enum {ATA_MAX_SECTORS_128 =128 ,ATA_MAX_SECTORS =256 ,ATA_MAX_SECTORS_1024 =1024 , -ATA_MAX_SECTORS_8191 =8191 ,ATA_MAX_SECTORS_LBA48 =65535 ,/* avoid count to be 0000h */ ATA_MAX_SECTORS_TAPE =65535 , ATA_MAX_TRIM_RNUM = 64, /* 512-byte payload / (6-byte LBA + 2-byte range per entry) */
include/linux/libata.h +2 -2
@@ -75,7 +75,7 @@ enum ata_quirks { __ATA_QUIRK_NO_DMA_LOG,/* Do not use DMA for log read */ __ATA_QUIRK_NOTRIM,/* Do not use TRIM */ __ATA_QUIRK_MAX_SEC_1024,/* Limit max sects to 1024 */ - __ATA_QUIRK_MAX_SEC_8191,/* Limit max sects to 8191 */ + __ATA_QUIRK_MAX_SEC,/* Limit max sectors */ __ATA_QUIRK_MAX_TRIM_128M,/* Limit max trim size to 128M */ __ATA_QUIRK_NO_NCQ_ON_ATI,/* Disable NCQ on ATI chipset */ __ATA_QUIRK_NO_LPM_ON_ATI, /* Disable LPM on ATI chipset */
@@ -116,7 +116,7 @@ enum {ATA_QUIRK_NO_DMA_LOG = (1U << __ATA_QUIRK_NO_DMA_LOG),ATA_QUIRK_NOTRIM = (1U << __ATA_QUIRK_NOTRIM),ATA_QUIRK_MAX_SEC_1024 = (1U << __ATA_QUIRK_MAX_SEC_1024), -ATA_QUIRK_MAX_SEC_8191 = (1U << __ATA_QUIRK_MAX_SEC_8191), +ATA_QUIRK_MAX_SEC = (1U << __ATA_QUIRK_MAX_SEC),ATA_QUIRK_MAX_TRIM_128M = (1U << __ATA_QUIRK_MAX_TRIM_128M),ATA_QUIRK_NO_NCQ_ON_ATI = (1U << __ATA_QUIRK_NO_NCQ_ON_ATI), ATA_QUIRK_NO_LPM_ON_ATI = (1U << __ATA_QUIRK_NO_LPM_ON_ATI),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1572/2151 ata: libata-core: Quirk INTEL SSDSC2KG480G8 max_sectors
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Niklas Cassel <[email protected]>
[ Upstream commit 5f64ae1ef639a2bab7e39497c55f76cc0682f108 ]
Commit 9b8b84879d4a ("block: Increase BLK_DEF_MAX_SECTORS_CAP") increased the default max_sectors_kb from 1280 KiB to 4096 KiB.
INTEL SSDSC2KG480G8 with FW rev XCV10120 times out when sending I/Os of size 4096 KiB.
Enable ATA_QUIRK_MAX_SEC, with value 8191 (sectors) for this device, since any I/O with more sectors than that lead to I/O timeouts.
With this, the INTEL SSDSC2KG480G8 is usable again.
Stable-dep-of: 4153718a215e ("ata: libata-core: Fix NO_FUA quirks shadowed by earlier quirk entries")
--- drivers/ata/libata-core.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/ata/libata-core.c +3 -0
@@ -4118,6 +4118,7 @@ static const struct ata_dev_quirk_value __ata_dev_max_sec_quirks[] = { { "LITEON CX1-JB*-HP", NULL, 1024 }, { "LITEON EP1-*", NULL, 1024 }, { "DELLBOSS VD", "MV.R00-0", 8191 }, + { "INTEL SSDSC2KG480G8", "XCV10120", 8191 }, { }, };
@@ -4383,6 +4384,8 @@ static const struct ata_dev_quirks_entry __ata_dev_quirks[] = { { "Micron*", NULL, ATA_QUIRK_ZERO_AFTER_TRIM }, { "Crucial*", NULL, ATA_QUIRK_ZERO_AFTER_TRIM }, + { "INTEL SSDSC2KG480G8", "XCV10120", ATA_QUIRK_ZERO_AFTER_TRIM | + ATA_QUIRK_MAX_SEC }, { "INTEL*SSD*", NULL, ATA_QUIRK_ZERO_AFTER_TRIM }, { "SSD*INTEL*", NULL, ATA_QUIRK_ZERO_AFTER_TRIM }, { "Samsung*SSD*", NULL, ATA_QUIRK_ZERO_AFTER_TRIM },
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1573/2151 ata: libata-core: Fix NO_FUA quirks shadowed by earlier quirk entries
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Niklas Cassel <[email protected]>
[ Upstream commit 4153718a215eeb5bab3df50417bbd9602e84658c ]
ata_dev_quirks() uses the first entry in __ata_dev_quirks[] that matches the device and ignores all later entries. Commit 38d431229bfb ("ata: libata: exclude FUA support for known buggy drives") appended three ATA_QUIRK_NO_FUA entries to the end of the table, with model patterns meant to cover whole product lines. Earlier entries already match some or all of these drives, so NO_FUA is not always applied:
- "INTEL*SSDSC2CT*" never takes effect. Every model it matches also matches the earlier "INTEL*SSD*" entry, so these drives only get ATA_QUIRK_ZERO_AFTER_TRIM.
- "WDC*WD2500J*" does not take effect for "WDC WD2500JD-*" drives, which match the earlier ATA_QUIRK_WD_BROKEN_LPM entry.
- "OCZ-VERTEX*" does not take effect for "OCZ-VERTEX" drives with firmware "1.30", which match the earlier ATA_QUIRK_BROKEN_HPA entry.
Move the Intel entry in front of "INTEL*SSD*" and keep ATA_QUIRK_ZERO_AFTER_TRIM in it, so these drives stay on the ZERO_AFTER_TRIM whitelist. Add ATA_QUIRK_NO_FUA to the WD2500JD and OCZ Vertex 1.30 entries. The quirks of all other drives are unchanged.
libata only uses FUA when it is enabled with libata.fua=1, so systems using the default setting are not affected.
--- drivers/ata/libata-core.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/ata/libata-core.c +6 -3
@@ -4250,7 +4250,8 @@ static const struct ata_dev_quirks_entry __ata_dev_quirks[] = { { "MAXTOR 6L080L4", "A93.0500", ATA_QUIRK_BROKEN_HPA },/* this one allows HPA unlocking but fails IOs on the area */ - { "OCZ-VERTEX", "1.30", ATA_QUIRK_BROKEN_HPA }, + { "OCZ-VERTEX", "1.30", ATA_QUIRK_BROKEN_HPA | + ATA_QUIRK_NO_FUA },/* Devices which report 1 sector over size HPA */ { "ST340823A", NULL, ATA_QUIRK_HPA_SIZE },
@@ -4386,6 +4387,8 @@ static const struct ata_dev_quirks_entry __ata_dev_quirks[] = { { "Crucial*", NULL, ATA_QUIRK_ZERO_AFTER_TRIM }, { "INTEL SSDSC2KG480G8", "XCV10120", ATA_QUIRK_ZERO_AFTER_TRIM | ATA_QUIRK_MAX_SEC }, + { "INTEL*SSDSC2CT*", NULL, ATA_QUIRK_ZERO_AFTER_TRIM | + ATA_QUIRK_NO_FUA }, { "INTEL*SSD*", NULL, ATA_QUIRK_ZERO_AFTER_TRIM }, { "SSD*INTEL*", NULL, ATA_QUIRK_ZERO_AFTER_TRIM }, { "Samsung*SSD*", NULL, ATA_QUIRK_ZERO_AFTER_TRIM },
@@ -4406,7 +4409,8 @@ static const struct ata_dev_quirks_entry __ata_dev_quirks[] = { { "WDC WD1200JD-*", NULL, ATA_QUIRK_WD_BROKEN_LPM }, { "WDC WD1600JD-*", NULL, ATA_QUIRK_WD_BROKEN_LPM }, { "WDC WD2000JD-*", NULL, ATA_QUIRK_WD_BROKEN_LPM }, - { "WDC WD2500JD-*", NULL, ATA_QUIRK_WD_BROKEN_LPM }, + { "WDC WD2500JD-*", NULL, ATA_QUIRK_WD_BROKEN_LPM | + ATA_QUIRK_NO_FUA }, { "WDC WD3000JD-*", NULL, ATA_QUIRK_WD_BROKEN_LPM }, { "WDC WD3200JD-*", NULL, ATA_QUIRK_WD_BROKEN_LPM },
@@ -4431,7 +4435,6 @@ static const struct ata_dev_quirks_entry __ata_dev_quirks[] = { { "Maxtor", "BANC1G10", ATA_QUIRK_NO_FUA }, { "WDC*WD2500J*", NULL, ATA_QUIRK_NO_FUA }, { "OCZ-VERTEX*", NULL, ATA_QUIRK_NO_FUA }, - { "INTEL*SSDSC2CT*", NULL, ATA_QUIRK_NO_FUA }, /* End Marker */ { }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1574/2151 selftests/bpf: Use its own netns in flow_dissector_skb_less_direct_attach
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qiliang Yuan <[email protected]>
[ Upstream commit 76c1913f311f32971dc2c3e106e285bd63c1804d ]
test_flow_dissector_skb_less_direct_attach() and test_flow_dissector_skb_less_indirect_attach() each create a netns to run in, and test_progs may run the two at the same time.
Both name their netns flow_dissector_skb_less_indirect_attach_ns. When the two tests overlap, one of them fails to create or open the netns, or loses it to the cleanup of the other one.
Name the netns of the direct attach test after that test.
--- tools/testing/selftests/bpf/prog_tests/flow_dissector.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/bpf/prog_tests/flow_dissector.c +1 -1
@@ -706,7 +706,7 @@ void test_flow_dissector_skb_less_direct_attach(void)struct bpf_flow *skel;struct netns_obj *ns; - ns =netns_new ("flow_dissector_skb_less_indirect_attach_ns" , true); + ns =netns_new ("flow_dissector_skb_less_direct_attach_ns" , true);if (!ASSERT_OK_PTR (ns,"create and open netns" ))return ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1575/2151 selftests/bpf: Report a failure to register the session key in test_progs
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qiliang Yuan <[email protected]>
[ Upstream commit 66fd5eb9da12ef4ed089ed1974160d07ff034a19 ]
test_progs adds the key that verifies signed programs to the session keyring before it runs any test, and exits when that fails.
It exits with 255 without printing anything. pam_keyinit revokes the session keyring on logout, so a test_progs started in the background from an ssh session that has been closed since leaves nothing but an empty log behind, with no hint of what went wrong.
Print the error before exiting.
--- tools/testing/selftests/bpf/test_progs.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
tools/testing/selftests/bpf/test_progs.c +4 -1
@@ -1973,8 +1973,11 @@ int main(int argc, char **argv)libbpf_set_print (libbpf_print_fn); err =register_session_key ((const char *)test_progs_verification_cert, test_progs_verification_cert_len); -if (err <0 ) +if (err <0 ) { +fprintf (stderr,"Failed to add libbpf_session_key to the session keyring: %s\n" , +strerror (errno));return err; + }traffic_monitor_set_print (traffic_monitor_print_fn);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1576/2151 selftests/bpf: Expect at least one tp_recursion miss in missed
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qiliang Yuan <[email protected]>
[ Upstream commit a5e144985d6855c84b56ea5443fd6333490ce8ec ]
missed_tp_recursion attaches its tp programs to bpf_trace_printk and expects each of them to miss exactly one run, the one that its kprobe program on bpf_fentry_test1 triggers by calling bpf_printk().
The test is not serial, so tests running in parallel can add misses to the tp programs while they are attached:
- The kprobe on bpf_fentry_test1 is global. Any other test that does bpf_prog_test_run() on a fentry/fexit program calls bpf_fentry_test1() and thereby fires the kprobe program, which calls bpf_printk() from kprobe context and makes the tp programs fail the bpf_prog_active check once more.
- Any other program that runs under the bpf_prog_active check, such as a kprobe program or the perf event tracepoint program in legacy_printk, and calls bpf_printk() hits bpf_trace_printk the same way.
Either way, test2_recursion_misses comes out as 2 instead of 1.
Expect at least one miss, as missed_kprobe_recursion does since commit 08a7078feacf ("selftests/bpf: Improve missed_kprobe_recursion test robustness").
--- tools/testing/selftests/bpf/prog_tests/missed.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tools/testing/selftests/bpf/prog_tests/missed.c +3 -3
@@ -120,9 +120,9 @@ static void test_missed_tp_recursion(void)ASSERT_EQ (topts.retval,0 ,"test_run" );ASSERT_EQ (get_missed_count (bpf_program__fd (skel->progs.test1)),0 ,"test1_recursion_misses" ); -ASSERT_EQ (get_missed_count (bpf_program__fd (skel->progs.test2)),1 ,"test2_recursion_misses" ); -ASSERT_EQ (get_missed_count (bpf_program__fd (skel->progs.test3)),1 ,"test3_recursion_misses" ); -ASSERT_EQ (get_missed_count (bpf_program__fd (skel->progs.test4)),1 ,"test4_recursion_misses" ); +ASSERT_GE (get_missed_count (bpf_program__fd (skel->progs.test2)),1 ,"test2_recursion_misses" ); +ASSERT_GE (get_missed_count (bpf_program__fd (skel->progs.test3)),1 ,"test3_recursion_misses" ); +ASSERT_GE (get_missed_count (bpf_program__fd (skel->progs.test4)),1 ,"test4_recursion_misses" ); cleanup:missed_tp_recursion__destroy (skel);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1577/2151 veth: clear rx queue hint in veth_xmit
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiayuan Chen <[email protected]>
[ Upstream commit 1b1c0e87cfe78d731bbab99c9c018655980b6790 ]
With more tx queues on one end of a veth pair than rx queues on the other, and RPS or generic XDP enabled on the receiving end, we get:
veth1 received packet on queue 2, but number of RX queues is 2
WARNING: net/core/dev.c:5212 at get_rps_cpu+0x560/0x1360
Call Trace:
<TASK>
netif_rx_internal+0x1af/0x4c0
__netif_rx+0x99/0x350
veth_xmit+0x713/0xca0
dev_hard_start_xmit+0x166/0x5f0
__dev_queue_xmit+0x1797/0x42d0
ip_finish_output2+0xa34/0x1f40
__ip_finish_output+0x510/0x7e0
ip_finish_output+0x2f/0x320
ip_output+0x17a/0x3f0
ip_send_skb+0x1bc/0x220
......Easy to hit with "ethtool -L veth0 tx 4", "ethtool -L veth1 rx 2", rps_cpus set on veth1 and a few flows sent over the pair [1].
veth_xmit() uses skb->queue_mapping to pick the peer rq, but never clears it before veth_forward_skb(), so the rx side still sees the tx queue index. Everything on the rx side that goes through skb_get_rx_queue(), like get_rps_cpu() and netif_get_rxqueue() for generic XDP, takes it as a recorded rx queue and warns once it is out of range.
Clear it before handing the skb to the peer:
- It is the tx queue index of this device, it says nothing about the rx queue of the peer.
- The two sides don't even agree on the encoding. The tx side stores the index as is, the rx side stores index + 1 so that 0 can mean "not recorded". So tx queue k is read back as rx queue k - 1, and tx queue 0 as "not recorded".
- Commit 710ad98c363a ("veth: Do not record rx queue hint in veth_xmit") already decided that veth should not pass any queue hint to the peer. There is no tx->rx queue mapping to preserve, so nothing is lost by clearing it.
On NETDEV_TX_BUSY the skb goes back to the qdisc, which looks up the txq from skb->queue_mapping to decide when to retry, so restore it there, next to the existing __skb_push().
[1]: https://lore.kernel.org/netdev/[email protected]/
--- drivers/net/veth.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/veth.c +5 -0
@@ -376,6 +376,9 @@ static netdev_tx_t veth_xmit(struct sk_buff *skb, struct net_device *dev)skb_tx_timestamp (skb); +/* tx queue index of this device, meaningless as rx queue of the peer */ +skb_set_queue_mapping (skb,0 ); + ret =veth_forward_skb (rcv, skb, rq, use_napi);switch (ret) {case NET_RX_SUCCESS :/* same as NETDEV_TX_OK */
@@ -396,6 +399,8 @@ static netdev_tx_t veth_xmit(struct sk_buff *skb, struct net_device *dev) }/* Restore Eth hdr pulled by dev_forward_skb/eth_type_trans */ __skb_push (skb,ETH_HLEN ); +/* qdisc requeues the skb on the txq it points to */ +skb_set_queue_mapping (skb, rxq);netif_tx_stop_queue (txq);/* Makes sure NAPI peer consumer runs. Consumer is responsible * for starting txq again, until then ndo_start_xmit (this
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1578/2151 IB/IPoIB: Cancel normal flush work on device stop
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Carolina Jubran <[email protected]>
[ Upstream commit 66196a559be5963b1ced18418c876caf9bfb76e6 ]
ipoib_ib_dev_flush_normal() can race with ipoib_stop() because the normal flush work does not run under RTNL.
Before commit a77a57a1a22a ("IPoIB: Fix deadlock on RTNL in ipoib_stop()"), ipoib_stop() flushed ipoib_workqueue after clearing IPOIB_FLAG_ADMIN_UP and before calling ipoib_ib_dev_down(). This ensured that any in-flight flush work completed before ipoib_ib_dev_down() performed the final clear of IPOIB_FLAG_OPER_UP.
After that commit removed the workqueue flush to avoid a deadlock with workqueue tasks taking RTNL, a normal flush can continue running concurrently with ipoib_stop() after IPOIB_FLAG_ADMIN_UP has been cleared.
The flush may observe IPOIB_FLAG_ADMIN_UP set and continue running while ipoib_stop() clears IPOIB_FLAG_ADMIN_UP and brings the device down. The flush can then call ipoib_ib_dev_up() and set IPOIB_FLAG_OPER_UP again after the device has already been stopped:
flush_normal (ipoib_workqueue) ipoib_stop() (RTNL held)
------------------------------ ------------------------
test_bit(ADMIN_UP) == 1
clear_bit(ADMIN_UP)
ipoib_ib_dev_down()
clear_bit(OPER_UP) ipoib_ib_dev_up()
set_bit(OPER_UP)
This leaves the interface with ADMIN_UP clear and OPER_UP set. During device removal, ipoib_ndo_uninit() waits in destroy_workqueue() while holding RTNL, while ipoib_mcast_carrier_on_task() may keep retrying rtnl_trylock() as long as OPER_UP remains set, resulting in a deadlock.
Cancel the normal flush work from ipoib_stop() after clearing IPOIB_FLAG_ADMIN_UP and before bringing the device down. A pending normal flush is canceled, while an already running flush is allowed to finish before ipoib_ib_dev_down() performs the final transition to OPER_UP clear.
Only the normal flush needs this synchronization. The heavy flush is already serialized with ipoib_stop() by RTNL, while the light flush does not bring the device back up and therefore cannot recreate this race.
--- drivers/infiniband/ulp/ipoib/ipoib_main.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/infiniband/ulp/ipoib/ipoib_main.c +7 -0
@@ -230,6 +230,13 @@ static int ipoib_stop(struct net_device *dev)clear_bit (IPOIB_FLAG_ADMIN_UP , &priv->flags); +/* Normal flush runs without RTNL and may bring the device back +* up. Cancel it before the device down transition. +* Heavy flush is already serialized by RTNL and must not be +* waited on here while RTNL is held. +*/ +cancel_work_sync (&priv->flush_normal); +netif_stop_queue (dev);ipoib_ib_dev_down (dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1579/2151 rxrpc: Revert "rxrpc: rxperf: Fix missing decoding of terminal magic cookie"
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Howells <[email protected]>
[ Upstream commit 870143cfdac1cad166d1dc03fbef915fac0c229a ]
Revert commit c34d999ca3145d9fe858258cc3342ec493f47d2e:
The rxperf RPCs seem to have a magic cookie at the end of the request that was failing to be taken account of by the unmarshalling of the request. Fix the rxperf code to expect this.
Actually, this isn't true; it's just that other Rx implementations ignore the extra data in the request and so my test programs are sending too much data without noticeable consequence.
--- net/rxrpc/rxperf.c | 12 ------------ 1 file changed, 12 deletions(-)
net/rxrpc/rxperf.c +0 -12
@@ -495,18 +495,6 @@ static int rxperf_deliver_request(struct rxperf_call *call) call->unmarshal++; fallthrough;case 2 : - ret =rxperf_extract_data (call, true); -if (ret <0 ) -return ret; - -/* Deal with the terminal magic cookie. */ - call->iov_len =4 ; - call->kvec[0 ].iov_len = call->iov_len; - call->kvec[0 ].iov_base = call->tmp; -iov_iter_kvec (&call->iter,READ , call->kvec,1 , call->iov_len); - call->unmarshal++; - fallthrough; -case 3 : ret =rxperf_extract_data (call, false);if (ret <0 )return ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1580/2151 rxrpc: Fix rxperf test rxgk key kvno to be 0
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Howells <[email protected]>
[ Upstream commit a7c8c3ab072375fc667ee294b58bcb9071d6e3ca ]
Fix the test rxgk keys in the rxperf test server to have kvno 0 to match other implementations.
--- net/rxrpc/rxperf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/rxrpc/rxperf.c +1 -1
@@ -593,7 +593,7 @@ static int rxperf_add_yfs_rxgk_key(struct key *keyring, u32 enctype)for (int i =0 ; i < krb5->key_len; i++) key[i] = i; -sprintf (name,"%u:6:1:%u" ,RX_PERF_SERVICE , enctype); +sprintf (name,"%u:6:0:%u" ,RX_PERF_SERVICE , enctype); kref = key_create_or_update(make_key_ref(keyring, true), "rxrpc_s", name,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1581/2151 rxrpc: Fix aborting in rxperf test server
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Howells <[email protected]>
[ Upstream commit 7f15923909866e76608ea6474368570938e783fc ]
Fix rxperf_process_call() to always abort if it gets a send error rather than only aborting on ENOMEM.
--- include/trace/events/rxrpc.h | 2 +- net/rxrpc/rxperf.c | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-)
include/trace/events/rxrpc.h +1 -1
@@ -28,8 +28,8 @@EM (afs_abort_unsupported_sec_class,"afs-unsup-sec-class" ) \ /* rxperf errors */ \ EM(rxperf_abort_general_error, "rxperf-error") \ - EM(rxperf_abort_oom, "rxperf-oom") \ EM(rxperf_abort_op_not_supported, "rxperf-op-notsupp") \ + EM(rxperf_abort_send_error, "rxperf-send-error") \EM (rxperf_abort_unmarshal_error,"rxperf-unmarshal" ) \ /* RxKAD security errors */ \EM (rxkad_abort_1_short_check,"rxkad1-short-check" ) \
net/rxrpc/rxperf.c +6 -5
@@ -527,7 +527,7 @@ static int rxperf_process_call(struct rxperf_call *call) ret =rxrpc_kernel_send_data (rxperf_socket, call->rxcall, &msg, rxperf_notify_end_reply_tx);if (ret <0 ) -return ret; + goto send_error; reply_len -= len; }
@@ -538,10 +538,11 @@ static int rxperf_process_call(struct rxperf_call *call) msg.msg_flags =0 ; ret =rxrpc_kernel_send_data (rxperf_socket, call->rxcall, &msg, rxperf_notify_end_reply_tx); -if (ret == -ENOMEM ) -rxrpc_kernel_abort_call (rxperf_socket, call->rxcall, -RXGEN_SS_MARSHAL , -ENOMEM , - rxperf_abort_oom); +if (ret ==0 ) +return 0 ; +send_error: +rxrpc_kernel_abort_call (rxperf_socket, call->rxcall,RXGEN_SS_MARSHAL , + ret, rxperf_abort_send_error);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1582/2151 rxrpc: Fix sendmsg length
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Howells <[email protected]>
[ Upstream commit ef369cacbd524931199078427ae152c63a826189 ]
rxrpc_send_data() is given two data lengths (len and msg->msg_iter.count) and is inconsistent about how it uses them. Fix this by using len in preference to msg->msg_iter.count. Also limit the amount copied to either len or msg->msg_iter.count, whichever is smaller.
Note that, currently, all the callers have len and msg->msg_iter.count the same and so the problem won't occur. This is a prerequisite for another patch that fixes the handling of encryption errors.
--- net/rxrpc/sendmsg.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
net/rxrpc/sendmsg.c +9 -8
@@ -374,9 +374,9 @@ static int rxrpc_send_data(struct rxrpc_sock *rx, ret = -EMSGSIZE ;if (call->tx_total_len !=-1 ) { -if (len - copied > call->tx_total_len) +if (len > call->tx_total_len) goto maybe_error; -if (!more && len - copied != call->tx_total_len) +if (!more && len != call->tx_total_len) goto maybe_error; }
@@ -402,7 +402,7 @@ static int rxrpc_send_data(struct rxrpc_sock *rx,* the security header is going to be in the padded * region (enc blocksize), but the trailer is not. */ - remain = more ?INT_MAX :msg_data_left (msg); + remain = more ?INT_MAX : len; txb = call->conn->security->alloc_txbuf (call, remain, sk->sk_allocation);if (!txb) { ret = -ENOMEM ;
@@ -416,8 +416,8 @@ static int rxrpc_send_data(struct rxrpc_sock *rx,_debug ("append" );/* append next segment of data to the current buffer */ - if (msg_data_left(msg) > 0) { - size_t copy = umin(txb->space, msg_data_left(msg)); + if (len > 0) { + size_t copy = min3(txb->space, len, msg_data_left(msg)); _debug("add %zu", copy); if (!copy_from_iter_full(txb->data + txb->offset,
@@ -428,6 +428,7 @@ static int rxrpc_send_data(struct rxrpc_sock *rx, txb->len += copy; txb->offset += copy; copied += copy; + len -= copy;if (call->tx_total_len !=-1 ) call->tx_total_len -= copy; }
@@ -439,8 +440,8 @@ static int rxrpc_send_data(struct rxrpc_sock *rx,/* add the packet to the send queue if it's now full */ if (!txb->space || - (msg_data_left (msg) ==0 && !more)) { -if (msg_data_left (msg) ==0 && !more) + (len ==0 && !more)) { +if (len ==0 && !more) txb->flags |=RXRPC_LAST_PACKET ; ret = call->security->secure_packet (call, txb);
@@ -449,7 +450,7 @@ static int rxrpc_send_data(struct rxrpc_sock *rx,rxrpc_queue_packet (rx, call, txb, notify_end_tx); call->tx_pending =NULL ; } - }while (msg_data_left (msg) >0 ); + }while (len >0 &&msg_data_left (msg) >0 ); success: ret = copied;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1583/2151 irqchip/gic-v3-its: Clear vpt_page after freeing the pending table
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fuad Tabba <[email protected]>
[ Upstream commit 0d604b1e4617d18dbb5573290ba447d7369251d1 ]
its_vpe_teardown() frees vpt_page without clearing it, so its vpt_page == NULL guard only holds the first time it runs on a vPE. struct its_vpe outlives a failed KVM_DEV_ARM_VGIC_CTRL_INIT, so a retry that fails again frees the pending table and the vPE ID a second time.
--- drivers/irqchip/irq-gic-v3-its.c | 1 + 1 file changed, 1 insertion(+)
drivers/irqchip/irq-gic-v3-its.c +1 -0
@@ -4604,6 +4604,7 @@ static void its_vpe_teardown(struct its_vpe *vpe)its_vpe_db_proxy_unmap (vpe);its_vpe_id_free (vpe->vpe_id);its_free_pending_table (vpe->vpt_page); + vpe->vpt_page =NULL ; } static void its_vpe_irq_domain_free(struct irq_domain *domain,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1584/2151 irqchip/riscv-imsic: Reject overlapping group index fields
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit 8caa8fcec8db5358437b9b7ca456bc3093d2a4d0 ]
The IMSIC address layout places the group index above the page offset, guest index and HART index. imsic_parse_fwnode() checks the individual field widths and the upper end of the group field, but does not check that its lower end is above the other fields.
Reject a nonzero group field whose shift overlaps the lower fields. Otherwise a firmware-supplied layout can assign the same address bit to different indices when MSI target addresses are constructed.
Keep the existing upper-bound check unchanged. The new lower-bound check applies only when group index bits are present.
The issue was found by our static-analysis tool.
--- drivers/irqchip/irq-riscv-imsic-state.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/irqchip/irq-riscv-imsic-state.c +8 -0
@@ -750,6 +750,14 @@ static int __init imsic_parse_fwnode(struct fwnode_handle *fwnode,return -EINVAL ; } +/* Group index bits must not overlap guest and HART index bits. */ + i =IMSIC_MMIO_PAGE_SHIFT + global->guest_index_bits + + global->hart_index_bits; +if (global->group_index_bits && global->group_index_shift < i) { +pr_err ("%pfwP: group index shift too small\n" , fwnode); +return -EINVAL ; + } +/* Sanity check group index shift */ i = global->group_index_bits + global->group_index_shift -1 ;if (i >=BITS_PER_LONG ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1585/2151 irqchip/gic-v3-its: Dont free a vPE table shared with another ITS
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fuad Tabba <[email protected]>
[ Upstream commit 32e056cc1d1582951f981113ca8b98914f29c32a ]
On GICv4.1, its_alloc_tables() copies a sibling's vPE table baser rather than allocating one, but its_free_tables() frees it like the rest. A probe failure on the copying ITS then frees pages the enabled sibling still points GITS_BASER2 at, and the kernel comes up running on that sibling.
Mark a shared table so its_free_tables() skips it.
--- drivers/irqchip/irq-gic-v3-its.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/irqchip/irq-gic-v3-its.c +5 -1
@@ -87,6 +87,8 @@ struct its_baser {u64 val;u32 order;u32 psz; +/* Inherited from a sibling ITS, not freed here */ +bool shared; };struct its_device ;
@@ -2608,7 +2610,8 @@ static void its_free_tables(struct its_node *its)for (i =0 ; i <GITS_BASER_NR_REGS ; i++) {if (its->tables[i].base) { -its_free_pages (its->tables[i].base, its->tables[i].order); +if (!its->tables[i].shared) +its_free_pages (its->tables[i].base, its->tables[i].order); its->tables[i].base =NULL ; } }
@@ -2707,6 +2710,7 @@ static int its_alloc_tables(struct its_node *its)WARN_ON (i !=2 );if ((sibling =find_sibling_its (its))) { *baser = sibling->tables[2 ]; + baser->shared = true;its_write_baser (its, baser, baser->val);continue ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1586/2151 irqchip/gic-v3-its: Dont free the tables of an enabled ITS
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fuad Tabba <[email protected]>
[ Upstream commit d09b36d8e0e60f35bd1cd7d63aadc6dfad61700c ]
its_probe_one() enables the ITS before its_init_domain(), the last step that can fail, and the unwind from there frees the tables and the command queue without disabling it. The kernel comes up with an enabled ITS pointing at freed pages.
Enable the ITS last. Nothing reaches the new domain before then: this runs from init_IRQ(), and the ITS joins its_nodes only after the enable.
--- drivers/irqchip/irq-gic-v3-its.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/irqchip/irq-gic-v3-its.c +6 -4
@@ -5333,16 +5333,18 @@ static int __init its_probe_one(struct its_node *its) }gits_write_cwriter (0 , its->base +GITS_CWRITER ); + + err =its_init_domain (its); +if (err) + goto out_free_collection; + +/* Enable last: the unwind frees memory an enabled ITS may access */ ctlr =readl_relaxed (its->base +GITS_CTLR ); ctlr |=GITS_CTLR_ENABLE ;if (is_v4 (its)) ctlr |= GITS_CTLR_ImDe;writel_relaxed (ctlr, its->base +GITS_CTLR ); - err =its_init_domain (its); -if (err) - goto out_free_collection; -raw_spin_lock (&its_lock);list_add (&its->entry, &its_nodes);raw_spin_unlock (&its_lock);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1587/2151 irqchip/gic-v3: Dont register a redistributor that was never counted
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fuad Tabba <[email protected]>
[ Upstream commit 6a21693b97ee5cb0a21d04bfd051a05dde5aa783 ]
gic_acpi_match_gicc() counts only the enabled GICCs with a non-zero gicr_base_address, and that count sizes redist_regs[], but gic_acpi_parse_madt_gicc() registers every enabled one. On a MADT with no GICR entries, an enabled GICC with a zero GICR base therefore makes gic_acpi_register_redist() write a struct redist_region past the end of the array.
Commit fa2dabe57220e ("irqchip/gic-v3: Don't return errors from gic_acpi_match_gicc()") removed the check that kept the two consistent. Its message says such entries are still caught by gic_populate_rdist(), but that runs from gic_cpu_init(), after the write.
Skip the entry instead, and mark the CPU's redistributor broken as the online-capable path does, so that gic_check_rdist() rejects the CPU. gic_starting_cpu() runs past cpuhp's last failure point, so without the mark the CPU would come online with its redistributor and CPU interface unconfigured. With an ITS, its_cpu_init() would then dereference a NULL rd_base.
--- drivers/irqchip/irq-gic-v3.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/irqchip/irq-gic-v3.c +11 -0
@@ -2454,6 +2454,17 @@ gic_acpi_parse_madt_gicc(union acpi_subtable_headers *header,return 0 ; } +/* Not counted by gic_acpi_match_gicc(), so there is no slot for it */ +if (!gicc->gicr_base_address) { +int cpu =get_cpu_for_acpi_id (gicc->uid); + +pr_warn (FW_BUG "GICC entry with ACPI UID %u has no GICR base address, CPU kept offline\n" , + gicc->uid); +if (cpu >=0 ) +cpumask_set_cpu (cpu, &broken_rdists); +return 0 ; + } + redist_base =ioremap (gicc->gicr_base_address, size);if (!redist_base)return -ENOMEM ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1588/2151 irqchip/gic: Fix UBSAN shift-out-of-bounds in GIC helpers
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhu Ling <[email protected]>
[ Upstream commit 13ce14ca41a35f5ee90b77ffa57da91ce6048a2d ]
When running with UBSAN enabled, enabling a GPIO controller that uses a GIC interrupt as its parent triggers several shift-out-of-bounds warnings:
shift-out-of-bounds in drivers/irqchip/irq-gic-common.c:50:21 left shift of 2 by 30 places cannot be represented in type 'int'
Similar reports are emitted from gic_poke_irq() and gic_peek_irq() in drivers/irqchip/irq-gic-v3.c. The corresponding GICv2 helpers use the same signed-shift pattern. These masks are generated by shifting signed integer constants, which invokes undefined behavior when bit 31 is selected.
Use BIT() to generate the masks with an unsigned type and make their intent explicit.
--- drivers/irqchip/irq-gic-common.c | 2 +- drivers/irqchip/irq-gic-v3.c | 4 ++-- drivers/irqchip/irq-gic.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-)
drivers/irqchip/irq-gic-common.c +1 -1
@@ -48,7 +48,7 @@ void gic_enable_quirks(u32 iidr, const struct gic_quirk *quirks,int gic_configure_irq (unsigned int irq,unsigned int type,void __iomem *base) { -u32 confmask =0x2 << ((irq %16 ) *2 ); +u32 confmask =BIT (((irq %16 ) *2 ) +1 );u32 confoff = (irq /16 ) *4 ;u32 val, oldval;int ret =0 ;
drivers/irqchip/irq-gic-v3.c +2 -2
@@ -457,7 +457,7 @@ static int gic_peek_irq(struct irq_data *d, u32 offset)u32 index, mask; offset =convert_offset_index (d, offset, &index); - mask =1 << (index %32 ); + mask =BIT (index %32 );if (gic_irq_in_rdist (d)) base =gic_data_rdist_sgi_base ();
@@ -473,7 +473,7 @@ static void gic_poke_irq(struct irq_data *d, u32 offset)u32 index, mask; offset =convert_offset_index (d, offset, &index); - mask =1 << (index %32 ); + mask =BIT (index %32 );if (gic_irq_in_rdist (d)) base =gic_data_rdist_sgi_base ();
drivers/irqchip/irq-gic.c +2 -2
@@ -178,14 +178,14 @@ static inline bool cascading_gic_irq(struct irq_data *d)*/ static void gic_poke_irq (struct irq_data *d,u32 offset) { -u32 mask =1 << (irqd_to_hwirq (d) %32 ); +u32 mask =BIT (irqd_to_hwirq (d) %32 );writel_relaxed (mask,gic_dist_base (d) + offset + (irqd_to_hwirq (d) /32 ) *4 ); }static int gic_peek_irq (struct irq_data *d,u32 offset) { -u32 mask =1 << (irqd_to_hwirq (d) %32 ); +u32 mask =BIT (irqd_to_hwirq (d) %32 );return !!(readl_relaxed (gic_dist_base (d) + offset + (irqd_to_hwirq (d) /32 ) *4 ) & mask); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1589/2151 irqchip/mips-gic: Fix unbalanced cm_core_lock in for_each_online_cpu_gic()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Benoît Monin <[email protected]>
[ Upstream commit 03c4d26933d54556a89379db5923ae9e474569e8 ]
Commit d9e2ed610a60 ("irqchip/mips-gic: Support multi-cluster in for_each_online_cpu_gic()") added a gic_unlock_cluster() call to the macro's loop increment, which unconditionally invokes mips_cm_unlock_other() on multi-cluster systems. However nothing in the loop ever acquires the corresponding mips_cm_lock_other(), so on multi-cluster hardware every invocation of for_each_online_cpu_gic() releases an unheld per-CPU cm_core_lock.
With CONFIG_PROVE_LOCKING this triggers a "bad unlock balance detected" warning at boot, e.g. from gic_irq_domain_map() while mapping local interrupts. Only the first occurrence is reported, since the first warning permanently disables lockdep (debug_locks = 0); the unbalanced release itself silently persists.
Fix this by moving both the acquire and release into __gic_with_next_online_cpu() so they stay balanced. When advancing to a CPU in a remote cluster, lock the CM redirect block for that cluster via mips_cm_lock_other(); when leaving a remote cluster (or finishing the iteration) release it with mips_cm_unlock_other(). Local-cluster CPUs require no locking, so single-cluster systems are unaffected. This also makes the redirect region behave correctly when accessing local register blocks of CPUs in other clusters.
Drop the now-unused gic_unlock_cluster() helper and its call from the for_each_online_cpu_gic() increment.
--- drivers/irqchip/irq-mips-gic.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-)
drivers/irqchip/irq-mips-gic.c +6 -14
@@ -70,6 +70,10 @@ static int __gic_with_next_online_cpu(int prev) {unsigned int cpu; +/* Release the redirect/other region lock to the previous CPU, if any. */ +if (prev >=0 ) +mips_cm_unlock_other (); +/* Discover the next online CPU */ cpu =cpumask_next (prev, cpu_online_mask);
@@ -77,23 +81,12 @@ static int __gic_with_next_online_cpu(int prev)if (cpu >= nr_cpu_ids)return cpu; -/* -* Move the access lock to the next CPU's GIC local register block. -* -* Set GIC_VL_OTHER. Since the caller holds gic_lock nothing can -* clobber the written value. -*/ -write_gic_vl_other (mips_cm_vp_id (cpu)); +/* Lock access to redirect/other region to the next CPU */ +mips_cm_lock_other_cpu (cpu, CM_GCR_Cx_OTHER_BLOCK_LOCAL);return cpu; } -static inline void gic_unlock_cluster (void ) -{ -if (mips_cps_multicluster_cpus ()) -mips_cm_unlock_other (); -} -/** * for_each_online_cpu_gic() - Iterate over online CPUs, access local registers * @cpu: An integer variable to hold the current CPU number
@@ -108,7 +101,6 @@ static inline void gic_unlock_cluster(void)guard (raw_spinlock_irqsave)(gic_lock); \for ((cpu) =__gic_with_next_online_cpu (-1 ); \ (cpu) < nr_cpu_ids; \ -gic_unlock_cluster (), \ (cpu) =__gic_with_next_online_cpu (cpu))/**
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1590/2151 irqchip/mips-gic: Fix recursive acquisition of gic_lock in gic_set_affinity()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Benoît Monin <[email protected]>
[ Upstream commit 1bae25dcc6beb8b874f23601d2efa142ac4f9f36 ]
Commit 322a90638768 ("irqchip/mips-gic: Multi-cluster support") made gic_set_affinity() call gic_set_type() when an interrupt's affinity is moved between clusters. gic_set_type() takes gic_lock with raw_spin_lock_irqsave(), but gic_set_affinity() holds gic_lock at that point, so the same raw spinlock is acquired twice, triggering a deadlock.
Split gic_set_type() into a gic_set_type_locked() helper that assumes gic_lock is already held. gic_set_type() takes gic_lock and calls the helper, and gic_set_affinity() calls gic_set_type_locked() directly, since it already holds gic_lock.
--- drivers/irqchip/irq-mips-gic.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
drivers/irqchip/irq-mips-gic.c +10 -5
@@ -297,14 +297,14 @@ static void gic_ack_irq(struct irq_data *d) } } -static int gic_set_type (struct irq_data *d,unsigned int type) +static int gic_set_type_locked (struct irq_data *d,unsigned int type) {unsigned int irq, pol, trig, dual; -unsigned long flags; + +lockdep_assert_held (&gic_lock); irq =GIC_HWIRQ_TO_SHARED (d->hwirq); -raw_spin_lock_irqsave (&gic_lock, flags);switch (type &IRQ_TYPE_SENSE_MASK ) {case IRQ_TYPE_EDGE_FALLING : pol =GIC_POL_FALLING_EDGE ;
@@ -351,11 +351,16 @@ static int gic_set_type(struct irq_data *d, unsigned int type)else irq_set_chip_handler_name_locked (d, &gic_level_irq_controller, handle_level_irq,NULL ); -raw_spin_unlock_irqrestore (&gic_lock, flags);return 0 ; } +static int gic_set_type (struct irq_data *d,unsigned int type) +{ +guard (raw_spinlock_irqsave)(&gic_lock); +return gic_set_type_locked (d, type); +} +#ifdef CONFIG_SMP static int gic_set_affinity (struct irq_data *d,const struct cpumask *cpumask,bool force)
@@ -407,7 +412,7 @@ static int gic_set_affinity(struct irq_data *d, const struct cpumask *cpumask,* trigger type in the new cluster. */ if (cl != old_cl) -gic_set_type (d,irqd_get_trigger_type (d)); +gic_set_type_locked (d,irqd_get_trigger_type (d));/* Route the interrupt to its new VP(E) */ if (gic_irq_lock_cluster (d)) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1591/2151 irqchip/mips-gic: Transfer interrupt mask state across clusters
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Benoît Monin <[email protected]>
[ Upstream commit a5f0dc656e89d0eb140547823a36212902cdf673 ]
When an interrupt's affinity is moved to a CPU in another cluster, gic_set_affinity() updates the routing (GIC_SH_MAP_VP) and trigger type in the destination cluster, but never touched the interrupt's mask state.
The interrupt mask is per-cluster. After such a move the interrupt may be left disabled in the destination cluster, so it never fires despite being correctly routed to its new VP.
Move the mask state along with the interrupt: disable it in the old cluster while clearing the route so it is no longer delivered, then configure the trigger type in the new cluster and re-enable it there if it was enabled in the old cluster.
--- drivers/irqchip/irq-mips-gic.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-)
drivers/irqchip/irq-mips-gic.c +20 -4
@@ -368,6 +368,7 @@ static int gic_set_affinity(struct irq_data *d, const struct cpumask *cpumask,unsigned int irq =GIC_HWIRQ_TO_SHARED (d->hwirq);unsigned int cpu, cl, old_cpu, old_cl;unsigned long flags; +bool enabled;/* * The GIC specifies that we can only route an interrupt to one VP(E),
@@ -389,15 +390,20 @@ static int gic_set_affinity(struct irq_data *d, const struct cpumask *cpumask,raw_spin_lock_irqsave (&gic_lock, flags);/* -* If we're moving affinity between clusters, stop routing the -* interrupt to any VP(E) in the old cluster. +* If we're moving affinity between clusters, save the interrupt's +* mask state, stop routing it to any VP(E) in the old cluster and +* disable it there so it is no longer delivered. */ if (cl != old_cl) {if (gic_irq_lock_cluster (d)) { + enabled =read_gic_redir_mask (irq);write_gic_redir_map_vp (irq,0 ); +write_gic_redir_rmask (irq);mips_cm_unlock_other (); }else { + enabled =read_gic_mask (irq);write_gic_map_vp (irq,0 ); +write_gic_rmask (irq); } }
@@ -409,10 +415,20 @@ static int gic_set_affinity(struct irq_data *d, const struct cpumask *cpumask,/* * If we're moving affinity between clusters, configure the interrupt -* trigger type in the new cluster. +* trigger type and, if it was enabled in the old cluster, enable it +* in the new one. */ -if (cl != old_cl) +if (cl != old_cl) {gic_set_type_locked (d,irqd_get_trigger_type (d)); +if (enabled) { +if (gic_irq_lock_cluster (d)) { +write_gic_redir_smask (irq); +mips_cm_unlock_other (); + }else { +write_gic_smask (irq); + } + } + }/* Route the interrupt to its new VP(E) */ if (gic_irq_lock_cluster (d)) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1592/2151 ALSA: Add simple refcount helper functions
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit dcca9b6064c33c84fbeb9f09814178a206321249 ]
There are many open-code to manage the same pattern for refcount + wakeup sync at closing. Let's provide the common helper functions to replace the open-code.
- The recount is kept in struct snd_refcount, where it's initialized by snd_refcount_init().
- The user can simply reference or unreference via snd_refcount_get() and snd_refcount_put() functions
- The user can wait for the all usages gone by snd_refcount_sync()
Note that here we use atomic_t instead of refcount_t since the current users allow reusing the refcount after sync again. The design of refcount_t prevents exactly this behavior, so it doesn't fit.
Stable-dep-of: 91d0048a97e0 ("ALSA: pcm: Add refcount for races between drain and unlink")
--- include/sound/core.h | 21 +++++++++++++++++++++ sound/core/misc.c | 24 ++++++++++++++++++++++++ 2 files changed, 45 insertions(+)
include/sound/core.h +21 -0
@@ -75,6 +75,27 @@ struct snd_device {#define snd_device (n) list_entry(n, struct snd_device, list) +/* +* A simple reference counter with a wait queue; +* typically used for usage counts, and you can synchronize at finishing +* via snd_refcount_sync(), which is woken up when the refcount reaches to +* zero again. +*/ +struct snd_refcount { +atomic_t count; +wait_queue_head_t waiter; +}; + +void snd_refcount_init (struct snd_refcount *ref); + +static inline void snd_refcount_get (struct snd_refcount *ref) +{ +atomic_inc (&ref->count); +} + +void snd_refcount_put (struct snd_refcount *ref); +void snd_refcount_sync (struct snd_refcount *ref); +/* main structure for soundcard */ struct snd_card {
sound/core/misc.c +24 -0
@@ -174,3 +174,27 @@ void snd_fasync_free(struct snd_fasync *fasync)kfree (fasync); }EXPORT_SYMBOL_GPL (snd_fasync_free); + +/* +* generic refcount helper +*/ + +void snd_refcount_init (struct snd_refcount *ref) +{ +atomic_set (&ref->count,0 ); +init_waitqueue_head (&ref->waiter); +} +EXPORT_SYMBOL_GPL (snd_refcount_init); + +void snd_refcount_put (struct snd_refcount *ref) +{ +if (atomic_dec_and_test (&ref->count)) +wake_up (&ref->waiter); +} +EXPORT_SYMBOL_GPL (snd_refcount_put); + +void snd_refcount_sync (struct snd_refcount *ref) +{ +wait_event (ref->waiter, !atomic_read (&ref->count)); +} +EXPORT_SYMBOL_GPL (snd_refcount_sync);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1593/2151 ALSA: pcm: Add refcount for races between drain and unlink
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit 91d0048a97e0fdc0a071caa0ba59e659bc6f84df ]
We added a workaround for the case where a linked substream gets unlinked during the drain operation by another substream of the same linked group in the commit 9b1dbd69ba6f ("ALSA: pcm: fix use-after-free on linked stream runtime in snd_pcm_drain()"). There, we just cached the parameters of the draining substream for avoiding UAF.
Then, we check the draining substream (to_check) again in the loop and remove it from the queue only when it's still present. It means, however, that the wait queue entry won't be removed if the substream went out of the link beforehand, hence a stale wq entry remains. Later on, this can be woken up, and this may hit a UAF, too. The problem surfaced more due to the recent change to call snd_pcm_unlink() earlier.
For properly handling both cases above, in this patch, we introduce a refcount to the snd_pcm_runtime that indicates the substream is being accessed / used, then at snd_pcm_release_substream(), it's synced before the actual resource release via snd_refcount_sync(). This guarantees that the accessors are finished, and safe to release memories. Along with the introduction of a refcount, the comments and the code changes by the former fix were partially reverted as they don't fit with the updated code flow any longer.
Last but not least, the setup of wait queue entry and prepare_to_wait() call are moved before the group unref. With this change, we can avoid the race between the enqueue and the wakeup, too.
--- include/sound/pcm.h | 2 ++ sound/core/pcm.c | 1 + sound/core/pcm_native.c | 54 ++++++++++++++++------------------------- 3 files changed, 24 insertions(+), 33 deletions(-)
include/sound/pcm.h +2 -0
@@ -8,6 +8,7 @@* Abramo Bagnara <[email protected]> */ +#include <sound/core.h> #include <sound/asound.h> #include <sound/memalloc.h> #include <sound/minors.h>
@@ -416,6 +417,7 @@ struct snd_pcm_runtime {snd_pcm_uframes_t twake;/* do transfer (!poll) wakeup if non-zero */ wait_queue_head_t sleep;/* poll sleep */ wait_queue_head_t tsleep;/* transfer sleep */ +struct snd_refcount refcnt;/* refcount for draining, etc */ struct snd_fasync *fasync;bool stop_operating;/* sync_stop will be called */ struct mutex buffer_mutex;/* protect for buffer changes */
sound/core/pcm.c +1 -0
@@ -961,6 +961,7 @@ int snd_pcm_attach_substream(struct snd_pcm *pcm, int stream,init_waitqueue_head (&runtime->sleep);init_waitqueue_head (&runtime->tsleep); +snd_refcount_init (&runtime->refcnt);__snd_pcm_set_state (runtime,SNDRV_PCM_STATE_OPEN );mutex_init (&runtime->buffer_mutex);
sound/core/pcm_native.c +21 -33
81 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1594/2151 ata: ahci: preserve preset port masks
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: zhoumin <[email protected]>
[ Upstream commit 014c29a8e3bdcaad8c6fdfcf1af2fdbbab3fc323 ]
ahci_get_port_mask() returns zero for absent or unmatched parameters, overwriting the mask set by the Marvell PATA quirk.
Update the mask in place only when parsing a global value or a matching device entry. Leave the mask unchanged on parsing errors.
--- drivers/ata/ahci.c | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-)
drivers/ata/ahci.c +11 -20
@@ -714,34 +714,27 @@ MODULE_PARM_DESC(mask_port_ext,"where <pci_dev> is the PCI ID of an AHCI controller in the " "form \"domain:bus:dev.func\""); -static u32 ahci_port_mask (struct device *dev,char *mask_s) +static void ahci_port_mask (struct device *dev,char *mask_s,u32 *mask) { -unsigned int mask; - -if (kstrtouint (mask_s,0 , &mask)) { +if (kstrtou32 (mask_s,0 , mask))dev_err (dev,"Invalid port map mask\n" ); -return 0 ; - } - -return mask; } -static u32 ahci_get_port_mask (struct device *dev,char *mask_p) +static void ahci_get_port_mask (struct device *dev,char *mask_p,u32 *mask) {char *param, *end, *str, *mask_s;char *name; -u32 mask =0 ;if (!mask_p || !strlen (mask_p)) -return 0 ; +return ; str =kstrdup (mask_p,GFP_KERNEL );if (!str) -return 0 ; +return ;/* Handle single mask case */ if (!strchr (str,'=' )) { - mask =ahci_port_mask (dev, str); +ahci_port_mask (dev, str, mask); goto free; }
@@ -776,13 +769,11 @@ static u32 ahci_get_port_mask(struct device *dev, char *mask_p) param++; } - mask =ahci_port_mask (dev, mask_s); +ahci_port_mask (dev, mask_s, mask); } free:kfree (str); - -return mask; } static void ahci_pci_save_initial_config(struct pci_dev *pdev,
@@ -808,10 +799,10 @@ static void ahci_pci_save_initial_config(struct pci_dev *pdev, }/* Handle port map masks passed as module parameter. */ - hpriv->mask_port_map = -ahci_get_port_mask (&pdev->dev, ahci_mask_port_map); - hpriv->mask_port_ext = -ahci_get_port_mask (&pdev->dev, ahci_mask_port_ext); +ahci_get_port_mask (&pdev->dev, ahci_mask_port_map, + &hpriv->mask_port_map); +ahci_get_port_mask (&pdev->dev, ahci_mask_port_ext, + &hpriv->mask_port_ext);ahci_save_initial_config (&pdev->dev, hpriv); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1595/2151 block: reject NOWAIT buffered write fallback
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Julian Sun <[email protected]>
[ Upstream commit a08bf4b9f87898628e70882430b8dd4260730dba ]
blkdev_write_iter() rejects NOWAIT buffered writes, but does not enforce this restriction when direct I/O falls back to buffered I/O. Successful fallback waits for writeback, violating NOWAIT semantics.
Reject NOWAIT requests in blkdev_buffered_write() with -EAGAIN.
--- block/fops.c | 4 ++++ 1 file changed, 4 insertions(+)
block/fops.c +4 -0
@@ -757,6 +757,10 @@ blkdev_direct_write(struct kiocb *iocb, struct iov_iter *from)static ssize_t blkdev_buffered_write (struct kiocb *iocb,struct iov_iter *from) { +/* Buffered fallback waits for writeback, which NOWAIT cannot allow. */ +if (iocb->ki_flags &IOCB_NOWAIT ) +return -EAGAIN ; +return iomap_file_buffered_write (iocb, from, &blkdev_iomap_ops,NULL ,NULL ); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1596/2151 block: take the inode lock for buffered write fallback
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Julian Sun <[email protected]>
[ Upstream commit 1b1be9ea4e34ccede1e7cf9ff2b6317328a5b6ad ]
Commit c0e473a0d226 ("block: fix race between set_blocksize and read paths") added shared inode locking around ordinary buffered writes, but missed the direct-I/O fallback path.
Move the lock into blkdev_buffered_write() so both paths serialize with set_blocksize().
Also correct the comment claiming that this path takes invalidate_lock; it only takes i_rwsem.
--- block/fops.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-)
block/fops.c +12 -9
@@ -757,12 +757,22 @@ blkdev_direct_write(struct kiocb *iocb, struct iov_iter *from)static ssize_t blkdev_buffered_write (struct kiocb *iocb,struct iov_iter *from) { +struct inode *inode =bdev_file_inode (iocb->ki_filp); +ssize_t ret; +/* Buffered fallback waits for writeback, which NOWAIT cannot allow. */ if (iocb->ki_flags &IOCB_NOWAIT )return -EAGAIN ; -return iomap_file_buffered_write (iocb, from, &blkdev_iomap_ops,NULL , -NULL ); +/* +* Take i_rwsem to avoid racing with set_blocksize() changing +* i_blkbits/folio order and truncating the page cache. +*/ +inode_lock_shared (inode); + ret =iomap_file_buffered_write (iocb, from, &blkdev_iomap_ops,NULL , +NULL ); +inode_unlock_shared (inode); +return ret; }/*
@@ -851,14 +861,7 @@ static ssize_t blkdev_write_iter(struct kiocb *iocb, struct iov_iter *from) need_sync = true; } }else { -/* -* Take i_rwsem and invalidate_lock to avoid racing with -* set_blocksize changing i_blkbits/folio order and punching -* out the pagecache. -*/ -inode_lock_shared (bd_inode); ret =blkdev_buffered_write (iocb, from); -inode_unlock_shared (bd_inode); need_sync = true; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1597/2151 spi: omap2-mcspi: handle DMA setup failures
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sahaj Chaudhari <[email protected]>
[ Upstream commit c126e07bde21c518f1356937ac240500d1bc81c0 ]
The DMA paths ignore failures from dmaengine_slave_config(), descriptor preparation and dmaengine_submit(), and carry FIXME comments about falling back to PIO. A failed setup can leave a half-started transfer or wait for a completion that never arrives.
Check each step and clean up with dmaengine_terminate_sync() on error. Prepare both descriptors before issuing either channel. Fall back to PIO only for host-mode transfers that have a TX buffer, when no DMA has been started and cleanup succeeded. RX-only and target-mode transfers return the error instead, since the bus may already be clocking.
The FIFO is enabled before the DMA attempt, but the PIO path polls per-word TXS/RXS and does not expect FIFO mode. Disable the FIFO, with the channel off while its bits change, before falling back.
Tested on an AM642 board with a TI 6.12.57 vendor kernel built with this patch and booted from RAM. On a McSPI bus using DMA, 200 iterations of 4096-byte TX and 1024-byte RX spidev transfers completed with no errors, timeouts or kernel warnings. With a temporary change that fails every DMA-sized TX setup, 60 spidev writes fell back to PIO with no errors or timeouts. That test used a bus with no device attached and did not show a difference with and without the FIFO disable, which is based on reading the code.
--- drivers/spi/spi-omap2-mcspi.c | 236 ++++++++++++++++++++++++---------- 1 file changed, 167 insertions(+), 69 deletions(-)
drivers/spi/spi-omap2-mcspi.c +167 -69
@@ -414,10 +414,11 @@ static void omap2_mcspi_tx_callback(void *data)complete (&mcspi_dma->dma_tx_completion); } -static void omap2_mcspi_tx_dma (struct spi_device *spi, -struct spi_transfer *xfer, -struct dma_slave_config cfg) +static int omap2_mcspi_tx_dma (struct spi_device *spi, +struct spi_transfer *xfer, +struct dma_slave_config cfg) { +int ret;struct omap2_mcspi *mcspi;struct omap2_mcspi_dma *mcspi_dma;struct dma_async_tx_descriptor *tx;
@@ -425,31 +426,31 @@ static void omap2_mcspi_tx_dma(struct spi_device *spi, mcspi =spi_controller_get_devdata (spi->controller); mcspi_dma = &mcspi->dma_channels[spi_get_chipselect (spi,0 )]; -dmaengine_slave_config (mcspi_dma->dma_tx, &cfg); + ret =dmaengine_slave_config (mcspi_dma->dma_tx, &cfg); +if (ret) +return ret; tx =dmaengine_prep_slave_sg (mcspi_dma->dma_tx, xfer->tx_sg.sgl, xfer->tx_sg.nents,DMA_MEM_TO_DEV ,DMA_PREP_INTERRUPT |DMA_CTRL_ACK ); -if (tx) { - tx->callback = omap2_mcspi_tx_callback; - tx->callback_param = spi; -dmaengine_submit (tx); - }else { -/* FIXME: fall back to PIO? */ - } -dma_async_issue_pending (mcspi_dma->dma_tx); -omap2_mcspi_set_dma_req (spi,0 ,1 ); +if (!tx) +return -EIO ; + + tx->callback = omap2_mcspi_tx_callback; + tx->callback_param = spi; + +return dma_submit_error (dmaengine_submit (tx)); } -static unsigned +static int omap2_mcspi_rx_dma (struct spi_device *spi,struct spi_transfer *xfer, -struct dma_slave_config cfg, -unsigned es) +struct dma_slave_config cfg,unsigned int es, +unsigned int *count,bool *rx_submitted,bool *dma_started) {struct omap2_mcspi *mcspi;struct omap2_mcspi_dma *mcspi_dma; -unsigned int count, transfer_reduction =0 ; +unsigned int transfer_reduction =0 ;struct scatterlist *sg_out[2 ];int nb_sizes =0 , out_mapped_nents[2 ], ret, x;size_t sizes[2 ];
@@ -462,7 +463,8 @@ omap2_mcspi_rx_dma(struct spi_device *spi, struct spi_transfer *xfer, mcspi =spi_controller_get_devdata (spi->controller); mcspi_dma = &mcspi->dma_channels[spi_get_chipselect (spi,0 )]; - count = xfer->len; + *count = xfer->len; + *rx_submitted = false;/* * In the "End-of-Transfer Procedure" section for DMA RX in OMAP35x TRM
@@ -476,14 +478,16 @@ omap2_mcspi_rx_dma(struct spi_device *spi, struct spi_transfer *xfer, l =mcspi_cached_chconf0 (spi);if (word_len <=8 ) - element_count = count; + element_count = *count;else if (word_len <=16 ) - element_count = count >>1 ; + element_count = *count >>1 ;else /* word_len <= 32 */ - element_count = count >>2 ; + element_count = *count >>2 ; -dmaengine_slave_config (mcspi_dma->dma_rx, &cfg); + ret =dmaengine_slave_config (mcspi_dma->dma_rx, &cfg); +if (ret) +return ret;/* * Reduce DMA transfer length by one more if McSPI is
@@ -494,7 +498,7 @@ omap2_mcspi_rx_dma(struct spi_device *spi, struct spi_transfer *xfer,if (transfer_reduction) {/* Split sgl into two. The second sgl won't be used. */ - sizes[0 ] = count - transfer_reduction; + sizes[0 ] = *count - transfer_reduction; sizes[1 ] = transfer_reduction; nb_sizes =2 ; }else {
@@ -502,44 +506,56 @@ omap2_mcspi_rx_dma(struct spi_device *spi, struct spi_transfer *xfer,* Don't bother splitting the sgl. This essentially * clones the original sgl. */ - sizes[0 ] = count; + sizes[0 ] = *count; nb_sizes =1 ; } ret =sg_split (xfer->rx_sg.sgl, xfer->rx_sg.nents,0 , nb_sizes, sizes, sg_out, out_mapped_nents,GFP_KERNEL ); -if (ret <0 ) { +if (ret) {dev_err (&spi->dev,"sg_split failed\n" ); -return 0 ; +return ret; } tx =dmaengine_prep_slave_sg (mcspi_dma->dma_rx, sg_out[0 ], out_mapped_nents[0 ],DMA_DEV_TO_MEM ,DMA_PREP_INTERRUPT |DMA_CTRL_ACK ); -if (tx) { - tx->callback = omap2_mcspi_rx_callback; - tx->callback_param = spi; -dmaengine_submit (tx); - }else { -/* FIXME: fall back to PIO? */ +if (!tx) { + ret = -EIO ; + goto out_free_sg; } + tx->callback = omap2_mcspi_rx_callback; + tx->callback_param = spi; + ret =dma_submit_error (dmaengine_submit (tx)); +if (ret) + goto out_free_sg; + + *rx_submitted = true; +if (mcspi->target_aborted) { + ret = -EINTR ; + goto out_free_sg; + } + *dma_started = true; +if (xfer->tx_buf) { +if (spi_controller_is_target (mcspi->ctlr)) +mcspi_write_reg (mcspi->ctlr,OMAP2_MCSPI_IRQENABLE , +OMAP2_MCSPI_IRQSTATUS_EOW ); +dma_async_issue_pending (mcspi_dma->dma_tx); +omap2_mcspi_set_dma_req (spi,0 ,1 ); + }dma_async_issue_pending (mcspi_dma->dma_rx);omap2_mcspi_set_dma_req (spi,1 ,1 ); - ret =mcspi_wait_for_completion (mcspi, &mcspi_dma->dma_rx_completion); -if (ret || mcspi->target_aborted) { -dmaengine_terminate_sync (mcspi_dma->dma_rx); -omap2_mcspi_set_dma_req (spi,1 ,0 ); -return 0 ; - } +if (ret || mcspi->target_aborted) + goto out_free_sg;for (x =0 ; x < nb_sizes; x++)kfree (sg_out[x]);if (mcspi->fifo_depth >0 ) -return count; +return 0 ;/* * Due to the DMA transfer length reduction the missing bytes must
@@ -566,9 +582,9 @@ omap2_mcspi_rx_dma(struct spi_device *spi, struct spi_transfer *xfer, }else {int bytes_per_word =mcspi_bytes_per_word (word_len);dev_err (&spi->dev,"DMA RX penultimate word empty\n" ); - count -= (bytes_per_word <<1 ); + *count -= (bytes_per_word <<1 );omap2_mcspi_set_enable (spi,1 ); -return count; +return 0 ; } }if (!mcspi_wait_for_reg_bit (chstat_reg,OMAP2_MCSPI_CHSTAT_RXS )) {
@@ -583,19 +599,27 @@ omap2_mcspi_rx_dma(struct spi_device *spi, struct spi_transfer *xfer, ((u32 *)xfer->rx_buf)[elements] = w; }else {dev_err (&spi->dev,"DMA RX last word empty\n" ); - count -=mcspi_bytes_per_word (word_len); + *count -=mcspi_bytes_per_word (word_len); }omap2_mcspi_set_enable (spi,1 ); -return count; +return 0 ; + +out_free_sg: +if (!ret) + ret = -EINTR ; +for (x =0 ; x < nb_sizes; x++) +kfree (sg_out[x]); +return ret; } -static unsigned -omap2_mcspi_txrx_dma (struct spi_device *spi,struct spi_transfer *xfer) +static int omap2_mcspi_txrx_dma (struct spi_device *spi, +struct spi_transfer *xfer, +unsigned int *count, +bool *pio_fallback) {struct omap2_mcspi *mcspi;struct omap2_mcspi_cs *cs = spi->controller_state;struct omap2_mcspi_dma *mcspi_dma; -unsigned int count;u8 *rx;const u8 *tx;struct dma_slave_config cfg;
@@ -603,10 +627,13 @@ omap2_mcspi_txrx_dma(struct spi_device *spi, struct spi_transfer *xfer)unsigned es;void __iomem *chstat_reg;void __iomem *irqstat_reg; -int wait_res; +bool tx_submitted = false, rx_submitted = false; +bool dma_started = false, terminate_failed = false; +int ret, wait_res; mcspi =spi_controller_get_devdata (spi->controller); mcspi_dma = &mcspi->dma_channels[spi_get_chipselect (spi,0 )]; + *pio_fallback = false;if (cs->word_len <=8 ) { width =DMA_SLAVE_BUSWIDTH_1_BYTE ;
@@ -619,7 +646,7 @@ omap2_mcspi_txrx_dma(struct spi_device *spi, struct spi_transfer *xfer) es =4 ; } - count = xfer->len; + *count = xfer->len;memset (&cfg,0 ,sizeof (cfg)); cfg.src_addr = cs->phys +OMAP2_MCSPI_RX0 ;
@@ -637,31 +664,39 @@ omap2_mcspi_txrx_dma(struct spi_device *spi, struct spi_transfer *xfer)reinit_completion (&mcspi_dma->dma_rx_completion);reinit_completion (&mcspi->txdone);if (tx) { -/* Enable EOW IRQ to know end of tx in target mode */ + ret =omap2_mcspi_tx_dma (spi, xfer, cfg); +if (ret) + goto out; + tx_submitted = true; + } + +if (rx) { + ret =omap2_mcspi_rx_dma (spi, xfer, cfg, es, count, + &rx_submitted, &dma_started); +if (ret) + goto out; + }else if (tx) { +if (mcspi->target_aborted) { + ret = -EINTR ; + goto out; + }if (spi_controller_is_target (spi->controller)) -mcspi_write_reg (spi->controller, -OMAP2_MCSPI_IRQENABLE , +mcspi_write_reg (spi->controller,OMAP2_MCSPI_IRQENABLE ,OMAP2_MCSPI_IRQSTATUS_EOW ); -omap2_mcspi_tx_dma (spi, xfer, cfg); + dma_started = true; +dma_async_issue_pending (mcspi_dma->dma_tx); +omap2_mcspi_set_dma_req (spi,0 ,1 ); } -if (rx !=NULL ) - count =omap2_mcspi_rx_dma (spi, xfer, cfg, es); - -if (tx !=NULL ) { -int ret; - +if (tx) { ret =mcspi_wait_for_completion (mcspi, &mcspi_dma->dma_tx_completion); -if (ret || mcspi->target_aborted) { -dmaengine_terminate_sync (mcspi_dma->dma_tx); -omap2_mcspi_set_dma_req (spi,0 ,0 ); -return 0 ; - } +if (ret || mcspi->target_aborted) + goto out;if (spi_controller_is_target (mcspi->ctlr)) { ret =mcspi_wait_for_completion (mcspi, &mcspi->txdone);if (ret || mcspi->target_aborted) -return 0 ; + goto out; }if (mcspi->fifo_depth >0 ) {
@@ -695,7 +730,43 @@ omap2_mcspi_txrx_dma(struct spi_device *spi, struct spi_transfer *xfer)dev_err (&spi->dev,"EOT timed out\n" ); } } -return count; +return 0 ; + +out: +if (!ret) + ret = -EINTR ; +if (rx_submitted) { + wait_res =dmaengine_terminate_sync (mcspi_dma->dma_rx); +if (wait_res) { +dev_err (&spi->dev,"failed to terminate RX DMA: %d\n" , + wait_res); + terminate_failed = true; + ret = wait_res; + } +omap2_mcspi_set_dma_req (spi,1 ,0 ); + } +if (tx_submitted) { + wait_res =dmaengine_terminate_sync (mcspi_dma->dma_tx); +if (wait_res) { +dev_err (&spi->dev,"failed to terminate TX DMA: %d\n" , + wait_res); + terminate_failed = true; + ret = wait_res; + } +omap2_mcspi_set_dma_req (spi,0 ,0 ); + } +if (spi_controller_is_target (mcspi->ctlr)) +mcspi_write_reg (mcspi->ctlr,OMAP2_MCSPI_IRQENABLE ,0 ); + + *pio_fallback = !dma_started && !terminate_failed; +return ret; +} + +static bool omap2_mcspi_can_pio_fallback (bool cleanup_ok, +const struct spi_transfer *xfer, +bool is_target) +{ +return cleanup_ok && xfer->tx_buf && !is_target; } static unsigned
@@ -1208,6 +1279,8 @@ static int omap2_mcspi_transfer_one(struct spi_controller *ctlr,if (t->len) {unsigned count; +bool pio_fallback; +int ret;if ((mcspi_dma->dma_rx && mcspi_dma->dma_tx) &&spi_xfer_is_dma_mapped (ctlr, spi, t))
@@ -1221,10 +1294,31 @@ static int omap2_mcspi_transfer_one(struct spi_controller *ctlr, + OMAP2_MCSPI_TX0);if ((mcspi_dma->dma_rx && mcspi_dma->dma_tx) && -spi_xfer_is_dma_mapped (ctlr, spi, t)) - count =omap2_mcspi_txrx_dma (spi, t); -else +spi_xfer_is_dma_mapped (ctlr, spi, t)) { + ret =omap2_mcspi_txrx_dma (spi, t, &count, + &pio_fallback); +if (ret) { +bool is_target =spi_controller_is_target (ctlr); +bool fallback; + + fallback =omap2_mcspi_can_pio_fallback (pio_fallback, t, + is_target); +if (!fallback) { + status = ret; + goto out; + } + +dev_warn (&spi->dev, +"DMA setup failed, falling back to PIO\n" ); +/* PIO does not use the FIFO enabled for DMA */ +omap2_mcspi_set_enable (spi,0 ); +omap2_mcspi_set_fifo (spi, t,0 ); +omap2_mcspi_set_enable (spi,1 ); + count =omap2_mcspi_txrx_pio (spi, t); + } + }else { count =omap2_mcspi_txrx_pio (spi, t); + }if (count != t->len) { status = -EIO ;
@@ -1240,8 +1334,12 @@ static int omap2_mcspi_transfer_one(struct spi_controller *ctlr, out:/* Restore defaults if they were overriden */ if (par_override) { +int restore_status; + par_override =0 ; - status =omap2_mcspi_setup_transfer (spi,NULL ); + restore_status =omap2_mcspi_setup_transfer (spi,NULL ); +if (!status) + status = restore_status; }omap2_mcspi_set_enable (spi,0 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1598/2151 RDMA/rxe: refuse to destroy a QP with type 2 MWs still bound
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Youngsung Ahn <[email protected]>
[ Upstream commit 9e61a2ac6590e9c42d2eeef687749781334b300f ]
Binding a type 2 memory window takes a reference on the QP:rxe_do_bind_mw() does rxe_get(qp) and stores it in mw->qp. That reference is released only when the window is invalidated (rxe_do_invalidate_mw() on IB_WR_LOCAL_INV) or the window itself is destroyed (rxe_mw_cleanup()).
rxe_qp_chk_destroy() does not account for those references -- it only refuses when qp->mcg_num is non-zero. So an unprivileged user can bind a type 2 MW to a QP and then destroy the QP while the binding is still live. __rxe_cleanup() cannot drop the QP refcount to zero (the MW still holds a reference), hits its -ETIMEDOUT path, and frees the QP anyway; mw->qp is left dangling. When the MW is later invalidated or deallocated, rxe_mw_cleanup()/rxe_do_invalidate_mw() do rxe_put(mw->qp) on the freed struct rxe_qp -- a use-after-free write (refcount_dec, and complete()/list work if it reaches zero) reachable from userspace. IB_WR_BIND_MW is a local operation, so no peer is required.
Track the number of type 2 MWs bound to a QP and refuse to destroy the QP while that count is non-zero, returning -EBUSY exactly as the existing multicast-attachment check does. The window must be invalidated or deallocated, which drops the reference and the count, before the QP can be destroyed.
--- drivers/infiniband/sw/rxe/rxe_mw.c | 3 +++ drivers/infiniband/sw/rxe/rxe_qp.c | 10 ++++++++++ drivers/infiniband/sw/rxe/rxe_verbs.h | 1 + 3 files changed, 14 insertions(+)
drivers/infiniband/sw/rxe/rxe_mw.c +3 -0
@@ -161,6 +161,7 @@ static void rxe_do_bind_mw(struct rxe_qp *qp, struct rxe_send_wqe *wqe,if (mw->ibmw.type ==IB_MW_TYPE_2 ) {rxe_get (qp); +atomic_inc (&qp->mw_bind_num); mw->qp = qp; } }
@@ -245,6 +246,7 @@ static void rxe_do_invalidate_mw(struct rxe_mw *mw)/* valid type 2 MW will always have a QP pointer */ qp = mw->qp; mw->qp =NULL ; +atomic_dec (&qp->mw_bind_num);rxe_put (qp);/* valid type 2 MW will always have an MR pointer */
@@ -332,6 +334,7 @@ void rxe_mw_cleanup(struct rxe_pool_elem *elem)struct rxe_qp *qp = mw->qp; mw->qp =NULL ; +atomic_dec (&qp->mw_bind_num);rxe_put (qp); }
drivers/infiniband/sw/rxe/rxe_qp.c +10 -0
@@ -809,6 +809,16 @@ int rxe_qp_chk_destroy(struct rxe_qp *qp)return -EBUSY ; } +/* An attempt to destroy a QP while it still holds references for +* bound type 2 memory windows will fail immediately. Otherwise the +* QP is freed with those references outstanding and the windows are +* left pointing at freed memory (use-after-free). +*/ +if (atomic_read (&qp->mw_bind_num)) { +rxe_dbg_qp (qp,"Attempt to destroy while type 2 MWs are bound\n" ); +return -EBUSY ; + } +return 0 ; }
drivers/infiniband/sw/rxe/rxe_verbs.h +1 -0
@@ -260,6 +260,7 @@ struct rxe_qp {struct rxe_av alt_av;atomic_t mcg_num; +atomic_t mw_bind_num;struct sk_buff_head req_pkts;struct sk_buff_head resp_pkts;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1599/2151 RDMA/rxe: reject IB_WR_REG_MR from user QPs in rxe_reg_fast_mr()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Youngsung Ahn <[email protected]>
[ Upstream commit 33afe9909f213d8bb8e80f0b93382dde0f56e2c7 ]
IB_WR_REG_MR is documented as kernel-only ("can not be issued by userspace"), but nothing enforces it. rxe_wr_opcode_info[IB_WR_REG_MR] sets WR_LOCAL_OP_MASK for IB_QPT_RC, a QP type userspace can create, so a user QP that writes opcode = IB_WR_REG_MR into its mmap'd SQ ring reaches rxe_do_local_ops() -> rxe_reg_fast_mr(). That function then trusts the ring-supplied fields:
struct rxe_mr *mr = to_rmr(wqe->wr.wr.reg.mr); ... if (unlikely(mr->state != RXE_MR_STATE_FREE)) /* deref */ ... mr->access = access; /* write */
For a user QP wqe->wr.wr.reg.mr is a fully attacker-chosen pointer, so this is an arbitrary-kernel-address dereference (arbitrary read confirmed, oops). No existing check distinguishes a user QP on this path.
Reject IB_WR_REG_MR for user QPs before dereferencing the supplied pointer.
--- drivers/infiniband/sw/rxe/rxe_mr.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/infiniband/sw/rxe/rxe_mr.c +4 -0
@@ -780,6 +780,10 @@ int rxe_reg_fast_mr(struct rxe_qp *qp, struct rxe_send_wqe *wqe)u32 key = wqe->wr.wr.reg.key;u32 access = wqe->wr.wr.reg.access; +/* IB_WR_REG_MR is a kernel-only op; a user QP must not reach here. */ +if (qp->is_user) +return -EOPNOTSUPP ; +/* user can only register MR in free state */ if (unlikely (mr->state !=RXE_MR_STATE_FREE )) {rxe_dbg_mr (mr,"mr->lkey = 0x%x not free\n" , mr->lkey);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1600/2151 RDMA/rxe: bound the ODP page index against the umem in rxe_check_pagefault()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Youngsung Ahn <[email protected]>
[ Upstream commit 7797bbb0e86f0062fe58480a0116c86e4ec0d0d1 ]
An ODP MR has a page array, map.pfn_list[]. Its size is computed from the umem start address. But rxe_check_pagefault() builds the index into that array from an iova that is relative to the same start, while the access itself was range-checked against the MR's iova (ibmr.iova).
Those two bases do not have to match. reg_mr only requires that start and hca_va have the same page offset, so a user can register an MR with hca_va = start + N*PAGE. The difference then becomes an index skew of (hca_va - start) >> PAGE_SHIFT. Nothing compares the result with the size of pfn_list[], so the read goes past the end of the array.
An unprivileged local user can reach this with a single RDMA operation on a self-connected rxe QP. KASAN reports a slab-out-of-bounds read. If the out-of-bounds qword happens to look like a writable HMM pfn, rxe then copies the payload into a page the user never registered.
Reject an index that falls outside the umem and take the fault path instead. That path rejects the out-of-range access in ib_umem_odp_map_dma_and_lock(), which does check the umem range. The other users of pfn_list[], __rxe_odp_mr_copy() and the atomic helpers, run only after a successful map, so this single check covers them too.
--- drivers/infiniband/sw/rxe/rxe_odp.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/infiniband/sw/rxe/rxe_odp.c +5 -0
@@ -142,6 +142,11 @@ static inline bool rxe_check_pagefault(struct ib_umem_odp *umem_odp, u64 iova,while (addr < iova + length) { idx = (addr -ib_umem_start (umem_odp)) >> umem_odp->page_shift; +if (idx >=ib_umem_odp_num_pages (umem_odp)) { + need_fault = true; +break ; + } +if ((umem_odp->map.pfn_list[idx] & access) != access) { need_fault = true;break ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1601/2151 RDMA/rxe: validate inline sge_offset in finish_packet() before indexing inline_data[]
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Youngsung Ahn <[email protected]>
[ Upstream commit 47a9c0338f2e0d4178d77b0d2f529fe1fde84642 ]
For a user QP, rxe_post_send() takes the qp->is_user branch and never runs init_send_wqe(), so dma.length/resid/num_sge/cur_sge/sge_offset all come straight from the mmap'd SQ ring. In the inline send path finish_packet() uses sge_offset directly as an index:
u8 *tmp = &wqe->dma.inline_data[wqe->dma.sge_offset]; memcpy(payload_addr(pkt), tmp, payload);
inline_data is a flex array whose capacity is qp->sq.max_inline, but sge_offset is a u32 from user space, so the source pointer is
displaced arbitrarily past the WQE and the memcpy reads out of
bounds.
commit 126c757e4cd4 ("RDMA/rxe: Validate num_sge/cur_sge before indexing wqe->dma.sge[]") added num_sge/cur_sge checks on the send path but not sge_offset, the
third attacker-controlled index in the same struct.
Read sge_offset once with READ_ONCE() and bound it (and the payload that follows it) by qp->sq.max_inline before indexing, so the value that is validated is the value that is used.
--- drivers/infiniband/sw/rxe/rxe_req.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/infiniband/sw/rxe/rxe_req.c +8 -1
@@ -510,7 +510,14 @@ static int finish_packet(struct rxe_qp *qp, struct rxe_av *av,if (pkt->mask &RXE_WRITE_OR_SEND_MASK ) {if (wqe->wr.send_flags &IB_SEND_INLINE ) { -u8 *tmp = &wqe->dma.inline_data[wqe->dma.sge_offset]; +u32 sge_offset =READ_ONCE (wqe->dma.sge_offset); +u8 *tmp; + +if (unlikely (sge_offset > (u32 )qp->sq.max_inline || + payload > (u32 )qp->sq.max_inline - sge_offset)) +return -EINVAL ; + + tmp = &wqe->dma.inline_data[sge_offset];memcpy (payload_addr (pkt), tmp, payload);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1602/2151 RDMA/rxe: Hold netdev reference for transmit skbs
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: xiongweimin <[email protected]>
[ Upstream commit 19881618ffa454c63e6b6bf34acd7cac28c695dc ]
rxe_init_packet() assigns skb->dev from an RCU-protected GID attribute without holding a netdev reference. If the netdev is unregistered before the skb is freed, subsequent accesses to skb->dev are unsafe.
Hold a reference with dev_hold() when the skb is initialized and release it from the transmit destructor or via rxe_put_skb() on error paths that run before the destructor is installed.
skb->dev can change on the TX path (VLAN/bond/tunnel, ip_finish_output2, etc.), so put must use the same netdev that was held. Stash that pointer in skb_shinfo()->destructor_arg: skb->cb is already used by rxe_pkt_info and is rewritten by IP control blocks.
To avoid blocking netdev unregistration on held skbs, flush all QPs to the error state on NETDEV_GOING_DOWN and NETDEV_UNREGISTER so pending TX work is drained and references can be dropped.
Stable-dep-of: 56a27df6cedd ("RDMA/rxe: Fix out-of-range unsigned-to-signed conversion for RDMA message in 2GiB size")
--- drivers/infiniband/sw/rxe/rxe_loc.h | 1 + drivers/infiniband/sw/rxe/rxe_net.c | 68 ++++++++++++++++++++++++++-- drivers/infiniband/sw/rxe/rxe_req.c | 2 +- drivers/infiniband/sw/rxe/rxe_resp.c | 4 +- 4 files changed, 68 insertions(+), 7 deletions(-)
drivers/infiniband/sw/rxe/rxe_loc.h +1 -0
@@ -95,6 +95,7 @@ void rxe_mw_cleanup(struct rxe_pool_elem *elem);/* rxe_net.c */ struct sk_buff *rxe_init_packet (struct rxe_dev *rxe,struct rxe_av *av,int paylen,struct rxe_pkt_info *pkt); +void rxe_put_skb (struct sk_buff *skb);int rxe_prepare (struct rxe_av *av,struct rxe_pkt_info *pkt,struct sk_buff *skb); int rxe_xmit_packet(struct rxe_qp *qp, struct rxe_pkt_info *pkt,
drivers/infiniband/sw/rxe/rxe_net.c +64 -4
111 lines not on this page · raw message
drivers/infiniband/sw/rxe/rxe_req.c +1 -1
@@ -818,7 +818,7 @@ int rxe_requester(struct rxe_qp *qp) wqe->status =IB_WC_LOC_PROT_ERR ; else wqe->status = IB_WC_LOC_QP_OP_ERR; -kfree_skb (skb); +rxe_put_skb (skb);if (ah)rxe_put (ah); goto err;
drivers/infiniband/sw/rxe/rxe_resp.c +2 -2
@@ -854,7 +854,7 @@ static struct sk_buff *prepare_ack_packet(struct rxe_qp *qp, err =rxe_prepare (&qp->pri_av, ack, skb);if (err) { -kfree_skb (skb); +rxe_put_skb (skb);return NULL ; }
@@ -982,7 +982,7 @@ static enum resp_states read_reply(struct rxe_qp *qp, err =rxe_mr_copy (mr, res->read.va,payload_addr (&ack_pkt), payload,RXE_FROM_MR_OBJ );if (err) { -kfree_skb (skb); +rxe_put_skb (skb); state =RESPST_ERR_RKEY_VIOLATION ; goto err_out; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1603/2151 RDMA/rxe: Fix out-of-range unsigned-to-signed conversion for RDMA message in 2GiB size
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Honggang LI <[email protected]>
[ Upstream commit 56a27df6cedd4f3918969d61c7b9d3cc177b2d1b ]
When RDMA READ request for 2GiB in single WR, res->read.resid is u32 0x80000000, which is INT_MIN (-2147483648).
payload = min_t(int, res->read.resid, mtu);
The min_t function will return -2147483648 for payload. The wrong size is propagated through call chain, read_reply -> prepare_ack_packet -> rxe_init_packet -> alloc_skb . alloc_skb failed because of invalid size. The passive side failed to emit response packet for RDMA READ request.
After fixed it, the active side of RDMA READ failed with error code "IB_WC_LOC_PROT_ERR". When RDMA_READ_RESPONSE_FIRST packet recived by the active side, do_read call copy_data. dma->resid is u32 0x80000000.
int resid = dma->resid;
This conversion set resid to -2147483648. copy_data abort as length greater than resid.
RDMA SEND and WRITE 2GiB message works too, after fixed these two bugs.
--- drivers/infiniband/sw/rxe/rxe_loc.h | 4 ++-- drivers/infiniband/sw/rxe/rxe_mr.c | 8 ++++---- drivers/infiniband/sw/rxe/rxe_net.c | 2 +- drivers/infiniband/sw/rxe/rxe_resp.c | 17 +++++++++-------- 4 files changed, 16 insertions(+), 15 deletions(-)
drivers/infiniband/sw/rxe/rxe_loc.h +2 -2
@@ -67,7 +67,7 @@ int rxe_flush_pmem_iova(struct rxe_mr *mr, u64 iova, unsigned int length);int rxe_mr_copy (struct rxe_mr *mr,u64 iova,void *addr,unsigned int length,enum rxe_mr_copy_dir dir);int copy_data (struct rxe_pd *pd,int access,struct rxe_dma_info *dma, -void *addr,int length,enum rxe_mr_copy_dir dir); +void *addr,u32 length,enum rxe_mr_copy_dir dir);int rxe_map_mr_sg (struct ib_mr *ibmr,struct scatterlist *sg,int sg_nents,unsigned int *sg_offset); enum resp_states rxe_mr_do_atomic_op(struct rxe_mr *mr, u64 iova, int opcode,
@@ -94,7 +94,7 @@ void rxe_mw_cleanup(struct rxe_pool_elem *elem);/* rxe_net.c */ struct sk_buff *rxe_init_packet (struct rxe_dev *rxe,struct rxe_av *av, -int paylen,struct rxe_pkt_info *pkt); +u32 paylen,struct rxe_pkt_info *pkt);void rxe_put_skb (struct sk_buff *skb);int rxe_prepare (struct rxe_av *av,struct rxe_pkt_info *pkt,struct sk_buff *skb);
drivers/infiniband/sw/rxe/rxe_mr.c +4 -4
@@ -420,13 +420,13 @@ int copy_data(int access, struct rxe_dma_info *dma, void *addr, - int length, + u32 length, enum rxe_mr_copy_dir dir) { - int bytes; + u32 bytes;struct rxe_sge *sge = &dma->sge[dma->cur_sge]; -int offset = dma->sge_offset; -int resid = dma->resid; +u32 offset = dma->sge_offset; +u32 resid = dma->resid;struct rxe_mr *mr =NULL ;u64 iova;int err;
drivers/infiniband/sw/rxe/rxe_net.c +1 -1
@@ -483,7 +483,7 @@ int rxe_xmit_packet(struct rxe_qp *qp, struct rxe_pkt_info *pkt, }struct sk_buff *rxe_init_packet (struct rxe_dev *rxe,struct rxe_av *av, -int paylen,struct rxe_pkt_info *pkt) +u32 paylen,struct rxe_pkt_info *pkt) {unsigned int hdr_len;struct sk_buff *skb =NULL ;
drivers/infiniband/sw/rxe/rxe_resp.c +9 -8
@@ -600,7 +600,7 @@ static enum resp_states check_rkey(struct rxe_qp *qp, }static enum resp_states send_data_in (struct rxe_qp *qp,void *data_addr, -int data_len) +u32 data_len) {int err;
@@ -815,20 +815,21 @@ static enum resp_states atomic_write_reply(struct rxe_qp *qp,static struct sk_buff *prepare_ack_packet (struct rxe_qp *qp,struct rxe_pkt_info *ack,int opcode, -int payload, +u32 payload,u32 psn,u8 syndrome) {struct rxe_dev *rxe =to_rdev (qp->ibqp.device);struct sk_buff *skb; -int paylen; -int pad; +u32 paylen; +u32 pad =0 ;int err;/* * allocate packet */ - pad = (-payload) &0x3 ; +if (payload %4 ) + pad =4 - payload %4 ; paylen = rxe_opcode[opcode].length + payload + pad +RXE_ICRC_SIZE ; skb =rxe_init_packet (rxe, &qp->pri_av, paylen, ack);
@@ -922,9 +923,9 @@ static enum resp_states read_reply(struct rxe_qp *qp, {struct rxe_pkt_info ack_pkt;struct sk_buff *skb; -int mtu = qp->mtu; +u32 mtu = qp->mtu;enum resp_states state; -int payload; +u32 payload;int opcode;int err;struct resp_res *res = qp->resp.res;
@@ -970,7 +971,7 @@ static enum resp_states read_reply(struct rxe_qp *qp, res->state = rdatm_res_state_next; - payload =min_t (int, res->read.resid, mtu); + payload =min (res->read.resid, mtu); skb =prepare_ack_packet (qp, &ack_pkt, opcode, payload, res->cur_psn,AETH_ACK_UNLIMITED );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1604/2151 RDMA/rxe: bound the WQE opcode before indexing rxe_wr_opcode_info[]
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Youngsung Ahn <[email protected]>
[ Upstream commit c887e53e1c852b88bd5442d1bf4717ee3e7aadda ]
wr_opcode_mask() indexes the global rxe_wr_opcode_info[] array with a caller-supplied opcode and no bounds check. For a user QP the WQE comes from an mmap'd SQ ring, so wqe->wr.opcode is an attacker-controlled __u32 read back by the requester (req_next_wqe() -> rxe_requester()); rxe_post_send() takes the qp->is_user branch and never runs validate_send_wr(), whose only opcode check is itself !wr_opcode_mask() (it indexes before it checks). rxe_wr_opcode_info[] has entries only up to IB_WR_REG_MR, so an out-of-range opcode reads out of bounds and the result is used as a mask and dereferenced; observed as a KASAN global-out-of-bounds "Read of size 4" and a wild-pointer oops.
Return a zero mask for an out-of-range opcode, matching how validate_send_wr() already treats a zero mask (an invalid WR), so no path indexes the array out of bounds.
--- drivers/infiniband/sw/rxe/rxe_loc.h | 3 +++ 1 file changed, 3 insertions(+)
drivers/infiniband/sw/rxe/rxe_loc.h +3 -0
@@ -188,6 +188,9 @@ void rxe_comp_queue_pkt(struct rxe_qp *qp, struct sk_buff *skb);static inline unsigned int wr_opcode_mask (int opcode,struct rxe_qp *qp) { +if (unlikely (opcode <0 || opcode >IB_WR_REG_MR )) +return 0 ; +return rxe_wr_opcode_info[opcode].mask[qp->ibqp.qp_type]; }
Signature · 1 line
2.53.0