5.10.237-rc1 review
Subsystems (2)
Greg Kroah-Hartman
maintainerPATCH 161/286 smb: client: fix potential UAF in cifs_debug_files_proc_show()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paulo Alcantara <[email protected]>
commit ca545b7f0823f19db0f1148d59bc5e1a56634502 upstream.
Skip sessions that are being teared down (status == SES_EXITING) to avoid UAF.
[ This patch removes lock/unlock operation in routine cifs_ses_exiting()
for ses_lock is not present in v5.10 and not ported yet. ses->status is protected by a global lock, cifs_tcp_ses_lock, in v5.10. ]
--- fs/cifs/cifs_debug.c | 2 ++ fs/cifs/cifsglob.h | 8 ++++++++ 2 files changed, 10 insertions(+)
fs/cifs/cifs_debug.c +2 -0
@@ -183,6 +183,8 @@ static int cifs_debug_files_proc_show(st tcp_ses_list);list_for_each (tmp, &server->smb_ses_list) { ses = list_entry(tmp, struct cifs_ses, smb_ses_list); +if (cifs_ses_exiting (ses)) +continue ;list_for_each (tmp1, &ses->tcon_list) { tcon = list_entry(tmp1, struct cifs_tcon, tcon_list);spin_lock (&tcon->open_file_lock);
fs/cifs/cifsglob.h +8 -0
@@ -2115,4 +2115,12 @@ static inline struct scatterlist *cifs_s return sg; } +static inline bool cifs_ses_exiting (struct cifs_ses *ses) +{ +bool ret; + + ret = ses->status == CifsExiting; +return ret; +} +#endif /* _CIFS_GLOB_H */
Greg Kroah-Hartman
maintainerPATCH 162/286 smb: client: fix use-after-free bug in cifs_debug_data_proc_show()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paulo Alcantara <[email protected]>
commit d328c09ee9f15ee5a26431f5aad7c9239fa85e62 upstream.
Skip SMB sessions that are being teared down
(e.g. @ses->ses_status == SES_EXITING) in cifs_debug_data_proc_show() to avoid use-after-free in @ses.
This fixes the following GPF when reading from /proc/fs/cifs/DebugData while mounting and umounting
[ 816.251274] general protection fault, probably for non-canonical address 0x6b6b6b6b6b6b6d81: 0000 [#1] PREEMPT SMP NOPTI ... [ 816.260138] Call Trace: [ 816.260329] <TASK> [ 816.260499] ? die_addr+0x36/0x90 [ 816.260762] ? exc_general_protection+0x1b3/0x410 [ 816.261126] ? asm_exc_general_protection+0x26/0x30 [ 816.261502] ? cifs_debug_tcon+0xbd/0x240 [cifs] [ 816.261878] ? cifs_debug_tcon+0xab/0x240 [cifs] [ 816.262249] cifs_debug_data_proc_show+0x516/0xdb0 [cifs] [ 816.262689] ? seq_read_iter+0x379/0x470 [ 816.262995] seq_read_iter+0x118/0x470 [ 816.263291] proc_reg_read_iter+0x53/0x90 [ 816.263596] ? srso_alias_return_thunk+0x5/0x7f [ 816.263945] vfs_read+0x201/0x350 [ 816.264211] ksys_read+0x75/0x100 [ 816.264472] do_syscall_64+0x3f/0x90 [ 816.264750] entry_SYSCALL_64_after_hwframe+0x6e/0xd8 [ 816.265135] RIP: 0033:0x7fd5e669d381
[ This patch removed lock/unlock operation due to ses_lock is not present in v5.10 and not ported yet. ses->status is protected by a global lock, cifs_tcp_ses_lock, in v5.10. ]
--- fs/cifs/cifs_debug.c | 2 ++ 1 file changed, 2 insertions(+)
fs/cifs/cifs_debug.c +2 -0
@@ -358,6 +358,8 @@ skip_rdma:list_for_each (tmp2, &server->smb_ses_list) { ses = list_entry(tmp2, struct cifs_ses, smb_ses_list); +if (ses->status == CifsExiting) +continue ;if ((ses->serverDomain ==NULL ) || (ses->serverOS ==NULL ) || (ses->serverNOS ==NULL )) {
Greg Kroah-Hartman
maintainerPATCH 163/286 cifs: Fix UAF in cifs_demultiplex_thread()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhang Xiaoxu <[email protected]>
commit d527f51331cace562393a8038d870b3e9916686f upstream.
There is a UAF when xfstests on cifs:
BUG: KASAN: use-after-free in smb2_is_network_name_deleted+0x27/0x160 Read of size 4 at addr ffff88810103fc08 by task cifsd/923 CPU: 1 PID: 923 Comm: cifsd Not tainted 6.1.0-rc4+ #45 ... Call Trace: <TASK> dump_stack_lvl+0x34/0x44 print_report+0x171/0x472 kasan_report+0xad/0x130 kasan_check_range+0x145/0x1a0 smb2_is_network_name_deleted+0x27/0x160 cifs_demultiplex_thread.cold+0x172/0x5a4 kthread+0x165/0x1a0 ret_from_fork+0x1f/0x30 </TASK> Allocated by task 923: kasan_save_stack+0x1e/0x40 kasan_set_track+0x21/0x30 __kasan_slab_alloc+0x54/0x60 kmem_cache_alloc+0x147/0x320 mempool_alloc+0xe1/0x260 cifs_small_buf_get+0x24/0x60 allocate_buffers+0xa1/0x1c0 cifs_demultiplex_thread+0x199/0x10d0 kthread+0x165/0x1a0 ret_from_fork+0x1f/0x30 Freed by task 921: kasan_save_stack+0x1e/0x40 kasan_set_track+0x21/0x30 kasan_save_free_info+0x2a/0x40 ____kasan_slab_free+0x143/0x1b0 kmem_cache_free+0xe3/0x4d0 cifs_small_buf_release+0x29/0x90 SMB2_negotiate+0x8b7/0x1c60 smb2_negotiate+0x51/0x70 cifs_negotiate_protocol+0xf0/0x160 cifs_get_smb_ses+0x5fa/0x13c0 mount_get_conns+0x7a/0x750 cifs_mount+0x103/0xd00 cifs_smb3_do_mount+0x1dd/0xcb0 smb3_get_tree+0x1d5/0x300 vfs_get_tree+0x41/0xf0 path_mount+0x9b3/0xdd0 __x64_sys_mount+0x190/0x1d0 do_syscall_64+0x35/0x80 entry_SYSCALL_64_after_hwframe+0x46/0xb0
The UAF is because:
mount(pid: 921) | cifsd(pid: 923)
-------------------------------|-------------------------------
| cifs_demultiplex_thread
SMB2_negotiate |
cifs_send_recv |
compound_send_recv |
smb_send_rqst |
wait_for_response |
wait_event_state [1] |
| standard_receive3
| cifs_handle_standard
| handle_mid
| mid->resp_buf = buf; [2]
| dequeue_mid [3]
KILL the process [4] |
resp_iov[i].iov_base = buf |
free_rsp_buf [5] |
| is_network_name_deleted [6]
| callback1. After send request to server, wait the response until
mid->mid_state != SUBMITTED;
2. Receive response from server, and set it to mid;
3. Set the mid state to RECEIVED;
4. Kill the process, the mid state already RECEIVED, get 0;
5. Handle and release the negotiate response;
6. UAF.
It can be easily reproduce with add some delay in [3] - [6].
Only sync call has the problem since async call's callback is executed in cifsd process.
Add an extra state to mark the mid state to READY before wakeup the waitter, then it can get the resp safely.
[fs/cifs was moved to fs/smb/client since38c8a9a52082 ("smb: move client and server files to common directory fs/smb"). We apply the patch to fs/cifs with some minor context changes.]
--- fs/cifs/cifsglob.h | 1 + fs/cifs/transport.c | 34 +++++++++++++++++++++++----------- 2 files changed, 24 insertions(+), 11 deletions(-)
fs/cifs/cifsglob.h +1 -0
@@ -1768,6 +1768,7 @@ static inline bool is_retryable_error(in#define MID_RETRY_NEEDED 8/* session closed while this request out */ #define MID_RESPONSE_MALFORMED 0x10#define MID_SHUTDOWN 0x20 +#define MID_RESPONSE_READY 0x40/* ready for other process handle the rsp */ /* Flags */ #define MID_WAIT_CANCELLED 1/* Cancelled while waiting for response */
fs/cifs/transport.c +23 -11
@@ -47,6 +47,8 @@void cifs_wake_up_task (struct mid_q_entry *mid) { +if (mid->mid_state ==MID_RESPONSE_RECEIVED ) + mid->mid_state =MID_RESPONSE_READY ;wake_up_process (mid->callback_data); }
@@ -99,7 +101,8 @@ static void _cifs_mid_q_entry_release(ststruct TCP_Server_Info *server = midEntry->server;if (midEntry->resp_buf && (midEntry->mid_flags &MID_WAIT_CANCELLED ) && - midEntry->mid_state ==MID_RESPONSE_RECEIVED && + (midEntry->mid_state ==MID_RESPONSE_RECEIVED || + midEntry->mid_state ==MID_RESPONSE_READY ) && server->ops->handle_cancelled_mid) server->ops->handle_cancelled_mid (midEntry, server);
@@ -733,7 +736,8 @@ wait_for_response(struct TCP_Server_Infoint error; error =wait_event_freezekillable_unsafe (server->response_q, - midQ->mid_state !=MID_REQUEST_SUBMITTED ); + midQ->mid_state !=MID_REQUEST_SUBMITTED && + midQ->mid_state !=MID_RESPONSE_RECEIVED );if (error <0 )return -ERESTARTSYS ;
@@ -885,7 +889,7 @@ cifs_sync_mid_result(struct mid_q_entryspin_lock (&GlobalMid_Lock);switch (mid->mid_state) { -case MID_RESPONSE_RECEIVED : +case MID_RESPONSE_READY :spin_unlock (&GlobalMid_Lock);return rc;case MID_RETRY_NEEDED :
@@ -984,6 +988,9 @@ cifs_compound_callback(struct mid_q_entr credits.instance = server->reconnect_instance;add_credits (server, &credits, mid->optype); + +if (mid->mid_state ==MID_RESPONSE_RECEIVED ) + mid->mid_state =MID_RESPONSE_READY ; } static void
@@ -1172,7 +1179,8 @@ compound_send_recv(const unsigned int xisend_cancel (server, &rqst[i], midQ[i]);spin_lock (&GlobalMid_Lock); midQ[i]->mid_flags |=MID_WAIT_CANCELLED ; -if (midQ[i]->mid_state ==MID_REQUEST_SUBMITTED ) { +if (midQ[i]->mid_state ==MID_REQUEST_SUBMITTED || + midQ[i]->mid_state ==MID_RESPONSE_RECEIVED ) { midQ[i]->callback = cifs_cancelled_callback; cancelled_mid[i] = true; credits[i].value =0 ;
@@ -1193,7 +1201,7 @@ compound_send_recv(const unsigned int xi }if (!midQ[i]->resp_buf || - midQ[i]->mid_state !=MID_RESPONSE_RECEIVED ) { + midQ[i]->mid_state !=MID_RESPONSE_READY ) { rc = -EIO ;cifs_dbg (FYI ,"Bad MID state?\n" ); goto out;
@@ -1372,7 +1380,8 @@ SendReceive(const unsigned int xid, struif (rc !=0 ) {send_cancel (server, &rqst, midQ);spin_lock (&GlobalMid_Lock); -if (midQ->mid_state ==MID_REQUEST_SUBMITTED ) { +if (midQ->mid_state ==MID_REQUEST_SUBMITTED || + midQ->mid_state ==MID_RESPONSE_RECEIVED ) {/* no longer considered to be "in-flight" */ midQ->callback = DeleteMidQEntry;spin_unlock (&GlobalMid_Lock);
@@ -1389,7 +1398,7 @@ SendReceive(const unsigned int xid, stru }if (!midQ->resp_buf || !out_buf || - midQ->mid_state !=MID_RESPONSE_RECEIVED ) { + midQ->mid_state !=MID_RESPONSE_READY ) { rc = -EIO ;cifs_server_dbg (VFS ,"Bad MID state?\n" ); goto out;
@@ -1509,13 +1518,15 @@ SendReceiveBlockingLock(const unsigned i/* Wait for a reply - allow signals to interrupt. */ rc =wait_event_interruptible (server->response_q, - (!(midQ->mid_state ==MID_REQUEST_SUBMITTED )) || + (!(midQ->mid_state ==MID_REQUEST_SUBMITTED || + midQ->mid_state ==MID_RESPONSE_RECEIVED )) || ((server->tcpStatus != CifsGood) && (server->tcpStatus != CifsNew)));/* Were we interrupted by a signal ? */ if ((rc == -ERESTARTSYS ) && - (midQ->mid_state ==MID_REQUEST_SUBMITTED ) && + (midQ->mid_state ==MID_REQUEST_SUBMITTED || + midQ->mid_state ==MID_RESPONSE_RECEIVED ) && ((server->tcpStatus == CifsGood) || (server->tcpStatus == CifsNew))) {
@@ -1545,7 +1556,8 @@ SendReceiveBlockingLock(const unsigned iif (rc) {send_cancel (server, &rqst, midQ);spin_lock (&GlobalMid_Lock); -if (midQ->mid_state ==MID_REQUEST_SUBMITTED ) { +if (midQ->mid_state ==MID_REQUEST_SUBMITTED || + midQ->mid_state ==MID_RESPONSE_RECEIVED ) {/* no longer considered to be "in-flight" */ midQ->callback = DeleteMidQEntry;spin_unlock (&GlobalMid_Lock);
@@ -1563,7 +1575,7 @@ SendReceiveBlockingLock(const unsigned ireturn rc;/* rcvd frame is ok */ -if (out_buf ==NULL || midQ->mid_state !=MID_RESPONSE_RECEIVED ) { +if (out_buf ==NULL || midQ->mid_state !=MID_RESPONSE_READY ) { rc = -EIO ;cifs_tcon_dbg (VFS ,"Bad MID state?\n" ); goto out;
Greg Kroah-Hartman
maintainerPATCH 164/286 smb: client: fix potential deadlock when releasing mids
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paulo Alcantara <[email protected]>
commit e6322fd177c6885a21dd4609dc5e5c973d1a2eb7 upstream.
All release_mid() callers seem to hold a reference of @mid so there is no need to call kref_put(&mid->refcount, __release_mid) under @server->mid_lock spinlock. If they don't, then an use-after-free bug would have occurred anyways.
By getting rid of such spinlock also fixes a potential deadlock as shown below
CPU 0 CPU 1
------------------------------------------------------------------cifs_demultiplex_thread() cifs_debug_data_proc_show()
release_mid()
spin_lock(&server->mid_lock);
spin_lock(&cifs_tcp_ses_lock)
spin_lock(&server->mid_lock) __release_mid()
smb2_find_smb_tcon()
spin_lock(&cifs_tcp_ses_lock) *deadlock*
[cifs_mid_q_entry_release() is renamed to release_mid() and
_cifs_mid_q_entry_release() is renamed to __release_mid() by commit 70f08f914a37 ("cifs: remove useless DeleteMidQEntry()") which is integrated into v6.0, so preserve old names in v5.10.]
--- fs/cifs/cifsproto.h | 7 ++++++- fs/cifs/smb2misc.c | 2 +- fs/cifs/transport.c | 9 +-------- 3 files changed, 8 insertions(+), 10 deletions(-)
fs/cifs/cifsproto.h +6 -1
@@ -85,7 +85,7 @@ extern struct mid_q_entry *AllocMidQEntr struct TCP_Server_Info *server);extern void DeleteMidQEntry (struct mid_q_entry *midEntry);extern void cifs_delete_mid (struct mid_q_entry *mid); -extern void cifs_mid_q_entry_release (struct mid_q_entry *midEntry); +void _cifs_mid_q_entry_release (struct kref *refcount);extern void cifs_wake_up_task (struct mid_q_entry *mid);extern int cifs_handle_standard (struct TCP_Server_Info *server,struct mid_q_entry *mid);
@@ -646,4 +646,9 @@ static inline int cifs_create_options(st return options; } +static inline void cifs_mid_q_entry_release (struct mid_q_entry *midEntry) +{ +kref_put (&midEntry->refcount, _cifs_mid_q_entry_release); +} +#endif /* _CIFSPROTO_H */
fs/cifs/smb2misc.c +1 -1
@@ -780,7 +780,7 @@ __smb2_handle_cancelled_cmd(struct cifs_ {struct close_cancelled_open *cancelled; - cancelled =kzalloc (sizeof (*cancelled),GFP_ATOMIC ); + cancelled =kzalloc (sizeof (*cancelled),GFP_KERNEL );if (!cancelled)return -ENOMEM ;
fs/cifs/transport.c +1 -8
@@ -88,7 +88,7 @@ AllocMidQEntry(const struct smb_hdr *smbreturn temp; } -static void _cifs_mid_q_entry_release (struct kref *refcount) +void _cifs_mid_q_entry_release (struct kref *refcount) {struct mid_q_entry *midEntry = container_of(refcount, struct mid_q_entry, refcount);
@@ -168,13 +168,6 @@ static void _cifs_mid_q_entry_release(stmempool_free (midEntry, cifs_mid_poolp); } -void cifs_mid_q_entry_release (struct mid_q_entry *midEntry) -{ -spin_lock (&GlobalMid_Lock); -kref_put (&midEntry->refcount, _cifs_mid_q_entry_release); -spin_unlock (&GlobalMid_Lock); -} -void DeleteMidQEntry (struct mid_q_entry *midEntry) {cifs_mid_q_entry_release (midEntry);
Greg Kroah-Hartman
maintainerPATCH 165/286 smb: client: fix potential UAF in cifs_stats_proc_show()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paulo Alcantara <[email protected]>
commit 0865ffefea197b437ba78b5dd8d8e256253efd65 upstream.
Skip sessions that are being teared down (status == SES_EXITING) to avoid UAF.
[ cifs_debug.c was moved from fs/cifs to fs/smb/client since
38c8a9a52082 ("smb: move client and server files to common directory fs/smb"). The cifs_ses_exiting() was introduced to cifs_debug.c since ca545b7f0823 ("smb: client: fix potential UAF in cifs_debug_files_proc_show()") which has been sent to upstream already. ]
--- fs/cifs/cifs_debug.c | 2 ++ 1 file changed, 2 insertions(+)
fs/cifs/cifs_debug.c +2 -0
@@ -595,6 +595,8 @@ static int cifs_stats_proc_show(struct slist_for_each (tmp2, &server->smb_ses_list) { ses = list_entry(tmp2, struct cifs_ses, smb_ses_list); +if (cifs_ses_exiting (ses)) +continue ;list_for_each (tmp3, &ses->tcon_list) { tcon = list_entry(tmp3, struct cifs_tcon,
Greg Kroah-Hartman
maintainerPATCH 166/286 smb: client: fix UAF in async decryption
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Enzo Matsumiya <[email protected]>
commit b0abcd65ec545701b8793e12bc27dc98042b151a upstream.
Doing an async decryption (large read) crashes with a slab-use-after-free way down in the crypto API.
Reproducer:
# mount.cifs -o ...,seal,esize=1 //srv/share /mnt
# dd if=/mnt/largefile of=/dev/null
...
[ 194.196391] ==================================================================
[ 194.196844] BUG: KASAN: slab-use-after-free in gf128mul_4k_lle+0xc1/0x110
[ 194.197269] Read of size 8 at addr ffff888112bd0448 by task kworker/u77:2/899
[ 194.197707]
[ 194.197818] CPU: 12 UID: 0 PID: 899 Comm: kworker/u77:2 Not tainted 6.11.0-lku-00028-gfca3ca14a17a-dirty #43
[ 194.198400] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.16.2-3-gd478f380-prebuilt.qemu.org 04/01/2014
[ 194.199046] Workqueue: smb3decryptd smb2_decrypt_offload [cifs]
[ 194.200032] Call Trace:
[ 194.200191] <TASK>
[ 194.200327] dump_stack_lvl+0x4e/0x70
[ 194.200558] ? gf128mul_4k_lle+0xc1/0x110
[ 194.200809] print_report+0x174/0x505
[ 194.201040] ? __pfx__raw_spin_lock_irqsave+0x10/0x10
[ 194.201352] ? srso_return_thunk+0x5/0x5f
[ 194.201604] ? __virt_addr_valid+0xdf/0x1c0
[ 194.201868] ? gf128mul_4k_lle+0xc1/0x110
[ 194.202128] kasan_report+0xc8/0x150
[ 194.202361] ? gf128mul_4k_lle+0xc1/0x110
[ 194.202616] gf128mul_4k_lle+0xc1/0x110
[ 194.202863] ghash_update+0x184/0x210
[ 194.203103] shash_ahash_update+0x184/0x2a0
[ 194.203377] ? __pfx_shash_ahash_update+0x10/0x10
[ 194.203651] ? srso_return_thunk+0x5/0x5f
[ 194.203877] ? crypto_gcm_init_common+0x1ba/0x340
[ 194.204142] gcm_hash_assoc_remain_continue+0x10a/0x140
[ 194.204434] crypt_message+0xec1/0x10a0 [cifs]
[ 194.206489] ? __pfx_crypt_message+0x10/0x10 [cifs]
[ 194.208507] ? srso_return_thunk+0x5/0x5f
[ 194.209205] ? srso_return_thunk+0x5/0x5f
[ 194.209925] ? srso_return_thunk+0x5/0x5f
[ 194.210443] ? srso_return_thunk+0x5/0x5f
[ 194.211037] decrypt_raw_data+0x15f/0x250 [cifs]
[ 194.212906] ? __pfx_decrypt_raw_data+0x10/0x10 [cifs]
[ 194.214670] ? srso_return_thunk+0x5/0x5f
[ 194.215193] smb2_decrypt_offload+0x12a/0x6c0 [cifs]This is because TFM is being used in parallel.
Fix this by allocating a new AEAD TFM for async decryption, but keep the existing one for synchronous READ cases (similar to what is done in smb3_calc_signature()).
Also remove the calls to aead_request_set_callback() and crypto_wait_req() since it's always going to be a synchronous operation.
--- fs/cifs/smb2ops.c | 48 ++++++++++++++++++++++++++++-------------------- fs/cifs/smb2pdu.c | 6 ++++++ 2 files changed, 34 insertions(+), 20 deletions(-)
fs/cifs/smb2ops.c +28 -20
@@ -4291,7 +4291,7 @@ smb2_get_enc_key(struct TCP_Server_Info*/ static int crypt_message (struct TCP_Server_Info *server,int num_rqst, -struct smb_rqst *rqst,int enc) +struct smb_rqst *rqst,int enc,struct crypto_aead *tfm) {struct smb2_transform_hdr *tr_hdr = (struct smb2_transform_hdr *)rqst[0 ].rq_iov[0 ].iov_base;
@@ -4302,8 +4302,6 @@ crypt_message(struct TCP_Server_Info *seu8 key[SMB3_ENC_DEC_KEY_SIZE ];struct aead_request *req;u8 *iv; -DECLARE_CRYPTO_WAIT (wait); -struct crypto_aead *tfm;unsigned int crypt_len =le32_to_cpu (tr_hdr->OriginalMessageSize);void *creq;
@@ -4314,15 +4312,6 @@ crypt_message(struct TCP_Server_Info *sereturn rc; } - rc =smb3_crypto_aead_allocate (server); -if (rc) { -cifs_server_dbg (VFS ,"%s: crypto alloc failed\n" , __func__); -return rc; - } - - tfm = enc ? server->secmech.ccmaesencrypt : - server->secmech.ccmaesdecrypt; -if ((server->cipher_type ==SMB2_ENCRYPTION_AES256_CCM ) || (server->cipher_type ==SMB2_ENCRYPTION_AES256_GCM )) rc =crypto_aead_setkey (tfm, key,SMB3_GCM256_CRYPTKEY_SIZE );
@@ -4361,11 +4350,7 @@ crypt_message(struct TCP_Server_Info *seaead_request_set_crypt (req, sg, sg, crypt_len, iv);aead_request_set_ad (req, assoc_data_len); -aead_request_set_callback (req,CRYPTO_TFM_REQ_MAY_BACKLOG , - crypto_req_done, &wait); - - rc =crypto_wait_req (enc ?crypto_aead_encrypt (req) - :crypto_aead_decrypt (req), &wait); + rc = enc ?crypto_aead_encrypt (req) :crypto_aead_decrypt (req);if (!rc && enc)memcpy (&tr_hdr->Signature, sign,SMB2_SIGNATURE_SIZE );
@@ -4454,7 +4439,7 @@ smb3_init_transform_rq(struct TCP_Server/* fill the 1st iov with a transform header */ fill_transform_hdr (tr_hdr, orig_len, old_rq, server->cipher_type); - rc =crypt_message (server, num_rqst, new_rq,1 ); + rc =crypt_message (server, num_rqst, new_rq,1 , server->secmech.ccmaesencrypt);cifs_dbg (FYI ,"Encrypt message returned %d\n" , rc);if (rc) goto err_free;
@@ -4480,8 +4465,9 @@ decrypt_raw_data(struct TCP_Server_Info unsigned int npages, unsigned int page_data_size, bool is_offloaded) { - struct kvec iov[2]; + struct crypto_aead *tfm;struct smb_rqst rqst = {NULL }; +struct kvec iov[2 ];int rc; iov[0 ].iov_base = buf;
@@ -4496,9 +4482,31 @@ decrypt_raw_data(struct TCP_Server_Info rqst.rq_pagesz =PAGE_SIZE ; rqst.rq_tailsz = (page_data_size %PAGE_SIZE ) ? :PAGE_SIZE ; - rc =crypt_message (server,1 , &rqst,0 ); +if (is_offloaded) { +if ((server->cipher_type ==SMB2_ENCRYPTION_AES128_GCM ) || + (server->cipher_type ==SMB2_ENCRYPTION_AES256_GCM )) + tfm =crypto_alloc_aead ("gcm(aes)" ,0 ,0 ); +else + tfm =crypto_alloc_aead ("ccm(aes)" ,0 ,0 ); +if (IS_ERR (tfm)) { + rc =PTR_ERR (tfm); +cifs_server_dbg (VFS ,"%s: Failed alloc decrypt TFM, rc=%d\n" , __func__, rc); + +return rc; + } + }else { +if (unlikely (!server->secmech.ccmaesdecrypt)) +return -EIO ; + + tfm = server->secmech.ccmaesdecrypt; + } + + rc =crypt_message (server,1 , &rqst,0 , tfm);cifs_dbg (FYI ,"Decrypt message returned %d\n" , rc); +if (is_offloaded) +crypto_free_aead (tfm); +if (rc)return rc;
fs/cifs/smb2pdu.c +6 -0
@@ -998,6 +998,12 @@ SMB2_negotiate(const unsigned int xid, selse cifs_server_dbg (VFS ,"Missing expected negotiate contexts\n" ); } + +if (server->cipher_type && !rc) { + rc =smb3_crypto_aead_allocate (server); +if (rc) +cifs_server_dbg (VFS ,"%s: crypto alloc failed, rc=%d\n" , __func__, rc); + } neg_exit:free_rsp_buf (resp_buftype, rsp);return rc;
Greg Kroah-Hartman
maintainerPATCH 167/286 smb: client: fix NULL ptr deref in crypto_aead_setkey()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paulo Alcantara <[email protected]>
commit 4bdec0d1f658f7c98749bd2c5a486e6cfa8565d2 upstream.
Neither SMB3.0 or SMB3.02 supports encryption negotiate context, so when SMB2_GLOBAL_CAP_ENCRYPTION flag is set in the negotiate response, the client uses AES-128-CCM as the default cipher. See MS-SMB2 3.3.5.4.
Commit b0abcd65ec54 ("smb: client: fix UAF in async decryption") added a @server->cipher_type check to conditionally call smb3_crypto_aead_allocate(), but that check would always be false as @server->cipher_type is unset for SMB3.02.
Fix the following KASAN splat by setting @server->cipher_type for SMB3.02 as well.
mount.cifs //srv/share /mnt -o vers=3.02,seal,...
BUG: KASAN: null-ptr-deref in crypto_aead_setkey+0x2c/0x130 Read of size 8 at addr 0000000000000020 by task mount.cifs/1095 CPU: 1 UID: 0 PID: 1095 Comm: mount.cifs Not tainted 6.12.0 #1 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-3.fc41 04/01/2014 Call Trace: <TASK> dump_stack_lvl+0x5d/0x80 ? crypto_aead_setkey+0x2c/0x130 kasan_report+0xda/0x110 ? crypto_aead_setkey+0x2c/0x130 crypto_aead_setkey+0x2c/0x130 crypt_message+0x258/0xec0 [cifs] ? __asan_memset+0x23/0x50 ? __pfx_crypt_message+0x10/0x10 [cifs] ? mark_lock+0xb0/0x6a0 ? hlock_class+0x32/0xb0 ? mark_lock+0xb0/0x6a0 smb3_init_transform_rq+0x352/0x3f0 [cifs] ? lock_acquire.part.0+0xf4/0x2a0 smb_send_rqst+0x144/0x230 [cifs] ? __pfx_smb_send_rqst+0x10/0x10 [cifs] ? hlock_class+0x32/0xb0 ? smb2_setup_request+0x225/0x3a0 [cifs] ? __pfx_cifs_compound_last_callback+0x10/0x10 [cifs] compound_send_recv+0x59b/0x1140 [cifs] ? __pfx_compound_send_recv+0x10/0x10 [cifs] ? __create_object+0x5e/0x90 ? hlock_class+0x32/0xb0 ? do_raw_spin_unlock+0x9a/0xf0 cifs_send_recv+0x23/0x30 [cifs] SMB2_tcon+0x3ec/0xb30 [cifs] ? __pfx_SMB2_tcon+0x10/0x10 [cifs] ? lock_acquire.part.0+0xf4/0x2a0 ? __pfx_lock_release+0x10/0x10 ? do_raw_spin_trylock+0xc6/0x120 ? lock_acquire+0x3f/0x90 ? _get_xid+0x16/0xd0 [cifs] ? __pfx_SMB2_tcon+0x10/0x10 [cifs] ? cifs_get_smb_ses+0xcdd/0x10a0 [cifs] cifs_get_smb_ses+0xcdd/0x10a0 [cifs] ? __pfx_cifs_get_smb_ses+0x10/0x10 [cifs] ? cifs_get_tcp_session+0xaa0/0xca0 [cifs] cifs_mount_get_session+0x8a/0x210 [cifs] dfs_mount_share+0x1b0/0x11d0 [cifs] ? __pfx___lock_acquire+0x10/0x10 ? __pfx_dfs_mount_share+0x10/0x10 [cifs] ? lock_acquire.part.0+0xf4/0x2a0 ? find_held_lock+0x8a/0xa0 ? hlock_class+0x32/0xb0 ? lock_release+0x203/0x5d0 cifs_mount+0xb3/0x3d0 [cifs] ? do_raw_spin_trylock+0xc6/0x120 ? __pfx_cifs_mount+0x10/0x10 [cifs] ? lock_acquire+0x3f/0x90 ? find_nls+0x16/0xa0 ? smb3_update_mnt_flags+0x372/0x3b0 [cifs] cifs_smb3_do_mount+0x1e2/0xc80 [cifs] ? __pfx_vfs_parse_fs_string+0x10/0x10 ? __pfx_cifs_smb3_do_mount+0x10/0x10 [cifs] smb3_get_tree+0x1bf/0x330 [cifs] vfs_get_tree+0x4a/0x160 path_mount+0x3c1/0xfb0 ? kasan_quarantine_put+0xc7/0x1d0 ? __pfx_path_mount+0x10/0x10 ? kmem_cache_free+0x118/0x3e0 ? user_path_at+0x74/0xa0 __x64_sys_mount+0x1a6/0x1e0 ? __pfx___x64_sys_mount+0x10/0x10 ? mark_held_locks+0x1a/0x90 do_syscall_64+0xbb/0x1d0 entry_SYSCALL_64_after_hwframe+0x77/0x7f
[ Commit b0abcd65ec54 ("smb: client: fix UAF in async decryption")
fixes CVE-2024-50047 but brings NULL-pointer dereferebce. So commit 4bdec0d1f658 ("smb: client: fix NULL ptr deref in crypto_aead_setkey()") should be backported too. ]
--- fs/cifs/smb2pdu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/cifs/smb2pdu.c +3 -1
@@ -963,7 +963,9 @@ SMB2_negotiate(const unsigned int xid, s* SMB3.0 supports only 1 cipher and doesn't have a encryption neg context * Set the cipher type manually. */ -if (server->dialect ==SMB30_PROT_ID && (server->capabilities &SMB2_GLOBAL_CAP_ENCRYPTION )) +if ((server->dialect ==SMB30_PROT_ID || + server->dialect ==SMB302_PROT_ID ) && + (server->capabilities &SMB2_GLOBAL_CAP_ENCRYPTION )) server->cipher_type =SMB2_ENCRYPTION_AES128_CCM ; security_blob = smb2_get_data_area_len(&blob_offset, &blob_length,
Greg Kroah-Hartman
maintainerPATCH 168/286 bpf: avoid holding freeze_mutex during mmap operation
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrii Nakryiko <[email protected]>
commit bc27c52eea189e8f7492d40739b7746d67b65beb upstream.
We use map->freeze_mutex to prevent races between map_freeze() and memory mapping BPF map contents with writable permissions. The way we naively do this means we'll hold freeze_mutex for entire duration of all the mm and VMA manipulations, which is completely unnecessary. This can potentially also lead to deadlocks, as reported by syzbot in [0].
So, instead, hold freeze_mutex only during writeability checks, bump (proactively) "write active" count for the map, unlock the mutex and proceed with mmap logic. And only if something went wrong during mmap logic, then undo that "write active" counter increment.
[0] https://lore.kernel.org/bpf/[email protected]/
--- kernel/bpf/syscall.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
kernel/bpf/syscall.c +10 -7
@@ -647,7 +647,7 @@ static const struct vm_operations_structstatic int bpf_map_mmap (struct file *filp,struct vm_area_struct *vma) {struct bpf_map *map = filp->private_data; -int err; +int err =0 ;if (!map->ops->map_mmap ||map_value_has_spin_lock (map))return -ENOTSUPP ;
@@ -671,7 +671,12 @@ static int bpf_map_mmap(struct file *fil err = -EACCES ; goto out; } +bpf_map_write_active_inc (map); } +out: +mutex_unlock (&map->freeze_mutex); +if (err) +return err;/* set default open/close callbacks */ vma->vm_ops = &bpf_map_default_vmops;
@@ -682,13 +687,11 @@ static int bpf_map_mmap(struct file *fil vma->vm_flags &= ~VM_MAYWRITE ; err = map->ops->map_mmap (map, vma); -if (err) - goto out; +if (err) { +if (vma->vm_flags &VM_WRITE ) +bpf_map_write_active_dec (map); + } -if (vma->vm_flags &VM_MAYWRITE ) -bpf_map_write_active_inc (map); -out: -mutex_unlock (&map->freeze_mutex);return err; }
Greg Kroah-Hartman
maintainerPATCH 169/286 bpf: Check rcu_read_lock_trace_held() before calling bpf map helpers
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hou Tao <[email protected]>
commit 169410eba271afc9f0fb476d996795aa26770c6d upstream.
These three bpf_map_{lookup,update,delete}_elem() helpers are also available for sleepable bpf program, so add the corresponding lock assertion for sleepable bpf program, otherwise the following warning will be reported when a sleepable bpf program manipulates bpf map under interpreter mode (aka bpf_jit_enable=0):
WARNING: CPU: 3 PID: 4985 at kernel/bpf/helpers.c:40 ...... CPU: 3 PID: 4985 Comm: test_progs Not tainted 6.6.0+ #2 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996) ...... RIP: 0010:bpf_map_lookup_elem+0x54/0x60 ...... Call Trace: <TASK> ? __warn+0xa5/0x240 ? bpf_map_lookup_elem+0x54/0x60 ? report_bug+0x1ba/0x1f0 ? handle_bug+0x40/0x80 ? exc_invalid_op+0x18/0x50 ? asm_exc_invalid_op+0x1b/0x20 ? __pfx_bpf_map_lookup_elem+0x10/0x10 ? rcu_lockdep_current_cpu_online+0x65/0xb0 ? rcu_is_watching+0x23/0x50 ? bpf_map_lookup_elem+0x54/0x60 ? __pfx_bpf_map_lookup_elem+0x10/0x10 ___bpf_prog_run+0x513/0x3b70 __bpf_prog_run32+0x9d/0xd0 ? __bpf_prog_enter_sleepable_recur+0xad/0x120 ? __bpf_prog_enter_sleepable_recur+0x3e/0x120 bpf_trampoline_6442580665+0x4d/0x1000 __x64_sys_getpgid+0x5/0x30 ? do_syscall_64+0x36/0xb0 entry_SYSCALL_64_after_hwframe+0x6e/0x76 </TASK>
--- kernel/bpf/helpers.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
kernel/bpf/helpers.c +6 -5
@@ -3,6 +3,7 @@*/ #include <linux/bpf.h> #include <linux/rcupdate.h> +#include <linux/rcupdate_trace.h> #include <linux/random.h> #include <linux/smp.h> #include <linux/topology.h>
@@ -24,12 +25,12 @@* * Different map implementations will rely on rcu in map methods * lookup/update/delete, therefore eBPF programs must run under rcu lock -* if program is allowed to access maps, so check rcu_read_lock_held in -* all three functions. +* if program is allowed to access maps, so check rcu_read_lock_held() or +* rcu_read_lock_trace_held() in all three functions. */ BPF_CALL_2(bpf_map_lookup_elem, struct bpf_map *, map, void *, key) { -WARN_ON_ONCE (!rcu_read_lock_held ()); +WARN_ON_ONCE (!rcu_read_lock_held () && !rcu_read_lock_trace_held ());return (unsigned long ) map->ops->map_lookup_elem (map, key); }
@@ -45,7 +46,7 @@ const struct bpf_func_proto bpf_map_look BPF_CALL_4(bpf_map_update_elem, struct bpf_map *, map, void *, key, void *, value, u64, flags) { -WARN_ON_ONCE (!rcu_read_lock_held ()); +WARN_ON_ONCE (!rcu_read_lock_held () && !rcu_read_lock_trace_held ());return map->ops->map_update_elem (map, key, value, flags); }
@@ -62,7 +63,7 @@ const struct bpf_func_proto bpf_map_upda BPF_CALL_2(bpf_map_delete_elem, struct bpf_map *, map, void *, key) { -WARN_ON_ONCE (!rcu_read_lock_held ()); +WARN_ON_ONCE (!rcu_read_lock_held () && !rcu_read_lock_trace_held ());return map->ops->map_delete_elem (map, key); }
Greg Kroah-Hartman
maintainerPATCH 170/286 blk-cgroup: support to track if policy is online
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yu Kuai <[email protected]>
commit dfd6200a095440b663099d8d42f1efb0175a1ce3 upstream.
A new field 'online' is added to blkg_policy_data to fix following 2 problem:
1) In blkcg_activate_policy(), if pd_alloc_fn() with 'GFP_NOWAIT' failed, 'queue_lock' will be dropped and pd_alloc_fn() will try again without 'GFP_NOWAIT'. In the meantime, remove cgroup can race with it, and pd_offline_fn() will be called without pd_init_fn() and pd_online_fn(). This way null-ptr-deference can be triggered.
2) In order to synchronize pd_free_fn() from blkg_free_workfn() and blkcg_deactivate_policy(), 'list_del_init(&blkg->q_node)' will be delayed to blkg_free_workfn(), hence pd_offline_fn() can be called first in blkg_destroy(), and then blkcg_deactivate_policy() will call it again, we must prevent it.
The new field 'online' will be set after pd_online_fn() and will be cleared after pd_offline_fn(), in the meantime pd_offline_fn() will only be called if 'online' is set.
--- block/blk-cgroup.c | 24 +++++++++++++++++------- include/linux/blk-cgroup.h | 1 + 2 files changed, 18 insertions(+), 7 deletions(-)
block/blk-cgroup.c +17 -7
@@ -191,6 +191,7 @@ static struct blkcg_gq *blkg_alloc(struc blkg->pd[i] = pd; pd->blkg = blkg; pd->plid = i; + pd->online = false; }return blkg;
@@ -288,8 +289,11 @@ static struct blkcg_gq *blkg_create(strufor (i =0 ; i <BLKCG_MAX_POLS ; i++) {struct blkcg_policy *pol = blkcg_policy[i]; -if (blkg->pd[i] && pol->pd_online_fn) - pol->pd_online_fn (blkg->pd[i]); +if (blkg->pd[i]) { +if (pol->pd_online_fn) + pol->pd_online_fn (blkg->pd[i]); + blkg->pd[i]->online = true; + } } } blkg->online = true;
@@ -389,8 +393,11 @@ static void blkg_destroy(struct blkcg_gqfor (i =0 ; i <BLKCG_MAX_POLS ; i++) {struct blkcg_policy *pol = blkcg_policy[i]; -if (blkg->pd[i] && pol->pd_offline_fn) - pol->pd_offline_fn (blkg->pd[i]); +if (blkg->pd[i] && blkg->pd[i]->online) { +if (pol->pd_offline_fn) + pol->pd_offline_fn (blkg->pd[i]); + blkg->pd[i]->online = false; + } } blkg->online = false;
@@ -1364,6 +1371,7 @@ retry: blkg->pd[pol->plid] = pd; pd->blkg = blkg; pd->plid = pol->plid; + pd->online = false; }/* all allocated, init in the same order */
@@ -1371,9 +1379,11 @@ retry:list_for_each_entry_reverse (blkg, &q->blkg_list, q_node) pol->pd_init_fn (blkg->pd[pol->plid]); -if (pol->pd_online_fn) -list_for_each_entry_reverse (blkg, &q->blkg_list, q_node) +list_for_each_entry_reverse (blkg, &q->blkg_list, q_node) { +if (pol->pd_online_fn) pol->pd_online_fn (blkg->pd[pol->plid]); + blkg->pd[pol->plid]->online = true; + }__set_bit (pol->plid, q->blkcg_pols); ret =0 ;
@@ -1435,7 +1445,7 @@ void blkcg_deactivate_policy(struct requspin_lock (&blkcg->lock);if (blkg->pd[pol->plid]) { -if (pol->pd_offline_fn) +if (blkg->pd[pol->plid]->online && pol->pd_offline_fn) pol->pd_offline_fn (blkg->pd[pol->plid]); pol->pd_free_fn (blkg->pd[pol->plid]); blkg->pd[pol->plid] =NULL ;
include/linux/blk-cgroup.h +1 -0
@@ -87,6 +87,7 @@ struct blkg_policy_data {/* the blkg and policy id this per-policy data belongs to */ struct blkcg_gq *blkg;int plid; +bool online; };/*
Greg Kroah-Hartman
maintainerPATCH 171/286 blk-iocost: do not WARN if iocg was already offlined
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li Nan <[email protected]>
commit 01bc4fda9ea0a6b52f12326486f07a4910666cf6 upstream.
In iocg_pay_debt(), warn is triggered if 'active_list' is empty, which is intended to confirm iocg is active when it has debt. However, warn can be triggered during a blkcg or disk removal, if iocg_waitq_timer_fn() is run at that time:
WARNING: CPU: 0 PID: 2344971 at block/blk-iocost.c:1402 iocg_pay_debt+0x14c/0x190 Call trace: iocg_pay_debt+0x14c/0x190 iocg_kick_waitq+0x438/0x4c0 iocg_waitq_timer_fn+0xd8/0x130 __run_hrtimer+0x144/0x45c __hrtimer_run_queues+0x16c/0x244 hrtimer_interrupt+0x2cc/0x7b0
The warn in this situation is meaningless. Since this iocg is being removed, the state of the 'active_list' is irrelevant, and 'waitq_timer' is canceled after removing 'active_list' in ioc_pd_free(), which ensures iocg is freed after iocg_waitq_timer_fn() returns.
Therefore, add the check if iocg was already offlined to avoid warn when removing a blkcg or disk.
--- block/blk-iocost.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
block/blk-iocost.c +5 -2
@@ -1389,8 +1389,11 @@ static void iocg_pay_debt(struct ioc_gqlockdep_assert_held (&iocg->ioc->lock);lockdep_assert_held (&iocg->waitq.lock); -/* make sure that nobody messed with @iocg */ -WARN_ON_ONCE (list_empty (&iocg->active_list)); +/* +* make sure that nobody messed with @iocg. Check iocg->pd.online +* to avoid warn when removing blkcg or disk. +*/ +WARN_ON_ONCE (list_empty (&iocg->active_list) && iocg->pd.online);WARN_ON_ONCE (iocg->inuse >1 ); iocg->abs_vdebt -=min (abs_vpay, iocg->abs_vdebt);
Greg Kroah-Hartman
maintainerPATCH 172/286 ext4: fix timer use-after-free on failed mount
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiaxi Shen <[email protected]>
commit 0ce160c5bdb67081a62293028dc85758a8efb22a upstream.
Syzbot has found an ODEBUG bug in ext4_fill_super
The del_timer_sync function cancels the s_err_report timer, which reminds about filesystem errors daily. We should guarantee the timer is no longer active before kfree(sbi).
When filesystem mounting fails, the flow goes to failed_mount3, where an error occurs when ext4_stop_mmpd is called, causing a read I/O failure. This triggers the ext4_handle_error function that ultimately re-arms the timer,
leaving the s_err_report timer active before kfree(sbi) is called.
Fix the issue by canceling the s_err_report timer after calling ext4_stop_mmpd.
--- fs/ext4/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext4/super.c +1 -1
@@ -5185,8 +5185,8 @@ failed_mount_wq: failed_mount3a:ext4_es_unregister_shrinker (sbi); failed_mount3: -del_timer_sync (&sbi->s_err_report);ext4_stop_mmpd (sbi); +del_timer_sync (&sbi->s_err_report); failed_mount2:rcu_read_lock (); group_desc =rcu_dereference (sbi->s_group_desc);
Greg Kroah-Hartman
maintainerPATCH 173/286 net/mlx5e: Fix use-after-free of encap entry in neigh update handler
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vlad Buslov <[email protected]>
commit fb1a3132ee1ac968316e45d21a48703a6db0b6c3 upstream.
Function mlx5e_rep_neigh_update() wasn't updated to accommodate rtnl lock removal from TC filter update path and properly handle concurrent encap entry insertion/deletion which can lead to following use-after-free:
[23827.464923] ================================================================== [23827.469446] BUG: KASAN: use-after-free in mlx5e_encap_take+0x72/0x140 [mlx5_core] [23827.470971] Read of size 4 at addr ffff8881d132228c by task kworker/u20:6/21635 [23827.472251] [23827.472615] CPU: 9 PID: 21635 Comm: kworker/u20:6 Not tainted 5.13.0-rc3+ #5 [23827.473788] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014 [23827.475639] Workqueue: mlx5e mlx5e_rep_neigh_update [mlx5_core] [23827.476731] Call Trace: [23827.477260] dump_stack+0xbb/0x107 [23827.477906] print_address_description.constprop.0+0x18/0x140 [23827.478896] ? mlx5e_encap_take+0x72/0x140 [mlx5_core] [23827.479879] ? mlx5e_encap_take+0x72/0x140 [mlx5_core] [23827.480905] kasan_report.cold+0x7c/0xd8 [23827.481701] ? mlx5e_encap_take+0x72/0x140 [mlx5_core] [23827.482744] kasan_check_range+0x145/0x1a0 [23827.493112] mlx5e_encap_take+0x72/0x140 [mlx5_core] [23827.494054] ? mlx5e_tc_tun_encap_info_equal_generic+0x140/0x140 [mlx5_core] [23827.495296] mlx5e_rep_neigh_update+0x41e/0x5e0 [mlx5_core] [23827.496338] ? mlx5e_rep_neigh_entry_release+0xb80/0xb80 [mlx5_core] [23827.497486] ? read_word_at_a_time+0xe/0x20 [23827.498250] ? strscpy+0xa0/0x2a0 [23827.498889] process_one_work+0x8ac/0x14e0 [23827.499638] ? lockdep_hardirqs_on_prepare+0x400/0x400 [23827.500537] ? pwq_dec_nr_in_flight+0x2c0/0x2c0 [23827.501359] ? rwlock_bug.part.0+0x90/0x90 [23827.502116] worker_thread+0x53b/0x1220 [23827.502831] ? process_one_work+0x14e0/0x14e0 [23827.503627] kthread+0x328/0x3f0 [23827.504254] ? _raw_spin_unlock_irq+0x24/0x40 [23827.505065] ? __kthread_bind_mask+0x90/0x90 [23827.505912] ret_from_fork+0x1f/0x30 [23827.506621] [23827.506987] Allocated by task 28248: [23827.507694] kasan_save_stack+0x1b/0x40 [23827.508476] __kasan_kmalloc+0x7c/0x90 [23827.509197] mlx5e_attach_encap+0xde1/0x1d40 [mlx5_core] [23827.510194] mlx5e_tc_add_fdb_flow+0x397/0xc40 [mlx5_core] [23827.511218] __mlx5e_add_fdb_flow+0x519/0xb30 [mlx5_core] [23827.512234] mlx5e_configure_flower+0x191c/0x4870 [mlx5_core] [23827.513298] tc_setup_cb_add+0x1d5/0x420 [23827.514023] fl_hw_replace_filter+0x382/0x6a0 [cls_flower] [23827.514975] fl_change+0x2ceb/0x4a51 [cls_flower] [23827.515821] tc_new_tfilter+0x89a/0x2070 [23827.516548] rtnetlink_rcv_msg+0x644/0x8c0 [23827.517300] netlink_rcv_skb+0x11d/0x340 [23827.518021] netlink_unicast+0x42b/0x700 [23827.518742] netlink_sendmsg+0x743/0xc20 [23827.519467] sock_sendmsg+0xb2/0xe0 [23827.520131] ____sys_sendmsg+0x590/0x770 [23827.520851] ___sys_sendmsg+0xd8/0x160 [23827.521552] __sys_sendmsg+0xb7/0x140 [23827.522238] do_syscall_64+0x3a/0x70 [23827.522907] entry_SYSCALL_64_after_hwframe+0x44/0xae [23827.523797] [23827.524163] Freed by task 25948: [23827.524780] kasan_save_stack+0x1b/0x40 [23827.525488] kasan_set_track+0x1c/0x30 [23827.526187] kasan_set_free_info+0x20/0x30 [23827.526968] __kasan_slab_free+0xed/0x130 [23827.527709] slab_free_freelist_hook+0xcf/0x1d0 [23827.528528] kmem_cache_free_bulk+0x33a/0x6e0 [23827.529317] kfree_rcu_work+0x55f/0xb70 [23827.530024] process_one_work+0x8ac/0x14e0 [23827.530770] worker_thread+0x53b/0x1220 [23827.531480] kthread+0x328/0x3f0 [23827.532114] ret_from_fork+0x1f/0x30 [23827.532785] [23827.533147] Last potentially related work creation: [23827.534007] kasan_save_stack+0x1b/0x40 [23827.534710] kasan_record_aux_stack+0xab/0xc0 [23827.535492] kvfree_call_rcu+0x31/0x7b0 [23827.536206] mlx5e_tc_del_fdb_flow+0x577/0xef0 [mlx5_core] [23827.537305] mlx5e_flow_put+0x49/0x80 [mlx5_core] [23827.538290] mlx5e_delete_flower+0x6d1/0xe60 [mlx5_core] [23827.539300] tc_setup_cb_destroy+0x18e/0x2f0 [23827.540144] fl_hw_destroy_filter+0x1d2/0x310 [cls_flower] [23827.541148] __fl_delete+0x4dc/0x660 [cls_flower] [23827.541985] fl_delete+0x97/0x160 [cls_flower] [23827.542782] tc_del_tfilter+0x7ab/0x13d0 [23827.543503] rtnetlink_rcv_msg+0x644/0x8c0 [23827.544257] netlink_rcv_skb+0x11d/0x340 [23827.544981] netlink_unicast+0x42b/0x700 [23827.545700] netlink_sendmsg+0x743/0xc20 [23827.546424] sock_sendmsg+0xb2/0xe0 [23827.547084] ____sys_sendmsg+0x590/0x770 [23827.547850] ___sys_sendmsg+0xd8/0x160 [23827.548606] __sys_sendmsg+0xb7/0x140 [23827.549303] do_syscall_64+0x3a/0x70 [23827.549969] entry_SYSCALL_64_after_hwframe+0x44/0xae [23827.550853] [23827.551217] The buggy address belongs to the object at ffff8881d1322200 [23827.551217] which belongs to the cache kmalloc-256 of size 256 [23827.553341] The buggy address is located 140 bytes inside of [23827.553341] 256-byte region [ffff8881d1322200, ffff8881d1322300) [23827.555747] The buggy address belongs to the page: [23827.556847] page:00000000898762aa refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1d1320 [23827.558651] head:00000000898762aa order:2 compound_mapcount:0 compound_pincount:0 [23827.559961] flags: 0x2ffff800010200(slab|head|node=0|zone=2|lastcpupid=0x1ffff) [23827.561243] raw: 002ffff800010200 dead000000000100 dead000000000122 ffff888100042b40 [23827.562653] raw: 0000000000000000 0000000000200020 00000001ffffffff 0000000000000000 [23827.564112] page dumped because: kasan: bad access detected [23827.565439] [23827.565932] Memory state around the buggy address: [23827.566917] ffff8881d1322180: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc [23827.568485] ffff8881d1322200: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb [23827.569818] >ffff8881d1322280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb [23827.571143] ^ [23827.571879] ffff8881d1322300: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc [23827.573283] ffff8881d1322380: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc [23827.574654] ==================================================================
Most of the necessary logic is already correctly implemented by mlx5e_get_next_valid_encap() helper that is used in neigh stats update handler. Make the handler generic by renaming it to mlx5e_get_next_matching_encap() and use callback to test whether flow is matching instead of hardcoded check for 'valid' flag value. Implement mlx5e_get_next_valid_encap() by calling mlx5e_get_next_matching_encap() with callback that tests encap MLX5_ENCAP_ENTRY_VALID flag. Implement new mlx5e_get_next_init_encap() helper by calling mlx5e_get_next_matching_encap() with callback that tests encap completion result to be non-error and use it in mlx5e_rep_neigh_update() to safely iterate over nhe->encap_list.
Remove encap completion logic from mlx5e_rep_update_flows() since the encap entries passed to this function are already guaranteed to be properly initialized by similar code in mlx5e_get_next_init_encap().
[ since kernel 5.10 doesn't have commit 0d9f96471493
("net/mlx5e: Extract tc tunnel encap/decap code to dedicated file") which moved encap/decap from en_tc.c to tc_tun_encap.c, so backport and move the additional functions to en_tc.c instead of tc_tun_encap.c ]
--- drivers/net/ethernet/mellanox/mlx5/core/en/rep/neigh.c | 17 +++----- drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c | 6 --- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 33 +++++++++++++++-- drivers/net/ethernet/mellanox/mlx5/core/en_tc.h | 3 + 4 files changed, 41 insertions(+), 18 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/rep/neigh.c +7 -10
@@ -129,9 +129,8 @@ static void mlx5e_rep_neigh_update(struc work);struct mlx5e_neigh_hash_entry *nhe = update_work->nhe;struct neighbour *n = update_work->n; -struct mlx5e_encap_entry *e; +struct mlx5e_encap_entry *e =NULL ;unsigned char ha[ETH_ALEN ]; -struct mlx5e_priv *priv;bool neigh_connected;u8 nud_state, dead;
@@ -152,14 +151,12 @@ static void mlx5e_rep_neigh_update(structrace_mlx5e_rep_neigh_update (nhe, ha, neigh_connected); -list_for_each_entry (e, &nhe->encap_list, encap_list) { -if (!mlx5e_encap_take (e)) -continue ; - - priv =netdev_priv (e->out_dev); -mlx5e_rep_update_flows (priv, e, neigh_connected, ha); -mlx5e_encap_put (priv, e); - } +/* mlx5e_get_next_init_encap() releases previous encap before returning +* the next one. +*/ +while ((e =mlx5e_get_next_init_encap (nhe, e)) !=NULL ) +mlx5e_rep_update_flows (netdev_priv (e->out_dev), e, neigh_connected, ha); +rtnl_unlock ();mlx5e_release_neigh_update_work (update_work); }
drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c +1 -5
@@ -91,13 +91,9 @@ void mlx5e_rep_update_flows(struct mlx5eASSERT_RTNL (); -/* wait for encap to be fully initialized */ -wait_for_completion (&e->res_ready); -mutex_lock (&esw->offloads.encap_tbl_lock); encap_connected = !!(e->flags &MLX5_ENCAP_ENTRY_VALID ); -if (e->compl_result <0 || (encap_connected == neigh_connected && -ether_addr_equal (e->h_dest, ha))) +if (encap_connected == neigh_connected &ðer_addr_equal (e->h_dest, ha)) goto unlock;mlx5e_take_all_encap_flows (e, &flow_list);
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +30 -3
@@ -1653,9 +1653,12 @@ void mlx5e_put_encap_flow_list(struct mlmlx5e_flow_put (priv, flow); } +typedef bool (match_cb )(struct mlx5e_encap_entry *); +static struct mlx5e_encap_entry * -mlx5e_get_next_valid_encap (struct mlx5e_neigh_hash_entry *nhe, -struct mlx5e_encap_entry *e) +mlx5e_get_next_matching_encap (struct mlx5e_neigh_hash_entry *nhe, +struct mlx5e_encap_entry *e, +match_cb match) {struct mlx5e_encap_entry *next =NULL ;
@@ -1690,7 +1693,7 @@ retry:/* wait for encap to be fully initialized */ wait_for_completion (&next->res_ready);/* continue searching if encap entry is not in valid state after completion */ -if (!(next->flags &MLX5_ENCAP_ENTRY_VALID )) { +if (!match (next)) { e = next; goto retry; }
@@ -1698,6 +1701,30 @@ retry:return next; } +static bool mlx5e_encap_valid (struct mlx5e_encap_entry *e) +{ +return e->flags &MLX5_ENCAP_ENTRY_VALID ; +} + +static struct mlx5e_encap_entry * +mlx5e_get_next_valid_encap (struct mlx5e_neigh_hash_entry *nhe, +struct mlx5e_encap_entry *e) +{ +return mlx5e_get_next_matching_encap (nhe, e, mlx5e_encap_valid); +} + +static bool mlx5e_encap_initialized (struct mlx5e_encap_entry *e) +{ +return e->compl_result >=0 ; +} + +struct mlx5e_encap_entry * +mlx5e_get_next_init_encap (struct mlx5e_neigh_hash_entry *nhe, +struct mlx5e_encap_entry *e) +{ +return mlx5e_get_next_matching_encap (nhe, e, mlx5e_encap_initialized); +} +void mlx5e_tc_update_neigh_used_value (struct mlx5e_neigh_hash_entry *nhe) {struct mlx5e_neigh *m_neigh = &nhe->m_neigh;
drivers/net/ethernet/mellanox/mlx5/core/en_tc.h +3 -0
@@ -161,6 +161,9 @@ void mlx5e_take_all_encap_flows(struct mvoid mlx5e_put_encap_flow_list (struct mlx5e_priv *priv,struct list_head *flow_list);struct mlx5e_neigh_hash_entry ; +struct mlx5e_encap_entry * +mlx5e_get_next_init_encap (struct mlx5e_neigh_hash_entry *nhe, +struct mlx5e_encap_entry *e);void mlx5e_tc_update_neigh_used_value (struct mlx5e_neigh_hash_entry *nhe);void mlx5e_tc_reoffload_flows_work (struct work_struct *work);
Greg Kroah-Hartman
maintainerPATCH 174/286 ipvs: properly dereference pe in ip_vs_add_service
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen Hanxiao <[email protected]>
commit cbd070a4ae62f119058973f6d2c984e325bce6e7 upstream.
Use pe directly to resolve sparse warning:
net/netfilter/ipvs/ip_vs_ctl.c:1471:27: warning: dereference of noderef expression
--- net/netfilter/ipvs/ip_vs_ctl.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
net/netfilter/ipvs/ip_vs_ctl.c +5 -5
@@ -1384,20 +1384,20 @@ ip_vs_add_service(struct netns_ipvs *ipv sched =NULL ; } -/* Bind the ct retriever */ -RCU_INIT_POINTER (svc->pe, pe); - pe =NULL ; -/* Update the virtual service counters */ if (svc->port ==FTPPORT )atomic_inc (&ipvs->ftpsvc_counter);else if (svc->port ==0 )atomic_inc (&ipvs->nullsvc_counter); -if (svc->pe && svc->pe->conn_out) +if (pe && pe->conn_out)atomic_inc (&ipvs->conn_out_counter);ip_vs_start_estimator (ipvs, &svc->stats); +/* Bind the ct retriever */ +RCU_INIT_POINTER (svc->pe, pe); + pe =NULL ; +/* Count only IPv4 services for old get/setsockopt interface */ if (svc->af ==AF_INET ) ipvs->num_services++;
Greg Kroah-Hartman
maintainerPATCH 175/286 net: openvswitch: fix race on port output
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felix Huettner <[email protected]>
commit 066b86787fa3d97b7aefb5ac0a99a22dad2d15f8 upstream.
assume the following setup on a single machine:
1. An openvswitch instance with one bridge and default flows
2. two network namespaces "server" and "client"
3. two ovs interfaces "server" and "client" on the bridge
4. for each ovs interface a veth pair with a matching name and 32 rx and tx queues
5. move the ends of the veth pairs to the respective network namespaces
6. assign ip addresses to each of the veth ends in the namespaces (needs to be the same subnet)
7. start some http server on the server network namespace
8. test if a client in the client namespace can reach the http server
when following the actions below the host has a chance of getting a cpu stuck in a infinite loop:
1. send a large amount of parallel requests to the http server (around 3000 curls should work)
2. in parallel delete the network namespace (do not delete interfaces or stop the server, just kill the namespace)
there is a low chance that this will cause the below kernel cpu stuck message. If this does not happen just retry.
Below there is also the output of bpftrace for the functions mentioned in the output.
The series of events happening here is:
1. the network namespace is deleted calling unregister_netdevice_many_notify somewhere in the process
2. this sets first NETREG_UNREGISTERING on both ends of the veth and then runs synchronize_net
3. it then calls call_netdevice_notifiers with NETDEV_UNREGISTER
4. this is then handled by dp_device_event which calls ovs_netdev_detach_dev (if a vport is found, which is the case for the veth interface attached to ovs)
5. this removes the rx_handlers of the device but does not prevent packages to be sent to the device
6. dp_device_event then queues the vport deletion to work in background as a ovs_lock is needed that we do not hold in the unregistration path
7. unregister_netdevice_many_notify continues to call netdev_unregister_kobject which sets real_num_tx_queues to 0
8. port deletion continues (but details are not relevant for this issue)
9. at some future point the background task deletes the vport
If after 7. but before 9. a packet is send to the ovs vport (which is not deleted at this point in time) which forwards it to the dev_queue_xmit flow even though the device is unregistering. In skb_tx_hash (which is called in the dev_queue_xmit) path there is a while loop (if the packet has a rx_queue recorded) that is infinite if dev->real_num_tx_queues is zero.
To prevent this from happening we update do_output to handle devices without carrier the same as if the device is not found (which would be the code path after 9. is done).
Additionally we now produce a warning in skb_tx_hash if we will hit the infinite loop.
bpftrace (first word is function name):
__dev_queue_xmit server: real_num_tx_queues: 1, cpu: 2, pid: 28024, tid: 28024, skb_addr: 0xffff9edb6f207000, reg_state: 1 netdev_core_pick_tx server: addr: 0xffff9f0a46d4a000 real_num_tx_queues: 1, cpu: 2, pid: 28024, tid: 28024, skb_addr: 0xffff9edb6f207000, reg_state: 1 dp_device_event server: real_num_tx_queues: 1 cpu 9, pid: 21024, tid: 21024, event 2, reg_state: 1synchronize_rcu_expedited: cpu 9, pid: 21024, tid: 21024synchronize_rcu_expedited: cpu 9, pid: 21024, tid: 21024synchronize_rcu_expedited: cpu 9, pid: 21024, tid: 21024synchronize_rcu_expedited: cpu 9, pid: 21024, tid: 21024dp_device_event server: real_num_tx_queues: 1 cpu 9, pid: 21024, tid: 21024, event 6, reg_state: 2ovs_netdev_detach_dev server: real_num_tx_queues: 1 cpu 9, pid: 21024, tid: 21024, reg_state: 2netdev_rx_handler_unregister server: real_num_tx_queues: 1, cpu: 9, pid: 21024, tid: 21024, reg_state: 2synchronize_rcu_expedited: cpu 9, pid: 21024, tid: 21024netdev_rx_handler_unregister ret server: real_num_tx_queues: 1, cpu: 9, pid: 21024, tid: 21024, reg_state: 2dp_device_event server: real_num_tx_queues: 1 cpu 9, pid: 21024, tid: 21024, event 27, reg_state: 2dp_device_event server: real_num_tx_queues: 1 cpu 9, pid: 21024, tid: 21024, event 22, reg_state: 2dp_device_event server: real_num_tx_queues: 1 cpu 9, pid: 21024, tid: 21024, event 18, reg_state: 2netdev_unregister_kobject: real_num_tx_queues: 1, cpu: 9, pid: 21024, tid: 21024synchronize_rcu_expedited: cpu 9, pid: 21024, tid: 21024ovs_vport_send server: real_num_tx_queues: 0, cpu: 2, pid: 28024, tid: 28024, skb_addr: 0xffff9edb6f207000, reg_state: 2 __dev_queue_xmit server: real_num_tx_queues: 0, cpu: 2, pid: 28024, tid: 28024, skb_addr: 0xffff9edb6f207000, reg_state: 2 netdev_core_pick_tx server: addr: 0xffff9f0a46d4a000 real_num_tx_queues: 0, cpu: 2, pid: 28024, tid: 28024, skb_addr: 0xffff9edb6f207000, reg_state: 2 broken device server: real_num_tx_queues: 0, cpu: 2, pid: 28024, tid: 28024ovs_dp_detach_port server: real_num_tx_queues: 0 cpu 9, pid: 9124, tid: 9124, reg_state: 2synchronize_rcu_expedited: cpu 9, pid: 33604, tid: 33604
stuck message:
watchdog: BUG: soft lockup - CPU#5 stuck for 26s! [curl:1929279] Modules linked in: veth pktgen bridge stp llc ip_set_hash_net nft_counter xt_set nft_compat nf_tables ip_set_hash_ip ip_set nfnetlink_cttimeout nfnetlink openvswitch nsh nf_conncount nf_nat nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 tls binfmt_misc nls_iso8859_1 input_leds joydev serio_raw dm_multipath scsi_dh_rdac scsi_dh_emc scsi_dh_alua sch_fq_codel drm efi_pstore virtio_rng ip_tables x_tables autofs4 btrfs blake2b_generic zstd_compress raid10 raid456 async_raid6_recov async_memcpy async_pq async_xor async_tx xor raid6_pq libcrc32c raid1 raid0 multipath linear hid_generic usbhid hid crct10dif_pclmul crc32_pclmul ghash_clmulni_intel aesni_intel virtio_net ahci net_failover crypto_simd cryptd psmouse libahci virtio_blk failover CPU: 5 PID: 1929279 Comm: curl Not tainted 5.15.0-67-generic #74-Ubuntu Hardware name: OpenStack Foundation OpenStack Nova, BIOS rel-1.16.0-0-gd239552ce722-prebuilt.qemu.org 04/01/2014 RIP: 0010:netdev_pick_tx+0xf1/0x320 Code: 00 00 8d 48 ff 0f b7 c1 66 39 ca 0f 86 e9 01 00 00 45 0f b7 ff 41 39 c7 0f 87 5b 01 00 00 44 29 f8 41 39 c7 0f 87 4f 01 00 00 <eb> f2 0f 1f 44 00 00 49 8b 94 24 28 04 00 00 48 85 d2 0f 84 53 01 RSP: 0018:ffffb78b40298820 EFLAGS: 00000246 RAX: 0000000000000000 RBX: ffff9c8773adc2e0 RCX: 000000000000083f RDX: 0000000000000000 RSI: ffff9c8773adc2e0 RDI: ffff9c870a25e000 RBP: ffffb78b40298858 R08: 0000000000000001 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000000 R12: ffff9c870a25e000 R13: ffff9c870a25e000 R14: ffff9c87fe043480 R15: 0000000000000000 FS: 00007f7b80008f00(0000) GS:ffff9c8e5f740000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f7b80f6a0b0 CR3: 0000000329d66000 CR4: 0000000000350ee0 Call Trace: <IRQ> netdev_core_pick_tx+0xa4/0xb0 __dev_queue_xmit+0xf8/0x510 ? __bpf_prog_exit+0x1e/0x30 dev_queue_xmit+0x10/0x20 ovs_vport_send+0xad/0x170 [openvswitch] do_output+0x59/0x180 [openvswitch] do_execute_actions+0xa80/0xaa0 [openvswitch] ? kfree+0x1/0x250 ? kfree+0x1/0x250 ? kprobe_perf_func+0x4f/0x2b0 ? flow_lookup.constprop.0+0x5c/0x110 [openvswitch] ovs_execute_actions+0x4c/0x120 [openvswitch] ovs_dp_process_packet+0xa1/0x200 [openvswitch] ? ovs_ct_update_key.isra.0+0xa8/0x120 [openvswitch] ? ovs_ct_fill_key+0x1d/0x30 [openvswitch] ? ovs_flow_key_extract+0x2db/0x350 [openvswitch] ovs_vport_receive+0x77/0xd0 [openvswitch] ? __htab_map_lookup_elem+0x4e/0x60 ? bpf_prog_680e8aff8547aec1_kfree+0x3b/0x714 ? trace_call_bpf+0xc8/0x150 ? kfree+0x1/0x250 ? kfree+0x1/0x250 ? kprobe_perf_func+0x4f/0x2b0 ? kprobe_perf_func+0x4f/0x2b0 ? __mod_memcg_lruvec_state+0x63/0xe0 netdev_port_receive+0xc4/0x180 [openvswitch] ? netdev_port_receive+0x180/0x180 [openvswitch] netdev_frame_hook+0x1f/0x40 [openvswitch] __netif_receive_skb_core.constprop.0+0x23d/0xf00 __netif_receive_skb_one_core+0x3f/0xa0 __netif_receive_skb+0x15/0x60 process_backlog+0x9e/0x170 __napi_poll+0x33/0x180 net_rx_action+0x126/0x280 ? ttwu_do_activate+0x72/0xf0 __do_softirq+0xd9/0x2e7 ? rcu_report_exp_cpu_mult+0x1b0/0x1b0 do_softirq+0x7d/0xb0 </IRQ> <TASK> __local_bh_enable_ip+0x54/0x60 ip_finish_output2+0x191/0x460 __ip_finish_output+0xb7/0x180 ip_finish_output+0x2e/0xc0 ip_output+0x78/0x100 ? __ip_finish_output+0x180/0x180 ip_local_out+0x5e/0x70 __ip_queue_xmit+0x184/0x440 ? tcp_syn_options+0x1f9/0x300 ip_queue_xmit+0x15/0x20 __tcp_transmit_skb+0x910/0x9c0 ? __mod_memcg_state+0x44/0xa0 tcp_connect+0x437/0x4e0 ? ktime_get_with_offset+0x60/0xf0 tcp_v4_connect+0x436/0x530 __inet_stream_connect+0xd4/0x3a0 ? kprobe_perf_func+0x4f/0x2b0 ? aa_sk_perm+0x43/0x1c0 inet_stream_connect+0x3b/0x60 __sys_connect_file+0x63/0x70 __sys_connect+0xa6/0xd0 ? setfl+0x108/0x170 ? do_fcntl+0xe8/0x5a0 __x64_sys_connect+0x18/0x20 do_syscall_64+0x5c/0xc0 ? __x64_sys_fcntl+0xa9/0xd0 ? exit_to_user_mode_prepare+0x37/0xb0 ? syscall_exit_to_user_mode+0x27/0x50 ? do_syscall_64+0x69/0xc0 ? __sys_setsockopt+0xea/0x1e0 ? exit_to_user_mode_prepare+0x37/0xb0 ? syscall_exit_to_user_mode+0x27/0x50 ? __x64_sys_setsockopt+0x1f/0x30 ? do_syscall_64+0x69/0xc0 ? irqentry_exit+0x1d/0x30 ? exc_page_fault+0x89/0x170 entry_SYSCALL_64_after_hwframe+0x61/0xcb RIP: 0033:0x7f7b8101c6a7 Code: 64 89 01 48 83 c8 ff c3 66 2e 0f 1f 84 00 00 00 00 00 90 f3 0f 1e fa 64 8b 04 25 18 00 00 00 85 c0 75 10 b8 2a 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 51 c3 48 83 ec 18 89 54 24 0c 48 89 34 24 89 RSP: 002b:00007ffffd6b2198 EFLAGS: 00000246 ORIG_RAX: 000000000000002a RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f7b8101c6a7 RDX: 0000000000000010 RSI: 00007ffffd6b2360 RDI: 0000000000000005 RBP: 0000561f1370d560 R08: 00002795ad21d1ac R09: 0030312e302e302e R10: 00007ffffd73f080 R11: 0000000000000246 R12: 0000561f1370c410 R13: 0000000000000000 R14: 0000000000000005 R15: 0000000000000000 </TASK>
--- net/core/dev.c | 1 + net/openvswitch/actions.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)
net/core/dev.c +1 -0
@@ -3186,6 +3186,7 @@ static u16 skb_tx_hash(const struct net_ }if (skb_rx_queue_recorded (skb)) { +BUILD_BUG_ON_INVALID (qcount ==0 ); hash =skb_get_rx_queue (skb);if (hash >= qoffset) hash -= qoffset;
net/openvswitch/actions.c +1 -1
@@ -912,7 +912,7 @@ static void do_output(struct datapath *d {struct vport *vport =ovs_vport_rcu (dp, out_port); -if (likely (vport)) { +if (likely (vport &&netif_carrier_ok (vport->dev))) {u16 mru =OVS_CB (skb)->mru;u32 cutlen =OVS_CB (skb)->cutlen;
Greg Kroah-Hartman
maintainerPATCH 176/286 openvswitch: fix lockup on tx to unregistering netdev with carrier
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilya Maximets <[email protected]>
commit 47e55e4b410f7d552e43011baa5be1aab4093990 upstream.
Commit in a fixes tag attempted to fix the issue in the following sequence of calls:
do_output
-> ovs_vport_send
-> dev_queue_xmit
-> __dev_queue_xmit
-> netdev_core_pick_tx
-> skb_tx_hashWhen device is unregistering, the 'dev->real_num_tx_queues' goes to zero and the 'while (unlikely(hash >= qcount))' loop inside the 'skb_tx_hash' becomes infinite, locking up the core forever.
But unfortunately, checking just the carrier status is not enough to fix the issue, because some devices may still be in unregistering state while reporting carrier status OK.
One example of such device is a net/dummy. It sets carrier ON on start, but it doesn't implement .ndo_stop to set the carrier off. And it makes sense, because dummy doesn't really have a carrier. Therefore, while this device is unregistering, it's still easy to hit the infinite loop in the skb_tx_hash() from the OVS datapath. There might be other drivers that do the same, but dummy by itself is important for the OVS ecosystem, because it is frequently used as a packet sink for tcpdump while debugging OVS deployments. And when the issue is hit, the only way to recover is to reboot.
Fix that by also checking if the device is running. The running state is handled by the net core during unregistering, so it covers unregistering case better, and we don't really need to send packets to devices that are not running anyway.
While only checking the running state might be enough, the carrier check is preserved. The running and the carrier states seem disjoined throughout the code and different drivers. And other core functions like __dev_direct_xmit() check both before attempting to transmit a packet. So, it seems safer to check both flags in OVS as well.
--- net/openvswitch/actions.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/openvswitch/actions.c +3 -1
@@ -912,7 +912,9 @@ static void do_output(struct datapath *d {struct vport *vport =ovs_vport_rcu (dp, out_port); -if (likely (vport &&netif_carrier_ok (vport->dev))) { +if (likely (vport && +netif_running (vport->dev) && +netif_carrier_ok (vport->dev))) {u16 mru =OVS_CB (skb)->mru;u32 cutlen =OVS_CB (skb)->cutlen;
Greg Kroah-Hartman
maintainerPATCH 177/286 scsi: lpfc: Fix a possible data race in lpfc_unregister_fcf_rescan()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tuo Li <[email protected]>
commit 0e881c0a4b6146b7e856735226208f48251facd8 upstream.
The variable phba->fcf.fcf_flag is often protected by the lock phba->hbalock() when is accessed. Here is an example in lpfc_unregister_fcf_rescan():
spin_lock_irq(&phba->hbalock); phba->fcf.fcf_flag |= FCF_INIT_DISC; spin_unlock_irq(&phba->hbalock);
However, in the same function, phba->fcf.fcf_flag is assigned with 0 without holding the lock, and thus can cause a data race:
phba->fcf.fcf_flag = 0;
To fix this possible data race, a lock and unlock pair is added when accessing the variable phba->fcf.fcf_flag.
--- drivers/scsi/lpfc/lpfc_hbadisc.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/scsi/lpfc/lpfc_hbadisc.c +2 -0
@@ -6790,7 +6790,9 @@ lpfc_unregister_fcf_rescan(struct lpfc_hif (rc)return ;/* Reset HBA FCF states after successful unregister FCF */ +spin_lock_irq (&phba->hbalock); phba->fcf.fcf_flag =0 ; +spin_unlock_irq (&phba->hbalock); phba->fcf.current_rec.flag =0 ;/*
Greg Kroah-Hartman
maintainerPATCH 178/286 scsi: ufs: bsg: Set bsg_queue to NULL after removal
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guixin Liu <[email protected]>
commit 1e95c798d8a7f70965f0f88d4657b682ff0ec75f upstream.
Currently, this does not cause any issues, but I believe it is necessary to set bsg_queue to NULL after removing it to prevent potential use-after-free (UAF) access.
--- drivers/scsi/ufs/ufs_bsg.c | 1 + 1 file changed, 1 insertion(+)
drivers/scsi/ufs/ufs_bsg.c +1 -0
@@ -175,6 +175,7 @@ void ufs_bsg_remove(struct ufs_hba *hba)return ;bsg_remove_queue (hba->bsg_queue); + hba->bsg_queue =NULL ;device_del (bsg_dev);put_device (bsg_dev);
Greg Kroah-Hartman
maintainerPATCH 179/286 net: defer final struct net free in netns dismantle
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
commit 0f6ede9fbc747e2553612271bce108f7517e7a45 upstream.
Ilya reported a slab-use-after-free in dst_destroy [1]
Issue is in xfrm6_net_init() and xfrm4_net_init() :
They copy xfrm[46]_dst_ops_template into net->xfrm.xfrm[46]_dst_ops.
But net structure might be freed before all the dst callbacks are called. So when dst_destroy() calls later :
if (dst->ops->destroy)
dst->ops->destroy(dst);
dst->ops points to the old net->xfrm.xfrm[46]_dst_ops, which has been freed.
See a relevant issue fixed in :
ac888d58869b ("net: do not delay dst_entries_add() in dst_release()")
A fix is to queue the 'struct net' to be freed after one another cleanup_net() round (and existing rcu_barrier())
[1]
BUG: KASAN: slab-use-after-free in dst_destroy (net/core/dst.c:112) Read of size 8 at addr ffff8882137ccab0 by task swapper/37/0 Dec 03 05:46:18 kernel: CPU: 37 UID: 0 PID: 0 Comm: swapper/37 Kdump: loaded Not tainted 6.12.0 #67 Hardware name: Red Hat KVM/RHEL, BIOS 1.16.1-1.el9 04/01/2014 Call Trace: <IRQ>
dump_stack_lvl (lib/dump_stack.c:124)
print_address_description.constprop.0 (mm/kasan/report.c:378)
? dst_destroy (net/core/dst.c:112)print_report (mm/kasan/report.c:489)
? dst_destroy (net/core/dst.c:112)
? kasan_addr_to_slab (mm/kasan/common.c:37)kasan_report (mm/kasan/report.c:603)
? dst_destroy (net/core/dst.c:112)
? rcu_do_batch (kernel/rcu/tree.c:2567)dst_destroy (net/core/dst.c:112)rcu_do_batch (kernel/rcu/tree.c:2567)
? __pfx_rcu_do_batch (kernel/rcu/tree.c:2491)
? lockdep_hardirqs_on_prepare (kernel/locking/lockdep.c:4339 kernel/locking/lockdep.c:4406) rcu_core (kernel/rcu/tree.c:2825)handle_softirqs (kernel/softirq.c:554)__irq_exit_rcu (kernel/softirq.c:589 kernel/softirq.c:428 kernel/softirq.c:637) irq_exit_rcu (kernel/softirq.c:651)
sysvec_apic_timer_interrupt (arch/x86/kernel/apic/apic.c:1049 arch/x86/kernel/apic/apic.c:1049) </IRQ> <TASK> asm_sysvec_apic_timer_interrupt (./arch/x86/include/asm/idtentry.h:702) RIP: 0010:default_idle (./arch/x86/include/asm/irqflags.h:37 ./arch/x86/include/asm/irqflags.h:92 arch/x86/kernel/process.c:743) Code: 00 4d 29 c8 4c 01 c7 4c 29 c2 e9 6e ff ff ff 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 66 90 0f 00 2d c7 c9 27 00 fb f4 <fa> c3 cc cc cc cc 66 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 90 RSP: 0018:ffff888100d2fe00 EFLAGS: 00000246 RAX: 00000000001870ed RBX: 1ffff110201a5fc2 RCX: ffffffffb61a3e46 RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffffffffb3d4d123 RBP: 0000000000000000 R08: 0000000000000001 R09: ffffed11c7e1835d R10: ffff888e3f0c1aeb R11: 0000000000000000 R12: 0000000000000000 R13: ffff888100d20000 R14: dffffc0000000000 R15: 0000000000000000
? ct_kernel_exit.constprop.0 (kernel/context_tracking.c:148) ? cpuidle_idle_call (kernel/sched/idle.c:186) default_idle_call (./include/linux/cpuidle.h:143 kernel/sched/idle.c:118) cpuidle_idle_call (kernel/sched/idle.c:186)
? __pfx_cpuidle_idle_call (kernel/sched/idle.c:168)
? lock_release (kernel/locking/lockdep.c:467 kernel/locking/lockdep.c:5848) ? lockdep_hardirqs_on_prepare (kernel/locking/lockdep.c:4347 kernel/locking/lockdep.c:4406) ? tsc_verify_tsc_adjust (arch/x86/kernel/tsc_sync.c:59) do_idle (kernel/sched/idle.c:326) cpu_startup_entry (kernel/sched/idle.c:423 (discriminator 1)) start_secondary (arch/x86/kernel/smpboot.c:202 arch/x86/kernel/smpboot.c:282) ? __pfx_start_secondary (arch/x86/kernel/smpboot.c:232) ? soft_restart_cpu (arch/x86/kernel/head_64.S:452) common_startup_64 (arch/x86/kernel/head_64.S:414) </TASK> Dec 03 05:46:18 kernel: Allocated by task 12184: kasan_save_stack (mm/kasan/common.c:48) kasan_save_track (./arch/x86/include/asm/current.h:49 mm/kasan/common.c:60 mm/kasan/common.c:69) __kasan_slab_alloc (mm/kasan/common.c:319 mm/kasan/common.c:345) kmem_cache_alloc_noprof (mm/slub.c:4085 mm/slub.c:4134 mm/slub.c:4141) copy_net_ns (net/core/net_namespace.c:421 net/core/net_namespace.c:480)
create_new_namespaces (kernel/nsproxy.c:110) unshare_nsproxy_namespaces (kernel/nsproxy.c:228 (discriminator 4)) ksys_unshare (kernel/fork.c:3313)__x64_sys_unshare (kernel/fork.c:3382)do_syscall_64 (arch/x86/entry/common.c:52 arch/x86/entry/common.c:83) entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:130)
Dec 03 05:46:18 kernel: Freed by task 11:
kasan_save_stack (mm/kasan/common.c:48)kasan_save_track (./arch/x86/include/asm/current.h:49 mm/kasan/common.c:60 mm/kasan/common.c:69) kasan_save_free_info (mm/kasan/generic.c:582)__kasan_slab_free (mm/kasan/common.c:271)
kmem_cache_free (mm/slub.c:4579 mm/slub.c:4681) cleanup_net (net/core/net_namespace.c:456 net/core/net_namespace.c:446 net/core/net_namespace.c:647)
process_one_work (kernel/workqueue.c:3229) worker_thread (kernel/workqueue.c:3304 kernel/workqueue.c:3391) kthread (kernel/kthread.c:389)ret_from_fork (arch/x86/kernel/process.c:147) ret_from_fork_asm (arch/x86/entry/entry_64.S:257)
Dec 03 05:46:18 kernel: Last potentially related work creation:
kasan_save_stack (mm/kasan/common.c:48)__kasan_record_aux_stack (mm/kasan/generic.c:541)insert_work (./include/linux/instrumented.h:68 ./include/asm-generic/bitops/instrumented-non-atomic.h:141 kernel/workqueue.c:788 kernel/workqueue.c:795 kernel/workqueue.c:2186) __queue_work (kernel/workqueue.c:2340)queue_work_on (kernel/workqueue.c:2391)xfrm_policy_insert (net/xfrm/xfrm_policy.c:1610)xfrm_add_policy (net/xfrm/xfrm_user.c:2116)xfrm_user_rcv_msg (net/xfrm/xfrm_user.c:3321)netlink_rcv_skb (net/netlink/af_netlink.c:2536)xfrm_netlink_rcv (net/xfrm/xfrm_user.c:3344)netlink_unicast (net/netlink/af_netlink.c:1316 net/netlink/af_netlink.c:1342)netlink_sendmsg (net/netlink/af_netlink.c:1886)
sock_write_iter (net/socket.c:729 net/socket.c:744 net/socket.c:1165) vfs_write (fs/read_write.c:590 fs/read_write.c:683) ksys_write (fs/read_write.c:736) do_syscall_64 (arch/x86/entry/common.c:52 arch/x86/entry/common.c:83) entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:130) Dec 03 05:46:18 kernel: Second to last potentially related work creation:
kasan_save_stack (mm/kasan/common.c:48)__kasan_record_aux_stack (mm/kasan/generic.c:541)insert_work (./include/linux/instrumented.h:68 ./include/asm-generic/bitops/instrumented-non-atomic.h:141 kernel/workqueue.c:788 kernel/workqueue.c:795 kernel/workqueue.c:2186) __queue_work (kernel/workqueue.c:2340)queue_work_on (kernel/workqueue.c:2391)
__xfrm_state_insert (./include/linux/workqueue.h:723 net/xfrm/xfrm_state.c:1150 net/xfrm/xfrm_state.c:1145 net/xfrm/xfrm_state.c:1513) xfrm_state_update (./include/linux/spinlock.h:396 net/xfrm/xfrm_state.c:1940)
xfrm_add_sa (net/xfrm/xfrm_user.c:912)xfrm_user_rcv_msg (net/xfrm/xfrm_user.c:3321)netlink_rcv_skb (net/netlink/af_netlink.c:2536)xfrm_netlink_rcv (net/xfrm/xfrm_user.c:3344)netlink_unicast (net/netlink/af_netlink.c:1316 net/netlink/af_netlink.c:1342) netlink_sendmsg (net/netlink/af_netlink.c:1886)
sock_write_iter (net/socket.c:729 net/socket.c:744 net/socket.c:1165) vfs_write (fs/read_write.c:590 fs/read_write.c:683)
ksys_write (fs/read_write.c:736)do_syscall_64 (arch/x86/entry/common.c:52 arch/x86/entry/common.c:83) entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:130)
--- include/net/net_namespace.h | 1 + net/core/net_namespace.c | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-)
include/net/net_namespace.h +1 -0
@@ -80,6 +80,7 @@ struct net {* or to unregister pernet ops * (pernet_ops_rwsem write locked). */ +struct llist_node defer_free_list;struct llist_node cleanup_list;/* namespaces on death row */ #ifdef CONFIG_KEYS
net/core/net_namespace.c +20 -1
@@ -455,11 +455,28 @@ out_free: goto out; } +static LLIST_HEAD (defer_free_list); + +static void net_complete_free (void ) +{ +struct llist_node *kill_list; +struct net *net, *next; + +/* Get the list of namespaces to free from last round. */ + kill_list =llist_del_all (&defer_free_list); + +llist_for_each_entry_safe (net, next, kill_list, defer_free_list) +kmem_cache_free (net_cachep, net); + +} +static void net_free (struct net *net) {if (refcount_dec_and_test (&net->passive)) {kfree (rcu_access_pointer (net->gen)); -kmem_cache_free (net_cachep, net); + +/* Wait for an extra rcu_barrier() before final free. */ +llist_add (&net->defer_free_list, &defer_free_list); } }
@@ -643,6 +660,8 @@ static void cleanup_net(struct work_stru*/ rcu_barrier (); +net_complete_free (); +/* Finally it is safe to free my network namespace structure */ list_for_each_entry_safe (net, tmp, &net_exit_list, exit_list) {list_del_init (&net->exit_list);
Greg Kroah-Hartman
maintainerPATCH 180/286 MIPS: dec: Declare which_prom() as static
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: WangYuli <[email protected]>
commit 55fa5868519bc48a7344a4c070efa2f4468f2167 upstream.
Declare which_prom() as static to suppress gcc compiler warning that 'missing-prototypes'. This function is not intended to be called from other parts.
Fix follow error with gcc-14 when -Werror:
arch/mips/dec/prom/init.c:45:13: error: no previous prototype for ‘which_prom’ [-Werror=missing-prototypes]
45 | void __init which_prom(s32 magic, s32 *prom_vec)
| ^~~~~~~~~~
cc1: all warnings being treated as errors
make[6]: *** [scripts/Makefile.build:207: arch/mips/dec/prom/init.o] Error 1 make[5]: *** [scripts/Makefile.build:465: arch/mips/dec/prom] Error 2 make[5]: *** Waiting for unfinished jobs....
--- arch/mips/dec/prom/init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/dec/prom/init.c +1 -1
@@ -42,7 +42,7 @@ int (*__pmax_close)(int);* Detect which PROM the DECSTATION has, and set the callback vectors * appropriately. */ -void __init which_prom (s32 magic,s32 *prom_vec) +static void __init which_prom (s32 magic,s32 *prom_vec) {/* * No sign of the REX PROM's magic number means we assume a non-REX
Greg Kroah-Hartman
maintainerPATCH 181/286 MIPS: cevt-ds1287: Add missing ds1287.h include
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: WangYuli <[email protected]>
commit f3be225f338a578851a7b607a409f476354a8deb upstream.
Address the issue of cevt-ds1287.c not including the ds1287.h header file.
Fix follow errors with gcc-14 when -Werror:
arch/mips/kernel/cevt-ds1287.c:15:5: error: no previous prototype for ‘ds1287_timer_state’ [-Werror=missing-prototypes]
15 | int ds1287_timer_state(void)
| ^~~~~~~~~~~~~~~~~~
arch/mips/kernel/cevt-ds1287.c:20:5: error: no previous prototype for ‘ds1287_set_base_clock’ [-Werror=missing-prototypes]
20 | int ds1287_set_base_clock(unsigned int hz)
| ^~~~~~~~~~~~~~~~~~~~~
arch/mips/kernel/cevt-ds1287.c:103:12: error: no previous prototype for ‘ds1287_clockevent_init’ [-Werror=missing-prototypes]
103 | int __init ds1287_clockevent_init(int irq)
| ^~~~~~~~~~~~~~~~~~~~~~cc1: all warnings being treated as errors
make[7]: *** [scripts/Makefile.build:207: arch/mips/kernel/cevt-ds1287.o] Error 1 make[7]: *** Waiting for unfinished jobs....
make[6]: *** [scripts/Makefile.build:465: arch/mips/kernel] Error 2 make[6]: *** Waiting for unfinished jobs....
--- arch/mips/kernel/cevt-ds1287.c | 1 + 1 file changed, 1 insertion(+)
arch/mips/kernel/cevt-ds1287.c +1 -0
@@ -10,6 +10,7 @@#include <linux/mc146818rtc.h> #include <linux/irq.h> +#include <asm/ds1287.h> #include <asm/time.h> int ds1287_timer_state (void )
Greg Kroah-Hartman
maintainerPATCH 182/286 MIPS: ds1287: Match ds1287_set_base_clock() function types
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: WangYuli <[email protected]>
commit a759109b234385b74d2f5f4c86b5f59b3201ec12 upstream.
Synchronize the declaration of ds1287_set_base_clock() between cevt-ds1287.c and ds1287.h.
Fix follow error with gcc-14 when -Werror:
arch/mips/kernel/cevt-ds1287.c:21:5: error: conflicting types for ‘ds1287_set_base_clock’; have ‘int(unsigned int)’
21 | int ds1287_set_base_clock(unsigned int hz)
| ^~~~~~~~~~~~~~~~~~~~~
In file included from arch/mips/kernel/cevt-ds1287.c:13:
./arch/mips/include/asm/ds1287.h:11:13: note: previous declaration of ‘ds1287_set_base_clock’ with type ‘void(unsigned int)’
11 | extern void ds1287_set_base_clock(unsigned int clock);
| ^~~~~~~~~~~~~~~~~~~~~make[7]: *** [scripts/Makefile.build:207: arch/mips/kernel/cevt-ds1287.o] Error 1 make[6]: *** [scripts/Makefile.build:465: arch/mips/kernel] Error 2 make[6]: *** Waiting for unfinished jobs....
--- arch/mips/include/asm/ds1287.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/include/asm/ds1287.h +1 -1
@@ -8,7 +8,7 @@#define __ASM_DS1287_Hextern int ds1287_timer_state (void ); -extern void ds1287_set_base_clock (unsigned int clock); +extern int ds1287_set_base_clock (unsigned int hz);extern int ds1287_clockevent_init (int irq);#endif
Greg Kroah-Hartman
maintainerPATCH 183/286 jfs: Fix shift-out-of-bounds in dbDiscardAG
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pei Li <[email protected]>
commit 7063b80268e2593e58bee8a8d709c2f3ff93e2f2 upstream.
When searching for the next smaller log2 block, BLKSTOL2() returned 0, causing shift exponent -1 to be negative.
This patch fixes the issue by exiting the loop directly when negative shift is found.
--- fs/jfs/jfs_dmap.c | 2 ++ 1 file changed, 2 insertions(+)
fs/jfs/jfs_dmap.c +2 -0
@@ -1698,6 +1698,8 @@ s64 dbDiscardAG(struct inode *ip, int ag }else if (rc == -ENOSPC ) {/* search for next smaller log2 block */ l2nb =BLKSTOL2 (nblocks) -1 ; +if (unlikely (l2nb <0 )) +break ; nblocks =1LL << l2nb; }else {/* Trim any already allocated blocks */
Greg Kroah-Hartman
maintainerPATCH 184/286 dm cache: fix flushing uninitialized delayed_work on cache_ctr error
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ming-Hung Tsai <[email protected]>
commit 135496c208ba26fd68cdef10b64ed7a91ac9a7ff upstream.
An unexpected WARN_ON from flush_work() may occur when cache creation fails, caused by destroying the uninitialized delayed_work waker in the error path of cache_create(). For example, the warning appears on the superblock checksum error.
Reproduce steps:
dmsetup create cmeta --table "0 8192 linear /dev/sdc 0" dmsetup create cdata --table "0 65536 linear /dev/sdc 8192" dmsetup create corig --table "0 524288 linear /dev/sdc 262144" dd if=/dev/urandom of=/dev/mapper/cmeta bs=4k count=1 oflag=direct dmsetup create cache --table "0 524288 cache /dev/mapper/cmeta \/dev/mapper/cdata /dev/mapper/corig 128 2 metadata2 writethrough smq 0"
Kernel logs:
(snip)
WARNING: CPU: 0 PID: 84 at kernel/workqueue.c:4178 __flush_work+0x5d4/0x890
Fix by pulling out the cancel_delayed_work_sync() from the constructor's error path. This patch doesn't affect the use-after-free fix for concurrent dm_resume and dm_destroy (commit 6a459d8edbdb ("dm cache: Fix UAF in destroy()")) as cache_dtr is not changed.
--- drivers/md/dm-cache-target.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-)
drivers/md/dm-cache-target.c +15 -9
@@ -1960,16 +1960,13 @@ static void check_migrations(struct work* This function gets called on the error paths of the constructor, so we * have to cope with a partially initialised struct. */ -static void destroy (struct cache *cache) +static void __destroy (struct cache *cache) { -unsigned i; -mempool_exit (&cache->migration_pool);if (cache->prison)dm_bio_prison_destroy_v2 (cache->prison); -cancel_delayed_work_sync (&cache->waker);if (cache->wq)destroy_workqueue (cache->wq);
@@ -1997,13 +1994,22 @@ static void destroy(struct cache *cache)if (cache->policy)dm_cache_policy_destroy (cache->policy); +bioset_exit (&cache->bs); + +kfree (cache); +} + +static void destroy (struct cache *cache) +{ +unsigned int i; + +cancel_delayed_work_sync (&cache->waker); +for (i =0 ; i < cache->nr_ctr_args ; i++)kfree (cache->ctr_args[i]);kfree (cache->ctr_args); -bioset_exit (&cache->bs); - -kfree (cache); +__destroy (cache); }static void cache_dtr (struct dm_target *ti)
@@ -2616,7 +2622,7 @@ static int cache_create(struct cache_arg *result = cache;return 0 ; bad: -destroy (cache); +__destroy (cache);return r; }
@@ -2667,7 +2673,7 @@ static int cache_ctr(struct dm_target *t r =copy_ctr_args (cache, argc -3 , (const char **)argv +3 );if (r) { -destroy (cache); +__destroy (cache); goto out; }
Greg Kroah-Hartman
maintainerPATCH 185/286 vfio/pci: fix memory leak during D3hot to D0 transition
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abhishek Sahu <[email protected]>
commit eadf88ecf6ac7d6a9f47a76c6055d9a1987a8991 upstream.
If 'vfio_pci_core_device::needs_pm_restore' is set (PCI device does not have No_Soft_Reset bit set in its PMCSR config register), then the current PCI state will be saved locally in 'vfio_pci_core_device::pm_save' during D0->D3hot transition and same will be restored back during D3hot->D0 transition.
For saving the PCI state locally, pci_store_saved_state() is being used and the pci_load_and_free_saved_state() will free the allocated memory.
But for reset related IOCTLs, vfio driver calls PCI reset-related API's which will internally change the PCI power state back to D0. So, when the guest resumes, then it will get the current state as D0 and it will skip the call to vfio_pci_set_power_state() for changing the power state to D0 explicitly. In this case, the memory pointed by 'pm_save' will never be freed. In a malicious sequence, the state changing to D3hot followed by VFIO_DEVICE_RESET/VFIO_DEVICE_PCI_HOT_RESET can be run in a loop and it can cause an OOM situation.
This patch frees the earlier allocated memory first before overwriting 'pm_save' to prevent the mentioned memory leak.
--- drivers/vfio/pci/vfio_pci.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/vfio/pci/vfio_pci.c +13 -0
@@ -299,6 +299,19 @@ int vfio_pci_set_power_state(struct vfioif (!ret) {/* D3 might be unsupported via quirk, skip unless in D3 */ if (needs_save && pdev->current_state >= PCI_D3hot) { +/* +* The current PCI state will be saved locally in +* 'pm_save' during the D3hot transition. When the +* device state is changed to D0 again with the current +* function, then pci_store_saved_state() will restore +* the state and will free the memory pointed by +* 'pm_save'. There are few cases where the PCI power +* state can be changed to D0 without the involvement +* of the driver. For these cases, free the earlier +* allocated memory first before overwriting 'pm_save' +* to prevent the memory leak. +*/ +kfree (vdev->pm_save); vdev->pm_save =pci_store_saved_state (pdev); }else if (needs_restore) {pci_load_and_free_saved_state (pdev, &vdev->pm_save);
Greg Kroah-Hartman
maintainerPATCH 186/286 kernel/resource: fix kfree() of bootmem memory again
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miaohe Lin <[email protected]>
commit 0cbcc92917c5de80f15c24d033566539ad696892 upstream.
Since commit ebff7d8f270d ("mem hotunplug: fix kfree() of bootmem memory"), we could get a resource allocated during boot via alloc_resource(). And it's required to release the resource using free_resource(). Howerver, many people use kfree directly which will result in kernel BUG. In order to fix this without fixing every call site, just leak a couple of bytes in such corner case.
--- kernel/resource.c | 41 ++++++++--------------------------------- 1 file changed, 8 insertions(+), 33 deletions(-)
kernel/resource.c +8 -33
@@ -53,14 +53,6 @@ struct resource_constraint {static DEFINE_RWLOCK (resource_lock); -/* -* For memory hotplug, there is no way to free resource entries allocated -* by boot mem after the system is up. So for reusing the resource entry -* we need to remember the resource. -*/ -static struct resource *bootmem_resource_free; -static DEFINE_SPINLOCK (bootmem_resource_lock); -static struct resource *next_resource (struct resource *p,bool sibling_only) {/* Caller wants to traverse through siblings only */
@@ -149,36 +141,19 @@ __initcall(ioresources_init);static void free_resource (struct resource *res) { -if (!res) -return ; - -if (!PageSlab (virt_to_head_page (res))) { -spin_lock (&bootmem_resource_lock); - res->sibling = bootmem_resource_free; - bootmem_resource_free = res; -spin_unlock (&bootmem_resource_lock); - }else { +/** +* If the resource was allocated using memblock early during boot +* we'll leak it here: we can only return full pages back to the +* buddy and trying to be smart and reusing them eventually in +* alloc_resource() overcomplicates resource handling. +*/ +if (res &&PageSlab (virt_to_head_page (res)))kfree (res); - } }static struct resource *alloc_resource (gfp_t flags) { -struct resource *res =NULL ; - -spin_lock (&bootmem_resource_lock); -if (bootmem_resource_free) { - res = bootmem_resource_free; - bootmem_resource_free = res->sibling; - } -spin_unlock (&bootmem_resource_lock); - -if (res) -memset (res,0 ,sizeof (struct resource )); -else - res =kzalloc (sizeof (struct resource ), flags); - -return res; +return kzalloc (sizeof (struct resource ), flags); }/* Return the conflict entry if you can't request it */
Greg Kroah-Hartman
maintainerPATCH 187/286 drm/i915/gt: Cleanup partial engine discovery failures
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Wilson <[email protected]>
commit 78a033433a5ae4fee85511ee075bc9a48312c79e upstream.
If we abort driver initialisation in the middle of gt/engine discovery, some engines will be fully setup and some not. Those incompletely setup engines only have 'engine->release == NULL' and so will leak any of the common objects allocated.
v2:
- Drop the destroy_pinned_context() helper for now. It's not really worth it with just a single callsite at the moment. (Janusz)
--- drivers/gpu/drm/i915/gt/intel_engine_cs.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/gt/intel_engine_cs.c +6 -1
@@ -904,8 +904,13 @@ int intel_engines_init(struct intel_gt *return err; err =setup (engine); -if (err) +if (err) { +intel_engine_cleanup_common (engine);return err; + } + +/* The backend should now be responsible for cleanup */ +GEM_BUG_ON (engine->release ==NULL ); err =engine_init_common (engine);if (err)
Greg Kroah-Hartman
maintainerPATCH 188/286 fs/proc: do_task_stat: use sig->stats_lock to gather the threads/children stats
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oleg Nesterov <[email protected]>
commit 7601df8031fd67310af891897ef6cc0df4209305 upstream.
lock_task_sighand() can trigger a hard lockup. If NR_CPUS threads call do_task_stat() at the same time and the process has NR_THREADS, it will spin with irqs disabled O(NR_CPUS * NR_THREADS) time.
Change do_task_stat() to use sig->stats_lock to gather the statistics outside of ->siglock protected section, in the likely case this code will run lockless.
--- fs/proc/array.c | 52 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 22 deletions(-)
fs/proc/array.c +30 -22
@@ -443,12 +443,12 @@ static int do_task_stat(struct seq_fileint permitted;struct mm_struct *mm;unsigned long long start_time; -unsigned long cmin_flt =0 , cmaj_flt =0 ; -unsigned long min_flt =0 , maj_flt =0 ; -u64 cutime, cstime, utime, stime; -u64 cgtime, gtime; +unsigned long cmin_flt, cmaj_flt, min_flt, maj_flt; +u64 cutime, cstime, cgtime, utime, stime, gtime;unsigned long rsslim =0 ;unsigned long flags; +struct signal_struct *sig = task->signal; +unsigned int seq =1 ; state = *get_task_state (task); vsize = eip = esp =0 ;
@@ -476,12 +476,9 @@ static int do_task_stat(struct seq_filesigemptyset (&sigign);sigemptyset (&sigcatch); - cutime = cstime = utime = stime =0 ; - cgtime = gtime =0 ; + utime = stime =0 ;if (lock_task_sighand (task, &flags)) { -struct signal_struct *sig = task->signal; -if (sig->tty) {struct pid *pgrp =tty_get_pgrp (sig->tty); tty_pgrp =pid_nr_ns (pgrp, ns);
@@ -492,37 +489,48 @@ static int do_task_stat(struct seq_file num_threads =get_nr_threads (task);collect_sigign_sigcatch (task, &sigign, &sigcatch); + rsslim =READ_ONCE (sig->rlim[RLIMIT_RSS ].rlim_cur); + + sid =task_session_nr_ns (task, ns); + ppid =task_tgid_nr_ns (task->real_parent, ns); + pgid =task_pgrp_nr_ns (task, ns); + +unlock_task_sighand (task, &flags); + } + +if (permitted && (!whole || num_threads <2 )) + wchan =get_wchan (task); + + do { + seq++; /* 2 on the 1st/lockless path, otherwise odd */ + flags = read_seqbegin_or_lock_irqsave(&sig->stats_lock, &seq); + cmin_flt = sig->cmin_flt; cmaj_flt = sig->cmaj_flt; cutime = sig->cutime; cstime = sig->cstime; cgtime = sig->cgtime; - rsslim =READ_ONCE (sig->rlim[RLIMIT_RSS ].rlim_cur); -/* add up live thread stats at the group level */ if (whole) { struct task_struct *t = task; + + min_flt = sig->min_flt; + maj_flt = sig->maj_flt; + gtime = sig->gtime; + + rcu_read_lock(); do { min_flt += t->min_flt; maj_flt += t->maj_flt; gtime += task_gtime(t); } while_each_thread(task, t); + rcu_read_unlock(); - min_flt += sig->min_flt; - maj_flt += sig->maj_flt; thread_group_cputime_adjusted(task, &utime, &stime); - gtime += sig->gtime; } + } while (need_seqretry(&sig->stats_lock, seq)); + done_seqretry_irqrestore(&sig->stats_lock, seq, flags); - sid = task_session_nr_ns(task, ns); - ppid = task_tgid_nr_ns(task->real_parent, ns); - pgid = task_pgrp_nr_ns(task, ns); - - unlock_task_sighand(task, &flags); - } - - if (permitted && (!whole || num_threads < 2)) - wchan = get_wchan(task); if (!whole) { min_flt = task->min_flt; maj_flt = task->maj_flt;
Greg Kroah-Hartman
maintainerPATCH 189/286 mm: fix apply_to_existing_page_range()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kirill A. Shutemov <[email protected]>
commit a995199384347261bb3f21b2e171fa7f988bd2f8 upstream.
In the case of apply_to_existing_page_range(), apply_to_pte_range() is reached with 'create' set to false. When !create, the loop over the PTE page table is broken.
apply_to_pte_range() will only move to the next PTE entry if 'create' is true or if the current entry is not pte_none().
This means that the user of apply_to_existing_page_range() will not have 'fn' called for any entries after the first pte_none() in the PTE page table.
Fix the loop logic in apply_to_pte_range().
There are no known runtime issues from this, but the fix is trivial enough for stable@ even without a known buggy user.
--- mm/memory.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
mm/memory.c +2 -2
@@ -2469,11 +2469,11 @@ static int apply_to_pte_range(struct mm_if (fn) {do {if (create || !pte_none (*pte)) { - err =fn (pte++, addr, data); + err =fn (pte, addr, data);if (err)break ; } - }while (addr +=PAGE_SIZE , addr != end); + }while (pte++, addr +=PAGE_SIZE , addr != end); } *mask |=PGTBL_PTE_MODIFIED ;
Greg Kroah-Hartman
maintainerPATCH 190/286 drivers: staging: rtl8723bs: Fix deadlock in rtw_surveydone_event_callback()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Duoming Zhou <[email protected]>
commit cc7ad0d77b51c872d629bcd98aea463a3c4109e7 upstream.
There is a deadlock in rtw_surveydone_event_callback(), which is shown below:
(Thread 1) | (Thread 2)
| _set_timer()
rtw_surveydone_event_callback()| mod_timer()
spin_lock_bh() //(1) | (wait a time)
... | rtw_scan_timeout_handler()
del_timer_sync() | spin_lock_bh() //(2)
(wait timer to stop) | ...We hold pmlmepriv->lock in position (1) of thread 1 and use del_timer_sync() to wait timer to stop, but timer handler also need pmlmepriv->lock in position (2) of thread 2. As a result, rtw_surveydone_event_callback() will block forever.
This patch extracts del_timer_sync() from the protection of spin_lock_bh(), which could let timer handler to obtain the needed lock. What`s more, we change spin_lock_bh() in rtw_scan_timeout_handler() to spin_lock_irq(). Otherwise, spin_lock_bh() will also cause deadlock() in timer handler.
--- drivers/staging/rtl8723bs/core/rtw_mlme.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/staging/rtl8723bs/core/rtw_mlme.c +4 -2
@@ -826,7 +826,9 @@ void rtw_surveydone_event_callback(strucRT_TRACE (_module_rtl871x_mlme_c_, _drv_info_, ("rtw_surveydone_event_callback: fw_state:%x\n\n" ,get_fwstate (pmlmepriv)));if (check_fwstate (pmlmepriv, _FW_UNDER_SURVEY)) { +spin_unlock_bh (&pmlmepriv->lock);del_timer_sync (&pmlmepriv->scan_to_timer); +spin_lock_bh (&pmlmepriv->lock);_clr_fwstate_ (pmlmepriv, _FW_UNDER_SURVEY); }else {
@@ -1753,11 +1755,11 @@ void rtw_scan_timeout_handler(struct timDBG_871X (FUNC_ADPT_FMT " fw_state =%x\n" ,FUNC_ADPT_ARG (adapter),get_fwstate (pmlmepriv)); -spin_lock_bh (&pmlmepriv->lock); +spin_lock_irq (&pmlmepriv->lock);_clr_fwstate_ (pmlmepriv, _FW_UNDER_SURVEY); -spin_unlock_bh (&pmlmepriv->lock); +spin_unlock_irq (&pmlmepriv->lock);rtw_indicate_scan_done (adapter, true); }
Greg Kroah-Hartman
maintainerPATCH 191/286 s390/dasd: fix double module refcount decrement
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miroslav Franc <[email protected]>
commit c3116e62ddeff79cae342147753ce596f01fcf06 upstream.
Once the discipline is associated with the device, deleting the device takes care of decrementing the module's refcount. Doing it manually on this error path causes refcount to artificially decrease on each error while it should just stay the same.
--- drivers/s390/block/dasd.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/s390/block/dasd.c +1 -4
@@ -3637,12 +3637,11 @@ int dasd_generic_set_online(struct ccw_ddasd_delete_device (device);return -EINVAL ; } + device->base_discipline = base_discipline;if (!try_module_get (discipline->owner)) { -module_put (base_discipline->owner);dasd_delete_device (device);return -EINVAL ; } - device->base_discipline = base_discipline; device->discipline = discipline;/* check_device will allocate block device if necessary */
@@ -3650,8 +3649,6 @@ int dasd_generic_set_online(struct ccw_dif (rc) {pr_warn ("%s Setting the DASD online with discipline %s failed with rc=%i\n" ,dev_name (&cdev->dev), discipline->name, rc); -module_put (discipline->owner); -module_put (base_discipline->owner);dasd_delete_device (device);return rc; }
Greg Kroah-Hartman
maintainerPATCH 192/286 pmdomain: ti: Add a null pointer check to the omap_prm_domain_init
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kunwu Chan <[email protected]>
commit 5d7f58ee08434a33340f75ac7ac5071eea9673b3 upstream.
devm_kasprintf() returns a pointer to dynamically allocated memory which can be NULL upon failure. Ensure the allocation was successful by checking the pointer validity.
--- drivers/soc/ti/omap_prm.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/soc/ti/omap_prm.c +2 -0
@@ -381,6 +381,8 @@ static int omap_prm_domain_init(struct d data = prm->data; name =devm_kasprintf (dev,GFP_KERNEL ,"prm_%s" , data->name); +if (!name) +return -ENOMEM ; prmd->dev = dev; prmd->prm = prm;
Greg Kroah-Hartman
maintainerPATCH 193/286 drivers: staging: rtl8723bs: Fix locking in rtw_scan_timeout_handler()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans de Goede <[email protected]>
commit 3f467036093fedd7e231924327455fc609b5ef02 upstream.
Commit cc7ad0d77b51 ("drivers: staging: rtl8723bs: Fix deadlock in rtw_surveydone_event_callback()") besides fixing the deadlock also modified rtw_scan_timeout_handler() to use spin_[un]lock_irq() instead of spin_[un]lock_bh().
Disabling the IRQs is not necessary since all code taking this lock runs from either user contexts or from softirqs
rtw_scan_timeout_handler() is the only function taking pmlmepriv->lock which uses spin_[un]lock_irq() for this. Switch back to spin_[un]lock_bh() to make it consistent with the rest of the code.
--- drivers/staging/rtl8723bs/core/rtw_mlme.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/rtl8723bs/core/rtw_mlme.c +2 -2
@@ -1755,11 +1755,11 @@ void rtw_scan_timeout_handler(struct timDBG_871X (FUNC_ADPT_FMT " fw_state =%x\n" ,FUNC_ADPT_ARG (adapter),get_fwstate (pmlmepriv)); -spin_lock_irq (&pmlmepriv->lock); +spin_lock_bh (&pmlmepriv->lock);_clr_fwstate_ (pmlmepriv, _FW_UNDER_SURVEY); -spin_unlock_irq (&pmlmepriv->lock); +spin_unlock_bh (&pmlmepriv->lock);rtw_indicate_scan_done (adapter, true); }
Greg Kroah-Hartman
maintainerPATCH 194/286 platform/x86: ISST: Correct command storage data length
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srinivas Pandruvada <[email protected]>
[ Upstream commit 9462e74c5c983cce34019bfb27f734552bebe59f ]
After resume/online turbo limit ratio (TRL) is restored partially if the admin explicitly changed TRL from user space.
A hash table is used to store SST mail box and MSR settings when modified to restore those settings after resume or online. This uses a struct isst_cmd field "data" to store these settings. This is a 64 bit field. But isst_store_new_cmd() is only assigning as u32. This results in truncation of 32 bits.
Change the argument to u64 from u32.
--- drivers/platform/x86/intel_speed_select_if/isst_if_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/x86/intel_speed_select_if/isst_if_common.c +1 -1
@@ -77,7 +77,7 @@ static DECLARE_HASHTABLE(isst_hash, 8);static DEFINE_MUTEX (isst_hash_lock);static int isst_store_new_cmd (int cmd,u32 cpu,int mbox_cmd_type,u32 param, -u32 data) +u64 data) {struct isst_cmd *sst_cmd;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 195/286 tracing: Allow synthetic events to pass around stacktraces
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steven Rostedt (Google) <[email protected]>
[ Upstream commit 00cf3d672a9dd409418647e9f98784c339c3ff63 ]
Allow a stacktrace from one event to be displayed by the end event of a synthetic event. This is very useful when looking for the longest latency of a sleep or something blocked on I/O.
# cd /sys/kernel/tracing/ # echo 's:block_lat pid_t pid; u64 delta; unsigned long[] stack;' > dynamic_events # echo 'hist:keys=next_pid:ts=common_timestamp.usecs,st=stacktrace if prev_state == 1||prev_state == 2' > events/sched/sched_switch/trigger # echo 'hist:keys=prev_pid:delta=common_timestamp.usecs-$ts,s=$st:onmax($delta).trace(block_lat,prev_pid,$delta,$s)' >> events/sched/sched_switch/trigger
The above creates a "block_lat" synthetic event that take the stacktrace of when a task schedules out in either the interruptible or uninterruptible states, and on a new per process max $delta (the time it was scheduled out), will print the process id and the stacktrace.
# echo 1 > events/synthetic/block_lat/enable
# cat trace
# TASK-PID CPU# ||||| TIMESTAMP FUNCTION
# | | | ||||| | |
kworker/u16:0-767 [006] d..4. 560.645045: block_lat: pid=767 delta=66 stack=STACK:
=> __schedule
=> schedule
=> pipe_read
=> vfs_read
=> ksys_read
=> do_syscall_64
=> 0x966000aa<idle>-0 [003] d..4. 561.132117: block_lat: pid=0 delta=413787 stack=STACK:
=> __schedule
=> schedule
=> schedule_hrtimeout_range_clock
=> do_sys_poll
=> __x64_sys_poll
=> do_syscall_64
=> 0x966000aa
<...>-153 [006] d..4. 562.068407: block_lat: pid=153 delta=54 stack=STACK:
=> __schedule
=> schedule
=> io_schedule
=> rq_qos_wait
=> wbt_wait
=> __rq_qos_throttle
=> blk_mq_submit_bio
=> submit_bio_noacct_nocheck
=> ext4_bio_write_page
=> mpage_submit_page
=> mpage_process_page_bufs
=> mpage_prepare_extent_to_map
=> ext4_do_writepages
=> ext4_writepages
=> do_writepages
=> __writeback_single_inode
Stable-dep-of: 4d38328eb442 ("tracing: Fix synth event printk format for str fields")
--- kernel/trace/trace.h | 4 ++ kernel/trace/trace_events_hist.c | 7 ++- kernel/trace/trace_events_synth.c | 80 ++++++++++++++++++++++++++++++- kernel/trace/trace_synth.h | 1 + 4 files changed, 87 insertions(+), 5 deletions(-)
kernel/trace/trace.h +4 -0
@@ -109,6 +109,10 @@ enum trace_type {unlikely (__ret_warn_once); \ }) +#define HIST_STACKTRACE_DEPTH 16 +#define HIST_STACKTRACE_SIZE (HIST_STACKTRACE_DEPTH * sizeof(unsigned long)) +#define HIST_STACKTRACE_SKIP 5 +/* * syscalls are special, and need special handling, this is why * they are not included in trace_entries.h
kernel/trace/trace_events_hist.c +3 -4
@@ -282,10 +282,6 @@ DEFINE_HIST_FIELD_FN(u8);#define for_each_hist_key_field (i, hist_data) \ for ((i) = (hist_data)->n_vals; (i) < (hist_data)->n_fields; (i)++) -#define HIST_STACKTRACE_DEPTH 16 -#define HIST_STACKTRACE_SIZE (HIST_STACKTRACE_DEPTH * sizeof(unsigned long)) -#define HIST_STACKTRACE_SKIP 5 -#define HITCOUNT_IDX 0#define HIST_KEY_SIZE_MAX (MAX_FILTER_STR_VAL + HIST_STACKTRACE_SIZE)
@@ -3356,6 +3352,9 @@ static int check_synth_field(struct synth_event *event, && field->is_dynamic)return 0 ; +if (strstr (hist_field->type,"long[" ) && field->is_stack) +return 0 ; +if (strcmp (field->type, hist_field->type) !=0 ) {if (field->size != hist_field->size || (!field->is_string && field->is_signed != hist_field->is_signed))
kernel/trace/trace_events_synth.c +79 -1
134 lines not on this page · raw message
kernel/trace/trace_synth.h +1 -0
@@ -18,6 +18,7 @@ struct synth_field {bool is_signed;bool is_string;bool is_dynamic; +bool is_stack; };struct synth_event {
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 196/286 tracing: Fix synth event printk format for str fields
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Douglas Raillard <[email protected]>
[ Upstream commit 4d38328eb442dc06aec4350fd9594ffa6488af02 ]
The printk format for synth event uses "%.*s" to print string fields, but then only passes the pointer part as var arg.
Replace %.*s with %s as the C string is guaranteed to be null-terminated.
The output in print fmt should never have been updated as __get_str() handles the string limit because it can access the length of the string in the string meta data that is saved in the ring buffer.
--- kernel/trace/trace_events_synth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace_events_synth.c +1 -1
@@ -290,7 +290,7 @@ static const char *synth_field_fmt(char *type)else if (strcmp (type,"gfp_t" ) ==0 ) fmt ="%x" ;else if (synth_field_is_string (type)) - fmt ="%.*s" ; + fmt ="%s" ;else if (synth_field_is_stack (type)) fmt ="%s" ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 197/286 media: streamzap: remove unnecessary ir_raw_event_reset and handle
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Young <[email protected]>
[ Upstream commit 4bed9306050497f49cbe77b842f0d812f4f27593 ]
There is no reason to have a reset after an IR timeout. Calling ir_raw_event_handle() twice for the same interrupt has no affect.
Stable-dep-of: f656cfbc7a29 ("media: streamzap: fix race between device disconnection and urb callback")
--- drivers/media/rc/streamzap.c | 2 -- 1 file changed, 2 deletions(-)
drivers/media/rc/streamzap.c +0 -2
@@ -215,8 +215,6 @@ static void sz_process_ir_data(struct streamzap_ir *sz, int len) sz->idle = true;if (sz->timeout_enabled)sz_push (sz, rawir); -ir_raw_event_handle (sz->rdev); -ir_raw_event_reset (sz->rdev); }else {sz_push_full_space (sz, sz->buf_in[i]); }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 198/286 media: streamzap: no need for usb pid/vid in device name
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Young <[email protected]>
[ Upstream commit 7a25e6849ad73de5aa01d62da43071bc02b8530c ]
The usb pid/vid can be found elsewhere, the idVendor/idProduct usb sysfs files for example.
Stable-dep-of: f656cfbc7a29 ("media: streamzap: fix race between device disconnection and urb callback")
--- drivers/media/rc/streamzap.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/media/rc/streamzap.c +1 -5
@@ -88,7 +88,6 @@ struct streamzap_ir {ktime_t signal_start;bool timeout_enabled; -char name[128 ];char phys[64 ]; };
@@ -287,13 +286,10 @@ static struct rc_dev *streamzap_init_rc_dev(struct streamzap_ir *sz) goto out; } -snprintf (sz->name,sizeof (sz->name),"Streamzap PC Remote Infrared Receiver (%04x:%04x)" , -le16_to_cpu (sz->usbdev->descriptor.idVendor), -le16_to_cpu (sz->usbdev->descriptor.idProduct));usb_make_path (sz->usbdev, sz->phys,sizeof (sz->phys));strlcat (sz->phys,"/input0" ,sizeof (sz->phys)); - rdev->device_name = sz->name; + rdev->device_name ="Streamzap PC Remote Infrared Receiver" ; rdev->input_phys = sz->phys;usb_to_input_id (sz->usbdev, &rdev->input_id); rdev->dev.parent = dev;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 199/286 media: streamzap: less chatter
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Young <[email protected]>
[ Upstream commit 35088717ad24140b6ab0ec00ef357709be607526 ]
Remove superfluous messages which add no information.
Stable-dep-of: f656cfbc7a29 ("media: streamzap: fix race between device disconnection and urb callback")
--- drivers/media/rc/streamzap.c | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-)
drivers/media/rc/streamzap.c +1 -19
@@ -26,7 +26,6 @@#include <linux/usb/input.h> #include <media/rc-core.h> -#define DRIVER_VERSION "1.61"#define DRIVER_NAME "streamzap"#define DRIVER_DESC "Streamzap Remote Control driver"
@@ -281,10 +280,8 @@ static struct rc_dev *streamzap_init_rc_dev(struct streamzap_ir *sz)int ret; rdev =rc_allocate_device (RC_DRIVER_IR_RAW ); -if (!rdev) { -dev_err (dev,"remote dev allocation failed\n" ); +if (!rdev) goto out; - }usb_make_path (sz->usbdev, sz->phys,sizeof (sz->phys));strlcat (sz->phys,"/input0" ,sizeof (sz->phys));
@@ -324,7 +321,6 @@ static int streamzap_probe(struct usb_interface *intf,struct usb_device *usbdev =interface_to_usbdev (intf);struct usb_host_interface *iface_host;struct streamzap_ir *sz =NULL ; -char buf[63 ], name[128 ] ="" ;int retval = -ENOMEM ;int pipe, maxp;
@@ -383,17 +379,6 @@ static int streamzap_probe(struct usb_interface *intf, sz->dev = &intf->dev; sz->buf_in_len = maxp; -if (usbdev->descriptor.iManufacturer - &&usb_string (usbdev, usbdev->descriptor.iManufacturer, - buf,sizeof (buf)) >0 ) -strscpy (name, buf,sizeof (name)); - -if (usbdev->descriptor.iProduct - &&usb_string (usbdev, usbdev->descriptor.iProduct, - buf,sizeof (buf)) >0 ) -snprintf (name +strlen (name),sizeof (name) -strlen (name), -" %s" , buf); - sz->rdev =streamzap_init_rc_dev (sz);if (!sz->rdev) goto rc_dev_fail;
@@ -424,9 +409,6 @@ static int streamzap_probe(struct usb_interface *intf,if (usb_submit_urb (sz->urb_in,GFP_ATOMIC ))dev_err (sz->dev,"urb submit failed\n" ); -dev_info (sz->dev,"Registered %s on usb%d:%d\n" , name, - usbdev->bus->busnum, usbdev->devnum); -return 0 ; rc_dev_fail:
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 200/286 media: streamzap: remove unused struct members
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Young <[email protected]>
[ Upstream commit 4df69e46c352df9bdbe859824da33428a3ce8a1d ]
These struct members do not serve any purpose.
Stable-dep-of: f656cfbc7a29 ("media: streamzap: fix race between device disconnection and urb callback")
--- drivers/media/rc/streamzap.c | 37 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 23 deletions(-)
drivers/media/rc/streamzap.c +14 -23
@@ -66,9 +66,6 @@ struct streamzap_ir {struct device *dev;/* usb */ -struct usb_device *usbdev; -struct usb_interface *interface; -struct usb_endpoint_descriptor *endpoint;struct urb *urb_in;/* buffer & dma */
@@ -85,7 +82,6 @@ struct streamzap_ir {/* start time of signal; necessary for gap tracking */ ktime_t signal_last;ktime_t signal_start; -bool timeout_enabled;char phys[64 ]; };
@@ -211,8 +207,7 @@ static void sz_process_ir_data(struct streamzap_ir *sz, int len) .duration = sz->rdev->timeout }; sz->idle = true; -if (sz->timeout_enabled) -sz_push (sz, rawir); +sz_push (sz, rawir); }else {sz_push_full_space (sz, sz->buf_in[i]); }
@@ -273,7 +268,8 @@ static void streamzap_callback(struct urb *urb)return ; } -static struct rc_dev *streamzap_init_rc_dev (struct streamzap_ir *sz) +static struct rc_dev *streamzap_init_rc_dev (struct streamzap_ir *sz, +struct usb_device *usbdev) {struct rc_dev *rdev;struct device *dev = sz->dev;
@@ -283,12 +279,12 @@ static struct rc_dev *streamzap_init_rc_dev(struct streamzap_ir *sz)if (!rdev) goto out; -usb_make_path (sz->usbdev, sz->phys,sizeof (sz->phys)); +usb_make_path (usbdev, sz->phys,sizeof (sz->phys));strlcat (sz->phys,"/input0" ,sizeof (sz->phys)); rdev->device_name ="Streamzap PC Remote Infrared Receiver" ; rdev->input_phys = sz->phys; -usb_to_input_id (sz->usbdev, &rdev->input_id); +usb_to_input_id (usbdev, &rdev->input_id); rdev->dev.parent = dev; rdev->priv = sz; rdev->allowed_protocols =RC_PROTO_BIT_ALL_IR_DECODER ;
@@ -319,6 +315,7 @@ static int streamzap_probe(struct usb_interface *intf, const struct usb_device_id *id) {struct usb_device *usbdev =interface_to_usbdev (intf); +struct usb_endpoint_descriptor *endpoint;struct usb_host_interface *iface_host;struct streamzap_ir *sz =NULL ;int retval = -ENOMEM ;
@@ -329,9 +326,6 @@ static int streamzap_probe(struct usb_interface *intf,if (!sz)return -ENOMEM ; - sz->usbdev = usbdev; - sz->interface = intf; -/* Check to ensure endpoint information matches requirements */ iface_host = intf->cur_altsetting;
@@ -342,22 +336,22 @@ static int streamzap_probe(struct usb_interface *intf, goto free_sz; } - sz->endpoint = &(iface_host->endpoint[0 ].desc); -if (!usb_endpoint_dir_in (sz->endpoint)) { + endpoint = &iface_host->endpoint[0 ].desc; +if (!usb_endpoint_dir_in (endpoint)) {dev_err (&intf->dev,"%s: endpoint doesn't match input device 02%02x\n" , - __func__, sz->endpoint->bEndpointAddress); + __func__, endpoint->bEndpointAddress); retval = -ENODEV ; goto free_sz; } -if (!usb_endpoint_xfer_int (sz->endpoint)) { +if (!usb_endpoint_xfer_int (endpoint)) {dev_err (&intf->dev,"%s: endpoint attributes don't match xfer 02%02x\n" , - __func__, sz->endpoint->bmAttributes); + __func__, endpoint->bmAttributes); retval = -ENODEV ; goto free_sz; } - pipe =usb_rcvintpipe (usbdev, sz->endpoint->bEndpointAddress); + pipe =usb_rcvintpipe (usbdev, endpoint->bEndpointAddress); maxp =usb_maxpacket (usbdev, pipe,usb_pipeout (pipe));if (maxp ==0 ) {
@@ -379,14 +373,13 @@ static int streamzap_probe(struct usb_interface *intf, sz->dev = &intf->dev; sz->buf_in_len = maxp; - sz->rdev =streamzap_init_rc_dev (sz); + sz->rdev =streamzap_init_rc_dev (sz, usbdev);if (!sz->rdev) goto rc_dev_fail; sz->idle = true; sz->decoder_state = PulseSpace;/* FIXME: don't yet have a way to set this */ - sz->timeout_enabled = true; sz->rdev->timeout =SZ_TIMEOUT *SZ_RESOLUTION ;#if 0 /* not yet supported, depends on patches from maxim */
@@ -399,8 +392,7 @@ static int streamzap_probe(struct usb_interface *intf,/* Complete final initialisations */ usb_fill_int_urb (sz->urb_in, usbdev, pipe, sz->buf_in, - maxp, (usb_complete_t )streamzap_callback, - sz, sz->endpoint->bInterval); + maxp, streamzap_callback, sz, endpoint->bInterval); sz->urb_in->transfer_dma = sz->dma_in; sz->urb_in->transfer_flags |=URB_NO_TRANSFER_DMA_MAP ;
@@ -441,7 +433,6 @@ static void streamzap_disconnect(struct usb_interface *interface)if (!sz)return ; - sz->usbdev =NULL ;rc_unregister_device (sz->rdev);usb_kill_urb (sz->urb_in);usb_free_urb (sz->urb_in);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 201/286 media: streamzap: fix race between device disconnection and urb callback
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Murad Masimov <[email protected]>
[ Upstream commit f656cfbc7a293a039d6a0c7100e1c846845148c1 ]
Syzkaller has reported a general protection fault at function ir_raw_event_store_with_filter(). This crash is caused by a NULL pointer dereference of dev->raw pointer, even though it is checked for NULL in the same function, which means there is a race condition. It occurs due to the incorrect order of actions in the streamzap_disconnect() function:rc_unregister_device() is called before usb_kill_urb(). The dev->raw pointer is freed and set to NULL in rc_unregister_device(), and only after that usb_kill_urb() waits for in-progress requests to finish.
If rc_unregister_device() is called while streamzap_callback() handler is not finished, this can lead to accessing freed resources. Thus rc_unregister_device() should be called after usb_kill_urb().
Found by Linux Verification Center (linuxtesting.org) with Syzkaller.
--- drivers/media/rc/streamzap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/rc/streamzap.c +1 -1
@@ -433,8 +433,8 @@ static void streamzap_disconnect(struct usb_interface *interface)if (!sz)return ; -rc_unregister_device (sz->rdev);usb_kill_urb (sz->urb_in); +rc_unregister_device (sz->rdev);usb_free_urb (sz->urb_in);usb_free_coherent (usbdev, sz->buf_in_len, sz->buf_in, sz->dma_in);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 202/286 media: venus: venc: Init the session only once in queue_setup
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stanimir Varbanov <[email protected]>
[ Upstream commit 5f2ca73dcca96c3de96a0e4d9ea24ebb46c55d2e ]
Init the hfi session only once in queue_setup and also cover that with inst->lock.
Stable-dep-of: 9edaaa8e3e15 ("media: venus: hfi_parser: refactor hfi packet parsing logic")
--- drivers/media/platform/qcom/venus/venc.c | 85 ++++++++++++++++++------ 1 file changed, 64 insertions(+), 21 deletions(-)
drivers/media/platform/qcom/venus/venc.c +64 -21
@@ -727,7 +727,9 @@ static int venc_init_session(struct venus_inst *inst)int ret; ret =hfi_session_init (inst, inst->fmt_cap->pixfmt); -if (ret) +if (ret == -EINVAL ) +return 0 ; +else if (ret)return ret; ret = venus_helper_set_input_resolution(inst, inst->width,
@@ -764,17 +766,13 @@ static int venc_out_num_buffers(struct venus_inst *inst, unsigned int *num)struct hfi_buffer_requirements bufreq;int ret; - ret =venc_init_session (inst); + ret =venus_helper_get_bufreq (inst,HFI_BUFFER_INPUT , &bufreq);if (ret)return ret; - ret =venus_helper_get_bufreq (inst,HFI_BUFFER_INPUT , &bufreq); - *num = bufreq.count_actual; -hfi_session_deinit (inst); - -return ret; +return 0 ; } static int venc_queue_setup(struct vb2_queue *q,
@@ -783,7 +781,7 @@ static int venc_queue_setup(struct vb2_queue *q, {struct venus_inst *inst =vb2_get_drv_priv (q);unsigned int num, min =4 ; -int ret =0 ; +int ret;if (*num_planes) { if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE &&
@@ -805,6 +803,13 @@ static int venc_queue_setup(struct vb2_queue *q,return 0 ; } +mutex_lock (&inst->lock); + ret =venc_init_session (inst); +mutex_unlock (&inst->lock); + +if (ret) +return ret; +switch (q->type) {case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE : *num_planes = inst->fmt_out->num_planes;
@@ -840,6 +845,49 @@ static int venc_queue_setup(struct vb2_queue *q,return ret; } +static int venc_buf_init (struct vb2_buffer *vb) +{ +struct venus_inst *inst =vb2_get_drv_priv (vb->vb2_queue); + + inst->buf_count++; + +return venus_helper_vb2_buf_init (vb); +} + +static void venc_release_session (struct venus_inst *inst) +{ +int ret; + +mutex_lock (&inst->lock); + + ret =hfi_session_deinit (inst); +if (ret || inst->session_error) +hfi_session_abort (inst); + +mutex_unlock (&inst->lock); + +venus_pm_load_scale (inst); +INIT_LIST_HEAD (&inst->registeredbufs); +venus_pm_release_core (inst); +} + +static void venc_buf_cleanup (struct vb2_buffer *vb) +{ +struct venus_inst *inst =vb2_get_drv_priv (vb->vb2_queue); +struct vb2_v4l2_buffer *vbuf =to_vb2_v4l2_buffer (vb); +struct venus_buffer *buf =to_venus_buffer (vbuf); + +mutex_lock (&inst->lock); +if (vb->type ==V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE ) +if (!list_empty (&inst->registeredbufs)) +list_del_init (&buf->reg_list); +mutex_unlock (&inst->lock); + + inst->buf_count--; +if (!inst->buf_count) +venc_release_session (inst); +} +static int venc_verify_conf (struct venus_inst *inst) {enum hfi_version ver = inst->core->res->hfi_version;
@@ -890,38 +938,32 @@ static int venc_start_streaming(struct vb2_queue *q, unsigned int count) inst->sequence_cap =0 ; inst->sequence_out =0 ; - ret =venc_init_session (inst); -if (ret) - goto bufs_done; - ret =venus_pm_acquire_core (inst);if (ret) - goto deinit_sess; + goto error; ret =venc_set_properties (inst);if (ret) - goto deinit_sess; + goto error; ret =venc_verify_conf (inst);if (ret) - goto deinit_sess; + goto error; ret =venus_helper_set_num_bufs (inst, inst->num_input_bufs, inst->num_output_bufs,0 );if (ret) - goto deinit_sess; + goto error; ret =venus_helper_vb2_start_streaming (inst);if (ret) - goto deinit_sess; + goto error;mutex_unlock (&inst->lock);return 0 ; -deinit_sess: -hfi_session_deinit (inst); -bufs_done: +error:venus_helper_buffers_done (inst, q->type,VB2_BUF_STATE_QUEUED );if (q->type ==V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE ) inst->streamon_out =0 ;
@@ -933,7 +975,8 @@ static int venc_start_streaming(struct vb2_queue *q, unsigned int count)static const struct vb2_ops venc_vb2_ops = { .queue_setup = venc_queue_setup, - .buf_init = venus_helper_vb2_buf_init, + .buf_init = venc_buf_init, + .buf_cleanup = venc_buf_cleanup, .buf_prepare = venus_helper_vb2_buf_prepare, .start_streaming = venc_start_streaming, .stop_streaming = venus_helper_vb2_stop_streaming,
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 203/286 media: venus: Limit HFI sessions to the maximum supported
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stanimir Varbanov <[email protected]>
[ Upstream commit 20891170f339a8754312a877f3d17f0e5dadd599 ]
Currently we rely on firmware to return error when we reach the maximum supported number of sessions. But this errors are happened at reqbuf time which is a bit later. The more reasonable way looks like is to return the error on driver open.
To achieve that modify hfi_session_create to return error when we reach maximum count of sessions and thus refuse open.
Stable-dep-of: 9edaaa8e3e15 ("media: venus: hfi_parser: refactor hfi packet parsing logic")
--- drivers/media/platform/qcom/venus/core.h | 1 + drivers/media/platform/qcom/venus/hfi.c | 16 +++++++++++++--- drivers/media/platform/qcom/venus/hfi_parser.c | 3 +++ 3 files changed, 17 insertions(+), 3 deletions(-)
drivers/media/platform/qcom/venus/core.h +1 -0
@@ -96,6 +96,7 @@ struct venus_format {#define MAX_CAP_ENTRIES 32#define MAX_ALLOC_MODE_ENTRIES 16#define MAX_CODEC_NUM 32 +#define MAX_SESSIONS 16struct raw_formats {u32 buftype;
drivers/media/platform/qcom/venus/hfi.c +13 -3
@@ -178,6 +178,8 @@ static int wait_session_msg(struct venus_inst *inst)int hfi_session_create (struct venus_inst *inst,const struct hfi_inst_ops *ops) {struct venus_core *core = inst->core; +bool max; +int ret;if (!ops)return -EINVAL ;
@@ -187,11 +189,19 @@ int hfi_session_create(struct venus_inst *inst, const struct hfi_inst_ops *ops) inst->ops = ops;mutex_lock (&core->lock); -list_add_tail (&inst->list, &core->instances); -atomic_inc (&core->insts_count); + + max =atomic_add_unless (&core->insts_count,1 , + core->max_sessions_supported); +if (!max) { + ret = -EAGAIN ; + }else { +list_add_tail (&inst->list, &core->instances); + ret =0 ; + } +mutex_unlock (&core->lock); -return 0 ; +return ret; }EXPORT_SYMBOL_GPL (hfi_session_create);
drivers/media/platform/qcom/venus/hfi_parser.c +3 -0
@@ -295,6 +295,9 @@ u32 hfi_parser(struct venus_core *core, struct venus_inst *inst, void *buf, words_count--; } +if (!core->max_sessions_supported) + core->max_sessions_supported =MAX_SESSIONS ; +parser_fini (inst, codecs, domain);return HFI_ERR_NONE ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 204/286 media: venus: hfi: Correct session init return error
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stanimir Varbanov <[email protected]>
[ Upstream commit e922a33e0228fa314ffc4f70b3b9ffbc4aad1bbe ]
The hfi_session_init can be called many times and it returns EINVAL when the session was already initialized. This error code (EINVAL) is confusing for the callers. Change hfi_session_init to return EALREADY error code when the session has been already initialized.
Stable-dep-of: 9edaaa8e3e15 ("media: venus: hfi_parser: refactor hfi packet parsing logic")
--- drivers/media/platform/qcom/venus/hfi.c | 2 +- drivers/media/platform/qcom/venus/vdec.c | 2 +- drivers/media/platform/qcom/venus/venc.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
drivers/media/platform/qcom/venus/hfi.c +1 -1
@@ -212,7 +212,7 @@ int hfi_session_init(struct venus_inst *inst, u32 pixfmt)int ret;if (inst->state !=INST_UNINIT ) -return -EINVAL ; +return -EALREADY ; inst->hfi_codec =to_codec_type (pixfmt);reinit_completion (&inst->done);
drivers/media/platform/qcom/venus/vdec.c +1 -1
@@ -768,7 +768,7 @@ static int vdec_session_init(struct venus_inst *inst)int ret; ret =hfi_session_init (inst, inst->fmt_out->pixfmt); -if (ret == -EINVAL ) +if (ret == -EALREADY )return 0 ;else if (ret)return ret;
drivers/media/platform/qcom/venus/venc.c +1 -1
@@ -727,7 +727,7 @@ static int venc_init_session(struct venus_inst *inst)int ret; ret =hfi_session_init (inst, inst->fmt_cap->pixfmt); -if (ret == -EINVAL ) +if (ret == -EALREADY )return 0 ;else if (ret)return ret;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 205/286 media: venus: pm_helpers: Check instance state when calculate instance frequency
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stanimir Varbanov <[email protected]>
[ Upstream commit d33a94412ed1081f30d904cab54faea7c7b839fc ]
Skip calculating instance frequency if it is not in running state.
Stable-dep-of: 9edaaa8e3e15 ("media: venus: hfi_parser: refactor hfi packet parsing logic")
--- drivers/media/platform/qcom/venus/pm_helpers.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/media/platform/qcom/venus/pm_helpers.c +3 -0
@@ -937,6 +937,9 @@ static unsigned long calculate_inst_freq(struct venus_inst *inst, mbs_per_sec =load_per_instance (inst) / fps; +if (inst->state !=INST_START ) +return 0 ; + vpp_freq = mbs_per_sec * inst->clk_data.codec_freq_data->vpp_freq;/* 21 / 20 is overhead factor */ vpp_freq += vpp_freq /20 ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 206/286 media: venus: Create hfi platform and move vpp/vsp there
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stanimir Varbanov <[email protected]>
[ Upstream commit aa6033892b1d8ea956ce0358867806e171a620d1 ]
Introduce a new hfi platform to cover differences between hfi versions. As a start move vpp/vsp freq data in that hfi platform, more platform data will come later.
Stable-dep-of: 9edaaa8e3e15 ("media: venus: hfi_parser: refactor hfi packet parsing logic")
--- drivers/media/platform/qcom/venus/Makefile | 3 +- drivers/media/platform/qcom/venus/core.c | 17 ------ drivers/media/platform/qcom/venus/core.h | 12 +--- drivers/media/platform/qcom/venus/helpers.c | 54 ++++++++--------- drivers/media/platform/qcom/venus/helpers.h | 2 +- .../media/platform/qcom/venus/hfi_platform.c | 49 +++++++++++++++ .../media/platform/qcom/venus/hfi_platform.h | 34 +++++++++++ .../platform/qcom/venus/hfi_platform_v4.c | 60 +++++++++++++++++++ .../media/platform/qcom/venus/pm_helpers.c | 9 +-- drivers/media/platform/qcom/venus/vdec.c | 6 +- drivers/media/platform/qcom/venus/venc.c | 6 +- 11 files changed, 179 insertions(+), 73 deletions(-) create mode 100644 drivers/media/platform/qcom/venus/hfi_platform.c create mode 100644 drivers/media/platform/qcom/venus/hfi_platform.h create mode 100644 drivers/media/platform/qcom/venus/hfi_platform_v4.c
drivers/media/platform/qcom/venus/Makefile +2 -1
@@ -3,7 +3,8 @@ venus-core-objs += core.o helpers.o firmware.o \ hfi_venus.o hfi_msgs.o hfi_cmds.o hfi.o \ - hfi_parser.o pm_helpers.o dbgfs.o + hfi_parser.o pm_helpers.o dbgfs.o \ + hfi_platform.o hfi_platform_v4.o \ venus-dec-objs += vdec.o vdec_ctrls.o venus-enc-objs += venc.o venc_ctrls.o
drivers/media/platform/qcom/venus/core.c +0 -17
@@ -529,17 +529,6 @@ static const struct freq_tbl sdm845_freq_table[] = { { 244800, 100000000 }, /* 1920x1080@30 */ }; -static const struct codec_freq_data sdm845_codec_freq_data[] = { - {V4L2_PIX_FMT_H264 ,VIDC_SESSION_TYPE_ENC ,675 ,10 }, - {V4L2_PIX_FMT_HEVC ,VIDC_SESSION_TYPE_ENC ,675 ,10 }, - {V4L2_PIX_FMT_VP8 ,VIDC_SESSION_TYPE_ENC ,675 ,10 }, - {V4L2_PIX_FMT_MPEG2 ,VIDC_SESSION_TYPE_DEC ,200 ,10 }, - {V4L2_PIX_FMT_H264 ,VIDC_SESSION_TYPE_DEC ,200 ,10 }, - {V4L2_PIX_FMT_HEVC ,VIDC_SESSION_TYPE_DEC ,200 ,10 }, - {V4L2_PIX_FMT_VP8 ,VIDC_SESSION_TYPE_DEC ,200 ,10 }, - {V4L2_PIX_FMT_VP9 ,VIDC_SESSION_TYPE_DEC ,200 ,10 }, -}; -static const struct bw_tbl sdm845_bw_table_enc[] = { {1944000 ,1612000 ,0 ,2416000 ,0 },/* 3840x2160@60 */ { 972000, 951000, 0, 1434000, 0 }, /* 3840x2160@30 */
@@ -561,8 +550,6 @@ static const struct venus_resources sdm845_res = { .bw_tbl_enc_size = ARRAY_SIZE(sdm845_bw_table_enc), .bw_tbl_dec = sdm845_bw_table_dec, .bw_tbl_dec_size = ARRAY_SIZE(sdm845_bw_table_dec), - .codec_freq_data = sdm845_codec_freq_data, - .codec_freq_data_size = ARRAY_SIZE(sdm845_codec_freq_data), .clks = {"core", "iface", "bus" }, .clks_num = 3, .vcodec0_clks = { "core", "bus" },
@@ -584,8 +571,6 @@ static const struct venus_resources sdm845_res_v2 = { .bw_tbl_enc_size = ARRAY_SIZE(sdm845_bw_table_enc), .bw_tbl_dec = sdm845_bw_table_dec, .bw_tbl_dec_size = ARRAY_SIZE(sdm845_bw_table_dec), - .codec_freq_data = sdm845_codec_freq_data, - .codec_freq_data_size = ARRAY_SIZE(sdm845_codec_freq_data), .clks = {"core", "iface", "bus" }, .clks_num = 3, .vcodec0_clks = { "vcodec0_core", "vcodec0_bus" },
@@ -635,8 +620,6 @@ static const struct venus_resources sc7180_res = { .bw_tbl_enc_size = ARRAY_SIZE(sc7180_bw_table_enc), .bw_tbl_dec = sc7180_bw_table_dec, .bw_tbl_dec_size = ARRAY_SIZE(sc7180_bw_table_dec), - .codec_freq_data = sdm845_codec_freq_data, - .codec_freq_data_size = ARRAY_SIZE(sdm845_codec_freq_data), .clks = {"core", "iface", "bus" }, .clks_num = 3, .vcodec0_clks = { "vcodec0_core", "vcodec0_bus" },
drivers/media/platform/qcom/venus/core.h +2 -10
@@ -36,13 +36,6 @@ struct reg_val {u32 value; }; -struct codec_freq_data { -u32 pixfmt; -u32 session_type; -unsigned long vpp_freq; -unsigned long vsp_freq; -}; -struct bw_tbl {u32 mbs_per_sec;u32 avg;
@@ -61,8 +54,6 @@ struct venus_resources {unsigned int bw_tbl_dec_size;const struct reg_val *reg_tbl;unsigned int reg_tbl_size; -const struct codec_freq_data *codec_freq_data; -unsigned int codec_freq_data_size;const char *const clks[VIDC_CLKS_NUM_MAX ];unsigned int clks_num;const char *const vcodec0_clks[VIDC_VCODEC_CLKS_NUM_MAX ];
@@ -280,7 +271,8 @@ struct venus_buffer {struct clock_data {u32 core_id;unsigned long freq; -const struct codec_freq_data *codec_freq_data; +unsigned long vpp_freq; +unsigned long vsp_freq; };#define to_venus_buffer (ptr) container_of(ptr, struct venus_buffer, vb)
drivers/media/platform/qcom/venus/helpers.c +24 -30
72 lines not on this page · raw message
drivers/media/platform/qcom/venus/helpers.h +1 -1
@@ -33,7 +33,6 @@ int venus_helper_set_output_resolution(struct venus_inst *inst, unsigned int width, unsigned int height, u32 buftype);int venus_helper_set_work_mode (struct venus_inst *inst,u32 mode); -int venus_helper_init_codec_freq_data (struct venus_inst *inst);int venus_helper_set_num_bufs (struct venus_inst *inst,unsigned int input_bufs,unsigned int output_bufs,unsigned int output2_bufs);
@@ -48,6 +47,7 @@ unsigned int venus_helper_get_opb_size(struct venus_inst *inst);void venus_helper_acquire_buf_ref (struct vb2_v4l2_buffer *vbuf);void venus_helper_release_buf_ref (struct venus_inst *inst,unsigned int idx);void venus_helper_init_instance (struct venus_inst *inst); +int venus_helper_session_init (struct venus_inst *inst);int venus_helper_get_out_fmts (struct venus_inst *inst,u32 fmt,u32 *out_fmt,u32 *out2_fmt,bool ubwc);int venus_helper_alloc_dpb_bufs (struct venus_inst *inst);
drivers/media/platform/qcom/venus/hfi_platform.c new file +49 -0
49 lines not on this page · raw message
drivers/media/platform/qcom/venus/hfi_platform.h new file +34 -0
@@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Copyright (c) 2020, The Linux Foundation. All rights reserved. +*/ + +#ifndef __HFI_PLATFORM_H__ +#define __HFI_PLATFORM_H__ + +#include <linux/types.h> +#include <linux/videodev2.h> + +#include "hfi.h" +#include "hfi_helper.h" + +struct hfi_platform_codec_freq_data { +u32 pixfmt; +u32 session_type; +unsigned long vpp_freq; +unsigned long vsp_freq; +}; + +struct hfi_platform { +unsigned long (*codec_vpp_freq)(u32 session_type,u32 codec); +unsigned long (*codec_vsp_freq)(u32 session_type,u32 codec); +}; + +extern const struct hfi_platform hfi_plat_v4; + +const struct hfi_platform *hfi_platform_get (enum hfi_version version); +unsigned long hfi_platform_get_codec_vpp_freq (enum hfi_version version,u32 codec, +u32 session_type); +unsigned long hfi_platform_get_codec_vsp_freq (enum hfi_version version,u32 codec, +u32 session_type); +#endif
drivers/media/platform/qcom/venus/hfi_platform_v4.c new file +60 -0
60 lines not on this page · raw message
drivers/media/platform/qcom/venus/pm_helpers.c +5 -4
@@ -18,6 +18,7 @@#include "hfi_parser.h" #include "hfi_venus_io.h" #include "pm_helpers.h" +#include "hfi_platform.h" static bool legacy_binding;
@@ -506,7 +507,7 @@ min_loaded_core(struct venus_inst *inst, u32 *min_coreid, u32 *min_load)if (inst_pos->state !=INST_START )continue ; - vpp_freq = inst_pos->clk_data.codec_freq_data->vpp_freq; + vpp_freq = inst_pos->clk_data.vpp_freq; coreid = inst_pos->clk_data.core_id; mbs_per_sec =load_per_instance (inst_pos);
@@ -555,7 +556,7 @@ static int decide_core(struct venus_inst *inst)return 0 ; inst_load =load_per_instance (inst); - inst_load *= inst->clk_data.codec_freq_data->vpp_freq; + inst_load *= inst->clk_data.vpp_freq; max_freq = core->res->freq_tbl[0 ].freq;min_loaded_core (inst, &min_coreid, &min_load);
@@ -940,10 +941,10 @@ static unsigned long calculate_inst_freq(struct venus_inst *inst,if (inst->state !=INST_START )return 0 ; - vpp_freq = mbs_per_sec * inst->clk_data.codec_freq_data->vpp_freq; + vpp_freq = mbs_per_sec * inst->clk_data.vpp_freq;/* 21 / 20 is overhead factor */ vpp_freq += vpp_freq /20 ; - vsp_freq = mbs_per_sec * inst->clk_data.codec_freq_data->vsp_freq; + vsp_freq = mbs_per_sec * inst->clk_data.vsp_freq;/* 10 / 7 is overhead factor */ if (inst->session_type ==VIDC_SESSION_TYPE_ENC )
drivers/media/platform/qcom/venus/vdec.c +1 -5
@@ -767,7 +767,7 @@ static int vdec_session_init(struct venus_inst *inst) {int ret; - ret =hfi_session_init (inst, inst->fmt_out->pixfmt); + ret =venus_helper_session_init (inst);if (ret == -EALREADY )return 0 ;else if (ret)
@@ -778,10 +778,6 @@ static int vdec_session_init(struct venus_inst *inst)if (ret) goto deinit; - ret =venus_helper_init_codec_freq_data (inst); -if (ret) - goto deinit; -return 0 ; deinit:hfi_session_deinit (inst);
drivers/media/platform/qcom/venus/venc.c +1 -5
@@ -726,7 +726,7 @@ static int venc_init_session(struct venus_inst *inst) {int ret; - ret =hfi_session_init (inst, inst->fmt_cap->pixfmt); + ret =venus_helper_session_init (inst);if (ret == -EALREADY )return 0 ;else if (ret)
@@ -747,10 +747,6 @@ static int venc_init_session(struct venus_inst *inst)if (ret) goto deinit; - ret =venus_helper_init_codec_freq_data (inst); -if (ret) - goto deinit; - ret =venc_set_properties (inst);if (ret) goto deinit;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 207/286 media: venus: Rename venus_caps to hfi_plat_caps
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stanimir Varbanov <[email protected]>
[ Upstream commit 8f3b41dcfb9a0fa2d2ca0af51c3eebd670dc153b ]
Now when we have hfi platform make venus capabilities an hfi platform capabilities.
Stable-dep-of: 9edaaa8e3e15 ("media: venus: hfi_parser: refactor hfi packet parsing logic")
--- drivers/media/platform/qcom/venus/core.h | 30 ++----------------- drivers/media/platform/qcom/venus/helpers.c | 6 ++-- .../media/platform/qcom/venus/hfi_parser.c | 18 +++++------ .../media/platform/qcom/venus/hfi_parser.h | 2 +- .../media/platform/qcom/venus/hfi_platform.h | 25 ++++++++++++++++ 5 files changed, 41 insertions(+), 40 deletions(-)
drivers/media/platform/qcom/venus/core.h +3 -27
@@ -14,6 +14,7 @@#include "dbgfs.h" #include "hfi.h" +#include "hfi_platform.h" #define VDBGL "VenusLow : "#define VDBGM "VenusMed : "
@@ -82,31 +83,6 @@ struct venus_format {u32 flags; }; -#define MAX_PLANES 4 -#define MAX_FMT_ENTRIES 32 -#define MAX_CAP_ENTRIES 32 -#define MAX_ALLOC_MODE_ENTRIES 16 -#define MAX_CODEC_NUM 32 -#define MAX_SESSIONS 16 - -struct raw_formats { -u32 buftype; -u32 fmt; -}; - -struct venus_caps { -u32 codec; -u32 domain; -bool cap_bufs_mode_dynamic; -unsigned int num_caps; -struct hfi_capability caps[MAX_CAP_ENTRIES ]; -unsigned int num_pl; -struct hfi_profile_level pl[HFI_MAX_PROFILE_COUNT ]; -unsigned int num_fmts; -struct raw_formats fmts[MAX_FMT_ENTRIES ]; -bool valid;/* used only for Venus v1xx */ -}; -/** * struct venus_core - holds core parameters valid for all instances *
@@ -199,7 +175,7 @@ struct venus_core {void *priv;const struct hfi_ops *ops;struct delayed_work work; -struct venus_caps caps[MAX_CODEC_NUM ]; +struct hfi_plat_caps caps[MAX_CODEC_NUM ];unsigned int codecs_count;unsigned int core0_usage_count;unsigned int core1_usage_count;
@@ -434,7 +410,7 @@ static inline void *to_hfi_priv(struct venus_core *core)return core->priv; } -static inline struct venus_caps * +static inline struct hfi_plat_caps *venus_caps_by_codec (struct venus_core *core,u32 codec,u32 domain) {unsigned int c;
drivers/media/platform/qcom/venus/helpers.c +3 -3
@@ -481,7 +481,7 @@ session_process_buf(struct venus_inst *inst, struct vb2_v4l2_buffer *vbuf)static bool is_dynamic_bufmode (struct venus_inst *inst) {struct venus_core *core = inst->core; -struct venus_caps *caps; +struct hfi_plat_caps *caps;/* * v4 doesn't send BUFFER_ALLOC_MODE_SUPPORTED property and supports
@@ -1539,7 +1539,7 @@ void venus_helper_init_instance(struct venus_inst *inst) }EXPORT_SYMBOL_GPL (venus_helper_init_instance); -static bool find_fmt_from_caps (struct venus_caps *caps,u32 buftype,u32 fmt) +static bool find_fmt_from_caps (struct hfi_plat_caps *caps,u32 buftype,u32 fmt) {unsigned int i;
@@ -1556,7 +1556,7 @@ int venus_helper_get_out_fmts(struct venus_inst *inst, u32 v4l2_fmt, u32 *out_fmt, u32 *out2_fmt, bool ubwc) {struct venus_core *core = inst->core; -struct venus_caps *caps; +struct hfi_plat_caps *caps;u32 ubwc_fmt, fmt =to_hfi_raw_fmt (v4l2_fmt);bool found, found_ubwc;
drivers/media/platform/qcom/venus/hfi_parser.c +9 -9
@@ -11,12 +11,12 @@#include "hfi_helper.h" #include "hfi_parser.h" -typedef void (*func )(struct venus_caps *cap,const void *data, +typedef void (*func )(struct hfi_plat_caps *cap,const void *data,unsigned int size);static void init_codecs (struct venus_core *core) { -struct venus_caps *caps = core->caps, *cap; +struct hfi_plat_caps *caps = core->caps, *cap;unsigned long bit; core->codecs_count =0 ;
@@ -39,11 +39,11 @@ static void init_codecs(struct venus_core *core) } } -static void for_each_codec (struct venus_caps *caps,unsigned int caps_num, +static void for_each_codec (struct hfi_plat_caps *caps,unsigned int caps_num,u32 codecs,u32 domain,func cb,void *data,unsigned int size) { -struct venus_caps *cap; +struct hfi_plat_caps *cap;unsigned int i;for (i =0 ; i < caps_num; i++) {
@@ -56,7 +56,7 @@ static void for_each_codec(struct venus_caps *caps, unsigned int caps_num, }static void -fill_buf_mode (struct venus_caps *cap,const void *data,unsigned int num) +fill_buf_mode (struct hfi_plat_caps *cap,const void *data,unsigned int num) {const u32 *type = data;
@@ -86,7 +86,7 @@ parse_alloc_mode(struct venus_core *core, u32 codecs, u32 domain, void *data) } } -static void fill_profile_level (struct venus_caps *cap,const void *data, +static void fill_profile_level (struct hfi_plat_caps *cap,const void *data,unsigned int num) {const struct hfi_profile_level *pl = data;
@@ -115,7 +115,7 @@ parse_profile_level(struct venus_core *core, u32 codecs, u32 domain, void *data) }static void -fill_caps (struct venus_caps *cap,const void *data,unsigned int num) +fill_caps (struct hfi_plat_caps *cap,const void *data,unsigned int num) {const struct hfi_capability *caps = data;
@@ -143,7 +143,7 @@ parse_caps(struct venus_core *core, u32 codecs, u32 domain, void *data) fill_caps, caps_arr, num_caps); } -static void fill_raw_fmts (struct venus_caps *cap,const void *fmts, +static void fill_raw_fmts (struct hfi_plat_caps *cap,const void *fmts,unsigned int num_fmts) {const struct raw_formats *formats = fmts;
@@ -228,7 +228,7 @@ static void parser_init(struct venus_inst *inst, u32 *codecs, u32 *domain)static void parser_fini (struct venus_inst *inst,u32 codecs,u32 domain) { -struct venus_caps *caps, *cap; +struct hfi_plat_caps *caps, *cap;unsigned int i;u32 dom;
drivers/media/platform/qcom/venus/hfi_parser.h +1 -1
@@ -16,7 +16,7 @@ static inline u32 get_cap(struct venus_inst *inst, u32 type, u32 which) {struct venus_core *core = inst->core;struct hfi_capability *cap =NULL ; -struct venus_caps *caps; +struct hfi_plat_caps *caps;unsigned int i; caps =venus_caps_by_codec (core, inst->hfi_codec, inst->session_type);
drivers/media/platform/qcom/venus/hfi_platform.h +25 -0
@@ -12,6 +12,31 @@#include "hfi.h" #include "hfi_helper.h" +#define MAX_PLANES 4 +#define MAX_FMT_ENTRIES 32 +#define MAX_CAP_ENTRIES 32 +#define MAX_ALLOC_MODE_ENTRIES 16 +#define MAX_CODEC_NUM 32 +#define MAX_SESSIONS 16 + +struct raw_formats { +u32 buftype; +u32 fmt; +}; + +struct hfi_plat_caps { +u32 codec; +u32 domain; +bool cap_bufs_mode_dynamic; +unsigned int num_caps; +struct hfi_capability caps[MAX_CAP_ENTRIES ]; +unsigned int num_pl; +struct hfi_profile_level pl[HFI_MAX_PROFILE_COUNT ]; +unsigned int num_fmts; +struct raw_formats fmts[MAX_FMT_ENTRIES ]; +bool valid;/* used only for Venus v1xx */ +}; +struct hfi_platform_codec_freq_data {u32 pixfmt;u32 session_type;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 208/286 media: venus: hfi_plat: Add codecs and capabilities ops
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stanimir Varbanov <[email protected]>
[ Upstream commit 9822291e031f6d7149ae4f3fc00bd9c33ac2a084 ]
Add ops to get the supported by the platform codecs and capabilities.
Stable-dep-of: 9edaaa8e3e15 ("media: venus: hfi_parser: refactor hfi packet parsing logic")
--- drivers/media/platform/qcom/venus/hfi_platform.h | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/platform/qcom/venus/hfi_platform.h +2 -0
@@ -47,6 +47,8 @@ struct hfi_platform_codec_freq_data {struct hfi_platform {unsigned long (*codec_vpp_freq)(u32 session_type,u32 codec);unsigned long (*codec_vsp_freq)(u32 session_type,u32 codec); +void (*codecs)(u32 *enc_codecs,u32 *dec_codecs,u32 *count); +const struct hfi_plat_caps *(*capabilities)(unsigned int *entries); };extern const struct hfi_platform hfi_plat_v4;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 209/286 media: venus: Get codecs and capabilities from hfi platform
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stanimir Varbanov <[email protected]>
[ Upstream commit e29929266be1ac0e40121f56b5c13b52c281db06 ]
Wire up hfi platform codec and capabilities instead of getting them from firmware.
Stable-dep-of: 9edaaa8e3e15 ("media: venus: hfi_parser: refactor hfi packet parsing logic")
--- .../media/platform/qcom/venus/hfi_parser.c | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+)
drivers/media/platform/qcom/venus/hfi_parser.c +38 -0
@@ -245,11 +245,49 @@ static void parser_fini(struct venus_inst *inst, u32 codecs, u32 domain) } } +static int hfi_platform_parser (struct venus_core *core,struct venus_inst *inst) +{ +const struct hfi_platform *plat; +const struct hfi_plat_caps *caps =NULL ; +u32 enc_codecs, dec_codecs, count; +unsigned int entries; + +if (inst) +return 0 ; + + plat =hfi_platform_get (core->res->hfi_version); +if (!plat) +return -EINVAL ; + +if (plat->codecs) + plat->codecs (&enc_codecs, &dec_codecs, &count); + +if (plat->capabilities) + caps = plat->capabilities (&entries); + +if (!caps || !entries || !count) +return -EINVAL ; + + core->enc_codecs = enc_codecs; + core->dec_codecs = dec_codecs; + core->codecs_count = count; + core->max_sessions_supported =MAX_SESSIONS ; +memset (core->caps,0 ,sizeof (*caps) *MAX_CODEC_NUM ); +memcpy (core->caps, caps,sizeof (*caps) * entries); + +return 0 ; +} +u32 hfi_parser (struct venus_core *core,struct venus_inst *inst,void *buf,u32 size) {unsigned int words_count = size >>2 ;u32 *word = buf, *data, codecs =0 , domain =0 ; +int ret; + + ret =hfi_platform_parser (core, inst); +if (!ret) +return HFI_ERR_NONE ;if (size %4 )return HFI_ERR_SYS_INSUFFICIENT_RESOURCES ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 210/286 media: venus: hfi_parser: refactor hfi packet parsing logic
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vikash Garodia <[email protected]>
[ Upstream commit 9edaaa8e3e15aab1ca413ab50556de1975bcb329 ]
words_count denotes the number of words in total payload, while data points to payload of various property within it. When words_count reaches last word, data can access memory beyond the total payload. This can lead to OOB access. With this patch, the utility api for handling individual properties now returns the size of data consumed. Accordingly remaining bytes are calculated before parsing the payload, thereby eliminates the OOB access possibilities.
--- .../media/platform/qcom/venus/hfi_parser.c | 98 ++++++++++++++----- 1 file changed, 72 insertions(+), 26 deletions(-)
drivers/media/platform/qcom/venus/hfi_parser.c +72 -26
@@ -64,7 +64,7 @@ fill_buf_mode(struct hfi_plat_caps *cap, const void *data, unsigned int num) cap->cap_bufs_mode_dynamic = true; } -static void +static int parse_alloc_mode (struct venus_core *core,u32 codecs,u32 domain,void *data) {struct hfi_buffer_alloc_mode_supported *mode = data;
@@ -72,7 +72,7 @@ parse_alloc_mode(struct venus_core *core, u32 codecs, u32 domain, void *data)u32 *type;if (num_entries >MAX_ALLOC_MODE_ENTRIES ) -return ; +return -EINVAL ; type = mode->data;
@@ -84,6 +84,8 @@ parse_alloc_mode(struct venus_core *core, u32 codecs, u32 domain, void *data) type++; } + +return sizeof (*mode); } static void fill_profile_level(struct hfi_plat_caps *cap, const void *data,
@@ -98,7 +100,7 @@ static void fill_profile_level(struct hfi_plat_caps *cap, const void *data, cap->num_pl += num; } -static void +static int parse_profile_level (struct venus_core *core,u32 codecs,u32 domain,void *data) {struct hfi_profile_level_supported *pl = data;
@@ -106,12 +108,14 @@ parse_profile_level(struct venus_core *core, u32 codecs, u32 domain, void *data)struct hfi_profile_level pl_arr[HFI_MAX_PROFILE_COUNT ] = {};if (pl->profile_count >HFI_MAX_PROFILE_COUNT ) -return ; +return -EINVAL ;memcpy (pl_arr, proflevel, pl->profile_count *sizeof (*proflevel));for_each_codec (core->caps,ARRAY_SIZE (core->caps), codecs, domain, fill_profile_level, pl_arr, pl->profile_count); + +return pl->profile_count *sizeof (*proflevel) +sizeof (u32); } static void
@@ -126,7 +130,7 @@ fill_caps(struct hfi_plat_caps *cap, const void *data, unsigned int num) cap->num_caps += num; } -static void +static int parse_caps (struct venus_core *core,u32 codecs,u32 domain,void *data) {struct hfi_capabilities *caps = data;
@@ -135,12 +139,14 @@ parse_caps(struct venus_core *core, u32 codecs, u32 domain, void *data)struct hfi_capability caps_arr[MAX_CAP_ENTRIES ] = {};if (num_caps >MAX_CAP_ENTRIES ) -return ; +return -EINVAL ;memcpy (caps_arr, cap, num_caps *sizeof (*cap));for_each_codec (core->caps,ARRAY_SIZE (core->caps), codecs, domain, fill_caps, caps_arr, num_caps); + +return sizeof (*caps); } static void fill_raw_fmts(struct hfi_plat_caps *cap, const void *fmts,
@@ -155,7 +161,7 @@ static void fill_raw_fmts(struct hfi_plat_caps *cap, const void *fmts, cap->num_fmts += num_fmts; } -static void +static int parse_raw_formats (struct venus_core *core,u32 codecs,u32 domain,void *data) {struct hfi_uncompressed_format_supported *fmt = data;
@@ -164,7 +170,8 @@ parse_raw_formats(struct venus_core *core, u32 codecs, u32 domain, void *data)struct raw_formats rawfmts[MAX_FMT_ENTRIES ] = {};u32 entries = fmt->format_entries;unsigned int i =0 ; -u32 num_planes; +u32 num_planes =0 ; +u32 size;while (entries) { num_planes = pinfo->num_planes;
@@ -174,7 +181,7 @@ parse_raw_formats(struct venus_core *core, u32 codecs, u32 domain, void *data) i++;if (i >=MAX_FMT_ENTRIES ) -return ; +return -EINVAL ;if (pinfo->num_planes >MAX_PLANES )break ;
@@ -186,9 +193,13 @@ parse_raw_formats(struct venus_core *core, u32 codecs, u32 domain, void *data)for_each_codec (core->caps,ARRAY_SIZE (core->caps), codecs, domain, fill_raw_fmts, rawfmts, i); + size = fmt->format_entries * (sizeof (*constr) * num_planes +2 *sizeof (u32)) + +2 *sizeof (u32); + +return size; } -static void parse_codecs (struct venus_core *core,void *data) +static int parse_codecs (struct venus_core *core,void *data) {struct hfi_codec_supported *codecs = data;
@@ -200,21 +211,27 @@ static void parse_codecs(struct venus_core *core, void *data) core->dec_codecs &= ~HFI_VIDEO_CODEC_SPARK ; core->enc_codecs &= ~HFI_VIDEO_CODEC_HEVC ; } + +return sizeof (*codecs); } -static void parse_max_sessions (struct venus_core *core,const void *data) +static int parse_max_sessions (struct venus_core *core,const void *data) {const struct hfi_max_sessions_supported *sessions = data; core->max_sessions_supported = sessions->max_sessions; + +return sizeof (*sessions); } -static void parse_codecs_mask (u32 *codecs,u32 *domain,void *data) +static int parse_codecs_mask (u32 *codecs,u32 *domain,void *data) {struct hfi_codec_mask_supported *mask = data; *codecs = mask->codecs; *domain = mask->video_domains; + +return sizeof (*mask); }static void parser_init (struct venus_inst *inst,u32 *codecs,u32 *domain)
@@ -281,8 +298,9 @@ static int hfi_platform_parser(struct venus_core *core, struct venus_inst *inst)u32 hfi_parser (struct venus_core *core,struct venus_inst *inst,void *buf,u32 size) { -unsigned int words_count = size >>2 ; -u32 *word = buf, *data, codecs =0 , domain =0 ; +u32 *words = buf, *payload, codecs =0 , domain =0 ; +u32 *frame_size = buf + size; +u32 rem_bytes = size;int ret; ret =hfi_platform_parser (core, inst);
@@ -299,38 +317,66 @@ u32 hfi_parser(struct venus_core *core, struct venus_inst *inst, void *buf,memset (core->caps,0 ,sizeof (core->caps)); } -while (words_count) { - data = word +1 ; +while (words < frame_size) { + payload = words +1 ; -switch (*word) { +switch (*words) {case HFI_PROPERTY_PARAM_CODEC_SUPPORTED : -parse_codecs (core, data); +if (rem_bytes <=sizeof (struct hfi_codec_supported )) +return HFI_ERR_SYS_INSUFFICIENT_RESOURCES ; + + ret =parse_codecs (core, payload); +if (ret <0 ) +return HFI_ERR_SYS_INSUFFICIENT_RESOURCES ; +init_codecs (core);break ;case HFI_PROPERTY_PARAM_MAX_SESSIONS_SUPPORTED : -parse_max_sessions (core, data); +if (rem_bytes <=sizeof (struct hfi_max_sessions_supported )) +return HFI_ERR_SYS_INSUFFICIENT_RESOURCES ; + + ret =parse_max_sessions (core, payload);break ;case HFI_PROPERTY_PARAM_CODEC_MASK_SUPPORTED : -parse_codecs_mask (&codecs, &domain, data); +if (rem_bytes <=sizeof (struct hfi_codec_mask_supported )) +return HFI_ERR_SYS_INSUFFICIENT_RESOURCES ; + + ret =parse_codecs_mask (&codecs, &domain, payload);break ;case HFI_PROPERTY_PARAM_UNCOMPRESSED_FORMAT_SUPPORTED : -parse_raw_formats (core, codecs, domain, data); +if (rem_bytes <=sizeof (struct hfi_uncompressed_format_supported )) +return HFI_ERR_SYS_INSUFFICIENT_RESOURCES ; + + ret =parse_raw_formats (core, codecs, domain, payload);break ;case HFI_PROPERTY_PARAM_CAPABILITY_SUPPORTED : -parse_caps (core, codecs, domain, data); +if (rem_bytes <=sizeof (struct hfi_capabilities )) +return HFI_ERR_SYS_INSUFFICIENT_RESOURCES ; + + ret =parse_caps (core, codecs, domain, payload);break ;case HFI_PROPERTY_PARAM_PROFILE_LEVEL_SUPPORTED : -parse_profile_level (core, codecs, domain, data); +if (rem_bytes <=sizeof (struct hfi_profile_level_supported )) +return HFI_ERR_SYS_INSUFFICIENT_RESOURCES ; + + ret =parse_profile_level (core, codecs, domain, payload);break ;case HFI_PROPERTY_PARAM_BUFFER_ALLOC_MODE_SUPPORTED : -parse_alloc_mode (core, codecs, domain, data); +if (rem_bytes <=sizeof (struct hfi_buffer_alloc_mode_supported )) +return HFI_ERR_SYS_INSUFFICIENT_RESOURCES ; + + ret =parse_alloc_mode (core, codecs, domain, payload);break ;default : + ret =sizeof (u32);break ; } - word++; - words_count--; +if (ret <0 ) +return HFI_ERR_SYS_INSUFFICIENT_RESOURCES ; + + words += ret /sizeof (u32); + rem_bytes -= ret; }if (!core->max_sessions_supported)
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 211/286 net: dsa: mv88e6xxx: fix VTU methods for 6320 family
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Behún <[email protected]>
[ Upstream commit f9a457722cf5e3534be5ffab549d6b49737fca72 ]
The VTU registers of the 6320 family use the 6352 semantics, not 6185. Fix it.
--- drivers/net/dsa/mv88e6xxx/chip.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/dsa/mv88e6xxx/chip.c +4 -4
@@ -4170,8 +4170,8 @@ static const struct mv88e6xxx_ops mv88e6320_ops = { .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, .pot_clear = mv88e6xxx_g2_pot_clear, .reset = mv88e6352_g1_reset, - .vtu_getnext = mv88e6185_g1_vtu_getnext, - .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge, + .vtu_getnext = mv88e6352_g1_vtu_getnext, + .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, .gpio_ops = &mv88e6352_gpio_ops, .avb_ops = &mv88e6352_avb_ops, .ptp_ops = &mv88e6352_ptp_ops,
@@ -4212,8 +4212,8 @@ static const struct mv88e6xxx_ops mv88e6321_ops = { .watchdog_ops = &mv88e6390_watchdog_ops, .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, .reset = mv88e6352_g1_reset, - .vtu_getnext = mv88e6185_g1_vtu_getnext, - .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge, + .vtu_getnext = mv88e6352_g1_vtu_getnext, + .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, .gpio_ops = &mv88e6352_gpio_ops, .avb_ops = &mv88e6352_avb_ops, .ptp_ops = &mv88e6352_ptp_ops,
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 212/286 soc: samsung: exynos-chipid: initialize later - with arch_initcall
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Kozlowski <[email protected]>
[ Upstream commit 3b4c362e5ef102ca2d70d33f4e8cf0780053a7db ]
The Exynos ChipID driver on Exynos SoCs has only informational purpose - to expose the SoC device in sysfs. No other drivers depend on it so there is really no benefit of initializing it early.
Instead, initialize everything with arch_initcall which:
1. Allows to use dev_info() as the SoC bus is present (since core_initcall),
2. Could speed things up because of execution in a SMP environment (after bringing up secondary CPUs, unlike early_initcall),
3. Reduces the amount of work to be done early, when the kernel has to bring up critical devices.
Stable-dep-of: c8222ef6cf29 ("soc: samsung: exynos-chipid: Add NULL pointer check in exynos_chipid_probe()")
--- drivers/soc/samsung/exynos-chipid.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/soc/samsung/exynos-chipid.c +4 -4
@@ -98,9 +98,9 @@ static int __init exynos_chipid_early_init(void) goto err; } -/* it is too early to use dev_info() here (soc_dev is NULL) */ -pr_info ("soc soc0: Exynos: CPU[%s] PRO_ID[0x%x] REV[0x%x] Detected\n" , - soc_dev_attr->soc_id, product_id, revision); +dev_info (soc_device_to_device (soc_dev), +"Exynos: CPU[%s] PRO_ID[0x%x] REV[0x%x] Detected\n" , + soc_dev_attr->soc_id, product_id, revision);return 0 ;
@@ -110,4 +110,4 @@ static int __init exynos_chipid_early_init(void)return ret; } -early_initcall (exynos_chipid_early_init); +arch_initcall (exynos_chipid_early_init);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 213/286 soc: samsung: exynos-chipid: convert to driver and merge exynos-asv
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Kozlowski <[email protected]>
[ Upstream commit 352bfbb3e0230c96b2bce00d2ac3f0de303cc7b6 ]
The Exynos Chip ID driver on Exynos SoCs has so far only informational purpose - to expose the SoC device in sysfs. No other drivers depend on it so there is really no benefit of initializing it early.
The code would be the most flexible if converted to a regular driver. However there is already another driver - Exynos ASV (Adaptive Supply Voltage) - which binds to the device node of Chip ID.
The solution is to convert the Exynos Chip ID to a built in driver and merge the Exynos ASV into it.
This has several benefits:
1. Although the Exynos ASV driver binds to a device node present in all Exynos DTS (generic compatible), it fails to probe except on the supported ones (only Exynos5422). This means that the regular boot process has a planned/normal device probe failure.
Merging the ASV into Chip ID will remove this probe failure because the final driver will always bind, just with disabled ASV features.
2. Allows to use dev_info() as the SoC bus is present (since core_initcall).
3. Could speed things up because of execution of Chip ID code in a SMP environment (after bringing up secondary CPUs, unlike early_initcall), This reduces the amount of work to be done early, when the kernel has to bring up critical devices.
5. Makes the Chip ID code defer-probe friendly,
Stable-dep-of: c8222ef6cf29 ("soc: samsung: exynos-chipid: Add NULL pointer check in exynos_chipid_probe()")
--- arch/arm/mach-exynos/Kconfig | 1 - drivers/soc/samsung/Kconfig | 12 +++-- drivers/soc/samsung/Makefile | 3 +- drivers/soc/samsung/exynos-asv.c | 45 +++++-------------- drivers/soc/samsung/exynos-asv.h | 2 + drivers/soc/samsung/exynos-chipid.c | 69 ++++++++++++++++++++--------- 6 files changed, 67 insertions(+), 65 deletions(-)
arch/arm/mach-exynos/Kconfig +0 -1
@@ -13,7 +13,6 @@ menuconfig ARCH_EXYNOS select ARM_GIC select EXYNOS_IRQ_COMBINER select COMMON_CLK_SAMSUNG - select EXYNOS_ASV select EXYNOS_CHIPID select EXYNOS_THERMAL select EXYNOS_PMU
drivers/soc/samsung/Kconfig +5 -7
@@ -7,21 +7,19 @@ menuconfig SOC_SAMSUNG if SOC_SAMSUNG -config EXYNOS_ASV - bool "Exynos Adaptive Supply Voltage support" if COMPILE_TEST - depends on (ARCH_EXYNOS && EXYNOS_CHIPID) || COMPILE_TEST - select EXYNOS_ASV_ARM if ARM && ARCH_EXYNOS - # There is no need to enable these drivers for ARMv8 config EXYNOS_ASV_ARM bool "Exynos ASV ARMv7-specific driver extensions" if COMPILE_TEST - depends on EXYNOS_ASV + depends on EXYNOS_CHIPID config EXYNOS_CHIPID - bool "Exynos Chipid controller driver" if COMPILE_TEST + bool "Exynos ChipID controller and ASV driver" if COMPILE_TEST depends on ARCH_EXYNOS || COMPILE_TEST + select EXYNOS_ASV_ARM if ARM && ARCH_EXYNOS select MFD_SYSCON select SOC_BUS + help + Support for Samsung Exynos SoC ChipID and Adaptive Supply Voltage. config EXYNOS_PMU bool "Exynos PMU controller driver" if COMPILE_TEST
drivers/soc/samsung/Makefile +1 -2
@@ -1,9 +1,8 @@ # SPDX-License-Identifier: GPL-2.0 -obj-$(CONFIG_EXYNOS_ASV) += exynos-asv.o obj-$(CONFIG_EXYNOS_ASV_ARM) += exynos5422-asv.o -obj-$(CONFIG_EXYNOS_CHIPID) += exynos-chipid.o +obj-$(CONFIG_EXYNOS_CHIPID) += exynos-chipid.o exynos-asv.o obj-$(CONFIG_EXYNOS_PMU) += exynos-pmu.o obj-$(CONFIG_EXYNOS_PMU_ARM_DRIVERS) += exynos3250-pmu.o exynos4-pmu.o \
drivers/soc/samsung/exynos-asv.c +11 -34
96 lines not on this page · raw message
drivers/soc/samsung/exynos-asv.h +2 -0
@@ -68,4 +68,6 @@ static inline u32 exynos_asv_opp_get_frequency(const struct exynos_asv_subsys *s return __asv_get_table_entry(&subsys->table, level, 0); } +int exynos_asv_init (struct device *dev,struct regmap *regmap); +#endif /* __LINUX_SOC_EXYNOS_ASV_H */
drivers/soc/samsung/exynos-chipid.c +48 -21
129 lines not on this page · raw message
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 214/286 soc: samsung: exynos-chipid: avoid soc_device_to_device()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Kozlowski <[email protected]>
[ Upstream commit d1141886c8d72ad77920e6e4b617d366e6e3ee8a ]
soc_device_to_device() seems to be discouraged [1] so remove it in favor of printing info message with platform device. This will only change the prefix in the info message from "soc soc0: " to "exynos-chipid 10000000.chipid:".
[1] https://lore.kernel.org/lkml/[email protected]/
Stable-dep-of: c8222ef6cf29 ("soc: samsung: exynos-chipid: Add NULL pointer check in exynos_chipid_probe()")
--- drivers/soc/samsung/exynos-chipid.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/soc/samsung/exynos-chipid.c +1 -2
@@ -103,8 +103,7 @@ static int exynos_chipid_probe(struct platform_device *pdev)platform_set_drvdata (pdev, soc_dev); -dev_info (soc_device_to_device (soc_dev), -"Exynos: CPU[%s] PRO_ID[0x%x] REV[0x%x] Detected\n" , +dev_info (&pdev->dev,"Exynos: CPU[%s] PRO_ID[0x%x] REV[0x%x] Detected\n" , soc_dev_attr->soc_id, product_id, revision);return 0 ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 215/286 soc: samsung: exynos-chipid: Pass revision reg offsets
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sam Protsenko <[email protected]>
[ Upstream commit c072c4ef7ef09e1d6470c48cf52570487589b76a ]
Old Exynos SoCs have both Product ID and Revision ID in one single register, while new SoCs tend to have two separate registers for those IDs. Implement handling of both cases by passing Revision ID register offsets in driver data.
Previously existing macros for Exynos4210 (removed in this patch) were incorrect:
#define EXYNOS_SUBREV_MASK (0xf << 4)
#define EXYNOS_MAINREV_MASK (0xf << 0)Actual format of PRO_ID register in Exynos4210 (offset 0x0):
[31:12] Product ID
[9:8] Package information
[7:4] Main Revision Number
[3:0] Sub Revision Number
This patch doesn't change the behavior on existing platforms, so '/sys/devices/soc0/revision' will show the same string as before.
Stable-dep-of: c8222ef6cf29 ("soc: samsung: exynos-chipid: Add NULL pointer check in exynos_chipid_probe()")
--- drivers/soc/samsung/exynos-chipid.c | 69 +++++++++++++++++++---- include/linux/soc/samsung/exynos-chipid.h | 6 +- 2 files changed, 60 insertions(+), 15 deletions(-)
drivers/soc/samsung/exynos-chipid.c +58 -11
@@ -16,6 +16,7 @@#include <linux/errno.h> #include <linux/mfd/syscon.h> #include <linux/of.h> +#include <linux/of_device.h> #include <linux/platform_device.h> #include <linux/regmap.h> #include <linux/slab.h>
@@ -24,6 +25,17 @@#include "exynos-asv.h" +struct exynos_chipid_variant { +unsigned int rev_reg;/* revision register offset */ +unsigned int main_rev_shift;/* main revision offset in rev_reg */ +unsigned int sub_rev_shift;/* sub revision offset in rev_reg */ +}; + +struct exynos_chipid_info { +u32 product_id; +u32 revision; +}; + static const struct exynos_soc_id { const char *name; unsigned int id;
@@ -48,31 +60,57 @@ static const char * __init product_id_to_soc_id(unsigned int product_id)int i;for (i =0 ; i <ARRAY_SIZE (soc_ids); i++) -if ((product_id &EXYNOS_MASK ) == soc_ids[i].id) +if (product_id == soc_ids[i].id)return soc_ids[i].name;return NULL ; } +static int exynos_chipid_get_chipid_info (struct regmap *regmap, +const struct exynos_chipid_variant *data, +struct exynos_chipid_info *soc_info) +{ +int ret; +unsigned int val, main_rev, sub_rev; + + ret =regmap_read (regmap,EXYNOS_CHIPID_REG_PRO_ID , &val); +if (ret <0 ) +return ret; + soc_info->product_id = val &EXYNOS_MASK ; + +if (data->rev_reg !=EXYNOS_CHIPID_REG_PRO_ID ) { + ret =regmap_read (regmap, data->rev_reg, &val); +if (ret <0 ) +return ret; + } + main_rev = (val >> data->main_rev_shift) &EXYNOS_REV_PART_MASK ; + sub_rev = (val >> data->sub_rev_shift) &EXYNOS_REV_PART_MASK ; + soc_info->revision = (main_rev <<EXYNOS_REV_PART_SHIFT ) | sub_rev; + +return 0 ; +} +static int exynos_chipid_probe (struct platform_device *pdev) { +const struct exynos_chipid_variant *drv_data; +struct exynos_chipid_info soc_info;struct soc_device_attribute *soc_dev_attr;struct soc_device *soc_dev;struct device_node *root;struct regmap *regmap; -u32 product_id; -u32 revision;int ret; + drv_data =of_device_get_match_data (&pdev->dev); +if (!drv_data) +return -EINVAL ; + regmap =device_node_to_regmap (pdev->dev.of_node);if (IS_ERR (regmap))return PTR_ERR (regmap); - ret =regmap_read (regmap,EXYNOS_CHIPID_REG_PRO_ID , &product_id); + ret =exynos_chipid_get_chipid_info (regmap, drv_data, &soc_info);if (ret <0 )return ret; - revision = product_id &EXYNOS_REV_MASK ; - soc_dev_attr =devm_kzalloc (&pdev->dev,sizeof (*soc_dev_attr),GFP_KERNEL );if (!soc_dev_attr)
@@ -85,8 +123,8 @@ static int exynos_chipid_probe(struct platform_device *pdev)of_node_put (root); soc_dev_attr->revision =devm_kasprintf (&pdev->dev,GFP_KERNEL , -"%x" , revision); - soc_dev_attr->soc_id =product_id_to_soc_id (product_id); +"%x" , soc_info.revision); + soc_dev_attr->soc_id =product_id_to_soc_id (soc_info.product_id);if (!soc_dev_attr->soc_id) {pr_err ("Unknown SoC\n" );return -ENODEV ;
@@ -104,7 +142,7 @@ static int exynos_chipid_probe(struct platform_device *pdev)platform_set_drvdata (pdev, soc_dev);dev_info (&pdev->dev,"Exynos: CPU[%s] PRO_ID[0x%x] REV[0x%x] Detected\n" , - soc_dev_attr->soc_id, product_id, revision); + soc_dev_attr->soc_id, soc_info.product_id, soc_info.revision);return 0 ;
@@ -123,9 +161,18 @@ static int exynos_chipid_remove(struct platform_device *pdev)return 0 ; } +static const struct exynos_chipid_variant exynos4210_chipid_drv_data = { + .rev_reg =0x0 , + .main_rev_shift =4 , + .sub_rev_shift =0 , +}; +static const struct of_device_id exynos_chipid_of_device_ids[] = { - { .compatible ="samsung,exynos4210-chipid" }, - {} + { + .compatible ="samsung,exynos4210-chipid" , + .data = &exynos4210_chipid_drv_data, + }, + { } };static struct platform_driver exynos_chipid_driver = {
include/linux/soc/samsung/exynos-chipid.h +2 -4
@@ -9,10 +9,8 @@#define __LINUX_SOC_EXYNOS_CHIPID_H#define EXYNOS_CHIPID_REG_PRO_ID 0x00 -#define EXYNOS_SUBREV_MASK (0xf << 4) -#define EXYNOS_MAINREV_MASK (0xf << 0) -#define EXYNOS_REV_MASK (EXYNOS_SUBREV_MASK | \ - EXYNOS_MAINREV_MASK) +#define EXYNOS_REV_PART_MASK 0xf +#define EXYNOS_REV_PART_SHIFT 4#define EXYNOS_MASK 0xfffff000#define EXYNOS_CHIPID_REG_PKG_ID 0x04
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 216/286 soc: samsung: exynos-chipid: Add NULL pointer check in exynos_chipid_probe()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chenyuan Yang <[email protected]>
[ Upstream commit c8222ef6cf29dd7cad21643228f96535cc02b327 ]
soc_dev_attr->revision could be NULL, thus,
a pointer check is added to prevent potential NULL pointer dereference. This is similar to the fix in commit 3027e7b15b02
("ice: Fix some null pointer dereference issues in ice_ptp.c").
This issue is found by our static analysis tool.
--- drivers/soc/samsung/exynos-chipid.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/soc/samsung/exynos-chipid.c +2 -0
@@ -124,6 +124,8 @@ static int exynos_chipid_probe(struct platform_device *pdev) soc_dev_attr->revision =devm_kasprintf (&pdev->dev,GFP_KERNEL ,"%x" , soc_info.revision); +if (!soc_dev_attr->revision) +return -ENOMEM ; soc_dev_attr->soc_id =product_id_to_soc_id (soc_info.product_id);if (!soc_dev_attr->soc_id) {pr_err ("Unknown SoC\n" );
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 217/286 iio: adc: ad7768-1: Move setting of val a bit later to avoid unnecessary return value check
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jonathan Cameron <[email protected]>
[ Upstream commit 0af1c801a15225304a6328258efbf2bee245c654 ]
The data used is all in local variables so there is no advantage in setting *val = ret with the direct mode claim held. Move it later to after error check.
Stable-dep-of: 8236644f5ecb ("iio: adc: ad7768-1: Fix conversion result sign")
--- drivers/iio/adc/ad7768-1.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/iio/adc/ad7768-1.c +1 -2
@@ -369,12 +369,11 @@ static int ad7768_read_raw(struct iio_dev *indio_dev,return ret; ret =ad7768_scan_direct (indio_dev); -if (ret >=0 ) - *val = ret;iio_device_release_direct_mode (indio_dev);if (ret <0 )return ret; + *val = ret;return IIO_VAL_INT ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 218/286 iio: adc: ad7768-1: Fix conversion result sign
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sergiu Cuciurean <[email protected]>
[ Upstream commit 8236644f5ecb180e80ad92d691c22bc509b747bb ]
The ad7768-1 ADC output code is two's complement, meaning that the voltage conversion result is a signed value.. Since the value is a 24 bit one, stored in a 32 bit variable, the sign should be extended in order to get the correct representation.
Also the channel description has been updated to signed representation, to match the ADC specifications.
--- drivers/iio/adc/ad7768-1.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/adc/ad7768-1.c +2 -2
@@ -142,7 +142,7 @@ static const struct iio_chan_spec ad7768_channels[] = { .channel = 0, .scan_index = 0, .scan_type = { - .sign = 'u', + .sign = 's', .realbits = 24, .storagebits = 32, .shift = 8,
@@ -373,7 +373,7 @@ static int ad7768_read_raw(struct iio_dev *indio_dev,iio_device_release_direct_mode (indio_dev);if (ret <0 )return ret; - *val = ret; + *val =sign_extend32 (ret, chan->scan_type.realbits -1 );return IIO_VAL_INT ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 219/286 backlight: led_bl: Hold led_access lock when calling led_sysfs_disable()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Herve Codina <[email protected]>
[ Upstream commit 276822a00db3c1061382b41e72cafc09d6a0ec30 ]
Lockdep detects the following issue on led-backlight removal:
[ 142.315935] ------------[ cut here ]------------ [ 142.315954] WARNING: CPU: 2 PID: 292 at drivers/leds/led-core.c:455 led_sysfs_enable+0x54/0x80 ... [ 142.500725] Call trace: [ 142.503176] led_sysfs_enable+0x54/0x80 (P) [ 142.507370] led_bl_remove+0x80/0xa8 [led_bl] [ 142.511742] platform_remove+0x30/0x58 [ 142.515501] device_remove+0x54/0x90 ...
Indeed, led_sysfs_enable() has to be called with the led_access lock held.
Hold the lock when calling led_sysfs_disable().
--- drivers/video/backlight/led_bl.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/video/backlight/led_bl.c +4 -1
@@ -226,8 +226,11 @@ static int led_bl_remove(struct platformbacklight_device_unregister (bl);led_bl_power_off (priv); -for (i =0 ; i < priv->nb_leds; i++) +for (i =0 ; i < priv->nb_leds; i++) { +mutex_lock (&priv->leds[i]->led_access);led_sysfs_enable (priv->leds[i]); +mutex_unlock (&priv->leds[i]->led_access); + }return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 220/286 cifs: print TIDs as hex
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Enzo Matsumiya <[email protected]>
[ Upstream commit 71081e7ac16c93acdd18afa65daa468620bb1b64 ]
Makes these debug messages easier to read
Stable-dep-of: b4885bd5935b ("cifs: avoid NULL pointer dereference in dbg call")
--- fs/cifs/connect.c | 2 +- fs/cifs/smb2misc.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
fs/cifs/connect.c +1 -1
@@ -2770,7 +2770,7 @@ cifs_setup_ipc(struct cifs_ses *ses, struct smb_vol *volume_info) goto out; } -cifs_dbg (FYI ,"IPC tcon rc = %d ipc tid = %d\n" , rc, tcon->tid); +cifs_dbg (FYI ,"IPC tcon rc=%d ipc tid=0x%x\n" , rc, tcon->tid); ses->tcon_ipc = tcon; out:
fs/cifs/smb2misc.c +1 -1
@@ -812,7 +812,7 @@ smb2_handle_cancelled_close(struct cifs_tcon *tcon, __u64 persistent_fid,if (tcon->ses) server = tcon->ses->server; -cifs_server_dbg (FYI ,"tid=%u: tcon is closing, skipping async close retry of fid %llu %llu\n" , +cifs_server_dbg (FYI ,"tid=0x%x: tcon is closing, skipping async close retry of fid %llu %llu\n" , tcon->tid, persistent_fid, volatile_fid);return 0 ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 221/286 cifs: avoid NULL pointer dereference in dbg call
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexandra Diupina <[email protected]>
[ Upstream commit b4885bd5935bb26f0a414ad55679a372e53f9b9b ]
cifs_server_dbg() implies server to be non-NULL so move call under condition to avoid NULL pointer dereference.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- fs/cifs/smb2misc.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
fs/cifs/smb2misc.c +5 -4
@@ -809,11 +809,12 @@ smb2_handle_cancelled_close(struct cifs_tcon *tcon, __u64 persistent_fid,WARN_ONCE (tcon->tc_count <0 ,"tcon refcount is negative" );spin_unlock (&cifs_tcp_ses_lock); -if (tcon->ses) +if (tcon->ses) { server = tcon->ses->server; - -cifs_server_dbg (FYI ,"tid=0x%x: tcon is closing, skipping async close retry of fid %llu %llu\n" , - tcon->tid, persistent_fid, volatile_fid); +cifs_server_dbg (FYI , +"tid=0x%x: tcon is closing, skipping async close retry of fid %llu %llu\n" , + tcon->tid, persistent_fid, volatile_fid); + }return 0 ; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 222/286 PCI: Introduce domain_nr in pci_host_bridge
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Boqun Feng <[email protected]>
[ Upstream commit 15d82ca23c996d50062286d27ed6a42a8105c04a ]
Currently we retrieve the PCI domain number of the host bridge from the bus sysdata (or pci_config_window if PCI_DOMAINS_GENERIC=y). Actually we have the information at PCI host bridge probing time, and it makes sense that we store it into pci_host_bridge. One benefit of doing so is the requirement for supporting PCI on Hyper-V for ARM64, because the host bridge of Hyper-V doesn't have pci_config_window, whereas ARM64 is a PCI_DOMAINS_GENERIC=y arch, so we cannot retrieve the PCI domain number from pci_config_window on ARM64 Hyper-V guest.
As the preparation for ARM64 Hyper-V PCI support, we introduce the domain_nr in pci_host_bridge and a sentinel value to allow drivers to set domain numbers properly at probing time. Currently CONFIG_PCI_DOMAINS_GENERIC=y archs are only users of this newly-introduced field.
Stable-dep-of: 804443c1f278 ("PCI: Fix reference leak in pci_register_host_bridge()")
--- drivers/pci/probe.c | 6 +++++- include/linux/pci.h | 11 +++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-)
drivers/pci/probe.c +5 -1
@@ -595,6 +595,7 @@ static void pci_init_host_bridge(struct pci_host_bridge *bridge) bridge->native_pme =1 ; bridge->native_ltr =1 ; bridge->native_dpc =1 ; + bridge->domain_nr =PCI_DOMAIN_NR_NOT_SET ;device_initialize (&bridge->dev); }
@@ -899,7 +900,10 @@ static int pci_register_host_bridge(struct pci_host_bridge *bridge) bus->ops = bridge->ops; bus->number = bus->busn_res.start = bridge->busnr;#ifdef CONFIG_PCI_DOMAINS_GENERIC - bus->domain_nr =pci_bus_find_domain_nr (bus, parent); +if (bridge->domain_nr ==PCI_DOMAIN_NR_NOT_SET ) + bus->domain_nr =pci_bus_find_domain_nr (bus, parent); +else + bus->domain_nr = bridge->domain_nr;#endif b =pci_find_bus (pci_domain_nr (bus), bridge->busnr);
include/linux/pci.h +11 -0
@@ -538,6 +538,16 @@ static inline int pci_channel_offline(struct pci_dev *pdev)return (pdev->error_state != pci_channel_io_normal); } +/* +* Currently in ACPI spec, for each PCI host bridge, PCI Segment +* Group number is limited to a 16-bit value, therefore (int)-1 is +* not a valid PCI domain number, and can be used as a sentinel +* value indicating ->domain_nr is not set by the driver (and +* CONFIG_PCI_DOMAINS_GENERIC=y archs will set it with +* pci_bus_find_domain_nr()). +*/ +#define PCI_DOMAIN_NR_NOT_SET (-1) +struct pci_host_bridge {struct device dev;struct pci_bus *bus;/* Root bus */
@@ -545,6 +555,7 @@ struct pci_host_bridge {struct pci_ops *child_ops;void *sysdata;int busnr; +int domain_nr;struct list_head windows;/* resource_entry */ struct list_head dma_ranges;/* dma ranges resource list */ u8 (*swizzle_irq)(struct pci_dev *,u8 *);/* Platform IRQ swizzler */
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 223/286 PCI: Coalesce host bridge contiguous apertures
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kai-Heng Feng <[email protected]>
[ Upstream commit 65db04053efea3f3e412a7e0cc599962999c96b4 ]
Built-in graphics on HP EliteDesk 805 G6 doesn't work because graphics can't get the BAR it needs:
pci_bus 0000:00: root bus resource [mem 0x10020200000-0x100303fffff window] pci_bus 0000:00: root bus resource [mem 0x10030400000-0x100401fffff window]
pci 0000:00:08.1: bridge window [mem 0xd2000000-0xd23fffff]
pci 0000:00:08.1: bridge window [mem 0x10030000000-0x100401fffff 64bit pref]
pci 0000:00:08.1: can't claim BAR 15 [mem 0x10030000000-0x100401fffff 64bit pref]: no compatible bridge window pci 0000:00:08.1: [mem 0x10030000000-0x100401fffff 64bit pref] clipped to [mem 0x10030000000-0x100303fffff 64bit pref]
pci 0000:00:08.1: bridge window [mem 0x10030000000-0x100303fffff 64bit pref]
pci 0000:07:00.0: can't claim BAR 0 [mem 0x10030000000-0x1003fffffff 64bit pref]: no compatible bridge window pci 0000:07:00.0: can't claim BAR 2 [mem 0x10040000000-0x100401fffff 64bit pref]: no compatible bridge window
However, the root bus has two contiguous apertures that can contain the child resource requested.
Coalesce contiguous apertures so we can allocate from the entire contiguous region.
[bhelgaas: fold in https://lore.kernel.org/r/[email protected]]
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=212013
Stable-dep-of: 804443c1f278 ("PCI: Fix reference leak in pci_register_host_bridge()")
--- drivers/pci/probe.c | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-)
drivers/pci/probe.c +27 -4
@@ -878,11 +878,11 @@ static void pci_set_bus_msi_domain(struct pci_bus *bus)static int pci_register_host_bridge (struct pci_host_bridge *bridge) {struct device *parent = bridge->dev.parent; -struct resource_entry *window, *n; +struct resource_entry *window, *next, *n;struct pci_bus *bus, *b; -resource_size_t offset; +resource_size_t offset, next_offset;LIST_HEAD (resources); -struct resource *res; +struct resource *res, *next_res;char addr[64 ], *fmt;const char *name;int err;
@@ -962,11 +962,34 @@ static int pci_register_host_bridge(struct pci_host_bridge *bridge)if (nr_node_ids >1 &&pcibus_to_node (bus) ==NUMA_NO_NODE )dev_warn (&bus->dev,"Unknown NUMA node; performance will be reduced\n" ); +/* Coalesce contiguous windows */ +resource_list_for_each_entry_safe (window, n, &resources) { +if (list_is_last (&window->node, &resources)) +break ; + + next =list_next_entry (window, node); + offset = window->offset; + res = window->res; + next_offset = next->offset; + next_res = next->res; + +if (res->flags != next_res->flags || offset != next_offset) +continue ; + +if (res->end +1 == next_res->start) { + next_res->start = res->start; + res->flags = res->start = res->end =0 ; + } + } +/* Add initial resources to the bus */ resource_list_for_each_entry_safe (window, n, &resources) { -list_move_tail (&window->node, &bridge->windows); offset = window->offset; res = window->res; +if (!res->end) +continue ; + +list_move_tail (&window->node, &bridge->windows);if (res->flags &IORESOURCE_BUS )pci_bus_insert_busn_res (bus, bus->number, res->end);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 224/286 PCI: Assign PCI domain IDs by ida_alloc()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pali Rohár <[email protected]>
[ Upstream commit c14f7ccc9f5dcf9d06ddeec706f85405b2c80600 ]
Replace assignment of PCI domain IDs from atomic_inc_return() to ida_alloc().
Use two IDAs, one for static domain allocations (those which are defined in device tree) and second for dynamic allocations (all other).
During removal of root bus / host bridge, also release the domain ID. The released ID can be reused again, for example when dynamically loading and unloading native PCI host bridge drivers.
This change also allows to mix static device tree assignment and dynamic by kernel as all static allocations are reserved in dynamic pool.
Stable-dep-of: 804443c1f278 ("PCI: Fix reference leak in pci_register_host_bridge()")
--- drivers/pci/pci.c | 103 +++++++++++++++++++++++++------------------ drivers/pci/probe.c | 7 +++ drivers/pci/remove.c | 6 +++ include/linux/pci.h | 1 + 4 files changed, 74 insertions(+), 43 deletions(-)
drivers/pci/pci.c +60 -43
@@ -6467,60 +6467,70 @@ static void pci_no_domains(void) }#ifdef CONFIG_PCI_DOMAINS_GENERIC -static atomic_t __domain_nr =ATOMIC_INIT (-1 ); +static DEFINE_IDA (pci_domain_nr_static_ida); +static DEFINE_IDA (pci_domain_nr_dynamic_ida); -static int pci_get_new_domain_nr (void ) +static void of_pci_reserve_static_domain_nr (void ) { -return atomic_inc_return (&__domain_nr); +struct device_node *np; +int domain_nr; + +for_each_node_by_type (np,"pci" ) { + domain_nr =of_get_pci_domain_nr (np); +if (domain_nr <0 ) +continue ; +/* +* Permanently allocate domain_nr in dynamic_ida +* to prevent it from dynamic allocation. +*/ +ida_alloc_range (&pci_domain_nr_dynamic_ida, + domain_nr, domain_nr,GFP_KERNEL ); + } }static int of_pci_bus_find_domain_nr (struct device *parent) { -static int use_dt_domains =-1 ; -int domain =-1 ; +static bool static_domains_reserved = false; +int domain_nr; -if (parent) - domain =of_get_pci_domain_nr (parent->of_node); +/* On the first call scan device tree for static allocations. */ +if (!static_domains_reserved) { +of_pci_reserve_static_domain_nr (); + static_domains_reserved = true; + } + +if (parent) { +/* +* If domain is in DT, allocate it in static IDA. This +* prevents duplicate static allocations in case of errors +* in DT. +*/ + domain_nr =of_get_pci_domain_nr (parent->of_node); +if (domain_nr >=0 ) +return ida_alloc_range (&pci_domain_nr_static_ida, + domain_nr, domain_nr, +GFP_KERNEL ); + }/* -* Check DT domain and use_dt_domains values. -* -* If DT domain property is valid (domain >= 0) and -* use_dt_domains != 0, the DT assignment is valid since this means -* we have not previously allocated a domain number by using -* pci_get_new_domain_nr(); we should also update use_dt_domains to -* 1, to indicate that we have just assigned a domain number from -* DT. -* -* If DT domain property value is not valid (ie domain < 0), and we -* have not previously assigned a domain number from DT -* (use_dt_domains != 1) we should assign a domain number by -* using the: -* -* pci_get_new_domain_nr() -* -* API and update the use_dt_domains value to keep track of method we -* are using to assign domain numbers (use_dt_domains = 0). -* -* All other combinations imply we have a platform that is trying -* to mix domain numbers obtained from DT and pci_get_new_domain_nr(), -* which is a recipe for domain mishandling and it is prevented by -* invalidating the domain value (domain = -1) and printing a -* corresponding error. +* If domain was not specified in DT, choose a free ID from dynamic +* allocations. All domain numbers from DT are permanently in +* dynamic allocations to prevent assigning them to other DT nodes +* without static domain. */ -if (domain >=0 && use_dt_domains) { - use_dt_domains =1 ; - }else if (domain <0 && use_dt_domains !=1 ) { - use_dt_domains =0 ; - domain =pci_get_new_domain_nr (); - }else { -if (parent) -pr_err ("Node %pOF has " , parent->of_node); -pr_err ("Inconsistent \"linux,pci-domain\" property in DT\n" ); - domain =-1 ; - } +return ida_alloc (&pci_domain_nr_dynamic_ida,GFP_KERNEL ); +} -return domain; +static void of_pci_bus_release_domain_nr (struct pci_bus *bus,struct device *parent) +{ +if (bus->domain_nr <0 ) +return ; + +/* Release domain from IDA where it was allocated. */ +if (of_get_pci_domain_nr (parent->of_node) == bus->domain_nr) +ida_free (&pci_domain_nr_static_ida, bus->domain_nr); +else +ida_free (&pci_domain_nr_dynamic_ida, bus->domain_nr); }int pci_bus_find_domain_nr (struct pci_bus *bus,struct device *parent)
@@ -6528,6 +6538,13 @@ int pci_bus_find_domain_nr(struct pci_bus *bus, struct device *parent)return acpi_disabled ?of_pci_bus_find_domain_nr (parent) : acpi_pci_bus_find_domain_nr(bus); } + +void pci_bus_release_domain_nr (struct pci_bus *bus,struct device *parent) +{ +if (!acpi_disabled) +return ; +of_pci_bus_release_domain_nr (bus, parent); +}#endif /**
drivers/pci/probe.c +7 -0
@@ -904,6 +904,10 @@ static int pci_register_host_bridge(struct pci_host_bridge *bridge) bus->domain_nr =pci_bus_find_domain_nr (bus, parent); else bus->domain_nr = bridge->domain_nr; +if (bus->domain_nr <0 ) { + err = bus->domain_nr; + goto free; + }#endif b =pci_find_bus (pci_domain_nr (bus), bridge->busnr);
@@ -1022,6 +1026,9 @@ static int pci_register_host_bridge(struct pci_host_bridge *bridge)device_del (&bridge->dev); free: +#ifdef CONFIG_PCI_DOMAINS_GENERIC +pci_bus_release_domain_nr (bus ,parent ); +#endif kfree (bus);return err; }
drivers/pci/remove.c +6 -0
@@ -159,6 +159,12 @@ void pci_remove_root_bus(struct pci_bus *bus)pci_remove_bus (bus); host_bridge->bus =NULL ; +#ifdef CONFIG_PCI_DOMAINS_GENERIC +/* Release domain_nr if it was dynamically allocated */ +if (host_bridge->domain_nr ==PCI_DOMAIN_NR_NOT_SET ) +pci_bus_release_domain_nr (bus, host_bridge->dev.parent); +#endif +/* remove the host bridge */ device_del (&host_bridge->dev); }
include/linux/pci.h +1 -0
@@ -1667,6 +1667,7 @@ static inline int acpi_pci_bus_find_domain_nr(struct pci_bus *bus) {return 0 ; }#endif int pci_bus_find_domain_nr (struct pci_bus *bus,struct device *parent); +void pci_bus_release_domain_nr (struct pci_bus *bus,struct device *parent);#endif /* Some architectures require additional setup to direct VGA traffic */
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 225/286 PCI: Fix reference leak in pci_register_host_bridge()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ma Ke <[email protected]>
[ Upstream commit 804443c1f27883926de94c849d91f5b7d7d696e9 ]
If device_register() fails, call put_device() to give up the reference to avoid a memory leak, per the comment at device_register().
Found by code review.
[bhelgaas: squash Dan Carpenter's double free fix from
https://lore.kernel.org/r/[email protected]]
--- drivers/pci/probe.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/pci/probe.c +7 -2
@@ -883,6 +883,7 @@ static int pci_register_host_bridge(struct pci_host_bridge *bridge)resource_size_t offset, next_offset;LIST_HEAD (resources);struct resource *res, *next_res; +bool bus_registered = false;char addr[64 ], *fmt;const char *name;int err;
@@ -944,6 +945,7 @@ static int pci_register_host_bridge(struct pci_host_bridge *bridge) name =dev_name (&bus->dev); err =device_register (&bus->dev); + bus_registered = true;if (err) goto unregister;
@@ -1024,12 +1026,15 @@ static int pci_register_host_bridge(struct pci_host_bridge *bridge) unregister:put_device (&bridge->dev);device_del (&bridge->dev); - free: #ifdef CONFIG_PCI_DOMAINS_GENERICpci_bus_release_domain_nr (bus ,parent );#endif -kfree (bus); +if (bus_registered) +put_device (&bus->dev); +else +kfree (bus); +return err; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 226/286 selftests/mm: generate a temporary mountpoint for cgroup filesystem
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mark Brown <[email protected]>
[ Upstream commit 9c02223e2d9df5cb37c51aedb78f3960294e09b5 ]
Currently if the filesystem for the cgroups version it wants to use is not mounted charge_reserved_hugetlb.sh and hugetlb_reparenting_test.sh tests will attempt to mount it on the hard coded path /dev/cgroup/memory, deleting that directory when the test finishes. This will fail if there is not a preexisting directory at that path, and since the directory is deleted subsequent runs of the test will fail. Instead of relying on this hard coded directory name use mktemp to generate a temporary directory to use as a mountpoint, fixing both the assumption and the disruption caused by deleting a preexisting directory.
This means that if the relevant cgroup filesystem is not already mounted then we rely on having coreutils (which provides mktemp) installed. I suspect that many current users are relying on having things automounted by default, and given that the script relies on bash it's probably not an unreasonable requirement.
--- tools/testing/selftests/vm/charge_reserved_hugetlb.sh | 4 ++-- tools/testing/selftests/vm/hugetlb_reparenting_test.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
tools/testing/selftests/vm/charge_reserved_hugetlb.sh +2 -2
@@ -24,7 +24,7 @@ fi if [[ $cgroup2 ]]; then cgroup_path=$(mount -t cgroup2 | head -1 | awk '{print $3}') if [[ -z "$cgroup_path" ]]; then - cgroup_path=/dev/cgroup/memory + cgroup_path=$(mktemp -d) mount -t cgroup2 none $cgroup_path do_umount=1 fi
@@ -32,7 +32,7 @@ if [[ $cgroup2 ]]; then else cgroup_path=$(mount -t cgroup | grep ",hugetlb" | awk '{print $3}') if [[ -z "$cgroup_path" ]]; then - cgroup_path=/dev/cgroup/memory + cgroup_path=$(mktemp -d) mount -t cgroup memory,hugetlb $cgroup_path do_umount=1 fi
tools/testing/selftests/vm/hugetlb_reparenting_test.sh +1 -1
@@ -19,7 +19,7 @@ fi if [[ $cgroup2 ]]; then CGROUP_ROOT=$(mount -t cgroup2 | head -1 | awk '{print $3}') if [[ -z "$CGROUP_ROOT" ]]; then - CGROUP_ROOT=/dev/cgroup/memory + CGROUP_ROOT=$(mktemp -d) mount -t cgroup2 none $CGROUP_ROOT do_umount=1 fi
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 227/286 drm/amd/amdgpu/amdgpu_vram_mgr: Add missing descriptions for dev and dir
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lee Jones <[email protected]>
[ Upstream commit 2c8645b7a6974b33744b677e9ddc89650776af46 ]
Fixes the following W=1 kernel build warning(s):
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c:648: warning: Function parameter or member 'dev' not described in 'amdgpu_vram_mgr_free_sgt' drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c:648: warning: Function parameter or member 'dir' not described in 'amdgpu_vram_mgr_free_sgt'
Stable-dep-of: c0dd8a9253fa ("drm/amdgpu/dma_buf: fix page_link check")
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +2 -0
@@ -531,6 +531,8 @@ int amdgpu_vram_mgr_alloc_sgt(struct amdgpu_device *adev,* amdgpu_vram_mgr_alloc_sgt - allocate and fill a sg table * * @adev: amdgpu device pointer +* @dev: device pointer +* @dir: data direction of resource to unmap * @sgt: sg table to free * * Free a previously allocate sg table.
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 228/286 drm/amdgpu: Remove amdgpu_device arg from free_sgt api (v2)
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ramesh Errabolu <[email protected]>
[ Upstream commit 5392b2af97dc5802991f953eb2687e538da4688c ]
Currently callers have to provide handle of amdgpu_device, which is not used by the implementation. It is unlikely this parameter will become useful in future, thus removing it
v2: squash in unused variable fix
Stable-dep-of: c0dd8a9253fa ("drm/amdgpu/dma_buf: fix page_link check")
--- drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c | 7 +------ drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h | 3 +-- drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 4 +--- 3 files changed, 3 insertions(+), 11 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c +1 -6
@@ -357,17 +357,12 @@ static void amdgpu_dma_buf_unmap(struct dma_buf_attachment *attach, struct sg_table *sgt, enum dma_data_direction dir) { -struct dma_buf *dma_buf = attach->dmabuf; -struct drm_gem_object *obj = dma_buf->priv; -struct amdgpu_bo *bo =gem_to_amdgpu_bo (obj); -struct amdgpu_device *adev =amdgpu_ttm_adev (bo->tbo.bdev); -if (sgt->sgl->page_link) {dma_unmap_sgtable (attach->dev, sgt, dir,0 );sg_free_table (sgt);kfree (sgt); }else { -amdgpu_vram_mgr_free_sgt (adev, attach->dev, dir, sgt); +amdgpu_vram_mgr_free_sgt (attach->dev, dir, sgt); } }
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +1 -2
@@ -113,8 +113,7 @@ int amdgpu_vram_mgr_alloc_sgt(struct amdgpu_device *adev,struct device *dev, enum dma_data_direction dir, struct sg_table **sgt); -void amdgpu_vram_mgr_free_sgt (struct amdgpu_device *adev, -struct device *dev, +void amdgpu_vram_mgr_free_sgt (struct device *dev,enum dma_data_direction dir,struct sg_table *sgt);uint64_t amdgpu_vram_mgr_usage (struct ttm_resource_manager *man);
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +1 -3
@@ -530,15 +530,13 @@ int amdgpu_vram_mgr_alloc_sgt(struct amdgpu_device *adev,/** * amdgpu_vram_mgr_alloc_sgt - allocate and fill a sg table * -* @adev: amdgpu device pointer * @dev: device pointer * @dir: data direction of resource to unmap * @sgt: sg table to free * * Free a previously allocate sg table. */ -void amdgpu_vram_mgr_free_sgt (struct amdgpu_device *adev, -struct device *dev, +void amdgpu_vram_mgr_free_sgt (struct device *dev,enum dma_data_direction dir,struct sg_table *sgt) {
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 229/286 drm/amdgpu/dma_buf: fix page_link check
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthew Auld <[email protected]>
[ Upstream commit c0dd8a9253fadfb8e5357217d085f1989da4ef0a ]
The page_link lower bits of the first sg could contain something like SG_END, if we are mapping a single VRAM page or contiguous blob which fits into one sg entry. Rather pull out the struct page, and use that in our check to know if we mapped struct pages vs VRAM.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c +1 -1
@@ -357,7 +357,7 @@ static void amdgpu_dma_buf_unmap(struct dma_buf_attachment *attach, struct sg_table *sgt, enum dma_data_direction dir) { -if (sgt->sgl->page_link) { + if (sg_page(sgt->sgl)) {dma_unmap_sgtable (attach->dev, sgt, dir,0 );sg_free_table (sgt);kfree (sgt);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 230/286 dma/contiguous: avoid warning about unused size_bytes
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
[ Upstream commit d7b98ae5221007d3f202746903d4c21c7caf7ea9 ]
When building with W=1, this variable is unused for configs with CONFIG_CMA_SIZE_SEL_PERCENTAGE=y:
kernel/dma/contiguous.c:67:26: error: 'size_bytes' defined but not used [-Werror=unused-const-variable=]
Change this to a macro to avoid the warning.
--- kernel/dma/contiguous.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
kernel/dma/contiguous.c +1 -2
@@ -69,8 +69,7 @@ struct cma *dma_contiguous_default_area;* Users, who want to set the size of global CMA area for their system * should use cma= kernel parameter. */ -static const phys_addr_t size_bytes__initconst = - (phys_addr_t )CMA_SIZE_MBYTES *SZ_1M ; +#define size_bytes ((phys_addr_t)CMA_SIZE_MBYTES * SZ_1M)static phys_addr_t size_cmdline__initdata =-1 ;static phys_addr_t base_cmdline__initdata ;static phys_addr_t limit_cmdline__initdata ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 231/286 cpufreq: scpi: Fix null-ptr-deref in scpi_cpufreq_get_rate()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Henry Martin <[email protected]>
[ Upstream commit 73b24dc731731edf762f9454552cb3a5b7224949 ]
cpufreq_cpu_get_raw() can return NULL when the target CPU is not present in the policy->cpus mask. scpi_cpufreq_get_rate() does not check for this case, which results in a NULL pointer dereference.
--- drivers/cpufreq/scpi-cpufreq.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/cpufreq/scpi-cpufreq.c +10 -3
@@ -37,9 +37,16 @@ static struct scpi_ops *scpi_ops;static unsigned int scpi_cpufreq_get_rate (unsigned int cpu) { -struct cpufreq_policy *policy =cpufreq_cpu_get_raw (cpu); -struct scpi_data *priv = policy->driver_data; -unsigned long rate =clk_get_rate (priv->clk); +struct cpufreq_policy *policy; +struct scpi_data *priv; +unsigned long rate; + + policy =cpufreq_cpu_get_raw (cpu); +if (unlikely (!policy)) +return 0 ; + + priv = policy->driver_data; + rate =clk_get_rate (priv->clk);return rate /1000 ; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 232/286 net: phy: leds: fix memory leak
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qingfang Deng <[email protected]>
[ Upstream commit b7f0ee992adf601aa00c252418266177eb7ac2bc ]
A network restart test on a router led to an out-of-memory condition, which was traced to a memory leak in the PHY LED trigger code.
The root cause is misuse of the devm API. The registration function (phy_led_triggers_register) is called from phy_attach_direct, not phy_probe, and the unregister function (phy_led_triggers_unregister) is called from phy_detach, not phy_remove. This means the register and unregister functions can be called multiple times for the same PHY device, but devm-allocated memory is not freed until the driver is unbound.
This also prevents kmemleak from detecting the leak, as the devm API internally stores the allocated pointer.
Fix this by replacing devm_kzalloc/devm_kcalloc with standard kzalloc/kcalloc, and add the corresponding kfree calls in the unregister path.
--- drivers/net/phy/phy_led_triggers.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-)
drivers/net/phy/phy_led_triggers.c +13 -10
@@ -91,9 +91,8 @@ int phy_led_triggers_register(struct phy_device *phy)if (!phy->phy_num_led_triggers)return 0 ; - phy->led_link_trigger =devm_kzalloc (&phy->mdio.dev, -sizeof (*phy->led_link_trigger), -GFP_KERNEL ); + phy->led_link_trigger =kzalloc (sizeof (*phy->led_link_trigger), +GFP_KERNEL );if (!phy->led_link_trigger) { err = -ENOMEM ; goto out_clear;
@@ -108,10 +107,9 @@ int phy_led_triggers_register(struct phy_device *phy)if (err) goto out_free_link; - phy->phy_led_triggers =devm_kcalloc (&phy->mdio.dev, - phy->phy_num_led_triggers, -sizeof (struct phy_led_trigger ), -GFP_KERNEL ); + phy->phy_led_triggers =kcalloc (phy->phy_num_led_triggers, +sizeof (struct phy_led_trigger ), +GFP_KERNEL );if (!phy->phy_led_triggers) { err = -ENOMEM ; goto out_unreg_link;
@@ -131,11 +129,11 @@ int phy_led_triggers_register(struct phy_device *phy) out_unreg:while (i--)phy_led_trigger_unregister (&phy->phy_led_triggers[i]); -devm_kfree (&phy->mdio.dev, phy->phy_led_triggers); +kfree (phy->phy_led_triggers); out_unreg_link:phy_led_trigger_unregister (phy->led_link_trigger); out_free_link: -devm_kfree (&phy->mdio.dev, phy->led_link_trigger); +kfree (phy->led_link_trigger); phy->led_link_trigger =NULL ; out_clear: phy->phy_num_led_triggers =0 ;
@@ -149,8 +147,13 @@ void phy_led_triggers_unregister(struct phy_device *phy)for (i =0 ; i < phy->phy_num_led_triggers; i++)phy_led_trigger_unregister (&phy->phy_led_triggers[i]); +kfree (phy->phy_led_triggers); + phy->phy_led_triggers =NULL ; -if (phy->led_link_trigger) +if (phy->led_link_trigger) {phy_led_trigger_unregister (phy->led_link_trigger); +kfree (phy->led_link_trigger); + phy->led_link_trigger =NULL ; + } }EXPORT_SYMBOL_GPL (phy_led_triggers_unregister);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 233/286 tipc: fix NULL pointer dereference in tipc_mon_reinit_self()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tung Nguyen <[email protected]>
[ Upstream commit d63527e109e811ef11abb1c2985048fdb528b4cb ]
syzbot reported:
tipc: Node number set to 1055423674
Oops: general protection fault, probably for non-canonical address 0xdffffc0000000000: 0000 [#1] SMP KASAN NOPTI KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007] CPU: 3 UID: 0 PID: 6017 Comm: kworker/3:5 Not tainted 6.15.0-rc1-syzkaller-00246-g900241a5cc15 #0 PREEMPT(full) Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014 Workqueue: events tipc_net_finalize_work RIP: 0010:tipc_mon_reinit_self+0x11c/0x210 net/tipc/monitor.c:719 ... RSP: 0018:ffffc9000356fb68 EFLAGS: 00010246 RAX: 0000000000000000 RBX: 0000000000000000 RCX: 000000003ee87cba RDX: 0000000000000000 RSI: ffffffff8dbc56a7 RDI: ffff88804c2cc010 RBP: dffffc0000000000 R08: 0000000000000001 R09: 0000000000000000 R10: 0000000000000001 R11: 0000000000000000 R12: 0000000000000007 R13: fffffbfff2111097 R14: ffff88804ead8000 R15: ffff88804ead9010 FS: 0000000000000000(0000) GS:ffff888097ab9000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00000000f720eb00 CR3: 000000000e182000 CR4: 0000000000352ef0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: <TASK> tipc_net_finalize+0x10b/0x180 net/tipc/net.c:140 process_one_work+0x9cc/0x1b70 kernel/workqueue.c:3238 process_scheduled_works kernel/workqueue.c:3319 [inline] worker_thread+0x6c8/0xf10 kernel/workqueue.c:3400 kthread+0x3c2/0x780 kernel/kthread.c:464 ret_from_fork+0x45/0x80 arch/x86/kernel/process.c:153 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245 </TASK> ... RIP: 0010:tipc_mon_reinit_self+0x11c/0x210 net/tipc/monitor.c:719 ... RSP: 0018:ffffc9000356fb68 EFLAGS: 00010246 RAX: 0000000000000000 RBX: 0000000000000000 RCX: 000000003ee87cba RDX: 0000000000000000 RSI: ffffffff8dbc56a7 RDI: ffff88804c2cc010 RBP: dffffc0000000000 R08: 0000000000000001 R09: 0000000000000000 R10: 0000000000000001 R11: 0000000000000000 R12: 0000000000000007 R13: fffffbfff2111097 R14: ffff88804ead8000 R15: ffff88804ead9010 FS: 0000000000000000(0000) GS:ffff888097ab9000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00000000f720eb00 CR3: 000000000e182000 CR4: 0000000000352ef0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
There is a racing condition between workqueue created when enabling bearer and another thread created when disabling bearer right after that as follow:
enabling_bearer | disabling_bearer
--------------- | ----------------
tipc_disc_timeout() |
{ | bearer_disable()
... | {
schedule_work(&tn->work); | tipc_mon_delete()
... | {
} | ...
| write_lock_bh(&mon->lock);
| mon->self = NULL;
| write_unlock_bh(&mon->lock);
| ...
| }
tipc_net_finalize_work() | }
{ |
... |
tipc_net_finalize() |
{ |
... |
tipc_mon_reinit_self() |
{ |
... |
write_lock_bh(&mon->lock); |
mon->self->addr = tipc_own_addr(net); |
write_unlock_bh(&mon->lock); |
... |
} |
... |
} |
... |
} |'mon->self' is set to NULL in disabling_bearer thread and dereferenced later in enabling_bearer thread.
This commit fixes this issue by validating 'mon->self' before assigning node address to it.
--- net/tipc/monitor.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/tipc/monitor.c +2 -1
@@ -685,7 +685,8 @@ void tipc_mon_reinit_self(struct net *net)if (!mon)continue ;write_lock_bh (&mon->lock); - mon->self->addr =tipc_own_addr (net); +if (mon->self) + mon->self->addr =tipc_own_addr (net);write_unlock_bh (&mon->lock); } }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 234/286 net_sched: hfsc: Fix a UAF vulnerability in class handling
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cong Wang <[email protected]>
[ Upstream commit 3df275ef0a6ae181e8428a6589ef5d5231e58b5c ]
This patch fixes a Use-After-Free vulnerability in the HFSC qdisc class handling. The issue occurs due to a time-of-check/time-of-use condition in hfsc_change_class() when working with certain child qdiscs like netem or codel.
The vulnerability works as follows:
1. hfsc_change_class() checks if a class has packets (q.qlen != 0)
2. It then calls qdisc_peek_len(), which for certain qdiscs (e.g., codel, netem) might drop packets and empty the queue
3. The code continues assuming the queue is still non-empty, adding the class to vttree
4. This breaks HFSC scheduler assumptions that only non-empty classes are in vttree
5. Later, when the class is destroyed, this can lead to a Use-After-Free
The fix adds a second queue length check after qdisc_peek_len() to verify the queue wasn't emptied.
--- net/sched/sch_hfsc.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
net/sched/sch_hfsc.c +7 -2
@@ -959,6 +959,7 @@ hfsc_change_class(struct Qdisc *sch, u32 classid, u32 parentid,if (cl !=NULL ) {int old_flags; +int len =0 ;if (parentid) { if (cl->cl_parent &&
@@ -989,9 +990,13 @@ hfsc_change_class(struct Qdisc *sch, u32 classid, u32 parentid,if (usc !=NULL )hfsc_change_usc (cl, usc, cur_time); +if (cl->qdisc->q.qlen !=0 ) + len =qdisc_peek_len (cl->qdisc); +/* Check queue length again since some qdisc implementations +* (e.g., netem/codel) might empty the queue during the peek +* operation. +*/ if (cl->qdisc->q.qlen !=0 ) { -int len =qdisc_peek_len (cl->qdisc); -if (cl->cl_flags &HFSC_RSC ) {if (old_flags &HFSC_RSC )update_ed (cl, len);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 235/286 net_sched: hfsc: Fix a potential UAF in hfsc_dequeue() too
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cong Wang <[email protected]>
[ Upstream commit 6ccbda44e2cc3d26fd22af54c650d6d5d801addf ]
Similarly to the previous patch, we need to safe guard hfsc_dequeue() too. But for this one, we don't have a reliable reproducer.
--- net/sched/sch_hfsc.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
net/sched/sch_hfsc.c +10 -4
@@ -1643,10 +1643,16 @@ hfsc_dequeue(struct Qdisc *sch)if (cl->qdisc->q.qlen !=0 ) {/* update ed */ next_len =qdisc_peek_len (cl->qdisc); -if (realtime) -update_ed (cl, next_len); -else -update_d (cl, next_len); +/* Check queue length again since some qdisc implementations +* (e.g., netem/codel) might empty the queue during the peek +* operation. +*/ +if (cl->qdisc->q.qlen !=0 ) { +if (realtime) +update_ed (cl, next_len); +else +update_d (cl, next_len); + } }else {/* the class becomes passive */ eltree_remove (cl);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 236/286 iommu/amd: Return an error if vCPU affinity is set for non-vCPU IRTE
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Christopherson <[email protected]>
[ Upstream commit 07172206a26dcf3f0bf7c3ecaadd4242b008ea54 ]
Return -EINVAL instead of success if amd_ir_set_vcpu_affinity() is invoked without use_vapic; lying to KVM about whether or not the IRTE was configured to post IRQs is all kinds of bad.
Message-ID: <[email protected]>
--- drivers/iommu/amd/iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/amd/iommu.c +1 -1
@@ -3979,7 +3979,7 @@ static int amd_ir_set_vcpu_affinity(struct irq_data *data, void *vcpu_info)* we should not modify the IRTE */ if (!dev_data || !dev_data->use_vapic) -return 0 ; +return -EINVAL ; ir_data->cfg =irqd_cfg (data); pi_data->ir_data = ir_data;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 237/286 virtio_console: fix missing byte order handling for cols and rows
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Halil Pasic <[email protected]>
commit fbd3039a64b01b769040677c4fc68badeca8e3b2 upstream.
As per virtio spec the fields cols and rows are specified as little endian. Although there is no legacy interface requirement that would state that cols and rows need to be handled as native endian when legacy interface is used, unlike for the fields of the adjacent struct virtio_console_control, I decided to err on the side of caution based on some non-conclusive virtio spec repo archaeology and opt for using virtio16_to_cpu() much like for virtio_console_control.event. Strictly by the letter of the spec virtio_le_to_cpu() would have been sufficient. But when the legacy interface is not used, it boils down to the same.
And when using the legacy interface, the device formatting these as little endian when the guest is big endian would surprise me more than it using guest native byte order (which would make it compatible with the current implementation). Nevertheless somebody trying to implement the spec following it to the letter could end up forcing little endian byte order when the legacy interface is in use. So IMHO this ultimately needs a judgement call by the maintainers.
Message-Id: <[email protected]>
--- drivers/char/virtio_console.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/char/virtio_console.c +4 -3
@@ -1617,8 +1617,8 @@ static void handle_control_message(strucbreak ;case VIRTIO_CONSOLE_RESIZE : {struct { -__u16 rows; -__u16 cols; +__virtio16 rows; +__virtio16 cols; } size;if (!is_console_port (port))
@@ -1626,7 +1626,8 @@ static void handle_control_message(strucmemcpy (&size, buf->buf + buf->offset +sizeof (*cpkt),sizeof (size)); -set_console_size (port, size.rows, size.cols); +set_console_size (port,virtio16_to_cpu (vdev, size.rows), +virtio16_to_cpu (vdev, size.cols)); port->cons.hvc->irq_requested =1 ;resize_console (port);
Greg Kroah-Hartman
maintainerPATCH 238/286 KVM: SVM: Allocate IR data using atomic allocation
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Christopherson <[email protected]>
commit 7537deda36521fa8fff9133b39c46e31893606f2 upstream.
Allocate SVM's interrupt remapping metadata using GFP_ATOMIC as svm_ir_list_add() is called with IRQs are disabled and irqfs.lock held when kvm_irq_routing_update() reacts to GSI routing changes.
Message-ID: <[email protected]>
--- arch/x86/kvm/svm/avic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/svm/avic.c +1 -1
@@ -742,7 +742,7 @@ static int svm_ir_list_add(struct vcpu_s* Allocating new amd_iommu_pi_data, which will get * add to the per-vcpu ir_list. */ - ir =kzalloc (sizeof (struct amd_svm_iommu_ir ),GFP_KERNEL_ACCOUNT ); + ir =kzalloc (sizeof (struct amd_svm_iommu_ir ),GFP_ATOMIC | __GFP_ACCOUNT);if (!ir) { ret = -ENOMEM ; goto out;
Greg Kroah-Hartman
maintainerPATCH 239/286 mcb: fix a double free bug in chameleon_parse_gdd()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haoxiang Li <[email protected]>
commit 7c7f1bfdb2249f854a736d9b79778c7e5a29a150 upstream.
In chameleon_parse_gdd(), if mcb_device_register() fails, 'mdev' would be released in mcb_device_register() via put_device(). Thus, goto 'err' label and free 'mdev' again causes a double free. Just return if mcb_device_register() fails.
--- drivers/mcb/mcb-parse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mcb/mcb-parse.c +1 -1
@@ -101,7 +101,7 @@ static int chameleon_parse_gdd(struct mc ret =mcb_device_register (bus, mdev);if (ret <0 ) - goto err; +return ret;return 0 ;
Greg Kroah-Hartman
maintainerPATCH 240/286 USB: storage: quirk for ADATA Portable HDD CH94
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Neukum <[email protected]>
commit 9ab75eee1a056f896b87d139044dd103adc532b9 upstream.
Version 1.60 specifically needs this quirk.
Version 2.00 is known good.
--- drivers/usb/storage/unusual_uas.h | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/usb/storage/unusual_uas.h +7 -0
@@ -83,6 +83,13 @@ UNUSUAL_DEV(0x0bc2, 0x331a, 0x0000, 0x99 USB_SC_DEVICE, USB_PR_DEVICE, NULL, US_FL_NO_REPORT_LUNS), +/* Reported-by: Oliver Neukum <[email protected]> */ +UNUSUAL_DEV (0x125f ,0xa94a ,0x0160 ,0x0160 , +"ADATA" , +"Portable HDD CH94" , +USB_SC_DEVICE ,USB_PR_DEVICE ,NULL , +US_FL_NO_ATA_1X ), +/* Reported-by: Benjamin Tissoires <[email protected]> */ UNUSUAL_DEV(0x13fd, 0x3940, 0x0000, 0x9999, "Initio Corporation",
Greg Kroah-Hartman
maintainerPATCH 241/286 mei: me: add panther lake H DID
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Usyskin <[email protected]>
commit 86ce5c0a1dec02e21b4c864b2bc0cc5880a2c13c upstream.
Add Panther Lake H device id.
--- drivers/misc/mei/hw-me-regs.h | 1 + drivers/misc/mei/pci-me.c | 1 + 2 files changed, 2 insertions(+)
drivers/misc/mei/hw-me-regs.h +1 -0
@@ -117,6 +117,7 @@#define MEI_DEV_ID_LNL_M 0xA870/* Lunar Lake Point M */ +#define MEI_DEV_ID_PTL_H 0xE370/* Panther Lake H */ #define MEI_DEV_ID_PTL_P 0xE470/* Panther Lake P */ /*
drivers/misc/mei/pci-me.c +1 -0
@@ -123,6 +123,7 @@ static const struct pci_device_id mei_me {MEI_PCI_DEVICE(MEI_DEV_ID_LNL_M, MEI_ME_PCH15_CFG)}, + {MEI_PCI_DEVICE(MEI_DEV_ID_PTL_H, MEI_ME_PCH15_CFG)}, {MEI_PCI_DEVICE(MEI_DEV_ID_PTL_P, MEI_ME_PCH15_CFG)},/* required last entry */
Greg Kroah-Hartman
maintainerPATCH 242/286 KVM: x86: Reset IRTE to host control if *new* route isnt postable
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Christopherson <[email protected]>
commit 9bcac97dc42d2f4da8229d18feb0fe2b1ce523a2 upstream.
Restore an IRTE back to host control (remapped or posted MSI mode) if the *new* GSI route prevents posting the IRQ directly to a vCPU, regardless of the GSI routing type. Updating the IRTE if and only if the new GSI is an MSI results in KVM leaving an IRTE posting to a vCPU.
The dangling IRTE can result in interrupts being incorrectly delivered to the guest, and in the worst case scenario can result in use-after-free, e.g. if the VM is torn down, but the underlying host IRQ isn't freed.
Message-ID: <[email protected]>
--- arch/x86/kvm/svm/avic.c | 58 +++++++++++++++++++++-------------------- arch/x86/kvm/vmx/posted_intr.c | 28 +++++++------------ 2 files changed, 41 insertions(+), 45 deletions(-)
arch/x86/kvm/svm/avic.c +31 -27
@@ -806,6 +806,7 @@ int svm_update_pi_irte(struct kvm *kvm, {struct kvm_kernel_irq_routing_entry *e;struct kvm_irq_routing_table *irq_rt; +bool enable_remapped_mode = true;int idx, ret =0 ; if (!kvm_arch_has_assigned_device(kvm) ||
@@ -843,6 +844,8 @@ int svm_update_pi_irte(struct kvm *kvm, kvm_vcpu_apicv_active(&svm->vcpu)) {struct amd_iommu_pi_data pi; + enable_remapped_mode = false; +/* Try to enable guest_mode in IRTE */ pi.base =__sme_set (page_to_phys (svm->avic_backing_page) &AVIC_HPA_MASK );
@@ -861,33 +864,6 @@ int svm_update_pi_irte(struct kvm *kvm,*/ if (!ret && pi.is_guest_mode)svm_ir_list_add (svm, &pi); - }else { -/* Use legacy mode in IRTE */ -struct amd_iommu_pi_data pi; - -/** -* Here, pi is used to: -* - Tell IOMMU to use legacy mode for this interrupt. -* - Retrieve ga_tag of prior interrupt remapping data. -*/ - pi.prev_ga_tag =0 ; - pi.is_guest_mode = false; - ret =irq_set_vcpu_affinity (host_irq, &pi); - -/** -* Check if the posted interrupt was previously -* setup with the guest_mode by checking if the ga_tag -* was cached. If so, we need to clean up the per-vcpu -* ir_list. -*/ -if (!ret && pi.prev_ga_tag) { -int id =AVIC_GATAG_TO_VCPUID (pi.prev_ga_tag); -struct kvm_vcpu *vcpu; - - vcpu =kvm_get_vcpu_by_id (kvm, id); -if (vcpu) -svm_ir_list_del (to_svm (vcpu), &pi); - } }if (!ret && svm) {
@@ -903,6 +879,34 @@ int svm_update_pi_irte(struct kvm *kvm, } ret =0 ; +if (enable_remapped_mode) { +/* Use legacy mode in IRTE */ +struct amd_iommu_pi_data pi; + +/** +* Here, pi is used to: +* - Tell IOMMU to use legacy mode for this interrupt. +* - Retrieve ga_tag of prior interrupt remapping data. +*/ + pi.prev_ga_tag =0 ; + pi.is_guest_mode = false; + ret =irq_set_vcpu_affinity (host_irq, &pi); + +/** +* Check if the posted interrupt was previously +* setup with the guest_mode by checking if the ga_tag +* was cached. If so, we need to clean up the per-vcpu +* ir_list. +*/ +if (!ret && pi.prev_ga_tag) { +int id =AVIC_GATAG_TO_VCPUID (pi.prev_ga_tag); +struct kvm_vcpu *vcpu; + + vcpu =kvm_get_vcpu_by_id (kvm, id); +if (vcpu) +svm_ir_list_del (to_svm (vcpu), &pi); + } + } out:srcu_read_unlock (&kvm->irq_srcu, idx);return ret;
arch/x86/kvm/vmx/posted_intr.c +10 -18
@@ -255,6 +255,7 @@ int pi_update_irte(struct kvm *kvm, unsi {struct kvm_kernel_irq_routing_entry *e;struct kvm_irq_routing_table *irq_rt; +bool enable_remapped_mode = true;struct kvm_lapic_irq irq;struct kvm_vcpu *vcpu;struct vcpu_data vcpu_info;
@@ -293,21 +294,8 @@ int pi_update_irte(struct kvm *kvm, unsikvm_set_msi_irq (kvm, e, &irq);if (!kvm_intr_is_single_vcpu (kvm, &irq, &vcpu) || - !kvm_irq_is_postable (&irq)) { -/* -* Make sure the IRTE is in remapped mode if -* we don't handle it in posted mode. -*/ - ret =irq_set_vcpu_affinity (host_irq,NULL ); -if (ret <0 ) { -printk (KERN_INFO -"failed to back to remapped mode, irq: %u\n" , - host_irq); - goto out; - } - + !kvm_irq_is_postable (&irq))continue ; - } vcpu_info.pi_desc_addr =__pa (&to_vmx (vcpu)->pi_desc); vcpu_info.vector = irq.vector;
@@ -315,11 +303,12 @@ int pi_update_irte(struct kvm *kvm, unsitrace_kvm_pi_irte_update (host_irq, vcpu->vcpu_id, e->gsi, vcpu_info.vector, vcpu_info.pi_desc_addr, set); -if (set) - ret =irq_set_vcpu_affinity (host_irq, &vcpu_info); -else - ret =irq_set_vcpu_affinity (host_irq,NULL ); +if (!set) +continue ; + enable_remapped_mode = false; + + ret =irq_set_vcpu_affinity (host_irq, &vcpu_info);if (ret <0 ) {printk (KERN_INFO "%s: failed to update PI IRTE\n" , __func__);
@@ -327,6 +316,9 @@ int pi_update_irte(struct kvm *kvm, unsi } } +if (enable_remapped_mode) + ret =irq_set_vcpu_affinity (host_irq,NULL ); + ret =0 ; out:srcu_read_unlock (&kvm->irq_srcu, idx);
Greg Kroah-Hartman
maintainerPATCH 243/286 serial: sifive: lock port in startup()/shutdown() callbacks
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ryo Takakura <[email protected]>
commit e1ca3ff28ab1e2c1e70713ef3fa7943c725742c3 upstream.
startup()/shutdown() callbacks access SIFIVE_SERIAL_IE_OFFS. The register is also accessed from write() callback.
If console were printing and startup()/shutdown() callback gets called, its access to the register could be overwritten.
Add port->lock to startup()/shutdown() callbacks to make sure their access to SIFIVE_SERIAL_IE_OFFS is synchronized against write() callback.
Rule: add
--- drivers/tty/serial/sifive.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/tty/serial/sifive.c +6 -0
@@ -596,8 +596,11 @@ static void sifive_serial_break_ctl(strustatic int sifive_serial_startup (struct uart_port *port) {struct sifive_serial_port *ssp =port_to_sifive_serial_port (port); +unsigned long flags; +uart_port_lock_irqsave (&ssp->port, &flags);__ssp_enable_rxwm (ssp); +uart_port_unlock_irqrestore (&ssp->port, flags);return 0 ; }
@@ -605,9 +608,12 @@ static int sifive_serial_startup(structstatic void sifive_serial_shutdown (struct uart_port *port) {struct sifive_serial_port *ssp =port_to_sifive_serial_port (port); +unsigned long flags; +uart_port_lock_irqsave (&ssp->port, &flags);__ssp_disable_rxwm (ssp);__ssp_disable_txwm (ssp); +uart_port_unlock_irqrestore (&ssp->port, flags); }/**
Greg Kroah-Hartman
maintainerPATCH 244/286 USB: serial: ftdi_sio: add support for Abacus Electrics Optical Probe
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Ehrenreich <[email protected]>
commit b399078f882b6e5d32da18b6c696cc84b12f90d5 upstream.
Abacus Electrics makes optical probes for interacting with smart meters over an optical interface.
At least one version uses an FT232B chip (as detected by ftdi_sio) with a custom USB PID, which needs to be added to the list to make the device work in a plug-and-play fashion.
--- drivers/usb/serial/ftdi_sio.c | 2 ++ drivers/usb/serial/ftdi_sio_ids.h | 5 +++++ 2 files changed, 7 insertions(+)
drivers/usb/serial/ftdi_sio.c +2 -0
@@ -1071,6 +1071,8 @@ static const struct usb_device_id id_tab { USB_DEVICE_INTERFACE_NUMBER(ALTERA_VID, ALTERA_UB3_602E_PID, 1) }, { USB_DEVICE_INTERFACE_NUMBER(ALTERA_VID, ALTERA_UB3_602E_PID, 2) }, { USB_DEVICE_INTERFACE_NUMBER(ALTERA_VID, ALTERA_UB3_602E_PID, 3) }, +/* Abacus Electrics */ + { USB_DEVICE(FTDI_VID, ABACUS_OPTICAL_PROBE_PID) }, { } /* Terminating entry */ };
drivers/usb/serial/ftdi_sio_ids.h +5 -0
@@ -436,6 +436,11 @@#define LINX_FUTURE_2_PID 0xF44C/* Linx future device */ /* +* Abacus Electrics +*/ +#define ABACUS_OPTICAL_PROBE_PID 0xf458/* ABACUS ELECTRICS Optical Probe */ + +/* * Oceanic product ids */ #define FTDI_OCEANIC_PID 0xF460/* Oceanic dive instrument */
Greg Kroah-Hartman
maintainerPATCH 245/286 USB: serial: option: add Sierra Wireless EM9291
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adam Xue <[email protected]>
commit 968e1cbb1f6293c3add9607f80b5ce3d29f57583 upstream.
Add Sierra Wireless EM9291.
Interface 0: MBIM control
1: MBIM data
3: AT port
4: Diagnostic port
T: Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 2 Spd=480 MxCh= 0 D: Ver= 2.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1 P: Vendor=1199 ProdID=90e3 Rev=00.06 S: Manufacturer=Sierra Wireless, Incorporated S: Product=Sierra Wireless EM9291 S: SerialNumber=xxxxxxxxxxxxxxxx C: #Ifs= 4 Cfg#= 1 Atr=a0 MxPwr=500mA I: If#= 0 Alt= 0 #EPs= 1 Cls=02(commc) Sub=0e Prot=00 Driver=cdc_mbim E: Ad=81(I) Atr=03(Int.) MxPS= 64 Ivl=32ms I: If#= 1 Alt= 1 #EPs= 2 Cls=0a(data ) Sub=00 Prot=02 Driver=cdc_mbim E: Ad=0f(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=8e(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms I: If#= 3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=40 Driver=(none) E: Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=83(I) Atr=03(Int.) MxPS= 10 Ivl=32ms I: If#= 4 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=30 Driver=(none) E: Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=84(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
--- drivers/usb/serial/option.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/usb/serial/option.c +3 -0
@@ -611,6 +611,7 @@ static void option_instat_callback(struc/* Sierra Wireless products */ #define SIERRA_VENDOR_ID 0x1199#define SIERRA_PRODUCT_EM9191 0x90d3 +#define SIERRA_PRODUCT_EM9291 0x90e3/* UNISOC (Spreadtrum) products */ #define UNISOC_VENDOR_ID 0x1782
@@ -2432,6 +2433,8 @@ static const struct usb_device_id option { USB_DEVICE_AND_INTERFACE_INFO(SIERRA_VENDOR_ID, SIERRA_PRODUCT_EM9191, 0xff, 0xff, 0x30) }, { USB_DEVICE_AND_INTERFACE_INFO(SIERRA_VENDOR_ID, SIERRA_PRODUCT_EM9191, 0xff, 0xff, 0x40) }, { USB_DEVICE_AND_INTERFACE_INFO(SIERRA_VENDOR_ID, SIERRA_PRODUCT_EM9191, 0xff, 0, 0) }, + { USB_DEVICE_AND_INTERFACE_INFO(SIERRA_VENDOR_ID, SIERRA_PRODUCT_EM9291, 0xff, 0xff, 0x30) }, + { USB_DEVICE_AND_INTERFACE_INFO(SIERRA_VENDOR_ID, SIERRA_PRODUCT_EM9291, 0xff, 0xff, 0x40) }, { USB_DEVICE_AND_INTERFACE_INFO(UNISOC_VENDOR_ID, TOZED_PRODUCT_LT70C, 0xff, 0, 0) }, { USB_DEVICE_AND_INTERFACE_INFO(UNISOC_VENDOR_ID, LUAT_PRODUCT_AIR720U, 0xff, 0, 0) }, { USB_DEVICE_INTERFACE_CLASS(0x1bbb, 0x0530, 0xff), /* TCL IK512 MBIM */
Greg Kroah-Hartman
maintainerPATCH 246/286 USB: serial: simple: add OWON HDS200 series oscilloscope support
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Craig Hesling <[email protected]>
commit 4cc01410e1c1dd075df10f750775c81d1cb6672b upstream.
Add serial support for OWON HDS200 series oscilloscopes and likely many other pieces of OWON test equipment.
OWON HDS200 series devices host two USB endpoints, designed to facilitate bidirectional SCPI. SCPI is a predominately ASCII text protocol for test/measurement equipment. Having a serial/tty interface for these devices lowers the barrier to entry for anyone trying to write programs to communicate with them.
The following shows the USB descriptor for the OWON HDS272S running firmware V5.7.1:
Bus 001 Device 068: ID 5345:1234 Owon PDS6062T Oscilloscope Negotiated speed: Full Speed (12Mbps)
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 0 [unknown] bDeviceSubClass 0 [unknown] bDeviceProtocol 0 bMaxPacketSize0 64 idVendor 0x5345 Owon idProduct 0x1234 PDS6062T Oscilloscope bcdDevice 1.00 iManufacturer 1 oscilloscope iProduct 2 oscilloscope iSerial 3 oscilloscope bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 0x0029
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 0
bmAttributes 0x80
(Bus Powered)
MaxPower 100mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 5 Physical Interface Device
bInterfaceSubClass 0 [unknown]
bInterfaceProtocol 0
iInterface 0
** UNRECOGNIZED: 09 21 11 01 00 01 22 5f 00 Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 32
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x01 EP 1 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 32
Device Status: 0x0000
(Bus Powered)
OWON appears to be using the same USB Vendor and Product ID for many of their oscilloscopes. Looking at the discussion about the USB vendor/product ID, in the link bellow, suggests that this VID/PID is shared with VDS, SDS, PDS, and now the HDS series oscilloscopes. Available documentation for these devices seems to indicate that all use a similar SCPI protocol, some with RS232 options. It is likely that this same simple serial setup would work correctly for them all.
--- drivers/usb/serial/usb-serial-simple.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/usb/serial/usb-serial-simple.c +7 -0
@@ -101,6 +101,11 @@ DEVICE(nokia, NOKIA_IDS); { USB_DEVICE(0x09d7, 0x0100) } /* NovAtel FlexPack GPS */DEVICE_N (novatel_gps,NOVATEL_IDS ,3 ); +/* OWON electronic test and measurement equipment driver */ +#define OWON_IDS () \ + { USB_DEVICE(0x5345, 0x1234) }/* HDS200 oscilloscopes and others */ +DEVICE (owon,OWON_IDS ); +/* Siemens USB/MPI adapter */ #define SIEMENS_IDS () \ { USB_DEVICE(0x908, 0x0004) }
@@ -135,6 +140,7 @@ static struct usb_serial_driver * const &motorola_tetra_device, &nokia_device, &novatel_gps_device, + &owon_device, &siemens_mpi_device, &suunto_device, &vivopay_device,
@@ -154,6 +160,7 @@ static const struct usb_device_id id_tabMOTOROLA_TETRA_IDS (),NOKIA_IDS (),NOVATEL_IDS (), +OWON_IDS (),SIEMENS_IDS (),SUUNTO_IDS (), VIVOPAY_IDS(),
Greg Kroah-Hartman
maintainerPATCH 247/286 usb: cdns3: Fix deadlock when using NCM gadget
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ralph Siemsen <[email protected]>
commit a1059896f2bfdcebcdc7153c3be2307ea319501f upstream.
The cdns3 driver has the same NCM deadlock as fixed in cdnsp by commit 58f2fcb3a845 ("usb: cdnsp: Fix deadlock issue during using NCM gadget").
Under PREEMPT_RT the deadlock can be readily triggered by heavy network traffic, for example using "iperf --bidir" over NCM ethernet link.
The deadlock occurs because the threaded interrupt handler gets preempted by a softirq, but both are protected by the same spinlock. Prevent deadlock by disabling softirq during threaded irq handler.
--- drivers/usb/cdns3/gadget.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/cdns3/gadget.c +2 -0
@@ -1961,6 +1961,7 @@ static irqreturn_t cdns3_device_thread_iunsigned int bit;unsigned long reg; +local_bh_disable ();spin_lock_irqsave (&priv_dev->lock, flags); reg =readl (&priv_dev->regs->usb_ists);
@@ -2002,6 +2003,7 @@ static irqreturn_t cdns3_device_thread_i irqend:writel (~0 , &priv_dev->regs->ep_ien);spin_unlock_irqrestore (&priv_dev->lock, flags); +local_bh_enable ();return ret; }
Greg Kroah-Hartman
maintainerPATCH 248/286 USB: OHCI: Add quirk for LS7A OHCI controller (rev 0x02)
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Huacai Chen <[email protected]>
commit bcb60d438547355b8f9ad48645909139b64d3482 upstream.
The OHCI controller (rev 0x02) under LS7A PCI host has a hardware flaw. MMIO register with offset 0x60/0x64 is treated as legacy PS2-compatible keyboard/mouse interface, which confuse the OHCI controller. Since OHCI only use a 4KB BAR resource indeed, the LS7A OHCI controller's 32KB BAR is wrapped around (the second 4KB BAR space is the same as the first 4KB internally). So we can add an 4KB offset (0x1000) to the OHCI registers (from the PCI BAR resource) as a quirk.
--- drivers/usb/host/ohci-pci.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
drivers/usb/host/ohci-pci.c +23 -0
@@ -165,6 +165,25 @@ static int ohci_quirk_amd700(struct usb_return 0 ; } +static int ohci_quirk_loongson (struct usb_hcd *hcd) +{ +struct pci_dev *pdev =to_pci_dev (hcd->self.controller); + +/* +* Loongson's LS7A OHCI controller (rev 0x02) has a +* flaw. MMIO register with offset 0x60/64 is treated +* as legacy PS2-compatible keyboard/mouse interface. +* Since OHCI only use 4KB BAR resource, LS7A OHCI's +* 32KB BAR is wrapped around (the 2nd 4KB BAR space +* is the same as the 1st 4KB internally). So add 4KB +* offset (0x1000) to the OHCI registers as a quirk. +*/ +if (pdev->revision ==0x2 ) + hcd->regs +=SZ_4K ;/* SZ_4K = 0x1000 */ + +return 0 ; +} +static int ohci_quirk_qemu (struct usb_hcd *hcd) {struct ohci_hcd *ohci =hcd_to_ohci (hcd);
@@ -225,6 +244,10 @@ static const struct pci_device_id ohci_p .driver_data = (unsigned long)ohci_quirk_amd700, }, { + PCI_DEVICE(PCI_VENDOR_ID_LOONGSON, 0x7a24), + .driver_data = (unsigned long)ohci_quirk_loongson, + }, + { .vendor = PCI_VENDOR_ID_APPLE, .device = 0x003f, .subvendor = PCI_SUBVENDOR_ID_REDHAT_QUMRANET,
Greg Kroah-Hartman
maintainerPATCH 249/286 usb: dwc3: gadget: check that event count does not exceed event buffer length
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Frode Isaksen <[email protected]>
commit 63ccd26cd1f6600421795f6ca3e625076be06c9f upstream.
The event count is read from register DWC3_GEVNTCOUNT. There is a check for the count being zero, but not for exceeding the event buffer length.
Check that event count does not exceed event buffer length, avoiding an out-of-bounds access when memcpy'ing the event. Crash log:
Unable to handle kernel paging request at virtual address ffffffc0129be000 pc : __memcpy+0x114/0x180 lr : dwc3_check_event_buf+0xec/0x348 x3 : 0000000000000030 x2 : 000000000000dfc4 x1 : ffffffc0129be000 x0 : ffffff87aad60080 Call trace: __memcpy+0x114/0x180 dwc3_interrupt+0x24/0x34
--- drivers/usb/dwc3/gadget.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/usb/dwc3/gadget.c +6 -0
@@ -3896,6 +3896,12 @@ static irqreturn_t dwc3_check_event_buf(if (!count)return IRQ_NONE ; +if (count > evt->length) { +dev_err_ratelimited (dwc->dev,"invalid count(%u) > evt->length(%u)\n" , + count, evt->length); +return IRQ_NONE ; + } + evt->count = count; evt->flags |=DWC3_EVENT_PENDING ;
Greg Kroah-Hartman
maintainerPATCH 250/286 usb: quirks: add DELAY_INIT quirk for Silicon Motion Flash Drive
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miao Li <[email protected]>
commit 2932b6b547ec36ad2ed60fbf2117c0e46bb7d40a upstream.
Silicon Motion Flash Drive connects to Huawei hisi platforms and performs a system reboot test for two thousand circles, it will randomly work incorrectly on boot, set DELAY_INIT quirk can workaround this issue.
--- drivers/usb/core/quirks.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/usb/core/quirks.c +3 -0
@@ -380,6 +380,9 @@ static const struct usb_device_id usb_qu { USB_DEVICE(0x0904, 0x6103), .driver_info = USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL }, + /* Silicon Motion Flash Drive */ + { USB_DEVICE(0x090c, 0x1000), .driver_info = USB_QUIRK_DELAY_INIT }, + /* Sound Devices USBPre2 */ { USB_DEVICE(0x0926, 0x0202), .driver_info = USB_QUIRK_ENDPOINT_IGNORE },
Greg Kroah-Hartman
maintainerPATCH 251/286 usb: quirks: Add delay init quirk for SanDisk 3.2Gen1 Flash Drive
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miao Li <[email protected]>
commit 37ffdbd695c02189dbf23d6e7d2385e0299587ca upstream.
The SanDisk 3.2Gen1 Flash Drive, which VID:PID is in 0781:55a3, just like Silicon Motion Flash Drive:
https://lore.kernel.org/r/[email protected]
also needs the DELAY_INIT quirk, or it will randomly work incorrectly (e.g.: lsusb and can't list this device info) when connecting Huawei hisi platforms and doing thousand of reboot test circles.
--- drivers/usb/core/quirks.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/usb/core/quirks.c +3 -0
@@ -366,6 +366,9 @@ static const struct usb_device_id usb_qu { USB_DEVICE(0x0781, 0x5583), .driver_info = USB_QUIRK_NO_LPM }, { USB_DEVICE(0x0781, 0x5591), .driver_info = USB_QUIRK_NO_LPM }, + /* SanDisk Corp. SanDisk 3.2Gen1 */ + { USB_DEVICE(0x0781, 0x55a3), .driver_info = USB_QUIRK_DELAY_INIT }, + /* Realforce 87U Keyboard */ { USB_DEVICE(0x0853, 0x011b), .driver_info = USB_QUIRK_NO_LPM },
Greg Kroah-Hartman
maintainerPATCH 252/286 USB: VLI disk crashes if LPM is used
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Neukum <[email protected]>
commit e00b39a4f3552c730f1e24c8d62c4a8c6aad4e5d upstream.
This device needs the NO_LPM quirk.
--- drivers/usb/core/quirks.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/usb/core/quirks.c +3 -0
@@ -540,6 +540,9 @@ static const struct usb_device_id usb_qu { USB_DEVICE(0x2040, 0x7200), .driver_info = USB_QUIRK_CONFIG_INTF_STRINGS }, + /* VLI disk */ + { USB_DEVICE(0x2109, 0x0711), .driver_info = USB_QUIRK_NO_LPM }, + /* Raydium Touchscreen */ { USB_DEVICE(0x2386, 0x3114), .driver_info = USB_QUIRK_NO_LPM },
Greg Kroah-Hartman
maintainerPATCH 253/286 MIPS: cm: Detect CM quirks from device tree
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gregory CLEMENT <[email protected]>
[ Upstream commit e27fbe16af5cfc40639de4ced67d1a866a1953e9 ]
Some information that should be retrieved at runtime for the Coherence Manager can be either absent or wrong. This patch allows checking if some of this information is available from the device tree and updates the internal variable accordingly.
For now, only the compatible string associated with the broken HCI is being retrieved.
--- arch/mips/include/asm/mips-cm.h | 22 ++++++++++++++++++++++ arch/mips/kernel/mips-cm.c | 14 ++++++++++++++ 2 files changed, 36 insertions(+)
arch/mips/include/asm/mips-cm.h +22 -0
@@ -47,6 +47,16 @@ extern phys_addr_t __mips_cm_phys_base(void);*/ extern int mips_cm_is64; +/* +* mips_cm_is_l2_hci_broken - determine if HCI is broken +* +* Some CM reports show that Hardware Cache Initialization is +* complete, but in reality it's not the case. They also incorrectly +* indicate that Hardware Cache Initialization is supported. This +* flags allows warning about this broken feature. +*/ +extern bool mips_cm_is_l2_hci_broken; +/** * mips_cm_error_report - Report CM cache errors */
@@ -85,6 +95,18 @@ static inline bool mips_cm_present(void)#endif } +/** +* mips_cm_update_property - update property from the device tree +* +* Retrieve the properties from the device tree if a CM node exist and +* update the internal variable based on this. +*/ +#ifdef CONFIG_MIPS_CM +extern void mips_cm_update_property (void ); +#else +static void mips_cm_update_property (void ) {} +#endif +/** * mips_cm_has_l2sync - determine whether an L2-only sync region is present *
arch/mips/kernel/mips-cm.c +14 -0
@@ -5,6 +5,7 @@*/ #include <linux/errno.h> +#include <linux/of.h> #include <linux/percpu.h> #include <linux/spinlock.h>
@@ -14,6 +15,7 @@void __iomem *mips_gcr_base;void __iomem *mips_cm_l2sync_base;int mips_cm_is64; +bool mips_cm_is_l2_hci_broken;static char *cm2_tr[8 ] = {"mem" ,"gcr" ,"gic" ,"mmio" ,
@@ -238,6 +240,18 @@ static void mips_cm_probe_l2sync(void) mips_cm_l2sync_base =ioremap (addr,MIPS_CM_L2SYNC_SIZE ); } +void mips_cm_update_property (void ) +{ +struct device_node *cm_node; + + cm_node =of_find_compatible_node (of_root,NULL ,"mobileye,eyeq6-cm" ); +if (!cm_node) +return ; +pr_info ("HCI (Hardware Cache Init for the L2 cache) in GCR_L2_RAM_CONFIG from the CM3 is broken" ); + mips_cm_is_l2_hci_broken = true; +of_node_put (cm_node); +} +int mips_cm_probe (void ) {phys_addr_t addr;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 254/286 crypto: null - Use spin lock instead of mutex
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Herbert Xu <[email protected]>
[ Upstream commit dcc47a028c24e793ce6d6efebfef1a1e92f80297 ]
As the null algorithm may be freed in softirq context through af_alg, use spin locks instead of mutexes to protect the default null algorithm.
--- crypto/crypto_null.c | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-)
crypto/crypto_null.c +26 -13
@@ -17,10 +17,10 @@#include <crypto/internal/skcipher.h> #include <linux/init.h> #include <linux/module.h> -#include <linux/mm.h> +#include <linux/spinlock.h> #include <linux/string.h> -static DEFINE_MUTEX (crypto_default_null_skcipher_lock); +static DEFINE_SPINLOCK (crypto_default_null_skcipher_lock);static struct crypto_sync_skcipher *crypto_default_null_skcipher;static int crypto_default_null_skcipher_refcnt;
@@ -152,23 +152,32 @@ MODULE_ALIAS_CRYPTO("cipher_null");struct crypto_sync_skcipher *crypto_get_default_null_skcipher (void ) { +struct crypto_sync_skcipher *ntfm =NULL ;struct crypto_sync_skcipher *tfm; -mutex_lock (&crypto_default_null_skcipher_lock); +spin_lock_bh (&crypto_default_null_skcipher_lock); tfm = crypto_default_null_skcipher;if (!tfm) { - tfm =crypto_alloc_sync_skcipher ("ecb(cipher_null)" ,0 ,0 ); -if (IS_ERR (tfm)) - goto unlock; - - crypto_default_null_skcipher = tfm; +spin_unlock_bh (&crypto_default_null_skcipher_lock); + + ntfm =crypto_alloc_sync_skcipher ("ecb(cipher_null)" ,0 ,0 ); +if (IS_ERR (ntfm)) +return ntfm; + +spin_lock_bh (&crypto_default_null_skcipher_lock); + tfm = crypto_default_null_skcipher; +if (!tfm) { + tfm = ntfm; + ntfm =NULL ; + crypto_default_null_skcipher = tfm; + } } crypto_default_null_skcipher_refcnt++; +spin_unlock_bh (&crypto_default_null_skcipher_lock); -unlock: -mutex_unlock (&crypto_default_null_skcipher_lock); +crypto_free_sync_skcipher (ntfm);return tfm; }
@@ -176,12 +185,16 @@ EXPORT_SYMBOL_GPL(crypto_get_default_null_skcipher);void crypto_put_default_null_skcipher (void ) { -mutex_lock (&crypto_default_null_skcipher_lock); +struct crypto_sync_skcipher *tfm =NULL ; + +spin_lock_bh (&crypto_default_null_skcipher_lock);if (!--crypto_default_null_skcipher_refcnt) { -crypto_free_sync_skcipher (crypto_default_null_skcipher); + tfm = crypto_default_null_skcipher; crypto_default_null_skcipher =NULL ; } -mutex_unlock (&crypto_default_null_skcipher_lock); +spin_unlock_bh (&crypto_default_null_skcipher_lock); + +crypto_free_sync_skcipher (tfm); }EXPORT_SYMBOL_GPL (crypto_put_default_null_skcipher);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 255/286 clk: check for disabled clock-provider in of_clk_get_hw_from_clkspec()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiko Stuebner <[email protected]>
[ Upstream commit b20150d499b3ee5c2d632fbc5ac94f98dd33accf ]
of_clk_get_hw_from_clkspec() checks all available clock-providers by comparing their of nodes to the one from the clkspec. If no matching clock provider is found, the function returns -EPROBE_DEFER to cause a re-check at a later date. If a matching clock provider is found, an authoritative answer can be retrieved from it whether the clock exists or not.
This does not take into account that the clock-provider may never appear, because it's node is disabled. This can happen when a clock is optional, provided by a separate block which never gets enabled.
One example of this happening is the rk3588's VOP, which has optional additional display clocks coming from PLLs inside the hdmiphy blocks. These can be used for better rates, but the system will also work without them.
The problem around that is described in the followups to[1]. As we already know the of node of the presumed clock provider, add a check via of_device_is_available() whether this is a "valid" device node. This prevents eternal defer loops.
--- drivers/clk/clk.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/clk/clk.c +4 -0
@@ -4858,6 +4858,10 @@ of_clk_get_hw_from_clkspec(struct of_phandle_args *clkspec)if (!clkspec)return ERR_PTR (-EINVAL ); +/* Check if node in clkspec is in disabled/fail state */ +if (!of_device_is_available (clkspec->np)) +return ERR_PTR (-ENOENT ); +mutex_lock (&of_clk_mutex);list_for_each_entry (provider, &of_clk_providers, link) {if (provider->node == clkspec->np) {
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 256/286 parisc: PDT: Fix missing prototype warning
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yu-Chun Lin <[email protected]>
[ Upstream commit b899981750dcb958ceffa4462d903963ee494aa2 ]
As reported by the kernel test robot, the following error occurs:
arch/parisc/kernel/pdt.c:65:6: warning: no previous prototype for 'arch_report_meminfo' [-Wmissing-prototypes]
65 | void arch_report_meminfo(struct seq_file *m)
| ^~~~~~~~~~~~~~~~~~~
arch_report_meminfo() is declared in include/linux/proc_fs.h and only defined when CONFIG_PROC_FS is enabled. Wrap its definition in #ifdef CONFIG_PROC_FS to fix the -Wmissing-prototypes warning.
--- arch/parisc/kernel/pdt.c | 2 ++ 1 file changed, 2 insertions(+)
arch/parisc/kernel/pdt.c +2 -0
@@ -62,6 +62,7 @@ static unsigned long pdt_entry[MAX_PDT_ENTRIES] __page_aligned_bss;#define PDT_ADDR_PERM_ERR (pdt_type != PDT_PDC ? 2UL : 0UL)#define PDT_ADDR_SINGLE_ERR 1UL +#ifdef CONFIG_PROC_FS /* report PDT entries via /proc/meminfo */ void arch_report_meminfo (struct seq_file *m) {
@@ -73,6 +74,7 @@ void arch_report_meminfo(struct seq_file *m)seq_printf (m,"PDT_cur_entries: %7lu\n" , pdt_status.pdt_entries); } +#endif static int get_info_pat_new (void ) {
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 257/286 usb: host: max3421-hcd: Add missing spi_device_id table
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Stein <[email protected]>
[ Upstream commit 41d5e3806cf589f658f92c75195095df0b66f66a ]
"maxim,max3421" DT compatible is missing its SPI device ID entry, not allowing module autoloading and leading to the following message:
"SPI driver max3421-hcd has no spi_device_id for maxim,max3421"
Fix this by adding the spi_device_id table.
--- drivers/usb/host/max3421-hcd.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/usb/host/max3421-hcd.c +7 -0
@@ -1956,6 +1956,12 @@ max3421_remove(struct spi_device *spi)return 0 ; } +static const struct spi_device_id max3421_spi_ids[] = { + {"max3421" }, + { }, +}; +MODULE_DEVICE_TABLE (spi, max3421_spi_ids); +static const struct of_device_id max3421_of_match_table[] = { { .compatible ="maxim,max3421" , }, {},
@@ -1965,6 +1971,7 @@ MODULE_DEVICE_TABLE(of, max3421_of_match_table);static struct spi_driver max3421_driver = { .probe = max3421_probe, .remove = max3421_remove, + .id_table = max3421_spi_ids, .driver = { .name ="max3421-hcd" , .of_match_table =of_match_ptr (max3421_of_match_table),
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 258/286 dmaengine: dmatest: Fix dmatest waiting less when interrupted
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vinicius Costa Gomes <[email protected]>
[ Upstream commit e87ca16e99118ab4e130a41bdf12abbf6a87656c ]
Change the "wait for operation finish" logic to take interrupts into account.
When using dmatest with idxd DMA engine, it's possible that during longer tests, the interrupt notifying the finish of an operation happens during wait_event_freezable_timeout(), which causes dmatest to cleanup all the resources, some of which might still be in use.
This fix ensures that the wait logic correctly handles interrupts, preventing premature cleanup of resources.
--- drivers/dma/dmatest.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/dma/dmatest.c +3 -3
@@ -825,9 +825,9 @@ static int dmatest_func(void *data) }else {dma_async_issue_pending (chan); -wait_event_freezable_timeout (thread->done_wait, - done->done, -msecs_to_jiffies (params->timeout)); +wait_event_timeout (thread->done_wait, + done->done, +msecs_to_jiffies (params->timeout)); status =dma_async_is_tx_complete (chan, cookie,NULL ,NULL );
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 259/286 usb: gadget: aspeed: Add NULL pointer check in ast_vhub_init_dev()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chenyuan Yang <[email protected]>
[ Upstream commit 8c75f3e6a433d92084ad4e78b029ae680865420f ]
The variable d->name, returned by devm_kasprintf(), could be NULL. A pointer check is added to prevent potential NULL pointer dereference. This is similar to the fix in commit 3027e7b15b02
("ice: Fix some null pointer dereference issues in ice_ptp.c").
This issue is found by our static analysis tool
--- drivers/usb/gadget/udc/aspeed-vhub/dev.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/usb/gadget/udc/aspeed-vhub/dev.c +3 -0
@@ -543,6 +543,9 @@ int ast_vhub_init_dev(struct ast_vhub *vhub, unsigned int idx) d->vhub = vhub; d->index = idx; d->name =devm_kasprintf (parent,GFP_KERNEL ,"port%d" , idx+1 ); +if (!d->name) +return -ENOMEM ; + d->regs = vhub->regs +0x100 +0x10 * idx;ast_vhub_init_ep0 (vhub, &d->ep0, d);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 260/286 objtool, ASoC: codecs: wcd934x: Remove potential undefined behavior in wcd934x_slim_irq_handler()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josh Poimboeuf <[email protected]>
[ Upstream commit 060aed9c0093b341480770457093449771cf1496 ]
If 'port_id' is negative, the shift counts in wcd934x_slim_irq_handler() also become negative, resulting in undefined behavior due to shift out of bounds.
If I'm reading the code correctly, that appears to be not possible, but with KCOV enabled, Clang's range analysis isn't always able to determine that and generates undefined behavior.
As a result the code generation isn't optimal, and undefined behavior should be avoided regardless. Improve code generation and remove the undefined behavior by converting the signed variables to unsigned.
Fixes the following warning with UBSAN:
sound/soc/codecs/snd-soc-wcd934x.o: warning: objtool: .text.wcd934x_slim_irq_handler: unexpected end of section
--- sound/soc/codecs/wcd934x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/wcd934x.c +1 -1
@@ -2188,7 +2188,7 @@ static irqreturn_t wcd934x_slim_irq_handler(int irq, void *data) {struct wcd934x_codec *wcd = data;unsigned long status =0 ; -int i, j, port_id; +unsigned int i, j, port_id;unsigned int val, int_val =0 ;irqreturn_t ret =IRQ_NONE ;bool tx;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 261/286 qibfs: fix _another_ leak
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
[ Upstream commit bdb43af4fdb39f844ede401bdb1258f67a580a27 ]
failure to allocate inode => leaked dentry...
this one had been there since the initial merge; to be fair, if we are that far OOM, the odds of failing at that particular allocation are low...
--- drivers/infiniband/hw/qib/qib_fs.c | 1 + 1 file changed, 1 insertion(+)
drivers/infiniband/hw/qib/qib_fs.c +1 -0
@@ -56,6 +56,7 @@ static int qibfs_mknod(struct inode *dir, struct dentry *dentry,struct inode *inode =new_inode (dir->i_sb);if (!inode) { +dput (dentry); error = -EPERM ; goto bail; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 262/286 ntb: reduce stack usage in idt_scan_mws
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
[ Upstream commit aff12700b8dd7422bfe2277696e192af4df9de8f ]
idt_scan_mws() puts a large fixed-size array on the stack and copies it into a smaller dynamically allocated array at the end. On 32-bit targets, the fixed size can easily exceed the warning limit for possible stack overflow:
drivers/ntb/hw/idt/ntb_hw_idt.c:1041:27: error: stack frame size (1032) exceeds limit (1024) in 'idt_scan_mws' [-Werror,-Wframe-larger-than]
Change it to instead just always use dynamic allocation for the array from the start. It's too big for the stack, but not actually all that much for a permanent allocation.
--- drivers/ntb/hw/idt/ntb_hw_idt.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-)
drivers/ntb/hw/idt/ntb_hw_idt.c +7 -11
@@ -1041,7 +1041,7 @@ static inline char *idt_get_mw_name(enum idt_mw_type mw_type)static struct idt_mw_cfg *idt_scan_mws (struct idt_ntb_dev *ndev,int port,unsigned char *mw_cnt) { -struct idt_mw_cfg mws[IDT_MAX_NR_MWS ], *ret_mws; +struct idt_mw_cfg *mws;const struct idt_ntb_bar *bars;enum idt_mw_type mw_type;unsigned char widx, bidx, en_cnt;
@@ -1049,6 +1049,11 @@ static struct idt_mw_cfg *idt_scan_mws(struct idt_ntb_dev *ndev, int port,int aprt_size;u32 data; + mws =devm_kcalloc (&ndev->ntb.pdev->dev,IDT_MAX_NR_MWS , +sizeof (*mws),GFP_KERNEL ); +if (!mws) +return ERR_PTR (-ENOMEM ); +/* Retrieve the array of the BARs registers */ bars = portdata_tbl[port].bars;
@@ -1103,16 +1108,7 @@ static struct idt_mw_cfg *idt_scan_mws(struct idt_ntb_dev *ndev, int port, } } -/* Allocate memory for memory window descriptors */ - ret_mws =devm_kcalloc (&ndev->ntb.pdev->dev, *mw_cnt,sizeof (*ret_mws), -GFP_KERNEL ); -if (!ret_mws) -return ERR_PTR (-ENOMEM ); - -/* Copy the info of detected memory windows */ -memcpy (ret_mws, mws, (*mw_cnt)*sizeof (*ret_mws)); - -return ret_mws; +return mws; }/*
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 263/286 sched/isolation: Make CONFIG_CPU_ISOLATION depend on CONFIG_SMP
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oleg Nesterov <[email protected]>
[ Upstream commit 975776841e689dd8ba36df9fa72ac3eca3c2957a ]
kernel/sched/isolation.c obviously makes no sense without CONFIG_SMP, but the Kconfig entry we have right now:
config CPU_ISOLATION bool "CPU isolation" depends on SMP || COMPILE_TEST
allows the creation of pointless .config's which cause build failures.
--- init/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
init/Kconfig +1 -1
@@ -656,7 +656,7 @@ endmenu # "CPU/Task time and stats accounting" config CPU_ISOLATION bool "CPU isolation" - depends on SMP || COMPILE_TEST + depends on SMP default y help Make sure that CPUs running critical tasks are not disturbed by
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 264/286 KVM: s390: Dont use %pK through tracepoints
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Weißschuh <[email protected]>
[ Upstream commit 6c9567e0850be2f0f94ab64fa6512413fd1a1eb1 ]
Restricted pointers ("%pK") are not meant to be used through TP_format(). It can unintentionally expose security sensitive, raw pointer values.
Use regular pointer formatting instead.
Message-ID: <20250217-restricted-pointers-s390-v1-1-0e4ace75d8aa@linutronix.de>
--- arch/s390/kvm/trace-s390.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/s390/kvm/trace-s390.h +2 -2
@@ -56,7 +56,7 @@ TRACE_EVENT(kvm_s390_create_vcpu, __entry->sie_block = sie_block; ), -TP_printk ("create cpu %d at 0x%pK, sie block at 0x%pK" , +TP_printk ("create cpu %d at 0x%p, sie block at 0x%p" , __entry->id, __entry->vcpu, __entry->sie_block) );
@@ -255,7 +255,7 @@ TRACE_EVENT(kvm_s390_enable_css, __entry->kvm = kvm; ), -TP_printk ("enabling channel I/O support (kvm @ %pK)\n" , +TP_printk ("enabling channel I/O support (kvm @ %p)\n" , __entry->kvm) );
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 265/286 udmabuf: fix a buf size overflow issue during udmabuf creation
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiaogang Chen <[email protected]>
[ Upstream commit 021ba7f1babd029e714d13a6bf2571b08af96d0f ]
by casting size_limit_mb to u64 when calculate pglimit.
--- drivers/dma-buf/udmabuf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma-buf/udmabuf.c +1 -1
@@ -177,7 +177,7 @@ static long udmabuf_create(struct miscdevice *device,if (!ubuf)return -ENOMEM ; - pglimit = (size_limit_mb *1024 *1024 ) >>PAGE_SHIFT ; + pglimit = ((u64 )size_limit_mb *1024 *1024 ) >>PAGE_SHIFT ;for (i =0 ; i < head->count; i++) {if (!IS_ALIGNED (list[i].offset,PAGE_SIZE )) goto err;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 266/286 selftests: ublk: fix test_stripe_04
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ming Lei <[email protected]>
[ Upstream commit 72070e57b0a518ec8e562a2b68fdfc796ef5c040 ]
Commit 57ed58c13256 ("selftests: ublk: enable zero copy for stripe target") added test entry of test_stripe_04, but forgot to add the test script.
So fix the test by adding the script file.
--- .../testing/selftests/ublk/test_stripe_04.sh | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 tools/testing/selftests/ublk/test_stripe_04.sh
tools/testing/selftests/ublk/test_stripe_04.sh new file +24 -0
@@ -0,0 +1,24 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh + +TID="stripe_04" +ERR_CODE=0 + +_prep_test "stripe" "mkfs & mount & umount on zero copy" + +backfile_0=$(_create_backfile 256M) +backfile_1=$(_create_backfile 256M) +dev_id=$(_add_ublk_dev -t stripe -z -q 2 "$backfile_0" "$backfile_1") +_check_add_dev $TID $? "$backfile_0" "$backfile_1" + +_mkfs_mount_test /dev/ublkb"${dev_id}" +ERR_CODE=$? + +_cleanup_test "stripe" + +_remove_backfile "$backfile_0" +_remove_backfile "$backfile_1" + +_show_result $TID $ERR_CODE
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 267/286 nvme: requeue namespace scan on missed AENs
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hannes Reinecke <[email protected]>
[ Upstream commit 9546ad1a9bda7362492114f5866b95b0ac4a100e ]
Scanning for namespaces can take some time, so if the target is reconfigured while the scan is running we may miss a Attached Namespace Attribute Changed AEN.
Check if the NVME_AER_NOTICE_NS_CHANGED bit is set once the scan has finished, and requeue scanning to pick up any missed change.
--- drivers/nvme/host/core.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/nvme/host/core.c +4 -0
@@ -4266,6 +4266,10 @@ static void nvme_scan_work(struct work_struct *work)if (nvme_scan_ns_list (ctrl) !=0 )nvme_scan_ns_sequential (ctrl);mutex_unlock (&ctrl->scan_lock); + +/* Requeue if we have missed AENs */ +if (test_bit (NVME_AER_NOTICE_NS_CHANGED , &ctrl->events)) +nvme_queue_scan (ctrl); }/*
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 268/286 ACPI PPTT: Fix coding mistakes in a couple of sizeof() calls
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jean-Marc Eurin <[email protected]>
[ Upstream commit 7ab4f0e37a0f4207e742a8de69be03984db6ebf0 ]
The end of table checks should be done with the structure size, but 2 of the 3 similar calls use the pointer size.
--- drivers/acpi/pptt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/acpi/pptt.c +2 -2
@@ -217,7 +217,7 @@ static int acpi_pptt_leaf_node(struct acpi_table_header *table_hdr, node_entry =ACPI_PTR_DIFF (node, table_hdr); entry = ACPI_ADD_PTR(struct acpi_subtable_header, table_hdr,sizeof (struct acpi_table_pptt )); - proc_sz =sizeof (struct acpi_pptt_processor *); + proc_sz =sizeof (struct acpi_pptt_processor );while ((unsigned long )entry + proc_sz < table_end) { cpu_node = (struct acpi_pptt_processor *)entry;
@@ -258,7 +258,7 @@ static struct acpi_pptt_processor *acpi_find_processor_node(struct acpi_table_he table_end = (unsigned long )table_hdr + table_hdr->length; entry = ACPI_ADD_PTR(struct acpi_subtable_header, table_hdr,sizeof (struct acpi_table_pptt )); - proc_sz =sizeof (struct acpi_pptt_processor *); + proc_sz =sizeof (struct acpi_pptt_processor );/* find the processor structure associated with this cpuid */ while ((unsigned long )entry + proc_sz < table_end) {
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 269/286 nvme: re-read ANA log page after ns scan completes
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hannes Reinecke <[email protected]>
[ Upstream commit 62baf70c327444338c34703c71aa8cc8e4189bd6 ]
When scanning for new namespaces we might have missed an ANA AEN.
The NVMe base spec (NVMe Base Specification v2.1, Figure 151 'Asynchonous Event Information - Notice': Asymmetric Namespace Access Change) states:
A controller shall not send this even if an Attached Namespace Attribute Changed asynchronous event [...] is sent for the same event.
so we need to re-read the ANA log page after we rescanned the namespace list to update the ANA states of the new namespaces.
--- drivers/nvme/host/core.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/nvme/host/core.c +5 -0
@@ -4270,6 +4270,11 @@ static void nvme_scan_work(struct work_struct *work)/* Requeue if we have missed AENs */ if (test_bit (NVME_AER_NOTICE_NS_CHANGED , &ctrl->events))nvme_queue_scan (ctrl); +#ifdef CONFIG_NVME_MULTIPATH + else +/* Re-read the ANA log page to not miss updates */ + queue_work(nvme_wq, &ctrl->ana_work); +#endif }/*
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 270/286 objtool: Stop UNRET validation on UD2
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josh Poimboeuf <[email protected]>
[ Upstream commit 9f9cc012c2cbac4833746a0182e06a8eec940d19 ]
In preparation for simplifying INSN_SYSCALL, make validate_unret() terminate control flow on UD2 just like validate_branch() already does.
--- tools/objtool/check.c | 3 +++ 1 file changed, 3 insertions(+)
tools/objtool/check.c +3 -0
@@ -3249,6 +3249,9 @@ static int validate_entry(struct objtool_file *file, struct instruction *insn)break ; } +if (insn->dead_end) +return 0 ; +if (!next) {WARN_FUNC ("teh end!" , insn->sec, insn->offset);return -1 ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 271/286 selftests/mincore: Allow read-ahead pages to reach the end of the file
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qiuxu Zhuo <[email protected]>
[ Upstream commit 197c1eaa7ba633a482ed7588eea6fd4aa57e08d4 ]
When running the mincore_selftest on a system with an XFS file system, it failed the "check_file_mmap" test case due to the read-ahead pages reaching the end of the file. The failure log is as below:
RUN global.check_file_mmap ...
mincore_selftest.c:264:check_file_mmap:Expected i (1024) < vec_size (1024) mincore_selftest.c:265:check_file_mmap:Read-ahead pages reached the end of the file
check_file_mmap: Test failed
FAIL global.check_file_mmap
This is because the read-ahead window size of the XFS file system on this machine is 4 MB, which is larger than the size from the #PF address to the end of the file. As a result, all the pages for this file are populated.
blockdev --getra /dev/nvme0n1p5
8192
blockdev --getbsz /dev/nvme0n1p5
512This issue can be fixed by extending the current FILE_SIZE 4MB to a larger number, but it will still fail if the read-ahead window size of the file system is larger enough. Additionally, in the real world, read-ahead pages reaching the end of the file can happen and is an expected behavior. Therefore, allowing read-ahead pages to reach the end of the file is a better choice for the "check_file_mmap" test case.
--- tools/testing/selftests/mincore/mincore_selftest.c | 3 --- 1 file changed, 3 deletions(-)
tools/testing/selftests/mincore/mincore_selftest.c +0 -3
@@ -262,9 +262,6 @@ TEST(check_file_mmap)TH_LOG ("No read-ahead pages found in memory" ); } - EXPECT_LT(i, vec_size) { -TH_LOG ("Read-ahead pages reached the end of the file" ); - }/* * End of the readahead window. The rest of the pages shouldn't * be in memory.
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 272/286 x86/bugs: Use SBPB in write_ibpb() if applicable
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josh Poimboeuf <[email protected]>
[ Upstream commit fc9fd3f98423367c79e0bd85a9515df26dc1b3cc ]
write_ibpb() does IBPB, which (among other things) flushes branch type predictions on AMD. If the CPU has SRSO_NO, or if the SRSO mitigation has been disabled, branch type flushing isn't needed, in which case the lighter-weight SBPB can be used.
The 'x86_pred_cmd' variable already keeps track of whether IBPB or SBPB should be used. Use that instead of hardcoding IBPB.
--- arch/x86/entry/entry.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/entry/entry.S +1 -1
@@ -16,7 +16,7 @@ SYM_FUNC_START(entry_ibpb) movl $MSR_IA32_PRED_CMD, %ecx - movl $PRED_CMD_IBPB, %eax + movl _ASM_RIP(x86_pred_cmd), %eax xorl %edx, %edx wrmsr
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 273/286 x86/bugs: Dont fill RSB on VMEXIT with eIBRS+retpoline
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josh Poimboeuf <[email protected]>
[ Upstream commit 18bae0dfec15b24ec14ca17dc18603372f5f254f ]
eIBRS protects against guest->host RSB underflow/poisoning attacks. Adding retpoline to the mix doesn't change that. Retpoline has a balanced CALL/RET anyway.
So the current full RSB filling on VMEXIT with eIBRS+retpoline is overkill. Disable it or do the VMEXIT_LITE mitigation if needed.
--- arch/x86/kernel/cpu/bugs.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/x86/kernel/cpu/bugs.c +4 -4
@@ -1543,20 +1543,20 @@ static void __init spectre_v2_determine_rsb_fill_type_at_vmexit(enum spectre_v2_case SPECTRE_V2_NONE :return ; -case SPECTRE_V2_EIBRS_LFENCE :case SPECTRE_V2_EIBRS : +case SPECTRE_V2_EIBRS_LFENCE : +case SPECTRE_V2_EIBRS_RETPOLINE :if (boot_cpu_has_bug (X86_BUG_EIBRS_PBRSB )) { -setup_force_cpu_cap (X86_FEATURE_RSB_VMEXIT_LITE );pr_info ("Spectre v2 / PBRSB-eIBRS: Retire a single CALL on VMEXIT\n" ); +setup_force_cpu_cap (X86_FEATURE_RSB_VMEXIT_LITE ); }return ; -case SPECTRE_V2_EIBRS_RETPOLINE :case SPECTRE_V2_RETPOLINE :case SPECTRE_V2_LFENCE :case SPECTRE_V2_IBRS : -setup_force_cpu_cap (X86_FEATURE_RSB_VMEXIT );pr_info ("Spectre v2 / SpectreRSB : Filling RSB on VMEXIT\n" ); +setup_force_cpu_cap (X86_FEATURE_RSB_VMEXIT );return ; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 274/286 ext4: make block validity check resistent to sb bh corruption
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ojaswin Mujoo <[email protected]>
[ Upstream commit ccad447a3d331a239477c281533bacb585b54a98 ]
Block validity checks need to be skipped in case they are called for journal blocks since they are part of system's protected zone.
Currently, this is done by checking inode->ino against sbi->s_es->s_journal_inum, which is a direct read from the ext4 sb buffer head. If someone modifies this underneath us then the s_journal_inum field might get corrupted. To prevent against this, change the check to directly compare the inode with journal->j_inode.
**Slight change in behavior**: During journal init path, check_block_validity etc might be called for journal inode when sbi->s_journal is not set yet. In this case we now proceed with ext4_inode_block_valid() instead of returning early. Since systems zones have not been set yet, it is okay to proceed so we can perform basic checks on the blocks.
--- fs/ext4/block_validity.c | 5 ++--- fs/ext4/inode.c | 7 ++++--- 2 files changed, 6 insertions(+), 6 deletions(-)
fs/ext4/block_validity.c +2 -3
@@ -353,10 +353,9 @@ int ext4_check_blockref(const char *function, unsigned int line, {__le32 *bref = p;unsigned int blk; +journal_t *journal =EXT4_SB (inode->i_sb)->s_journal; -if (ext4_has_feature_journal (inode->i_sb) && - (inode->i_ino == -le32_to_cpu (EXT4_SB (inode->i_sb)->s_es->s_journal_inum))) +if (journal && inode == journal->j_inode)return 0 ;while (bref < p+max) {
fs/ext4/inode.c +4 -3
@@ -409,10 +409,11 @@ static int __check_block_validity(struct inode *inode, const char *func,unsigned int line, struct ext4_map_blocks *map) { - if (ext4_has_feature_journal(inode->i_sb) && - (inode->i_ino == - le32_to_cpu(EXT4_SB(inode->i_sb)->s_es->s_journal_inum))) + journal_t *journal = EXT4_SB(inode->i_sb)->s_journal; + +if (journal && inode == journal->j_inode)return 0 ; +if (!ext4_inode_block_valid (inode, map->m_pblk, map->m_len)) {ext4_error_inode (inode, func, line, map->m_pblk, "lblock %lu mapped to illegal pblock %llu "
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 275/286 scsi: pm80xx: Set phy_attached to zero when device is gone
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Igor Pylypiv <[email protected]>
[ Upstream commit f7b705c238d1483f0a766e2b20010f176e5c0fb7 ]
When a fatal error occurs, a phy down event may not be received to set phy->phy_attached to zero.
--- drivers/scsi/pm8001/pm8001_sas.c | 1 + 1 file changed, 1 insertion(+)
drivers/scsi/pm8001/pm8001_sas.c +1 -0
@@ -892,6 +892,7 @@ static void pm8001_dev_gone_notify(struct domain_device *dev)spin_lock_irqsave (&pm8001_ha->lock, flags); }PM8001_CHIP_DISP ->dereg_dev_req (pm8001_ha, device_id); + pm8001_ha->phy[pm8001_dev->attached_phy].phy_attached =0 ;pm8001_free_dev (pm8001_dev); }else {pm8001_dbg (pm8001_ha,DISC ,"Found dev has gone.\n" );
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 276/286 md/raid1: Add check for missing source disk in process_checks()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Meir Elisha <[email protected]>
[ Upstream commit b7c178d9e57c8fd4238ff77263b877f6f16182ba ]
During recovery/check operations, the process_checks function loops through available disks to find a 'primary' source with successfully read data.
If no suitable source disk is found after checking all possibilities, the 'primary' index will reach conf->raid_disks * 2. Add an explicit check for this condition after the loop. If no source disk was found, print an error message and return early to prevent further processing without a valid primary source.
--- drivers/md/raid1.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-)
drivers/md/raid1.c +16 -10
@@ -2034,14 +2034,9 @@ static int fix_sync_read_error(struct r1bio *r1_bio)if (!rdev_set_badblocks (rdev, sect, s,0 )) abort =1 ; } -if (abort) { - conf->recovery_disabled = - mddev->recovery_disabled; -set_bit (MD_RECOVERY_INTR , &mddev->recovery); -md_done_sync (mddev, r1_bio->sectors,0 ); -put_buf (r1_bio); +if (abort)return 0 ; - } +/* Try next page */ sectors -= s; sect += s;
@@ -2181,10 +2176,21 @@ static void sync_request_write(struct mddev *mddev, struct r1bio *r1_bio)int disks = conf->raid_disks *2 ;struct bio *wbio; -if (!test_bit (R1BIO_Uptodate, &r1_bio->state)) -/* ouch - failed to read all of that. */ -if (!fix_sync_read_error (r1_bio)) +if (!test_bit (R1BIO_Uptodate, &r1_bio->state)) { +/* +* ouch - failed to read all of that. +* No need to fix read error for check/repair +* because all member disks are read. +*/ +if (test_bit (MD_RECOVERY_REQUESTED , &mddev->recovery) || + !fix_sync_read_error (r1_bio)) { + conf->recovery_disabled = mddev->recovery_disabled; +set_bit (MD_RECOVERY_INTR , &mddev->recovery); +md_done_sync (mddev, r1_bio->sectors,0 ); +put_buf (r1_bio);return ; + } + }if (test_bit (MD_RECOVERY_REQUESTED , &mddev->recovery))process_checks (r1_bio);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 277/286 s390/virtio_ccw: Dont allocate/assign airqs for non-existing queues
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Hildenbrand <[email protected]>
commit 2ccd42b959aaf490333dbd3b9b102eaf295c036a upstream.
If we finds a vq without a name in our input array in virtio_ccw_find_vqs(), we treat it as "non-existing" and set the vq pointer to NULL; we will not call virtio_ccw_setup_vq() to allocate/setup a vq.
Consequently, we create only a queue if it actually exists (name != NULL) and assign an incremental queue index to each such existing queue.
However, in virtio_ccw_register_adapter_ind()->get_airq_indicator() we will not ignore these "non-existing queues", but instead assign an airq indicator to them.
Besides never releasing them in virtio_ccw_drop_indicators() (because there is no virtqueue), the bigger issue seems to be that there will be a disagreement between the device and the Linux guest about the airq indicator to be used for notifying a queue, because the indicator bit for adapter I/O interrupt is derived from the queue index.
The virtio spec states under "Setting Up Two-Stage Queue Indicators":
... indicator contains the guest address of an area wherein the indicators for the devices are contained, starting at bit_nr, one bit per virtqueue of the device.
And further in "Notification via Adapter I/O Interrupts":
For notifying the driver of virtqueue buffers, the device sets the bit in the guest-provided indicator area at the corresponding offset.
For example, QEMU uses in virtio_ccw_notify() the queue index (passed as "vector") to select the relevant indicator bit. If a queue does not exist, it does not have a corresponding indicator bit assigned, because it effectively doesn't have a queue index.
Using a virtio-balloon-ccw device under QEMU with free-page-hinting disabled ("free-page-hint=off") but free-page-reporting enabled ("free-page-reporting=on") will result in free page reporting not working as expected: in the virtio_balloon driver, we'll be stuck forever in virtballoon_free_page_report()->wait_event(), because the waitqueue will not be woken up as the notification from the device is
lost: it would use the wrong indicator bit.
Free page reporting stops working and we get splats (when configured to detect hung wqs) like:
INFO: task kworker/1:3:463 blocked for more than 61 seconds.
Not tainted 6.14.0 #4
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
task:kworker/1:3 [...]
Workqueue: events page_reporting_process
Call Trace:
[<000002f404e6dfb2>] __schedule+0x402/0x1640
[<000002f404e6f22e>] schedule+0x3e/0xe0
[<000002f3846a88fa>] virtballoon_free_page_report+0xaa/0x110 [virtio_balloon]
[<000002f40435c8a4>] page_reporting_process+0x2e4/0x740
[<000002f403fd3ee2>] process_one_work+0x1c2/0x400
[<000002f403fd4b96>] worker_thread+0x296/0x420
[<000002f403fe10b4>] kthread+0x124/0x290
[<000002f403f4e0dc>] __ret_from_fork+0x3c/0x60
[<000002f404e77272>] ret_from_fork+0xa/0x38There was recently a discussion [1] whether the "holes" should be treated differently again, effectively assigning also non-existing queues a queue index: that should also fix the issue, but requires other workarounds to not break existing setups.
Let's fix it without affecting existing setups for now by properly ignoring the non-existing queues, so the indicator bits will match the queue indexes.
[1] https://lore.kernel.org/all/[email protected]/
--- drivers/s390/virtio/virtio_ccw.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
drivers/s390/virtio/virtio_ccw.c +12 -4
@@ -261,11 +261,17 @@ static struct airq_info *new_airq_info(istatic unsigned long get_airq_indicator (struct virtqueue *vqs[],int nvqs,u64 *first,void **airq_info) { -int i, j; +int i, j, queue_idx, highest_queue_idx =-1 ;struct airq_info *info;unsigned long indicator_addr =0 ;unsigned long bit, flags; +/* Array entries without an actual queue pointer must be ignored. */ +for (i =0 ; i < nvqs; i++) { +if (vqs[i]) + highest_queue_idx++; + } +for (i =0 ; i <MAX_AIRQ_AREAS && !indicator_addr; i++) {mutex_lock (&airq_areas_lock);if (!airq_areas[i])
@@ -275,7 +281,7 @@ static unsigned long get_airq_indicator(if (!info)return 0 ;write_lock_irqsave (&info->lock, flags); - bit =airq_iv_alloc (info->aiv, nvqs); + bit =airq_iv_alloc (info->aiv, highest_queue_idx +1 );if (bit ==-1UL ) {/* Not enough vacancies. */ write_unlock_irqrestore (&info->lock, flags);
@@ -284,8 +290,10 @@ static unsigned long get_airq_indicator( *first = bit; *airq_info = info; indicator_addr = (unsigned long )info->aiv->vector; -for (j =0 ; j < nvqs; j++) { -airq_iv_set_ptr (info->aiv, bit + j, +for (j =0 , queue_idx =0 ; j < nvqs; j++) { +if (!vqs[j]) +continue ; +airq_iv_set_ptr (info->aiv, bit + queue_idx++, (unsigned long )vqs[j]); }write_unlock_irqrestore (&info->lock, flags);
Greg Kroah-Hartman
maintainerPATCH 278/286 comedi: jr3_pci: Fix synchronous deletion of timer
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Abbott <[email protected]>
commit 44d9b3f584c59a606b521e7274e658d5b866c699 upstream.
When jr3_pci_detach() is called during device removal, it calls timer_delete_sync() to stop the timer, but the timer expiry function always reschedules the timer, so the synchronization is ineffective.
Call timer_shutdown_sync() instead. It does not matter that the timer expiry function pointer is cleared, because the device is being removed.
--- drivers/staging/comedi/drivers/jr3_pci.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/staging/comedi/drivers/jr3_pci.c +11 -4
@@ -88,6 +88,7 @@ struct jr3_pci_poll_delay {struct jr3_pci_dev_private {struct timer_list timer;struct comedi_device *dev; +bool timer_enable; };union jr3_pci_single_range {
@@ -612,10 +613,11 @@ static void jr3_pci_poll_dev(struct time delay = sub_delay.max; } } +if (devpriv->timer_enable) { + devpriv->timer.expires = jiffies +msecs_to_jiffies (delay); +add_timer (&devpriv->timer); + }spin_unlock_irqrestore (&dev->spinlock, flags); - - devpriv->timer.expires = jiffies +msecs_to_jiffies (delay); -add_timer (&devpriv->timer); } static struct jr3_pci_subdev_private *
@@ -764,6 +766,7 @@ static int jr3_pci_auto_attach(struct co devpriv->dev = dev;timer_setup (&devpriv->timer, jr3_pci_poll_dev,0 ); devpriv->timer.expires = jiffies +msecs_to_jiffies (1000 ); + devpriv->timer_enable = true;add_timer (&devpriv->timer);return 0 ;
@@ -773,8 +776,12 @@ static void jr3_pci_detach(struct comedi {struct jr3_pci_dev_private *devpriv = dev->private; -if (devpriv) +if (devpriv) { +spin_lock_bh (&dev->spinlock); + devpriv->timer_enable = false; +spin_unlock_bh (&dev->spinlock);del_timer_sync (&devpriv->timer); + }comedi_pci_detach (dev); }
Greg Kroah-Hartman
maintainerPATCH 279/286 crypto: atmel-sha204a - Set hwrng quality to lowest possible
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Behún <[email protected]>
commit 8006aff15516a170640239c5a8e6696c0ba18d8e upstream.
According to the review by Bill Cox [1], the Atmel SHA204A random number generator produces random numbers with very low entropy.
Set the lowest possible entropy for this chip just to be safe.
[1] https://www.metzdowd.com/pipermail/cryptography/2014-December/023858.html
--- drivers/crypto/atmel-sha204a.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/crypto/atmel-sha204a.c +6 -1
@@ -107,7 +107,12 @@ static int atmel_sha204a_probe(struct i2 i2c_priv->hwrng.name =dev_name (&client->dev); i2c_priv->hwrng.read = atmel_sha204a_rng_read; - i2c_priv->hwrng.quality =1024 ; + +/* +* According to review by Bill Cox [1], this HWRNG has very low entropy. +* [1] https://www.metzdowd.com/pipermail/cryptography/2014-December/023858.html +*/ + i2c_priv->hwrng.quality =1 ; ret =devm_hwrng_register (&client->dev, &i2c_priv->hwrng);if (ret)
Greg Kroah-Hartman
maintainerPATCH 280/286 xdp: Reset bpf_redirect_info before running a xdps BPF prog.
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Andrzej Siewior <[email protected]>
Ricardo reported a KASAN discovered use after free in v6.6-stable.
The syzbot starts a BPF program via xdp_test_run_batch() which assigns ri->tgt_value via dev_hash_map_redirect() and the return code isn't XDP_REDIRECT it looks like nonsense. So the output in bpf_warn_invalid_xdp_action() appears once.
Then the TUN driver runs another BPF program (on the same CPU) which returns XDP_REDIRECT without setting ri->tgt_value first. It invokes bpf_trace_printk() to print four characters and obtain the required return value. This is enough to get xdp_do_redirect() invoked which then accesses the pointer in tgt_value which might have been already deallocated.
This problem does not affect upstream because since commit
401cb7dae8130 ("net: Reference bpf_redirect_info via task_struct on PREEMPT_RT.")
the per-CPU variable is referenced via task's task_struct and exists on the stack during NAPI callback. Therefore it is cleared once before the first invocation and remains valid within the RCU section of the NAPI callback.
Instead of performing the huge backport of the commit (plus its fix ups) here is an alternative version which only resets the variable in question prior invoking the BPF program.
--- include/linux/filter.h | 4 ++++ 1 file changed, 4 insertions(+)
include/linux/filter.h +4 -0
@@ -758,6 +758,10 @@ static __always_inline u32 bpf_prog_run_* already takes rcu_read_lock() when fetching the program, so * it's not necessary here anymore. */ +struct bpf_redirect_info *ri =this_cpu_ptr (&bpf_redirect_info); + +if (ri->map) + ri->map =NULL ;return __BPF_PROG_RUN (prog, xdp,BPF_DISPATCHER_FUNC (xdp)); }
Greg Kroah-Hartman
maintainerPATCH 281/286 MIPS: cm: Fix warning if MIPS_CM is disabled
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Bogendoerfer <[email protected]>
commit b73c3ccdca95c237750c981054997c71d33e09d7 upstream.
Commit e27fbe16af5c ("MIPS: cm: Detect CM quirks from device tree") introduced
arch/mips/include/asm/mips-cm.h:119:13: error: ‘mips_cm_update_property’
defined but not used [-Werror=unused-function]
Fix this by making empty function implementation inline
--- arch/mips/include/asm/mips-cm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/include/asm/mips-cm.h +1 -1
@@ -104,7 +104,7 @@ static inline bool mips_cm_present(void)#ifdef CONFIG_MIPS_CM extern void mips_cm_update_property (void );#else -static void mips_cm_update_property (void ) {} +static inline void mips_cm_update_property (void ) {}#endif /**
Greg Kroah-Hartman
maintainerPATCH 282/286 nvme: fixup scan failure for non-ANA multipath controllers
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hannes Reinecke <[email protected]>
commit 26d7fb4fd4ca1180e2fa96587dea544563b4962a upstream.
Commit 62baf70c3274 caused the ANA log page to be re-read, even on controllers that do not support ANA. While this should generally harmless, some controllers hang on the unsupported log page and never finish probing.
--- drivers/nvme/host/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/host/core.c +1 -1
@@ -4271,7 +4271,7 @@ static void nvme_scan_work(struct work_sif (test_bit (NVME_AER_NOTICE_NS_CHANGED , &ctrl->events))nvme_queue_scan (ctrl);#ifdef CONFIG_NVME_MULTIPATH - else + else if (ctrl->ana_log_buf) /* Re-read the ANA log page to not miss updates */ queue_work(nvme_wq, &ctrl->ana_work);#endif
Greg Kroah-Hartman
maintainerPATCH 283/286 PCI: Fix use-after-free in pci_bus_release_domain_nr()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rob Herring <[email protected]>
commit 30ba2d09edb5ea857a1473ae3d820911347ada62 upstream.
Commit c14f7ccc9f5d ("PCI: Assign PCI domain IDs by ida_alloc()") introduced a use-after-free bug in the bus removal cleanup. The issue was found with kfence:
[ 19.293351] BUG: KFENCE: use-after-free read in pci_bus_release_domain_nr+0x10/0x70
[ 19.302817] Use-after-free read at 0x000000007f3b80eb (in kfence-#115): [ 19.309677] pci_bus_release_domain_nr+0x10/0x70 [ 19.309691] dw_pcie_host_deinit+0x28/0x78 [ 19.309702] tegra_pcie_deinit_controller+0x1c/0x38 [pcie_tegra194] [ 19.309734] tegra_pcie_dw_probe+0x648/0xb28 [pcie_tegra194] [ 19.309752] platform_probe+0x90/0xd8 ...
[ 19.311457] kfence-#115: 0x00000000063a155a-0x00000000ba698da8, size=1072, cache=kmalloc-2k
[ 19.311469] allocated by task 96 on cpu 10 at 19.279323s: [ 19.311562] __kmem_cache_alloc_node+0x260/0x278 [ 19.311571] kmalloc_trace+0x24/0x30 [ 19.311580] pci_alloc_bus+0x24/0xa0 [ 19.311590] pci_register_host_bridge+0x48/0x4b8 [ 19.311601] pci_scan_root_bus_bridge+0xc0/0xe8 [ 19.311613] pci_host_probe+0x18/0xc0 [ 19.311623] dw_pcie_host_init+0x2c0/0x568 [ 19.311630] tegra_pcie_dw_probe+0x610/0xb28 [pcie_tegra194] [ 19.311647] platform_probe+0x90/0xd8 ...
[ 19.311782] freed by task 96 on cpu 10 at 19.285833s: [ 19.311799] release_pcibus_dev+0x30/0x40 [ 19.311808] device_release+0x30/0x90 [ 19.311814] kobject_put+0xa8/0x120 [ 19.311832] device_unregister+0x20/0x30 [ 19.311839] pci_remove_bus+0x78/0x88 [ 19.311850] pci_remove_root_bus+0x5c/0x98 [ 19.311860] dw_pcie_host_deinit+0x28/0x78 [ 19.311866] tegra_pcie_deinit_controller+0x1c/0x38 [pcie_tegra194] [ 19.311883] tegra_pcie_dw_probe+0x648/0xb28 [pcie_tegra194] [ 19.311900] platform_probe+0x90/0xd8 ...
[ 19.313579] CPU: 10 PID: 96 Comm: kworker/u24:2 Not tainted 6.2.0 #4 [ 19.320171] Hardware name: /, BIOS 1.0-d7fb19b 08/10/2022 [ 19.325852] Workqueue: events_unbound deferred_probe_work_func
The stack trace is a bit misleading as dw_pcie_host_deinit() doesn't directly call pci_bus_release_domain_nr(). The issue turns out to be in pci_remove_root_bus() which first calls pci_remove_bus() which frees the struct pci_bus when its struct device is released. Then pci_bus_release_domain_nr() is called and accesses the freed struct pci_bus. Reordering these fixes the issue.
--- drivers/pci/remove.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/pci/remove.c +3 -2
@@ -156,8 +156,6 @@ void pci_remove_root_bus(struct pci_buslist_for_each_entry_safe (child, tmp, &bus->devices, bus_list)pci_remove_bus_device (child); -pci_remove_bus (bus); - host_bridge->bus =NULL ;#ifdef CONFIG_PCI_DOMAINS_GENERIC /* Release domain_nr if it was dynamically allocated */
@@ -165,6 +163,9 @@ void pci_remove_root_bus(struct pci_buspci_bus_release_domain_nr (bus, host_bridge->dev.parent);#endif +pci_remove_bus (bus); + host_bridge->bus =NULL ; +/* remove the host bridge */ device_del (&host_bridge->dev); }
Greg Kroah-Hartman
maintainerPATCH 284/286 soc: samsung: exynos-chipid: correct helpers __init annotation
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Kozlowski <[email protected]>
commit 6166174afc2bc74ca550af388508384b57d5163d upstream.
After converting to builtin driver, the probe function should not call __init functions anymore:
Quoted 1 line
Quoted 1 line
WARNING: modpost:
vmlinux.o(.text+0x8884d4):
Section mismatch in reference from the function exynos_chipid_probe() to the function .init.text:product_id_to_soc_id()
--- drivers/soc/samsung/exynos-chipid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/soc/samsung/exynos-chipid.c +1 -1
@@ -55,7 +55,7 @@ static const struct exynos_soc_id { { "EXYNOS5433", 0xE5433000 }, }; -static const char *__init product_id_to_soc_id (unsigned int product_id) +static const char *product_id_to_soc_id (unsigned int product_id) {int i;
Greg Kroah-Hartman
maintainerPATCH 285/286 media: venus: Fix uninitialized variable count being checked for zero
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Colin Ian King <[email protected]>
commit c5b14df7a80acadbbd184808dc3f519fbb2ab96c upstream.
In the case where plat->codecs is NULL the variable count is uninitialized but is being checked to see if it is 0. Fix this by initializing count to 0.
Addresses-Coverity: ("Uninitialized scalar variable")
--- drivers/media/platform/qcom/venus/hfi_parser.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/qcom/venus/hfi_parser.c +1 -1
@@ -266,7 +266,7 @@ static int hfi_platform_parser(struct ve {const struct hfi_platform *plat;const struct hfi_plat_caps *caps =NULL ; -u32 enc_codecs, dec_codecs, count; +u32 enc_codecs, dec_codecs, count =0 ;unsigned int entries;if (inst)
Greg Kroah-Hartman
maintainerPATCH 286/286 media: venus: hfi_parser: Check for instance after hfi platform get
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stanimir Varbanov <[email protected]>
commit 9b5d8fd580caa898c6e1b8605c774f2517f786ab upstream.
The inst function argument is != NULL only for Venus v1 and we did not migrate v1 to a hfi_platform abstraction yet. So check for instance != NULL only after hfi_platform_get returns no error.
--- drivers/media/platform/qcom/venus/hfi_parser.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/media/platform/qcom/venus/hfi_parser.c +3 -3
@@ -269,13 +269,13 @@ static int hfi_platform_parser(struct veu32 enc_codecs, dec_codecs, count =0 ;unsigned int entries; -if (inst) -return 0 ; - plat =hfi_platform_get (core->res->hfi_version);if (!plat)return -EINVAL ; +if (inst) +return 0 ; +if (plat->codecs) plat->codecs (&enc_codecs, &dec_codecs, &count);
Hi!
Quoted 4 lines
This is the start of the stable review cycle for the 5.10.237 release. There are 286 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.
CIP testing did not find any problems here:
https://gitlab.com/cip-project/cip-testing/linux-stable-rc-ci/-/tree/linux-5.10.y
Best regards,
Pavel
Signature · 2 lines
DENX Software Engineering GmbH, Managing Director: Erika Unter HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Greg Kroah-Hartman wrote on Tue, Apr 29, 2025:
Quoted 5 lines
This is the start of the stable review cycle for the 5.10.237 release. There are 286 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.
Quoted 8 lines
Responses should be made by Thu, 01 May 2025 16:10:15 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.10.237-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.10.y
and the diffstat can be found below.
Tested ce0fd5a9f1a4 ("Linux 5.10.237-rc1") on:
- arm i.MX6ULL (Armadillo 640)
- arm64 i.MX8MP (Armadillo G4)
No obvious regression in dmesg or basic tests:
Signature · 1 line
Dominique Martinet
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.10.237 release. There are 286 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 Thu, 01 May 2025 16:10:15 +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.10.237-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.10.y
and the diffstat can be found below.thanks,
greg k-h
All tests passing for Tegra ...
Test results for stable-v5.10:
10 builds: 10 pass, 0 fail
26 boots: 26 pass, 0 fail
67 tests: 67 pass, 0 failLinux version: 5.10.237-rc1-gce0fd5a9f1a4
Boards tested: tegra124-jetson-tk1, tegra186-p2771-0000,
tegra194-p2972-0000, tegra194-p3509-0000+p3668-0000,
tegra20-ventana, tegra210-p2371-2180,
tegra210-p3450-0000, tegra30-cardhu-a04Jon
Quoted 10 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.10.237 release. There are 286 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 Thu, 01 May 2025 16:10:15 +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.10.237-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.10.y
and the diffstat can be found below.thanks,
greg k-h
Results from Linaro’s test farm.
No regressions on arm64, arm, x86_64, and i386.
## Build
* kernel: 5.10.237-rc1
* git: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
* git commit: ce0fd5a9f1a4e7c9d2c59cffe033ca7d1d7e1688
* git describe: v5.10.236-287-gce0fd5a9f1a4
* test details:
https://qa-reports.linaro.org/lkft/linux-stable-rc-linux-5.10.y/build/v5.10.236-287-gce0fd5a9f1a4
## Test Regressions (compared to v5.10.235-229-g5b68aafded4a)
## Metric Regressions (compared to v5.10.235-229-g5b68aafded4a)
## Test Fixes (compared to v5.10.235-229-g5b68aafded4a)
## Metric Fixes (compared to v5.10.235-229-g5b68aafded4a)
## Test result summary
total: 45273, pass: 32910, fail: 3086, skip: 9042, xfail: 235
## Build Summary
* arc: 5 total, 5 passed, 0 failed
* arm: 102 total, 102 passed, 0 failed
* arm64: 30 total, 30 passed, 0 failed
* i386: 22 total, 22 passed, 0 failed
* mips: 22 total, 22 passed, 0 failed
* parisc: 3 total, 0 passed, 3 failed
* powerpc: 21 total, 21 passed, 0 failed
* riscv: 9 total, 9 passed, 0 failed
* s390: 9 total, 9 passed, 0 failed
* sh: 10 total, 10 passed, 0 failed
* sparc: 6 total, 6 passed, 0 failed
* x86_64: 26 total, 26 passed, 0 failed
## Test suites summary
* boot
* kselftest-arm64
* kselftest-breakpoints
* kselftest-capabilities
* kselftest-cgroup
* kselftest-clone3
* kselftest-core
* kselftest-cpu-hotplug
* kselftest-cpufreq
* kselftest-efivarfs
* kselftest-exec
* kselftest-fpu
* kselftest-ftrace
* kselftest-futex
* kselftest-gpio
* kselftest-intel_pstate
* kselftest-ipc
* kselftest-kcmp
* kselftest-livepatch
* kselftest-membarrier
* kselftest-memfd
* kselftest-mincore
* kselftest-mqueue
* kselftest-net
* kselftest-net-mptcp
* kselftest-openat2
* kselftest-ptrace
* kselftest-rseq
* kselftest-rtc
* kselftest-sigaltstack
* kselftest-size
* kselftest-tc-testing
* kselftest-timers
* kselftest-tmpfs
* kselftest-tpm2
* kselftest-user_events
* kselftest-vDSO
* kselftest-x86
* kunit
* lava
* libgpiod
* libhugetlbfs
* log-parser-boot
* log-parser-build-clang
* log-parser-build-gcc
* log-parser-test
* ltp-capability
* ltp-commands
* ltp-containers
* ltp-controllers
* ltp-cpuhotplug
* ltp-crypto
* ltp-cve
* ltp-dio
* ltp-fcntl-locktests
* ltp-fs
* ltp-fs_bind
* ltp-fs_perms_simple
* ltp-hugetlb
* ltp-ipc
* ltp-math
* ltp-mm
* ltp-nptl
* ltp-pty
* ltp-sched
* ltp-smoke
* ltp-syscalls
* ltp-tracing
* perf
* rcutorture
--
Linaro LKFT
https://lkft.linaro.org
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.10.237 release. There are 286 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 Thu, 01 May 2025 16:10:15 +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.10.237-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.10.y
and the diffstat can be found below.thanks,
greg k-h
On ARCH_BRCMSTB using 32-bit and 64-bit ARM kernels, build tested on BMIPS_GENERIC:
Signature · 1 line
Florian