5.15.140-rc1 review
Subsystems (3)
Greg Kroah-Hartman
maintainerPATCH 137/297 cifs: spnego: add ; in HOST_KEY_LEN
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anastasia Belova <[email protected]>
[ Upstream commit ff31ba19d732efb9aca3633935d71085e68d5076 ]
"host=" should start with ';' (as in cifs_get_spnego_key) So its length should be 6.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- fs/cifs/cifs_spnego.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/cifs/cifs_spnego.c +2 -2
@@ -64,8 +64,8 @@ struct key_type cifs_spnego_key_type = {* strlen(";sec=ntlmsspi") */ #define MAX_MECH_STR_LEN 13 -/* strlen of "host=" */ -#define HOST_KEY_LEN 5 +/* strlen of ";host=" */ +#define HOST_KEY_LEN 6/* strlen of ";ip4=" or ";ip6=" */ #define IP_KEY_LEN 5
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 138/297 cifs: fix check of rc in function generate_smb3signingkey
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ekaterina Esina <[email protected]>
[ Upstream commit 181724fc72486dec2bec8803459be05b5162aaa8 ]
Remove extra check after condition, add check after generating key for encryption. The check is needed to return non zero rc before rewriting it with generating key for decryption.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- fs/cifs/smb2transport.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
fs/cifs/smb2transport.c +2 -3
@@ -430,6 +430,8 @@ generate_smb3signingkey(struct cifs_ses *ses, ptriplet->encryption.context, ses->smb3encryptionkey, SMB3_ENC_DEC_KEY_SIZE); +if (rc) +return rc; rc = generate_key(ses, ptriplet->decryption.label, ptriplet->decryption.context, ses->smb3decryptionkey,
@@ -438,9 +440,6 @@ generate_smb3signingkey(struct cifs_ses *ses,return rc; } -if (rc) -return rc; -#ifdef CONFIG_CIFS_DEBUG_DUMP_KEYS cifs_dbg (VFS ,"%s: dumping generated AES session keys\n" , __func__);/*
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 139/297 xfs: refactor buffer cancellation table allocation
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Darrick J. Wong <[email protected]>
[ Upstream commit 2723234923b3294dbcf6019c288c87465e927ed4 ]
Move the code that allocates and frees the buffer cancellation tables used by log recovery into the file that actually uses the tables. This is a precursor to some cleanups and a memory leak fix.
( backport: dependency of 8db074bd84df5ccc88bff3f8f900f66f4b8349fa )
--- fs/xfs/libxfs/xfs_log_recover.h | 14 +++++----- fs/xfs/xfs_buf_item_recover.c | 47 +++++++++++++++++++++++++++++++++ fs/xfs/xfs_log_priv.h | 3 --- fs/xfs/xfs_log_recover.c | 32 +++++++--------------- 4 files changed, 64 insertions(+), 32 deletions(-)
fs/xfs/libxfs/xfs_log_recover.h +8 -6
@@ -108,12 +108,6 @@ struct xlog_recover {#define ITEM_TYPE (i) (*(unsigned short *)(i)->ri_buf[0].i_addr) -/* -* This is the number of entries in the l_buf_cancel_table used during -* recovery. -*/ -#define XLOG_BC_TABLE_SIZE 64 -#define XLOG_RECOVER_CRCPASS 0#define XLOG_RECOVER_PASS1 1#define XLOG_RECOVER_PASS2 2
@@ -126,5 +120,13 @@ int xlog_recover_iget(struct xfs_mount *mp, xfs_ino_t ino, struct xfs_inode **ipp);void xlog_recover_release_intent (struct xlog *log,unsigned short intent_type,uint64_t intent_id); +void xlog_alloc_buf_cancel_table (struct xlog *log); +void xlog_free_buf_cancel_table (struct xlog *log); + +#ifdef DEBUG +void xlog_check_buf_cancel_table (struct xlog *log); +#else +#define xlog_check_buf_cancel_table (log) do { } while (0) +#endif #endif /* __XFS_LOG_RECOVER_H__ */
fs/xfs/xfs_buf_item_recover.c +47 -0
56 lines not on this page · raw message
fs/xfs/xfs_log_priv.h +0 -3
@@ -454,9 +454,6 @@ struct xlog {struct rw_semaphore l_incompat_users; }; -#define XLOG_BUF_CANCEL_BUCKET (log, blkno) \ - ((log)->l_buf_cancel_table + ((uint64_t)blkno % XLOG_BC_TABLE_SIZE)) -/* * Bits for operational state */
fs/xfs/xfs_log_recover.c +9 -23
@@ -3248,7 +3248,7 @@ xlog_do_log_recovery(xfs_daddr_t head_blk, xfs_daddr_t tail_blk) { - int error, i; + int error;ASSERT (head_blk != tail_blk);
@@ -3256,37 +3256,23 @@ xlog_do_log_recovery(* First do a pass to find all of the cancelled buf log items. * Store them in the buf_cancel_table for use in the second pass. */ - log->l_buf_cancel_table =kmem_zalloc (XLOG_BC_TABLE_SIZE * -sizeof (struct list_head ), -0 ); -for (i =0 ; i <XLOG_BC_TABLE_SIZE ; i++) -INIT_LIST_HEAD (&log->l_buf_cancel_table[i]); +xlog_alloc_buf_cancel_table (log); error =xlog_do_recovery_pass (log, head_blk, tail_blk,XLOG_RECOVER_PASS1 ,NULL ); -if (error !=0 ) { -kmem_free (log->l_buf_cancel_table); - log->l_buf_cancel_table =NULL ; -return error; - } +if (error !=0 ) + goto out_cancel; +/* * Then do a second pass to actually recover the items in the log. * When it is complete free the table of buf cancel items. */ error =xlog_do_recovery_pass (log, head_blk, tail_blk,XLOG_RECOVER_PASS2 ,NULL ); -#ifdef DEBUG -if (!error) { -int i; - -for (i =0 ; i <XLOG_BC_TABLE_SIZE ; i++) -ASSERT (list_empty (&log->l_buf_cancel_table[i])); - } -#endif /* DEBUG */ - -kmem_free (log->l_buf_cancel_table); - log->l_buf_cancel_table =NULL ; - +if (!error) +xlog_check_buf_cancel_table (log); +out_cancel: +xlog_free_buf_cancel_table (log);return error; }
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 140/297 xfs: dont leak xfs_buf_cancel structures when recovery fails
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Darrick J. Wong <[email protected]>
[ Upstream commit 8db074bd84df5ccc88bff3f8f900f66f4b8349fa ]
If log recovery fails, we free the memory used by the buffer cancellation buckets, but we don't actually traverse each bucket list to free the individual xfs_buf_cancel objects. This leads to a memory leak, as reported by kmemleak in xfs/051:
unreferenced object 0xffff888103629560 (size 32):
comm "mount", pid 687045, jiffies 4296935916 (age 10.752s) hex dump (first 32 bytes):
08 d3 0a 01 00 00 00 00 08 00 00 00 01 00 00 00 ................
d0 f5 0b 92 81 88 ff ff 80 64 64 25 81 88 ff ff .........dd%....
backtrace:
[<ffffffffa0317c83>] kmem_alloc+0x73/0x140 [xfs]
[<ffffffffa03234a9>] xlog_recover_buf_commit_pass1+0x139/0x200 [xfs]
[<ffffffffa032dc27>] xlog_recover_commit_trans+0x307/0x350 [xfs]
[<ffffffffa032df15>] xlog_recovery_process_trans+0xa5/0xe0 [xfs]
[<ffffffffa032e12d>] xlog_recover_process_data+0x8d/0x140 [xfs]
[<ffffffffa032e49d>] xlog_do_recovery_pass+0x19d/0x740 [xfs]
[<ffffffffa032f22d>] xlog_do_log_recovery+0x6d/0x150 [xfs]
[<ffffffffa032f343>] xlog_do_recover+0x33/0x1d0 [xfs]
[<ffffffffa032faba>] xlog_recover+0xda/0x190 [xfs]
[<ffffffffa03194bc>] xfs_log_mount+0x14c/0x360 [xfs]
[<ffffffffa030bfed>] xfs_mountfs+0x50d/0xa60 [xfs]
[<ffffffffa03124b5>] xfs_fs_fill_super+0x6a5/0x950 [xfs]
[<ffffffff812b92a5>] get_tree_bdev+0x175/0x280
[<ffffffff812b7c3a>] vfs_get_tree+0x1a/0x80
[<ffffffff812e366f>] path_mount+0x6ff/0xaa0
[<ffffffff812e3b13>] __x64_sys_mount+0x103/0x140--- fs/xfs/xfs_buf_item_recover.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
fs/xfs/xfs_buf_item_recover.c +13 -0
@@ -1044,9 +1044,22 @@ voidxlog_free_buf_cancel_table ( struct xlog *log) { +int i; +if (!log->l_buf_cancel_table)return ; +for (i =0 ; i <XLOG_BC_TABLE_SIZE ; i++) { +struct xfs_buf_cancel *bc; + +while ((bc =list_first_entry_or_null ( + &log->l_buf_cancel_table[i], + struct xfs_buf_cancel, bc_list))) { +list_del (&bc->bc_list); +kmem_free (bc); + } + } +kmem_free (log->l_buf_cancel_table); log->l_buf_cancel_table =NULL ; }
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 141/297 xfs: convert buf_cancel_table allocation to kmalloc_array
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Darrick J. Wong <[email protected]>
[ Upstream commit 910bbdf2f4d7df46781bc9b723048f5ebed3d0d7 ]
While we're messing around with how recovery allocates and frees the buffer cancellation table, convert the allocation to use kmalloc_array instead of the old kmem_alloc APIs, and make it handle a null return, even though that's not likely.
--- fs/xfs/libxfs/xfs_log_recover.h | 2 +- fs/xfs/xfs_buf_item_recover.c | 14 ++++++++++---- fs/xfs/xfs_log_recover.c | 4 +++- 3 files changed, 14 insertions(+), 6 deletions(-)
fs/xfs/libxfs/xfs_log_recover.h +1 -1
@@ -120,7 +120,7 @@ int xlog_recover_iget(struct xfs_mount *mp, xfs_ino_t ino, struct xfs_inode **ipp);void xlog_recover_release_intent (struct xlog *log,unsigned short intent_type,uint64_t intent_id); -void xlog_alloc_buf_cancel_table (struct xlog *log); +int xlog_alloc_buf_cancel_table (struct xlog *log);void xlog_free_buf_cancel_table (struct xlog *log);#ifdef DEBUG
fs/xfs/xfs_buf_item_recover.c +10 -4
@@ -1025,19 +1025,25 @@ xlog_check_buf_cancel_table( }#endif -void +int xlog_alloc_buf_cancel_table (struct xlog *log) { +void *p;int i;ASSERT (log->l_buf_cancel_table ==NULL ); - log->l_buf_cancel_table =kmem_zalloc (XLOG_BC_TABLE_SIZE * -sizeof (struct list_head ), -0 ); + p =kmalloc_array (XLOG_BC_TABLE_SIZE ,sizeof (struct list_head ), +GFP_KERNEL ); +if (!p) +return -ENOMEM ; + + log->l_buf_cancel_table = p;for (i =0 ; i <XLOG_BC_TABLE_SIZE ; i++)INIT_LIST_HEAD (&log->l_buf_cancel_table[i]); + +return 0 ; }void
fs/xfs/xfs_log_recover.c +3 -1
@@ -3256,7 +3256,9 @@ xlog_do_log_recovery(* First do a pass to find all of the cancelled buf log items. * Store them in the buf_cancel_table for use in the second pass. */ -xlog_alloc_buf_cancel_table (log); + error =xlog_alloc_buf_cancel_table (log); +if (error) +return error; error =xlog_do_recovery_pass (log, head_blk, tail_blk,XLOG_RECOVER_PASS1 ,NULL );
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 142/297 xfs: use invalidate_lock to check the state of mmap_lock
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kaixu Xia <[email protected]>
[ Upstream commit 82af88063961da9425924d9aec3fb67a4ebade3e ]
We should use invalidate_lock and XFS_MMAPLOCK_SHARED to check the state of mmap_lock rw_semaphore in xfs_isilocked(), rather than i_rwsem and XFS_IOLOCK_SHARED.
--- fs/xfs/xfs_inode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/xfs/xfs_inode.c +2 -2
@@ -378,8 +378,8 @@ xfs_isilocked( }if (lock_flags & (XFS_MMAPLOCK_EXCL |XFS_MMAPLOCK_SHARED )) { -return __xfs_rwsem_islocked (&VFS_I (ip)->i_rwsem, - (lock_flags &XFS_IOLOCK_SHARED )); +return __xfs_rwsem_islocked (&VFS_I (ip)->i_mapping->invalidate_lock, + (lock_flags &XFS_MMAPLOCK_SHARED )); }if (lock_flags & (XFS_IOLOCK_EXCL |XFS_IOLOCK_SHARED )) {
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 143/297 xfs: prevent a UAF when log IO errors race with unmount
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Darrick J. Wong <[email protected]>
[ Upstream commit 7561cea5dbb97fecb952548a0fb74fb105bf4664 ]
KASAN reported the following use after free bug when running generic/475:
XFS (dm-0): Mounting V5 Filesystem
XFS (dm-0): Starting recovery (logdev: internal)
XFS (dm-0): Ending recovery (logdev: internal)
Buffer I/O error on dev dm-0, logical block 20639616, async page read Buffer I/O error on dev dm-0, logical block 20639617, async page read XFS (dm-0): log I/O error -5
XFS (dm-0): Filesystem has been shut down due to log error (0x2). XFS (dm-0): Unmounting Filesystem
XFS (dm-0): Please unmount the filesystem and rectify the problem(s).
==================================================================
BUG: KASAN: use-after-free in do_raw_spin_lock+0x246/0x270 Read of size 4 at addr ffff888109dd84c4 by task 3:1H/136 CPU: 3 PID: 136 Comm: 3:1H Not tainted 5.19.0-rc4-xfsx #rc4 8e53ab5ad0fddeb31cee5e7063ff9c361915a9c4 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.15.0-1 04/01/2014 Workqueue: xfs-log/dm-0 xlog_ioend_work [xfs] Call Trace: <TASK> dump_stack_lvl+0x34/0x44 print_report.cold+0x2b8/0x661 ? do_raw_spin_lock+0x246/0x270 kasan_report+0xab/0x120 ? do_raw_spin_lock+0x246/0x270 do_raw_spin_lock+0x246/0x270 ? rwlock_bug.part.0+0x90/0x90 xlog_force_shutdown+0xf6/0x370 [xfs 4ad76ae0d6add7e8183a553e624c31e9ed567318] xlog_ioend_work+0x100/0x190 [xfs 4ad76ae0d6add7e8183a553e624c31e9ed567318] process_one_work+0x672/0x1040 worker_thread+0x59b/0xec0 ? __kthread_parkme+0xc6/0x1f0 ? process_one_work+0x1040/0x1040 ? process_one_work+0x1040/0x1040 kthread+0x29e/0x340 ? kthread_complete_and_exit+0x20/0x20 ret_from_fork+0x1f/0x30 </TASK> Allocated by task 154099: kasan_save_stack+0x1e/0x40 __kasan_kmalloc+0x81/0xa0 kmem_alloc+0x8d/0x2e0 [xfs] xlog_cil_init+0x1f/0x540 [xfs] xlog_alloc_log+0xd1e/0x1260 [xfs] xfs_log_mount+0xba/0x640 [xfs] xfs_mountfs+0xf2b/0x1d00 [xfs] xfs_fs_fill_super+0x10af/0x1910 [xfs] get_tree_bdev+0x383/0x670 vfs_get_tree+0x7d/0x240 path_mount+0xdb7/0x1890 __x64_sys_mount+0x1fa/0x270 do_syscall_64+0x2b/0x80 entry_SYSCALL_64_after_hwframe+0x46/0xb0 Freed by task 154151: kasan_save_stack+0x1e/0x40 kasan_set_track+0x21/0x30 kasan_set_free_info+0x20/0x30 ____kasan_slab_free+0x110/0x190 slab_free_freelist_hook+0xab/0x180 kfree+0xbc/0x310 xlog_dealloc_log+0x1b/0x2b0 [xfs] xfs_unmountfs+0x119/0x200 [xfs] xfs_fs_put_super+0x6e/0x2e0 [xfs] generic_shutdown_super+0x12b/0x3a0 kill_block_super+0x95/0xd0 deactivate_locked_super+0x80/0x130 cleanup_mnt+0x329/0x4d0 task_work_run+0xc5/0x160 exit_to_user_mode_prepare+0xd4/0xe0 syscall_exit_to_user_mode+0x1d/0x40 entry_SYSCALL_64_after_hwframe+0x46/0xb0
This appears to be a race between the unmount process, which frees the CIL and waits for in-flight iclog IO; and the iclog IO completion. When generic/475 runs, it starts fsstress in the background, waits a few seconds, and substitutes a dm-error device to simulate a disk falling out of a machine. If the fsstress encounters EIO on a pure data write, it will exit but the filesystem will still be online.
The next thing the test does is unmount the filesystem, which tries to clean the log, free the CIL, and wait for iclog IO completion. If an iclog was being written when the dm-error switch occurred, it can race with log unmounting as follows:
Thread 1 Thread 2
xfs_log_unmount xfs_log_clean xfs_log_quiescexlog_ioend_work
<observe error>xlog_force_shutdowntest_and_set_bit(XLOG_IOERROR)
xfs_log_force <log is shut down, nop> xfs_log_umount_write <log is shut down, nop> xlog_dealloc_log xlog_cil_destroy <wait for iclogs>spin_lock(&log->l_cilp->xc_push_lock)
<KABOOM>
Therefore, free the CIL after waiting for the iclogs to complete. I /think/ this race has existed for quite a few years now, though I don't remember the ~2014 era logging code well enough to know if it was a real threat then or if the actual race was exposed only more recently.
--- fs/xfs/xfs_log.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
fs/xfs/xfs_log.c +7 -2
@@ -2061,8 +2061,6 @@ xlog_dealloc_log(xlog_in_core_t *iclog, *next_iclog;int i; -xlog_cil_destroy (log); -/* * Cycle all the iclogbuf locks to make sure all log IO completion * is done before we tear down these buffers.
@@ -2074,6 +2072,13 @@ xlog_dealloc_log( iclog = iclog->ic_next; } +/* +* Destroy the CIL after waiting for iclog IO completion because an +* iclog EIO error will try to shut down the log, which accesses the +* CIL to wake up the waiters. +*/ +xlog_cil_destroy (log); + iclog = log->l_iclog;for (i =0 ; i < log->l_iclog_bufs; i++) { next_iclog = iclog->ic_next;
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 144/297 xfs: flush inode gc workqueue before clearing agi bucket
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhang Yi <[email protected]>
[ Upstream commit 04a98a036cf8b810dda172a9dcfcbd783bf63655 ]
In the procedure of recover AGI unlinked lists, if something bad happenes on one of the unlinked inode in the bucket list, we would call xlog_recover_clear_agi_bucket() to clear the whole unlinked bucket list, not the unlinked inodes after the bad one. If we have already added some inodes to the gc workqueue before the bad inode in the list, we could get below error when freeing those inodes, and finaly fail to complete the log recover procedure.
XFS (ram0): Internal error xfs_iunlink_remove at line 2456 of file fs/xfs/xfs_inode.c. Caller xfs_ifree+0xb0/0x360 [xfs]
The problem is xlog_recover_clear_agi_bucket() clear the bucket list, so the gc worker fail to check the agino in xfs_verify_agino(). Fix this by flush workqueue before clearing the bucket.
--- fs/xfs/xfs_log_recover.c | 1 + 1 file changed, 1 insertion(+)
fs/xfs/xfs_log_recover.c +1 -0
@@ -2739,6 +2739,7 @@ xlog_recover_process_one_iunlink(* Call xlog_recover_clear_agi_bucket() to perform a transaction to * clear the inode pointer in the bucket. */ +xfs_inodegc_flush (mp);xlog_recover_clear_agi_bucket (mp, agno, bucket);return NULLAGINO ; }
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 145/297 xfs: fix use-after-free in xattr node block inactivation
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Darrick J. Wong <[email protected]>
[ Upstream commit 95ff0363f3f6ae70c21a0f2b0603e54438e5988b ]
The kernel build robot reported a UAF error while running xfs/433 (edited somewhat for brevity):
BUG: KASAN: use-after-free in xfs_attr3_node_inactive (fs/xfs/xfs_attr_inactive.c:214) xfs Read of size 4 at addr ffff88820ac2bd44 by task kworker/0:2/139 CPU: 0 PID: 139 Comm: kworker/0:2 Tainted: G S 5.19.0-rc2-00004-g7cf2b0f9611b #1 Hardware name: Hewlett-Packard p6-1451cx/2ADA, BIOS 8.15 02/05/2013 Workqueue: xfs-inodegc/sdb4 xfs_inodegc_worker [xfs] Call Trace: <TASK> dump_stack_lvl (lib/dump_stack.c:107 (discriminator 1)) print_address_description+0x1f/0x200 print_report.cold (mm/kasan/report.c:430) kasan_report (mm/kasan/report.c:162 mm/kasan/report.c:493) xfs_attr3_node_inactive (fs/xfs/xfs_attr_inactive.c:214) xfs xfs_attr3_root_inactive (fs/xfs/xfs_attr_inactive.c:296) xfs xfs_attr_inactive (fs/xfs/xfs_attr_inactive.c:371) xfs xfs_inactive (fs/xfs/xfs_inode.c:1781) xfs xfs_inodegc_worker (fs/xfs/xfs_icache.c:1837 fs/xfs/xfs_icache.c:1860) xfs process_one_work worker_thread kthread ret_from_fork </TASK> Allocated by task 139: kasan_save_stack (mm/kasan/common.c:39) __kasan_slab_alloc (mm/kasan/common.c:45 mm/kasan/common.c:436 mm/kasan/common.c:469) kmem_cache_alloc (mm/slab.h:750 mm/slub.c:3214 mm/slub.c:3222 mm/slub.c:3229 mm/slub.c:3239) _xfs_buf_alloc (include/linux/instrumented.h:86 include/linux/atomic/atomic-instrumented.h:41 fs/xfs/xfs_buf.c:232) xfs xfs_buf_get_map (fs/xfs/xfs_buf.c:660) xfs xfs_buf_read_map (fs/xfs/xfs_buf.c:777) xfs xfs_trans_read_buf_map (fs/xfs/xfs_trans_buf.c:289) xfs xfs_da_read_buf (fs/xfs/libxfs/xfs_da_btree.c:2652) xfs xfs_da3_node_read (fs/xfs/libxfs/xfs_da_btree.c:392) xfs xfs_attr3_root_inactive (fs/xfs/xfs_attr_inactive.c:272) xfs xfs_attr_inactive (fs/xfs/xfs_attr_inactive.c:371) xfs xfs_inactive (fs/xfs/xfs_inode.c:1781) xfs xfs_inodegc_worker (fs/xfs/xfs_icache.c:1837 fs/xfs/xfs_icache.c:1860) xfs process_one_work worker_thread kthread ret_from_fork Freed by task 139: kasan_save_stack (mm/kasan/common.c:39) kasan_set_track (mm/kasan/common.c:45) kasan_set_free_info (mm/kasan/generic.c:372) __kasan_slab_free (mm/kasan/common.c:368 mm/kasan/common.c:328 mm/kasan/common.c:374) kmem_cache_free (mm/slub.c:1753 mm/slub.c:3507 mm/slub.c:3524) xfs_buf_rele (fs/xfs/xfs_buf.c:1040) xfs xfs_attr3_node_inactive (fs/xfs/xfs_attr_inactive.c:210) xfs xfs_attr3_root_inactive (fs/xfs/xfs_attr_inactive.c:296) xfs xfs_attr_inactive (fs/xfs/xfs_attr_inactive.c:371) xfs xfs_inactive (fs/xfs/xfs_inode.c:1781) xfs xfs_inodegc_worker (fs/xfs/xfs_icache.c:1837 fs/xfs/xfs_icache.c:1860) xfs process_one_work worker_thread kthread ret_from_fork
I reproduced this for my own satisfaction, and got the same report, along with an extra morsel:
The buggy address belongs to the object at ffff88802103a800 which belongs to the cache xfs_buf of size 432 The buggy address is located 396 bytes inside of 432-byte region [ffff88802103a800, ffff88802103a9b0)
I tracked this code down to:
error = xfs_trans_get_buf(*trans, mp->m_ddev_targp, child_blkno, XFS_FSB_TO_BB(mp, mp->m_attr_geo->fsbcount), 0, &child_bp); if (error) return error; error = bp->b_error;
That doesn't look right -- I think this should be dereferencing child_bp, not bp. Looking through the codebase history, I think this was added by commit 2911edb653b9 ("xfs: remove the mappedbno argument to xfs_da_get_buf"), which replaced a call to xfs_da_get_buf with the current call to xfs_trans_get_buf. Not sure why we trans_brelse'd @bp earlier in the function, but I'm guessing it's to avoid pinning too many buffers in memory while we inactivate the bottom of the attr tree. Hence we now have to get the buffer back.
I /think/ this was supposed to check child_bp->b_error and fail the rest of the invalidation if child_bp had experienced any kind of IO or corruption error. I bet the xfs_da3_node_read earlier in the loop will catch most cases of incoming on-disk corruption which makes this check mostly moot unless someone corrupts the buffer and the AIL pushes it out to disk while the buffer's unlocked.
In the first case we'll never get to the bad check, and in the second case the AIL will shut down the log, at which point there's no reason to check b_error. Remove the check, and null out @bp to avoid this problem in the future.
--- fs/xfs/xfs_attr_inactive.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
fs/xfs/xfs_attr_inactive.c +3 -5
@@ -158,6 +158,7 @@ xfs_attr3_node_inactive( } child_fsb =be32_to_cpu (ichdr.btree[0 ].before);xfs_trans_brelse (*trans, bp);/* no locks for later trans */ + bp =NULL ;/* * If this is the node level just above the leaves, simply loop
@@ -211,12 +212,8 @@ xfs_attr3_node_inactive( &child_bp);if (error)return error; - error = bp->b_error; -if (error) { -xfs_trans_brelse (*trans, child_bp); -return error; - }xfs_trans_binval (*trans, child_bp); + child_bp =NULL ;/* * If we're not done, re-read the parent to get the next
@@ -233,6 +230,7 @@ xfs_attr3_node_inactive( bp->b_addr); child_fsb =be32_to_cpu (phdr.btree[i +1 ].before);xfs_trans_brelse (*trans, bp); + bp =NULL ; }/* * Atomically commit the whole invalidate stuff.
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 146/297 xfs: dont leak memory when attr fork loading fails
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Darrick J. Wong <[email protected]>
[ Upstream commit c78c2d0903183a41beb90c56a923e30f90fa91b9 ]
I observed the following evidence of a memory leak while running xfs/399 from the xfs fsck test suite (edited for brevity):
XFS (sde): Metadata corruption detected at xfs_attr_shortform_verify_struct.part.0+0x7b/0xb0 [xfs], inode 0x1172 attr fork
XFS: Assertion failed: ip->i_af.if_u1.if_data == NULL, file: fs/xfs/libxfs/xfs_inode_fork.c, line: 315
------------[ cut here ]------------ WARNING: CPU: 2 PID: 91635 at fs/xfs/xfs_message.c:104 assfail+0x46/0x4a [xfs] CPU: 2 PID: 91635 Comm: xfs_scrub Tainted: G W 5.19.0-rc7-xfsx #rc7 6e6475eb29fd9dda3181f81b7ca7ff961d277a40 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.15.0-1 04/01/2014 RIP: 0010:assfail+0x46/0x4a [xfs] Call Trace: <TASK> xfs_ifork_zap_attr+0x7c/0xb0 xfs_iformat_attr_fork+0x86/0x110 xfs_inode_from_disk+0x41d/0x480 xfs_iget+0x389/0xd70 xfs_bulkstat_one_int+0x5b/0x540 xfs_bulkstat_iwalk+0x1e/0x30 xfs_iwalk_ag_recs+0xd1/0x160 xfs_iwalk_run_callbacks+0xb9/0x180 xfs_iwalk_ag+0x1d8/0x2e0 xfs_iwalk+0x141/0x220 xfs_bulkstat+0x105/0x180 xfs_ioc_bulkstat.constprop.0.isra.0+0xc5/0x130 xfs_file_ioctl+0xa5f/0xef0 __x64_sys_ioctl+0x82/0xa0 do_syscall_64+0x2b/0x80 entry_SYSCALL_64_after_hwframe+0x46/0xb0
This newly-added assertion checks that there aren't any incore data structures hanging off the incore fork when we're trying to reset its contents. From the call trace, it is evident that iget was trying to construct an incore inode from the ondisk inode, but the attr fork verifier failed and we were trying to undo all the memory allocations that we had done earlier.
The three assertions in xfs_ifork_zap_attr check that the caller has already called xfs_idestroy_fork, which clearly has not been done here. As the zap function then zeroes the pointers, we've effectively leaked the memory.
The shortest change would have been to insert an extra call to xfs_idestroy_fork, but it makes more sense to bundle the _idestroy_fork call into _zap_attr, since all other callsites call _idestroy_fork immediately prior to calling _zap_attr. IOWs, it eliminates one way to fail.
Note: This change only applies cleanly to 2ed5b09b3e8f, since we just reworked the attr fork lifetime. However, I think this memory leak has existed since 0f45a1b20cd8, since the chain xfs_iformat_attr_fork -> xfs_iformat_local -> xfs_init_local_fork will allocate ifp->if_u1.if_data, but if xfs_ifork_verify_local_attr fails, xfs_iformat_attr_fork will free i_afp without freeing any of the stuff hanging off i_afp. The solution for older kernels I think is to add the missing call to xfs_idestroy_fork just prior to calling kmem_cache_free.
Found by fuzzing a.sfattr.hdr.totsize = lastbit in xfs/399.
[ backport note: did not include refactoring of xfs_idestroy_fork into xfs_ifork_zap_attr, simply added the missing call as suggested in the commit for backports ]
Probably-Fixes: 0f45a1b20cd8 ("xfs: improve local fork verification")
--- fs/xfs/libxfs/xfs_inode_fork.c | 1 + 1 file changed, 1 insertion(+)
fs/xfs/libxfs/xfs_inode_fork.c +1 -0
@@ -330,6 +330,7 @@ xfs_iformat_attr_fork( }if (error) { +xfs_idestroy_fork (ip->i_afp);kmem_cache_free (xfs_ifork_zone, ip->i_afp); ip->i_afp =NULL ; }
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 147/297 xfs: fix intermittent hang during quotacheck
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Darrick J. Wong <[email protected]>
[ Upstream commit f0c2d7d2abca24d19831c99edea458704fac8087 ]
Every now and then, I see the following hang during mount time quotacheck when running fstests. Turning on KASAN seems to make it happen somewhat more frequently. I've edited the backtrace for brevity.
XFS (sdd): Quotacheck needed: Please wait.
XFS: Assertion failed: bp->b_flags & _XBF_DELWRI_Q, file: fs/xfs/xfs_buf.c, line: 2411
------------[ cut here ]------------ WARNING: CPU: 0 PID: 1831409 at fs/xfs/xfs_message.c:104 assfail+0x46/0x4a [xfs] CPU: 0 PID: 1831409 Comm: mount Tainted: G W 5.19.0-rc6-xfsx #rc6 09911566947b9f737b036b4af85e399e4b9aef64 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.15.0-1 04/01/2014 RIP: 0010:assfail+0x46/0x4a [xfs] Code: a0 8f 41 a0 e8 45 fe ff ff 8a 1d 2c 36 10 00 80 fb 01 76 0f 0f b6 f3 48 c7 c7 c0 f0 4f a0 e8 10 f0 02 e1 80 e3 01 74 02 0f 0b <0f> 0b 5b c3 48 8d 45 10 48 89 e2 4c 89 e6 48 89 1c 24 48 89 44 24 RSP: 0018:ffffc900078c7b30 EFLAGS: 00010246 RAX: 0000000000000000 RBX: ffff8880099ac000 RCX: 000000007fffffff RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffffffffa0418fa0 RBP: ffff8880197bc1c0 R08: 0000000000000000 R09: 000000000000000a R10: 000000000000000a R11: f000000000000000 R12: ffffc900078c7d20 R13: 00000000fffffff5 R14: ffffc900078c7d20 R15: 0000000000000000 FS: 00007f0449903800(0000) GS:ffff88803ec00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00005610ada631f0 CR3: 0000000014dd8002 CR4: 00000000001706f0 Call Trace: <TASK> xfs_buf_delwri_pushbuf+0x150/0x160 [xfs 4561f5b32c9bfb874ec98d58d0719464e1f87368] xfs_qm_flush_one+0xd6/0x130 [xfs 4561f5b32c9bfb874ec98d58d0719464e1f87368] xfs_qm_dquot_walk.isra.0+0x109/0x1e0 [xfs 4561f5b32c9bfb874ec98d58d0719464e1f87368] xfs_qm_quotacheck+0x319/0x490 [xfs 4561f5b32c9bfb874ec98d58d0719464e1f87368] xfs_qm_mount_quotas+0x65/0x2c0 [xfs 4561f5b32c9bfb874ec98d58d0719464e1f87368] xfs_mountfs+0x6b5/0xab0 [xfs 4561f5b32c9bfb874ec98d58d0719464e1f87368] xfs_fs_fill_super+0x781/0x990 [xfs 4561f5b32c9bfb874ec98d58d0719464e1f87368] get_tree_bdev+0x175/0x280 vfs_get_tree+0x1a/0x80 path_mount+0x6f5/0xaa0 __x64_sys_mount+0x103/0x140 do_syscall_64+0x2b/0x80 entry_SYSCALL_64_after_hwframe+0x46/0xb0
I /think/ this can happen if xfs_qm_flush_one is racing with xfs_qm_dquot_isolate (i.e. dquot reclaim) when the second function has taken the dquot flush lock but xfs_qm_dqflush hasn't yet locked the dquot buffer, let alone queued it to the delwri list. In this case, flush_one will fail to get the dquot flush lock, but it can lock the incore buffer, but xfs_buf_delwri_pushbuf will then trip over this ASSERT, which checks that the buffer isn't on a delwri list. The hang results because the _delwri_submit_buffers ignores non DELWRI_Q buffers, which means that xfs_buf_iowait waits forever for an IO that has not yet been scheduled.
AFAICT, a reasonable solution here is to detect a dquot buffer that is not on a DELWRI list, drop it, and return -EAGAIN to try the flush again. It's not /that/ big of a deal if quotacheck writes the dquot buffer repeatedly before we even set QUOTA_CHKD.
--- fs/xfs/xfs_qm.c | 7 +++++++ 1 file changed, 7 insertions(+)
fs/xfs/xfs_qm.c +7 -0
@@ -1244,6 +1244,13 @@ xfs_qm_flush_one( error = -EINVAL ; goto out_unlock; } + +if (!(bp->b_flags & _XBF_DELWRI_Q)) { + error = -EAGAIN ; +xfs_buf_relse (bp); + goto out_unlock; + } +xfs_buf_unlock (bp);xfs_buf_delwri_pushbuf (bp, buffer_list);
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 148/297 xfs: add missing cmap->br_state = XFS_EXT_NORM update
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gao Xiang <[email protected]>
[ Upstream commit 1a39ae415c1be1e46f5b3f97d438c7c4adc22b63 ]
COW extents are already converted into written real extents after xfs_reflink_convert_cow_locked(), therefore cmap->br_state should reflect it.
Otherwise, there is another necessary unwritten convertion triggered in xfs_dio_write_end_io() for direct I/O cases.
--- fs/xfs/xfs_reflink.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
fs/xfs/xfs_reflink.c +4 -1
@@ -425,7 +425,10 @@ xfs_reflink_allocate_cow(if (!convert_now || cmap->br_state ==XFS_EXT_NORM )return 0 ;trace_xfs_reflink_convert_cow (ip, cmap); -return xfs_reflink_convert_cow_locked (ip, offset_fsb, count_fsb); + error =xfs_reflink_convert_cow_locked (ip, offset_fsb, count_fsb); +if (!error) + cmap->br_state =XFS_EXT_NORM ; +return error; out_trans_cancel:xfs_trans_cancel (tp);
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 149/297 xfs: Fix false ENOSPC when performing direct write on a delalloc extent in cow fork
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandan Babu R <[email protected]>
[ Upstream commit d62113303d691bcd8d0675ae4ac63e7769afc56c ]
On a higly fragmented filesystem a Direct IO write can fail with -ENOSPC error even though the filesystem has sufficient number of free blocks.
This occurs if the file offset range on which the write operation is being performed has a delalloc extent in the cow fork and this delalloc extent begins much before the Direct IO range.
In such a scenario, xfs_reflink_allocate_cow() invokes xfs_bmapi_write() to allocate the blocks mapped by the delalloc extent. The extent thus allocated may not cover the beginning of file offset range on which the Direct IO write was issued. Hence xfs_reflink_allocate_cow() ends up returning -ENOSPC.
The following script reliably recreates the bug described above.
#!/usr/bin/bash
device=/dev/loop0
shortdev=$(basename $device)
mntpnt=/mnt/
file1=${mntpnt}/file1
file2=${mntpnt}/file2
fragmentedfile=${mntpnt}/fragmentedfile
punchprog=/root/repos/xfstests-dev/src/punch-alternating
errortag=/sys/fs/xfs/${shortdev}/errortag/bmap_alloc_minlen_extent umount $device > /dev/null 2>&1
echo "Create FS"
mkfs.xfs -f -m reflink=1 $device > /dev/null 2>&1 if [[ $? != 0 ]]; then
echo "mkfs failed."
exit 1
fi
echo "Mount FS"
mount $device $mntpnt > /dev/null 2>&1
if [[ $? != 0 ]]; then
echo "mount failed."
exit 1
fi
echo "Create source file"
xfs_io -f -c "pwrite 0 32M" $file1 > /dev/null 2>&1
sync
echo "Create Reflinked file"
xfs_io -f -c "reflink $file1" $file2 &>/dev/null
echo "Set cowextsize"
xfs_io -c "cowextsize 16M" $file1 > /dev/null 2>&1
echo "Fragment FS"
xfs_io -f -c "pwrite 0 64M" $fragmentedfile > /dev/null 2>&1 sync
$punchprog $fragmentedfile
echo "Allocate block sized extent from now onwards" echo -n 1 > $errortag
echo "Create 16MiB delalloc extent in CoW fork"
xfs_io -c "pwrite 0 4k" $file1 > /dev/null 2>&1
sync
echo "Direct I/O write at offset 12k"
xfs_io -d -c "pwrite 12k 8k" $file1
This commit fixes the bug by invoking xfs_bmapi_write() in a loop until disk blocks are allocated for atleast the starting file offset of the Direct IO write range.
--- fs/xfs/xfs_reflink.c | 198 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 163 insertions(+), 35 deletions(-)
fs/xfs/xfs_reflink.c +163 -35
@@ -340,9 +340,41 @@ xfs_find_trim_cow_extent(return 0 ; } -/* Allocate all CoW reservations covering a range of blocks in a file. */ -int -xfs_reflink_allocate_cow( +static int +xfs_reflink_convert_unwritten ( +struct xfs_inode *ip, +struct xfs_bmbt_irec *imap, +struct xfs_bmbt_irec *cmap, +bool convert_now) +{ +xfs_fileoff_t offset_fsb = imap->br_startoff; +xfs_filblks_t count_fsb = imap->br_blockcount; +int error; + +/* +* cmap might larger than imap due to cowextsize hint. +*/ +xfs_trim_extent (cmap, offset_fsb, count_fsb); + +/* +* COW fork extents are supposed to remain unwritten until we're ready +* to initiate a disk write. For direct I/O we are going to write the +* data and need the conversion, but for buffered writes we're done. +*/ +if (!convert_now || cmap->br_state ==XFS_EXT_NORM ) +return 0 ; + +trace_xfs_reflink_convert_cow (ip, cmap); + + error =xfs_reflink_convert_cow_locked (ip, offset_fsb, count_fsb); +if (!error) + cmap->br_state =XFS_EXT_NORM ; + +return error; +} + +static int +xfs_reflink_fill_cow_hole( struct xfs_inode *ip, struct xfs_bmbt_irec *imap, struct xfs_bmbt_irec *cmap,
@@ -351,25 +383,12 @@ xfs_reflink_allocate_cow( bool convert_now) {struct xfs_mount *mp = ip->i_mount; -xfs_fileoff_t offset_fsb = imap->br_startoff; -xfs_filblks_t count_fsb = imap->br_blockcount;struct xfs_trans *tp; -int nimaps, error =0 ; -bool found;xfs_filblks_t resaligned; -xfs_extlen_t resblks =0 ; - -ASSERT (xfs_isilocked (ip,XFS_ILOCK_EXCL )); -if (!ip->i_cowfp) { -ASSERT (!xfs_is_reflink_inode (ip)); -xfs_ifork_init_cow (ip); - } - - error =xfs_find_trim_cow_extent (ip, imap, cmap, shared, &found); -if (error || !*shared) -return error; -if (found) - goto convert; +xfs_extlen_t resblks; +int nimaps; +int error; +bool found; resaligned =xfs_aligned_fsb_count (imap->br_startoff, imap->br_blockcount,xfs_get_cowextsz_hint (ip));
@@ -385,17 +404,17 @@ xfs_reflink_allocate_cow( *lockmode =XFS_ILOCK_EXCL ; -/* -* Check for an overlapping extent again now that we dropped the ilock. -*/ error =xfs_find_trim_cow_extent (ip, imap, cmap, shared, &found);if (error || !*shared) goto out_trans_cancel; +if (found) {xfs_trans_cancel (tp); goto convert; } +ASSERT (cmap->br_startoff > imap->br_startoff); +/* Allocate the entire reservation as unwritten blocks. */ nimaps =1 ; error = xfs_bmapi_write(tp, ip, imap->br_startoff, imap->br_blockcount,
@@ -415,26 +434,135 @@ xfs_reflink_allocate_cow(*/ if (nimaps ==0 )return -ENOSPC ; + convert: -xfs_trim_extent (cmap, offset_fsb, count_fsb); -/* -* COW fork extents are supposed to remain unwritten until we're ready -* to initiate a disk write. For direct I/O we are going to write the -* data and need the conversion, but for buffered writes we're done. -*/ -if (!convert_now || cmap->br_state ==XFS_EXT_NORM ) -return 0 ; -trace_xfs_reflink_convert_cow (ip, cmap); - error =xfs_reflink_convert_cow_locked (ip, offset_fsb, count_fsb); -if (!error) - cmap->br_state =XFS_EXT_NORM ; +return xfs_reflink_convert_unwritten (ip, imap, cmap, convert_now); + +out_trans_cancel: +xfs_trans_cancel (tp);return error; +} + +static int +xfs_reflink_fill_delalloc ( +struct xfs_inode *ip, +struct xfs_bmbt_irec *imap, +struct xfs_bmbt_irec *cmap, +bool *shared, +uint *lockmode, +bool convert_now) +{ +struct xfs_mount *mp = ip->i_mount; +struct xfs_trans *tp; +int nimaps; +int error; +bool found; + +do { +xfs_iunlock (ip, *lockmode); + *lockmode =0 ; + + error =xfs_trans_alloc_inode (ip, &M_RES (mp)->tr_write,0 ,0 , + false, &tp); +if (error) +return error; + + *lockmode =XFS_ILOCK_EXCL ; + + error =xfs_find_trim_cow_extent (ip, imap, cmap, shared, + &found); +if (error || !*shared) + goto out_trans_cancel; + +if (found) { +xfs_trans_cancel (tp); +break ; + } + +ASSERT (isnullstartblock (cmap->br_startblock) || + cmap->br_startblock ==DELAYSTARTBLOCK ); + +/* +* Replace delalloc reservation with an unwritten extent. +*/ + nimaps =1 ; + error =xfs_bmapi_write (tp, ip, cmap->br_startoff, + cmap->br_blockcount, +XFS_BMAPI_COWFORK |XFS_BMAPI_PREALLOC ,0 , + cmap, &nimaps); +if (error) + goto out_trans_cancel; + +xfs_inode_set_cowblocks_tag (ip); + error =xfs_trans_commit (tp); +if (error) +return error; + +/* +* Allocation succeeded but the requested range was not even +* partially satisfied? Bail out! +*/ +if (nimaps ==0 ) +return -ENOSPC ; + }while (cmap->br_startoff + cmap->br_blockcount <= imap->br_startoff); + +return xfs_reflink_convert_unwritten (ip, imap, cmap, convert_now); out_trans_cancel:xfs_trans_cancel (tp);return error; } +/* Allocate all CoW reservations covering a range of blocks in a file. */ +int +xfs_reflink_allocate_cow ( +struct xfs_inode *ip, +struct xfs_bmbt_irec *imap, +struct xfs_bmbt_irec *cmap, +bool *shared, +uint *lockmode, +bool convert_now) +{ +int error; +bool found; + +ASSERT (xfs_isilocked (ip,XFS_ILOCK_EXCL )); +if (!ip->i_cowfp) { +ASSERT (!xfs_is_reflink_inode (ip)); +xfs_ifork_init_cow (ip); + } + + error =xfs_find_trim_cow_extent (ip, imap, cmap, shared, &found); +if (error || !*shared) +return error; + +/* CoW fork has a real extent */ +if (found) +return xfs_reflink_convert_unwritten (ip, imap, cmap, + convert_now); + +/* +* CoW fork does not have an extent and data extent is shared. +* Allocate a real extent in the CoW fork. +*/ +if (cmap->br_startoff > imap->br_startoff) +return xfs_reflink_fill_cow_hole (ip, imap, cmap, shared, + lockmode, convert_now); + +/* +* CoW fork has a delalloc reservation. Replace it with a real extent. +* There may or may not be a data fork mapping. +*/ +if (isnullstartblock (cmap->br_startblock) || + cmap->br_startblock ==DELAYSTARTBLOCK ) +return xfs_reflink_fill_delalloc (ip, imap, cmap, shared, + lockmode, convert_now); + +/* Shouldn't get here. */ +ASSERT (0 ); +return -EFSCORRUPTED ; +} +/* * Cancel CoW reservations for some block range of an inode. *
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 150/297 xfs: fix inode reservation space for removing transaction
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: hexiaole <[email protected]>
[ Upstream commit 031d166f968efba6e4f091ff75d0bb5206bb3918 ]
In 'fs/xfs/libxfs/xfs_trans_resv.c', the comment for transaction of removing a directory entry writes:
/* fs/xfs/libxfs/xfs_trans_resv.c begin */
/*
* For removing a directory entry we can modify:
* the parent directory inode: inode size
* the removed inode: inode size
...
xfs_calc_remove_reservation(
struct xfs_mount *mp)
{
return XFS_DQUOT_LOGRES(mp) +
xfs_calc_iunlink_add_reservation(mp) + max((xfs_calc_inode_res(mp, 1) +
...
/* fs/xfs/libxfs/xfs_trans_resv.c end */
There has 2 inode size of space to be reserverd, but the actual code for inode reservation space writes.
There only count for 1 inode size to be reserved in 'xfs_calc_inode_res(mp, 1)', rather than 2.
--- fs/xfs/libxfs/xfs_trans_resv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/libxfs/xfs_trans_resv.c +1 -1
@@ -423,7 +423,7 @@ xfs_calc_remove_reservation( {return XFS_DQUOT_LOGRES (mp) +xfs_calc_iunlink_add_reservation (mp) + - max((xfs_calc_inode_res(mp, 1) + + max((xfs_calc_inode_res(mp, 2) + xfs_calc_buf_res(XFS_DIROP_LOG_COUNT(mp), XFS_FSB_TO_B(mp, 1))), (xfs_calc_buf_res(4, mp->m_sb.sb_sectsize) +
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 151/297 xfs: avoid a UAF when log intent item recovery fails
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Darrick J. Wong <[email protected]>
[ Upstream commit 97cf79677ecb50a38517253ae2fd705849a7e51a ]
KASAN reported a UAF bug when I was running xfs/235:
BUG: KASAN: use-after-free in xlog_recover_process_intents+0xa77/0xae0 [xfs]
Read of size 8 at addr ffff88804391b360 by task mount/5680
CPU: 2 PID: 5680 Comm: mount Not tainted 6.0.0-xfsx #6.0.0 77e7b52a4943a975441e5ac90a5ad7748b7867f6
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.15.0-1 04/01/2014
Call Trace:
<TASK>
dump_stack_lvl+0x34/0x44
print_report.cold+0x2cc/0x682
kasan_report+0xa3/0x120
xlog_recover_process_intents+0xa77/0xae0 [xfs fb841c7180aad3f8359438576e27867f5795667e]
xlog_recover_finish+0x7d/0x970 [xfs fb841c7180aad3f8359438576e27867f5795667e]
xfs_log_mount_finish+0x2d7/0x5d0 [xfs fb841c7180aad3f8359438576e27867f5795667e]
xfs_mountfs+0x11d4/0x1d10 [xfs fb841c7180aad3f8359438576e27867f5795667e]
xfs_fs_fill_super+0x13d5/0x1a80 [xfs fb841c7180aad3f8359438576e27867f5795667e]
get_tree_bdev+0x3da/0x6e0
vfs_get_tree+0x7d/0x240
path_mount+0xdd3/0x17d0
__x64_sys_mount+0x1fa/0x270
do_syscall_64+0x2b/0x80
entry_SYSCALL_64_after_hwframe+0x46/0xb0
RIP: 0033:0x7ff5bc069eae
Code: 48 8b 0d 85 1f 0f 00 f7 d8 64 89 01 48 83 c8 ff c3 66 2e 0f 1f 84 00 00 00 00 00 90 f3 0f 1e fa 49 89 ca b8 a5 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 52 1f 0f 00 f7 d8 64 89 01 48
RSP: 002b:00007ffe433fd448 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007ff5bc069eae
RDX: 00005575d7213290 RSI: 00005575d72132d0 RDI: 00005575d72132b0
RBP: 00005575d7212fd0 R08: 00005575d7213230 R09: 00005575d7213fe0
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00005575d7213290 R14: 00005575d72132b0 R15: 00005575d7212fd0
</TASK>
Allocated by task 5680:
kasan_save_stack+0x1e/0x40
__kasan_slab_alloc+0x66/0x80
kmem_cache_alloc+0x152/0x320
xfs_rui_init+0x17a/0x1b0 [xfs]
xlog_recover_rui_commit_pass2+0xb9/0x2e0 [xfs]
xlog_recover_items_pass2+0xe9/0x220 [xfs]
xlog_recover_commit_trans+0x673/0x900 [xfs]
xlog_recovery_process_trans+0xbe/0x130 [xfs]
xlog_recover_process_data+0x103/0x2a0 [xfs]
xlog_do_recovery_pass+0x548/0xc60 [xfs]
xlog_do_log_recovery+0x62/0xc0 [xfs]
xlog_do_recover+0x73/0x480 [xfs]
xlog_recover+0x229/0x460 [xfs]
xfs_log_mount+0x284/0x640 [xfs]
xfs_mountfs+0xf8b/0x1d10 [xfs]
xfs_fs_fill_super+0x13d5/0x1a80 [xfs]
get_tree_bdev+0x3da/0x6e0
vfs_get_tree+0x7d/0x240
path_mount+0xdd3/0x17d0
__x64_sys_mount+0x1fa/0x270
do_syscall_64+0x2b/0x80
entry_SYSCALL_64_after_hwframe+0x46/0xb0
Freed by task 5680:
kasan_save_stack+0x1e/0x40
kasan_set_track+0x21/0x30
kasan_set_free_info+0x20/0x30
____kasan_slab_free+0x144/0x1b0
slab_free_freelist_hook+0xab/0x180
kmem_cache_free+0x1f1/0x410
xfs_rud_item_release+0x33/0x80 [xfs]
xfs_trans_free_items+0xc3/0x220 [xfs]
xfs_trans_cancel+0x1fa/0x590 [xfs]
xfs_rui_item_recover+0x913/0xd60 [xfs]
xlog_recover_process_intents+0x24e/0xae0 [xfs]
xlog_recover_finish+0x7d/0x970 [xfs]
xfs_log_mount_finish+0x2d7/0x5d0 [xfs]
xfs_mountfs+0x11d4/0x1d10 [xfs]
xfs_fs_fill_super+0x13d5/0x1a80 [xfs]
get_tree_bdev+0x3da/0x6e0
vfs_get_tree+0x7d/0x240
path_mount+0xdd3/0x17d0
__x64_sys_mount+0x1fa/0x270
do_syscall_64+0x2b/0x80
entry_SYSCALL_64_after_hwframe+0x46/0xb0
The buggy address belongs to the object at ffff88804391b300
which belongs to the cache xfs_rui_item of size 688
The buggy address is located 96 bytes inside of
688-byte region [ffff88804391b300, ffff88804391b5b0)
The buggy address belongs to the physical page:
page:ffffea00010e4600 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff888043919320 pfn:0x43918
head:ffffea00010e4600 order:2 compound_mapcount:0 compound_pincount:0
flags: 0x4fff80000010200(slab|head|node=1|zone=1|lastcpupid=0xfff)
raw: 04fff80000010200 0000000000000000 dead000000000122 ffff88807f0eadc0
raw: ffff888043919320 0000000080140010 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff88804391b200: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff88804391b280: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff88804391b300: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88804391b380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88804391b400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================The test fuzzes an rmap btree block and starts writer threads to induce a filesystem shutdown on the corrupt block. When the filesystem is remounted, recovery will try to replay the committed rmap intent item, but the corruption problem causes the recovery transaction to fail. Cancelling the transaction frees the RUD, which frees the RUI that we recovered.
When we return to xlog_recover_process_intents, @lip is now a dangling pointer, and we cannot use it to find the iop_recover method for the tracepoint. Hence we must store the item ops before calling ->iop_recover if we want to give it to the tracepoint so that the trace data will tell us exactly which intent item failed.
--- fs/xfs/xfs_log_recover.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
fs/xfs/xfs_log_recover.c +7 -2
@@ -2560,6 +2560,7 @@ xlog_recover_process_intents(for (lip =xfs_trans_ail_cursor_first (ailp, &cur,0 ); lip !=NULL ; lip =xfs_trans_ail_cursor_next (ailp, &cur)) { +const struct xfs_item_ops *ops;/* * We're done when we see something other than an intent. * There should be no intents left in the AIL now.
@@ -2584,13 +2585,17 @@ xlog_recover_process_intents(* deferred ops, you /must/ attach them to the capture list in * the recover routine or else those subsequent intents will be * replayed in the wrong order! +* +* The recovery function can free the log item, so we must not +* access lip after it returns. */ spin_unlock (&ailp->ail_lock); - error = lip->li_ops->iop_recover (lip, &capture_list); + ops = lip->li_ops; + error = ops->iop_recover (lip, &capture_list);spin_lock (&ailp->ail_lock);if (error) {trace_xlog_intent_recovery_failed (log->l_mp, error, - lip->li_ops->iop_recover); + ops->iop_recover);break ; } }
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 152/297 xfs: fix exception caused by unexpected illegal bestcount in leaf dir
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guo Xuenan <[email protected]>
[ Upstream commit 13cf24e00665c9751951a422756d975812b71173 ]
For leaf dir, In most cases, there should be as many bestfree slots as the dir data blocks that can fit under i_size (except for [1]).
Root cause is we don't examin the number bestfree slots, when the slots number less than dir data blocks, if we need to allocate new dir data block and update the bestfree array, we will use the dir block number as index to assign bestfree array, while we did not check the leaf buf boundary which may cause UAF or other memory access problem. This issue can also triggered with test cases xfs/473 from fstests.
According to Dave Chinner & Darrick's suggestion, adding buffer verifier to detect this abnormal situation in time.
Simplify the testcase for fstest xfs/554 [1]
The error log is shown as follows:
==================================================================
BUG: KASAN: use-after-free in xfs_dir2_leaf_addname+0x1995/0x1ac0 Write of size 2 at addr ffff88810168b000 by task touch/1552 CPU: 5 PID: 1552 Comm: touch Not tainted 6.0.0-rc3+ #101 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-1ubuntu1.1 04/01/2014 Call Trace: <TASK> dump_stack_lvl+0x4d/0x66 print_report.cold+0xf6/0x691 kasan_report+0xa8/0x120 xfs_dir2_leaf_addname+0x1995/0x1ac0 xfs_dir_createname+0x58c/0x7f0 xfs_create+0x7af/0x1010 xfs_generic_create+0x270/0x5e0 path_openat+0x270b/0x3450 do_filp_open+0x1cf/0x2b0 do_sys_openat2+0x46b/0x7a0 do_sys_open+0xb7/0x130 do_syscall_64+0x35/0x80 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x7fe4d9e9312b Code: 25 00 00 41 00 3d 00 00 41 00 74 4b 64 8b 04 25 18 00 00 00 85 c0
75 67 44 89 e2 48 89 ee bf 9c ff ff ff b8 01 01 00 00 0f 05 <48> 3d 00 f0 ff ff 0f 87 91 00 00 00 48 8b 4c 24 28 64 48 33 0c 25
RSP: 002b:00007ffda4c16c20 EFLAGS: 00000246 ORIG_RAX: 0000000000000101
RAX: ffffffffffffffda RBX: 0000000000000001 RCX: 00007fe4d9e9312b
RDX: 0000000000000941 RSI: 00007ffda4c17f33 RDI: 00000000ffffff9c
RBP: 00007ffda4c17f33 R08: 0000000000000000 R09: 0000000000000000
R10: 00000000000001b6 R11: 0000000000000246 R12: 0000000000000941
R13: 00007fe4d9f631a4 R14: 00007ffda4c17f33 R15: 0000000000000000
</TASK>
The buggy address belongs to the physical page:
page:ffffea000405a2c0 refcount:0 mapcount:0 mapping:0000000000000000
index:0x0 pfn:0x10168b
flags: 0x2fffff80000000(node=0|zone=2|lastcpupid=0x1fffff)
raw: 002fffff80000000 ffffea0004057788 ffffea000402dbc8 0000000000000000
raw: 0000000000000000 0000000000170000 00000000ffffffff 0000000000000000
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff88810168af00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ffff88810168af80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff88810168b000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
^
ffff88810168b080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
ffff88810168b100: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
==================================================================Disabling lock debugging due to kernel taint
00000000: 58 44 44 33 5b 53 35 c2 00 00 00 00 00 00 00 78 XDD3[S5........x
XFS (sdb): Internal error xfs_dir2_data_use_free at line 1200 of file fs/xfs/libxfs/xfs_dir2_data.c. Caller
xfs_dir2_data_use_free+0x28a/0xeb0 CPU: 5 PID: 1552 Comm: touch Tainted: G B 6.0.0-rc3+ Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-1ubuntu1.1 04/01/2014 Call Trace: <TASK> dump_stack_lvl+0x4d/0x66 xfs_corruption_error+0x132/0x150 xfs_dir2_data_use_free+0x198/0xeb0 xfs_dir2_leaf_addname+0xa59/0x1ac0 xfs_dir_createname+0x58c/0x7f0 xfs_create+0x7af/0x1010 xfs_generic_create+0x270/0x5e0 path_openat+0x270b/0x3450 do_filp_open+0x1cf/0x2b0 do_sys_openat2+0x46b/0x7a0 do_sys_open+0xb7/0x130 do_syscall_64+0x35/0x80 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x7fe4d9e9312b Code: 25 00 00 41 00 3d 00 00 41 00 74 4b 64 8b 04 25 18 00 00 00 85 c0
75 67 44 89 e2 48 89 ee bf 9c ff ff ff b8 01 01 00 00 0f 05 <48> 3d 00 f0 ff ff 0f 87 91 00 00 00 48 8b 4c 24 28 64 48 33 0c 25
RSP: 002b:00007ffda4c16c20 EFLAGS: 00000246 ORIG_RAX: 0000000000000101
RAX: ffffffffffffffda RBX: 0000000000000001 RCX: 00007fe4d9e9312b
RDX: 0000000000000941 RSI: 00007ffda4c17f46 RDI: 00000000ffffff9c
RBP: 00007ffda4c17f46 R08: 0000000000000000 R09: 0000000000000001
R10: 00000000000001b6 R11: 0000000000000246 R12: 0000000000000941
R13: 00007fe4d9f631a4 R14: 00007ffda4c17f46 R15: 0000000000000000
</TASK>
XFS (sdb): Corruption detected. Unmount and run xfs_repair
[1] https://lore.kernel.org/all/[email protected]/
--- fs/xfs/libxfs/xfs_dir2_leaf.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
fs/xfs/libxfs/xfs_dir2_leaf.c +7 -2
@@ -146,6 +146,8 @@ xfs_dir3_leaf_check_int(xfs_dir2_leaf_tail_t *ltp;int stale;int i; +bool isleaf1 = (hdr->magic ==XFS_DIR2_LEAF1_MAGIC || + hdr->magic ==XFS_DIR3_LEAF1_MAGIC ); ltp =xfs_dir2_leaf_tail_p (geo, leaf);
@@ -158,8 +160,7 @@ xfs_dir3_leaf_check_int(return __this_address;/* Leaves and bests don't overlap in leaf format. */ -if ((hdr->magic ==XFS_DIR2_LEAF1_MAGIC || - hdr->magic ==XFS_DIR3_LEAF1_MAGIC ) && +if (isleaf1 && (char *)&hdr->ents[hdr->count] > (char *)xfs_dir2_leaf_bests_p (ltp))return __this_address;
@@ -175,6 +176,10 @@ xfs_dir3_leaf_check_int( }if (hdr->ents[i].address ==cpu_to_be32 (XFS_DIR2_NULL_DATAPTR )) stale++; +if (isleaf1 &&xfs_dir2_dataptr_to_db (geo, +be32_to_cpu (hdr->ents[i].address)) >= +be32_to_cpu (ltp->bestcount)) +return __this_address; }if (hdr->stale != stale)return __this_address;
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 153/297 xfs: fix memory leak in xfs_errortag_init
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zeng Heng <[email protected]>
[ Upstream commit cf4f4c12dea7a977a143c8fe5af1740b7f9876f8 ]
When xfs_sysfs_init returns failed, mp->m_errortag needs to free. Otherwise kmemleak would report memory leak after mounting xfs image:
unreferenced object 0xffff888101364900 (size 192):
comm "mount", pid 13099, jiffies 4294915218 (age 335.207s) hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<00000000f08ad25c>] __kmalloc+0x41/0x1b0
[<00000000dca9aeb6>] kmem_alloc+0xfd/0x430
[<0000000040361882>] xfs_errortag_init+0x20/0x110
[<00000000b384a0f6>] xfs_mountfs+0x6ea/0x1a30
[<000000003774395d>] xfs_fs_fill_super+0xe10/0x1a80
[<000000009cf07b6c>] get_tree_bdev+0x3e7/0x700
[<00000000046b5426>] vfs_get_tree+0x8e/0x2e0
[<00000000952ec082>] path_mount+0xf8c/0x1990
[<00000000beb1f838>] do_mount+0xee/0x110
[<000000000e9c41bb>] __x64_sys_mount+0x14b/0x1f0
[<00000000f7bb938e>] do_syscall_64+0x3b/0x90
[<000000003fcd67a9>] entry_SYSCALL_64_after_hwframe+0x63/0xcd--- fs/xfs/xfs_error.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
fs/xfs/xfs_error.c +7 -2
@@ -224,13 +224,18 @@ intxfs_errortag_init ( struct xfs_mount *mp) { +int ret; + mp->m_errortag =kmem_zalloc (sizeof (unsigned int ) *XFS_ERRTAG_MAX ,KM_MAYFAIL );if (!mp->m_errortag)return -ENOMEM ; -return xfs_sysfs_init (&mp->m_errortag_kobj, &xfs_errortag_ktype, - &mp->m_kobj,"errortag" ); + ret =xfs_sysfs_init (&mp->m_errortag_kobj, &xfs_errortag_ktype, + &mp->m_kobj,"errortag" ); +if (ret) +kmem_free (mp->m_errortag); +return ret; }void
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 154/297 xfs: Fix unreferenced object reported by kmemleak in xfs_sysfs_init()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li Zetao <[email protected]>
[ Upstream commit d08af40340cad0e025d643c3982781a8f99d5032 ]
kmemleak reported a sequence of memory leaks, and one of them indicated we failed to free a pointer:
comm "mount", pid 19610, jiffies 4297086464 (age 60.635s)
hex dump (first 8 bytes):
73 64 61 00 81 88 ff ff sda.....
backtrace:
[<00000000d77f3e04>] kstrdup_const+0x46/0x70
[<00000000e51fa804>] kobject_set_name_vargs+0x2f/0xb0
[<00000000247cd595>] kobject_init_and_add+0xb0/0x120
[<00000000f9139aaf>] xfs_mountfs+0x367/0xfc0
[<00000000250d3caf>] xfs_fs_fill_super+0xa16/0xdc0
[<000000008d873d38>] get_tree_bdev+0x256/0x390
[<000000004881f3fa>] vfs_get_tree+0x41/0xf0
[<000000008291ab52>] path_mount+0x9b3/0xdd0
[<0000000022ba8f2d>] __x64_sys_mount+0x190/0x1d0As mentioned in kobject_init_and_add() comment, if this function returns an error, kobject_put() must be called to properly clean up the memory associated with the object. Apparently, xfs_sysfs_init() does not follow such a requirement. When kobject_init_and_add() returns an error, the space of kobj->kobject.name alloced by kstrdup_const() is unfree, which will cause the above stack.
Fix it by adding kobject_put() when kobject_init_and_add returns an error.
--- fs/xfs/xfs_sysfs.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
fs/xfs/xfs_sysfs.h +6 -1
@@ -33,10 +33,15 @@ xfs_sysfs_init( const char *name) {struct kobject *parent; +int err; parent = parent_kobj ? &parent_kobj->kobject :NULL ;init_completion (&kobj->complete); -return kobject_init_and_add (&kobj->kobject, ktype, parent,"%s" , name); + err =kobject_init_and_add (&kobj->kobject, ktype, parent,"%s" , name); +if (err) +kobject_put (&kobj->kobject); + +return err; } static inline void
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 155/297 i915/perf: Fix NULL deref bugs with drm_dbg() calls
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Harshit Mogalapalli <[email protected]>
commit 471aa951bf1206d3c10d0daa67005b8e4db4ff83 upstream.
When i915 perf interface is not available dereferencing it will lead to NULL dereferences.
As returning -ENOTSUPP is pretty clear return when perf interface is not available.
--- drivers/gpu/drm/i915/i915_perf.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-)
drivers/gpu/drm/i915/i915_perf.c +3 -12
@@ -3795,11 +3795,8 @@ int i915_perf_open_ioctl(struct drm_deviu32 known_open_flags;int ret; -if (!perf->i915) { -drm_dbg (&perf->i915->drm, -"i915 perf interface not available for this system\n" ); +if (!perf->i915)return -ENOTSUPP ; - } known_open_flags =I915_PERF_FLAG_FD_CLOEXEC | I915_PERF_FLAG_FD_NONBLOCK |
@@ -4090,11 +4087,8 @@ int i915_perf_add_config_ioctl(struct drstruct i915_oa_reg *regs;int err, id; -if (!perf->i915) { -drm_dbg (&perf->i915->drm, -"i915 perf interface not available for this system\n" ); +if (!perf->i915)return -ENOTSUPP ; - }if (!perf->metrics_kobj) { drm_dbg(&perf->i915->drm,
@@ -4256,11 +4250,8 @@ int i915_perf_remove_config_ioctl(structstruct i915_oa_config *oa_config;int ret; -if (!perf->i915) { -drm_dbg (&perf->i915->drm, -"i915 perf interface not available for this system\n" ); +if (!perf->i915)return -ENOTSUPP ; - }if (i915_perf_stream_paranoid && !perfmon_capable ()) { drm_dbg(&perf->i915->drm,
Greg Kroah-Hartman
maintainerPATCH 156/297 media: venus: hfi: add checks to perform sanity on queue pointers
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vikash Garodia <[email protected]>
commit 5e538fce33589da6d7cb2de1445b84d3a8a692f7 upstream.
Read and write pointers are used to track the packet index in the memory shared between video driver and firmware. There is a possibility of OOB access if the read or write pointer goes beyond the queue memory size. Add checks for the read and write pointer to avoid OOB access.
--- drivers/media/platform/qcom/venus/hfi_venus.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/media/platform/qcom/venus/hfi_venus.c +10 -0
@@ -205,6 +205,11 @@ static int venus_write_queue(struct venu new_wr_idx = wr_idx + dwords; wr_ptr = (u32 *)(queue->qmem.kva + (wr_idx <<2 )); + +if (wr_ptr < (u32 *)queue->qmem.kva || + wr_ptr > (u32 *)(queue->qmem.kva + queue->qmem.size -sizeof (*wr_ptr))) +return -EINVAL ; +if (new_wr_idx < qsize) {memcpy (wr_ptr, packet, dwords <<2 ); }else {
@@ -272,6 +277,11 @@ static int venus_read_queue(struct venus } rd_ptr = (u32 *)(queue->qmem.kva + (rd_idx <<2 )); + +if (rd_ptr < (u32 *)queue->qmem.kva || + rd_ptr > (u32 *)(queue->qmem.kva + queue->qmem.size -sizeof (*rd_ptr))) +return -EINVAL ; + dwords = *rd_ptr >>2 ;if (!dwords)return -EINVAL ;
Greg Kroah-Hartman
maintainerPATCH 157/297 powerpc/perf: Fix disabling BHRB and instruction sampling
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicholas Piggin <[email protected]>
commit ea142e590aec55ba40c5affb4d49e68c713c63dc upstream.
When the PMU is disabled, MMCRA is not updated to disable BHRB and instruction sampling. This can lead to those features remaining enabled, which can slow down a real or emulated CPU.
--- arch/powerpc/perf/core-book3s.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
arch/powerpc/perf/core-book3s.c +2 -3
@@ -1342,8 +1342,7 @@ static void power_pmu_disable(struct pmu/* * Disable instruction sampling if it was enabled */ -if (cpuhw->mmcr.mmcra &MMCRA_SAMPLE_ENABLE ) - val &= ~MMCRA_SAMPLE_ENABLE ; + val &= ~MMCRA_SAMPLE_ENABLE ;/* Disable BHRB via mmcra (BHRBRD) for p10 */ if (ppmu->flags &PPMU_ARCH_31 )
@@ -1354,7 +1353,7 @@ static void power_pmu_disable(struct pmu* instruction sampling or BHRB. */ if (val != mmcra) { -mtspr (SPRN_MMCRA , mmcra); +mtspr (SPRN_MMCRA , val);mb ();isync (); }
Greg Kroah-Hartman
maintainerPATCH 158/297 randstruct: Fix gcc-plugin performance mode to stay in group
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kees Cook <[email protected]>
commit 381fdb73d1e2a48244de7260550e453d1003bb8e upstream.
The performance mode of the gcc-plugin randstruct was shuffling struct members outside of the cache-line groups. Limit the range to the specified group indexes.
--- scripts/gcc-plugins/randomize_layout_plugin.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
scripts/gcc-plugins/randomize_layout_plugin.c +8 -3
@@ -209,12 +209,14 @@ static void partition_struct(tree *fieldstatic void performance_shuffle (tree *newtree,unsigned long length,ranctx *prng_state) { -unsigned long i, x; +unsigned long i, x, index;struct partition_group size_group[length];unsigned long num_groups =0 ;unsigned long randnum;partition_struct (newtree, length, (struct partition_group *)&size_group, &num_groups); + +/* FIXME: this group shuffle is currently a no-op. */ for (i = num_groups -1 ; i >0 ; i--) {struct partition_group tmp; randnum =ranval (prng_state) % (i +1 );
@@ -224,11 +226,14 @@ static void performance_shuffle(tree *ne }for (x =0 ; x < num_groups; x++) { -for (i = size_group[x].start + size_group[x].length -1 ; i > size_group[x].start; i--) { +for (index = size_group[x].length -1 ; index >0 ; index--) {tree tmp; + + i = size_group[x].start + index;if (DECL_BIT_FIELD_TYPE (newtree[i]))continue ; - randnum =ranval (prng_state) % (i +1 ); + randnum =ranval (prng_state) % (index +1 ); + randnum += size_group[x].start;// we could handle this case differently if desired if (DECL_BIT_FIELD_TYPE (newtree[randnum]))continue ;
Greg Kroah-Hartman
maintainerPATCH 159/297 bpf: Fix check_stack_write_fixed_off() to correctly spill imm
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hao Sun <[email protected]>
commit 811c363645b33e6e22658634329e95f383dfc705 upstream.
In check_stack_write_fixed_off(), imm value is cast to u32 before being spilled to the stack. Therefore, the sign information is lost, and the range information is incorrect when load from the stack again.
For the following prog:
0: r2 = r10
1: *(u64*)(r2 -40) = -44
2: r0 = *(u64*)(r2 - 40)
3: if r0 s<= 0xa goto +2
4: r0 = 1
5: exit
6: r0 = 0
7: exit
The verifier gives:
func#0 @0
0: R1=ctx(off=0,imm=0) R10=fp0
0: (bf) r2 = r10 ; R2_w=fp0 R10=fp0 1: (7a) *(u64 *)(r2 -40) = -44 ; R2_w=fp0 fp-40_w=4294967252 2: (79) r0 = *(u64 *)(r2 -40) ; R0_w=4294967252 R2_w=fp0
fp-40_w=4294967252
3: (c5) if r0 s< 0xa goto pc+2mark_precise: frame0: last_idx 3 first_idx 0 subseq_idx -1mark_precise: frame0: regs=r0 stack= before 2: (79) r0 = *(u64 *)(r2 -40) 3: R0_w=4294967252
4: (b7) r0 = 1 ; R0_w=1
5: (95) exit
verification time 7971 usec
stack depth 40
processed 6 insns (limit 1000000) max_states_per_insn 0 total_states 0 peak_states 0 mark_read 0
So remove the incorrect cast, since imm field is declared as s32, and __mark_reg_known() takes u64, so imm would be correctly sign extended by compiler.
--- kernel/bpf/verifier.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/bpf/verifier.c +1 -1
@@ -2885,7 +2885,7 @@ static int check_stack_write_fixed_off(s insn->imm != 0 && env->bpf_capable) {struct bpf_reg_state fake_reg = {}; -__mark_reg_known (&fake_reg, (u32 )insn->imm); +__mark_reg_known (&fake_reg, insn->imm); fake_reg.type =SCALAR_VALUE ;save_register_state (state, spi, &fake_reg, size); } else if (reg && is_spillable_regtype(reg->type)) {
Greg Kroah-Hartman
maintainerPATCH 160/297 bpf: Fix precision tracking for BPF_ALU | BPF_TO_BE | BPF_END
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shung-Hsi Yu <[email protected]>
commit 291d044fd51f8484066300ee42afecf8c8db7b3a upstream.
BPF_END and BPF_NEG has a different specification for the source bit in the opcode compared to other ALU/ALU64 instructions, and is either reserved or use to specify the byte swap endianness. In both cases the source bit does not encode source operand location, and src_reg is a reserved field.
backtrack_insn() currently does not differentiate BPF_END and BPF_NEG from other ALU/ALU64 instructions, which leads to r0 being incorrectly marked as precise when processing BPF_ALU | BPF_TO_BE | BPF_END instructions. This commit teaches backtrack_insn() to correctly mark precision for such case.
While precise tracking of BPF_NEG and other BPF_END instructions are correct and does not need fixing, this commit opt to process all BPF_NEG and BPF_END instructions within the same if-clause to better align with current convention used in the verifier (e.g. check_alu_op).
--- kernel/bpf/verifier.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
kernel/bpf/verifier.c +6 -1
@@ -2189,7 +2189,12 @@ static int backtrack_insn(struct bpf_verif (class ==BPF_ALU || class ==BPF_ALU64 ) {if (!(*reg_mask & dreg))return 0 ; -if (opcode ==BPF_MOV ) { +if (opcode ==BPF_END || opcode ==BPF_NEG ) { +/* sreg is reserved and unused +* dreg still need precision before this insn +*/ +return 0 ; + }else if (opcode ==BPF_MOV ) {if (BPF_SRC (insn->code) ==BPF_X ) {/* dreg = sreg * dreg needs precision after this insn
Greg Kroah-Hartman
maintainerPATCH 161/297 scsi: mpt3sas: Fix loop logic
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ranjan Kumar <[email protected]>
commit 3c978492c333f0c08248a8d51cecbe5eb5f617c9 upstream.
The retry loop continues to iterate until the count reaches 30, even after receiving the correct value. Exit loop when a non-zero value is read.
--- drivers/scsi/mpt3sas/mpt3sas_base.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/mpt3sas/mpt3sas_base.c +2 -2
@@ -224,8 +224,8 @@ _base_readl_ext_retry(const volatile voifor (i =0 ; i <30 ; i++) { ret_val =readl (addr); -if (ret_val ==0 ) -continue ; +if (ret_val !=0 ) +break ; }return ret_val;
Greg Kroah-Hartman
maintainerPATCH 162/297 scsi: megaraid_sas: Increase register read retry rount from 3 to 30 for selected registers
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandrakanth patil <[email protected]>
commit 8e3ed9e786511ad800c33605ed904b9de49323cf upstream.
In BMC environments with concurrent access to multiple registers, certain registers occasionally yield a value of 0 even after 3 retries due to hardware errata. As a fix, we have extended the retry count from 3 to 30.
The same errata applies to the mpt3sas driver, and a similar patch has been accepted. Please find more details in the mpt3sas patch reference link.
--- drivers/scsi/megaraid/megaraid_sas_base.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/megaraid/megaraid_sas_base.c +2 -2
@@ -263,13 +263,13 @@ u32 megasas_readl(struct megasas_instanc* Fusion registers could intermittently return all zeroes. * This behavior is transient in nature and subsequent reads will * return valid value. As a workaround in driver, retry readl for -* upto three times until a non-zero value is read. +* up to thirty times until a non-zero value is read. */ if (instance->adapter_type ==AERO_SERIES ) {do { ret_val =readl (addr); i++; - }while (ret_val ==0 && i <3 ); + }while (ret_val ==0 && i <30 );return ret_val; }else {return readl (addr);
Greg Kroah-Hartman
maintainerPATCH 163/297 scsi: qla2xxx: Fix system crash due to bad pointer access
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Quinn Tran <[email protected]>
commit 19597cad64d608aa8ac2f8aef50a50187a565223 upstream.
User experiences system crash when running AER error injection. The perturbation causes the abort-all-I/O path to trigger. The driver assumes all I/O on this path is FCP only. If there is both NVMe & FCP traffic, a system crash happens. Add additional check to see if I/O is FCP or not before access.
PID: 999019 TASK: ff35d769f24722c0 CPU: 53 COMMAND: "kworker/53:1"
0 [ff3f78b964847b58] machine_kexec at ffffffffae86973d
1 [ff3f78b964847ba8] __crash_kexec at ffffffffae9be29d
2 [ff3f78b964847c70] crash_kexec at ffffffffae9bf528
3 [ff3f78b964847c78] oops_end at ffffffffae8282ab
4 [ff3f78b964847c98] exc_page_fault at ffffffffaf2da502
5 [ff3f78b964847cc0] asm_exc_page_fault at ffffffffaf400b62
[exception RIP: qla2x00_abort_srb+444]
RIP: ffffffffc07b5f8c RSP: ff3f78b964847d78 RFLAGS: 00010046 RAX: 0000000000000282 RBX: ff35d74a0195a200 RCX: ff35d76886fd03a0 RDX: 0000000000000001 RSI: ffffffffc07c5ec8 RDI: ff35d74a0195a200 RBP: ff35d76913d22080 R8: ff35d7694d103200 R9: ff35d7694d103200 R10: 0000000100000000 R11: ffffffffb05d6630 R12: 0000000000010000 R13: ff3f78b964847df8 R14: ff35d768d8754000 R15: ff35d768877248e0 ORIG_RAX: ffffffffffffffff CS: 0010 SS: 0018 6 [ff3f78b964847d70] qla2x00_abort_srb at ffffffffc07b5f84 [qla2xxx] 7 [ff3f78b964847de0] __qla2x00_abort_all_cmds at ffffffffc07b6238 [qla2xxx] 8 [ff3f78b964847e38] qla2x00_abort_all_cmds at ffffffffc07ba635 [qla2xxx] 9 [ff3f78b964847e58] qla2x00_terminate_rport_io at ffffffffc08145eb [qla2xxx]
10 [ff3f78b964847e70] fc_terminate_rport_io at ffffffffc045987e [scsi_transport_fc] 11 [ff3f78b964847e88] process_one_work at ffffffffae914f15
12 [ff3f78b964847ed0] worker_thread at ffffffffae9154c0
13 [ff3f78b964847f10] kthread at ffffffffae91c456
14 [ff3f78b964847f50] ret_from_fork at ffffffffae8036ef
--- drivers/scsi/qla2xxx/qla_os.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/scsi/qla2xxx/qla_os.c +10 -2
@@ -1823,8 +1823,16 @@ static void qla2x00_abort_srb(struct qla }spin_lock_irqsave (qp->qp_lock_ptr, *flags); -if (ret_cmd &&blk_mq_request_started (scsi_cmd_to_rq (cmd))) - sp->done (sp, res); +switch (sp->type) { +case SRB_SCSI_CMD : +if (ret_cmd &&blk_mq_request_started (scsi_cmd_to_rq (cmd))) + sp->done (sp, res); +break ; +default : +if (ret_cmd) + sp->done (sp, res); +break ; + } }else { sp->done (sp, res); }
Greg Kroah-Hartman
maintainerPATCH 164/297 crypto: x86/sha - load modules based on CPU features
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Roxana Nicolescu <[email protected]>
commit 1c43c0f1f84aa59dfc98ce66f0a67b2922aa7f9d upstream.
x86 optimized crypto modules are built as modules rather than build-in and they are not loaded when the crypto API is initialized, resulting in the generic builtin module (sha1-generic) being used instead.
It was discovered when creating a sha1/sha256 checksum of a 2Gb file by using kcapi-tools because it would take significantly longer than creating a sha512 checksum of the same file. trace-cmd showed that for sha1/256 the generic module was used, whereas for sha512 the optimized module was used instead.
Add module aliases() for these x86 optimized crypto modules based on CPU feature bits so udev gets a chance to load them later in the boot process. This resulted in ~3x decrease in the real-time execution of kcapi-dsg.
Fix is inspired from commitaa031b8f702e ("crypto: x86/sha512 - load based on CPU features") where a similar fix was done for sha512.
--- arch/x86/crypto/sha1_ssse3_glue.c | 12 ++++++++++++ arch/x86/crypto/sha256_ssse3_glue.c | 12 ++++++++++++ 2 files changed, 24 insertions(+)
arch/x86/crypto/sha1_ssse3_glue.c +12 -0
@@ -24,8 +24,17 @@#include <linux/types.h> #include <crypto/sha1.h> #include <crypto/sha1_base.h> +#include <asm/cpu_device_id.h> #include <asm/simd.h> +static const struct x86_cpu_id module_cpu_ids[] = { +X86_MATCH_FEATURE (X86_FEATURE_AVX2 ,NULL ), +X86_MATCH_FEATURE (X86_FEATURE_AVX ,NULL ), +X86_MATCH_FEATURE (X86_FEATURE_SSSE3 ,NULL ), + {} +}; +MODULE_DEVICE_TABLE (x86cpu, module_cpu_ids); +static int sha1_update (struct shash_desc *desc,const u8 *data,unsigned int len,sha1_block_fn *sha1_xform) {
@@ -301,6 +310,9 @@ static inline void unregister_sha1_ni(void) { }static int __init sha1_ssse3_mod_init (void ) { +if (!x86_match_cpu (module_cpu_ids)) +return -ENODEV ; +if (register_sha1_ssse3 ()) goto fail;
arch/x86/crypto/sha256_ssse3_glue.c +12 -0
@@ -38,11 +38,20 @@#include <crypto/sha2.h> #include <crypto/sha256_base.h> #include <linux/string.h> +#include <asm/cpu_device_id.h> #include <asm/simd.h> asmlinkage void sha256_transform_ssse3(struct sha256_state *state,const u8 *data,int blocks); +static const struct x86_cpu_id module_cpu_ids[] = { +X86_MATCH_FEATURE (X86_FEATURE_AVX2 ,NULL ), +X86_MATCH_FEATURE (X86_FEATURE_AVX ,NULL ), +X86_MATCH_FEATURE (X86_FEATURE_SSSE3 ,NULL ), + {} +}; +MODULE_DEVICE_TABLE (x86cpu, module_cpu_ids); +static int _sha256_update (struct shash_desc *desc,const u8 *data,unsigned int len,sha256_block_fn *sha256_xform) {
@@ -366,6 +375,9 @@ static inline void unregister_sha256_ni(void) { }static int __init sha256_ssse3_mod_init (void ) { +if (!x86_match_cpu (module_cpu_ids)) +return -ENODEV ; +if (register_sha256_ssse3 ()) goto fail;
Signature · 1 line
2.42.1
Greg Kroah-Hartman
maintainerPATCH 165/297 x86/cpu/hygon: Fix the CPU topology evaluation for real
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pu Wen <[email protected]>
commit ee545b94d39a00c93dc98b1dbcbcf731d2eadeb4 upstream.
Hygon processors with a model ID > 3 have CPUID leaf 0xB correctly populated and don't need the fixed package ID shift workaround. The fixup is also incorrect when running in a guest.
--- arch/x86/kernel/cpu/hygon.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
arch/x86/kernel/cpu/hygon.c +6 -2
@@ -86,8 +86,12 @@ static void hygon_get_topology(struct cpif (!err) c->x86_coreid_bits =get_count_order (c->x86_max_cores); -/* Socket ID is ApicId[6] for these processors. */ - c->phys_proc_id = c->apicid >>APICID_SOCKET_ID_BIT ; +/* +* Socket ID is ApicId[6] for the processors with model <= 0x3 +* when running on host. +*/ +if (!boot_cpu_has (X86_FEATURE_HYPERVISOR ) && c->x86_model <=0x3 ) + c->phys_proc_id = c->apicid >>APICID_SOCKET_ID_BIT ;cacheinfo_hygon_init_llc_id (c, cpu); }else if (cpu_has (c,X86_FEATURE_NODEID_MSR )) {
Greg Kroah-Hartman
maintainerPATCH 166/297 KVM: x86: hyper-v: Dont auto-enable stimer on write from user-space
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolas Saenz Julienne <[email protected]>
commit d6800af51c76b6dae20e6023bbdc9b3da3ab5121 upstream.
Don't apply the stimer's counter side effects when modifying its value from user-space, as this may trigger spurious interrupts.
For example:
- The stimer is configured in auto-enable mode.
- The stimer's count is set and the timer enabled.
- The stimer expires, an interrupt is injected.
- The VM is live migrated.
- The stimer config and count are deserialized, auto-enable is ON, the stimer is re-enabled.
- The stimer expires right away, and injects an unwarranted interrupt.
--- arch/x86/kvm/hyperv.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
arch/x86/kvm/hyperv.c +6 -4
@@ -701,10 +701,12 @@ static int stimer_set_count(struct kvm_vstimer_cleanup (stimer); stimer->count = count; -if (stimer->count ==0 ) - stimer->config.enable =0 ; -else if (stimer->config.auto_enable) - stimer->config.enable =1 ; +if (!host) { +if (stimer->count ==0 ) + stimer->config.enable =0 ; +else if (stimer->config.auto_enable) + stimer->config.enable =1 ; + }if (stimer->config.enable)stimer_mark_pending (stimer, false);
Greg Kroah-Hartman
maintainerPATCH 167/297 KVM: x86: Ignore MSR_AMD64_TW_CFG access
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maciej S. Szmigiero <[email protected]>
commit 2770d4722036d6bd24bcb78e9cd7f6e572077d03 upstream.
Hyper-V enabled Windows Server 2022 KVM VM cannot be started on Zen1 Ryzen since it crashes at boot with SYSTEM_THREAD_EXCEPTION_NOT_HANDLED + STATUS_PRIVILEGED_INSTRUCTION (in other words, because of an unexpected #GP in the guest kernel).
This is because Windows tries to set bit 8 in MSR_AMD64_TW_CFG and can't handle receiving a #GP when doing so.
Give this MSR the same treatment that commit 2e32b7190641 ("x86, kvm: Add MSR_AMD64_BU_CFG2 to the list of ignored MSRs") gave MSR_AMD64_BU_CFG2 under justification that this MSR is baremetal-relevant only.
Although apparently it was then needed for Linux guests, not Windows as in this case.
With this change, the aforementioned guest setup is able to finish booting successfully.
This issue can be reproduced either on a Summit Ridge Ryzen (with just "-cpu host") or on a Naples EPYC (with "-cpu host,stepping=1" since EPYC is ordinarily stepping 2).
Alternatively, userspace could solve the problem by using MSR filters, but forcing every userspace to define a filter isn't very friendly and doesn't add much, if any, value. The only potential hiccup is if one of these "baremetal-only" MSRs ever requires actual emulation and/or has F/M/S specific behavior. But if that happens, then KVM can still punt *that* handling to userspace since userspace MSR filters "win" over KVM's default handling.
--- arch/x86/include/asm/msr-index.h | 1 + arch/x86/kvm/x86.c | 2 ++ 2 files changed, 3 insertions(+)
arch/x86/include/asm/msr-index.h +1 -0
@@ -511,6 +511,7 @@#define MSR_AMD64_CPUID_FN_1 0xc0011004#define MSR_AMD64_LS_CFG 0xc0011020#define MSR_AMD64_DC_CFG 0xc0011022 +#define MSR_AMD64_TW_CFG 0xc0011023#define MSR_AMD64_DE_CFG 0xc0011029#define MSR_AMD64_DE_CFG_LFENCE_SERIALIZE_BIT 1
arch/x86/kvm/x86.c +2 -0
@@ -3393,6 +3393,7 @@ int kvm_set_msr_common(struct kvm_vcpu *case MSR_AMD64_PATCH_LOADER :case MSR_AMD64_BU_CFG2 :case MSR_AMD64_DC_CFG : +case MSR_AMD64_TW_CFG :case MSR_F15H_EX_CFG :break ;
@@ -3733,6 +3734,7 @@ int kvm_get_msr_common(struct kvm_vcpu *case MSR_AMD64_BU_CFG2 :case MSR_IA32_PERF_CTL :case MSR_AMD64_DC_CFG : +case MSR_AMD64_TW_CFG :case MSR_F15H_EX_CFG :/* * Intel Sandy Bridge CPUs must support the RAPL (running average power
Greg Kroah-Hartman
maintainerPATCH 168/297 audit: dont take task_lock() in audit_exe_compare() code path
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paul Moore <[email protected]>
commit 47846d51348dd62e5231a83be040981b17c955fa upstream.
The get_task_exe_file() function locks the given task with task_lock() which when used inside audit_exe_compare() can cause deadlocks on systems that generate audit records when the task_lock() is held. We resolve this problem with two changes: ignoring those cases where the task being audited is not the current task, and changing our approach to obtaining the executable file struct to not require task_lock().
With the intent of the audit exe filter being to filter on audit events generated by processes started by the specified executable, it makes sense that we would only want to use the exe filter on audit records associated with the currently executing process, e.g. @current. If we are asked to filter records using a non-@current task_struct we can safely ignore the exe filter without negatively impacting the admin's expectations for the exe filter.
Knowing that we only have to worry about filtering the currently executing task in audit_exe_compare() we can do away with the task_lock() and call get_mm_exe_file() with @current->mm directly.
--- kernel/audit_watch.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
kernel/audit_watch.c +8 -1
@@ -527,11 +527,18 @@ int audit_exe_compare(struct task_structunsigned long ino;dev_t dev; - exe_file =get_task_exe_file (tsk); +/* only do exe filtering if we are recording @current events/records */ +if (tsk != current) +return 0 ; + +if (WARN_ON_ONCE (!current->mm)) +return 0 ; + exe_file =get_mm_exe_file (current->mm);if (!exe_file)return 0 ; ino =file_inode (exe_file)->i_ino; dev =file_inode (exe_file)->i_sb->s_dev;fput (exe_file); +return audit_mark_compare (mark, ino, dev); }
Greg Kroah-Hartman
maintainerPATCH 169/297 audit: dont WARN_ON_ONCE(!current->mm) in audit_exe_compare()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paul Moore <[email protected]>
commit 969d90ec212bae4b45bf9d21d7daa30aa6cf055e upstream.
eBPF can end up calling into the audit code from some odd places, and some of these places don't have @current set properly so we end up tripping the WARN_ON_ONCE(!current->mm) near the top of audit_exe_compare(). While the basic !current->mm check is good, the WARN_ON_ONCE() results in some scary console messages so let's drop that and just do the regular !current->mm check to avoid problems.
--- kernel/audit_watch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/audit_watch.c +1 -1
@@ -531,7 +531,7 @@ int audit_exe_compare(struct task_structif (tsk != current)return 0 ; -if (WARN_ON_ONCE (!current->mm)) +if (!current->mm)return 0 ; exe_file =get_mm_exe_file (current->mm);if (!exe_file)
Greg Kroah-Hartman
maintainerPATCH 170/297 tty/sysrq: replace smp_processor_id() with get_cpu()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Muhammad Usama Anjum <[email protected]>
commit dd976a97d15b47656991e185a94ef42a0fa5cfd4 upstream.
The smp_processor_id() shouldn't be called from preemptible code. Instead use get_cpu() and put_cpu() which disables preemption in addition to getting the processor id. Enable preemption back after calling schedule_work() to make sure that the work gets scheduled on all cores other than the current core. We want to avoid a scenario where current core's stack trace is printed multiple times and one core's stack trace isn't printed because of scheduling of current task.
This fixes the following bug:
[ 119.143590] sysrq: Show backtrace of all active CPUs [ 119.143902] BUG: using smp_processor_id() in preemptible [00000000] code: bash/873 [ 119.144586] caller is debug_smp_processor_id+0x20/0x30 [ 119.144827] CPU: 6 PID: 873 Comm: bash Not tainted 5.10.124-dirty #3 [ 119.144861] Hardware name: QEMU QEMU Virtual Machine, BIOS 2023.05-1 07/22/2023 [ 119.145053] Call trace: [ 119.145093] dump_backtrace+0x0/0x1a0 [ 119.145122] show_stack+0x18/0x70 [ 119.145141] dump_stack+0xc4/0x11c [ 119.145159] check_preemption_disabled+0x100/0x110 [ 119.145175] debug_smp_processor_id+0x20/0x30 [ 119.145195] sysrq_handle_showallcpus+0x20/0xc0 [ 119.145211] __handle_sysrq+0x8c/0x1a0 [ 119.145227] write_sysrq_trigger+0x94/0x12c [ 119.145247] proc_reg_write+0xa8/0xe4 [ 119.145266] vfs_write+0xec/0x280 [ 119.145282] ksys_write+0x6c/0x100 [ 119.145298] __arm64_sys_write+0x20/0x30 [ 119.145315] el0_svc_common.constprop.0+0x78/0x1e4 [ 119.145332] do_el0_svc+0x24/0x8c [ 119.145348] el0_svc+0x10/0x20 [ 119.145364] el0_sync_handler+0x134/0x140 [ 119.145381] el0_sync+0x180/0x1c0
--- drivers/tty/sysrq.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/tty/sysrq.c +2 -1
@@ -263,13 +263,14 @@ static void sysrq_handle_showallcpus(intif (in_hardirq ()) regs =get_irq_regs (); -pr_info ("CPU%d:\n" ,smp_processor_id ()); +pr_info ("CPU%d:\n" ,get_cpu ());if (regs)show_regs (regs);else show_stack (NULL ,NULL ,KERN_INFO );schedule_work (&sysrq_showallcpus); +put_cpu (); } }
Greg Kroah-Hartman
maintainerPATCH 171/297 hvc/xen: fix console unplug
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Woodhouse <[email protected]>
commit a30badfd7c13fc8763a9e10c5a12ba7f81515a55 upstream.
On unplug of a Xen console, xencons_disconnect_backend() unconditionally calls free_irq() via unbind_from_irqhandler(), causing a warning of freeing an already-free IRQ:
(qemu) device_del con1
[ 32.050919] ------------[ cut here ]------------ [ 32.050942] Trying to free already-free IRQ 33 [ 32.050990] WARNING: CPU: 0 PID: 51 at kernel/irq/manage.c:1895 __free_irq+0x1d4/0x330
It should be using evtchn_put() to tear down the event channel binding, and let the Linux IRQ side of it be handled by notifier_del_irq() through the HVC code.
On which topic... xencons_disconnect_backend() should call hvc_remove() *first*, rather than tearing down the event channel and grant mapping while they are in use. And then the IRQ is guaranteed to be freed by the time it's torn down by evtchn_put().
Since evtchn_put() also closes the actual event channel, avoid calling xenbus_free_evtchn() except in the failure path where the IRQ was not successfully set up.
However, calling hvc_remove() at the start of xencons_disconnect_backend() still isn't early enough. An unplug request is indicated by the backend setting its state to XenbusStateClosing, which triggers a notification to xencons_backend_changed(), which... does nothing except set its own frontend state directly to XenbusStateClosed without *actually* tearing down the HVC device or, you know, making sure it isn't actively in use.
So the backend sees the guest frontend set its state to XenbusStateClosed and stops servicing the interrupt... and the guest spins for ever in the domU_write_console() function waiting for the ring to drain.
Fix that one by calling hvc_remove() from xencons_backend_changed() before signalling to the backend that it's OK to proceed with the removal.
Tested with 'dd if=/dev/zero of=/dev/hvc1' while telling Qemu to remove the console device.
--- drivers/tty/hvc/hvc_xen.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-)
drivers/tty/hvc/hvc_xen.c +24 -8
@@ -377,18 +377,21 @@ void xen_console_resume(void)#ifdef CONFIG_HVC_XEN_FRONTEND static void xencons_disconnect_backend (struct xencons_info *info) { -if (info->irq >0 ) -unbind_from_irqhandler (info->irq,NULL ); - info->irq =0 ; +if (info->hvc !=NULL ) +hvc_remove (info->hvc); + info->hvc =NULL ; +if (info->irq >0 ) { +evtchn_put (info->evtchn); + info->irq =0 ; + info->evtchn =0 ; + } +/* evtchn_put() will also close it so this is only an error path */ if (info->evtchn >0 )xenbus_free_evtchn (info->xbdev, info->evtchn); info->evtchn =0 ;if (info->gntref >0 )gnttab_free_grant_references (info->gntref); info->gntref =0 ; -if (info->hvc !=NULL ) -hvc_remove (info->hvc); - info->hvc =NULL ; }static void xencons_free (struct xencons_info *info)
@@ -553,10 +556,23 @@ static void xencons_backend_changed(struif (dev->state == XenbusStateClosed)break ; fallthrough;/* Missed the backend's CLOSING state */ -case XenbusStateClosing: +case XenbusStateClosing: { +struct xencons_info *info =dev_get_drvdata (&dev->dev);; + +/* +* Don't tear down the evtchn and grant ref before the other +* end has disconnected, but do stop userspace from trying +* to use the device before we allow the backend to close. +*/ +if (info->hvc) { +hvc_remove (info->hvc); + info->hvc =NULL ; + } +xenbus_frontend_closed (dev);break ; } + } }static const struct xenbus_device_id xencons_ids[] = {
@@ -615,7 +631,7 @@ static int __init xen_hvc_init(void)list_del (&info->list);spin_unlock_irqrestore (&xencons_lock, flags);if (info->irq) -unbind_from_irqhandler (info->irq,NULL ); +evtchn_put (info->evtchn);kfree (info);return r; }
Greg Kroah-Hartman
maintainerPATCH 172/297 hvc/xen: fix error path in xen_hvc_init() to always register frontend driver
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Woodhouse <[email protected]>
commit 2704c9a5593f4a47620c12dad78838ca62b52f48 upstream.
The xen_hvc_init() function should always register the frontend driver, even when there's no primary console — as there may be secondary consoles. (Qemu can always add secondary consoles, but only the toolstack can add the primary because it's special.)
--- drivers/tty/hvc/hvc_xen.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/tty/hvc/hvc_xen.c +3 -2
@@ -603,7 +603,7 @@ static int __init xen_hvc_init(void) ops = &dom0_hvc_ops; r =xen_initial_domain_console_init ();if (r <0 ) -return r; + goto register_fe; info =vtermno_to_xencons (HVC_COOKIE ); }else { ops = &domU_hvc_ops;
@@ -612,7 +612,7 @@ static int __init xen_hvc_init(void)else r =xen_pv_console_init ();if (r <0 ) -return r; + goto register_fe; info =vtermno_to_xencons (HVC_COOKIE ); info->irq =bind_evtchn_to_irq_lateeoi (info->evtchn);
@@ -637,6 +637,7 @@ static int __init xen_hvc_init(void) } r =0 ; + register_fe: #ifdef CONFIG_HVC_XEN_FRONTEND r =xenbus_register_frontend (&xencons_driver);#endif
Greg Kroah-Hartman
maintainerPATCH 173/297 hvc/xen: fix event channel handling for secondary consoles
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Woodhouse <[email protected]>
commit ef5dd8ec88ac11e8e353164407d55b73c988b369 upstream.
The xencons_connect_backend() function allocates a local interdomain event channel with xenbus_alloc_evtchn(), then calls bind_interdomain_evtchn_to_irq_lateeoi() to bind to that port# on the *remote* domain.
That doesn't work very well:
(qemu) device_add xen-console,id=con1,chardev=pty0
[ 44.323872] xenconsole console-1: 2 xenbus_dev_probe on device/console/1 [ 44.323995] xenconsole: probe of console-1 failed with error -2
Fix it to use bind_evtchn_to_irq_lateeoi(), which does the right thing by just binding that *local* event channel to an irq. The backend will do the interdomain binding.
This didn't affect the primary console because the setup for that is special — the toolstack allocates the guest event channel and the guest discovers it with HVMOP_get_param.
--- drivers/tty/hvc/hvc_xen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/hvc/hvc_xen.c +1 -1
@@ -436,7 +436,7 @@ static int xencons_connect_backend(strucif (ret)return ret; info->evtchn = evtchn; - irq =bind_interdomain_evtchn_to_irq_lateeoi (dev, evtchn); + irq =bind_evtchn_to_irq_lateeoi (evtchn);if (irq <0 )return irq; info->irq = irq;
Greg Kroah-Hartman
maintainerPATCH 174/297 PCI/sysfs: Protect drivers D3cold preference from user space
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lukas Wunner <[email protected]>
commit 70b70a4307cccebe91388337b1c85735ce4de6ff upstream.
struct pci_dev contains two flags which govern whether the device may suspend to D3cold:
* no_d3cold provides an opt-out for drivers (e.g. if a device is known to not wake from D3cold)
* d3cold_allowed provides an opt-out for user space (default is true, user space may set to false)
Since commit 9d26d3a8f1b0 ("PCI: Put PCIe ports into D3 during suspend"), the user space setting overwrites the driver setting. Essentially user space is trusted to know better than the driver whether D3cold is working.
That feels unsafe and wrong. Assume that the change was introduced inadvertently and do not overwrite no_d3cold when d3cold_allowed is modified. Instead, consider d3cold_allowed in addition to no_d3cold when choosing a suspend state for the device.
That way, user space may opt out of D3cold if the driver hasn't, but it may no longer force an opt in if the driver has opted out.
--- drivers/pci/pci-acpi.c | 2 +- drivers/pci/pci-sysfs.c | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-)
drivers/pci/pci-acpi.c +1 -1
@@ -910,7 +910,7 @@ static pci_power_t acpi_pci_choose_state {int acpi_state, d_max; -if (pdev->no_d3cold) +if (pdev->no_d3cold || !pdev->d3cold_allowed) d_max =ACPI_STATE_D3_HOT ;else d_max =ACPI_STATE_D3_COLD ;
drivers/pci/pci-sysfs.c +1 -4
@@ -508,10 +508,7 @@ static ssize_t d3cold_allowed_store(strureturn -EINVAL ; pdev->d3cold_allowed = !!val; -if (pdev->d3cold_allowed) -pci_d3cold_enable (pdev); -else -pci_d3cold_disable (pdev); +pci_bridge_d3_update (pdev);pm_runtime_resume (dev);
Greg Kroah-Hartman
maintainerPATCH 175/297 watchdog: move softlockup_panic back to early_param
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krister Johansen <[email protected]>
commit 8b793bcda61f6c3ed4f5b2ded7530ef6749580cb upstream.
Setting softlockup_panic from do_sysctl_args() causes it to take effect later in boot. The lockup detector is enabled before SMP is brought online, but do_sysctl_args runs afterwards. If a user wants to set softlockup_panic on boot and have it trigger should a softlockup occur during onlining of the non-boot processors, they could do this prior to commit f117955a2255 ("kernel/watchdog.c: convert {soft/hard}lockup boot parameters to sysctl aliases"). However, after this commit the value of softlockup_panic is set too late to be of help for this type of problem. Restore the prior behavior.
--- fs/proc/proc_sysctl.c | 1 - kernel/watchdog.c | 7 +++++++ 2 files changed, 7 insertions(+), 1 deletion(-)
fs/proc/proc_sysctl.c +0 -1
@@ -1765,7 +1765,6 @@ static const struct sysctl_alias sysctl_ {"hung_task_panic", "kernel.hung_task_panic" }, {"numa_zonelist_order", "vm.numa_zonelist_order" }, {"softlockup_all_cpu_backtrace", "kernel.softlockup_all_cpu_backtrace" }, - {"softlockup_panic", "kernel.softlockup_panic" }, { } };
kernel/watchdog.c +7 -0
@@ -183,6 +183,13 @@ static DEFINE_PER_CPU(unsigned long, hrt static DEFINE_PER_CPU(unsigned long, hrtimer_interrupts_saved);static unsigned long soft_lockup_nmi_warn; +static int __init softlockup_panic_setup (char *str) +{ + softlockup_panic =simple_strtoul (str,NULL ,0 ); +return 1 ; +} +__setup ("softlockup_panic=" , softlockup_panic_setup); +static int __init nowatchdog_setup (char *str) { watchdog_user_enabled =0 ;
Greg Kroah-Hartman
maintainerPATCH 176/297 ACPI: resource: Do IRQ override on TongFang GMxXGxx
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Werner Sembach <[email protected]>
commit 0da9eccde3270b832c059ad618bf66e510c75d33 upstream.
The TongFang GMxXGxx/TUXEDO Stellaris/Pollaris Gen5 needs IRQ overriding for the keyboard to work.
Adding an entry for this laptop to the override_table makes the internal keyboard functional.
--- drivers/acpi/resource.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/acpi/resource.c +12 -0
@@ -468,6 +468,18 @@ static const struct dmi_system_id mainge } }, { +/* TongFang GMxXGxx/TUXEDO Polaris 15 Gen5 AMD */ + .matches = { + DMI_MATCH(DMI_BOARD_NAME, "GMxXGxx"), + }, + }, + { +/* TongFang GM6XGxX/TUXEDO Stellaris 16 Gen5 AMD */ + .matches = { + DMI_MATCH(DMI_BOARD_NAME, "GM6XGxX"), + }, + }, + { .ident = "MAINGEAR Vector Pro 2 17", .matches = { DMI_MATCH(DMI_SYS_VENDOR, "Micro Electronics Inc"),
Greg Kroah-Hartman
maintainerPATCH 177/297 arm64: Restrict CPU_BIG_ENDIAN to GNU as or LLVM IAS 15.x or newer
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nathan Chancellor <[email protected]>
commit 146a15b873353f8ac28dc281c139ff611a3c4848 upstream.
Prior to LLVM 15.0.0, LLVM's integrated assembler would incorrectly byte-swap NOP when compiling for big-endian, and the resulting series of bytes happened to match the encoding of FNMADD S21, S30, S0, S0.
This went unnoticed until commit:
34f66c4c4d5518c1 ("arm64: Use a positive cpucap for FP/SIMD")
Prior to that commit, the kernel would always enable the use of FPSIMD early in boot when __cpu_setup() initialized CPACR_EL1, and so usage of FNMADD within the kernel was not detected, but could result in the corruption of user or kernel FPSIMD state.
After that commit, the instructions happen to trap during boot prior to FPSIMD being detected and enabled, e.g.
| Unhandled 64-bit el1h sync exception on CPU0, ESR 0x000000001fe00000 -- ASIMD | CPU: 0 PID: 0 Comm: swapper Not tainted 6.6.0-rc3-00013-g34f66c4c4d55 #1 | Hardware name: linux,dummy-virt (DT) | pstate: 400000c9 (nZcv daIF -PAN -UAO -TCO -DIT -SSBS BTYPE=--) | pc : __pi_strcmp+0x1c/0x150 | lr : populate_properties+0xe4/0x254 | sp : ffffd014173d3ad0 | x29: ffffd014173d3af0 x28: fffffbfffddffcb8 x27: 0000000000000000 | x26: 0000000000000058 x25: fffffbfffddfe054 x24: 0000000000000008 | x23: fffffbfffddfe000 x22: fffffbfffddfe000 x21: fffffbfffddfe044 | x20: ffffd014173d3b70 x19: 0000000000000001 x18: 0000000000000005 | x17: 0000000000000010 x16: 0000000000000000 x15: 00000000413e7000 | x14: 0000000000000000 x13: 0000000000001bcc x12: 0000000000000000 | x11: 00000000d00dfeed x10: ffffd414193f2cd0 x9 : 0000000000000000 | x8 : 0101010101010101 x7 : ffffffffffffffc0 x6 : 0000000000000000 | x5 : 0000000000000000 x4 : 0101010101010101 x3 : 000000000000002a | x2 : 0000000000000001 x1 : ffffd014171f2988 x0 : fffffbfffddffcb8 | Kernel panic - not syncing: Unhandled exception | CPU: 0 PID: 0 Comm: swapper Not tainted 6.6.0-rc3-00013-g34f66c4c4d55 #1 | Hardware name: linux,dummy-virt (DT) | Call trace: | dump_backtrace+0xec/0x108 | show_stack+0x18/0x2c | dump_stack_lvl+0x50/0x68 | dump_stack+0x18/0x24 | panic+0x13c/0x340 | el1t_64_irq_handler+0x0/0x1c | el1_abort+0x0/0x5c | el1h_64_sync+0x64/0x68 | __pi_strcmp+0x1c/0x150 | unflatten_dt_nodes+0x1e8/0x2d8 | __unflatten_device_tree+0x5c/0x15c | unflatten_device_tree+0x38/0x50 | setup_arch+0x164/0x1e0 | start_kernel+0x64/0x38c | __primary_switched+0xbc/0xc4
Restrict CONFIG_CPU_BIG_ENDIAN to a known good assembler, which is either GNU as or LLVM's IAS 15.0.0 and newer, which contains the linked commit.
--- arch/arm64/Kconfig | 2 ++ 1 file changed, 2 insertions(+)
arch/arm64/Kconfig +2 -0
@@ -1153,6 +1153,8 @@ choice config CPU_BIG_ENDIAN bool "Build big-endian kernel" depends on !LD_IS_LLD || LLD_VERSION >= 130000 + # https://github.com/llvm/llvm-project/commit/1379b150991f70a5782e9a143c2ba5308da1161c + depends on AS_IS_GNU || AS_VERSION >= 150000 help Say Y if you plan on running a kernel with a big-endian userspace.
Greg Kroah-Hartman
maintainerPATCH 178/297 parisc/pdc: Add width field to struct pdc_model
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Helge Deller <[email protected]>
commit 6240553b52c475d9fc9674de0521b77e692f3764 upstream.
PDC2.0 specifies the additional PSW-bit field.
--- arch/parisc/include/uapi/asm/pdc.h | 1 + 1 file changed, 1 insertion(+)
arch/parisc/include/uapi/asm/pdc.h +1 -0
@@ -465,6 +465,7 @@ struct pdc_model { /* for PDC_MODEL */unsigned long arch_rev;unsigned long pot_key;unsigned long curr_key; +unsigned long width;/* default of PSW_W bit (1=enabled) */ };struct pdc_cache_cf {/* for PDC_CACHE (I/D-caches) */
Greg Kroah-Hartman
maintainerPATCH 179/297 parisc/power: Add power soft-off when running on qemu
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Helge Deller <[email protected]>
commit d0c219472980d15f5cbc5c8aec736848bda3f235 upstream.
--- drivers/parisc/power.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
drivers/parisc/power.c +15 -1
@@ -197,6 +197,14 @@ static struct notifier_block parisc_pani .priority = INT_MAX, }; +/* qemu soft power-off function */ +static int qemu_power_off (struct sys_off_data *data) +{ +/* this turns the system off via SeaBIOS */ + *(int *)data->cb_data =0 ; +pdc_soft_power_button (1 ); +return NOTIFY_DONE ; +}static int __init power_init (void ) {
@@ -226,7 +234,13 @@ static int __init power_init(void) soft_power_reg); } - power_task =kthread_run (kpowerswd, (void *)soft_power_reg,KTHREAD_NAME ); + power_task =NULL ; +if (running_on_qemu && soft_power_reg) +register_sys_off_handler (SYS_OFF_MODE_POWER_OFF ,SYS_OFF_PRIO_DEFAULT , + qemu_power_off, (void *)soft_power_reg); +else + power_task =kthread_run (kpowerswd, (void *)soft_power_reg, +KTHREAD_NAME );if (IS_ERR (power_task)) { printk(KERN_ERR DRIVER_NAME ": thread creation failed. Driver not loaded.\n");pdc_soft_power_button (0 );
Greg Kroah-Hartman
maintainerPATCH 180/297 clk: socfpga: Fix undefined behavior bug in struct stratix10_clock_data
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gustavo A. R. Silva <[email protected]>
commit d761bb01c85b22d5b44abe283eb89019693f6595 upstream.
struct clk_hw_onecell_data is a flexible structure, which means that it contains flexible-array member at the bottom, in this case array hws:
include/linux/clk-provider.h:
1380 struct clk_hw_onecell_data {
1381 unsigned int num;
1382 struct clk_hw *hws[] __counted_by(num);
1383 };
This could potentially lead to an overwrite of the objects following clk_data in struct stratix10_clock_data, in this case void __iomem *base; at run-time:
drivers/clk/socfpga/stratix10-clk.h:
9 struct stratix10_clock_data {
10 struct clk_hw_onecell_data clk_data;
11 void __iomem *base;
12 };
There are currently three different places where memory is allocated for struct stratix10_clock_data, including the flex-array hws in struct clk_hw_onecell_data:
drivers/clk/socfpga/clk-agilex.c:
469 clk_data = devm_kzalloc(dev, struct_size(clk_data, clk_data.hws,
470 num_clks), GFP_KERNEL);
drivers/clk/socfpga/clk-agilex.c:
509 clk_data = devm_kzalloc(dev, struct_size(clk_data, clk_data.hws,
510 num_clks), GFP_KERNEL);
drivers/clk/socfpga/clk-s10.c:
400 clk_data = devm_kzalloc(dev, struct_size(clk_data, clk_data.hws,
401 num_clks), GFP_KERNEL);
I'll use just one of them to describe the issue. See below.
Notice that a total of 440 bytes are allocated for flexible-array member hws at line 469:
include/dt-bindings/clock/agilex-clock.h:
70 #define AGILEX_NUM_CLKS 55
drivers/clk/socfpga/clk-agilex.c:
459 struct stratix10_clock_data *clk_data;
460 void __iomem *base;
...
466
467 num_clks = AGILEX_NUM_CLKS;
468
469 clk_data = devm_kzalloc(dev, struct_size(clk_data, clk_data.hws,
470 num_clks), GFP_KERNEL);
struct_size(clk_data, clk_data.hws, num_clks) above translates tosizeof(struct stratix10_clock_data) + sizeof(struct clk_hw *) * 55 == 16 + 8 * 55 == 16 + 440
^^^ | allocated bytes for flex-array `hws`
474 for (i = 0; i < num_clks; i++)
475 clk_data->clk_data.hws[i] = ERR_PTR(-ENOENT);
476
477 clk_data->base = base;
and then some data is written into both hws and base objects.
Fix this by placing the declaration of object clk_data at the end of struct stratix10_clock_data. Also, add a comment to make it clear that this object must always be last in the structure.
-Wflex-array-member-not-at-end is coming in GCC-14, and we are getting ready to enable it globally.
--- drivers/clk/socfpga/stratix10-clk.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/clk/socfpga/stratix10-clk.h +3 -1
@@ -7,8 +7,10 @@#define __STRATIX10_CLK_Hstruct stratix10_clock_data { -struct clk_hw_onecell_data clk_data;void __iomem *base; + +/* Must be last */ +struct clk_hw_onecell_data clk_data; };struct stratix10_pll_clock {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 181/297 clk: qcom: ipq8074: drop the CLK_SET_RATE_PARENT flag from PLL clocks
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kathiravan Thirumoorthy <[email protected]>
commit e641a070137dd959932c7c222e000d9d941167a2 upstream.
GPLL, NSS crypto PLL clock rates are fixed and shouldn't be scaled based on the request from dependent clocks. Doing so will result in the unexpected behaviour. So drop the CLK_SET_RATE_PARENT flag from the PLL clocks.
--- drivers/clk/qcom/gcc-ipq8074.c | 6 ------ 1 file changed, 6 deletions(-)
drivers/clk/qcom/gcc-ipq8074.c +0 -6
@@ -418,7 +418,6 @@ static struct clk_fixed_factor gpll0_out }, .num_parents = 1, .ops = &clk_fixed_factor_ops, - .flags = CLK_SET_RATE_PARENT, }, };
@@ -465,7 +464,6 @@ static struct clk_alpha_pll_postdiv gpll }, .num_parents = 1, .ops = &clk_alpha_pll_postdiv_ro_ops, - .flags = CLK_SET_RATE_PARENT, }, };
@@ -498,7 +496,6 @@ static struct clk_alpha_pll_postdiv gpll }, .num_parents = 1, .ops = &clk_alpha_pll_postdiv_ro_ops, - .flags = CLK_SET_RATE_PARENT, }, };
@@ -532,7 +529,6 @@ static struct clk_alpha_pll_postdiv gpll }, .num_parents = 1, .ops = &clk_alpha_pll_postdiv_ro_ops, - .flags = CLK_SET_RATE_PARENT, }, };
@@ -546,7 +542,6 @@ static struct clk_fixed_factor gpll6_out }, .num_parents = 1, .ops = &clk_fixed_factor_ops, - .flags = CLK_SET_RATE_PARENT, }, };
@@ -611,7 +606,6 @@ static struct clk_alpha_pll_postdiv nss_ }, .num_parents = 1, .ops = &clk_alpha_pll_postdiv_ro_ops, - .flags = CLK_SET_RATE_PARENT, }, };
Greg Kroah-Hartman
maintainerPATCH 182/297 clk: qcom: ipq6018: drop the CLK_SET_RATE_PARENT flag from PLL clocks
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kathiravan Thirumoorthy <[email protected]>
commit 99cd4935cb972d0aafb16838bb2aeadbcaf196ce upstream.
GPLL, NSS crypto PLL clock rates are fixed and shouldn't be scaled based on the request from dependent clocks. Doing so will result in the unexpected behaviour. So drop the CLK_SET_RATE_PARENT flag from the PLL clocks.
--- drivers/clk/qcom/gcc-ipq6018.c | 6 ------ 1 file changed, 6 deletions(-)
drivers/clk/qcom/gcc-ipq6018.c +0 -6
@@ -75,7 +75,6 @@ static struct clk_fixed_factor gpll0_out &gpll0_main.clkr.hw }, .num_parents = 1, .ops = &clk_fixed_factor_ops, - .flags = CLK_SET_RATE_PARENT, }, };
@@ -89,7 +88,6 @@ static struct clk_alpha_pll_postdiv gpll &gpll0_main.clkr.hw }, .num_parents = 1, .ops = &clk_alpha_pll_postdiv_ro_ops, - .flags = CLK_SET_RATE_PARENT, }, };
@@ -164,7 +162,6 @@ static struct clk_alpha_pll_postdiv gpll &gpll6_main.clkr.hw }, .num_parents = 1, .ops = &clk_alpha_pll_postdiv_ro_ops, - .flags = CLK_SET_RATE_PARENT, }, };
@@ -195,7 +192,6 @@ static struct clk_alpha_pll_postdiv gpll &gpll4_main.clkr.hw }, .num_parents = 1, .ops = &clk_alpha_pll_postdiv_ro_ops, - .flags = CLK_SET_RATE_PARENT, }, };
@@ -246,7 +242,6 @@ static struct clk_alpha_pll_postdiv gpll &gpll2_main.clkr.hw }, .num_parents = 1, .ops = &clk_alpha_pll_postdiv_ro_ops, - .flags = CLK_SET_RATE_PARENT, }, };
@@ -277,7 +272,6 @@ static struct clk_alpha_pll_postdiv nss_ &nss_crypto_pll_main.clkr.hw }, .num_parents = 1, .ops = &clk_alpha_pll_postdiv_ro_ops, - .flags = CLK_SET_RATE_PARENT, }, };
Greg Kroah-Hartman
maintainerPATCH 183/297 mmc: vub300: fix an error code
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
commit b44f9da81783fda72632ef9b0d05ea3f3ca447a5 upstream.
This error path should return -EINVAL instead of success.
--- drivers/mmc/host/vub300.c | 1 + 1 file changed, 1 insertion(+)
drivers/mmc/host/vub300.c +1 -0
@@ -2311,6 +2311,7 @@ static int vub300_probe(struct usb_inter vub300->read_only = (0x0010 & vub300->system_port_status.port_flags) ?1 :0 ; }else { + retval = -EINVAL ; goto error5; }usb_set_intfdata (interface, vub300);
Greg Kroah-Hartman
maintainerPATCH 184/297 mmc: sdhci_am654: fix start loop index for TAP value parsing
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nitin Yadav <[email protected]>
commit 71956d0cb56c1e5f9feeb4819db87a076418e930 upstream.
ti,otap-del-sel-legacy/ti,itap-del-sel-legacy passed from DT are currently ignored for all SD/MMC and eMMC modes. Fix this by making start loop index to MMC_TIMING_LEGACY.
--- drivers/mmc/host/sdhci_am654.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/host/sdhci_am654.c +1 -1
@@ -600,7 +600,7 @@ static int sdhci_am654_get_otap_delay(streturn 0 ; } -for (i =MMC_TIMING_MMC_HS ; i <=MMC_TIMING_MMC_HS400 ; i++) { +for (i =MMC_TIMING_LEGACY ; i <=MMC_TIMING_MMC_HS400 ; i++) { ret =device_property_read_u32 (dev, td[i].otap_binding, &sdhci_am654->otap_del_sel[i]);
Greg Kroah-Hartman
maintainerPATCH 185/297 PCI/ASPM: Fix L1 substate handling in aspm_attr_store_common()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiner Kallweit <[email protected]>
commit 8e37372ad0bea4c9b4712d9943f6ae96cff9491f upstream.
aspm_attr_store_common(), which handles sysfs control of ASPM, has the same problem as fb097dcd5a28 ("PCI/ASPM: Disable only ASPM_STATE_L1 when driver disables L1"): disabling L1 adds only ASPM_L1 (but not any of the L1.x substates) to the "aspm_disable" mask.
Enabling one substate, e.g., L1.1, via sysfs removes ASPM_L1 from the disable mask. Since disabling L1 via sysfs doesn't add any of the substates to the disable mask, enabling L1.1 actually enables *all* the substates.
In this scenario:
- Write 0 to "l1_aspm" to disable L1
- Write 1 to "l1_1_aspm" to enable L1.1
the intention is to disable L1 and all L1.x substates, then enable just L1.1, but in fact, *all* L1.x substates are enabled.
Fix this by explicitly disabling all the L1.x substates when disabling L1.
--- drivers/pci/pcie/aspm.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/pci/pcie/aspm.c +2 -0
@@ -1231,6 +1231,8 @@ static ssize_t aspm_attr_store_common(st link->aspm_disable &= ~ASPM_STATE_L1 ; }else { link->aspm_disable |= state; +if (state &ASPM_STATE_L1 ) + link->aspm_disable |=ASPM_STATE_L1SS ; }pcie_config_aspm_link (link,policy_to_aspm_state (link));
Greg Kroah-Hartman
maintainerPATCH 186/297 PCI: exynos: Dont discard .remove() callback
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Uwe Kleine-König <[email protected]>
commit 83a939f0fdc208ff3639dd3d42ac9b3c35607fd2 upstream.
With CONFIG_PCI_EXYNOS=y and exynos_pcie_remove() marked with __exit, the function is discarded from the driver. In this case a bound device can still get unbound, e.g via sysfs. Then no cleanup code is run resulting in resource leaks or worse.
The right thing to do is do always have the remove callback available. This fixes the following warning by modpost:
WARNING: modpost: drivers/pci/controller/dwc/pci-exynos: section mismatch in reference: exynos_pcie_driver+0x8 (section: .data) -> exynos_pcie_remove (section: .exit.text)
(with ARCH=x86_64 W=1 allmodconfig).
--- drivers/pci/controller/dwc/pci-exynos.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pci/controller/dwc/pci-exynos.c +2 -2
@@ -377,7 +377,7 @@ fail_probe:return ret; } -static int __exit exynos_pcie_remove(struct platform_device *pdev) +static int exynos_pcie_remove (struct platform_device *pdev) {struct exynos_pcie *ep =platform_get_drvdata (pdev);
@@ -433,7 +433,7 @@ static const struct of_device_id exynos_static struct platform_driver exynos_pcie_driver = { .probe = exynos_pcie_probe, - .remove =__exit_p (exynos_pcie_remove), + .remove = exynos_pcie_remove, .driver = { .name ="exynos-pcie" , .of_match_table = exynos_pcie_of_match,
Greg Kroah-Hartman
maintainerPATCH 187/297 wifi: wilc1000: use vmm_table as array in wilc struct
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ajay Singh <[email protected]>
commit 05ac1a198a63ad66bf5ae8b7321407c102d40ef3 upstream.
Enabling KASAN and running some iperf tests raises some memory issues with vmm_table:
BUG: KASAN: slab-out-of-bounds in wilc_wlan_handle_txq+0x6ac/0xdb4 Write of size 4 at addr c3a61540 by task wlan0-tx/95
KASAN detects that we are writing data beyond range allocated to vmm_table. There is indeed a mismatch between the size passed to allocator in wilc_wlan_init, and the range of possible indexes used later: allocation size is missing a multiplication by sizeof(u32)
--- drivers/net/wireless/microchip/wilc1000/wlan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/microchip/wilc1000/wlan.c +1 -1
@@ -1458,7 +1458,7 @@ int wilc_wlan_init(struct net_device *de }if (!wilc->vmm_table) - wilc->vmm_table =kzalloc (WILC_VMM_TBL_SIZE ,GFP_KERNEL ); + wilc->vmm_table =kcalloc (WILC_VMM_TBL_SIZE ,sizeof (u32),GFP_KERNEL );if (!wilc->vmm_table) { ret = -ENOBUFS ;
Greg Kroah-Hartman
maintainerPATCH 188/297 svcrdma: Drop connection after an RDMA Read error
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
commit 197115ebf358cb440c73e868b2a0a5ef728decc6 upstream.
When an RPC Call message cannot be pulled from the client, that is a message loss, by definition. Close the connection to trigger the client to resend.
--- net/sunrpc/xprtrdma/svc_rdma_recvfrom.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/sunrpc/xprtrdma/svc_rdma_recvfrom.c +2 -1
@@ -852,7 +852,8 @@ out_readfail:if (ret == -EINVAL )svc_rdma_send_error (rdma_xprt, ctxt, ret);svc_rdma_recv_ctxt_put (rdma_xprt, ctxt); -return ret; +svc_xprt_deferred_close (xprt); +return -ENOTCONN ; out_backchannel:svc_rdma_handle_bc_reply (rqstp, ctxt);
Greg Kroah-Hartman
maintainerPATCH 189/297 rcu/tree: Defer setting of jiffies during stall reset
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joel Fernandes (Google) <[email protected]>
commit b96e7a5fa0ba9cda32888e04f8f4bac42d49a7f8 upstream.
There are instances where rcu_cpu_stall_reset() is called when jiffies did not get a chance to update for a long time. Before jiffies is updated, the CPU stall detector can go off triggering false-positives where a just-started grace period appears to be ages old. In the past, we disabled stall detection in rcu_cpu_stall_reset() however this got changed [1]. This is resulting in false-positives in KGDB usecase [2].
Fix this by deferring the update of jiffies to the third run of the FQS loop. This is more robust, as, even if rcu_cpu_stall_reset() is called just before jiffies is read, we would end up pushing out the jiffies read by 3 more FQS loops. Meanwhile the CPU stall detection will be delayed and we will not get any false positives.
[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/
Tested with rcutorture.cpu_stall option as well to verify stall behavior with/without patch.
--- kernel/rcu/tree.c | 12 ++++++++++++ kernel/rcu/tree.h | 4 ++++ kernel/rcu/tree_stall.h | 20 ++++++++++++++++++-- 3 files changed, 34 insertions(+), 2 deletions(-)
kernel/rcu/tree.c +12 -0
@@ -1906,10 +1906,22 @@ static bool rcu_gp_fqs_check_wake(int *g*/ static void rcu_gp_fqs (bool first_time) { +int nr_fqs =READ_ONCE (rcu_state.nr_fqs_jiffies_stall);struct rcu_node *rnp =rcu_get_root ();WRITE_ONCE (rcu_state.gp_activity, jiffies);WRITE_ONCE (rcu_state.n_force_qs, rcu_state.n_force_qs +1 ); + +WARN_ON_ONCE (nr_fqs >3 ); +/* Only countdown nr_fqs for stall purposes if jiffies moves. */ +if (nr_fqs) { +if (nr_fqs ==1 ) { +WRITE_ONCE (rcu_state.jiffies_stall, + jiffies +rcu_jiffies_till_stall_check ()); + } +WRITE_ONCE (rcu_state.nr_fqs_jiffies_stall, --nr_fqs); + } +if (first_time) {/* Collect dyntick-idle snapshots. */ force_qs_rnp (dyntick_save_progress_counter);
kernel/rcu/tree.h +4 -0
@@ -351,6 +351,10 @@ struct rcu_state {/* in jiffies. */ unsigned long jiffies_stall;/* Time at which to check */ /* for CPU stalls. */ +int nr_fqs_jiffies_stall;/* Number of fqs loops after +* which read jiffies and set +* jiffies_stall. Stall +* warnings disabled if !0. */ unsigned long jiffies_resched;/* Time at which to resched */ /* a reluctant CPU. */ unsigned long n_force_qs_gpstart;/* Snapshot of n_force_qs at */
kernel/rcu/tree_stall.h +18 -2
@@ -121,12 +121,17 @@ static void panic_on_rcu_stall(void)/** * rcu_cpu_stall_reset - restart stall-warning timeout for current grace period * +* To perform the reset request from the caller, disable stall detection until +* 3 fqs loops have passed. This is required to ensure a fresh jiffies is +* loaded. It should be safe to do from the fqs loop as enough timer +* interrupts and context switches should have passed. +* * The caller must disable hard irqs. */ void rcu_cpu_stall_reset (void ) { -WRITE_ONCE (rcu_state.jiffies_stall, - jiffies +rcu_jiffies_till_stall_check ()); +WRITE_ONCE (rcu_state.nr_fqs_jiffies_stall,3 ); +WRITE_ONCE (rcu_state.jiffies_stall,ULONG_MAX ); }//////////////////////////////////////////////////////////////////////////////
@@ -142,6 +147,7 @@ static void record_gp_stall_check_time(vWRITE_ONCE (rcu_state.gp_start, j); j1 =rcu_jiffies_till_stall_check ();smp_mb ();// ->gp_start before ->jiffies_stall and caller's ->gp_seq. +WRITE_ONCE (rcu_state.nr_fqs_jiffies_stall,0 );WRITE_ONCE (rcu_state.jiffies_stall, j + j1); rcu_state.jiffies_resched = j + j1 /2 ; rcu_state.n_force_qs_gpstart =READ_ONCE (rcu_state.n_force_qs);
@@ -662,6 +668,16 @@ static void check_cpu_stall(struct rcu_d !rcu_gp_in_progress())return ;rcu_stall_kick_kthreads (); + +/* +* Check if it was requested (via rcu_cpu_stall_reset()) that the FQS +* loop has to set jiffies to ensure a non-stale jiffies value. This +* is required to have good jiffies value after coming out of long +* breaks of jiffies updates. Not doing so can cause false positives. +*/ +if (READ_ONCE (rcu_state.nr_fqs_jiffies_stall) >0 ) +return ; + j = jiffies;/*
Greg Kroah-Hartman
maintainerPATCH 190/297 arm64: dts: qcom: ipq6018: Fix hwlock index for SMEM
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vignesh Viswanathan <[email protected]>
commit 95d97b111e1e184b0c8656137033ed64f2cf21e4 upstream.
SMEM uses lock index 3 of the TCSR Mutex hwlock for allocations in SMEM region shared by the Host and FW.
Fix the SMEM hwlock index to 3 for IPQ6018.
--- arch/arm64/boot/dts/qcom/ipq6018.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/qcom/ipq6018.dtsi +1 -1
@@ -175,7 +175,7 @@ smem { compatible = "qcom,smem"; memory-region = <&smem_region>; - hwlocks = <&tcsr_mutex 0>; + hwlocks = <&tcsr_mutex 3>; }; soc: soc {
Greg Kroah-Hartman
maintainerPATCH 191/297 PM: hibernate: Use __get_safe_page() rather than touching the list
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Brian Geffon <[email protected]>
commit f0c7183008b41e92fa676406d87f18773724b48b upstream.
We found at least one situation where the safe pages list was empty and get_buffer() would gladly try to use a NULL pointer.
--- kernel/power/snapshot.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
kernel/power/snapshot.c +6 -4
@@ -2414,8 +2414,9 @@ static void *get_highmem_page_buffer(str pbe->copy_page = tmp; }else {/* Copy of the page will be stored in normal memory */ - kaddr = safe_pages_list; - safe_pages_list = safe_pages_list->next; + kaddr =__get_safe_page (ca->gfp_mask); +if (!kaddr) +return ERR_PTR (-ENOMEM ); pbe->copy_page =virt_to_page (kaddr); } pbe->next = highmem_pblist;
@@ -2595,8 +2596,9 @@ static void *get_buffer(struct memory_bireturn ERR_PTR (-ENOMEM ); } pbe->orig_address =page_address (page); - pbe->address = safe_pages_list; - safe_pages_list = safe_pages_list->next; + pbe->address =__get_safe_page (ca->gfp_mask); +if (!pbe->address) +return ERR_PTR (-ENOMEM ); pbe->next = restore_pblist; restore_pblist = pbe;return pbe->address;
Greg Kroah-Hartman
maintainerPATCH 192/297 PM: hibernate: Clean up sync_read handling in snapshot_write_next()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Brian Geffon <[email protected]>
commit d08970df1980476f27936e24d452550f3e9e92e1 upstream.
In snapshot_write_next(), sync_read is set and unset in three different spots unnecessiarly. As a result there is a subtle bug where the first page after the meta data has been loaded unconditionally sets sync_read to 0. If this first PFN was actually a highmem page, then the returned buffer will be the global "buffer," and the page needs to be loaded synchronously.
That is, I'm not sure we can always assume the following to be safe:
handle->buffer = get_buffer(&orig_bm, &ca); handle->sync_read = 0;
Because get_buffer() can call get_highmem_page_buffer() which can return 'buffer'.
The easiest way to address this is just set sync_read before snapshot_write_next() returns if handle->buffer == buffer.
--- kernel/power/snapshot.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
kernel/power/snapshot.c +1 -5
@@ -2629,8 +2629,6 @@ int snapshot_write_next(struct snapshot_if (handle->cur >1 && handle->cur > nr_meta_pages + nr_copy_pages)return 0 ; - handle->sync_read =1 ; -if (!handle->cur) {if (!buffer)/* This makes the buffer be freed by swsusp_free() */
@@ -2666,7 +2664,6 @@ int snapshot_write_next(struct snapshot_memory_bm_position_reset (&orig_bm); restore_pblist =NULL ; handle->buffer =get_buffer (&orig_bm, &ca); - handle->sync_read =0 ;if (IS_ERR (handle->buffer))return PTR_ERR (handle->buffer); }
@@ -2676,9 +2673,8 @@ int snapshot_write_next(struct snapshot_ handle->buffer =get_buffer (&orig_bm, &ca);if (IS_ERR (handle->buffer))return PTR_ERR (handle->buffer); -if (handle->buffer != buffer) - handle->sync_read =0 ; } + handle->sync_read = (handle->buffer == buffer); handle->cur++;return PAGE_SIZE ; }
Greg Kroah-Hartman
maintainerPATCH 193/297 rcu: kmemleak: Ignore kmemleak false positives when RCU-freeing objects
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Catalin Marinas <[email protected]>
commit 5f98fd034ca6fd1ab8c91a3488968a0e9caaabf6 upstream.
Since the actual slab freeing is deferred when calling kvfree_rcu(), so is the kmemleak_free() callback informing kmemleak of the object deletion. From the perspective of the kvfree_rcu() caller, the object is freed and it may remove any references to it. Since kmemleak does not scan RCU internal data storing the pointer, it will report such objects as leaks during the grace period.
Tell kmemleak to ignore such objects on the kvfree_call_rcu() path. Note that the tiny RCU implementation does not have such issue since the objects can be tracked from the rcu_ctrlblk structure.
--- kernel/rcu/tree.c | 9 +++++++++ 1 file changed, 9 insertions(+)
kernel/rcu/tree.c +9 -0
@@ -31,6 +31,7 @@#include <linux/bitops.h> #include <linux/export.h> #include <linux/completion.h> +#include <linux/kmemleak.h> #include <linux/moduleparam.h> #include <linux/panic.h> #include <linux/panic_notifier.h>
@@ -3609,6 +3610,14 @@ void kvfree_call_rcu(struct rcu_head *heWRITE_ONCE (krcp->count, krcp->count +1 ); +/* +* The kvfree_rcu() caller considers the pointer freed at this point +* and likely removes any references to it. Since the actual slab +* freeing (and kmemleak_free()) is deferred, tell kmemleak to ignore +* this object (no scanning or false positives reporting). +*/ +kmemleak_ignore (ptr); +// Set timer to drain after KFREE_DRAIN_JIFFIES. if (rcu_scheduler_active ==RCU_SCHEDULER_RUNNING && !krcp->monitor_todo) {
Greg Kroah-Hartman
maintainerPATCH 194/297 btrfs: dont arbitrarily slow down delalloc if were committing
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josef Bacik <[email protected]>
commit 11aeb97b45ad2e0040cbb2a589bc403152526345 upstream.
We have a random schedule_timeout() if the current transaction is committing, which seems to be a holdover from the original delalloc reservation code.
Remove this, we have the proper flushing stuff, we shouldn't be hoping for random timing things to make everything work. This just induces latency for no reason.
--- fs/btrfs/delalloc-space.c | 3 --- 1 file changed, 3 deletions(-)
fs/btrfs/delalloc-space.c +0 -3
@@ -312,9 +312,6 @@ int btrfs_delalloc_reserve_metadata(stru }else {if (current->journal_info) flush =BTRFS_RESERVE_FLUSH_LIMIT ; - -if (btrfs_transaction_in_commit (fs_info)) -schedule_timeout (1 ); } num_bytes =ALIGN (num_bytes, fs_info->sectorsize);
Greg Kroah-Hartman
maintainerPATCH 195/297 firmware: qcom_scm: use 64-bit calling convention only when client is 64-bit
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kathiravan Thirumoorthy <[email protected]>
commit 3337a6fea25370d3d244ec6bb38c71ee86fcf837 upstream.
Per the "SMC calling convention specification", the 64-bit calling convention can only be used when the client is 64-bit. Whereas the 32-bit calling convention can be used by either a 32-bit or a 64-bit client.
Currently during SCM probe, irrespective of the client, 64-bit calling convention is made, which is incorrect and may lead to the undefined behaviour when the client is 32-bit. Let's fix it.
--- drivers/firmware/qcom_scm.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/firmware/qcom_scm.c +7 -0
@@ -137,6 +137,12 @@ static enum qcom_scm_convention __get_coreturn qcom_scm_convention;/* +* Per the "SMC calling convention specification", the 64-bit calling +* convention can only be used when the client is 64-bit, otherwise +* system will encounter the undefined behaviour. +*/ +#if IS_ENABLED (CONFIG_ARM64 ) +/* * Device isn't required as there is only one argument - no device * needed to dma_map_single to secure world */
@@ -156,6 +162,7 @@ static enum qcom_scm_convention __get_co forced = true; goto found; } +#endif probed_convention =SMC_CONVENTION_ARM_32 ; ret =__scm_smc_call (NULL , &desc, probed_convention, &res, true);
Greg Kroah-Hartman
maintainerPATCH 196/297 ACPI: FPDT: properly handle invalid FPDT subtables
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vasily Khoruzhick <[email protected]>
commit a83c68a3bf7c418c9a46693c63c638852b0c1f4e upstream.
Buggy BIOSes may have invalid FPDT subtables, e.g. on my hardware:
S3PT subtable:
7F20FE30: 53 33 50 54 24 00 00 00-00 00 00 00 00 00 18 01 *S3PT$...........* 7F20FE40: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 *................* 7F20FE50: 00 00 00 00
Here the first record has zero length.
FBPT subtable:
7F20FE50: 46 42 50 54-3C 00 00 00 46 42 50 54 *....FBPT<...FBPT* 7F20FE60: 02 00 30 02 00 00 00 00-00 00 00 00 00 00 00 00 *..0.............* 7F20FE70: 2A A6 BC 6E 0B 00 00 00-1A 44 41 70 0B 00 00 00 **..n.....DAp....* 7F20FE80: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 *................*
And here FBPT table has FBPT signature repeated instead of the first record.
Current code will be looping indefinitely due to zero length records, so break out of the loop if record length is zero.
While we are here, add proper handling for fpdt_process_subtable() failures.
--- drivers/acpi/acpi_fpdt.c | 45 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 8 deletions(-)
drivers/acpi/acpi_fpdt.c +37 -8
@@ -194,12 +194,19 @@ static int fpdt_process_subtable(u64 add record_header = (void *)subtable_header + offset; offset += record_header->length; +if (!record_header->length) { +pr_err (FW_BUG "Zero-length record found in FPTD.\n" ); + result = -EINVAL ; + goto err; + } +switch (record_header->type) {case RECORD_S3_RESUME :if (subtable_type !=SUBTABLE_S3PT ) {pr_err (FW_BUG "Invalid record %d for subtable %s\n" , record_header->type, signature); -return -EINVAL ; + result = -EINVAL ; + goto err; }if (record_resume) {pr_err ("Duplicate resume performance record found.\n" );
@@ -208,7 +215,7 @@ static int fpdt_process_subtable(u64 add record_resume = (struct resume_performance_record *)record_header; result =sysfs_create_group (fpdt_kobj, &resume_attr_group);if (result) -return result; + goto err;break ;case RECORD_S3_SUSPEND :if (subtable_type !=SUBTABLE_S3PT ) {
@@ -223,13 +230,14 @@ static int fpdt_process_subtable(u64 add record_suspend = (struct suspend_performance_record *)record_header; result =sysfs_create_group (fpdt_kobj, &suspend_attr_group);if (result) -return result; + goto err;break ;case RECORD_BOOT :if (subtable_type !=SUBTABLE_FBPT ) {pr_err (FW_BUG "Invalid %d for subtable %s\n" , record_header->type, signature); -return -EINVAL ; + result = -EINVAL ; + goto err; }if (record_boot) {pr_err ("Duplicate boot performance record found.\n" );
@@ -238,7 +246,7 @@ static int fpdt_process_subtable(u64 add record_boot = (struct boot_performance_record *)record_header; result =sysfs_create_group (fpdt_kobj, &boot_attr_group);if (result) -return result; + goto err;break ;default :
@@ -247,6 +255,18 @@ static int fpdt_process_subtable(u64 add } }return 0 ; + +err: +if (record_boot) +sysfs_remove_group (fpdt_kobj, &boot_attr_group); + +if (record_suspend) +sysfs_remove_group (fpdt_kobj, &suspend_attr_group); + +if (record_resume) +sysfs_remove_group (fpdt_kobj, &resume_attr_group); + +return result; }static int __init acpi_init_fpdt (void )
@@ -255,6 +275,7 @@ static int __init acpi_init_fpdt(void)struct acpi_table_header *header;struct fpdt_subtable_entry *subtable;u32 offset =sizeof (*header); +int result; status =acpi_get_table (ACPI_SIG_FPDT ,0 , &header);
@@ -263,8 +284,8 @@ static int __init acpi_init_fpdt(void) fpdt_kobj =kobject_create_and_add ("fpdt" , acpi_kobj);if (!fpdt_kobj) { -acpi_put_table (header); -return -ENOMEM ; + result = -ENOMEM ; + goto err_nomem; }while (offset < header->length) {
@@ -272,8 +293,10 @@ static int __init acpi_init_fpdt(void)switch (subtable->type) {case SUBTABLE_FBPT :case SUBTABLE_S3PT : -fpdt_process_subtable (subtable->address, + result =fpdt_process_subtable (subtable->address, subtable->type); +if (result) + goto err_subtable;break ;default :/* Other types are reserved in ACPI 6.4 spec. */
@@ -282,6 +305,12 @@ static int __init acpi_init_fpdt(void) offset +=sizeof (*subtable); }return 0 ; +err_subtable: +kobject_put (fpdt_kobj); + +err_nomem: +acpi_put_table (header); +return result; }fs_initcall (acpi_init_fpdt);
Greg Kroah-Hartman
maintainerPATCH 197/297 ima: annotate iint mutex to avoid lockdep false positive warnings
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Amir Goldstein <[email protected]>
commit e044374a8a0a99e46f4e6d6751d3042b6d9cc12e upstream.
It is not clear that IMA should be nested at all, but as long is it measures files both on overlayfs and on underlying fs, we need to annotate the iint mutex to avoid lockdep false positives related to IMA + overlayfs, same as overlayfs annotates the inode mutex.
--- security/integrity/iint.c | 48 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 11 deletions(-)
security/integrity/iint.c +37 -11
@@ -66,9 +66,32 @@ struct integrity_iint_cache *integrity_ireturn iint; } -static void iint_free (struct integrity_iint_cache *iint) +#define IMA_MAX_NESTING (FILESYSTEM_MAX_STACK_DEPTH+1) + +/* +* It is not clear that IMA should be nested at all, but as long is it measures +* files both on overlayfs and on underlying fs, we need to annotate the iint +* mutex to avoid lockdep false positives related to IMA + overlayfs. +* See ovl_lockdep_annotate_inode_mutex_key() for more details. +*/ +static inline void iint_lockdep_annotate (struct integrity_iint_cache *iint, +struct inode *inode) +{ +#ifdef CONFIG_LOCKDEP +static struct lock_class_key iint_mutex_key[IMA_MAX_NESTING ]; + +int depth = inode->i_sb->s_stack_depth; + +if (WARN_ON_ONCE (depth <0 || depth >=IMA_MAX_NESTING )) + depth =0 ; + +lockdep_set_class (&iint->mutex, &iint_mutex_key[depth]); +#endif +} + +static void iint_init_always (struct integrity_iint_cache *iint, +struct inode *inode) { -kfree (iint->ima_hash); iint->ima_hash =NULL ; iint->version =0 ; iint->flags =0UL ;
@@ -80,6 +103,14 @@ static void iint_free(struct integrity_i iint->ima_creds_status =INTEGRITY_UNKNOWN ; iint->evm_status =INTEGRITY_UNKNOWN ; iint->measured_pcrs =0 ; +mutex_init (&iint->mutex); +iint_lockdep_annotate (iint, inode); +} + +static void iint_free (struct integrity_iint_cache *iint) +{ +kfree (iint->ima_hash); +mutex_destroy (&iint->mutex);kmem_cache_free (iint_cache, iint); }
@@ -112,6 +143,8 @@ struct integrity_iint_cache *integrity_iif (!iint)return NULL ; +iint_init_always (iint, inode); +write_lock (&integrity_iint_lock); p = &integrity_iint_tree.rb_node;
@@ -161,25 +194,18 @@ void integrity_inode_free(struct inode *iint_free (iint); } -static void init_once (void *foo) +static void iint_init_once (void *foo) {struct integrity_iint_cache *iint = (struct integrity_iint_cache *) foo;memset (iint,0 ,sizeof (*iint)); - iint->ima_file_status =INTEGRITY_UNKNOWN ; - iint->ima_mmap_status =INTEGRITY_UNKNOWN ; - iint->ima_bprm_status =INTEGRITY_UNKNOWN ; - iint->ima_read_status =INTEGRITY_UNKNOWN ; - iint->ima_creds_status =INTEGRITY_UNKNOWN ; - iint->evm_status =INTEGRITY_UNKNOWN ; -mutex_init (&iint->mutex); }static int __init integrity_iintcache_init (void ) { iint_cache =kmem_cache_create ("iint_cache" ,sizeof (struct integrity_iint_cache ), -0 ,SLAB_PANIC , init_once); +0 ,SLAB_PANIC , iint_init_once);return 0 ; }DEFINE_LSM (integrity) = {
Greg Kroah-Hartman
maintainerPATCH 198/297 ima: detect changes to the backing overlay file
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mimi Zohar <[email protected]>
commit b836c4d29f2744200b2af41e14bf50758dddc818 upstream.
Commit 18b44bc5a672 ("ovl: Always reevaluate the file signature for IMA") forced signature re-evaulation on every file access.
Instead of always re-evaluating the file's integrity, detect a change to the backing file, by comparing the cached file metadata with the backing file's metadata. Verifying just the i_version has not changed is insufficient. In addition save and compare the i_ino and s_dev as well.
--- fs/overlayfs/super.c | 2 +- security/integrity/ima/ima_api.c | 5 +++++ security/integrity/ima/ima_main.c | 16 +++++++++++++++- security/integrity/integrity.h | 2 ++ 4 files changed, 23 insertions(+), 2 deletions(-)
fs/overlayfs/super.c +1 -1
@@ -2140,7 +2140,7 @@ static int ovl_fill_super(struct super_b ovl_trusted_xattr_handlers; sb->s_fs_info = ofs; sb->s_flags |=SB_POSIXACL ; - sb->s_iflags |=SB_I_SKIP_SYNC |SB_I_IMA_UNVERIFIABLE_SIGNATURE ; + sb->s_iflags |=SB_I_SKIP_SYNC ; err = -ENOMEM ; root_dentry =ovl_get_root (sb, upperpath.dentry, oe);
security/integrity/ima/ima_api.c +5 -0
@@ -216,6 +216,7 @@ int ima_collect_measurement(struct integ {const char *audit_cause ="failed" ;struct inode *inode =file_inode (file); +struct inode *real_inode =d_real_inode (file_dentry (file));const char *filename = file->f_path.dentry->d_name.name;int result =0 ;int length;
@@ -266,6 +267,10 @@ int ima_collect_measurement(struct integ iint->ima_hash = tmpbuf;memcpy (iint->ima_hash, &hash, length); iint->version = i_version; +if (real_inode != inode) { + iint->real_ino = real_inode->i_ino; + iint->real_dev = real_inode->i_sb->s_dev; + }/* Possibly temporary failure due to type of read (eg. O_DIRECT) */ if (!result)
security/integrity/ima/ima_main.c +15 -1
@@ -26,6 +26,7 @@#include <linux/ima.h> #include <linux/iversion.h> #include <linux/fs.h> +#include <linux/iversion.h> #include "ima.h"
@@ -202,7 +203,7 @@ static int process_measurement(struct fi u32 secid, char *buf, loff_t size, int mask, enum ima_hooks func) { - struct inode *inode = file_inode(file); + struct inode *backing_inode, *inode = file_inode(file);struct integrity_iint_cache *iint =NULL ;struct ima_template_desc *template_desc =NULL ;char *pathbuf =NULL ;
@@ -278,6 +279,19 @@ static int process_measurement(struct fi iint->measured_pcrs =0 ; } +/* Detect and re-evaluate changes made to the backing file. */ + backing_inode =d_real_inode (file_dentry (file)); +if (backing_inode != inode && + (action &IMA_DO_MASK ) && (iint->flags &IMA_DONE_MASK )) { +if (!IS_I_VERSION (backing_inode) || + backing_inode->i_sb->s_dev != iint->real_dev || + backing_inode->i_ino != iint->real_ino || + !inode_eq_iversion (backing_inode, iint->version)) { + iint->flags &= ~IMA_DONE_MASK ; + iint->measured_pcrs =0 ; + } + } +/* Determine if already appraised/measured based on bitmask * (IMA_MEASURE, IMA_MEASURED, IMA_XXXX_APPRAISE, IMA_XXXX_APPRAISED, * IMA_AUDIT, IMA_AUDITED)
security/integrity/integrity.h +2 -0
@@ -131,6 +131,8 @@ struct integrity_iint_cache {unsigned long flags;unsigned long measured_pcrs;unsigned long atomic_flags; +unsigned long real_ino; +dev_t real_dev; enum integrity_status ima_file_status:4; enum integrity_status ima_mmap_status:4; enum integrity_status ima_bprm_status:4;
Greg Kroah-Hartman
maintainerPATCH 199/297 wifi: ath11k: fix temperature event locking
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 1a5352a81b4720ba43d9c899974e3bddf7ce0ce8 upstream.
The ath11k active pdevs are protected by RCU but the temperature event handling code calling ath11k_mac_get_ar_by_pdev_id() was not marked as a read-side critical section as reported by RCU lockdep:
============================= WARNING: suspicious RCU usage 6.6.0-rc6 #7 Not tainted ----------------------------- drivers/net/wireless/ath/ath11k/mac.c:638 suspicious rcu_dereference_check() usage! other info that might help us debug this: rcu_scheduler_active = 2, debug_locks = 1 no locks held by swapper/0/0. ... Call trace: ... lockdep_rcu_suspicious+0x16c/0x22c ath11k_mac_get_ar_by_pdev_id+0x194/0x1b0 [ath11k] ath11k_wmi_tlv_op_rx+0xa84/0x2c1c [ath11k] ath11k_htc_rx_completion_handler+0x388/0x510 [ath11k]
Mark the code in question as an RCU read-side critical section to avoid any potential use-after-free issues.
Tested-on: WCN6855 hw2.1 PCI WLAN.HSP.1.1-03125-QCAHSPSWPL_V1_V2_SILICONZ_LITE-3.6510.23
--- drivers/net/wireless/ath/ath11k/wmi.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath11k/wmi.c +6 -2
@@ -6855,15 +6855,19 @@ ath11k_wmi_pdev_temperature_event(structath11k_dbg (ab,ATH11K_DBG_WMI ,"pdev temperature ev temp %d pdev_id %d\n" , ev->temp, ev->pdev_id); +rcu_read_lock (); + ar =ath11k_mac_get_ar_by_pdev_id (ab, ev->pdev_id);if (!ar) {ath11k_warn (ab,"invalid pdev id in pdev temperature ev %d" , ev->pdev_id); -kfree (tb); -return ; + goto exit; }ath11k_thermal_event_temperature (ar, ev->temp); +exit: +rcu_read_unlock (); +kfree (tb); }
Greg Kroah-Hartman
maintainerPATCH 200/297 wifi: ath11k: fix dfs radar event locking
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 3b6c14833165f689cc5928574ebafe52bbce5f1e upstream.
The ath11k active pdevs are protected by RCU but the DFS radar event handling code calling ath11k_mac_get_ar_by_pdev_id() was not marked as a read-side critical section.
Mark the code in question as an RCU read-side critical section to avoid any potential use-after-free issues.
Compile tested only.
--- drivers/net/wireless/ath/ath11k/wmi.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/wireless/ath/ath11k/wmi.c +4 -0
@@ -6809,6 +6809,8 @@ ath11k_wmi_pdev_dfs_radar_detected_event ev->detector_id, ev->segment_id, ev->timestamp, ev->is_chirp, ev->freq_offset, ev->sidx); +rcu_read_lock (); + ar =ath11k_mac_get_ar_by_pdev_id (ab, ev->pdev_id);if (!ar) {
@@ -6826,6 +6828,8 @@ ath11k_wmi_pdev_dfs_radar_detected_eventieee80211_radar_detected (ar->hw); exit: +rcu_read_unlock (); +kfree (tb); }
Greg Kroah-Hartman
maintainerPATCH 201/297 wifi: ath11k: fix htt pktlog locking
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 3f77c7d605b29df277d77e9ee75d96e7ad145d2d upstream.
The ath11k active pdevs are protected by RCU but the htt pktlog handling code calling ath11k_mac_get_ar_by_pdev_id() was not marked as a read-side critical section.
Mark the code in question as an RCU read-side critical section to avoid any potential use-after-free issues.
Compile tested only.
--- drivers/net/wireless/ath/ath11k/dp_rx.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/ath11k/dp_rx.c +7 -1
@@ -1603,14 +1603,20 @@ static void ath11k_htt_pktlog(struct athu8 pdev_id; pdev_id =FIELD_GET (HTT_T2H_PPDU_STATS_INFO_PDEV_ID , data->hdr); + +rcu_read_lock (); + ar =ath11k_mac_get_ar_by_pdev_id (ab, pdev_id);if (!ar) {ath11k_warn (ab,"invalid pdev id %d on htt pktlog\n" , pdev_id); -return ; + goto out; }trace_ath11k_htt_pktlog (ar, data->payload, hdr->size, ar->ab->pktlog_defs_checksum); + +out: +rcu_read_unlock (); } static void ath11k_htt_backpressure_event_handler(struct ath11k_base *ab,
Greg Kroah-Hartman
maintainerPATCH 202/297 mmc: meson-gx: Remove setting of CMD_CFG_ERROR
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rong Chen <[email protected]>
commit 57925e16c9f7d18012bcf45bfa658f92c087981a upstream.
For the t7 and older SoC families, the CMD_CFG_ERROR has no effect. Starting from SoC family C3, setting this bit without SG LINK data address will cause the controller to generate an IRQ and stop working.
To fix it, don't set the bit CMD_CFG_ERROR anymore.
--- drivers/mmc/host/meson-gx-mmc.c | 1 - 1 file changed, 1 deletion(-)
drivers/mmc/host/meson-gx-mmc.c +0 -1
@@ -811,7 +811,6 @@ static void meson_mmc_start_cmd(struct m cmd_cfg |=FIELD_PREP (CMD_CFG_CMD_INDEX_MASK , cmd->opcode); cmd_cfg |=CMD_CFG_OWNER ;/* owned by CPU */ - cmd_cfg |=CMD_CFG_ERROR ;/* stop in case of error */ meson_mmc_set_response_bits (cmd, &cmd_cfg);
Greg Kroah-Hartman
maintainerPATCH 203/297 genirq/generic_chip: Make irq_remove_generic_chip() irqdomain aware
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Herve Codina <[email protected]>
commit 5e7afb2eb7b2a7c81e9f608cbdf74a07606fd1b5 upstream.
irq_remove_generic_chip() calculates the Linux interrupt number for removing the handler and interrupt chip based on gc::irq_base as a linear function of the bit positions of set bits in the @msk argument.
When the generic chip is present in an irq domain, i.e. created with a call to irq_alloc_domain_generic_chips(), gc::irq_base contains not the base Linux interrupt number. It contains the base hardware interrupt for this chip. It is set to 0 for the first chip in the domain, 0 + N for the next chip, where $N is the number of hardware interrupts per chip.
That means the Linux interrupt number cannot be calculated based on gc::irq_base for irqdomain based chips without a domain map lookup, which is currently missing.
Rework the code to take the irqdomain case into account and calculate the Linux interrupt number by a irqdomain lookup of the domain specific hardware interrupt number.
[ tglx: Massage changelog. Reshuffle the logic and add a proper comment. ]
--- kernel/irq/generic-chip.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-)
kernel/irq/generic-chip.c +19 -6
@@ -541,21 +541,34 @@ EXPORT_SYMBOL_GPL(irq_setup_alt_chip);void irq_remove_generic_chip (struct irq_chip_generic *gc,u32 msk,unsigned int clr,unsigned int set) { -unsigned int i = gc->irq_base; +unsigned int i, virq;raw_spin_lock (&gc_lock);list_del (&gc->list);raw_spin_unlock (&gc_lock); -for (; msk; msk >>=1 , i++) { +for (i =0 ; msk; msk >>=1 , i++) {if (!(msk &0x01 ))continue ; +/* +* Interrupt domain based chips store the base hardware +* interrupt number in gc::irq_base. Otherwise gc::irq_base +* contains the base Linux interrupt number. +*/ +if (gc->domain) { + virq =irq_find_mapping (gc->domain, gc->irq_base + i); +if (!virq) +continue ; + }else { + virq = gc->irq_base + i; + } +/* Remove handler first. That will mask the irq line */ -irq_set_handler (i,NULL ); -irq_set_chip (i, &no_irq_chip); -irq_set_chip_data (i,NULL ); -irq_modify_status (i, clr, set); +irq_set_handler (virq,NULL ); +irq_set_chip (virq, &no_irq_chip); +irq_set_chip_data (virq,NULL ); +irq_modify_status (virq, clr, set); } }EXPORT_SYMBOL_GPL (irq_remove_generic_chip);
Greg Kroah-Hartman
maintainerPATCH 204/297 KEYS: trusted: Rollback init_trusted() consistently
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jarkko Sakkinen <[email protected]>
commit 31de287345f41bbfaec36a5c8cbdba035cf76442 upstream.
Do bind neither static calls nor trusted_key_exit() before a successful init, in order to maintain a consistent state. In addition, depart the init_trusted() in the case of a real error (i.e. getting back something else than -ENODEV).
--- security/keys/trusted-keys/trusted_core.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
security/keys/trusted-keys/trusted_core.c +10 -10
@@ -354,17 +354,17 @@ static int __init init_trusted(void)if (!get_random) get_random = kernel_get_random; -static_call_update (trusted_key_seal, - trusted_key_sources[i].ops->seal); -static_call_update (trusted_key_unseal, - trusted_key_sources[i].ops->unseal); -static_call_update (trusted_key_get_random, - get_random); - trusted_key_exit = trusted_key_sources[i].ops->exit; - migratable = trusted_key_sources[i].ops->migratable; - ret = trusted_key_sources[i].ops->init (); -if (!ret) +if (!ret) { +static_call_update (trusted_key_seal, trusted_key_sources[i].ops->seal); +static_call_update (trusted_key_unseal, trusted_key_sources[i].ops->unseal); +static_call_update (trusted_key_get_random, get_random); + + trusted_key_exit = trusted_key_sources[i].ops->exit; + migratable = trusted_key_sources[i].ops->migratable; + } + +if (!ret || ret != -ENODEV )break ; }
Greg Kroah-Hartman
maintainerPATCH 205/297 PCI: keystone: Dont discard .remove() callback
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Uwe Kleine-König <[email protected]>
commit 200bddbb3f5202bbce96444fdc416305de14f547 upstream.
With CONFIG_PCIE_KEYSTONE=y and ks_pcie_remove() marked with __exit, the function is discarded from the driver. In this case a bound device can still get unbound, e.g via sysfs. Then no cleanup code is run resulting in resource leaks or worse.
The right thing to do is do always have the remove callback available. Note that this driver cannot be compiled as a module, so ks_pcie_remove() was always discarded before this change and modpost couldn't warn about this issue. Furthermore the __ref annotation also prevents a warning.
--- drivers/pci/controller/dwc/pci-keystone.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pci/controller/dwc/pci-keystone.c +2 -2
@@ -1284,7 +1284,7 @@ err_link:return ret; } -static int __exit ks_pcie_remove(struct platform_device *pdev) +static int ks_pcie_remove (struct platform_device *pdev) {struct keystone_pcie *ks_pcie =platform_get_drvdata (pdev);struct device_link **link = ks_pcie->link;
@@ -1302,7 +1302,7 @@ static int __exit ks_pcie_remove(structstatic struct platform_driver ks_pcie_driver__refdata = { .probe = ks_pcie_probe, - .remove =__exit_p (ks_pcie_remove), + .remove = ks_pcie_remove, .driver = { .name ="keystone-pcie" , .of_match_table =of_match_ptr (ks_pcie_of_match),
Greg Kroah-Hartman
maintainerPATCH 206/297 PCI: keystone: Dont discard .probe() callback
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Uwe Kleine-König <[email protected]>
commit 7994db905c0fd692cf04c527585f08a91b560144 upstream.
The __init annotation makes the ks_pcie_probe() function disappear after booting completes. However a device can also be bound later. In that case, we try to call ks_pcie_probe(), but the backing memory is likely already overwritten.
The right thing to do is do always have the probe callback available. Note that the (wrong) __refdata annotation prevented this issue to be noticed by modpost.
--- drivers/pci/controller/dwc/pci-keystone.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pci/controller/dwc/pci-keystone.c +2 -2
@@ -1080,7 +1080,7 @@ static const struct of_device_id ks_pcie { }, }; -static int __init ks_pcie_probe (struct platform_device *pdev) +static int ks_pcie_probe (struct platform_device *pdev) {const struct dw_pcie_host_ops *host_ops;const struct dw_pcie_ep_ops *ep_ops;
@@ -1300,7 +1300,7 @@ static int ks_pcie_remove(struct platforreturn 0 ; } -static struct platform_driver ks_pcie_driver__refdata = { +static struct platform_driver ks_pcie_driver = { .probe = ks_pcie_probe, .remove = ks_pcie_remove, .driver = {
Greg Kroah-Hartman
maintainerPATCH 207/297 netfilter: nf_tables: remove catchall element in GC sync path
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pablo Neira Ayuso <[email protected]>
[ Upstream commit 93995bf4af2c5a99e2a87f0cd5ce547d31eb7630 ]
The expired catchall element is not deactivated and removed from GC sync path. This path holds mutex so just call nft_setelem_data_deactivate() and nft_setelem_catchall_remove() before queueing the GC work.
--- net/netfilter/nf_tables_api.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-)
net/netfilter/nf_tables_api.c +21 -5
@@ -6049,6 +6049,12 @@ static int nft_setelem_deactivate(const struct net *net,return ret; } +static void nft_setelem_catchall_destroy (struct nft_set_elem_catchall *catchall) +{ +list_del_rcu (&catchall->list); +kfree_rcu (catchall, rcu); +} +static void nft_setelem_catchall_remove (const struct net *net,const struct nft_set *set,const struct nft_set_elem *elem)
@@ -6057,8 +6063,7 @@ static void nft_setelem_catchall_remove(const struct net *net,list_for_each_entry_safe (catchall, next, &set->catchall_list, list) {if (catchall->elem == elem->priv) { -list_del_rcu (&catchall->list); -kfree_rcu (catchall, rcu); +nft_setelem_catchall_destroy (catchall);break ; } }
@@ -9046,11 +9051,12 @@ static struct nft_trans_gc *nft_trans_gc_catchall(struct nft_trans_gc *gc, unsigned int gc_seq, bool sync) { -struct nft_set_elem_catchall *catchall; +struct nft_set_elem_catchall *catchall, *next;const struct nft_set *set = gc->set; +struct nft_elem_priv *elem_priv;struct nft_set_ext *ext; -list_for_each_entry_rcu (catchall, &set->catchall_list, list) { +list_for_each_entry_safe (catchall, next, &set->catchall_list, list) { ext =nft_set_elem_ext (set, catchall->elem);if (!nft_set_elem_expired (ext))
@@ -9068,7 +9074,17 @@ static struct nft_trans_gc *nft_trans_gc_catchall(struct nft_trans_gc *gc,if (!gc)return NULL ; -nft_trans_gc_elem_add (gc, catchall->elem); + elem_priv = catchall->elem; +if (sync) { +struct nft_set_elem elem = { + .priv = elem_priv, + }; + +nft_setelem_data_deactivate (gc->net, gc->set, &elem); +nft_setelem_catchall_destroy (catchall); + } + +nft_trans_gc_elem_add (gc, elem_priv); }return gc;
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 208/297 netfilter: nf_tables: split async and sync catchall in two functions
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pablo Neira Ayuso <[email protected]>
[ Upstream commit 8837ba3e58ea1e3d09ae36db80b1e80853aada95 ]
list_for_each_entry_safe() does not work for the async case which runs under RCU, therefore, split GC logic for catchall in two functions instead, one for each of the sync and async GC variants.
The catchall sync GC variant never sees a _DEAD bit set on ever, thus, this handling is removed in such case, moreover, allocate GC sync batch via GFP_KERNEL.
--- net/netfilter/nf_tables_api.c | 61 ++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 29 deletions(-)
net/netfilter/nf_tables_api.c +32 -29
@@ -9047,16 +9047,14 @@ void nft_trans_gc_queue_sync_done(struct nft_trans_gc *trans)call_rcu (&trans->rcu, nft_trans_gc_trans_free); } -static struct nft_trans_gc *nft_trans_gc_catchall (struct nft_trans_gc *gc, -unsigned int gc_seq, -bool sync) +struct nft_trans_gc *nft_trans_gc_catchall_async (struct nft_trans_gc *gc, +unsigned int gc_seq) { -struct nft_set_elem_catchall *catchall, *next; +struct nft_set_elem_catchall *catchall;const struct nft_set *set = gc->set; -struct nft_elem_priv *elem_priv;struct nft_set_ext *ext; -list_for_each_entry_safe (catchall, next, &set->catchall_list, list) { +list_for_each_entry_rcu (catchall, &set->catchall_list, list) { ext =nft_set_elem_ext (set, catchall->elem);if (!nft_set_elem_expired (ext))
@@ -9066,39 +9064,44 @@ static struct nft_trans_gc *nft_trans_gc_catchall(struct nft_trans_gc *gc,nft_set_elem_dead (ext); dead_elem: -if (sync) - gc =nft_trans_gc_queue_sync (gc,GFP_ATOMIC ); -else - gc =nft_trans_gc_queue_async (gc, gc_seq,GFP_ATOMIC ); - + gc =nft_trans_gc_queue_async (gc, gc_seq,GFP_ATOMIC );if (!gc)return NULL ; - elem_priv = catchall->elem; -if (sync) { -struct nft_set_elem elem = { - .priv = elem_priv, - }; - -nft_setelem_data_deactivate (gc->net, gc->set, &elem); -nft_setelem_catchall_destroy (catchall); - } - -nft_trans_gc_elem_add (gc, elem_priv); +nft_trans_gc_elem_add (gc, catchall->elem); }return gc; } -struct nft_trans_gc *nft_trans_gc_catchall_async (struct nft_trans_gc *gc, -unsigned int gc_seq) -{ -return nft_trans_gc_catchall (gc, gc_seq, false); -} -struct nft_trans_gc *nft_trans_gc_catchall_sync (struct nft_trans_gc *gc) { -return nft_trans_gc_catchall (gc,0 , true); +struct nft_set_elem_catchall *catchall, *next; +const struct nft_set *set = gc->set; +struct nft_set_elem elem; +struct nft_set_ext *ext; + +WARN_ON_ONCE (!lockdep_commit_lock_is_held (gc->net)); + +list_for_each_entry_safe (catchall, next, &set->catchall_list, list) { + ext =nft_set_elem_ext (set, catchall->elem); + +if (!nft_set_elem_expired (ext)) +continue ; + + gc =nft_trans_gc_queue_sync (gc,GFP_KERNEL ); +if (!gc) +return NULL ; + +memset (&elem,0 ,sizeof (elem)); + elem.priv = catchall->elem; + +nft_setelem_data_deactivate (gc->net, gc->set, &elem); +nft_setelem_catchall_destroy (catchall); +nft_trans_gc_elem_add (gc, elem.priv); + } + +return gc; }static void nf_tables_module_autoload_cleanup (struct net *net)
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 209/297 selftests/resctrl: Remove duplicate feature check from CMT test
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilpo Järvinen <[email protected]>
commit 030b48fb2cf045dead8ee2c5ead560930044c029 upstream.
The test runner run_cmt_test() in resctrl_tests.c checks for CMT feature and does not run cmt_resctrl_val() if CMT is not supported. Then cmt_resctrl_val() also check is CMT is supported.
Remove the duplicated feature check for CMT from cmt_resctrl_val().
--- tools/testing/selftests/resctrl/cmt_test.c | 3 --- 1 file changed, 3 deletions(-)
tools/testing/selftests/resctrl/cmt_test.c +0 -3
@@ -91,9 +91,6 @@ int cmt_resctrl_val(int cpu_no, int n, cif (ret)return ret; -if (!validate_resctrl_feature_request (CMT_STR )) -return -1 ; - ret =get_cbm_mask ("L3" , cbm_mask);if (ret)return ret;
Greg Kroah-Hartman
maintainerPATCH 210/297 selftests/resctrl: Reduce failures due to outliers in MBA/MBM tests
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilpo Järvinen <[email protected]>
commit ef43c30858754d99373a63dff33280a9969b49bc upstream.
The initial value of 5% chosen for the maximum allowed percentage difference between resctrl mbm value and IMC mbm value in
commit 06bd03a57f8c ("selftests/resctrl: Fix MBA/MBM results reporting
format") was "randomly chosen value" (as admitted by the changelog).
When running tests in our lab across a large number platforms, 5% difference upper bound for success seems a bit on the low side for the MBA and MBM tests. Some platforms produce outliers that are slightly above that, typically 6-7%, which leads MBA/MBM test frequently failing.
Replace the "randomly chosen value" with a success bound that is based on those measurements across large number of platforms by relaxing the MBA/MBM success bound to 8%. The relaxed bound removes the failures due the frequent outliers.
Fixed commit description style error during merge:
Shuah Khan <[email protected]>
--- tools/testing/selftests/resctrl/mba_test.c | 2 +- tools/testing/selftests/resctrl/mbm_test.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/resctrl/mba_test.c +1 -1
@@ -12,7 +12,7 @@#define RESULT_FILE_NAME "result_mba"#define NUM_OF_RUNS 5 -#define MAX_DIFF_PERCENT 5 +#define MAX_DIFF_PERCENT 8#define ALLOCATION_MAX 100#define ALLOCATION_MIN 10#define ALLOCATION_STEP 10
tools/testing/selftests/resctrl/mbm_test.c +1 -1
@@ -11,7 +11,7 @@#include "resctrl.h" #define RESULT_FILE_NAME "result_mbm" -#define MAX_DIFF_PERCENT 5 +#define MAX_DIFF_PERCENT 8#define NUM_OF_RUNS 5 static int
Greg Kroah-Hartman
maintainerPATCH 211/297 ASoC: codecs: wsa-macro: fix uninitialized stack variables with name prefix
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Kozlowski <[email protected]>
commit 72151ad0cba8a07df90130ff62c979520d71f23b upstream.
Driver compares widget name in wsa_macro_spk_boost_event() widget event callback, however it does not handle component's name prefix. This leads to using uninitialized stack variables as registers and register values. Handle gracefully such case.
--- sound/soc/codecs/lpass-wsa-macro.c | 3 +++ 1 file changed, 3 insertions(+)
sound/soc/codecs/lpass-wsa-macro.c +3 -0
@@ -1678,6 +1678,9 @@ static int wsa_macro_spk_boost_event(str boost_path_cfg1 =CDC_WSA_RX1_RX_PATH_CFG1 ; reg =CDC_WSA_RX1_RX_PATH_CTL ; reg_mix =CDC_WSA_RX1_RX_PATH_MIX_CTL ; + }else { +dev_warn (component->dev,"Incorrect widget name in the driver\n" ); +return -EINVAL ; }switch (event) {
Greg Kroah-Hartman
maintainerPATCH 212/297 jbd2: fix potential data lost in recovering journal raced with synchronizing fs bdev
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhihao Cheng <[email protected]>
commit 61187fce8600e8ef90e601be84f9d0f3222c1206 upstream.
JBD2 makes sure journal data is fallen on fs device by sync_blockdev(), however, other process could intercept the EIO information from bdev's mapping, which leads journal recovering successful even EIO occurs during data written back to fs device.
We found this problem in our product, iscsi + multipath is chosen for block device of ext4. Unstable network may trigger kpartx to rescan partitions in device mapper layer. Detailed process is shown as following:
mount kpartx irqjbd2_journal_recover
do_one_pass
memcpy(nbh->b_data, obh->b_data) // copy data to fs dev from journal mark_buffer_dirty // mark bh dirty
vfs_read
generic_file_read_iter // dio
filemap_write_and_wait_range
__filemap_fdatawrite_range
do_writepages
block_write_full_folio
submit_bh_wbc
>> EIO occurs in disk <<
end_buffer_async_write
mark_buffer_write_io_error
mapping_set_error
set_bit(AS_EIO, &mapping->flags) // set!
filemap_check_errors
test_and_clear_bit(AS_EIO, &mapping->flags) // clear!
err2 = sync_blockdev
filemap_write_and_wait
filemap_check_errors
test_and_clear_bit(AS_EIO, &mapping->flags) // false
err2 = 0
Filesystem is mounted successfully even data from journal is failed written into disk, and ext4/ocfs2 could become corrupted.
Fix it by comparing the wb_err state in fs block device before recovering and after recovering.
A reproducer can be found in the kernel bugzilla referenced below.
--- fs/jbd2/recovery.c | 8 ++++++++ 1 file changed, 8 insertions(+)
fs/jbd2/recovery.c +8 -0
@@ -283,6 +283,8 @@ int jbd2_journal_recover(journal_t *jourjournal_superblock_t * sb;struct recovery_info info; +errseq_t wb_err; +struct address_space *mapping;memset (&info,0 ,sizeof (info)); sb = journal->j_superblock;
@@ -300,6 +302,9 @@ int jbd2_journal_recover(journal_t *jourreturn 0 ; } + wb_err =0 ; + mapping = journal->j_fs_dev->bd_inode->i_mapping; +errseq_check_and_advance (&mapping->wb_err, &wb_err); err =do_one_pass (journal, &info,PASS_SCAN );if (!err) err =do_one_pass (journal, &info,PASS_REVOKE );
@@ -320,6 +325,9 @@ int jbd2_journal_recover(journal_t *jour err2 =sync_blockdev (journal->j_fs_dev);if (!err) err = err2; + err2 =errseq_check_and_advance (&mapping->wb_err, &wb_err); +if (!err) + err = err2;/* Make sure all replayed data is on permanent storage */ if (journal->j_flags &JBD2_BARRIER ) { err2 =blkdev_issue_flush (journal->j_fs_dev);
Greg Kroah-Hartman
maintainerPATCH 213/297 quota: explicitly forbid quota files from being encrypted
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
commit d3cc1b0be258191d6360c82ea158c2972f8d3991 upstream.
Since commit d7e7b9af104c ("fscrypt: stop using keyrings subsystem for fscrypt_master_key"), xfstest generic/270 causes a WARNING when run on f2fs with test_dummy_encryption in the mount options:
$ kvm-xfstests -c f2fs/encrypt generic/270 [...] WARNING: CPU: 1 PID: 2453 at fs/crypto/keyring.c:240 fscrypt_destroy_keyring+0x1f5/0x260
The cause of the WARNING is that not all encrypted inodes have been evicted before fscrypt_destroy_keyring() is called, which violates an assumption. This happens because the test uses an external quota file, which gets automatically encrypted due to test_dummy_encryption.
Encryption of quota files has never really been supported. On ext4, ext4_quota_read() does not decrypt the data, so encrypted quota files are always considered invalid on ext4. On f2fs, f2fs_quota_read() uses the pagecache, so trying to use an encrypted quota file gets farther, resulting in the issue described above being possible. But this was never intended to be possible, and there is no use case for it.
Therefore, make the quota support layer explicitly reject using IS_ENCRYPTED inodes when quotaon is attempted.
Message-Id: <[email protected]>
--- fs/quota/dquot.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
fs/quota/dquot.c +14 -0
@@ -2396,6 +2396,20 @@ static int vfs_setup_quota_inode(structif (sb_has_quota_loaded (sb, type))return -EBUSY ; +/* +* Quota files should never be encrypted. They should be thought of as +* filesystem metadata, not user data. New-style internal quota files +* cannot be encrypted by users anyway, but old-style external quota +* files could potentially be incorrectly created in an encrypted +* directory, hence this explicit check. Some reasons why encrypted +* quota files don't work include: (1) some filesystems that support +* encryption don't handle it in their quota_read and quota_write, and +* (2) cleaning up encrypted quota files at unmount would need special +* consideration, as quota files are cleaned up later than user files. +*/ +if (IS_ENCRYPTED (inode)) +return -EINVAL ; + dqopt->files[type] =igrab (inode);if (!dqopt->files[type])return -EIO ;
Greg Kroah-Hartman
maintainerPATCH 214/297 kernel/reboot: emergency_restart: Set correct system_state
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Benjamin Bara <[email protected]>
commit 60466c067927abbcaff299845abd4b7069963139 upstream.
As the emergency restart does not call kernel_restart_prepare(), the system_state stays in SYSTEM_RUNNING.
Since bae1d3a05a8b, this hinders i2c_in_atomic_xfer_mode() from becoming active, and therefore might lead to avoidable warnings in the restart handlers, e.g.:
[ 12.667612] WARNING: CPU: 1 PID: 1 at kernel/rcu/tree_plugin.h:318 rcu_note_context_switch+0x33c/0x6b0 [ 12.676926] Voluntary context switch within RCU read-side critical section! ... [ 12.742376] schedule_timeout from wait_for_completion_timeout+0x90/0x114 [ 12.749179] wait_for_completion_timeout from tegra_i2c_wait_completion+0x40/0x70 ... [ 12.994527] atomic_notifier_call_chain from machine_restart+0x34/0x58 [ 13.001050] machine_restart from panic+0x2a8/0x32c
Avoid these by setting the correct system_state.
--- kernel/reboot.c | 1 + 1 file changed, 1 insertion(+)
kernel/reboot.c +1 -0
@@ -65,6 +65,7 @@ EXPORT_SYMBOL_GPL(pm_power_off_prepare);void emergency_restart (void ) {kmsg_dump (KMSG_DUMP_EMERG ); + system_state =SYSTEM_RESTART ;machine_emergency_restart (); }EXPORT_SYMBOL_GPL (emergency_restart);
Greg Kroah-Hartman
maintainerPATCH 215/297 i2c: core: Run atomic i2c xfer when !preemptible
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Benjamin Bara <[email protected]>
commit aa49c90894d06e18a1ee7c095edbd2f37c232d02 upstream.
Since bae1d3a05a8b, i2c transfers are non-atomic if preemption is disabled. However, non-atomic i2c transfers require preemption (e.g. in wait_for_completion() while waiting for the DMA).
panic() calls preempt_disable_notrace() before calling emergency_restart(). Therefore, if an i2c device is used for the restart, the xfer should be atomic. This avoids warnings like:
[ 12.667612] WARNING: CPU: 1 PID: 1 at kernel/rcu/tree_plugin.h:318 rcu_note_context_switch+0x33c/0x6b0 [ 12.676926] Voluntary context switch within RCU read-side critical section! ... [ 12.742376] schedule_timeout from wait_for_completion_timeout+0x90/0x114 [ 12.749179] wait_for_completion_timeout from tegra_i2c_wait_completion+0x40/0x70 ... [ 12.994527] atomic_notifier_call_chain from machine_restart+0x34/0x58 [ 13.001050] machine_restart from panic+0x2a8/0x32c
Use !preemptible() instead, which is basically the same check as pre-v5.2.
--- drivers/i2c/i2c-core.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/i2c-core.h +1 -1
@@ -29,7 +29,7 @@ int i2c_dev_irq_from_resources(const str*/ static inline bool i2c_in_atomic_xfer_mode (void ) { -return system_state >SYSTEM_RUNNING &&irqs_disabled (); +return system_state >SYSTEM_RUNNING && !preemptible (); }static inline int __i2c_lock_bus_helper (struct i2c_adapter *adap)
Greg Kroah-Hartman
maintainerPATCH 216/297 tracing: Have the user copy of synthetic event address use correct context
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steven Rostedt (Google) <[email protected]>
commit 4f7969bcd6d33042d62e249b41b5578161e4c868 upstream.
A synthetic event is created by the synthetic event interface that can read both user or kernel address memory. In reality, it reads any arbitrary memory location from within the kernel. If the address space is in USER (where CONFIG_ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE is set) then it uses strncpy_from_user_nofault() to copy strings otherwise it uses strncpy_from_kernel_nofault().
But since both functions use the same variable there's no annotation to what that variable is (ie. __user). This makes sparse complain.
Quiet sparse by typecasting the strncpy_from_user_nofault() variable to a __user pointer.
--- kernel/trace/trace_events_synth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace_events_synth.c +1 -1
@@ -454,7 +454,7 @@ static unsigned int trace_string(struct#ifdef CONFIG_ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE if ((unsigned long )str_val <TASK_SIZE ) - ret =strncpy_from_user_nofault (str_field, str_val,STR_VAR_LEN_MAX ); + ret =strncpy_from_user_nofault (str_field, (const void __user *)str_val,STR_VAR_LEN_MAX ); else#endif ret =strncpy_from_kernel_nofault (str_field, str_val,STR_VAR_LEN_MAX );
Greg Kroah-Hartman
maintainerPATCH 217/297 mcb: fix error handling for different scenarios when parsing
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sanjuán García, Jorge <[email protected]>
commit 63ba2d07b4be72b94216d20561f43e1150b25d98 upstream.
chameleon_parse_gdd() may fail for different reasons and end up in the err tag. Make sure we at least always free the mcb_device allocated with mcb_alloc_dev().
If mcb_device_register() fails, make sure to give up the reference in the same place the device was added.
--- drivers/mcb/mcb-core.c | 1 + drivers/mcb/mcb-parse.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/mcb/mcb-core.c +1 -0
@@ -246,6 +246,7 @@ int mcb_device_register(struct mcb_bus *return 0 ; out: +put_device (&dev->dev);return ret; }
drivers/mcb/mcb-parse.c +1 -1
@@ -106,7 +106,7 @@ static int chameleon_parse_gdd(struct mcreturn 0 ; err: -put_device (&mdev->dev); +mcb_free_dev (mdev);return ret; }
Greg Kroah-Hartman
maintainerPATCH 218/297 dmaengine: stm32-mdma: correct desc prep when channel running
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alain Volmat <[email protected]>
commit 03f25d53b145bc2f7ccc82fc04e4482ed734f524 upstream.
In case of the prep descriptor while the channel is already running, the CCR register value stored into the channel could already have its EN bit set. This would lead to a bad transfer since, at start transfer time, enabling the channel while other registers aren't yet properly set. To avoid this, ensure to mask the CCR_EN bit when storing the ccr value into the mdma channel structure.
--- drivers/dma/stm32-mdma.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/dma/stm32-mdma.c +2 -2
@@ -509,7 +509,7 @@ static int stm32_mdma_set_xfer_param(str src_maxburst = chan->dma_config.src_maxburst; dst_maxburst = chan->dma_config.dst_maxburst; - ccr =stm32_mdma_read (dmadev,STM32_MDMA_CCR (chan->id)); + ccr =stm32_mdma_read (dmadev,STM32_MDMA_CCR (chan->id)) & ~STM32_MDMA_CCR_EN ; ctcr =stm32_mdma_read (dmadev,STM32_MDMA_CTCR (chan->id)); ctbr =stm32_mdma_read (dmadev,STM32_MDMA_CTBR (chan->id));
@@ -937,7 +937,7 @@ stm32_mdma_prep_dma_memcpy(struct dma_chif (!desc)return NULL ; - ccr =stm32_mdma_read (dmadev,STM32_MDMA_CCR (chan->id)); + ccr =stm32_mdma_read (dmadev,STM32_MDMA_CCR (chan->id)) & ~STM32_MDMA_CCR_EN ; ctcr =stm32_mdma_read (dmadev,STM32_MDMA_CTCR (chan->id)); ctbr =stm32_mdma_read (dmadev,STM32_MDMA_CTBR (chan->id)); cbndtr =stm32_mdma_read (dmadev,STM32_MDMA_CBNDTR (chan->id));
Greg Kroah-Hartman
maintainerPATCH 219/297 s390/cmma: fix initial kernel address space page table walk
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiko Carstens <[email protected]>
commit 16ba44826a04834d3eeeda4b731c2ea3481062b7 upstream.
If the cmma no-dat feature is available the kernel page tables are walked to identify and mark all pages which are used for address translation (all region, segment, and page tables). In a subsequent loop all other pages are marked as "no-dat" pages with the ESSA instruction.
This information is visible to the hypervisor, so that the hypervisor can optimize purging of guest TLB entries. The initial loop however does not cover the complete kernel address space. This can result in pages being marked as not being used for dynamic address translation, even though they are. In turn guest TLB entries incorrectly may not be purged.
Fix this by adjusting the end address of the kernel address range being walked.
--- arch/s390/mm/page-states.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
arch/s390/mm/page-states.c +10 -3
@@ -161,15 +161,22 @@ static void mark_kernel_p4d(pgd_t *pgd,static void mark_kernel_pgd (void ) { -unsigned long addr, next; +unsigned long addr, next, max_addr;struct page *page;pgd_t *pgd;int i; addr =0 ; +/* +* Figure out maximum virtual address accessible with the +* kernel ASCE. This is required to keep the page table walker +* from accessing non-existent entries. +*/ + max_addr = (S390_lowcore.kernel_asce.val & _ASCE_TYPE_MASK) >>2 ; + max_addr =1UL << (max_addr *11 +31 ); pgd =pgd_offset_k (addr); do { - next = pgd_addr_end(addr, MODULES_END); + next = pgd_addr_end(addr, max_addr); if (pgd_none(*pgd)) continue; if (!pgd_folded(*pgd)) {
@@ -178,7 +185,7 @@ static void mark_kernel_pgd(void)set_bit (PG_arch_1, &page[i].flags); }mark_kernel_p4d (pgd, addr, next); - }while (pgd++, addr = next, addr !=MODULES_END ); + }while (pgd++, addr = next, addr != max_addr); }void __init cmma_init_nodat (void )
Greg Kroah-Hartman
maintainerPATCH 220/297 s390/cmma: fix detection of DAT pages
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiko Carstens <[email protected]>
commit 44d93045247661acbd50b1629e62f415f2747577 upstream.
If the cmma no-dat feature is available the kernel page tables are walked to identify and mark all pages which are used for address translation (all region, segment, and page tables). In a subsequent loop all other pages are marked as "no-dat" pages with the ESSA instruction.
This information is visible to the hypervisor, so that the hypervisor can optimize purging of guest TLB entries. The initial loop however is
incorrect: only the first three of the four pages which belong to segment and region tables will be marked as being used for DAT. The last page is incorrectly marked as no-dat.
This can result in incorrect guest TLB flushes.
Fix this by simply marking all four pages.
--- arch/s390/mm/page-states.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/s390/mm/page-states.c +3 -3
@@ -131,7 +131,7 @@ static void mark_kernel_pud(p4d_t *p4d,continue ;if (!pud_folded (*pud)) { page =phys_to_page (pud_val (*pud)); -for (i =0 ; i <3 ; i++) +for (i =0 ; i <4 ; i++)set_bit (PG_arch_1, &page[i].flags); }mark_kernel_pmd (pud, addr, next);
@@ -152,7 +152,7 @@ static void mark_kernel_p4d(pgd_t *pgd,continue ;if (!p4d_folded (*p4d)) { page =phys_to_page (p4d_val (*p4d)); -for (i =0 ; i <3 ; i++) +for (i =0 ; i <4 ; i++)set_bit (PG_arch_1, &page[i].flags); }mark_kernel_pud (p4d, addr, next);
@@ -181,7 +181,7 @@ static void mark_kernel_pgd(void)continue ;if (!pgd_folded (*pgd)) { page =phys_to_page (pgd_val (*pgd)); -for (i =0 ; i <3 ; i++) +for (i =0 ; i <4 ; i++)set_bit (PG_arch_1, &page[i].flags); }mark_kernel_p4d (pgd, addr, next);
Greg Kroah-Hartman
maintainerPATCH 221/297 s390/cmma: fix handling of swapper_pg_dir and invalid_pg_dir
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiko Carstens <[email protected]>
commit 84bb41d5df48868055d159d9247b80927f1f70f9 upstream.
If the cmma no-dat feature is available the kernel page tables are walked to identify and mark all pages which are used for address translation (all region, segment, and page tables). In a subsequent loop all other pages are marked as "no-dat" pages with the ESSA instruction.
This information is visible to the hypervisor, so that the hypervisor can optimize purging of guest TLB entries. All pages used for swapper_pg_dir and invalid_pg_dir are incorrectly marked as no-dat, which in turn can result in incorrect guest TLB flushes.
Fix this by marking those pages correctly as being used for DAT.
--- arch/s390/mm/page-states.c | 6 ++++++ 1 file changed, 6 insertions(+)
arch/s390/mm/page-states.c +6 -0
@@ -198,6 +198,12 @@ void __init cmma_init_nodat(void)return ;/* Mark pages used in kernel page tables */ mark_kernel_pgd (); + page =virt_to_page (&swapper_pg_dir); +for (i =0 ; i <4 ; i++) +set_bit (PG_arch_1, &page[i].flags); + page =virt_to_page (&invalid_pg_dir); +for (i =0 ; i <4 ; i++) +set_bit (PG_arch_1, &page[i].flags);/* Set all kernel pages not used for page tables to stable/no-dat */ for_each_mem_pfn_range (i,MAX_NUMNODES , &start, &end,NULL ) {
Greg Kroah-Hartman
maintainerPATCH 222/297 mm/cma: use nth_page() in place of direct struct page manipulation
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zi Yan <[email protected]>
commit 2e7cfe5cd5b6b0b98abf57a3074885979e187c1c upstream.
Patch series "Use nth_page() in place of direct struct page manipulation", v3.
On SPARSEMEM without VMEMMAP, struct page is not guaranteed to be contiguous, since each memory section's memmap might be allocated independently. hugetlb pages can go beyond a memory section size, thus direct struct page manipulation on hugetlb pages/subpages might give wrong struct page. Kernel provides nth_page() to do the manipulation properly. Use that whenever code can see hugetlb pages.
This patch (of 5):
When dealing with hugetlb pages, manipulating struct page pointers directly can get to wrong struct page, since struct page is not guaranteed to be contiguous on SPARSEMEM without VMEMMAP. Use nth_page() to handle it properly.
Without the fix, page_kasan_tag_reset() could reset wrong page tags, causing a wrong kasan result. No related bug is reported. The fix comes from code inspection.
--- mm/cma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/cma.c +1 -1
@@ -503,7 +503,7 @@ struct page *cma_alloc(struct cma *cma,*/ if (page) {for (i =0 ; i < count; i++) -page_kasan_tag_reset (page + i); +page_kasan_tag_reset (nth_page (page, i)); }if (ret && !no_warn) {
Greg Kroah-Hartman
maintainerPATCH 223/297 mm/memory_hotplug: use pfn math in place of direct struct page manipulation
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zi Yan <[email protected]>
commit 1640a0ef80f6d572725f5b0330038c18e98ea168 upstream.
When dealing with hugetlb pages, manipulating struct page pointers directly can get to wrong struct page, since struct page is not guaranteed to be contiguous on SPARSEMEM without VMEMMAP. Use pfn calculation to handle it properly.
Without the fix, a wrong number of page might be skipped. Since skip cannot be negative, scan_movable_page() will end early and might miss a movable page with -ENOENT. This might fail offline_pages(). No bug is reported. The fix comes from code inspection.
--- mm/memory_hotplug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/memory_hotplug.c +1 -1
@@ -1677,7 +1677,7 @@ static int scan_movable_pages(unsigned l*/ if (HPageMigratable (head)) goto found; - skip =compound_nr (head) - (page - head); + skip =compound_nr (head) - (pfn -page_to_pfn (head)); pfn += skip -1 ; }return -ENOENT ;
Greg Kroah-Hartman
maintainerPATCH 224/297 mtd: cfi_cmdset_0001: Byte swap OTP info
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
commit 565fe150624ee77dc63a735cc1b3bff5101f38a3 upstream.
Currently the offset into the device when looking for OTP bits can go outside of the address of the MTD NOR devices, and if that memory isn't readable, bad things happen on the IXP4xx (added prints that illustrate the problem before the crash):
cfi_intelext_otp_walk walk OTP on chip 0 start at reg_prot_offset 0x00000100 ixp4xx_copy_from copy from 0x00000100 to 0xc880dd78 cfi_intelext_otp_walk walk OTP on chip 0 start at reg_prot_offset 0x12000000 ixp4xx_copy_from copy from 0x12000000 to 0xc880dd78
8<--- cut here ---
Unable to handle kernel paging request at virtual address db000000
[db000000] *pgd=00000000
(...)
This happens in this case because the IXP4xx is big endian and the 32- and 16-bit fields in the struct cfi_intelext_otpinfo are not properly byteswapped. Compare to how the code in read_pri_intelext() byteswaps the fields in struct cfi_pri_intelext.
Adding a small byte swapping loop for the OTP in read_pri_intelext() and the crash goes away.
The problem went unnoticed for many years until I enabled CONFIG_MTD_OTP on the IXP4xx as well, triggering the bug.
--- drivers/mtd/chips/cfi_cmdset_0001.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)
drivers/mtd/chips/cfi_cmdset_0001.c +18 -2
@@ -421,9 +421,25 @@ read_pri_intelext(struct map_info *map, extra_size =0 ;/* Protection Register info */ -if (extp->NumProtectionFields) +if (extp->NumProtectionFields) { +struct cfi_intelext_otpinfo *otp = + (struct cfi_intelext_otpinfo *)&extp->extra[0 ]; + extra_size += (extp->NumProtectionFields -1 ) * -sizeof (struct cfi_intelext_otpinfo ); +sizeof (struct cfi_intelext_otpinfo ); + +if (extp_size >=sizeof (*extp) + extra_size) { +int i; + +/* Do some byteswapping if necessary */ +for (i =0 ; i < extp->NumProtectionFields -1 ; i++) { + otp->ProtRegAddr =le32_to_cpu (otp->ProtRegAddr); + otp->FactGroups =le16_to_cpu (otp->FactGroups); + otp->UserGroups =le16_to_cpu (otp->UserGroups); + otp++; + } + } + } }if (extp->MinorVersion >='1' ) {
Greg Kroah-Hartman
maintainerPATCH 225/297 i3c: master: cdns: Fix reading status register
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joshua Yeong <[email protected]>
commit 4bd8405257da717cd556f99e5fb68693d12c9766 upstream.
IBIR_DEPTH and CMDR_DEPTH should read from status0 instead of status1.
--- drivers/i3c/master/i3c-master-cdns.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/i3c/master/i3c-master-cdns.c +3 -3
@@ -192,7 +192,7 @@#define SLV_STATUS1_HJ_DIS BIT(18)#define SLV_STATUS1_MR_DIS BIT(17)#define SLV_STATUS1_PROT_ERR BIT(16) -#define SLV_STATUS1_DA (x) (((s) & GENMASK(15, 9)) >> 9) +#define SLV_STATUS1_DA (s) (((s) & GENMASK(15, 9)) >> 9)#define SLV_STATUS1_HAS_DA BIT(8)#define SLV_STATUS1_DDR_RX_FULL BIT(7)#define SLV_STATUS1_DDR_TX_FULL BIT(6)
@@ -1624,13 +1624,13 @@ static int cdns_i3c_master_probe(struct/* Device ID0 is reserved to describe this master. */ master->maxdevs =CONF_STATUS0_DEVS_NUM (val); master->free_rr_slots =GENMASK (master->maxdevs,1 ); + master->caps.ibirfifodepth =CONF_STATUS0_IBIR_DEPTH (val); + master->caps.cmdrfifodepth =CONF_STATUS0_CMDR_DEPTH (val); val =readl (master->regs +CONF_STATUS1 ); master->caps.cmdfifodepth =CONF_STATUS1_CMD_DEPTH (val); master->caps.rxfifodepth =CONF_STATUS1_RX_DEPTH (val); master->caps.txfifodepth =CONF_STATUS1_TX_DEPTH (val); - master->caps.ibirfifodepth =CONF_STATUS0_IBIR_DEPTH (val); - master->caps.cmdrfifodepth =CONF_STATUS0_CMDR_DEPTH (val);spin_lock_init (&master->ibi.lock); master->ibi.num_slots =CONF_STATUS1_IBI_HW_RES (val);
Greg Kroah-Hartman
maintainerPATCH 226/297 i3c: master: svc: fix race condition in ibi work thread
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Frank Li <[email protected]>
commit 6bf3fc268183816856c96b8794cd66146bc27b35 upstream.
The ibi work thread operates asynchronously with other transfers, such as svc_i3c_master_priv_xfers(). Introduce mutex protection to ensure the completion of the entire i3c/i2c transaction.
--- drivers/i3c/master/svc-i3c-master.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
drivers/i3c/master/svc-i3c-master.c +14 -0
@@ -165,6 +165,7 @@ struct svc_i3c_xfer {* @ibi.slots: Available IBI slots * @ibi.tbq_slot: To be queued IBI slot * @ibi.lock: IBI lock +* @lock: Transfer lock, protect between IBI work thread and callbacks from master */ struct svc_i3c_master {struct i3c_master_controller base;
@@ -192,6 +193,7 @@ struct svc_i3c_master {/* Prevent races within IBI handlers */ spinlock_t lock; } ibi; +struct mutex lock; };/**
@@ -345,6 +347,7 @@ static void svc_i3c_master_ibi_work(struu32 status, val;int ret; +mutex_lock (&master->lock);/* Acknowledge the incoming interrupt with the AUTOIBI mechanism */ writel(SVC_I3C_MCTRL_REQUEST_AUTO_IBI | SVC_I3C_MCTRL_IBIRESP_AUTO,
@@ -421,6 +424,7 @@ static void svc_i3c_master_ibi_work(stru reenable_ibis:svc_i3c_master_enable_interrupts (master,SVC_I3C_MINT_SLVSTART ); +mutex_unlock (&master->lock); }static irqreturn_t svc_i3c_master_irq_handler (int irq,void *dev_id)
@@ -1095,9 +1099,11 @@ static int svc_i3c_master_send_bdcast_cc cmd->read_len =0 ; cmd->continued = false; +mutex_lock (&master->lock);svc_i3c_master_enqueue_xfer (master, xfer);if (!wait_for_completion_timeout (&xfer->comp,msecs_to_jiffies (1000 )))svc_i3c_master_dequeue_xfer (master, xfer); +mutex_unlock (&master->lock); ret = xfer->ret;kfree (buf);
@@ -1141,9 +1147,11 @@ static int svc_i3c_master_send_direct_cc cmd->read_len = read_len; cmd->continued = false; +mutex_lock (&master->lock);svc_i3c_master_enqueue_xfer (master, xfer);if (!wait_for_completion_timeout (&xfer->comp,msecs_to_jiffies (1000 )))svc_i3c_master_dequeue_xfer (master, xfer); +mutex_unlock (&master->lock); ret = xfer->ret;svc_i3c_master_free_xfer (xfer);
@@ -1197,9 +1205,11 @@ static int svc_i3c_master_priv_xfers(str cmd->continued = (i +1 ) < nxfers; } +mutex_lock (&master->lock);svc_i3c_master_enqueue_xfer (master, xfer);if (!wait_for_completion_timeout (&xfer->comp,msecs_to_jiffies (1000 )))svc_i3c_master_dequeue_xfer (master, xfer); +mutex_unlock (&master->lock); ret = xfer->ret;svc_i3c_master_free_xfer (xfer);
@@ -1235,9 +1245,11 @@ static int svc_i3c_master_i2c_xfers(stru cmd->continued = (i +1 < nxfers); } +mutex_lock (&master->lock);svc_i3c_master_enqueue_xfer (master, xfer);if (!wait_for_completion_timeout (&xfer->comp,msecs_to_jiffies (1000 )))svc_i3c_master_dequeue_xfer (master, xfer); +mutex_unlock (&master->lock); ret = xfer->ret;svc_i3c_master_free_xfer (xfer);
@@ -1407,6 +1419,8 @@ static int svc_i3c_master_probe(struct pINIT_WORK (&master->hj_work, svc_i3c_master_hj_work);INIT_WORK (&master->ibi_work, svc_i3c_master_ibi_work); +mutex_init (&master->lock); + ret =devm_request_irq (dev, master->irq, svc_i3c_master_irq_handler,IRQF_NO_SUSPEND ,"svc-i3c-irq" , master);if (ret)
Greg Kroah-Hartman
maintainerPATCH 227/297 i3c: master: svc: fix wrong data return when IBI happen during start frame
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Frank Li <[email protected]>
commit 5e5e3c92e748a6d859190e123b9193cf4911fcca upstream.
┌─────┐ ┏──┐ ┏──┐ ┏──┐ ┏──┐ ┏──┐ ┏──┐ ┏──┐ ┏──┐ ┌─────
SCL: ┘ └─────┛ └──┛ └──┛ └──┛ └──┛ └──┛ └──┛ └──┛ └──┘
───┐ ┌─────┐ ┌─────┐ ┌───────────┐
SDA: └───────────────────────┘ └─────┘ └─────┘ └─────
xxx╱ ╲╱ ╲╱ ╲╱ ╲╱ ╲
: xxx╲IBI ╱╲ Addr(0x0a) ╱╲ RW ╱╲NACK╱╲ S ╱If an In-Band Interrupt (IBI) occurs and IBI work thread is not immediately scheduled, when svc_i3c_master_priv_xfers() initiates the I3C transfer and attempts to send address 0x7e, the target interprets it as an IBI handler and returns the target address 0x0a.
However, svc_i3c_master_priv_xfers() does not handle this case and proceeds with other transfers, resulting in incorrect data being returned.
Add IBIWON check in svc_i3c_master_xfer(). In case this situation occurs, return a failure to the driver.
--- drivers/i3c/master/svc-i3c-master.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
drivers/i3c/master/svc-i3c-master.c +20 -0
@@ -930,6 +930,9 @@ static int svc_i3c_master_xfer(struct svu32 reg;int ret; +/* clean SVC_I3C_MINT_IBIWON w1c bits */ +writel (SVC_I3C_MINT_IBIWON , master->regs +SVC_I3C_MSTATUS ); + writel(SVC_I3C_MCTRL_REQUEST_START_ADDR | xfer_type | SVC_I3C_MCTRL_IBIRESP_NACK |
@@ -943,6 +946,23 @@ static int svc_i3c_master_xfer(struct svif (ret) goto emit_stop; +/* +* According to I3C spec ver 1.1.1, 5.1.2.2.3 Consequence of Controller Starting a Frame +* with I3C Target Address. +* +* The I3C Controller normally should start a Frame, the Address may be arbitrated, and so +* the Controller shall monitor to see whether an In-Band Interrupt request, a Controller +* Role Request (i.e., Secondary Controller requests to become the Active Controller), or +* a Hot-Join Request has been made. +* +* If missed IBIWON check, the wrong data will be return. When IBIWON happen, return failure +* and yield the above events handler. +*/ +if (SVC_I3C_MSTATUS_IBIWON (reg)) { + ret = -ENXIO ; + goto emit_stop; + } +if (rnw) ret =svc_i3c_master_read (master, in, xfer_len);else
Greg Kroah-Hartman
maintainerPATCH 228/297 i3c: master: svc: fix ibi may not return mandatory data byte
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Frank Li <[email protected]>
commit c85e209b799f12d18a90ae6353b997b1bb1274a5 upstream.
MSTATUS[RXPEND] is only updated after the data transfer cycle started. This creates an issue when the I3C clock is slow, and the CPU is running fast enough that MSTATUS[RXPEND] may not be updated when the code reaches checking point. As a result, mandatory data can be missed.
Add a wait for MSTATUS[COMPLETE] to ensure that all mandatory data is already in FIFO. It also works without mandatory data.
--- drivers/i3c/master/svc-i3c-master.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/i3c/master/svc-i3c-master.c +8 -0
@@ -294,6 +294,7 @@ static int svc_i3c_master_handle_ibi(strstruct i3c_ibi_slot *slot;unsigned int count;u32 mdatactrl; +int ret, val;u8 *buf; slot =i3c_generic_ibi_get_free_slot (data->ibi_pool);
@@ -303,6 +304,13 @@ static int svc_i3c_master_handle_ibi(str slot->len =0 ; buf = slot->data; + ret =readl_relaxed_poll_timeout (master->regs +SVC_I3C_MSTATUS , val, +SVC_I3C_MSTATUS_COMPLETE (val),0 ,1000 ); +if (ret) { +dev_err (master->dev,"Timeout when polling for COMPLETE\n" ); +return ret; + } +while (SVC_I3C_MSTATUS_RXPEND (readl (master->regs +SVC_I3C_MSTATUS )) && slot->len <SVC_I3C_FIFO_SIZE ) { mdatactrl =readl (master->regs +SVC_I3C_MDATACTRL );
Greg Kroah-Hartman
maintainerPATCH 229/297 i3c: master: svc: fix check wrong status register in irq handler
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Frank Li <[email protected]>
commit 225d5ef048c4ed01a475c95d94833bd7dd61072d upstream.
svc_i3c_master_irq_handler() wrongly checks register SVC_I3C_MINTMASKED. It should be SVC_I3C_MSTATUS.
--- drivers/i3c/master/svc-i3c-master.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i3c/master/svc-i3c-master.c +1 -1
@@ -438,7 +438,7 @@ reenable_ibis:static irqreturn_t svc_i3c_master_irq_handler (int irq,void *dev_id) {struct svc_i3c_master *master = (struct svc_i3c_master *)dev_id; -u32 active =readl (master->regs +SVC_I3C_MINTMASKED ); +u32 active =readl (master->regs +SVC_I3C_MSTATUS );if (!SVC_I3C_MSTATUS_SLVSTART (active))return IRQ_NONE ;
Greg Kroah-Hartman
maintainerPATCH 230/297 i3c: master: svc: fix SDA keep low when polling IBIWON timeout happen
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Frank Li <[email protected]>
commit dfd7cd6aafdb1f5ba93828e97e56b38304b23a05 upstream.
Upon IBIWON timeout, the SDA line will always be kept low if we don't emit a stop. Calling svc_i3c_master_emit_stop() there will let the bus return to idle state.
--- drivers/i3c/master/svc-i3c-master.c | 1 + 1 file changed, 1 insertion(+)
drivers/i3c/master/svc-i3c-master.c +1 -0
@@ -366,6 +366,7 @@ static void svc_i3c_master_ibi_work(stru SVC_I3C_MSTATUS_IBIWON(val), 0, 1000);if (ret) {dev_err (master->dev,"Timeout when polling for IBIWON\n" ); +svc_i3c_master_emit_stop (master); goto reenable_ibis; }
Greg Kroah-Hartman
maintainerPATCH 231/297 parisc: Prevent booting 64-bit kernels on PA1.x machines
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Helge Deller <[email protected]>
commit a406b8b424fa01f244c1aab02ba186258448c36b upstream.
Bail out early with error message when trying to boot a 64-bit kernel on 32-bit machines. This fixes the previous commit to include the check for true 64-bit kernels as well.
--- arch/parisc/kernel/head.S | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
arch/parisc/kernel/head.S +2 -3
@@ -69,9 +69,8 @@ $bss_loop: stw,ma %arg2,4(%r1) stw,ma %arg3,4(%r1) -#if !defined(CONFIG_64BIT) && defined(CONFIG_PA20) - /* This 32-bit kernel was compiled for PA2.0 CPUs. Check current CPU - * and halt kernel if we detect a PA1.x CPU. */ +#if defined(CONFIG_PA20) + /* check for 64-bit capable CPU as required by current kernel */ ldi 32,%r10 mtctl %r10,%cr11 .level 2.0
Greg Kroah-Hartman
maintainerPATCH 232/297 parisc/pgtable: Do not drop upper 5 address bits of physical address
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Helge Deller <[email protected]>
commit 166b0110d1ee53290bd11618df6e3991c117495a upstream.
When calculating the pfn for the iitlbt/idtlbt instruction, do not drop the upper 5 address bits. This doesn't seem to have an effect on physical hardware which uses less physical address bits, but in qemu the missing bits are visible.
--- arch/parisc/kernel/entry.S | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
arch/parisc/kernel/entry.S +3 -4
@@ -497,13 +497,13 @@ * to a CPU TLB 4k PFN (4k => 12 bits to shift) */ #define PAGE_ADD_SHIFT (PAGE_SHIFT-12) #define PAGE_ADD_HUGE_SHIFT (REAL_HPAGE_SHIFT-12) + #define PFN_START_BIT (63-ASM_PFN_PTE_SHIFT+(63-58)-PAGE_ADD_SHIFT) /* Drop prot bits and convert to page addr for iitlbt and idtlbt */ .macro convert_for_tlb_insert20 pte,tmp #ifdef CONFIG_HUGETLB_PAGE copy \pte,\tmp - extrd,u \tmp,(63-ASM_PFN_PTE_SHIFT)+(63-58)+PAGE_ADD_SHIFT,\ - 64-PAGE_SHIFT-PAGE_ADD_SHIFT,\pte + extrd,u \tmp,PFN_START_BIT,PFN_START_BIT+1,\pte depdi _PAGE_SIZE_ENCODING_DEFAULT,63,\ (63-58)+PAGE_ADD_SHIFT,\pte
@@ -511,8 +511,7 @@ depdi _HUGE_PAGE_SIZE_ENCODING_DEFAULT,63,\ (63-58)+PAGE_ADD_HUGE_SHIFT,\pte #else /* Huge pages disabled */ - extrd,u \pte,(63-ASM_PFN_PTE_SHIFT)+(63-58)+PAGE_ADD_SHIFT,\ - 64-PAGE_SHIFT-PAGE_ADD_SHIFT,\pte + extrd,u \pte,PFN_START_BIT,PFN_START_BIT+1,\pte depdi _PAGE_SIZE_ENCODING_DEFAULT,63,\ (63-58)+PAGE_ADD_SHIFT,\pte #endif
Greg Kroah-Hartman
maintainerPATCH 233/297 parisc/power: Fix power soft-off when running on qemu
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Helge Deller <[email protected]>
commit 6ad6e15a9c46b8f0932cd99724f26f3db4db1cdf upstream.
Firmware returns the physical address of the power switch, so need to use gsc_writel() instead of direct memory access.
--- drivers/parisc/power.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/parisc/power.c +1 -1
@@ -201,7 +201,7 @@ static struct notifier_block parisc_panistatic int qemu_power_off (struct sys_off_data *data) {/* this turns the system off via SeaBIOS */ - *(int *)data->cb_data =0 ; +gsc_writel (0 , (unsigned long ) data->cb_data);pdc_soft_power_button (1 );return NOTIFY_DONE ; }
Greg Kroah-Hartman
maintainerPATCH 234/297 xhci: Enable RPM on controllers that support low-power states
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Basavaraj Natikar <[email protected]>
commit a5d6264b638efeca35eff72177fd28d149e0764b upstream.
Use the low-power states of the underlying platform to enable runtime PM. If the platform doesn't support runtime D3, then enabling default RPM will result in the controller malfunctioning, as in the case of hotplug devices not being detected because of a failed interrupt generation.
--- drivers/usb/host/xhci-pci.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/usb/host/xhci-pci.c +3 -1
@@ -509,7 +509,9 @@ static int xhci_pci_probe(struct pci_dev/* USB-2 and USB-3 roothubs initialized, allow runtime pm suspend */ pm_runtime_put_noidle (&dev->dev); -if (xhci->quirks &XHCI_DEFAULT_PM_RUNTIME_ALLOW ) +if (pci_choose_state (dev,PMSG_SUSPEND ) ==PCI_D0 ) +pm_runtime_forbid (&dev->dev); +else if (xhci->quirks &XHCI_DEFAULT_PM_RUNTIME_ALLOW )pm_runtime_allow (&dev->dev);dma_set_max_seg_size (&dev->dev,UINT_MAX );
Greg Kroah-Hartman
maintainerPATCH 235/297 ALSA: info: Fix potential deadlock at disconnection
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit c7a60651953359f98dbf24b43e1bf561e1573ed4 upstream.
As reported recently, ALSA core info helper may cause a deadlock at the forced device disconnection during the procfs operation.
The proc_remove() (that is called from the snd_card_disconnect() helper) has a synchronization of the pending procfs accesses via wait_for_completion(). Meanwhile, ALSA procfs helper takes the global mutex_lock(&info_mutex) at both the proc_open callback and snd_card_info_disconnect() helper. Since the proc_open can't finish due to the mutex lock, wait_for_completion() never returns, either, hence it deadlocks.
TASK#1 TASK#2 proc_reg_open() takes use_pde() snd_info_text_entry_open() snd_card_disconnect() snd_info_card_disconnect() takes mutex_lock(&info_mutex) proc_remove() wait_for_completion(unused_pde) ... waiting task#1 closes mutex_lock(&info_mutex) => DEADLOCK
This patch is a workaround for avoiding the deadlock scenario above.
The basic strategy is to move proc_remove() call outside the mutex lock. proc_remove() can work gracefully without extra locking, and it can delete the tree recursively alone. So, we call proc_remove() at snd_info_card_disconnection() at first, then delete the rest resources recursively within the info_mutex lock.
After the change, the function snd_info_disconnect() doesn't do disconnection by itself any longer, but it merely clears the procfs pointer. So rename the function to snd_info_clear_entries() for avoiding confusion.
The similar change is applied to snd_info_free_entry(), too. Since the proc_remove() is called only conditionally with the non-NULL entry->p, it's skipped after the snd_info_clear_entries() call.
--- sound/core/info.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-)
sound/core/info.c +13 -8
@@ -56,7 +56,7 @@ struct snd_info_private_data { };static int snd_info_version_init (void ); -static void snd_info_disconnect (struct snd_info_entry *entry); +static void snd_info_clear_entries (struct snd_info_entry *entry);/*
@@ -569,11 +569,16 @@ void snd_info_card_disconnect(struct snd {if (!card)return ; -mutex_lock (&info_mutex); +proc_remove (card->proc_root_link); - card->proc_root_link =NULL ;if (card->proc_root) -snd_info_disconnect (card->proc_root); +proc_remove (card->proc_root->p); + +mutex_lock (&info_mutex); +if (card->proc_root) +snd_info_clear_entries (card->proc_root); + card->proc_root_link =NULL ; + card->proc_root =NULL ;mutex_unlock (&info_mutex); }
@@ -745,15 +750,14 @@ struct snd_info_entry *snd_info_create_c }EXPORT_SYMBOL (snd_info_create_card_entry); -static void snd_info_disconnect (struct snd_info_entry *entry) +static void snd_info_clear_entries (struct snd_info_entry *entry) {struct snd_info_entry *p;if (!entry->p)return ;list_for_each_entry (p, &entry->children, list) -snd_info_disconnect (p); -proc_remove (entry->p); +snd_info_clear_entries (p); entry->p =NULL ; }
@@ -770,8 +774,9 @@ void snd_info_free_entry(struct snd_infoif (!entry)return ;if (entry->p) { +proc_remove (entry->p);mutex_lock (&info_mutex); -snd_info_disconnect (entry); +snd_info_clear_entries (entry);mutex_unlock (&info_mutex); }
Greg Kroah-Hartman
maintainerPATCH 236/297 ALSA: hda/realtek - Add Dell ALC295 to pin fall back table
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kailang Yang <[email protected]>
commit 4b21a669ca21ed8f24ef4530b2918be5730114de upstream.
Add ALC295 to pin fall back table.
Remove 5 pin quirks for Dell ALC295.
ALC295 was only support MIC2 for external MIC function. ALC295 assigned model "ALC269_FIXUP_DELL1_MIC_NO_PRESENCE" for pin fall back table.
It was assigned wrong model. So, let's remove it.
--- sound/pci/hda/patch_realtek.c | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-)
sound/pci/hda/patch_realtek.c +3 -16
@@ -9963,22 +9963,6 @@ static const struct snd_hda_pin_quirk al {0x12, 0x90a60130}, {0x17, 0x90170110}, {0x21, 0x03211020}), -SND_HDA_PIN_QUIRK (0x10ec0295 ,0x1028 ,"Dell" ,ALC269_FIXUP_DELL4_MIC_NO_PRESENCE , - {0x14, 0x90170110}, - {0x21, 0x04211020}), -SND_HDA_PIN_QUIRK (0x10ec0295 ,0x1028 ,"Dell" ,ALC269_FIXUP_DELL4_MIC_NO_PRESENCE , - {0x14, 0x90170110}, - {0x21, 0x04211030}), -SND_HDA_PIN_QUIRK (0x10ec0295 ,0x1028 ,"Dell" ,ALC269_FIXUP_DELL1_MIC_NO_PRESENCE , -ALC295_STANDARD_PINS , - {0x17, 0x21014020}, - {0x18, 0x21a19030}), -SND_HDA_PIN_QUIRK (0x10ec0295 ,0x1028 ,"Dell" ,ALC269_FIXUP_DELL1_MIC_NO_PRESENCE , -ALC295_STANDARD_PINS , - {0x17, 0x21014040}, - {0x18, 0x21a19050}), -SND_HDA_PIN_QUIRK (0x10ec0295 ,0x1028 ,"Dell" ,ALC269_FIXUP_DELL1_MIC_NO_PRESENCE , -ALC295_STANDARD_PINS ),SND_HDA_PIN_QUIRK (0x10ec0298 ,0x1028 ,"Dell" ,ALC298_FIXUP_DELL1_MIC_NO_PRESENCE ,ALC298_STANDARD_PINS , {0x17, 0x90170110}),
@@ -10022,6 +10006,9 @@ static const struct snd_hda_pin_quirk alSND_HDA_PIN_QUIRK (0x10ec0289 ,0x1028 ,"Dell" ,ALC269_FIXUP_DELL4_MIC_NO_PRESENCE , {0x19, 0x40000000}, {0x1b, 0x40000000}), +SND_HDA_PIN_QUIRK (0x10ec0295 ,0x1028 ,"Dell" ,ALC269_FIXUP_DELL4_MIC_NO_PRESENCE , + {0x19, 0x40000000}, + {0x1b, 0x40000000}),SND_HDA_PIN_QUIRK (0x10ec0256 ,0x1028 ,"Dell" ,ALC255_FIXUP_DELL1_MIC_NO_PRESENCE , {0x19, 0x40000000}, {0x1a, 0x40000000}),
Greg Kroah-Hartman
maintainerPATCH 237/297 ALSA: hda/realtek - Enable internal speaker of ASUS K6500ZC
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandradeep Dey <[email protected]>
commit 713f040cd22285fcc506f40a0d259566e6758c3c upstream.
Apply the already existing quirk chain ALC294_FIXUP_ASUS_SPK to enable the internal speaker of ASUS K6500ZC.
--- sound/pci/hda/patch_realtek.c | 1 + 1 file changed, 1 insertion(+)
sound/pci/hda/patch_realtek.c +1 -0
@@ -9113,6 +9113,7 @@ static const struct snd_pci_quirk alc269SND_PCI_QUIRK (0x1043 ,0x10a1 ,"ASUS UX391UA" ,ALC294_FIXUP_ASUS_SPK ),SND_PCI_QUIRK (0x1043 ,0x10c0 ,"ASUS X540SA" ,ALC256_FIXUP_ASUS_MIC ),SND_PCI_QUIRK (0x1043 ,0x10d0 ,"ASUS X540LA/X540LJ" ,ALC255_FIXUP_ASUS_MIC_NO_PRESENCE ), +SND_PCI_QUIRK (0x1043 ,0x10d3 ,"ASUS K6500ZC" ,ALC294_FIXUP_ASUS_SPK ),SND_PCI_QUIRK (0x1043 ,0x115d ,"Asus 1015E" ,ALC269_FIXUP_LIMIT_INT_MIC_BOOST ),SND_PCI_QUIRK (0x1043 ,0x11c0 ,"ASUS X556UR" ,ALC255_FIXUP_ASUS_MIC_NO_PRESENCE ), SND_PCI_QUIRK(0x1043, 0x125e, "ASUS Q524UQK", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE),
Greg Kroah-Hartman
maintainerPATCH 238/297 serial: meson: Use platform_get_irq() to get the interrupt
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lad Prabhakar <[email protected]>
[ Upstream commit 5b68061983471470d4109bac776145245f06bc09 ]
platform_get_resource(pdev, IORESOURCE_IRQ, ..) relies on static allocation of IRQ resources in DT core code, this causes an issue when using hierarchical interrupt domains using "interrupts" property in the node as this bypasses the hierarchical setup and messes up the irq chaining.
In preparation for removal of static setup of IRQ resource from DT core code use platform_get_irq().
Stable-dep-of: 2a1d728f20ed ("tty: serial: meson: fix hard LOCKUP on crtscts mode")
--- drivers/tty/serial/meson_uart.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/tty/serial/meson_uart.c +6 -5
@@ -726,10 +726,11 @@ static int meson_uart_probe_clocks(struct platform_device *pdev,static int meson_uart_probe (struct platform_device *pdev) { -struct resource *res_mem, *res_irq; +struct resource *res_mem;struct uart_port *port;u32 fifosize =64 ;/* Default is 64, 128 for EE UART_0 */ int ret =0 ; +int irq;if (pdev->dev.of_node) pdev->id =of_alias_get_id (pdev->dev.of_node,"serial" );
@@ -752,9 +753,9 @@ static int meson_uart_probe(struct platform_device *pdev)if (!res_mem)return -ENODEV ; - res_irq =platform_get_resource (pdev,IORESOURCE_IRQ ,0 ); -if (!res_irq) -return -ENODEV ; + irq =platform_get_irq (pdev,0 ); +if (irq <0 ) +return irq;of_property_read_u32 (pdev->dev.of_node,"fifo-size" , &fifosize);
@@ -779,7 +780,7 @@ static int meson_uart_probe(struct platform_device *pdev) port->iotype =UPIO_MEM ; port->mapbase = res_mem->start; port->mapsize =resource_size (res_mem); - port->irq = res_irq->start; + port->irq = irq; port->flags =UPF_BOOT_AUTOCONF |UPF_LOW_LATENCY ; port->has_sysrq =IS_ENABLED (CONFIG_SERIAL_MESON_CONSOLE ); port->dev = &pdev->dev;
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 239/297 tty: serial: meson: fix hard LOCKUP on crtscts mode
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pavel Krasavin <[email protected]>
[ Upstream commit 2a1d728f20edeee7f26dc307ed9df4e0d23947ab ]
There might be hard lockup if we set crtscts mode on port without RTS/CTS configured:
# stty -F /dev/ttyAML6 crtscts; echo 1 > /dev/ttyAML6; echo 2 > /dev/ttyAML6 [ 95.890386] rcu: INFO: rcu_preempt detected stalls on CPUs/tasks: [ 95.890857] rcu: 3-...0: (201 ticks this GP) idle=e33c/1/0x4000000000000000 softirq=5844/5846 fqs=4984 [ 95.900212] rcu: (detected by 2, t=21016 jiffies, g=7753, q=296 ncpus=4) [ 95.906972] Task dump for CPU 3: [ 95.910178] task:bash state:R running task stack:0 pid:205 ppid:1 flags:0x00000202 [ 95.920059] Call trace: [ 95.922485] __switch_to+0xe4/0x168 [ 95.925951] 0xffffff8003477508 [ 95.974379] watchdog: Watchdog detected hard LOCKUP on cpu 3 [ 95.974424] Modules linked in: 88x2cs(O) rtc_meson_vrtc
Possible solution would be to not allow to setup crtscts on such port.
Tested on S905X3 based board.
v6: stable tag added
v5: https://lore.kernel.org/lkml/[email protected]/
added missed Reviewed-by tags, Fixes tag added according to Dmitry and Neil notes
v4: https://lore.kernel.org/lkml/[email protected]/
More correct patch subject according to Jiri's note
v3: https://lore.kernel.org/lkml/[email protected]/
"From:" line added to the mail
v2: https://lore.kernel.org/lkml/[email protected]/
braces for single statement removed according to Dmitry's note
v1: https://lore.kernel.org/lkml/[email protected]/
--- drivers/tty/serial/meson_uart.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
drivers/tty/serial/meson_uart.c +11 -3
@@ -368,10 +368,14 @@ static void meson_uart_set_termios(struct uart_port *port,else val |=AML_UART_STOP_BIT_1SB ; -if (cflags &CRTSCTS ) - val &= ~AML_UART_TWO_WIRE_EN ; -else +if (cflags &CRTSCTS ) { +if (port->flags &UPF_HARD_FLOW ) + val &= ~AML_UART_TWO_WIRE_EN ; +else + termios->c_cflag &= ~CRTSCTS ; + }else { val |=AML_UART_TWO_WIRE_EN ; + }writel (val, port->membase +AML_UART_CONTROL );
@@ -731,6 +735,7 @@ static int meson_uart_probe(struct platform_device *pdev)u32 fifosize =64 ;/* Default is 64, 128 for EE UART_0 */ int ret =0 ;int irq; +bool has_rtscts;if (pdev->dev.of_node) pdev->id =of_alias_get_id (pdev->dev.of_node,"serial" );
@@ -758,6 +763,7 @@ static int meson_uart_probe(struct platform_device *pdev)return irq;of_property_read_u32 (pdev->dev.of_node,"fifo-size" , &fifosize); + has_rtscts =of_property_read_bool (pdev->dev.of_node,"uart-has-rtscts" );if (meson_ports[pdev->id]) {dev_err (&pdev->dev,"port %d already allocated\n" , pdev->id);
@@ -782,6 +788,8 @@ static int meson_uart_probe(struct platform_device *pdev) port->mapsize =resource_size (res_mem); port->irq = irq; port->flags =UPF_BOOT_AUTOCONF |UPF_LOW_LATENCY ; +if (has_rtscts) + port->flags |=UPF_HARD_FLOW ; port->has_sysrq =IS_ENABLED (CONFIG_SERIAL_MESON_CONSOLE ); port->dev = &pdev->dev; port->line = pdev->id;
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 240/297 regmap: Ensure range selector registers are updated after cache sync
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mark Brown <[email protected]>
[ Upstream commit 0ec7731655de196bc1e4af99e495b38778109d22 ]
When we sync the register cache we do so with the cache bypassed in order to avoid overhead from writing the synced values back into the cache. If the regmap has ranges and the selector register for those ranges is in a register which is cached this has the unfortunate side effect of meaning that the physical and cached copies of the selector register can be out of sync after a cache sync. The cache will have whatever the selector was when the sync started and the hardware will have the selector for the register that was synced last.
Fix this by rewriting all cached selector registers after every sync, ensuring that the hardware and cache have the same content. This will result in extra writes that wouldn't otherwise be needed but is simple so hopefully robust. We don't read from the hardware since not all devices have physical read support.
Given that nobody noticed this until now it is likely that we are rarely if ever hitting this case.
--- drivers/base/regmap/regcache.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)
drivers/base/regmap/regcache.c +30 -0
@@ -325,6 +325,11 @@ static int regcache_default_sync(struct regmap *map, unsigned int min,return 0 ; } +static int rbtree_all (const void *key,const struct rb_node *node) +{ +return 0 ; +} +/** * regcache_sync - Sync the register cache with the hardware. *
@@ -342,6 +347,7 @@ int regcache_sync(struct regmap *map)unsigned int i;const char *name;bool bypass; +struct rb_node *node;if (WARN_ON (map->cache_type ==REGCACHE_NONE ))return -EINVAL ;
@@ -386,6 +392,30 @@ int regcache_sync(struct regmap *map) map->async = false; map->cache_bypass = bypass; map->no_sync_defaults = false; + +/* +* If we did any paging with cache bypassed and a cached +* paging register then the register and cache state might +* have gone out of sync, force writes of all the paging +* registers. +*/ +rb_for_each (node,0 , &map->range_tree, rbtree_all) { +struct regmap_range_node *this = + rb_entry(node, struct regmap_range_node, node); + +/* If there's nothing in the cache there's nothing to sync */ + ret =regcache_read (map, this->selector_reg, &i); +if (ret !=0 ) +continue ; + + ret =_regmap_write (map, this->selector_reg, i); +if (ret !=0 ) { +dev_err (map->dev,"Failed to write %x = %x: %d\n" , + this->selector_reg, i, ret); +break ; + } + } + map->unlock (map->lock_arg);regmap_async_complete (map);
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 241/297 cpufreq: stats: Fix buffer overflow detection in trans_stats()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Marangi <[email protected]>
[ Upstream commit ea167a7fc2426f7685c3735e104921c1a20a6d3f ]
Commit 3c0897c180c6 ("cpufreq: Use scnprintf() for avoiding potential buffer overflow") switched from snprintf to the more secure scnprintf but never updated the exit condition for PAGE_SIZE.
As the commit say and as scnprintf document, what scnprintf returns what is actually written not counting the '\0' end char. This results in the case of len exceeding the size, len set to PAGE_SIZE - 1, as it can be written at max PAGE_SIZE - 1 (as '\0' is not counted)
Because of len is never set to PAGE_SIZE, the function never break early, never prints the warning and never return -EFBIG.
Fix this by changing the condition to PAGE_SIZE - 1 to correctly trigger the error.
--- drivers/cpufreq/cpufreq_stats.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/cpufreq/cpufreq_stats.c +7 -7
@@ -131,25 +131,25 @@ static ssize_t show_trans_table(struct cpufreq_policy *policy, char *buf) len +=scnprintf (buf + len,PAGE_SIZE - len," From : To\n" ); len +=scnprintf (buf + len,PAGE_SIZE - len," : " );for (i =0 ; i < stats->state_num; i++) { -if (len >=PAGE_SIZE ) +if (len >=PAGE_SIZE -1 )break ; len +=scnprintf (buf + len,PAGE_SIZE - len,"%9u " , stats->freq_table[i]); } -if (len >=PAGE_SIZE ) -return PAGE_SIZE ; +if (len >=PAGE_SIZE -1 ) +return PAGE_SIZE -1 ; len +=scnprintf (buf + len,PAGE_SIZE - len,"\n" );for (i =0 ; i < stats->state_num; i++) { -if (len >=PAGE_SIZE ) +if (len >=PAGE_SIZE -1 )break ; len +=scnprintf (buf + len,PAGE_SIZE - len,"%9u: " , stats->freq_table[i]);for (j =0 ; j < stats->state_num; j++) { -if (len >=PAGE_SIZE ) +if (len >=PAGE_SIZE -1 )break ;if (pending)
@@ -159,12 +159,12 @@ static ssize_t show_trans_table(struct cpufreq_policy *policy, char *buf) len +=scnprintf (buf + len,PAGE_SIZE - len,"%9u " , count); } -if (len >=PAGE_SIZE ) +if (len >=PAGE_SIZE -1 )break ; len +=scnprintf (buf + len,PAGE_SIZE - len,"\n" ); } -if (len >=PAGE_SIZE ) { +if (len >=PAGE_SIZE -1 ) {pr_warn_once ("cpufreq transition table exceeds PAGE_SIZE. Disabling\n" );return -EFBIG ; }
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 242/297 Bluetooth: btusb: Add Realtek RTL8852BE support ID 0x0cb8:0xc559
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Artem Lukyanov <[email protected]>
[ Upstream commit 393b4916b7b5b94faf5c6a7c68df1c62d17e4f38 ]
Add the support ID(0x0cb8, 0xc559) to usb_device_id table for Realtek RTL8852BE.
The device info from /sys/kernel/debug/usb/devices as below.
T: Bus=03 Lev=01 Prnt=01 Port=02 Cnt=01 Dev#= 2 Spd=12 MxCh= 0 D: Ver= 1.00 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs= 1 P: Vendor=0cb8 ProdID=c559 Rev= 0.00 S: Manufacturer=Realtek S: Product=Bluetooth Radio S: SerialNumber=00e04c000001 C:* #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=500mA I:* If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=81(I) Atr=03(Int.) MxPS= 16 Ivl=1ms E: Ad=02(O) Atr=02(Bulk) MxPS= 64 Ivl=0ms E: Ad=82(I) Atr=02(Bulk) MxPS= 64 Ivl=0ms I:* If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 0 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 0 Ivl=1ms I: If#= 1 Alt= 1 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 9 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 9 Ivl=1ms I: If#= 1 Alt= 2 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 17 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 17 Ivl=1ms I: If#= 1 Alt= 3 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 25 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 25 Ivl=1ms I: If#= 1 Alt= 4 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 33 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 33 Ivl=1ms I: If#= 1 Alt= 5 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 49 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 49 Ivl=1ms
Stable-dep-of: da06ff1f585e ("Bluetooth: btusb: Add 0bda:b85b for Fn-Link RTL8852BE")
--- drivers/bluetooth/btusb.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/bluetooth/btusb.c +4 -0
@@ -436,6 +436,10 @@ static const struct usb_device_id blacklist_table[] = { { USB_DEVICE(0x13d3, 0x3586), .driver_info = BTUSB_REALTEK | BTUSB_WIDEBAND_SPEECH }, + /* Realtek 8852BE Bluetooth devices */ + { USB_DEVICE(0x0cb8, 0xc559), .driver_info = BTUSB_REALTEK | + BTUSB_WIDEBAND_SPEECH }, + /* Realtek Bluetooth devices */ { USB_VENDOR_AND_INTERFACE_INFO(0x0bda, 0xe0, 0x01, 0x01), .driver_info = BTUSB_REALTEK },
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 243/297 bluetooth: Add device 0bda:887b to device tables
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Larry Finger <[email protected]>
[ Upstream commit 730a1d1a93a3e30c3723f87af97a8517334b2203 ]
This device is part of a Realtek RTW8852BE chip.
The device table entry is as follows:
T: Bus=03 Lev=01 Prnt=01 Port=12 Cnt=02 Dev#= 3 Spd=12 MxCh= 0 D: Ver= 1.00 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs= 1 P: Vendor=0bda ProdID=887b Rev= 0.00 S: Manufacturer=Realtek S: Product=Bluetooth Radio S: SerialNumber=00e04c000001 C:* #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=500mA I:* If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=81(I) Atr=03(Int.) MxPS= 16 Ivl=1ms E: Ad=02(O) Atr=02(Bulk) MxPS= 64 Ivl=0ms E: Ad=82(I) Atr=02(Bulk) MxPS= 64 Ivl=0ms I:* If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 0 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 0 Ivl=1ms I: If#= 1 Alt= 1 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 9 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 9 Ivl=1ms I: If#= 1 Alt= 2 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 17 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 17 Ivl=1ms I: If#= 1 Alt= 3 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 25 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 25 Ivl=1ms I: If#= 1 Alt= 4 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 33 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 33 Ivl=1ms I: If#= 1 Alt= 5 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 49 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 49 Ivl=1ms
Stable-dep-of: da06ff1f585e ("Bluetooth: btusb: Add 0bda:b85b for Fn-Link RTL8852BE")
--- drivers/bluetooth/btusb.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/bluetooth/btusb.c +2 -0
@@ -439,6 +439,8 @@ static const struct usb_device_id blacklist_table[] = {/* Realtek 8852BE Bluetooth devices */ { USB_DEVICE(0x0cb8, 0xc559), .driver_info = BTUSB_REALTEK | BTUSB_WIDEBAND_SPEECH }, + { USB_DEVICE(0x0bda, 0x887b), .driver_info = BTUSB_REALTEK | + BTUSB_WIDEBAND_SPEECH },/* Realtek Bluetooth devices */ { USB_VENDOR_AND_INTERFACE_INFO(0x0bda, 0xe0, 0x01, 0x01),
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 244/297 bluetooth: Add device 13d3:3571 to device tables
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Larry Finger <[email protected]>
[ Upstream commit 069f534247bb6db4f8c2c2ea8e9155abf495c37e ]
This device is part of a Realtek RTW8852BE chip. The device table is as follows:
T: Bus=03 Lev=01 Prnt=01 Port=01 Cnt=01 Dev#= 2 Spd=12 MxCh= 0 D: Ver= 1.00 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs= 1 P: Vendor=13d3 ProdID=3571 Rev= 0.00 S: Manufacturer=Realtek S: Product=Bluetooth Radio S: SerialNumber=00e04c000001 C:* #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=500mA I:* If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=81(I) Atr=03(Int.) MxPS= 16 Ivl=1ms E: Ad=02(O) Atr=02(Bulk) MxPS= 64 Ivl=0ms E: Ad=82(I) Atr=02(Bulk) MxPS= 64 Ivl=0ms I:* If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 0 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 0 Ivl=1ms I: If#= 1 Alt= 1 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 9 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 9 Ivl=1ms I: If#= 1 Alt= 2 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 17 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 17 Ivl=1ms I: If#= 1 Alt= 3 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 25 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 25 Ivl=1ms I: If#= 1 Alt= 4 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 33 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 33 Ivl=1ms I: If#= 1 Alt= 5 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 49 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 49 Ivl=1ms
Stable-dep-of: da06ff1f585e ("Bluetooth: btusb: Add 0bda:b85b for Fn-Link RTL8852BE")
--- drivers/bluetooth/btusb.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/bluetooth/btusb.c +2 -0
@@ -441,6 +441,8 @@ static const struct usb_device_id blacklist_table[] = { BTUSB_WIDEBAND_SPEECH }, { USB_DEVICE(0x0bda, 0x887b), .driver_info = BTUSB_REALTEK | BTUSB_WIDEBAND_SPEECH }, + { USB_DEVICE(0x13d3, 0x3571), .driver_info = BTUSB_REALTEK | + BTUSB_WIDEBAND_SPEECH },/* Realtek Bluetooth devices */ { USB_VENDOR_AND_INTERFACE_INFO(0x0bda, 0xe0, 0x01, 0x01),
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 245/297 Bluetooth: btusb: Add RTW8852BE device 13d3:3570 to device tables
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Masum Reza <[email protected]>
[ Upstream commit 02be109d3a405dbc4d53fb4b4473d7a113548088 ]
This device is used in TP-Link TX20E WiFi+Bluetooth adapter.
Relevant information in /sys/kernel/debug/usb/devices about the Bluetooth device is listed as the below.
T: Bus=01 Lev=01 Prnt=01 Port=08 Cnt=01 Dev#= 2 Spd=12 MxCh= 0 D: Ver= 1.00 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs= 1 P: Vendor=13d3 ProdID=3570 Rev= 0.00 S: Manufacturer=Realtek S: Product=Bluetooth Radio S: SerialNumber=00e04c000001 C:* #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=500mA I:* If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=81(I) Atr=03(Int.) MxPS= 16 Ivl=1ms E: Ad=02(O) Atr=02(Bulk) MxPS= 64 Ivl=0ms E: Ad=82(I) Atr=02(Bulk) MxPS= 64 Ivl=0ms I:* If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 0 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 0 Ivl=1ms I: If#= 1 Alt= 1 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 9 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 9 Ivl=1ms I: If#= 1 Alt= 2 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 17 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 17 Ivl=1ms I: If#= 1 Alt= 3 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 25 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 25 Ivl=1ms I: If#= 1 Alt= 4 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 33 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 33 Ivl=1ms I: If#= 1 Alt= 5 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 49 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 49 Ivl=1ms
Stable-dep-of: da06ff1f585e ("Bluetooth: btusb: Add 0bda:b85b for Fn-Link RTL8852BE")
--- drivers/bluetooth/btusb.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/bluetooth/btusb.c +2 -0
@@ -441,6 +441,8 @@ static const struct usb_device_id blacklist_table[] = { BTUSB_WIDEBAND_SPEECH }, { USB_DEVICE(0x0bda, 0x887b), .driver_info = BTUSB_REALTEK | BTUSB_WIDEBAND_SPEECH }, + { USB_DEVICE(0x13d3, 0x3570), .driver_info = BTUSB_REALTEK | + BTUSB_WIDEBAND_SPEECH }, { USB_DEVICE(0x13d3, 0x3571), .driver_info = BTUSB_REALTEK | BTUSB_WIDEBAND_SPEECH },
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 246/297 Bluetooth: btusb: Add 0bda:b85b for Fn-Link RTL8852BE
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guan Wentao <[email protected]>
[ Upstream commit da06ff1f585ea784c79f80e7fab0e0c4ebb49c1c ]
Add PID/VID 0bda:b85b for Realtek RTL8852BE USB bluetooth part. The PID/VID was reported by the patch last year. [1] Some SBCs like rockpi 5B A8 module contains the device. And it`s founded in website. [2] [3]
Here is the device tables in /sys/kernel/debug/usb/devices .
T: Bus=07 Lev=01 Prnt=01 Port=01 Cnt=01 Dev#= 2 Spd=12 MxCh= 0 D: Ver= 1.00 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs= 1 P: Vendor=0bda ProdID=b85b Rev= 0.00 S: Manufacturer=Realtek S: Product=Bluetooth Radio S: SerialNumber=00e04c000001 C:* #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=500mA I:* If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=81(I) Atr=03(Int.) MxPS= 16 Ivl=1ms E: Ad=02(O) Atr=02(Bulk) MxPS= 64 Ivl=0ms E: Ad=82(I) Atr=02(Bulk) MxPS= 64 Ivl=0ms I:* If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 0 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 0 Ivl=1ms I: If#= 1 Alt= 1 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 9 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 9 Ivl=1ms I: If#= 1 Alt= 2 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 17 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 17 Ivl=1ms I: If#= 1 Alt= 3 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 25 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 25 Ivl=1ms I: If#= 1 Alt= 4 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 33 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 33 Ivl=1ms I: If#= 1 Alt= 5 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 49 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 49 Ivl=1ms
--- drivers/bluetooth/btusb.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/bluetooth/btusb.c +2 -0
@@ -441,6 +441,8 @@ static const struct usb_device_id blacklist_table[] = { BTUSB_WIDEBAND_SPEECH }, { USB_DEVICE(0x0bda, 0x887b), .driver_info = BTUSB_REALTEK | BTUSB_WIDEBAND_SPEECH }, + { USB_DEVICE(0x0bda, 0xb85b), .driver_info = BTUSB_REALTEK | + BTUSB_WIDEBAND_SPEECH }, { USB_DEVICE(0x13d3, 0x3570), .driver_info = BTUSB_REALTEK | BTUSB_WIDEBAND_SPEECH }, { USB_DEVICE(0x13d3, 0x3571), .driver_info = BTUSB_REALTEK |
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 247/297 ksmbd: fix slab out of bounds write in smb_inherit_dacl()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namjae Jeon <[email protected]>
[ Upstream commit eebff19acaa35820cb09ce2ccb3d21bee2156ffb ]
slab out-of-bounds write is caused by that offsets is bigger than pntsd allocation size. This patch add the check to validate 3 offsets using allocation size.
--- fs/ksmbd/smbacl.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-)
fs/ksmbd/smbacl.c +26 -3
@@ -1105,6 +1105,7 @@ int smb_inherit_dacl(struct ksmbd_conn *conn,struct smb_acl *pdacl;struct smb_sid *powner_sid =NULL , *pgroup_sid =NULL ;int powner_sid_size =0 , pgroup_sid_size =0 , pntsd_size; +int pntsd_alloc_size;if (parent_pntsd->osidoffset) { powner_sid = (struct smb_sid *)((char *)parent_pntsd +
@@ -1117,9 +1118,10 @@ int smb_inherit_dacl(struct ksmbd_conn *conn, pgroup_sid_size =1 +1 +6 + (pgroup_sid->num_subauth *4 ); } - pntsd =kzalloc (sizeof (struct smb_ntsd ) + powner_sid_size + - pgroup_sid_size +sizeof (struct smb_acl ) + - nt_size,GFP_KERNEL ); + pntsd_alloc_size =sizeof (struct smb_ntsd ) + powner_sid_size + + pgroup_sid_size +sizeof (struct smb_acl ) + nt_size; + + pntsd =kzalloc (pntsd_alloc_size,GFP_KERNEL );if (!pntsd) { rc = -ENOMEM ; goto free_aces_base;
@@ -1134,6 +1136,27 @@ int smb_inherit_dacl(struct ksmbd_conn *conn, pntsd->gsidoffset = parent_pntsd->gsidoffset; pntsd->dacloffset = parent_pntsd->dacloffset; +if ((u64 )le32_to_cpu (pntsd->osidoffset) + powner_sid_size > + pntsd_alloc_size) { + rc = -EINVAL ; +kfree (pntsd); + goto free_aces_base; + } + +if ((u64 )le32_to_cpu (pntsd->gsidoffset) + pgroup_sid_size > + pntsd_alloc_size) { + rc = -EINVAL ; +kfree (pntsd); + goto free_aces_base; + } + +if ((u64 )le32_to_cpu (pntsd->dacloffset) +sizeof (struct smb_acl ) + nt_size > + pntsd_alloc_size) { + rc = -EINVAL ; +kfree (pntsd); + goto free_aces_base; + } +if (pntsd->osidoffset) {struct smb_sid *owner_sid = (struct smb_sid *)((char *)pntsd +le32_to_cpu (pntsd->osidoffset));
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 248/297 arm64: dts: qcom: ipq6018: switch TCSR mutex to MMIO
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Kozlowski <[email protected]>
[ Upstream commit f5e303aefc06b7508d7a490f9a2d80e4dc134c70 ]
The TCSR mutex bindings allow device to be described only with address space (so it uses MMIO, not syscon regmap). This seems reasonable as TCSR mutex is actually a dedicated IO address space and it also fixes DT schema checks:
qcom/ipq6018-cp01-c1.dtb: hwlock: 'reg' is a required property qcom/ipq6018-cp01-c1.dtb: hwlock: 'syscon' does not match any of the regexes: 'pinctrl-[0-9]+'
Stable-dep-of: 72fc3d58b87b ("arm64: dts: qcom: ipq6018: Fix tcsr_mutex register size")
--- arch/arm64/boot/dts/qcom/ipq6018.dtsi | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
arch/arm64/boot/dts/qcom/ipq6018.dtsi +4 -9
@@ -129,12 +129,6 @@ }; }; - tcsr_mutex: hwlock { - compatible = "qcom,tcsr-mutex"; - syscon = <&tcsr_mutex_regs 0 0x80>; - #hwlock-cells = <1>; - }; - pmuv8: pmu { compatible = "arm,cortex-a53-pmu"; interrupts = <GIC_PPI 7 (GIC_CPU_MASK_SIMPLE(4) |
@@ -253,9 +247,10 @@ #reset-cells = <1>; }; - tcsr_mutex_regs: syscon@1905000 { - compatible = "syscon"; - reg = <0x0 0x01905000 0x0 0x8000>; + tcsr_mutex: hwlock@1905000 { + compatible = "qcom,ipq6018-tcsr-mutex", "qcom,tcsr-mutex"; + reg = <0x0 0x01905000 0x0 0x1000>; + #hwlock-cells = <1>; }; tcsr: syscon@1937000 {
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 249/297 arm64: dts: qcom: ipq6018: Fix tcsr_mutex register size
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vignesh Viswanathan <[email protected]>
[ Upstream commit 72fc3d58b87b0d622039c6299b89024fbb7b420f ]
IPQ6018's TCSR Mutex HW lock register has 32 locks of size 4KB each. Total size of the TCSR Mutex registers is 128KB.
Fix size of the tcsr_mutex hwlock register to 0x20000.
Changes in v2:
- Drop change to remove qcom,ipq6018-tcsr-mutex compatible string
- Added Fixes and stable tags
--- arch/arm64/boot/dts/qcom/ipq6018.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/qcom/ipq6018.dtsi +1 -1
@@ -249,7 +249,7 @@ tcsr_mutex: hwlock@1905000 { compatible = "qcom,ipq6018-tcsr-mutex", "qcom,tcsr-mutex"; - reg = <0x0 0x01905000 0x0 0x1000>; + reg = <0x0 0x01905000 0x0 0x20000>; #hwlock-cells = <1>; };
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 250/297 powerpc/pseries/ddw: simplify enable_ddw()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexey Kardashevskiy <[email protected]>
[ Upstream commit fb4ee2b30cd09e95524640149e4ee0d7f22c3e7b ]
This drops rather useless ddw_enabled flag as direct_mapping implies it anyway.
While at this, fix indents in enable_ddw().
This should not cause any behavioral change.
Stable-dep-of: 3bf983e4e93c ("powerpc/pseries/iommu: enable_ddw incorrectly returns direct mapping for SR-IOV device")
--- arch/powerpc/platforms/pseries/iommu.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
arch/powerpc/platforms/pseries/iommu.c +4 -7
@@ -1241,7 +1241,6 @@ static bool enable_ddw(struct pci_dev *dev, struct device_node *pdn)u32 ddw_avail[DDW_APPLICABLE_SIZE ];struct dma_win *window;struct property *win64; -bool ddw_enabled = false;struct failed_ddw_pdn *fpdn;bool default_win_removed = false, direct_mapping = false;bool pmem_present;
@@ -1256,7 +1255,6 @@ static bool enable_ddw(struct pci_dev *dev, struct device_node *pdn)if (find_existing_ddw (pdn, &dev->dev.archdata.dma_offset, &len)) { direct_mapping = (len >= max_ram_len); - ddw_enabled = true; goto out_unlock; }
@@ -1411,8 +1409,8 @@ static bool enable_ddw(struct pci_dev *dev, struct device_node *pdn)dev_info (&dev->dev,"failed to map DMA window for %pOF: %d\n" , dn, ret); -/* Make sure to clean DDW if any TCE was set*/ -clean_dma_window (pdn, win64->value); +/* Make sure to clean DDW if any TCE was set*/ +clean_dma_window (pdn, win64->value); goto out_del_list; } }else {
@@ -1459,7 +1457,6 @@ static bool enable_ddw(struct pci_dev *dev, struct device_node *pdn)spin_unlock (&dma_win_list_lock); dev->dev.archdata.dma_offset = win_addr; - ddw_enabled = true; goto out_unlock; out_del_list:
@@ -1495,10 +1492,10 @@ static bool enable_ddw(struct pci_dev *dev, struct device_node *pdn)* as RAM, then we failed to create a window to cover persistent * memory and need to set the DMA limit. */ -if (pmem_present && ddw_enabled && direct_mapping && len == max_ram_len) +if (pmem_present && direct_mapping && len == max_ram_len) dev->dev.bus_dma_limit = dev->dev.archdata.dma_offset + (1ULL << len); -return ddw_enabled && direct_mapping; +return direct_mapping; }static void pci_dma_dev_setup_pSeriesLP (struct pci_dev *dev)
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 251/297 powerpc/pseries/iommu: enable_ddw incorrectly returns direct mapping for SR-IOV device
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gaurav Batra <[email protected]>
[ Upstream commit 3bf983e4e93ce8e6d69e9d63f52a66ec0856672e ]
When a device is initialized, the driver invokes dma_supported() twice - first for streaming mappings followed by coherent mappings. For an SR-IOV device, default window is deleted and DDW created. With vPMEM enabled, TCE mappings are dynamically created for both vPMEM and SR-IOV device. There are no direct mappings.
First time when dma_supported() is called with 64 bit mask, DDW is created and marked as dynamic window. The second time dma_supported() is called, enable_ddw() finds existing window for the device and incorrectly returns it as "direct mapping".
This only happens when size of DDW is big enough to map max LPAR memory.
This results in streaming TCEs to not get dynamically mapped, since code incorrently assumes these are already pre-mapped. The adapter initially comes up but goes down due to EEH.
--- arch/powerpc/platforms/pseries/iommu.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/powerpc/platforms/pseries/iommu.c +4 -4
@@ -891,7 +891,8 @@ static int remove_ddw(struct device_node *np, bool remove_prop, const char *win_return 0 ; } -static bool find_existing_ddw (struct device_node *pdn,u64 *dma_addr,int *window_shift) +static bool find_existing_ddw (struct device_node *pdn,u64 *dma_addr,int *window_shift, +bool *direct_mapping) {struct dma_win *window;const struct dynamic_dma_window_prop *dma64;
@@ -904,6 +905,7 @@ static bool find_existing_ddw(struct device_node *pdn, u64 *dma_addr, int *windo dma64 = window->prop; *dma_addr =be64_to_cpu (dma64->dma_base); *window_shift =be32_to_cpu (dma64->window_shift); + *direct_mapping = window->direct; found = true;break ; }
@@ -1253,10 +1255,8 @@ static bool enable_ddw(struct pci_dev *dev, struct device_node *pdn)mutex_lock (&dma_win_init_mutex); -if (find_existing_ddw (pdn, &dev->dev.archdata.dma_offset, &len)) { - direct_mapping = (len >= max_ram_len); +if (find_existing_ddw (pdn, &dev->dev.archdata.dma_offset, &len, &direct_mapping)) goto out_unlock; - }/* * If we already went through this for a previous function of
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 252/297 Revert ncsi: Propagate carrier gain/loss events to the NCSI controller
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johnathan Mantey <[email protected]>
commit 9e2e7efbbbff69d8340abb56d375dd79d1f5770f upstream.
This reverts commit 3780bb29311eccb7a1c9641032a112eed237f7e3.
The cited commit introduced unwanted behavior.
The intent for the commit was to be able to detect carrier loss/gain for just the NIC connected to the BMC. The unwanted effect is a carrier loss for auxiliary paths also causes the BMC to lose carrier. The BMC never regains carrier despite the secondary NIC regaining a link.
This change, when merged, needs to be backported to stable kernels. 5.4-stable, 5.10-stable, 5.15-stable, 6.1-stable, 6.5-stable
--- net/ncsi/ncsi-aen.c | 5 ----- 1 file changed, 5 deletions(-)
net/ncsi/ncsi-aen.c +0 -5
@@ -89,11 +89,6 @@ static int ncsi_aen_handler_lsc(struct nif ((had_link == has_link) || chained)return 0 ; -if (had_link) -netif_carrier_off (ndp->ndev.dev); -else -netif_carrier_on (ndp->ndev.dev); -if (!ndp->multi_package && !nc->package->multi_channel) {if (had_link) { ndp->flags |=NCSI_DEV_RESHUFFLE ;
Greg Kroah-Hartman
maintainerPATCH 253/297 Revert "i2c: pxa: move to generic GPIO recovery"
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Robert Marko <[email protected]>
commit 7b211c7671212cad0b83603c674838c7e824d845 upstream.
This reverts commit 0b01392c18b9993a584f36ace1d61118772ad0ca.
Conversion of PXA to generic I2C recovery, makes the I2C bus completely lock up if recovery pinctrl is present in the DT and I2C recovery is enabled.
So, until the generic I2C recovery can also work with PXA lets revert to have working I2C and I2C recovery again.
--- drivers/i2c/busses/i2c-pxa.c | 76 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 68 insertions(+), 8 deletions(-)
drivers/i2c/busses/i2c-pxa.c +68 -8
@@ -264,6 +264,9 @@ struct pxa_i2c {u32 hs_mask;struct i2c_bus_recovery_info recovery; +struct pinctrl *pinctrl; +struct pinctrl_state *pinctrl_default; +struct pinctrl_state *pinctrl_recovery; };#define _IBMR (i2c) ((i2c)->reg_ibmr)
@@ -1302,12 +1305,13 @@ static void i2c_pxa_prepare_recovery(str*/ gpiod_set_value (i2c->recovery.scl_gpiod, ibmr &IBMR_SCLS );gpiod_set_value (i2c->recovery.sda_gpiod, ibmr &IBMR_SDAS ); + +WARN_ON (pinctrl_select_state (i2c->pinctrl, i2c->pinctrl_recovery)); }static void i2c_pxa_unprepare_recovery (struct i2c_adapter *adap) {struct pxa_i2c *i2c = adap->algo_data; -struct i2c_bus_recovery_info *bri = adap->bus_recovery_info;u32 isr;/*
@@ -1321,7 +1325,7 @@ static void i2c_pxa_unprepare_recovery(si2c_pxa_do_reset (i2c); } -WARN_ON (pinctrl_select_state (bri->pinctrl, bri->pins_default)); +WARN_ON (pinctrl_select_state (i2c->pinctrl, i2c->pinctrl_default));dev_dbg (&i2c->adap.dev,"recovery: IBMR 0x%08x ISR 0x%08x\n" ,readl (_IBMR (i2c)),readl (_ISR (i2c)));
@@ -1343,20 +1347,76 @@ static int i2c_pxa_init_recovery(structif (IS_ENABLED (CONFIG_I2C_PXA_SLAVE ))return 0 ; - bri->pinctrl =devm_pinctrl_get (dev); -if (PTR_ERR (bri->pinctrl) == -ENODEV ) { - bri->pinctrl =NULL ; + i2c->pinctrl =devm_pinctrl_get (dev); +if (PTR_ERR (i2c->pinctrl) == -ENODEV ) + i2c->pinctrl =NULL ; +if (IS_ERR (i2c->pinctrl)) +return PTR_ERR (i2c->pinctrl); + +if (!i2c->pinctrl) +return 0 ; + + i2c->pinctrl_default =pinctrl_lookup_state (i2c->pinctrl, +PINCTRL_STATE_DEFAULT ); + i2c->pinctrl_recovery =pinctrl_lookup_state (i2c->pinctrl,"recovery" ); + +if (IS_ERR (i2c->pinctrl_default) ||IS_ERR (i2c->pinctrl_recovery)) { +dev_info (dev,"missing pinmux recovery information: %ld %ld\n" , +PTR_ERR (i2c->pinctrl_default), +PTR_ERR (i2c->pinctrl_recovery)); +return 0 ; + } + +/* +* Claiming GPIOs can influence the pinmux state, and may glitch the +* I2C bus. Do this carefully. +*/ + bri->scl_gpiod =devm_gpiod_get (dev,"scl" ,GPIOD_OUT_HIGH_OPEN_DRAIN ); +if (bri->scl_gpiod ==ERR_PTR (-EPROBE_DEFER )) +return -EPROBE_DEFER ; +if (IS_ERR (bri->scl_gpiod)) { +dev_info (dev,"missing scl gpio recovery information: %pe\n" , + bri->scl_gpiod); +return 0 ; + } + +/* +* We have SCL. Pull SCL low and wait a bit so that SDA glitches +* have no effect. +*/ +gpiod_direction_output (bri->scl_gpiod,0 ); +udelay (10 ); + bri->sda_gpiod =devm_gpiod_get (dev,"sda" ,GPIOD_OUT_HIGH_OPEN_DRAIN ); + +/* Wait a bit in case of a SDA glitch, and then release SCL. */ +udelay (10 ); +gpiod_direction_output (bri->scl_gpiod,1 ); + +if (bri->sda_gpiod ==ERR_PTR (-EPROBE_DEFER )) +return -EPROBE_DEFER ; + +if (IS_ERR (bri->sda_gpiod)) { +dev_info (dev,"missing sda gpio recovery information: %pe\n" , + bri->sda_gpiod);return 0 ; } -if (IS_ERR (bri->pinctrl)) -return PTR_ERR (bri->pinctrl); bri->prepare_recovery = i2c_pxa_prepare_recovery; bri->unprepare_recovery = i2c_pxa_unprepare_recovery; + bri->recover_bus = i2c_generic_scl_recovery; i2c->adap.bus_recovery_info = bri; -return 0 ; +/* +* Claiming GPIOs can change the pinmux state, which confuses the +* pinctrl since pinctrl's idea of the current setting is unaffected +* by the pinmux change caused by claiming the GPIO. Work around that +* by switching pinctrl to the GPIO state here. We do it this way to +* avoid glitching the I2C bus. +*/ +pinctrl_select_state (i2c->pinctrl, i2c->pinctrl_recovery); + +return pinctrl_select_state (i2c->pinctrl, i2c->pinctrl_default); }static int i2c_pxa_probe (struct platform_device *dev)
Greg Kroah-Hartman
maintainerPATCH 254/297 lsm: fix default return value for vm_enough_memory
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ondrej Mosnacek <[email protected]>
commit 866d648059d5faf53f1cd960b43fe8365ad93ea7 upstream.
1 is the return value that implements a "no-op" hook, not 0.
--- include/linux/lsm_hook_defs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/lsm_hook_defs.h +1 -1
@@ -48,7 +48,7 @@ LSM_HOOK(int, 0, quota_on, struct dentry LSM_HOOK(int, 0, syslog, int type) LSM_HOOK(int, 0, settime, const struct timespec64 *ts, const struct timezone *tz) -LSM_HOOK(int, 0, vm_enough_memory, struct mm_struct *mm, long pages) +LSM_HOOK(int, 1, vm_enough_memory, struct mm_struct *mm, long pages) LSM_HOOK(int, 0, bprm_creds_for_exec, struct linux_binprm *bprm) LSM_HOOK(int, 0, bprm_creds_from_file, struct linux_binprm *bprm, struct file *file) LSM_HOOK(int, 0, bprm_check_security, struct linux_binprm *bprm)
Greg Kroah-Hartman
maintainerPATCH 255/297 lsm: fix default return value for inode_getsecctx
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ondrej Mosnacek <[email protected]>
commit b36995b8609a5a8fe5cf259a1ee768fcaed919f8 upstream.
-EOPNOTSUPP is the return value that implements a "no-op" hook, not 0.
Without this fix having only the BPF LSM enabled (with no programs attached) can cause uninitialized variable reads in nfsd4_encode_fattr(), because the BPF hook returns 0 without touching the 'ctxlen' variable and the corresponding 'contextlen' variable in nfsd4_encode_fattr() remains uninitialized, yet being treated as valid based on the 0 return value.
--- include/linux/lsm_hook_defs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/lsm_hook_defs.h +1 -1
@@ -265,7 +265,7 @@ LSM_HOOK(void, LSM_RET_VOID, release_sec LSM_HOOK(void, LSM_RET_VOID, inode_invalidate_secctx, struct inode *inode) LSM_HOOK(int, 0, inode_notifysecctx, struct inode *inode, void *ctx, u32 ctxlen) LSM_HOOK(int, 0, inode_setsecctx, struct dentry *dentry, void *ctx, u32 ctxlen) -LSM_HOOK(int, 0, inode_getsecctx, struct inode *inode, void **ctx, +LSM_HOOK(int, -EOPNOTSUPP, inode_getsecctx, struct inode *inode, void **ctx, u32 *ctxlen)#if defined(CONFIG_SECURITY ) && defined(CONFIG_WATCH_QUEUE )
Greg Kroah-Hartman
maintainerPATCH 256/297 sbsa_gwdt: Calculate timeout with 64-bit math
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Darren Hart <[email protected]>
commit 5d6aa89bba5bd6af2580f872b57f438dab883738 upstream.
Commit abd3ac7902fb ("watchdog: sbsa: Support architecture version 1") introduced new timer math for watchdog revision 1 with the 48 bit offset register.
The gwdt->clk and timeout are u32, but the argument being calculated is u64. Without a cast, the compiler performs u32 operations, truncating intermediate steps, resulting in incorrect values.
A watchdog revision 1 implementation with a gwdt->clk of 1GHz and a timeout of 600s writes 3647256576 to the one shot watchdog instead of 300000000000, resulting in the watchdog firing in 3.6s instead of 600s.
Force u64 math by casting the first argument (gwdt->clk) as a u64. Make the order of operations explicit with parenthesis.
--- drivers/watchdog/sbsa_gwdt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/watchdog/sbsa_gwdt.c +2 -2
@@ -153,14 +153,14 @@ static int sbsa_gwdt_set_timeout(struct timeout = clamp_t(unsigned int, timeout, 1, wdd->max_hw_heartbeat_ms / 1000);if (action) -sbsa_gwdt_reg_write (gwdt->clk * timeout, gwdt); +sbsa_gwdt_reg_write ((u64 )gwdt->clk * timeout, gwdt);else /* * In the single stage mode, The first signal (WS0) is ignored, * the timeout is (WOR * 2), so the WOR should be configured * to half value of timeout. */ -sbsa_gwdt_reg_write (gwdt->clk /2 * timeout, gwdt); +sbsa_gwdt_reg_write (((u64 )gwdt->clk /2 ) * timeout, gwdt);return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 257/297 i2c: designware: Disable TX_EMPTY irq while waiting for block length byte
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tam Nguyen <[email protected]>
commit e8183fa10c25c7b3c20670bf2b430ddcc1ee03c0 upstream.
During SMBus block data read process, we have seen high interrupt rate because of TX_EMPTY irq status while waiting for block length byte (the first data byte after the address phase). The interrupt handler does not do anything because the internal state is kept as STATUS_WRITE_IN_PROGRESS. Hence, we should disable TX_EMPTY IRQ until I2C DesignWare receives first data byte from I2C device, then re-enable it to resume SMBus transaction.
It takes 0.789 ms for host to receive data length from slave. Without the patch, i2c_dw_isr() is called 99 times by TX_EMPTY interrupt. And it is none after applying the patch.
--- drivers/i2c/busses/i2c-designware-master.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
drivers/i2c/busses/i2c-designware-master.c +16 -3
@@ -456,10 +456,16 @@ i2c_dw_xfer_msg(struct dw_i2c_dev *dev)/* * Because we don't know the buffer length in the -* I2C_FUNC_SMBUS_BLOCK_DATA case, we can't stop -* the transaction here. +* I2C_FUNC_SMBUS_BLOCK_DATA case, we can't stop the +* transaction here. Also disable the TX_EMPTY IRQ +* while waiting for the data length byte to avoid the +* bogus interrupts flood. */ -if (buf_len >0 || flags &I2C_M_RECV_LEN ) { +if (flags &I2C_M_RECV_LEN ) { + dev->status |=STATUS_WRITE_IN_PROGRESS ; + intr_mask &= ~DW_IC_INTR_TX_EMPTY ; +break ; + }else if (buf_len >0 ) {/* more bytes to be written */ dev->status |=STATUS_WRITE_IN_PROGRESS ;break ;
@@ -495,6 +501,13 @@ i2c_dw_recv_len(struct dw_i2c_dev *dev, msgs[dev->msg_read_idx].len = len; msgs[dev->msg_read_idx].flags &= ~I2C_M_RECV_LEN ; +/* +* Received buffer length, re-enable TX_EMPTY interrupt +* to resume the SMBUS transaction. +*/ +regmap_update_bits (dev->map,DW_IC_INTR_MASK ,DW_IC_INTR_TX_EMPTY , +DW_IC_INTR_TX_EMPTY ); +return len; }
Greg Kroah-Hartman
maintainerPATCH 258/297 s390/ap: fix AP bus crash on early config change callback invocation
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Harald Freudenberger <[email protected]>
commit e14aec23025eeb1f2159ba34dbc1458467c4c347 upstream.
Fix kernel crash in AP bus code caused by very early invocation of the config change callback function via SCLP.
After a fresh IML of the machine the crypto cards are still offline and will get switched online only with activation of any LPAR which has the card in it's configuration. A crypto card coming online is reported to the LPAR via SCLP and the AP bus offers a callback function to get this kind of information. However, it may happen that the callback is invoked before the AP bus init function is complete. As the callback triggers a synchronous AP bus scan, the scan may already run but some internal states are not initialized by the AP bus init function resulting in a crash like this:
[ 11.635859] Unable to handle kernel pointer dereference in virtual kernel address space [ 11.635861] Failing address: 0000000000000000 TEID: 0000000000000887 [ 11.635862] Fault in home space mode while using kernel ASCE. [ 11.635864] AS:00000000894c4007 R3:00000001fece8007 S:00000001fece7800 P:000000000000013d [ 11.635879] Oops: 0004 ilc:1 [#1] SMP [ 11.635882] Modules linked in: [ 11.635884] CPU: 5 PID: 42 Comm: kworker/5:0 Not tainted 6.6.0-rc3-00003-g4dbf7cdc6b42 #12 [ 11.635886] Hardware name: IBM 3931 A01 751 (LPAR) [ 11.635887] Workqueue: events_long ap_scan_bus [ 11.635891] Krnl PSW : 0704c00180000000 0000000000000000 (0x0) [ 11.635895] R:0 T:1 IO:1 EX:1 Key:0 M:1 W:0 P:0 AS:3 CC:0 PM:0 RI:0 EA:3 [ 11.635897] Krnl GPRS: 0000000001000a00 0000000000000000 0000000000000006 0000000089591940 [ 11.635899] 0000000080000000 0000000000000a00 0000000000000000 0000000000000000 [ 11.635901] 0000000081870c00 0000000089591000 000000008834e4e2 0000000002625a00 [ 11.635903] 0000000081734200 0000038000913c18 000000008834c6d6 0000038000913ac8 [ 11.635906] Krnl Code:>0000000000000000: 0000 illegal [ 11.635906] 0000000000000002: 0000 illegal [ 11.635906] 0000000000000004: 0000 illegal [ 11.635906] 0000000000000006: 0000 illegal [ 11.635906] 0000000000000008: 0000 illegal [ 11.635906] 000000000000000a: 0000 illegal [ 11.635906] 000000000000000c: 0000 illegal [ 11.635906] 000000000000000e: 0000 illegal [ 11.635915] Call Trace: [ 11.635916] [<0000000000000000>] 0x0 [ 11.635918] [<000000008834e4e2>] ap_queue_init_state+0x82/0xb8 [ 11.635921] [<000000008834ba1c>] ap_scan_domains+0x6fc/0x740 [ 11.635923] [<000000008834c092>] ap_scan_adapter+0x632/0x8b0 [ 11.635925] [<000000008834c3e4>] ap_scan_bus+0xd4/0x288 [ 11.635927] [<00000000879a33ba>] process_one_work+0x19a/0x410 [ 11.635930] Discipline DIAG cannot be used without z/VM [ 11.635930] [<00000000879a3a2c>] worker_thread+0x3fc/0x560 [ 11.635933] [<00000000879aea60>] kthread+0x120/0x128 [ 11.635936] [<000000008792afa4>] __ret_from_fork+0x3c/0x58 [ 11.635938] [<00000000885ebe62>] ret_from_fork+0xa/0x30 [ 11.635942] Last Breaking-Event-Address: [ 11.635942] [<000000008834c6d4>] ap_wait+0xcc/0x148
This patch improves the ap_bus_force_rescan() function which is invoked by the config change callback by checking if a first initial AP bus scan has been done. If not, the force rescan request is simple ignored. Anyhow it does not make sense to trigger AP bus re-scans even before the very first bus scan is complete.
--- drivers/s390/crypto/ap_bus.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/s390/crypto/ap_bus.c +4 -0
@@ -955,6 +955,10 @@ EXPORT_SYMBOL(ap_driver_unregister);void ap_bus_force_rescan (void ) { +/* Only trigger AP bus scans after the initial scan is done */ +if (atomic64_read (&ap_scan_bus_count) <=0 ) +return ; +/* processing a asynchronous bus rescan */ del_timer (&ap_config_timer);queue_work (system_long_wq, &ap_scan_work);
Greg Kroah-Hartman
maintainerPATCH 259/297 net: ethtool: Fix documentation of ethtool_sprintf()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrew Lunn <[email protected]>
commit f55d8e60f10909dbc5524e261041e1d28d7d20d8 upstream.
This function takes a pointer to a pointer, unlike sprintf() which is passed a plain pointer. Fix up the documentation to make this clear.
--- include/linux/ethtool.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/ethtool.h +2 -2
@@ -781,10 +781,10 @@ int ethtool_get_phc_vclocks(struct net_d/** * ethtool_sprintf - Write formatted string to ethtool string data -* @data: Pointer to start of string to update +* @data: Pointer to a pointer to the start of string to update * @fmt: Format of string to write * -* Write formatted string to data. Update data to point at start of +* Write formatted string to *data. Update *data to point at start of * next string. */ extern __printf(2, 3) void ethtool_sprintf(u8 **data, const char *fmt, ...);
Greg Kroah-Hartman
maintainerPATCH 260/297 net: dsa: lan9303: consequently nested-lock physical MDIO
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Sverdlin <[email protected]>
commit 5a22fbcc10f3f7d94c5d88afbbffa240a3677057 upstream.
When LAN9303 is MDIO-connected two callchains exist into mdio->bus->write():
1. switch ports 1&2 ("physical" PHYs):
virtual (switch-internal) MDIO bus (lan9303_switch_ops->phy_{read|write})->
lan9303_mdio_phy_{read|write} -> mdiobus_{read|write}_nested
2. LAN9303 virtual PHY:
virtual MDIO bus (lan9303_phy_{read|write}) ->
lan9303_virt_phy_reg_{read|write} -> regmap -> lan9303_mdio_{read|write}
If the latter functions just take mutex_lock(&sw_dev->device->bus->mdio_lock) it triggers a LOCKDEP false-positive splat. It's false-positive because the first mdio_lock in the second callchain above belongs to virtual MDIO bus, the second mdio_lock belongs to physical MDIO bus.
Consequent annotation in lan9303_mdio_{read|write} as nested lock (similar to lan9303_mdio_phy_{read|write}, it's the same physical MDIO bus) prevents the following splat:
WARNING: possible circular locking dependency detected
5.15.71 #1 Not tainted
------------------------------------------------------
kworker/u4:3/609 is trying to acquire lock:ffff000011531c68 (lan9303_mdio:131:(&lan9303_mdio_regmap_config)->lock){+.+.}-{3:3}, at: regmap_lock_mutex but task is already holding lock:ffff0000114c44d8 (&bus->mdio_lock){+.+.}-{3:3}, at: mdiobus_read
which lock already depends on the new lock.
the existing dependency chain (in reverse order) is:
-> #1 (&bus->mdio_lock){+.+.}-{3:3}:
lock_acquire
__mutex_lock
mutex_lock_nested
lan9303_mdio_read
_regmap_read
regmap_read
lan9303_probe
lan9303_mdio_probe
mdio_probe
really_probe
__driver_probe_device
driver_probe_device
__device_attach_driver
bus_for_each_drv
__device_attach
device_initial_probe
bus_probe_device
deferred_probe_work_func
process_one_work
worker_thread
kthread
ret_from_fork
-> #0 (lan9303_mdio:131:(&lan9303_mdio_regmap_config)->lock){+.+.}-{3:3}:
__lock_acquire
lock_acquire.part.0
lock_acquire
__mutex_lock
mutex_lock_nested
regmap_lock_mutex
regmap_read
lan9303_phy_read
dsa_slave_phy_read
__mdiobus_read
mdiobus_read
get_phy_device
mdiobus_scan
__mdiobus_register
dsa_register_switch
lan9303_probe
lan9303_mdio_probe
mdio_probe
really_probe
__driver_probe_device
driver_probe_device
__device_attach_driver
bus_for_each_drv
__device_attach
device_initial_probe
bus_probe_device
deferred_probe_work_func
process_one_work
worker_thread
kthread
ret_from_fork
other info that might help us debug this:
Possible unsafe locking scenario:
CPU0 CPU1
---- ----
lock(&bus->mdio_lock);
lock(lan9303_mdio:131:(&lan9303_mdio_regmap_config)->lock);
lock(&bus->mdio_lock);
lock(lan9303_mdio:131:(&lan9303_mdio_regmap_config)->lock);
*** DEADLOCK ***
5 locks held by kworker/u4:3/609:
#0: ffff000002842938 ((wq_completion)events_unbound){+.+.}-{0:0}, at: process_one_work
#1: ffff80000bacbd60 (deferred_probe_work){+.+.}-{0:0}, at: process_one_work
#2: ffff000007645178 (&dev->mutex){....}-{3:3}, at: __device_attach
#3: ffff8000096e6e78 (dsa2_mutex){+.+.}-{3:3}, at: dsa_register_switch
#4: ffff0000114c44d8 (&bus->mdio_lock){+.+.}-{3:3}, at: mdiobus_read
stack backtrace:
CPU: 1 PID: 609 Comm: kworker/u4:3 Not tainted 5.15.71 #1
Workqueue: events_unbound deferred_probe_work_func
Call trace:
dump_backtrace
show_stack
dump_stack_lvl
dump_stack
print_circular_bug
check_noncircular
__lock_acquire
lock_acquire.part.0
lock_acquire
__mutex_lock
mutex_lock_nested
regmap_lock_mutex
regmap_read
lan9303_phy_read
dsa_slave_phy_read
__mdiobus_read
mdiobus_read
get_phy_device
mdiobus_scan
__mdiobus_register
dsa_register_switch
lan9303_probe
lan9303_mdio_probe...
--- drivers/net/dsa/lan9303_mdio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/dsa/lan9303_mdio.c +2 -2
@@ -32,7 +32,7 @@ static int lan9303_mdio_write(void *ctx,struct lan9303_mdio *sw_dev = (struct lan9303_mdio *)ctx; reg <<=2 ;/* reg num to offset */ -mutex_lock (&sw_dev->device->bus->mdio_lock); +mutex_lock_nested (&sw_dev->device->bus->mdio_lock,MDIO_MUTEX_NESTED );lan9303_mdio_real_write (sw_dev->device, reg, val &0xffff );lan9303_mdio_real_write (sw_dev->device, reg +2 , (val >>16 ) &0xffff );mutex_unlock (&sw_dev->device->bus->mdio_lock);
@@ -50,7 +50,7 @@ static int lan9303_mdio_read(void *ctx,struct lan9303_mdio *sw_dev = (struct lan9303_mdio *)ctx; reg <<=2 ;/* reg num to offset */ -mutex_lock (&sw_dev->device->bus->mdio_lock); +mutex_lock_nested (&sw_dev->device->bus->mdio_lock,MDIO_MUTEX_NESTED ); *val =lan9303_mdio_real_read (sw_dev->device, reg); *val |= (lan9303_mdio_real_read (sw_dev->device, reg +2 ) <<16 );mutex_unlock (&sw_dev->device->bus->mdio_lock);
Greg Kroah-Hartman
maintainerPATCH 261/297 net: phylink: initialize carrier state at creation
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Klaus Kudielka <[email protected]>
commit 02d5fdbf4f2b8c406f7a4c98fa52aa181a11d733 upstream.
Background: Turris Omnia (Armada 385); eth2 (mvneta) connected to SFP bus; SFP module is present, but no fiber connected, so definitely no carrier.
After booting, eth2 is down, but netdev LED trigger surprisingly reports link active. Then, after "ip link set eth2 up", the link indicator goes away - as I would have expected it from the beginning.
It turns out, that the default carrier state after netdev creation is "carrier ok". Some ethernet drivers explicitly call netif_carrier_off during probing, others (like mvneta) don't - which explains the current
behaviour: only when the device is brought up, phylink_start calls netif_carrier_off.
Fix this for all drivers using phylink, by calling netif_carrier_off in phylink_create.
--- drivers/net/phy/phylink.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/phy/phylink.c +1 -0
@@ -853,6 +853,7 @@ struct phylink *phylink_create(struct ph pl->config = config;if (config->type ==PHYLINK_NETDEV ) { pl->netdev =to_net_dev (config->dev); +netif_carrier_off (pl->netdev); }else if (config->type ==PHYLINK_DEV ) { pl->dev = config->dev; }else {
Greg Kroah-Hartman
maintainerPATCH 262/297 i2c: i801: fix potential race in i801_block_transaction_byte_by_byte
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiner Kallweit <[email protected]>
commit f78ca48a8ba9cdec96e8839351e49eec3233b177 upstream.
Currently we set SMBHSTCNT_LAST_BYTE only after the host has started receiving the last byte. If we get e.g. preempted before setting SMBHSTCNT_LAST_BYTE, the host may be finished with receiving the byte before SMBHSTCNT_LAST_BYTE is set.
Therefore change the code to set SMBHSTCNT_LAST_BYTE before writing SMBHSTSTS_BYTE_DONE for the byte before the last byte. Now the code is also consistent with what we do in i801_isr_byte_done().
--- drivers/i2c/busses/i2c-i801.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)
drivers/i2c/busses/i2c-i801.c +9 -10
@@ -702,15 +702,11 @@ static int i801_block_transaction_byte_breturn i801_check_post (priv, result ? priv->status : -ETIMEDOUT ); } -for (i =1 ; i <= len; i++) { -if (i == len && read_write ==I2C_SMBUS_READ ) - smbcmd |=SMBHSTCNT_LAST_BYTE ; -outb_p (smbcmd,SMBHSTCNT (priv)); - -if (i ==1 ) -outb_p (inb (SMBHSTCNT (priv)) |SMBHSTCNT_START , -SMBHSTCNT (priv)); +if (len ==1 && read_write ==I2C_SMBUS_READ ) + smbcmd |=SMBHSTCNT_LAST_BYTE ; +outb_p (smbcmd |SMBHSTCNT_START ,SMBHSTCNT (priv)); +for (i =1 ; i <= len; i++) { status =i801_wait_byte_done (priv);if (status) goto exit;
@@ -733,9 +729,12 @@ static int i801_block_transaction_byte_b data->block[0 ] = len; } -/* Retrieve/store value in SMBBLKDAT */ -if (read_write ==I2C_SMBUS_READ ) +if (read_write ==I2C_SMBUS_READ ) { data->block[i] =inb_p (SMBBLKDAT (priv)); +if (i == len -1 ) +outb_p (smbcmd |SMBHSTCNT_LAST_BYTE ,SMBHSTCNT (priv)); + } +if (read_write ==I2C_SMBUS_WRITE && i+1 <= len)outb_p (data->block[i+1 ],SMBBLKDAT (priv));
Greg Kroah-Hartman
maintainerPATCH 263/297 f2fs: avoid format-overflow warning
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Su Hui <[email protected]>
commit e0d4e8acb3789c5a8651061fbab62ca24a45c063 upstream.
With gcc and W=1 option, there's a warning like this:
fs/f2fs/compress.c: In function ‘f2fs_init_page_array_cache’:fs/f2fs/compress.c:1984:47: error: ‘%u’ directive writing between 1 and 7 bytes into a region of size between 5 and 8 [-Werror=format-overflow=]
1984 | sprintf(slab_name, "f2fs_page_array_entry-%u:%u", MAJOR(dev),
MINOR(dev));
| ^~String "f2fs_page_array_entry-%u:%u" can up to 35. The first "%u" can up to 4 and the second "%u" can up to 7, so total size is "24 + 4 + 7 = 35". slab_name's size should be 35 rather than 32.
--- fs/f2fs/compress.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/compress.c +1 -1
@@ -1906,7 +1906,7 @@ void f2fs_destroy_compress_inode(structint f2fs_init_page_array_cache (struct f2fs_sb_info *sbi) {dev_t dev = sbi->sb->s_bdev->bd_dev; -char slab_name[32 ]; +char slab_name[35 ];sprintf (slab_name,"f2fs_page_array_entry-%u:%u" ,MAJOR (dev),MINOR (dev));
Greg Kroah-Hartman
maintainerPATCH 264/297 media: lirc: drop trailing space from scancode transmit
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Young <[email protected]>
commit c8a489f820179fb12251e262b50303c29de991ac upstream.
When transmitting, infrared drivers expect an odd number of samples; iow without a trailing space. No problems have been observed so far, so this is just belt and braces.
--- drivers/media/rc/lirc_dev.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/media/rc/lirc_dev.c +5 -1
@@ -287,7 +287,11 @@ static ssize_t lirc_transmit(struct fileif (ret <0 ) goto out_kfree_raw; - count = ret; +/* drop trailing space */ +if (!(ret %2 )) + count = ret -1 ; +else + count = ret; txbuf =kmalloc_array (count,sizeof (unsigned int ),GFP_KERNEL );if (!txbuf) {
Greg Kroah-Hartman
maintainerPATCH 265/297 media: sharp: fix sharp encoding
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Young <[email protected]>
commit 4f7efc71891462ab7606da7039f480d7c1584a13 upstream.
The Sharp protocol[1] encoding has incorrect timings for bit space.
[1] https://www.sbprojects.net/knowledge/ir/sharp.php
--- drivers/media/rc/ir-sharp-decoder.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/media/rc/ir-sharp-decoder.c +5 -3
@@ -15,7 +15,9 @@#define SHARP_UNIT 40/* us */ #define SHARP_BIT_PULSE (8 * SHARP_UNIT)/* 320us */ #define SHARP_BIT_0_PERIOD (25 * SHARP_UNIT)/* 1ms (680us space) */ -#define SHARP_BIT_1_PERIOD (50 * SHARP_UNIT)/* 2ms (1680ms space) */ +#define SHARP_BIT_1_PERIOD (50 * SHARP_UNIT)/* 2ms (1680us space) */ +#define SHARP_BIT_0_SPACE (17 * SHARP_UNIT)/* 680us space */ +#define SHARP_BIT_1_SPACE (42 * SHARP_UNIT)/* 1680us space */ #define SHARP_ECHO_SPACE (1000 * SHARP_UNIT)/* 40 ms */ #define SHARP_TRAILER_SPACE (125 * SHARP_UNIT)/* 5 ms (even longer) */
@@ -168,8 +170,8 @@ static const struct ir_raw_timings_pd ir .header_pulse = 0, .header_space = 0, .bit_pulse = SHARP_BIT_PULSE, - .bit_space[0] = SHARP_BIT_0_PERIOD, - .bit_space[1] = SHARP_BIT_1_PERIOD, + .bit_space[0] = SHARP_BIT_0_SPACE, + .bit_space[1] = SHARP_BIT_1_SPACE, .trailer_pulse = SHARP_BIT_PULSE, .trailer_space = SHARP_ECHO_SPACE, .msb_first = 1,
Greg Kroah-Hartman
maintainerPATCH 266/297 media: venus: hfi_parser: Add check to keep the number of codecs within range
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vikash Garodia <[email protected]>
commit 0768a9dd809ef52440b5df7dce5a1c1c7e97abbd upstream.
Supported codec bitmask is populated from the payload from venus firmware. There is a possible case when all the bits in the codec bitmask is set. In such case, core cap for decoder is filled and MAX_CODEC_NUM is utilized. Now while filling the caps for encoder, it can lead to access the caps array beyong 32 index. Hence leading to OOB write.
The fix counts the supported encoder and decoder. If the count is more than max, then it skips accessing the caps.
--- drivers/media/platform/qcom/venus/hfi_parser.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/media/platform/qcom/venus/hfi_parser.c +3 -0
@@ -19,6 +19,9 @@ static void init_codecs(struct venus_corstruct hfi_plat_caps *caps = core->caps, *cap;unsigned long bit; +if (hweight_long (core->dec_codecs) +hweight_long (core->enc_codecs) >MAX_CODEC_NUM ) +return ; +for_each_set_bit (bit, &core->dec_codecs,MAX_CODEC_NUM ) { cap = &caps[core->codecs_count++]; cap->codec =BIT (bit);
Greg Kroah-Hartman
maintainerPATCH 267/297 media: venus: hfi: fix the check to handle session buffer requirement
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vikash Garodia <[email protected]>
commit b18e36dfd6c935da60a971310374f3dfec3c82e1 upstream.
Buffer requirement, for different buffer type, comes from video firmware. While copying these requirements, there is an OOB possibility when the payload from firmware is more than expected size. Fix the check to avoid the OOB possibility.
--- drivers/media/platform/qcom/venus/hfi_msgs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/qcom/venus/hfi_msgs.c +1 -1
@@ -367,7 +367,7 @@ session_get_prop_buf_req(struct hfi_msg_memcpy (&bufreq[idx], buf_req,sizeof (*bufreq)); idx++; -if (idx >HFI_BUFFER_TYPE_MAX ) +if (idx >=HFI_BUFFER_TYPE_MAX )return HFI_ERR_SESSION_INVALID_PARAMETER ; req_bytes -=sizeof (struct hfi_buffer_requirements );
Greg Kroah-Hartman
maintainerPATCH 268/297 media: venus: hfi: add checks to handle capabilities from firmware
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vikash Garodia <[email protected]>
commit 8d0b89398b7ebc52103e055bf36b60b045f5258f upstream.
The hfi parser, parses the capabilities received from venus firmware and copies them to core capabilities. Consider below api, for example, fill_caps - In this api, caps in core structure gets updated with the number of capabilities received in firmware data payload. If the same api is called multiple times, there is a possibility of copying beyond the max allocated size in core caps.
Similar possibilities in fill_raw_fmts and fill_profile_level functions.
--- drivers/media/platform/qcom/venus/hfi_parser.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/media/platform/qcom/venus/hfi_parser.c +12 -0
@@ -89,6 +89,9 @@ static void fill_profile_level(struct hf {const struct hfi_profile_level *pl = data; +if (cap->num_pl + num >=HFI_MAX_PROFILE_COUNT ) +return ; +memcpy (&cap->pl[cap->num_pl], pl, num *sizeof (*pl)); cap->num_pl += num; }
@@ -114,6 +117,9 @@ fill_caps(struct hfi_plat_caps *cap, con {const struct hfi_capability *caps = data; +if (cap->num_caps + num >=MAX_CAP_ENTRIES ) +return ; +memcpy (&cap->caps[cap->num_caps], caps, num *sizeof (*caps)); cap->num_caps += num; }
@@ -140,6 +146,9 @@ static void fill_raw_fmts(struct hfi_pla {const struct raw_formats *formats = fmts; +if (cap->num_fmts + num_fmts >=MAX_FMT_ENTRIES ) +return ; +memcpy (&cap->fmts[cap->num_fmts], formats, num_fmts *sizeof (*formats)); cap->num_fmts += num_fmts; }
@@ -162,6 +171,9 @@ parse_raw_formats(struct venus_core *cor rawfmts[i].buftype = fmt->buffer_type; i++; +if (i >=MAX_FMT_ENTRIES ) +return ; +if (pinfo->num_planes >MAX_PLANES )break ;
Greg Kroah-Hartman
maintainerPATCH 269/297 media: ccs: Correctly initialise try compose rectangle
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sakari Ailus <[email protected]>
commit 724ff68e968b19d786870d333f9952bdd6b119cb upstream.
Initialise the try sink compose rectangle size to the sink compose rectangle for binner and scaler sub-devices. This was missed due to the faulty condition that lead to the compose rectangles to be initialised for the pixel array sub-device where it is not relevant.
--- drivers/media/i2c/ccs/ccs-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/i2c/ccs/ccs-core.c +1 -1
@@ -3089,7 +3089,7 @@ static int ccs_open(struct v4l2_subdev * try_fmt->code = sensor->internal_csi_format->code; try_fmt->field =V4L2_FIELD_NONE ; -if (ssd != sensor->pixel_array) +if (ssd == sensor->pixel_array)continue ; try_comp =v4l2_subdev_get_try_compose (sd, fh->state, i);
Greg Kroah-Hartman
maintainerPATCH 270/297 nfsd: fix file memleak on client_opens_release
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mahmoud Adam <[email protected]>
commit bc1b5acb40201a0746d68a7d7cfc141899937f4f upstream.
seq_release should be called to free the allocated seq_file
--- fs/nfsd/nfs4state.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfsd/nfs4state.c +1 -1
@@ -2686,7 +2686,7 @@ static int client_opens_release(struct i/* XXX: alternatively, we could get/drop in seq start/stop */ drop_client (clp); -return 0 ; +return seq_release (inode, file); }static const struct file_operations client_states_fops = {
Greg Kroah-Hartman
maintainerPATCH 271/297 riscv: kprobes: allow writing to x0
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nam Cao <[email protected]>
commit 8cb22bec142624d21bc85ff96b7bad10b6220e6a upstream.
Instructions can write to x0, so we should simulate these instructions normally.
Currently, the kernel hangs if an instruction who writes to x0 is simulated.
--- arch/riscv/kernel/probes/simulate-insn.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/riscv/kernel/probes/simulate-insn.c +1 -1
@@ -24,7 +24,7 @@ static inline bool rv_insn_reg_set_val(struct pt_regs *regs, u32 index, unsigned long val) {if (index ==0 ) -return false; +return true;else if (index <=31 ) *((unsigned long *)regs + index) = val;else
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 272/297 mmc: sdhci-pci-gli: A workaround to allow GL9750 to enter ASPM L1.2
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Victor Shih <[email protected]>
commit d7133797e9e1b72fd89237f68cb36d745599ed86 upstream.
When GL9750 enters ASPM L1 sub-states, it will stay at L1.1 and will not enter L1.2. The workaround is to toggle PM state to allow GL9750 to enter ASPM L1.2.
--- drivers/mmc/host/sdhci-pci-gli.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
drivers/mmc/host/sdhci-pci-gli.c +14 -0
@@ -23,6 +23,9 @@#define GLI_9750_WT_EN_ON 0x1#define GLI_9750_WT_EN_OFF 0x0 +#define PCI_GLI_9750_PM_CTRL 0xFC +#define PCI_GLI_9750_PM_STATE GENMASK(1, 0) +#define SDHCI_GLI_9750_CFG2 0x848#define SDHCI_GLI_9750_CFG2_L1DLY GENMASK(28, 24)#define GLI_9750_CFG2_L1DLY_VALUE 0x1F
@@ -421,8 +424,12 @@ static void sdhci_gl9750_set_clock(strucstatic void gl9750_hw_setting (struct sdhci_host *host) { +struct sdhci_pci_slot *slot =sdhci_priv (host); +struct pci_dev *pdev;u32 value; + pdev = slot->chip->pdev; +gl9750_wt_on (host); value =sdhci_readl (host,SDHCI_GLI_9750_CFG2 );
@@ -432,6 +439,13 @@ static void gl9750_hw_setting(struct sdh GLI_9750_CFG2_L1DLY_VALUE);sdhci_writel (host, value,SDHCI_GLI_9750_CFG2 ); +/* toggle PM state to allow GL9750 to enter ASPM L1.2 */ +pci_read_config_dword (pdev,PCI_GLI_9750_PM_CTRL , &value); + value |=PCI_GLI_9750_PM_STATE ; +pci_write_config_dword (pdev,PCI_GLI_9750_PM_CTRL , value); + value &= ~PCI_GLI_9750_PM_STATE ; +pci_write_config_dword (pdev,PCI_GLI_9750_PM_CTRL , value); +gl9750_wt_off (host); }
Greg Kroah-Hartman
maintainerPATCH 273/297 mm: kmem: drop __GFP_NOFAIL when allocating objcg vectors
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Roman Gushchin <[email protected]>
commit 24948e3b7b12e0031a6edb4f49bbb9fb2ad1e4e9 upstream.
Objcg vectors attached to slab pages to store slab object ownership information are allocated using gfp flags for the original slab allocation. Depending on slab page order and the size of slab objects, objcg vector can take several pages.
If the original allocation was done with the __GFP_NOFAIL flag, it triggered a warning in the page allocation code. Indeed, order > 1 pages should not been allocated with the __GFP_NOFAIL flag.
Fix this by simply dropping the __GFP_NOFAIL flag when allocating the objcg vector. It effectively allows to skip the accounting of a single slab object under a heavy memory pressure.
An alternative would be to implement the mechanism to fallback to order-0 allocations for accounting metadata, which is also not perfect because it will increase performance penalty and memory footprint of the kernel memory accounting under memory pressure.
--- mm/memcontrol.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
mm/memcontrol.c +2 -1
@@ -2822,7 +2822,8 @@ retry:* Moreover, it should not come from DMA buffer and is not readily * reclaimable. So those GFP bits should be masked off. */ -#define OBJCGS_CLEAR_MASK (__GFP_DMA | __GFP_RECLAIMABLE | __GFP_ACCOUNT) +#define OBJCGS_CLEAR_MASK (__GFP_DMA | __GFP_RECLAIMABLE | \ + __GFP_ACCOUNT | __GFP_NOFAIL)int memcg_alloc_page_obj_cgroups (struct page *page,struct kmem_cache *s,gfp_t gfp,bool new_page)
Greg Kroah-Hartman
maintainerPATCH 274/297 r8169: fix network lost after resume on DASH systems
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: ChunHao Lin <[email protected]>
commit 868c3b95afef4883bfb66c9397482da6840b5baf upstream.
Device that support DASH may be reseted or powered off during suspend. So driver needs to handle DASH during system suspend and resume. Or DASH firmware will influence device behavior and causes network lost.
--- drivers/net/ethernet/realtek/r8169_main.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/ethernet/realtek/r8169_main.c +6 -0
@@ -4714,10 +4714,16 @@ static void rtl8169_down(struct rtl8169_rtl8169_cleanup (tp, true);rtl_prepare_power_down (tp); + +if (tp->dash_type !=RTL_DASH_NONE ) +rtl8168_driver_stop (tp); }static void rtl8169_up (struct rtl8169_private *tp) { +if (tp->dash_type !=RTL_DASH_NONE ) +rtl8168_driver_start (tp); +pci_set_master (tp->pci_dev);phy_init_hw (tp->phydev);phy_resume (tp->phydev);
Greg Kroah-Hartman
maintainerPATCH 275/297 mmc: sdhci-pci-gli: GL9750: Mask the replay timer timeout of AER
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Victor Shih <[email protected]>
commit 015c9cbcf0ad709079117d27c2094a46e0eadcdb upstream.
Due to a flaw in the hardware design, the GL9750 replay timer frequently times out when ASPM is enabled. As a result, the warning messages will often appear in the system log when the system accesses the GL9750 PCI config. Therefore, the replay timer timeout must be masked.
--- drivers/mmc/host/sdhci-pci-gli.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/mmc/host/sdhci-pci-gli.c +8 -0
@@ -26,6 +26,9 @@#define PCI_GLI_9750_PM_CTRL 0xFC#define PCI_GLI_9750_PM_STATE GENMASK(1, 0) +#define PCI_GLI_9750_CORRERR_MASK 0x214 +#define PCI_GLI_9750_CORRERR_MASK_REPLAY_TIMER_TIMEOUT BIT(12) +#define SDHCI_GLI_9750_CFG2 0x848#define SDHCI_GLI_9750_CFG2_L1DLY GENMASK(28, 24)#define GLI_9750_CFG2_L1DLY_VALUE 0x1F
@@ -446,6 +449,11 @@ static void gl9750_hw_setting(struct sdh value &= ~PCI_GLI_9750_PM_STATE ;pci_write_config_dword (pdev,PCI_GLI_9750_PM_CTRL , value); +/* mask the replay timer timeout of AER */ +pci_read_config_dword (pdev,PCI_GLI_9750_CORRERR_MASK , &value); + value |=PCI_GLI_9750_CORRERR_MASK_REPLAY_TIMER_TIMEOUT ; +pci_write_config_dword (pdev,PCI_GLI_9750_CORRERR_MASK , value); +gl9750_wt_off (host); }
Greg Kroah-Hartman
maintainerPATCH 276/297 media: qcom: camss: Fix pm_domain_on sequence in probe
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bryan O'Donoghue <[email protected]>
commit 7405116519ad70b8c7340359bfac8db8279e7ce4 upstream.
We need to make sure camss_configure_pd() happens before camss_register_entities() as the vfe_get() path relies on the pointer provided by camss_configure_pd().
Fix the ordering sequence in probe to ensure the pointers vfe_get() demands are present by the time camss_register_entities() runs.
In order to facilitate backporting to stable kernels I've moved the configure_pd() call pretty early on the probe() function so that irrespective of the existence of the old error handling jump labels this patch should still apply to -next circa Aug 2023 to v5.13 inclusive.
--- drivers/media/platform/qcom/camss/camss.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/media/platform/qcom/camss/camss.c +6 -6
@@ -1369,6 +1369,12 @@ static int camss_probe(struct platform_d goto err_cleanup; } + ret =camss_configure_pd (camss); +if (ret <0 ) { +dev_err (dev,"Failed to configure power domains: %d\n" , ret); + goto err_cleanup; + } + ret =camss_init_subdevices (camss);if (ret <0 ) goto err_cleanup;
@@ -1421,12 +1427,6 @@ static int camss_probe(struct platform_d } } - ret =camss_configure_pd (camss); -if (ret <0 ) { -dev_err (dev,"Failed to configure power domains: %d\n" , ret); -return ret; - } -pm_runtime_enable (dev);return 0 ;
Greg Kroah-Hartman
maintainerPATCH 277/297 media: qcom: camss: Fix vfe_get() error jump
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bryan O'Donoghue <[email protected]>
commit 26bda3da00c3edef727a6acb00ed2eb4b22f8723 upstream.
Right now it is possible to do a vfe_get() with the internal reference count at 1. If vfe_check_clock_rates() returns non-zero then we will leave the reference count as-is and
run:
- pm_runtime_put_sync()
- vfe->ops->pm_domain_off()
skip:
- camss_disable_clocks()
Subsequent vfe_put() calls will when the ref-count is non-zero unconditionally run:
- pm_runtime_put_sync()
- vfe->ops->pm_domain_off()
- camss_disable_clocks()
vfe_get() should not attempt to roll-back on error when the ref-count is non-zero as the upper layers will still do their own vfe_put() operations.
vfe_put() will drop the reference count and do the necessary power domain release, the cleanup jumps in vfe_get() should only be run when the ref-count is zero.
[ 50.095796] CPU: 7 PID: 3075 Comm: cam Not tainted 6.3.2+ #80 [ 50.095798] Hardware name: LENOVO 21BXCTO1WW/21BXCTO1WW, BIOS N3HET82W (1.54 ) 05/26/2023 [ 50.095799] pstate: 60400005 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 50.095802] pc : refcount_warn_saturate+0xf4/0x148 [ 50.095804] lr : refcount_warn_saturate+0xf4/0x148 [ 50.095805] sp : ffff80000c7cb8b0 [ 50.095806] x29: ffff80000c7cb8b0 x28: ffff16ecc0e3fc10 x27: 0000000000000000 [ 50.095810] x26: 0000000000000000 x25: 0000000000020802 x24: 0000000000000000 [ 50.095813] x23: ffff16ecc7360640 x22: 00000000ffffffff x21: 0000000000000005 [ 50.095815] x20: ffff16ed175f4400 x19: ffffb4d9852942a8 x18: ffffffffffffffff [ 50.095818] x17: ffffb4d9852d4a48 x16: ffffb4d983da5db8 x15: ffff80000c7cb320 [ 50.095821] x14: 0000000000000001 x13: 2e656572662d7265 x12: 7466612d65737520 [ 50.095823] x11: 00000000ffffefff x10: ffffb4d9850cebf0 x9 : ffffb4d9835cf954 [ 50.095826] x8 : 0000000000017fe8 x7 : c0000000ffffefff x6 : 0000000000057fa8 [ 50.095829] x5 : ffff16f813fe3d08 x4 : 0000000000000000 x3 : ffff621e8f4d2000 [ 50.095832] x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffff16ed32119040 [ 50.095835] Call trace: [ 50.095836] refcount_warn_saturate+0xf4/0x148 [ 50.095838] device_link_put_kref+0x84/0xc8 [ 50.095843] device_link_del+0x38/0x58 [ 50.095846] vfe_pm_domain_off+0x3c/0x50 [qcom_camss] [ 50.095860] vfe_put+0x114/0x140 [qcom_camss] [ 50.095869] csid_set_power+0x2c8/0x408 [qcom_camss] [ 50.095878] pipeline_pm_power_one+0x164/0x170 [videodev] [ 50.095896] pipeline_pm_power+0xc4/0x110 [videodev] [ 50.095909] v4l2_pipeline_pm_use+0x5c/0xa0 [videodev] [ 50.095923] v4l2_pipeline_pm_get+0x1c/0x30 [videodev] [ 50.095937] video_open+0x7c/0x100 [qcom_camss] [ 50.095945] v4l2_open+0x84/0x130 [videodev] [ 50.095960] chrdev_open+0xc8/0x250 [ 50.095964] do_dentry_open+0x1bc/0x498 [ 50.095966] vfs_open+0x34/0x40 [ 50.095968] path_openat+0xb44/0xf20 [ 50.095971] do_filp_open+0xa4/0x160 [ 50.095974] do_sys_openat2+0xc8/0x188 [ 50.095975] __arm64_sys_openat+0x6c/0xb8 [ 50.095977] invoke_syscall+0x50/0x128 [ 50.095982] el0_svc_common.constprop.0+0x4c/0x100 [ 50.095985] do_el0_svc+0x40/0xa8 [ 50.095988] el0_svc+0x2c/0x88 [ 50.095991] el0t_64_sync_handler+0xf4/0x120 [ 50.095994] el0t_64_sync+0x190/0x198 [ 50.095996] ---[ end trace 0000000000000000 ]---
--- drivers/media/platform/qcom/camss/camss-vfe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/qcom/camss/camss-vfe.c +1 -1
@@ -607,7 +607,7 @@ static int vfe_get(struct vfe_device *vf }else { ret =vfe_check_clock_rates (vfe);if (ret <0 ) - goto error_pm_runtime_get; + goto error_pm_domain; } vfe->power_count++;
Greg Kroah-Hartman
maintainerPATCH 278/297 media: qcom: camss: Fix VFE-17x vfe_disable_output()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bryan O'Donoghue <[email protected]>
commit 3143ad282fc08bf995ee73e32a9e40c527bf265d upstream.
There are two problems with the current vfe_disable_output() routine.
Firstly we rightly use a spinlock to protect output->gen2.active_num everywhere except for in the IDLE timeout path of vfe_disable_output(). Even if that is not racy "in practice" somehow it is by happenstance not by design.
Secondly we do not get consistent behaviour from this routine. On sc8280xp 50% of the time I get "VFE idle timeout - resetting". In this case the subsequent capture will succeed. The other 50% of the time, we don't hit the idle timeout, never do the VFE reset and subsequent captures stall indefinitely.
Rewrite the vfe_disable_output() routine to
- Quiesce write masters with vfe_wm_stop()
- Set active_num = 0
remembering to hold the spinlock when we do so followed by
- Reset the VFE
Testing on sc8280xp and sdm845 shows this to be a valid fix.
--- drivers/media/platform/qcom/camss/camss-vfe-170.c | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-)
drivers/media/platform/qcom/camss/camss-vfe-170.c +3 -19
@@ -7,7 +7,6 @@* Copyright (C) 2020-2021 Linaro Ltd. */ -#include <linux/delay.h> #include <linux/interrupt.h> #include <linux/io.h> #include <linux/iopoll.h>
@@ -498,35 +497,20 @@ static int vfe_enable_output(struct vfe_return 0 ; } -static int vfe_disable_output (struct vfe_line *line) +static void vfe_disable_output (struct vfe_line *line) {struct vfe_device *vfe =to_vfe (line);struct vfe_output *output = &line->output;unsigned long flags;unsigned int i; -bool done; -int timeout =0 ; - -do { -spin_lock_irqsave (&vfe->output_lock, flags); - done = !output->gen2.active_num; -spin_unlock_irqrestore (&vfe->output_lock, flags); -usleep_range (10000 ,20000 ); - -if (timeout++ ==100 ) { -dev_err (vfe->camss->dev,"VFE idle timeout - resetting\n" ); -vfe_reset (vfe); - output->gen2.active_num =0 ; -return 0 ; - } - }while (!done);spin_lock_irqsave (&vfe->output_lock, flags);for (i =0 ; i < output->wm_num; i++)vfe_wm_stop (vfe, output->wm_idx[i]); + output->gen2.active_num =0 ;spin_unlock_irqrestore (&vfe->output_lock, flags); -return 0 ; +vfe_reset (vfe); }/*
Greg Kroah-Hartman
maintainerPATCH 279/297 media: qcom: camss: Fix missing vfe_lite clocks check
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bryan O'Donoghue <[email protected]>
commit b6e1bdca463a932c1ac02caa7d3e14bf39288e0c upstream.
check_clock doesn't account for vfe_lite which means that vfe_lite will never get validated by this routine. Add the clock name to the expected set to remediate.
--- drivers/media/platform/qcom/camss/camss-vfe.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/media/platform/qcom/camss/camss-vfe.c +2 -1
@@ -533,7 +533,8 @@ static int vfe_check_clock_rates(structstruct camss_clock *clock = &vfe->clock[i];if (!strcmp (clock->name,"vfe0" ) || - !strcmp (clock->name,"vfe1" )) { + !strcmp (clock->name,"vfe1" ) || + !strcmp (clock->name,"vfe_lite" )) {u64 min_rate =0 ;unsigned long rate;
Greg Kroah-Hartman
maintainerPATCH 280/297 Revert "net: r8169: Disable multicast filter for RTL8168H and RTL8107E"
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiner Kallweit <[email protected]>
commit 6a26310273c323380da21eb23fcfd50e31140913 upstream.
This reverts commit efa5f1311c4998e9e6317c52bc5ee93b3a0f36df.
I couldn't reproduce the reported issue. What I did, based on a pcap packet log provided by the reporter:
- Used same chip version (RTL8168h)
- Set MAC address to the one used on the reporters system
- Replayed the EAPOL unicast packet that, according to the reporter, was filtered out by the mc filter.
The packet was properly received.
Therefore the root cause of the reported issue seems to be somewhere else. Disabling mc filtering completely for the most common chip version is a quite big hammer. Therefore revert the change and wait for further analysis results from the reporter.
--- drivers/net/ethernet/realtek/r8169_main.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/ethernet/realtek/r8169_main.c +1 -3
@@ -2553,9 +2553,7 @@ static void rtl_set_rx_mode(struct net_d rx_mode &= ~AcceptMulticast; }else if (netdev_mc_count (dev) >MC_FILTER_LIMIT || dev->flags &IFF_ALLMULTI || - tp->mac_version ==RTL_GIGA_MAC_VER_35 || - tp->mac_version ==RTL_GIGA_MAC_VER_46 || - tp->mac_version ==RTL_GIGA_MAC_VER_48 ) { + tp->mac_version ==RTL_GIGA_MAC_VER_35 ) {/* accept all multicasts */ }else if (netdev_mc_empty (dev)) { rx_mode &= ~AcceptMulticast;
Greg Kroah-Hartman
maintainerPATCH 281/297 ext4: apply umask if ACL support is disabled
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Max Kellermann <[email protected]>
commit 484fd6c1de13b336806a967908a927cc0356e312 upstream.
The function ext4_init_acl() calls posix_acl_create() which is responsible for applying the umask. But without CONFIG_EXT4_FS_POSIX_ACL, ext4_init_acl() is an empty inline function, and nobody applies the umask.
This fixes a bug which causes the umask to be ignored with O_TMPFILE on ext4:
https://github.com/MusicPlayerDaemon/MPD/issues/558
https://bugs.gentoo.org/show_bug.cgi?id=686142#c3
https://bugzilla.kernel.org/show_bug.cgi?id=203625
--- fs/ext4/acl.h | 5 +++++ 1 file changed, 5 insertions(+)
fs/ext4/acl.h +5 -0
@@ -68,6 +68,11 @@ extern int ext4_init_acl(handle_t *, strstatic inline int ext4_init_acl (handle_t *handle,struct inode *inode,struct inode *dir) { +/* usually, the umask is applied by posix_acl_create(), but if +ext4 ACL support is disabled at compile time, we need to do +it here, because posix_acl_create() will never be called */ + inode->i_mode &= ~current_umask (); +return 0 ; }#endif /* CONFIG_EXT4_FS_POSIX_ACL */
Greg Kroah-Hartman
maintainerPATCH 282/297 ext4: correct offset of gdb backup in non meta_bg group to update_backups
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kemeng Shi <[email protected]>
commit 31f13421c004a420c0e9d288859c9ea9259ea0cc upstream.
Commit 0aeaa2559d6d5 ("ext4: fix corruption when online resizing a 1K bigalloc fs") found that primary superblock's offset in its group is not equal to offset of backup superblock in its group when block size is 1K and bigalloc is enabled. As group descriptor blocks are right after superblock, we can't pass block number of gdb to update_backups for the same reason.
The root casue of the issue above is that leading 1K padding block is count as data block offset for primary block while backup block has no padding block offset in its group.
Remove padding data block count to fix the issue for gdb backups.
For meta_bg case, update_backups treat blk_off as block number, do no conversion in this case.
--- fs/ext4/resize.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
fs/ext4/resize.c +4 -2
@@ -1555,6 +1555,8 @@ exit_journal:int gdb_num_end = ((group + flex_gd->count -1 ) /EXT4_DESC_PER_BLOCK (sb));int meta_bg =ext4_has_feature_meta_bg (sb); +sector_t padding_blocks = meta_bg ?0 : sbi->s_sbh->b_blocknr - +ext4_group_first_block_no (sb,0 );sector_t old_gdb =0 ; update_backups(sb, ext4_group_first_block_no(sb, 0),
@@ -1566,8 +1568,8 @@ exit_journal: gdb_num);if (old_gdb == gdb_bh->b_blocknr)continue ; -update_backups (sb, gdb_bh->b_blocknr, gdb_bh->b_data, - gdb_bh->b_size, meta_bg); +update_backups (sb, gdb_bh->b_blocknr - padding_blocks, + gdb_bh->b_data, gdb_bh->b_size, meta_bg); old_gdb = gdb_bh->b_blocknr; } }
Greg Kroah-Hartman
maintainerPATCH 283/297 ext4: correct return value of ext4_convert_meta_bg
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kemeng Shi <[email protected]>
commit 48f1551592c54f7d8e2befc72a99ff4e47f7dca0 upstream.
Avoid to ignore error in "err".
--- fs/ext4/resize.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
fs/ext4/resize.c +1 -3
@@ -1938,9 +1938,7 @@ static int ext4_convert_meta_bg(struct s errout: ret =ext4_journal_stop (handle); -if (!err) - err = ret; -return ret; +return err ? err : ret; invalid_resize_inode:ext4_error (sb,"corrupted/inconsistent resize inode" );
Greg Kroah-Hartman
maintainerPATCH 284/297 ext4: correct the start block of counting reserved clusters
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhang Yi <[email protected]>
commit 40ea98396a3659062267d1fe5f99af4f7e4f05e3 upstream.
When big allocate feature is enabled, we need to count and update reserved clusters before removing a delayed only extent_status entry. {init|count|get}_rsvd() have already done this, but the start block number of this counting isn't correct in the following case.
lblk end
| | v v
-------------------------
| | orig_es
-------------------------
^ ^
len1 is 0 | len2 |
If the start block of the orig_es entry founded is bigger than lblk, we passed lblk as start block to count_rsvd(), but the length is correct, finally, the range to be counted is offset. This patch fix this by passing the start blocks to 'orig_es->lblk + len1'.
--- fs/ext4/extents_status.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/ext4/extents_status.c +2 -2
@@ -1366,8 +1366,8 @@ retry: } }if (count_reserved) -count_rsvd (inode, lblk, orig_es.es_len - len1 - len2, - &orig_es, &rc); +count_rsvd (inode, orig_es.es_lblk + len1, + orig_es.es_len - len1 - len2, &orig_es, &rc); goto out_get_reserved; }
Greg Kroah-Hartman
maintainerPATCH 285/297 ext4: remove gdb backup copy for meta bg in setup_new_flex_group_blocks
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kemeng Shi <[email protected]>
commit 40dd7953f4d606c280074f10d23046b6812708ce upstream.
Wrong check of gdb backup in meta bg as following:first_group is the first group of meta_bg which contains target group, so target group is always >= first_group. We check if target group has gdb backup by comparing first_group with [group + 1] and [group + EXT4_DESC_PER_BLOCK(sb) - 1]. As group >= first_group, then [group + N] is
Quoted 1 line
first_group. So no copy of gdb backup in meta bg is done in
setup_new_flex_group_blocks.
No need to do gdb backup copy in meta bg from setup_new_flex_group_blocks as we always copy updated gdb block to backups at end of ext4_flex_group_add as following:
ext4_flex_group_add
/* no gdb backup copy for meta bg any more */
setup_new_flex_group_blocks
/* update current group number */
ext4_update_super
sbi->s_groups_count += flex_gd->count; /*
* if group in meta bg contains backup is added, the primary gdb block
* of the meta bg will be copy to backup in new added group here. */
for (; gdb_num <= gdb_num_end; gdb_num++)
update_backups(...)
In summary, we can remove wrong gdb backup copy code in setup_new_flex_group_blocks.
--- fs/ext4/resize.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
fs/ext4/resize.c +2 -7
@@ -556,13 +556,8 @@ static int setup_new_flex_group_blocks(sif (meta_bg ==0 && !ext4_bg_has_super (sb, group)) goto handle_itb; -if (meta_bg ==1 ) { -ext4_group_t first_group; - first_group =ext4_meta_bg_first_group (sb, group); -if (first_group != group +1 && - first_group != group +EXT4_DESC_PER_BLOCK (sb) -1 ) - goto handle_itb; - } +if (meta_bg ==1 ) + goto handle_itb; block = start +ext4_bg_has_super (sb, group);/* Copy all of the GDT blocks into the backup in this group */
Greg Kroah-Hartman
maintainerPATCH 286/297 ext4: add missed brelse in update_backups
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kemeng Shi <[email protected]>
commit 9adac8b01f4be28acd5838aade42b8daa4f0b642 upstream.
add missed brelse in update_backups
--- fs/ext4/resize.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/ext4/resize.c +3 -1
@@ -1160,8 +1160,10 @@ static void update_backups(struct super_ ext4_group_first_block_no(sb, group));BUFFER_TRACE (bh,"get_write_access" );if ((err =ext4_journal_get_write_access (handle, sb, bh, -EXT4_JTR_NONE ))) +EXT4_JTR_NONE ))) { +brelse (bh);break ; + }lock_buffer (bh);memcpy (bh->b_data, data, size);if (rest)
Greg Kroah-Hartman
maintainerPATCH 287/297 ext4: properly sync file size update after O_SYNC direct IO
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Kara <[email protected]>
commit 91562895f8030cb9a0470b1db49de79346a69f91 upstream.
Gao Xiang has reported that on ext4 O_SYNC direct IO does not properly sync file size update and thus if we crash at unfortunate moment, the file can have smaller size although O_SYNC IO has reported successful completion. The problem happens because update of on-disk inode size is handled in ext4_dio_write_iter() *after* iomap_dio_rw() (and thus dio_complete() in particular) has returned and generic_file_sync() gets called by dio_complete(). Fix the problem by handling on-disk inode size update directly in our ->end_io completion handler.
References: https://lore.kernel.org/all/[email protected]
--- fs/ext4/file.c | 153 ++++++++++++++++++++++++--------------------------------- 1 file changed, 65 insertions(+), 88 deletions(-)
fs/ext4/file.c +65 -88
@@ -279,80 +279,38 @@ out: }static ssize_t ext4_handle_inode_extension (struct inode *inode,loff_t offset, -ssize_t written,size_t count) +ssize_t count) {handle_t *handle; -bool truncate = false; -u8 blkbits = inode->i_blkbits; -ext4_lblk_t written_blk, end_blk; -int ret; - -/* -* Note that EXT4_I(inode)->i_disksize can get extended up to -* inode->i_size while the I/O was running due to writeback of delalloc -* blocks. But, the code in ext4_iomap_alloc() is careful to use -* zeroed/unwritten extents if this is possible; thus we won't leave -* uninitialized blocks in a file even if we didn't succeed in writing -* as much as we intended. -*/ -WARN_ON_ONCE (i_size_read (inode) <EXT4_I (inode)->i_disksize); -if (offset + count <=EXT4_I (inode)->i_disksize) { -/* -* We need to ensure that the inode is removed from the orphan -* list if it has been added prematurely, due to writeback of -* delalloc blocks. -*/ -if (!list_empty (&EXT4_I (inode)->i_orphan) && inode->i_nlink) { - handle =ext4_journal_start (inode,EXT4_HT_INODE ,2 ); - -if (IS_ERR (handle)) { -ext4_orphan_del (NULL , inode); -return PTR_ERR (handle); - } - -ext4_orphan_del (handle, inode); -ext4_journal_stop (handle); - } - -return written; - } - -if (written <0 ) - goto truncate; +lockdep_assert_held_write (&inode->i_rwsem); handle =ext4_journal_start (inode,EXT4_HT_INODE ,2 ); -if (IS_ERR (handle)) { - written =PTR_ERR (handle); - goto truncate; - } +if (IS_ERR (handle)) +return PTR_ERR (handle); -if (ext4_update_inode_size (inode, offset + written)) { - ret =ext4_mark_inode_dirty (handle, inode); +if (ext4_update_inode_size (inode, offset + count)) { +int ret =ext4_mark_inode_dirty (handle, inode);if (unlikely (ret)) { - written = ret;ext4_journal_stop (handle); - goto truncate; +return ret; } } -/* -* We may need to truncate allocated but not written blocks beyond EOF. -*/ - written_blk =ALIGN (offset + written,1 << blkbits); - end_blk =ALIGN (offset + count,1 << blkbits); -if (written_blk < end_blk &&ext4_can_truncate (inode)) - truncate = true; - -/* -* Remove the inode from the orphan list if it has been extended and -* everything went OK. -*/ -if (!truncate && inode->i_nlink) +if (inode->i_nlink)ext4_orphan_del (handle, inode);ext4_journal_stop (handle); -if (truncate) { -truncate: +return count; +} + +/* +* Clean up the inode after DIO or DAX extending write has completed and the +* inode size has been updated using ext4_handle_inode_extension(). +*/ +static void ext4_inode_extension_cleanup (struct inode *inode,ssize_t count) +{ +lockdep_assert_held_write (&inode->i_rwsem); +if (count <0 ) {ext4_truncate_failed_write (inode);/* * If the truncate operation failed early, then the inode may
@@ -361,9 +319,28 @@ truncate:*/ if (inode->i_nlink)ext4_orphan_del (NULL , inode); +return ; } +/* +* If i_disksize got extended due to writeback of delalloc blocks while +* the DIO was running we could fail to cleanup the orphan list in +* ext4_handle_inode_extension(). Do it now. +*/ +if (!list_empty (&EXT4_I (inode)->i_orphan) && inode->i_nlink) { +handle_t *handle =ext4_journal_start (inode,EXT4_HT_INODE ,2 ); -return written; +if (IS_ERR (handle)) { +/* +* The write has successfully completed. Not much to +* do with the error here so just cleanup the orphan +* list and hope for the best. +*/ +ext4_orphan_del (NULL , inode); +return ; + } +ext4_orphan_del (handle, inode); +ext4_journal_stop (handle); + } } static int ext4_dio_write_end_io(struct kiocb *iocb, ssize_t size,
@@ -372,31 +349,22 @@ static int ext4_dio_write_end_io(structloff_t pos = iocb->ki_pos;struct inode *inode =file_inode (iocb->ki_filp); +if (!error && size && flags &IOMAP_DIO_UNWRITTEN ) + error =ext4_convert_unwritten_extents (NULL , inode, pos, size);if (error)return error; - -if (size && flags &IOMAP_DIO_UNWRITTEN ) { - error =ext4_convert_unwritten_extents (NULL , inode, pos, size); -if (error <0 ) -return error; - }/* -* If we are extending the file, we have to update i_size here before -* page cache gets invalidated in iomap_dio_rw(). Otherwise racing -* buffered reads could zero out too much from page cache pages. Update -* of on-disk size will happen later in ext4_dio_write_iter() where -* we have enough information to also perform orphan list handling etc. -* Note that we perform all extending writes synchronously under -* i_rwsem held exclusively so i_size update is safe here in that case. -* If the write was not extending, we cannot see pos > i_size here -* because operations reducing i_size like truncate wait for all -* outstanding DIO before updating i_size. +* Note that EXT4_I(inode)->i_disksize can get extended up to +* inode->i_size while the I/O was running due to writeback of delalloc +* blocks. But the code in ext4_iomap_alloc() is careful to use +* zeroed/unwritten extents if this is possible; thus we won't leave +* uninitialized blocks in a file even if we didn't succeed in writing +* as much as we intended. */ - pos += size; -if (pos >i_size_read (inode)) -i_size_write (inode, pos); - -return 0 ; +WARN_ON_ONCE (i_size_read (inode) <READ_ONCE (EXT4_I (inode)->i_disksize)); +if (pos + size <=READ_ONCE (EXT4_I (inode)->i_disksize)) +return size; +return ext4_handle_inode_extension (inode, pos, size); }static const struct iomap_dio_ops ext4_dio_write_ops = {
@@ -572,9 +540,16 @@ static ssize_t ext4_dio_write_iter(struc 0);if (ret == -ENOTBLK ) ret =0 ; - -if (extend) - ret =ext4_handle_inode_extension (inode, offset, ret, count); +if (extend) { +/* +* We always perform extending DIO write synchronously so by +* now the IO is completed and ext4_handle_inode_extension() +* was called. Cleanup the inode in case of error or race with +* writeback of delalloc blocks. +*/ +WARN_ON_ONCE (ret == -EIOCBQUEUED ); +ext4_inode_extension_cleanup (inode, ret); + } out:if (ilock_shared)
@@ -655,8 +630,10 @@ ext4_dax_write_iter(struct kiocb *iocb, ret =dax_iomap_rw (iocb, from, &ext4_iomap_ops); -if (extend) - ret =ext4_handle_inode_extension (inode, offset, ret, count); +if (extend) { + ret =ext4_handle_inode_extension (inode, offset, ret); +ext4_inode_extension_cleanup (inode, ret); + } out:inode_unlock (inode);if (ret >0 )
Greg Kroah-Hartman
maintainerPATCH 288/297 drm/amd/pm: Handle non-terminated overdrive commands.
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bas Nieuwenhuizen <[email protected]>
commit 08e9ebc75b5bcfec9d226f9e16bab2ab7b25a39a upstream.
The incoming strings might not be terminated by a newline or a 0.
(found while testing a program that just wrote the string
itself, causing a crash)
--- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/pm/amdgpu_pm.c +6 -2
@@ -807,7 +807,7 @@ static ssize_t amdgpu_set_pp_od_clk_voltif (adev->in_suspend && !adev->in_runpm)return -EPERM ; -if (count >127 ) +if (count >127 || count ==0 )return -EINVAL ;if (*buf =='s' )
@@ -827,7 +827,8 @@ static ssize_t amdgpu_set_pp_od_clk_voltelse return -EINVAL ; -memcpy (buf_cpy, buf, count+1 ); +memcpy (buf_cpy, buf, count); + buf_cpy[count] =0 ; tmp_str = buf_cpy;
@@ -844,6 +845,9 @@ static ssize_t amdgpu_set_pp_od_clk_voltreturn -EINVAL ; parameter_size++; +if (!tmp_str) +break ; +while (isspace (*tmp_str)) tmp_str++; }
Greg Kroah-Hartman
maintainerPATCH 289/297 drm/i915: Fix potential spectre vulnerability
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kunwu Chan <[email protected]>
commit 1a8e9bad6ef563c28ab0f8619628d5511be55431 upstream.
Fix smatch warning:drivers/gpu/drm/i915/gem/i915_gem_context.c:847 set_proto_ctx_sseu()
warn: potential spectre issue 'pc->user_engines' [r] (local cap)
--- drivers/gpu/drm/i915/gem/i915_gem_context.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/i915/gem/i915_gem_context.c +1 -0
@@ -642,6 +642,7 @@ static int set_proto_ctx_sseu(struct drmif (idx >= pc->num_user_engines)return -EINVAL ; + idx =array_index_nospec (idx, pc->num_user_engines); pe = &pc->user_engines[idx];/* Only render engine supports RPCS configuration. */
Greg Kroah-Hartman
maintainerPATCH 290/297 drm/amdgpu: dont use ATRM for external devices
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Deucher <[email protected]>
commit 432e664e7c98c243fab4c3c95bd463bea3aeed28 upstream.
The ATRM ACPI method is for fetching the dGPU vbios rom image on laptops and all-in-one systems. It should not be used for external add in cards. If the dGPU is thunderbolt connected, don't try ATRM.
v2: pci_is_thunderbolt_attached only works for Intel. Use
pdev->external_facing instead.
v3: dev_is_removable() seems to be what we want
--- drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c +5 -0
@@ -29,6 +29,7 @@#include "amdgpu.h" #include "atom.h" +#include <linux/device.h> #include <linux/pci.h> #include <linux/slab.h> #include <linux/acpi.h>
@@ -289,6 +290,10 @@ static bool amdgpu_atrm_get_bios(structif (adev->flags &AMD_IS_APU )return false; +/* ATRM is for on-platform devices only */ +if (dev_is_removable (&adev->pdev->dev)) +return false; +while ((pdev =pci_get_class (PCI_CLASS_DISPLAY_VGA <<8 , pdev)) !=NULL ) { dhandle =ACPI_HANDLE (&pdev->dev);if (!dhandle)
Greg Kroah-Hartman
maintainerPATCH 291/297 drm/amdgpu: fix error handling in amdgpu_bo_list_get()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian König <[email protected]>
commit 12f76050d8d4d10dab96333656b821bd4620d103 upstream.
We should not leak the pointer where we couldn't grab the reference on to the caller because it can be that the error handling still tries to put the reference then.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c +1 -0
@@ -178,6 +178,7 @@ int amdgpu_bo_list_get(struct amdgpu_fpr }rcu_read_unlock (); + *result =NULL ;return -ENOENT ; }
Greg Kroah-Hartman
maintainerPATCH 292/297 drm/amd/display: Change the DMCUB mailbox memory location from FB to inbox
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lewis Huang <[email protected]>
commit 5911d02cac70d7fb52009fbd37423e63f8f6f9bc upstream.
[WHY]
Flush command sent to DMCUB spends more time for execution on a dGPU than on an APU. This causes cursor lag when using high refresh rate mouses.
[HOW]
1. Change the DMCUB mailbox memory location from FB to inbox.
2. Only change windows memory to inbox.
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 13 ++++---- drivers/gpu/drm/amd/display/dmub/dmub_srv.h | 22 +++++++++------ drivers/gpu/drm/amd/display/dmub/src/dmub_srv.c | 32 ++++++++++++++++------ 3 files changed, 45 insertions(+), 22 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +7 -6
@@ -1911,7 +1911,7 @@ static int dm_dmub_sw_init(struct amdgpustruct dmub_srv_create_params create_params;struct dmub_srv_region_params region_params;struct dmub_srv_region_info region_info; -struct dmub_srv_fb_params fb_params; +struct dmub_srv_memory_params memory_params;struct dmub_srv_fb_info *fb_info;struct dmub_srv *dmub_srv;const struct dmcub_firmware_header_v1_0 *hdr;
@@ -2021,6 +2021,7 @@ static int dm_dmub_sw_init(struct amdgpu adev->dm.dmub_fw->data +le32_to_cpu (hdr->header.ucode_array_offset_bytes) +PSP_HEADER_BYTES ; + region_params.is_mailbox_in_inbox = false; status =dmub_srv_calc_region_info (dmub_srv, ®ion_params, ®ion_info);
@@ -2042,10 +2043,10 @@ static int dm_dmub_sw_init(struct amdgpureturn r;/* Rebase the regions on the framebuffer address. */ -memset (&fb_params,0 ,sizeof (fb_params)); - fb_params.cpu_addr = adev->dm.dmub_bo_cpu_addr; - fb_params.gpu_addr = adev->dm.dmub_bo_gpu_addr; - fb_params.region_info = ®ion_info; +memset (&memory_params,0 ,sizeof (memory_params)); + memory_params.cpu_fb_addr = adev->dm.dmub_bo_cpu_addr; + memory_params.gpu_fb_addr = adev->dm.dmub_bo_gpu_addr; + memory_params.region_info = ®ion_info; adev->dm.dmub_fb_info =kzalloc (sizeof (*adev->dm.dmub_fb_info),GFP_KERNEL );
@@ -2057,7 +2058,7 @@ static int dm_dmub_sw_init(struct amdgpureturn -ENOMEM ; } - status =dmub_srv_calc_fb_info (dmub_srv, &fb_params, fb_info); + status =dmub_srv_calc_mem_info (dmub_srv, &memory_params, fb_info);if (status !=DMUB_STATUS_OK ) {DRM_ERROR ("Error calculating DMUB FB info: %d\n" , status);return -EINVAL ;
drivers/gpu/drm/amd/display/dmub/dmub_srv.h +14 -8
@@ -166,6 +166,7 @@ struct dmub_srv_region_params {uint32_t vbios_size;const uint8_t *fw_inst_const;const uint8_t *fw_bss_data; +bool is_mailbox_in_inbox; };/**
@@ -185,20 +186,25 @@ struct dmub_srv_region_params {*/ struct dmub_srv_region_info {uint32_t fb_size; +uint32_t inbox_size;uint8_t num_regions;struct dmub_region regions[DMUB_WINDOW_TOTAL ]; };/** -* struct dmub_srv_fb_params - parameters used for driver fb setup +* struct dmub_srv_memory_params - parameters used for driver fb setup * @region_info: region info calculated by dmub service -* @cpu_addr: base cpu address for the framebuffer -* @gpu_addr: base gpu virtual address for the framebuffer +* @cpu_fb_addr: base cpu address for the framebuffer +* @cpu_inbox_addr: base cpu address for the gart +* @gpu_fb_addr: base gpu virtual address for the framebuffer +* @gpu_inbox_addr: base gpu virtual address for the gart */ -struct dmub_srv_fb_params { +struct dmub_srv_memory_params {const struct dmub_srv_region_info *region_info; -void *cpu_addr; -uint64_t gpu_addr; +void *cpu_fb_addr; +void *cpu_inbox_addr; +uint64_t gpu_fb_addr; +uint64_t gpu_inbox_addr; };/**
@@ -496,8 +502,8 @@ dmub_srv_calc_region_info(struct dmub_sr* DMUB_STATUS_OK - success * DMUB_STATUS_INVALID - unspecified error */ -enum dmub_status dmub_srv_calc_fb_info (struct dmub_srv *dmub, -const struct dmub_srv_fb_params *params, +enum dmub_status dmub_srv_calc_mem_info (struct dmub_srv *dmub, +const struct dmub_srv_memory_params *params,struct dmub_srv_fb_info *out);/**
drivers/gpu/drm/amd/display/dmub/src/dmub_srv.c +24 -8
@@ -318,7 +318,7 @@ dmub_srv_calc_region_info(struct dmub_sruint32_t fw_state_size =DMUB_FW_STATE_SIZE ;uint32_t trace_buffer_size =DMUB_TRACE_BUFFER_SIZE ;uint32_t scratch_mem_size =DMUB_SCRATCH_MEM_SIZE ; - +uint32_t previous_top =0 ;if (!dmub->sw_init)return DMUB_STATUS_INVALID ;
@@ -343,8 +343,15 @@ dmub_srv_calc_region_info(struct dmub_sr bios->base =dmub_align (stack->top,256 ); bios->top = bios->base + params->vbios_size; - mail->base =dmub_align (bios->top,256 ); - mail->top = mail->base +DMUB_MAILBOX_SIZE ; +if (params->is_mailbox_in_inbox) { + mail->base =0 ; + mail->top = mail->base +DMUB_MAILBOX_SIZE ; + previous_top = bios->top; + }else { + mail->base =dmub_align (bios->top,256 ); + mail->top = mail->base +DMUB_MAILBOX_SIZE ; + previous_top = mail->top; + } fw_info =dmub_get_fw_meta_info (params);
@@ -363,7 +370,7 @@ dmub_srv_calc_region_info(struct dmub_sr dmub->fw_version = fw_info->fw_version; } - trace_buff->base =dmub_align (mail->top,256 ); + trace_buff->base =dmub_align (previous_top,256 ); trace_buff->top = trace_buff->base +dmub_align (trace_buffer_size,64 ); fw_state->base =dmub_align (trace_buff->top,256 );
@@ -374,11 +381,14 @@ dmub_srv_calc_region_info(struct dmub_sr out->fb_size =dmub_align (scratch_mem->top,4096 ); +if (params->is_mailbox_in_inbox) + out->inbox_size =dmub_align (mail->top,4096 ); +return DMUB_STATUS_OK ; } -enum dmub_status dmub_srv_calc_fb_info (struct dmub_srv *dmub, -const struct dmub_srv_fb_params *params, +enum dmub_status dmub_srv_calc_mem_info (struct dmub_srv *dmub, +const struct dmub_srv_memory_params *params,struct dmub_srv_fb_info *out) {uint8_t *cpu_base;
@@ -393,8 +403,8 @@ enum dmub_status dmub_srv_calc_fb_info(sif (params->region_info->num_regions !=DMUB_NUM_WINDOWS )return DMUB_STATUS_INVALID ; - cpu_base = (uint8_t *)params->cpu_addr; - gpu_base = params->gpu_addr; + cpu_base = (uint8_t *)params->cpu_fb_addr; + gpu_base = params->gpu_fb_addr;for (i =0 ; i <DMUB_NUM_WINDOWS ; ++i) { const struct dmub_region *reg =
@@ -402,6 +412,12 @@ enum dmub_status dmub_srv_calc_fb_info(s out->fb[i].cpu_addr = cpu_base + reg->base; out->fb[i].gpu_addr = gpu_base + reg->base; + +if (i ==DMUB_WINDOW_4_MAILBOX && params->cpu_inbox_addr !=0 ) { + out->fb[i].cpu_addr = (uint8_t *)params->cpu_inbox_addr + reg->base; + out->fb[i].gpu_addr = params->gpu_inbox_addr + reg->base; + } + out->fb[i].size = reg->top - reg->base; }
Greg Kroah-Hartman
maintainerPATCH 293/297 io_uring/fdinfo: lock SQ thread while retrieving thread cpu/pid
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jens Axboe <[email protected]>
commit 7644b1a1c9a7ae8ab99175989bfc8676055edb46 upstream.
We could race with SQ thread exit, and if we do, we'll hit a NULL pointer dereference when the thread is cleared. Grab the SQPOLL data lock before attempting to get the task cpu and pid for fdinfo, this ensures we have a stable view of it.
--- io_uring/io_uring.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
io_uring/io_uring.c +12 -6
@@ -10411,7 +10411,7 @@ static int io_uring_show_cred(struct seqstatic void __io_uring_show_fdinfo (struct io_ring_ctx *ctx,struct seq_file *m) { -struct io_sq_data *sq =NULL ; +int sq_pid =-1 , sq_cpu =-1 ;bool has_lock;int i;
@@ -10424,13 +10424,19 @@ static void __io_uring_show_fdinfo(struc has_lock =mutex_trylock (&ctx->uring_lock);if (has_lock && (ctx->flags &IORING_SETUP_SQPOLL )) { - sq = ctx->sq_data; -if (!sq->thread) - sq =NULL ; +struct io_sq_data *sq = ctx->sq_data; + +if (mutex_trylock (&sq->lock)) { +if (sq->thread) { + sq_pid =task_pid_nr (sq->thread); + sq_cpu =task_cpu (sq->thread); + } +mutex_unlock (&sq->lock); + } } -seq_printf (m,"SqThread:\t%d\n" , sq ?task_pid_nr (sq->thread) :-1 ); -seq_printf (m,"SqThreadCpu:\t%d\n" , sq ?task_cpu (sq->thread) :-1 ); +seq_printf (m,"SqThread:\t%d\n" , sq_pid); +seq_printf (m,"SqThreadCpu:\t%d\n" , sq_cpu);seq_printf (m,"UserFiles:\t%u\n" , ctx->nr_user_files);for (i =0 ; has_lock && i < ctx->nr_user_files; i++) {struct file *f =io_file_from_index (ctx, i);
Greg Kroah-Hartman
maintainerPATCH 294/297 powerpc/powernv: Fix fortify source warnings in opal-prd.c
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Ellerman <[email protected]>
commit feea65a338e52297b68ceb688eaf0ffc50310a83 upstream.
As reported by Mahesh & Aneesh, opal_prd_msg_notifier() triggers a FORTIFY_SOURCE warning:
memcpy: detected field-spanning write (size 32) of single field "&item->msg" at arch/powerpc/platforms/powernv/opal-prd.c:355 (size 4)
WARNING: CPU: 9 PID: 660 at arch/powerpc/platforms/powernv/opal-prd.c:355 opal_prd_msg_notifier+0x174/0x188 [opal_prd]
NIP opal_prd_msg_notifier+0x174/0x188 [opal_prd]
LR opal_prd_msg_notifier+0x170/0x188 [opal_prd]
Call Trace:
opal_prd_msg_notifier+0x170/0x188 [opal_prd] (unreliable)
notifier_call_chain+0xc0/0x1b0
atomic_notifier_call_chain+0x2c/0x40
opal_message_notify+0xf4/0x2c0This happens because the copy is targeting item->msg, which is only 4 bytes in size, even though the enclosing item was allocated with extra space following the msg.
To fix the warning define struct opal_prd_msg with a union of the header and a flex array, and have the memcpy target the flex array.
--- arch/powerpc/platforms/powernv/opal-prd.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
arch/powerpc/platforms/powernv/opal-prd.c +12 -5
@@ -24,13 +24,20 @@#include <linux/uaccess.h> +struct opal_prd_msg { +union { +struct opal_prd_msg_header header; + DECLARE_FLEX_ARRAY(u8, data); + }; +}; +/* * The msg member must be at the end of the struct, as it's followed by the * message data. */ struct opal_prd_msg_queue_item { -struct list_head list; -struct opal_prd_msg_header msg; +struct list_head list; +struct opal_prd_msg msg; };static struct device_node *prd_node;
@@ -156,7 +163,7 @@ static ssize_t opal_prd_read(struct fileint rc;/* we need at least a header's worth of data */ -if (count <sizeof (item->msg)) +if (count <sizeof (item->msg.header))return -EINVAL ;if (*ppos)
@@ -186,7 +193,7 @@ static ssize_t opal_prd_read(struct filereturn -EINTR ; } - size =be16_to_cpu (item->msg.size); + size =be16_to_cpu (item->msg.header.size);if (size > count) { err = -EINVAL ; goto err_requeue;
@@ -352,7 +359,7 @@ static int opal_prd_msg_notifier(structif (!item)return -ENOMEM ; -memcpy (&item->msg, msg->params, msg_size); +memcpy (&item->msg.data, msg->params, msg_size);spin_lock_irqsave (&opal_prd_msg_queue_lock, flags);list_add_tail (&item->list, &opal_prd_msg_queue);
Greg Kroah-Hartman
maintainerPATCH 295/297 tracing: Have trace_event_file have ref counters
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steven Rostedt (Google) <[email protected]>
commit bb32500fb9b78215e4ef6ee8b4345c5f5d7eafb4 upstream.
The following can crash the kernel:
# cd /sys/kernel/tracing # echo 'p:sched schedule' > kprobe_events # exec 5>>events/kprobes/sched/enable # > kprobe_events # exec 5>&-
The above commands:
1. Change directory to the tracefs directory
2. Create a kprobe event (doesn't matter what one)
3. Open bash file descriptor 5 on the enable file of the kprobe event
4. Delete the kprobe event (removes the files too)
5. Close the bash file descriptor 5
The above causes a crash!
BUG: kernel NULL pointer dereference, address: 0000000000000028 #PF: supervisor read access in kernel mode #PF: error_code(0x0000) - not-present page PGD 0 P4D 0 Oops: 0000 [#1] PREEMPT SMP PTI CPU: 6 PID: 877 Comm: bash Not tainted 6.5.0-rc4-test-00008-g2c6b6b1029d4-dirty #186 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.2-debian-1.16.2-1 04/01/2014 RIP: 0010:tracing_release_file_tr+0xc/0x50
What happens here is that the kprobe event creates a trace_event_file "file" descriptor that represents the file in tracefs to the event. It maintains state of the event (is it enabled for the given instance?). Opening the "enable" file gets a reference to the event "file" descriptor via the open file descriptor. When the kprobe event is deleted, the file is also deleted from the tracefs system which also frees the event "file" descriptor.
But as the tracefs file is still opened by user space, it will not be totally removed until the final dput() is called on it. But this is not true with the event "file" descriptor that is already freed. If the user does a write to or simply closes the file descriptor it will reference the event "file" descriptor that was just freed, causing a use-after-free bug.
To solve this, add a ref count to the event "file" descriptor as well as a new flag called "FREED". The "file" will not be freed until the last reference is released. But the FREE flag will be set when the event is removed to prevent any more modifications to that event from happening, even if there's still a reference to the event "file" descriptor.
--- include/linux/trace_events.h | 4 +++ kernel/trace/trace.c | 15 ++++++++++++ kernel/trace/trace.h | 3 ++ kernel/trace/trace_events.c | 43 ++++++++++++++++++++++++------------- kernel/trace/trace_events_filter.c | 3 ++ 5 files changed, 53 insertions(+), 15 deletions(-)
include/linux/trace_events.h +4 -0
@@ -468,6 +468,7 @@ enum {EVENT_FILE_FL_TRIGGER_COND_BIT ,EVENT_FILE_FL_PID_FILTER_BIT ,EVENT_FILE_FL_WAS_ENABLED_BIT , + EVENT_FILE_FL_FREED_BIT, }; extern struct trace_event_file *trace_get_event_file(const char *instance,
@@ -606,6 +607,7 @@ extern int __kprobe_event_add_fields(str* TRIGGER_COND - When set, one or more triggers has an associated filter * PID_FILTER - When set, the event is filtered based on pid * WAS_ENABLED - Set when enabled to know to clear trace on module removal +* FREED - File descriptor is freed, all fields should be considered invalid */ enum {EVENT_FILE_FL_ENABLED = (1 <<EVENT_FILE_FL_ENABLED_BIT ),
@@ -619,6 +621,7 @@ enum {EVENT_FILE_FL_TRIGGER_COND = (1 <<EVENT_FILE_FL_TRIGGER_COND_BIT ),EVENT_FILE_FL_PID_FILTER = (1 <<EVENT_FILE_FL_PID_FILTER_BIT ),EVENT_FILE_FL_WAS_ENABLED = (1 <<EVENT_FILE_FL_WAS_ENABLED_BIT ), + EVENT_FILE_FL_FREED = (1 << EVENT_FILE_FL_FREED_BIT), }; struct trace_event_file {
@@ -647,6 +650,7 @@ struct trace_event_file {* caching and such. Which is mostly OK ;-) */ unsigned long flags; +atomic_t ref;/* ref count for opened files */ atomic_t sm_ref;/* soft-mode reference counter */ atomic_t tm_ref;/* trigger-mode reference counter */ };
kernel/trace/trace.c +15 -0
@@ -4900,6 +4900,20 @@ int tracing_open_file_tr(struct inode *iif (ret)return ret; +mutex_lock (&event_mutex); + +/* Fail if the file is marked for removal */ +if (file->flags &EVENT_FILE_FL_FREED ) { +trace_array_put (file->tr); + ret = -ENODEV ; + }else { +event_file_get (file); + } + +mutex_unlock (&event_mutex); +if (ret) +return ret; + filp->private_data = inode->i_private;return 0 ;
@@ -4910,6 +4924,7 @@ int tracing_release_file_tr(struct inodestruct trace_event_file *file = inode->i_private;trace_array_put (file->tr); +event_file_put (file);return 0 ; }
kernel/trace/trace.h +3 -0
@@ -1620,6 +1620,9 @@ extern int register_event_command(structextern int unregister_event_command (struct event_command *cmd);extern int register_trigger_hist_enable_disable_cmds (void ); +extern void event_file_get (struct trace_event_file *file); +extern void event_file_put (struct trace_event_file *file); +/** * struct event_trigger_ops - callbacks for trace event triggers *
kernel/trace/trace_events.c +28 -15
81 lines not on this page · raw message
kernel/trace/trace_events_filter.c +3 -0
@@ -1872,6 +1872,9 @@ int apply_event_filter(struct trace_evenstruct event_filter *filter =NULL ;int err; +if (file->flags &EVENT_FILE_FL_FREED ) +return -ENODEV ; +if (!strcmp (strstrip (filter_string),"0" )) {filter_disable (file); filter =event_filter (file);
Greg Kroah-Hartman
maintainerPATCH 296/297 Input: xpad - add VID for Turtle Beach controllers
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vicki Pfau <[email protected]>
commit 1999a6b12a3b5c8953fc9ec74863ebc75a1b851d upstream.
This adds support for the Turtle Beach REACT-R and Recon Xbox controllers
--- drivers/input/joystick/xpad.c | 1 + 1 file changed, 1 insertion(+)
drivers/input/joystick/xpad.c +1 -0
@@ -449,6 +449,7 @@ static const struct usb_device_id xpad_tXPAD_XBOX360_VENDOR (0x0f0d ),/* Hori Controllers */ XPAD_XBOXONE_VENDOR (0x0f0d ),/* Hori Controllers */ XPAD_XBOX360_VENDOR (0x1038 ),/* SteelSeries Controllers */ +XPAD_XBOXONE_VENDOR (0x10f5 ),/* Turtle Beach Controllers */ XPAD_XBOX360_VENDOR (0x11c9 ),/* Nacon GC100XF */ XPAD_XBOX360_VENDOR (0x11ff ),/* PXN V900 */ XPAD_XBOX360_VENDOR(0x1209), /* Ardwiino Controllers */
Greg Kroah-Hartman
maintainerPATCH 297/297 driver core: Release all resources during unbind before updating device links
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Saravana Kannan <[email protected]>
commit 2e84dc37920012b458e9458b19fc4ed33f81bc74 upstream.
This commit fixes a bug in commit 9ed9895370ae ("driver core: Functional dependencies tracking support") where the device link status was incorrectly updated in the driver unbind path before all the device's resources were released.
--- drivers/base/dd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/base/dd.c +2 -2
@@ -1228,8 +1228,6 @@ static void __device_release_driver(struelse if (drv->remove) drv->remove (dev); -device_links_driver_cleanup (dev); -devres_release_all (dev);arch_teardown_dma_ops (dev);kfree (dev->dma_range_map);
@@ -1241,6 +1239,8 @@ static void __device_release_driver(strupm_runtime_reinit (dev);dev_pm_set_driver_flags (dev,0 ); +device_links_driver_cleanup (dev); +klist_remove (&dev->p->knode_driver);device_pm_check_callbacks (dev);if (dev->bus)
Hello!
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.15.140 release. There are 297 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Sun, 26 Nov 2023 17:19:17 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.140-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.15.y
and the diffstat can be found below.thanks,
greg k-h
There are problems with PA-RISC:
-----8<-----
/builds/linux/drivers/parisc/power.c:201:34: warning: 'struct sys_off_data' declared inside parameter list will not be visible outside of this definition or declaration
201 | static int qemu_power_off(struct sys_off_data *data)
| ^~~~~~~~~~~~
/builds/linux/drivers/parisc/power.c: In function 'qemu_power_off':
/builds/linux/drivers/parisc/power.c:204:43: error: invalid use of undefined type 'struct sys_off_data'
204 | gsc_writel(0, (unsigned long) data->cb_data);
| ^~
/builds/linux/drivers/parisc/power.c: In function 'power_init':
/builds/linux/drivers/parisc/power.c:239:17: error: implicit declaration of function 'register_sys_off_handler'; did you mean 'register_restart_handler'? [-Werror=implicit-function-declaration]
239 | register_sys_off_handler(SYS_OFF_MODE_POWER_OFF, SYS_OFF_PRIO_DEFAULT,
| ^~~~~~~~~~~~~~~~~~~~~~~~
| register_restart_handler
/builds/linux/drivers/parisc/power.c:239:42: error: 'SYS_OFF_MODE_POWER_OFF' undeclared (first use in this function); did you mean 'SYSTEM_POWER_OFF'?
239 | register_sys_off_handler(SYS_OFF_MODE_POWER_OFF, SYS_OFF_PRIO_DEFAULT,
| ^~~~~~~~~~~~~~~~~~~~~~
| SYSTEM_POWER_OFF /builds/linux/drivers/parisc/power.c:239:42: note: each undeclared identifier is reported only once for each function it appears in /builds/linux/drivers/parisc/power.c:239:66: error: 'SYS_OFF_PRIO_DEFAULT' undeclared (first use in this function)
239 | register_sys_off_handler(SYS_OFF_MODE_POWER_OFF, SYS_OFF_PRIO_DEFAULT,
| ^~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
make[3]: *** [/builds/linux/scripts/Makefile.build:289: drivers/parisc/power.o] Error 1
----->8-----
That's allnoconfig with GCC 11; defconfig and tinyconfig fail just like that.
Bisection points to:
commit 065a7d0b92c0f1ef4160e2129d835eb6093cc675
Author: Helge Deller <[email protected]>
Date: Tue Oct 17 22:19:53 2023 +0200
parisc/power: Add power soft-off when running on qemu
commit d0c219472980d15f5cbc5c8aec736848bda3f235 upstream.
Then there's this failure on System/390:
-----8<-----
/builds/linux/arch/s390/mm/page-states.c: In function 'mark_kernel_pgd':
/builds/linux/arch/s390/mm/page-states.c:175:38: error: request for member 'val' in something not a structure or union
max_addr = (S390_lowcore.kernel_asce.val & _ASCE_TYPE_MASK) >> 2;
^
In file included from /builds/linux/arch/s390/include/asm/page.h:186,
from /builds/linux/arch/s390/include/asm/thread_info.h:26,
from /builds/linux/include/linux/thread_info.h:60,
from /builds/linux/arch/s390/include/asm/preempt.h:6,
from /builds/linux/include/linux/preempt.h:78,
from /builds/linux/include/linux/spinlock.h:55,
from /builds/linux/include/linux/mmzone.h:8,
from /builds/linux/include/linux/gfp.h:6,
from /builds/linux/include/linux/mm.h:10,
from /builds/linux/arch/s390/mm/page-states.c:13:
/builds/linux/arch/s390/mm/page-states.c: In function 'cmma_init_nodat':
/builds/linux/arch/s390/mm/page-states.c:204:23: error: 'invalid_pg_dir' undeclared (first use in this function); did you mean 'is_valid_bugaddr'?
page = virt_to_page(&invalid_pg_dir);
^~~~~~~~~~~~~~
/builds/linux/include/asm-generic/memory_model.h:25:40: note: in definition of macro '__pfn_to_page'
#define __pfn_to_page(pfn) (vmemmap + (pfn))
^~~
/builds/linux/arch/s390/include/asm/page.h:176:29: note: in expansion of macro 'phys_to_pfn'
#define virt_to_pfn(kaddr) (phys_to_pfn(__pa(kaddr)))
^~~~~~~~~~~
/builds/linux/arch/s390/include/asm/page.h:176:41: note: in expansion of macro '__pa'
#define virt_to_pfn(kaddr) (phys_to_pfn(__pa(kaddr)))
^~~~
/builds/linux/arch/s390/include/asm/page.h:179:41: note: in expansion of macro 'virt_to_pfn'
#define virt_to_page(kaddr) pfn_to_page(virt_to_pfn(kaddr))
^~~~~~~~~~~
/builds/linux/arch/s390/mm/page-states.c:204:9: note: in expansion of macro 'virt_to_page'
page = virt_to_page(&invalid_pg_dir);
^~~~~~~~~~~~
/builds/linux/arch/s390/mm/page-states.c:204:23: note: each undeclared identifier is reported only once for each function it appears in
page = virt_to_page(&invalid_pg_dir);
^~~~~~~~~~~~~~
/builds/linux/include/asm-generic/memory_model.h:25:40: note: in definition of macro '__pfn_to_page'
#define __pfn_to_page(pfn) (vmemmap + (pfn))
^~~
/builds/linux/arch/s390/include/asm/page.h:176:29: note: in expansion of macro 'phys_to_pfn'
#define virt_to_pfn(kaddr) (phys_to_pfn(__pa(kaddr)))
^~~~~~~~~~~
/builds/linux/arch/s390/include/asm/page.h:176:41: note: in expansion of macro '__pa'
#define virt_to_pfn(kaddr) (phys_to_pfn(__pa(kaddr)))
^~~~
/builds/linux/arch/s390/include/asm/page.h:179:41: note: in expansion of macro 'virt_to_pfn'
#define virt_to_page(kaddr) pfn_to_page(virt_to_pfn(kaddr))
^~~~~~~~~~~
/builds/linux/arch/s390/mm/page-states.c:204:9: note: in expansion of macro 'virt_to_page'
page = virt_to_page(&invalid_pg_dir);
^~~~~~~~~~~~ make[3]: *** [/builds/linux/scripts/Makefile.build:289: arch/s390/mm/page-states.o] Error 1
----->8-----
Bisection in this case points to:
commit d247caa47712c9cc36f25ec744f3b5dba90c3334
Author: Heiko Carstens <[email protected]>
Date: Tue Oct 17 21:07:03 2023 +0200
s390/cmma: fix initial kernel address space page table walk
commit 16ba44826a04834d3eeeda4b731c2ea3481062b7 upstream.
Reproducers:
tuxmake --runtime podman --target-arch parisc --toolchain gcc-11 --kconfig allnoconfig
and
tuxmake --runtime podman --target-arch s390 --toolchain gcc-8 --kconfig allnoconfig
Greetings!
Daniel Díaz
[email protected]
Quoted 9 lines · Daniel Díaz
Quoted 1 line · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.15.140 release.
...
There are problems with PA-RISC:-----8<-----
/builds/linux/drivers/parisc/power.c:201:34: warning: 'structsys_off_data' declared inside parameter list will not be visible outside of this definition or declaration
...
Quoted 8 lines
Bisection points to:
commit
065a7d0b92c0f1ef4160e2129d835eb6093cc675
Author: Helge Deller <[email protected]> Date: Tue Oct 17 22:19:53 2023 +0200parisc/power: Add power soft-off when running on qemu commit
d0c219472980d15f5cbc5c8aec736848bda3f235upstream.
Right.
I already asked Greg to drop two patches from all queues where kernel < 6.0:
- parisc-power-add-power-soft-off-when-running-on-qemu.patch
- parisc-power-fix-power-soft-off-when-running-on-qemu.patch
Helge