6.1.175-rc1 review
Subsystems (7)
Greg Kroah-Hartman
maintainerPATCH 251/969 tcp: call sk_data_ready() after listener migration
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhenzhong Wu <[email protected]>
commit 3864c6ba1e041bc75342353a70fa2a2c6f909923 upstream.
When inet_csk_listen_stop() migrates an established child socket from a closing listener to another socket in the same SO_REUSEPORT group, the target listener gets a new accept-queue entry via inet_csk_reqsk_queue_add(), but that path never notifies the target listener's waiters. A nonblocking accept() still works because it checks the queue directly, but poll()/epoll_wait() waiters and blocking accept() callers can also remain asleep indefinitely.
Call READ_ONCE(nsk->sk_data_ready)(nsk) after a successful migration in inet_csk_listen_stop().
However, after inet_csk_reqsk_queue_add() succeeds, the ref acquired in reuseport_migrate_sock() is effectively transferred to nreq->rsk_listener. Another CPU can then dequeue nreq via accept() or listener shutdown, hit reqsk_put(), and drop that listener ref. Since listeners are SOCK_RCU_FREE, wrap the post-queue_add() dereferences of nsk in rcu_read_lock()/rcu_read_unlock(), which also covers the existing sock_net(nsk) access in that path.
The reqsk_timer_handler() path does not need the same changes for two
reasons: half-open requests become readable only after the final ACK, where tcp_child_process() already wakes the listener; and once nreq is visible via inet_ehash_insert(), the success path no longer touches nsk directly.
--- net/ipv4/inet_connection_sock.c | 3 +++ 1 file changed, 3 insertions(+)
net/ipv4/inet_connection_sock.c +3 -0
@@ -1429,16 +1429,19 @@ void inet_csk_listen_stop(struct sock *sif (nreq) {refcount_set (&nreq->rsk_refcnt,1 ); +rcu_read_lock ();if (inet_csk_reqsk_queue_add (nsk, nreq, child)) {__NET_INC_STATS (sock_net (nsk),LINUX_MIB_TCPMIGRATEREQSUCCESS );reqsk_migrate_reset (req); +READ_ONCE (nsk->sk_data_ready)(nsk); }else {__NET_INC_STATS (sock_net (nsk),LINUX_MIB_TCPMIGRATEREQFAILURE );reqsk_migrate_reset (nreq);__reqsk_free (nreq); } +rcu_read_unlock ();/* inet_csk_reqsk_queue_add() has already * called inet_child_forget() on failure case.
Greg Kroah-Hartman
maintainerPATCH 252/969 taskstats: set version in TGID exit notifications
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yiyang Chen <[email protected]>
commit 16c4f0211aaa1ec1422b11b59f64f1abe9009fc0 upstream.
delay accounting started populating taskstats records with a valid version field via fill_pid() and fill_tgid().
Later, commit ad4ecbcba728 ("[PATCH] delay accounting taskstats interface send tgid once") changed the TGID exit path to send the cached signal->stats aggregate directly instead of building the outgoing record through fill_tgid(). Unlike fill_tgid(), fill_tgid_exit() only accumulates accounting data and never initializes stats->version.
As a result, TGID exit notifications can reach userspace with version == 0 even though PID exit notifications and TASKSTATS_CMD_GET replies carry a valid taskstats version.
This is easy to reproduce with tools/accounting/getdelays.c.
I have a small follow-up patch for that tool which:
1. increases the receive buffer/message size so the pid+tgid combined exit notification is not dropped/truncated
2. prints stats->version.
With that patch, the reproducer is:
Terminal 1:
./getdelays -d -v -l -m 0
Terminal 2:
taskset -c 0 python3 -c 'import threading,time; t=threading.Thread(target=time.sleep,args=(0.1,)); t.start(); t.join()'
That produces both PID and TGID exit notifications for the same process. The PID exit record reports a valid taskstats version, while the TGID exit record reports version 0.
This patch (of 2):
Set stats->version = TASKSTATS_VERSION after copying the cached TGID aggregate into the outgoing netlink payload so all taskstats records are self-describing again.
--- kernel/taskstats.c | 1 + 1 file changed, 1 insertion(+)
kernel/taskstats.c +1 -0
@@ -656,6 +656,7 @@ void taskstats_exit(struct task_struct * goto err;memcpy (stats, tsk->signal->stats,sizeof (*stats)); + stats->version =TASKSTATS_VERSION ; send:send_cpu_listeners (rep_skb, listeners);
Greg Kroah-Hartman
maintainerPATCH 253/969 Bluetooth: hci_event: fix potential UAF in SSP passkey handlers
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shuvam Pandey <[email protected]>
commit 85fa3512048793076eef658f66489112dcc91993 upstream.
hci_conn lookup and field access must be covered by hdev lock in hci_user_passkey_notify_evt() and hci_keypress_notify_evt(), otherwise the connection can be freed concurrently.
Extend the hci_dev_lock critical section to cover all conn usage in both handlers.
Keep the existing keypress notification behavior unchanged by routing the early exits through a common unlock path.
--- net/bluetooth/hci_event.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
net/bluetooth/hci_event.c +14 -4
@@ -5497,9 +5497,11 @@ static void hci_user_passkey_notify_evt(bt_dev_dbg (hdev,"" ); +hci_dev_lock (hdev); + conn =hci_conn_hash_lookup_ba (hdev,ACL_LINK , &ev->bdaddr);if (!conn) -return ; + goto unlock; conn->passkey_notify =__le32_to_cpu (ev->passkey); conn->passkey_entered =0 ;
@@ -5508,6 +5510,9 @@ static void hci_user_passkey_notify_evt(mgmt_user_passkey_notify (hdev, &conn->dst, conn->type, conn->dst_type, conn->passkey_notify, conn->passkey_entered); + +unlock: +hci_dev_unlock (hdev); } static void hci_keypress_notify_evt(struct hci_dev *hdev, void *data,
@@ -5518,14 +5523,16 @@ static void hci_keypress_notify_evt(strubt_dev_dbg (hdev,"" ); +hci_dev_lock (hdev); + conn =hci_conn_hash_lookup_ba (hdev,ACL_LINK , &ev->bdaddr);if (!conn) -return ; + goto unlock;switch (ev->type) {case HCI_KEYPRESS_STARTED : conn->passkey_entered =0 ; -return ; + goto unlock;case HCI_KEYPRESS_ENTERED : conn->passkey_entered++;
@@ -5540,13 +5547,16 @@ static void hci_keypress_notify_evt(strubreak ;case HCI_KEYPRESS_COMPLETED : -return ; + goto unlock; }if (hci_dev_test_flag (hdev,HCI_MGMT ))mgmt_user_passkey_notify (hdev, &conn->dst, conn->type, conn->dst_type, conn->passkey_notify, conn->passkey_entered); + +unlock: +hci_dev_unlock (hdev); } static void hci_simple_pair_complete_evt(struct hci_dev *hdev, void *data,
Greg Kroah-Hartman
maintainerPATCH 254/969 can: ucan: fix devres lifetime
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit fed4626501c871890da287bec62a96e52da1af89 upstream.
USB drivers bind to USB interfaces and any device managed resources should have their lifetime tied to the interface rather than parent USB device. This avoids issues like memory leaks when drivers are unbound without their devices being physically disconnected (e.g. on probe deferral or configuration changes).
Fix the control message buffer lifetime so that it is released on driver unbind.
--- drivers/net/can/usb/ucan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/can/usb/ucan.c +1 -1
@@ -1398,7 +1398,7 @@ static int ucan_probe(struct usb_interfa*/ /* Prepare Memory for control transfers */ - ctl_msg_buffer =devm_kzalloc (&udev->dev, + ctl_msg_buffer =devm_kzalloc (&intf->dev,sizeof (union ucan_ctl_payload ),GFP_KERNEL );if (!ctl_msg_buffer) {
Greg Kroah-Hartman
maintainerPATCH 255/969 crypto: arm64/aes - Fix 32-bit aes_mac_update() arg treated as 64-bit
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
commit f8f08d7cc43237e91e3aedf7b67d015d24c38fcc upstream.
Since the 'enc_after' argument to neon_aes_mac_update() and ce_aes_mac_update() has type 'int', it needs to be accessed using the corresponding 32-bit register, not the 64-bit register. The upper half of the corresponding 64-bit register may contain garbage.
--- arch/arm64/crypto/aes-modes.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/crypto/aes-modes.S +2 -2
@@ -848,7 +848,7 @@ AES_FUNC_START(aes_mac_update) encrypt_block v0, w2, x1, x7, w8 eor v0.16b, v0.16b, v4.16b cmp w3, wzr - csinv x5, x6, xzr, eq + csinv w5, w6, wzr, eq cbz w5, .Lmacout encrypt_block v0, w2, x1, x7, w8 st1 {v0.16b}, [x4] /* return dg */
@@ -862,7 +862,7 @@ AES_FUNC_START(aes_mac_update) eor v0.16b, v0.16b, v1.16b /* ..and xor with dg */ subs w3, w3, #1 - csinv x5, x6, xzr, eq + csinv w5, w6, wzr, eq cbz w5, .Lmacout .Lmacenc:
Greg Kroah-Hartman
maintainerPATCH 256/969 crypto: atmel-aes - Fix 3-page memory leak in atmel_aes_buff_cleanup
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thorsten Blum <[email protected]>
commit 3fcfff4ed35f963380a68741bcd52742baff7f76 upstream.
atmel_aes_buff_init() allocates 4 pages using __get_free_pages() with ATMEL_AES_BUFFER_ORDER, but atmel_aes_buff_cleanup() frees only the first page using free_page(), leaking the remaining 3 pages. Use free_pages() with ATMEL_AES_BUFFER_ORDER to fix the memory leak.
--- drivers/crypto/atmel-aes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/crypto/atmel-aes.c +1 -1
@@ -2329,7 +2329,7 @@ static int atmel_aes_buff_init(struct atstatic void atmel_aes_buff_cleanup (struct atmel_aes_dev *dd) { -free_page ((unsigned long )dd->buf); +free_pages ((unsigned long )dd->buf,ATMEL_AES_BUFFER_ORDER ); }static int atmel_aes_dma_init (struct atmel_aes_dev *dd)
Greg Kroah-Hartman
maintainerPATCH 257/969 crypto: atmel-ecc - Release client on allocation failure
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thorsten Blum <[email protected]>
commit 095d50008d55d13f8fcf1bbeb7c6eba51779bc85 upstream.
Call atmel_ecc_i2c_client_free() to release the I2C client reserved by atmel_ecc_i2c_client_alloc() when crypto_alloc_kpp() fails. Otherwise ->tfm_count will be out of sync.
--- drivers/crypto/atmel-ecc.c | 1 + 1 file changed, 1 insertion(+)
drivers/crypto/atmel-ecc.c +1 -0
@@ -261,6 +261,7 @@ static int atmel_ecdh_init_tfm(struct crif (IS_ERR (fallback)) {dev_err (&ctx->client->dev,"Failed to allocate transformation for '%s': %ld\n" , alg,PTR_ERR (fallback)); +atmel_ecc_i2c_client_free (ctx->client);return PTR_ERR (fallback); }
Greg Kroah-Hartman
maintainerPATCH 258/969 crypto: hisilicon - Fix dma_unmap_single() direction
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Fourier <[email protected]>
commit 1ee57ab93b75eb59f426aef37b5498a7ffc28278 upstream.
The direction used to map the buffer skreq->iv is DMA_TO_DEVICE but it is unmapped with direction DMA_BIDIRECTIONAL in the error path.
Change the unmap to match the mapping.
--- drivers/crypto/hisilicon/sec/sec_algs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/crypto/hisilicon/sec/sec_algs.c +1 -1
@@ -844,7 +844,7 @@ err_free_elements:if (crypto_skcipher_ivsize (atfm))dma_unmap_single (info->dev, sec_req->dma_iv,crypto_skcipher_ivsize (atfm), -DMA_BIDIRECTIONAL ); +DMA_TO_DEVICE ); err_unmap_out_sg:if (split) sec_unmap_sg_on_err(skreq->dst, steps, splits_out,
Greg Kroah-Hartman
maintainerPATCH 259/969 crypto: ccree - fix a memory leak in cc_mac_digest()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haoxiang Li <[email protected]>
commit 02c64052fad03699b9c6d1df2f9b444d17e4ac50 upstream.
Add cc_unmap_result() if cc_map_hash_request_final() fails to prevent potential memory leak.
--- drivers/crypto/ccree/cc_hash.c | 1 + 1 file changed, 1 insertion(+)
drivers/crypto/ccree/cc_hash.c +1 -0
@@ -1448,6 +1448,7 @@ static int cc_mac_digest(struct ahash_reif (cc_map_hash_request_final (ctx->drvdata, state, req->src, req->nbytes,1 , flags)) {dev_err (dev,"map_ahash_request_final() failed\n" ); +cc_unmap_result (dev, state, digestsize, req->result);cc_unmap_req (dev, state, ctx);return -ENOMEM ; }
Greg Kroah-Hartman
maintainerPATCH 260/969 crypto: atmel-tdes - fix DMA sync direction
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thorsten Blum <[email protected]>
commit c8a9a647532f5c2a04180352693215e24e9dba03 upstream.
Before DMA output is consumed by the CPU, ->dma_addr_out must be synced with dma_sync_single_for_cpu() instead of dma_sync_single_for_device(). Using the wrong direction can return stale cache data on non-coherent platforms.
--- drivers/crypto/atmel-tdes.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/crypto/atmel-tdes.c +4 -4
@@ -304,8 +304,8 @@ static int atmel_tdes_crypt_pdc_stop(strdma_unmap_sg (dd->dev, dd->out_sg,1 ,DMA_FROM_DEVICE );dma_unmap_sg (dd->dev, dd->in_sg,1 ,DMA_TO_DEVICE ); }else { -dma_sync_single_for_device (dd->dev, dd->dma_addr_out, - dd->dma_size,DMA_FROM_DEVICE ); +dma_sync_single_for_cpu (dd->dev, dd->dma_addr_out, + dd->dma_size,DMA_FROM_DEVICE );/* copy data */ count = atmel_tdes_sg_copy(&dd->out_sg, &dd->out_offset,
@@ -660,8 +660,8 @@ static int atmel_tdes_crypt_dma_stop(strdma_unmap_sg (dd->dev, dd->out_sg,1 ,DMA_FROM_DEVICE );dma_unmap_sg (dd->dev, dd->in_sg,1 ,DMA_TO_DEVICE ); }else { -dma_sync_single_for_device (dd->dev, dd->dma_addr_out, - dd->dma_size,DMA_FROM_DEVICE ); +dma_sync_single_for_cpu (dd->dev, dd->dma_addr_out, + dd->dma_size,DMA_FROM_DEVICE );/* copy data */ count = atmel_tdes_sg_copy(&dd->out_sg, &dd->out_offset,
Greg Kroah-Hartman
maintainerPATCH 261/969 crypto: atmel-sha204a - Fix potential UAF and memory leak in remove path
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thorsten Blum <[email protected]>
commit bab1adf3b87e4bfac92c4f5963c63db434d561c1 upstream.
Unregister the hwrng to prevent new ->read() calls and flush the Atmel I2C workqueue before teardown to prevent a potential UAF if a queued callback runs while the device is being removed.
Drop the early return to ensure sysfs entries are removed and ->hwrng.priv is freed, preventing a memory leak.
--- drivers/crypto/atmel-sha204a.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/crypto/atmel-sha204a.c +2 -4
@@ -126,10 +126,8 @@ static void atmel_sha204a_remove(struct {struct atmel_i2c_client_priv *i2c_priv =i2c_get_clientdata (client); -if (atomic_read (&i2c_priv->tfm_count)) { -dev_emerg (&client->dev,"Device is busy, will remove it anyhow\n" ); -return ; - } +devm_hwrng_unregister (&client->dev, &i2c_priv->hwrng); +atmel_i2c_flush_queue ();kfree ((void *)i2c_priv->hwrng.priv); }
Greg Kroah-Hartman
maintainerPATCH 262/969 dm mirror: fix integer overflow in create_dirty_log()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Junrui Luo <[email protected]>
commit 4c788c6f921b22f9b6c3f316c4a071c05683e7de upstream.
The argument count calculation in create_dirty_log() performs *args_used = 2 + param_count before validating against argc. When a user provides a param_count close to UINT_MAX via the device mapper table string, this unsigned addition wraps around to a small value, causing the subsequent argc < *args_used check to be bypassed.
The overflowed param_count is then passed as argc to dm_dirty_log_create(), where it can cause out-of-bounds reads on the argv array.
Fix by comparing param_count against argc - 2 before performing the addition, following the same pattern used by parse_features() in the same file. Since argc >= 2 is already guaranteed, the subtraction is safe.
--- drivers/md/dm-raid1.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/md/dm-raid1.c +3 -3
@@ -978,13 +978,13 @@ static struct dm_dirty_log *create_dirtyreturn NULL ; } - *args_used =2 + param_count; - -if (argc < *args_used) { +if (param_count > argc -2 ) { ti->error ="Insufficient mirror log arguments" ;return NULL ; } + *args_used =2 + param_count; + dl =dm_dirty_log_create (argv[0 ], ti, mirror_flush, param_count, argv +2 );if (!dl) {
Greg Kroah-Hartman
maintainerPATCH 263/969 IB/core: Fix zero dmac race in neighbor resolution
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen Zhao <[email protected]>
commit 5e6de34d82b49cab9d8a42063e9cd0f22a4f31e5 upstream.
dst_fetch_ha() checks nud_state without holding the neighbor lock, then copies ha under the seqlock. A race in __neigh_update() where nud_state is set to NUD_REACHABLE before ha is written allows dst_fetch_ha() to read a zero MAC address while the seqlock reports no concurrent writer.
netevent_callback amplifies this by waking ALL pending addr_req workers when ANY neighbor becomes NUD_VALID. At scale (N peers resolving ARP concurrently), the hit probability scales as N^2, making it near-certain for large RDMA workloads.
N(A): neigh_update(A) W(A): addr_resolve(A)
| [sleep] | write_lock_bh(&A->lock) | | A->nud_state = NUD_REACHABLE | | // A->ha is still 0 | | [woken by netevent_cb() of | another neighbour] | | dst_fetch_ha(A) | | A->nud_state & NUD_VALID | | read_seqbegin(&A->ha_lock) | | snapshot = A->ha /* 0 */ | | read_seqretry(&A->ha_lock) | | return snapshot | seqlock(&A->ha_lock) | A->ha = mac_A /* too late */ | sequnlock(&A->ha_lock) | write_unlock_bh(&A->lock)
The incorrect/zero mac is read and programmed in the device QP while it was not yet updated. This causes silent packet loss and eventual RETRY_EXC_ERR.
Fix by holding the neighbor read lock across the nud_state check and ha copy in dst_fetch_ha(), ensuring it synchronizes with __neigh_update() which is updating while holding the write lock.
--- drivers/infiniband/core/addr.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/infiniband/core/addr.c +3 -0
@@ -321,11 +321,14 @@ static int dst_fetch_ha(const struct dstif (!n)return -ENODATA ; +read_lock_bh (&n->lock);if (!(n->nud_state &NUD_VALID )) { +read_unlock_bh (&n->lock);neigh_event_send (n,NULL ); ret = -ENODATA ; }else {neigh_ha_snapshot (dev_addr->dst_dev_addr, n, dst->dev); +read_unlock_bh (&n->lock); }neigh_release (n);
Greg Kroah-Hartman
maintainerPATCH 264/969 ktest: Fix the month in the name of the failure directory
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steven Rostedt <[email protected]>
commit 768059ede35f197575a38b10797b52402d9d4d2f upstream.
The Perl localtime() function returns the month starting at 0 not 1. This caused the date produced to create the directory for saving files of a failed run to have the month off by one.
machine-test-useconfig-fail-20260314073628
The above happened in April, not March. The correct name should have been:
machine-test-useconfig-fail-20260414073628
This was somewhat confusing.
--- tools/testing/ktest/ktest.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/ktest/ktest.pl +1 -1
@@ -1770,7 +1770,7 @@ sub save_logs { my ($result, $basedir) = @_; my @t = localtime; my $date = sprintf "%04d%02d%02d%02d%02d%02d", - 1900+$t[5],$t[4],$t[3],$t[2],$t[1],$t[0]; + 1900+$t[5],$t[4]+1,$t[3],$t[2],$t[1],$t[0]; my $type = $build_type; if ($type =~ /useconfig/) {
Greg Kroah-Hartman
maintainerPATCH 265/969 ntfs3: add buffer boundary checks to run_unpack()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tobias Gaertner <[email protected]>
commit b62567bca47408e6739dee75f02a2113548af875 upstream.
run_unpack() checks run_buf < run_last at the top of the while loop but then reads size_size and offset_size bytes via run_unpack_s64() without verifying they fit within the remaining buffer. A crafted NTFS image with truncated run data in an MFT attribute triggers an OOB heap read of up to 15 bytes when the filesystem is mounted.
Add boundary checks before each run_unpack_s64() call to ensure the declared field size does not exceed the remaining buffer.
Found by fuzzing with a source-patched harness (LibAFL + QEMU).
--- fs/ntfs3/run.c | 6 ++++++ 1 file changed, 6 insertions(+)
fs/ntfs3/run.c +6 -0
@@ -963,6 +963,9 @@ int run_unpack(struct runs_tree *run, stif (size_size >8 )return -EINVAL ; +if (run_buf + size_size > run_last) +return -EINVAL ; + len =run_unpack_s64 (run_buf, size_size,0 );/* Skip size_size. */ run_buf += size_size;
@@ -975,6 +978,9 @@ int run_unpack(struct runs_tree *run, stelse if (offset_size <=8 ) {s64 dlcn; +if (run_buf + offset_size > run_last) +return -EINVAL ; +/* Initial value of dlcn is -1 or 0. */ dlcn = (run_buf[offset_size -1 ] &0x80 ) ? (s64)-1 :0 ; dlcn =run_unpack_s64 (run_buf, offset_size, dlcn);
Greg Kroah-Hartman
maintainerPATCH 266/969 ntfs3: fix integer overflow in run_unpack() volume boundary check
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tobias Gaertner <[email protected]>
commit 984a415f019536ea2d24de9010744e5302a9a948 upstream.
The volume boundary check lcn + len > sbi->used.bitmap.nbits uses raw addition which can wrap around for large lcn and len values, bypassing the validation. Use check_add_overflow() as is already done for the adjacent prev_lcn + dlcn and vcn64 + len checks added by commit 3ac37e100385 ("ntfs3: Fix integer overflow in run_unpack()").
Found by fuzzing with a source-patched harness (LibAFL + QEMU).
--- fs/ntfs3/run.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
fs/ntfs3/run.c +9 -3
@@ -1018,9 +1018,15 @@ int run_unpack(struct runs_tree *run, st return -EOPNOTSUPP; }#endif -if (lcn !=SPARSE_LCN64 && lcn + len > sbi->used.bitmap.nbits) { -/* LCN range is out of volume. */ -return -EINVAL ; +if (lcn !=SPARSE_LCN64 ) { +u64 lcn_end; + +if (check_add_overflow (lcn, len, &lcn_end)) +return -EINVAL ; +if (lcn_end > sbi->used.bitmap.nbits) { +/* LCN range is out of volume. */ +return -EINVAL ; + } }if (!run)
Greg Kroah-Hartman
maintainerPATCH 267/969 rtmutex: Use waiter::task instead of current in remove_waiter()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Keenan Dong <[email protected]>
commit 3bfdc63936dd4773109b7b8c280c0f3b5ae7d349 upstream.
remove_waiter() is used by the slowlock paths, but it is also used for proxy-lock rollback in rt_mutex_start_proxy_lock() when invoked from futex_requeue().
In the latter case waiter::task is not current, but remove_waiter() operates on current for the dequeue operation. That results in several problems:
1) the rbtree dequeue happens without waiter::task::pi_lock being held
2) the waiter task's pi_blocked_on state is not cleared, which leaves a dangling pointer primed for UAF around.
3) rt_mutex_adjust_prio_chain() operates on the wrong top priority waiter task
Use waiter::task instead of current in all related operations in remove_waiter() to cure those problems.
[ tglx: Fixup rt_mutex_adjust_prio_chain(), add a comment and amend the
changelog ]
--- kernel/locking/rtmutex.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
kernel/locking/rtmutex.c +8 -5
@@ -1511,20 +1511,23 @@ static bool rtmutex_spin_on_owner(struct* * Must be called with lock->wait_lock held and interrupts disabled. It must * have just failed to try_to_take_rt_mutex(). +* +* When invoked from rt_mutex_start_proxy_lock() waiter::task != current ! */ static void __sched remove_waiter(struct rt_mutex_base *lock,struct rt_mutex_waiter *waiter) {bool is_top_waiter = (waiter ==rt_mutex_top_waiter (lock));struct task_struct *owner =rt_mutex_owner (lock); +struct task_struct *waiter_task = waiter->task;struct rt_mutex_base *next_lock;lockdep_assert_held (&lock->wait_lock); -raw_spin_lock (¤t->pi_lock); -rt_mutex_dequeue (lock, waiter); - current->pi_blocked_on =NULL ; -raw_spin_unlock (¤t->pi_lock); + scoped_guard(raw_spinlock, &waiter_task->pi_lock) { +rt_mutex_dequeue (lock, waiter); + waiter_task->pi_blocked_on =NULL ; + }/* * Only update priority if the waiter was the highest priority
@@ -1560,7 +1563,7 @@ static void __sched remove_waiter(structraw_spin_unlock_irq (&lock->wait_lock);rt_mutex_adjust_prio_chain (owner,RT_MUTEX_MIN_CHAINWALK , lock, - next_lock,NULL , current); + next_lock,NULL , waiter_task);raw_spin_lock_irq (&lock->wait_lock); }
Greg Kroah-Hartman
maintainerPATCH 268/969 scsi: sd: fix missing put_disk() when device_add(&disk_dev) fails
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yang Xiuwei <[email protected]>
commit 1e111c4b3a726df1254670a5cc4868cedb946d37 upstream.
If device_add(&sdkp->disk_dev) fails, put_device() runs scsi_disk_release(), which frees the scsi_disk but leaves the gendisk referenced. The device_add_disk() error path in sd_probe() calls put_disk(gd); call put_disk(gd) here to mirror that cleanup.
--- drivers/scsi/sd.c | 1 + 1 file changed, 1 insertion(+)
drivers/scsi/sd.c +1 -0
@@ -3607,6 +3607,7 @@ static int sd_probe(struct device *dev) error =device_add (&sdkp->disk_dev);if (error) {put_device (&sdkp->disk_dev); +put_disk (gd); goto out; }
Greg Kroah-Hartman
maintainerPATCH 269/969 seg6: fix seg6 lwtunnel output redirect for L2 reduced encap mode
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrea Mayer <[email protected]>
commit ade67d5f588832c7ba131aadd4215a94ce0a15c8 upstream.
When SEG6_IPTUN_MODE_L2ENCAP_RED (L2ENCAP_RED) was introduced, the condition in seg6_build_state() that excludes L2 encap modes from setting LWTUNNEL_STATE_OUTPUT_REDIRECT was not updated to account for the new mode.
As a consequence, L2ENCAP_RED routes incorrectly trigger seg6_output() on the output path, where the packet is silently dropped because skb_mac_header_was_set() fails on L3 packets.
Extend the check to also exclude L2ENCAP_RED, consistent with L2ENCAP.
--- net/ipv6/seg6_iptunnel.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/ipv6/seg6_iptunnel.c +2 -1
@@ -712,7 +712,8 @@ static int seg6_build_state(struct net * newts->type =LWTUNNEL_ENCAP_SEG6 ; newts->flags |=LWTUNNEL_STATE_INPUT_REDIRECT ; -if (tuninfo->mode !=SEG6_IPTUN_MODE_L2ENCAP ) +if (tuninfo->mode !=SEG6_IPTUN_MODE_L2ENCAP && + tuninfo->mode !=SEG6_IPTUN_MODE_L2ENCAP_RED ) newts->flags |=LWTUNNEL_STATE_OUTPUT_REDIRECT ; newts->headroom =seg6_lwt_headroom (tuninfo);
Greg Kroah-Hartman
maintainerPATCH 270/969 crypto: authencesn - reject short ahash digests during instance creation
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yucheng Lu <[email protected]>
commit 5db6ef9847717329f12c5ea8aba7e9f588a980c0 upstream.
authencesn requires either a zero authsize or an authsize of at least 4 bytes because the ESN encrypt/decrypt paths always move 4 bytes of high-order sequence number data at the end of the authenticated data.
While crypto_authenc_esn_setauthsize() already rejects explicit non-zero authsizes in the range 1..3, crypto_authenc_esn_create() still copied auth->digestsize into inst->alg.maxauthsize without validating it. The AEAD core then initialized the tfm's default authsize from that value.
As a result, selecting an ahash with digest size 1..3, such as cbcmac(cipher_null), exposed authencesn instances whose default authsize was invalid even though setauthsize() would have rejected the same value. AF_ALG could then trigger the ESN tail handling with a too-short tag and hit an out-of-bounds access.
Reject authencesn instances whose ahash digest size is in the invalid non-zero range 1..3 so that no tfm can inherit an unsupported default authsize.
--- crypto/authencesn.c | 5 +++++ 1 file changed, 5 insertions(+)
crypto/authencesn.c +5 -0
@@ -400,6 +400,11 @@ static int crypto_authenc_esn_create(str auth =crypto_spawn_ahash_alg (&ctx->auth); auth_base = &auth->base; +if (auth->digestsize >0 && auth->digestsize <4 ) { + err = -EINVAL ; + goto err_free_inst; + } + err =crypto_grab_skcipher (&ctx->enc,aead_crypto_instance (inst),crypto_attr_alg_name (tb[2 ]),0 , mask);if (err)
Greg Kroah-Hartman
maintainerPATCH 271/969 driver core: Add kernel-doc for DEV_FLAG_COUNT enum value
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Douglas Anderson <[email protected]>
commit 5b484311507b5d403c1f7a45f6aa3778549e268b upstream.
Even though nobody should use this value (except when declaring the "flags" bitmap), kernel-doc still gets upset that it's not documented. It reports:
WARNING: ../include/linux/device.h:519 Enum value 'DEV_FLAG_COUNT' not described in enum 'struct_device_flags'
Add the description of DEV_FLAG_COUNT.
--- include/linux/device.h | 1 + 1 file changed, 1 insertion(+)
include/linux/device.h +1 -0
@@ -465,6 +465,7 @@ struct device_physical_location {* * @DEV_FLAG_READY_TO_PROBE: If set then device_add() has finished enough * initialization that probe could be called. +* @DEV_FLAG_COUNT: Number of defined struct_device_flags. */ enum struct_device_flags {DEV_FLAG_READY_TO_PROBE =0 ,
Greg Kroah-Hartman
maintainerPATCH 272/969 ALSA: caiaq: Fix potentially leftover ep1_in_urb at error path
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 0a7b5221b5b51cc798fcfc3be00d02eade149d69 upstream.
The previous fix for handling the error from setup_card() missed that an internal URB cdev->ep1_in_urb might have been already submitted beforehand. In the normal case, this URB gets killed at the disconnection, but in the error path, we didn't do it, hence there can be a potential leak.
Fix it in the error path for setup_card(), too.
--- sound/usb/caiaq/device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/usb/caiaq/device.c +1 -1
@@ -514,7 +514,7 @@ static int init_card(struct snd_usb_caia card->private_free = card_free; err =setup_card (cdev);if (err <0 ) -return err; + goto err_kill_urb;return 0 ;
Greg Kroah-Hartman
maintainerPATCH 273/969 ALSA: caiaq: Dont abort when no input device is available
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit b32ae47a2b0a1fb4bd4942242847966d9b178222 upstream.
The previous fix to handle the error from setup_card() caused a regression for the models that have no dedicated input device; snd_usb_caiaq_input_init() just returns -EINVAL, and we treat it as a fatal error although it should be ignored.
As a regression fix, change the error code to -ENODEV, and ignore this error in the callee, to continue probing.
--- sound/usb/caiaq/device.c | 2 +- sound/usb/caiaq/input.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
sound/usb/caiaq/device.c +1 -1
@@ -366,7 +366,7 @@ static int setup_card(struct snd_usb_cai#ifdef CONFIG_SND_USB_CAIAQ_INPUT ret =snd_usb_caiaq_input_init (cdev); -if (ret <0 ) { +if (ret <0 && ret != -ENODEV ) {dev_err (dev,"Unable to set up input system (ret=%d)\n" , ret);return ret; }
sound/usb/caiaq/input.c +1 -1
@@ -804,7 +804,7 @@ int snd_usb_caiaq_input_init(struct snd_default :/* no input methods supported on this device */ - ret = -EINVAL ; + ret = -ENODEV ; goto exit_free_idev; }
Greg Kroah-Hartman
maintainerPATCH 274/969 ipv6: rpl: reserve mac_len headroom when recompressed SRH grows
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Greg Kroah-Hartman <[email protected]>
commit 9e6bf146b55999a095bb14f73a843942456d1adc upstream.
ipv6_rpl_srh_rcv() decompresses an RFC 6554 Source Routing Header, swaps the next segment into ipv6_hdr->daddr, recompresses, then pulls the old header and pushes the new one plus the IPv6 header back. The recompressed header can be larger than the received one when the swap reduces the common-prefix length the segments share with daddr (CmprI=0, CmprE>0, seg[0][0] != daddr[0] gives the maximum +8 bytes).
pskb_expand_head() was gated on segments_left == 0, so on earlier segments the push consumed unchecked headroom. Once skb_push() leaves fewer than skb->mac_len bytes in front of data, skb_mac_header_rebuild()'s call to:
skb_set_mac_header(skb, -skb->mac_len);
will store (data - head) - mac_len into the u16 mac_header field, which wraps to ~65530, and the following memmove() writes mac_len bytes ~64KiB past skb->head.
A single AF_INET6/SOCK_RAW/IPV6_HDRINCL packet over lo with a two segment type-3 SRH (CmprI=0, CmprE=15) reaches headroom 8 after one pass; KASAN reports a 14-byte OOB write in ipv6_rthdr_rcv.
Fix this by expanding the head whenever the remaining room is less than the push size plus mac_len, and request that much extra so the rebuilt MAC header fits afterwards.
--- net/ipv6/exthdrs.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
net/ipv6/exthdrs.c +6 -3
@@ -500,6 +500,7 @@ static int ipv6_rpl_srh_rcv(struct sk_bustruct net *net =dev_net (skb->dev);struct inet6_dev *idev;struct ipv6hdr *oldhdr; +unsigned int chdr_len;unsigned char *buf;int accept_rpl_seg;int i, err;
@@ -619,8 +620,10 @@ looped_back:skb_pull (skb, ((hdr->hdrlen +1 ) <<3 ));skb_postpull_rcsum (skb, oldhdr,sizeof (struct ipv6hdr ) + ((hdr->hdrlen +1 ) <<3 )); -if (unlikely (!hdr->segments_left)) { -if (pskb_expand_head (skb,sizeof (struct ipv6hdr ) + ((chdr->hdrlen +1 ) <<3 ),0 , + chdr_len =sizeof (struct ipv6hdr ) + ((chdr->hdrlen +1 ) <<3 ); +if (unlikely (!hdr->segments_left || +skb_headroom (skb) < chdr_len + skb->mac_len)) { +if (pskb_expand_head (skb, chdr_len + skb->mac_len,0 ,GFP_ATOMIC )) {__IP6_INC_STATS (net,ip6_dst_idev (skb_dst (skb)),IPSTATS_MIB_OUTDISCARDS );kfree_skb (skb);
@@ -630,7 +633,7 @@ looped_back: oldhdr =ipv6_hdr (skb); } -skb_push (skb, ((chdr->hdrlen +1 ) <<3 ) +sizeof (struct ipv6hdr )); +skb_push (skb, chdr_len);skb_reset_network_header (skb);skb_mac_header_rebuild (skb);skb_set_transport_header (skb,sizeof (struct ipv6hdr ));
Greg Kroah-Hartman
maintainerPATCH 275/969 drm/amdgpu: fix zero-size GDS range init on RDNA4
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arjan van de Ven <[email protected]>
commit 095a8b0ad3c3b5cdc3850d961adb8a8f735220bb upstream.
RDNA4 (GFX 12) hardware removes the GDS, GWS, and OA on-chip memory resources. The gfx_v12_0 initialisation code correctly leaves adev->gds.gds_size, adev->gds.gws_size, and adev->gds.oa_size at zero to reflect this.
amdgpu_ttm_init() unconditionally calls amdgpu_ttm_init_on_chip() for each of these resources regardless of size. When the size is zero, amdgpu_ttm_init_on_chip() forwards the call to ttm_range_man_init(), which calls drm_mm_init(mm, 0, 0). drm_mm_init() immediately fires DRM_MM_BUG_ON(start + size <= start) -- trivially true when size is zero -- crashing the kernel during modprobe of amdgpu on an RX 9070 XT.
Guard against this by returning 0 early from amdgpu_ttm_init_on_chip() when size_in_page is zero. This skips TTM resource manager registration for hardware resources that are absent, without affecting any other GPU type.
DRM_MM_BUG_ON() only asserts if CONFIG_DRM_DEBUG_MM is enabled in the kernel config. This is apparently rarely enabled as these chips have been in the market for over a year and this issue was only reported now.
Oops-Analysis: http://oops.fenrus.org/reports/bugzilla.korg/221376/report.html
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +3 -0
@@ -76,6 +76,9 @@ static int amdgpu_ttm_init_on_chip(struc unsigned int type, uint64_t size_in_page) { +if (!size_in_page) +return 0 ; +return ttm_range_man_init (&adev->mman.bdev, type, false, size_in_page); }
Greg Kroah-Hartman
maintainerPATCH 276/969 ALSA: caiaq: fix usb_dev refcount leak on probe failure
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Deepanshu Kartikey <[email protected]>
commit 7a5f1cd22d47f8ca4b760b6334378ae42c1bd24b upstream.
create_card() takes a reference on the USB device with usb_get_dev() and stores the matching usb_put_dev() in card_free(), which is installed as the snd_card's ->private_free destructor.
However, ->private_free is only assigned near the end of init_card(), after several failure points (usb_set_interface(), EP type checks, usb_submit_urb(), the EP1_CMD_GET_DEVICE_INFO exchange, and its timeout). When any of those fail, init_card() returns an error to snd_probe(), which calls snd_card_free(card). Because ->private_free is still NULL, card_free() never runs, the usb_get_dev() reference is not dropped, and the struct usb_device leaks along with its descriptor allocations and device_private.
syzbot reproduces this with a malformed UAC3 device whose only valid altsetting is 0; init_card()'s usb_set_interface(usb_dev, 0, 1) call fails with -EIO and triggers the leak.
Move the ->private_free assignment into create_card(), immediately after usb_get_dev(), so that every error path reaching snd_card_free() balances the reference. card_free()'s callees (snd_usb_caiaq_input_free, free_urbs, kfree) already tolerate the partially-initialized state because the chip private area is zero-initialized by snd_card_new().
--- sound/usb/caiaq/device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/usb/caiaq/device.c +1 -1
@@ -423,6 +423,7 @@ static int create_card(struct usb_device cdev =caiaqdev (card); cdev->chip.dev =usb_get_dev (usb_dev); + card->private_free = card_free; cdev->chip.card = card; cdev->chip.usb_id =USB_ID (le16_to_cpu (usb_dev->descriptor.idVendor),le16_to_cpu (usb_dev->descriptor.idProduct));
@@ -511,7 +512,6 @@ static int init_card(struct snd_usb_caiasnprintf (card->longname,sizeof (card->longname),"%s %s (%s)" , cdev->vendor_name, cdev->product_name, usbpath); - card->private_free = card_free; err =setup_card (cdev);if (err <0 ) goto err_kill_urb;
Greg Kroah-Hartman
maintainerPATCH 277/969 net: ipv6: fix NOREF dst use in seg6 and rpl lwtunnels
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrea Mayer <[email protected]>
commit f9c52a6ba9780bd27e0bf4c044fd91c13c778b6e upstream.
seg6_input_core() and rpl_input() call ip6_route_input() which sets a NOREF dst on the skb, then pass it to dst_cache_set_ip6() invoking dst_hold() unconditionally.
On PREEMPT_RT, ksoftirqd is preemptible and a higher-priority task can release the underlying pcpu_rt between the lookup and the caching through a concurrent FIB lookup on a shared nexthop. Simplified race sequence:
ksoftirqd/X higher-prio task (same CPU X)
----------- --------------------------------
seg6_input_core(,skb)/rpl_input(skb)
dst_cache_get()
-> miss
ip6_route_input(skb)
-> ip6_pol_route(,skb,flags)
[RT6_LOOKUP_F_DST_NOREF in flags]
-> FIB lookup resolves fib6_nh
[nhid=N route]
-> rt6_make_pcpu_route()
[creates pcpu_rt, refcount=1]
pcpu_rt->sernum = fib6_sernum
[fib6_sernum=W]
-> cmpxchg(fib6_nh.rt6i_pcpu,
NULL, pcpu_rt)
[slot was empty, store succeeds]
-> skb_dst_set_noref(skb, dst)
[dst is pcpu_rt, refcount still 1]
rt_genid_bump_ipv6()
-> bumps fib6_sernum
[fib6_sernum from W to Z]
ip6_route_output()
-> ip6_pol_route()
-> FIB lookup resolves fib6_nh
[nhid=N]
-> rt6_get_pcpu_route()
pcpu_rt->sernum != fib6_sernum
[W <> Z, stale]
-> prev = xchg(rt6i_pcpu, NULL)
-> dst_release(prev)
[prev is pcpu_rt,
refcount 1->0, dead]
dst = skb_dst(skb)
[dst is the dead pcpu_rt]
dst_cache_set_ip6(dst)
-> dst_hold() on dead dst
-> WARN / use-after-freeFor the race to occur, ksoftirqd must be preemptible (PREEMPT_RT without PREEMPT_RT_NEEDS_BH_LOCK) and a concurrent task must be able to release the pcpu_rt. Shared nexthop objects provide such a path, as two routes pointing to the same nhid share the same fib6_nh and its rt6i_pcpu entry.
Fix seg6_input_core() and rpl_input() by calling skb_dst_force() after ip6_route_input() to force the NOREF dst into a refcounted one before caching.
The output path is not affected as ip6_route_output() already returns a refcounted dst.
--- net/ipv6/rpl_iptunnel.c | 9 +++++++++ net/ipv6/seg6_iptunnel.c | 9 +++++++++ 2 files changed, 18 insertions(+)
net/ipv6/rpl_iptunnel.c +9 -0
@@ -284,7 +284,16 @@ static int rpl_input(struct sk_buff *skbif (!dst) {ip6_route_input (skb); + +/* ip6_route_input() sets a NOREF dst; force a refcount on it +* before caching or further use. +*/ +skb_dst_force (skb); dst =skb_dst (skb); +if (unlikely (!dst)) { + err = -ENETUNREACH ; + goto drop; + }/* cache only if we don't create a dst reference loop */ if (!dst->error && lwtst != dst->lwtstate) {
net/ipv6/seg6_iptunnel.c +9 -0
@@ -498,7 +498,16 @@ static int seg6_input_core(struct net *nif (!dst) {ip6_route_input (skb); + +/* ip6_route_input() sets a NOREF dst; force a refcount on it +* before caching or further use. +*/ +skb_dst_force (skb); dst =skb_dst (skb); +if (unlikely (!dst)) { + err = -ENETUNREACH ; + goto drop; + }/* cache only if we don't create a dst reference loop */ if (!dst->error && lwtst != dst->lwtstate) {
Greg Kroah-Hartman
maintainerPATCH 278/969 netfilter: reject zero shift in nft_bitwise
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kai Ma <[email protected]>
commit fe11e5c40817b84abaa5d83bfb6586d8412bfd07 upstream.
Reject zero shift operands for nft_bitwise left and right shift expressions during initialization.
The carry propagation logic computes the carry from the adjacent 32-bit word using BITS_PER_TYPE(u32) - shift. A zero shift operand turns this into a 32-bit shift, which is undefined behaviour.
Reject zero shift operands in the control plane, alongside the existing check for values greater than or equal to 32, so malformed rules never reach the packet path.
--- net/netfilter/nft_bitwise.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/netfilter/nft_bitwise.c +2 -1
@@ -149,7 +149,8 @@ static int nft_bitwise_init_shift(structif (err <0 )return err; -if (priv->data.data[0 ] >=BITS_PER_TYPE (u32)) { +if (!priv->data.data[0 ] || + priv->data.data[0 ] >=BITS_PER_TYPE (u32)) {nft_data_release (&priv->data, desc.type);return -EINVAL ; }
Greg Kroah-Hartman
maintainerPATCH 279/969 scsi: target: configfs: Bound snprintf() return in tg_pt_gp_members_show()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Greg Kroah-Hartman <[email protected]>
commit 772a896a56e0e3ef9424a025cec9176f9d8f4552 upstream.
target_tg_pt_gp_members_show() formats LUN paths with snprintf() into a 256-byte stack buffer, then will memcpy() cur_len bytes from that buffer. snprintf() returns the length the output would have had, which can exceed the buffer size when the fabric WWN is long because iSCSI IQN names can be up to 223 bytes. The check at the memcpy() site only guards the destination page write, not the source read, so memcpy() will read past the stack buffer and copy adjacent stack contents to the sysfs reader, which when CONFIG_FORTIFY_SOURCE is enabled, fortify_panic() will be triggered.
Commit 27e06650a5ea ("scsi: target: target_core_configfs: Add length check to avoid buffer overflow") added the same bound to the target_lu_gp_members_show() but the tg_pt_gp variant was missed so resolve that here.
--- drivers/target/target_core_configfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/target/target_core_configfs.c +1 -1
@@ -3087,7 +3087,7 @@ static ssize_t target_tg_pt_gp_members_s config_item_name(&lun->lun_group.cg_item)); cur_len++;/* Extra byte for NULL terminator */ -if ((cur_len + len) >PAGE_SIZE ) { +if (cur_len >TG_PT_GROUP_NAME_BUF || (cur_len + len) >PAGE_SIZE ) {pr_warn ("Ran out of lu_gp_show_attr" "_members buffer\n" );break ;
Greg Kroah-Hartman
maintainerPATCH 280/969 ipmi: Add limits to event and receive message requests
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Corey Minyard <[email protected]>
commit c4cca236968683eb0d59abfb12d5c7e4d8514227 upstream.
The driver would just fetch events and receive messages until the BMC said it was done. To avoid issues with BMCs that never say they are done, add a limit of 10 fetches at a time.
In addition, an si interface has an attn state it can return from the hardware which is supposed to cause a flag fetch to see if the driver needs to fetch events or message or a few other things. If the attn bit gets stuck, it's a similar problem. So allow messages in between flag fetches so the driver itself doesn't get stuck.
This is a more general fix than the previous fix for the specific bad BMC, but should fix the more general issue of a BMC that won't stop saying it has data.
This has been there from the beginning of the driver. It's not a bug per-se, but it is accounting for bugs in BMCs.
--- drivers/char/ipmi/ipmi_si_intf.c | 54 +++++++++++++++++++++++++++++++-------- drivers/char/ipmi/ipmi_ssif.c | 23 +++++++++++++++- 2 files changed, 64 insertions(+), 13 deletions(-)
drivers/char/ipmi/ipmi_si_intf.c +43 -11
@@ -162,6 +162,10 @@ struct smi_info { OEM2_DATA_AVAIL) unsigned char msg_flags; +/* When requesting events and messages, don't do it forever. */ +unsigned int num_requests_in_a_row; +bool last_was_flag_fetch; +/* Does the BMC have an event buffer? */ bool has_event_buffer;
@@ -394,7 +398,10 @@ static void start_getting_msg_queue(strustart_new_msg (smi_info, smi_info->curr_msg->data, smi_info->curr_msg->data_size); - smi_info->si_state =SI_GETTING_MESSAGES ; +if (smi_info->si_state !=SI_GETTING_MESSAGES ) { + smi_info->num_requests_in_a_row =0 ; + smi_info->si_state =SI_GETTING_MESSAGES ; + } }static void start_getting_events (struct smi_info *smi_info)
@@ -405,7 +412,10 @@ static void start_getting_events(structstart_new_msg (smi_info, smi_info->curr_msg->data, smi_info->curr_msg->data_size); - smi_info->si_state =SI_GETTING_EVENTS ; +if (smi_info->si_state !=SI_GETTING_EVENTS ) { + smi_info->num_requests_in_a_row =0 ; + smi_info->si_state =SI_GETTING_EVENTS ; + } }/*
@@ -579,6 +589,7 @@ static void handle_transaction_done(stru smi_info->si_state =SI_NORMAL ; }else { smi_info->msg_flags = msg[3 ]; + smi_info->last_was_flag_fetch = true;handle_flags (smi_info); }break ;
@@ -624,6 +635,11 @@ static void handle_transaction_done(stru }else {smi_inc_stat (smi_info, events); + smi_info->num_requests_in_a_row++; +if (smi_info->num_requests_in_a_row >10 ) +/* Stop if we do this too many times. */ + smi_info->msg_flags &= ~EVENT_MSG_BUFFER_FULL ; +/* * Do this before we deliver the message * because delivering the message releases the
@@ -662,6 +678,11 @@ static void handle_transaction_done(stru }else {smi_inc_stat (smi_info, incoming_messages); + smi_info->num_requests_in_a_row++; +if (smi_info->num_requests_in_a_row >10 ) +/* Stop if we do this too many times. */ + smi_info->msg_flags &= ~RECEIVE_MSG_AVAIL ; +/* * Do this before we deliver the message * because delivering the message releases the
@@ -790,6 +811,26 @@ restart: }/* +* If we are currently idle, or if the last thing that was +* done was a flag fetch and there is a message pending, try +* to start the next message. +* +* We do the waiting message check to avoid a stuck flag +* completely wedging the driver. Let a message through +* in between flag operations if that happens. +*/ +if (si_sm_result ==SI_SM_IDLE || + (si_sm_result ==SI_SM_ATTN && smi_info->waiting_msg && + smi_info->last_was_flag_fetch)) { + smi_info->last_was_flag_fetch = false; +smi_inc_stat (smi_info, idles); + + si_sm_result =start_next_msg (smi_info); +if (si_sm_result !=SI_SM_IDLE ) + goto restart; + } + +/* * We prefer handling attn over new messages. But don't do * this if there is not yet an upper layer to handle anything. */
@@ -822,15 +863,6 @@ restart: } } -/* If we are currently idle, try to start the next message. */ -if (si_sm_result ==SI_SM_IDLE ) { -smi_inc_stat (smi_info, idles); - - si_sm_result =start_next_msg (smi_info); -if (si_sm_result !=SI_SM_IDLE ) - goto restart; - } -if ((si_sm_result ==SI_SM_IDLE ) && (atomic_read (&smi_info->req_events))) {/*
drivers/char/ipmi/ipmi_ssif.c +21 -2
@@ -225,6 +225,9 @@ struct ssif_info {bool has_event_buffer;bool supports_alert; +/* When requesting events and messages, don't do it forever. */ +unsigned int num_requests_in_a_row; +/* * Used to tell what we should do with alerts. If we are * waiting on a response, read the data immediately.
@@ -413,7 +416,10 @@ static void start_event_fetch(struct ssi } ssif_info->curr_msg = msg; - ssif_info->ssif_state =SSIF_GETTING_EVENTS ; +if (ssif_info->ssif_state !=SSIF_GETTING_EVENTS ) { + ssif_info->num_requests_in_a_row =0 ; + ssif_info->ssif_state =SSIF_GETTING_EVENTS ; + }ipmi_ssif_unlock_cond (ssif_info, flags); msg->data[0 ] = (IPMI_NETFN_APP_REQUEST <<2 );
@@ -436,7 +442,10 @@ static void start_recv_msg_fetch(struct } ssif_info->curr_msg = msg; - ssif_info->ssif_state =SSIF_GETTING_MESSAGES ; +if (ssif_info->ssif_state !=SSIF_GETTING_MESSAGES ) { + ssif_info->num_requests_in_a_row =0 ; + ssif_info->ssif_state =SSIF_GETTING_MESSAGES ; + }ipmi_ssif_unlock_cond (ssif_info, flags); msg->data[0 ] = (IPMI_NETFN_APP_REQUEST <<2 );
@@ -843,6 +852,11 @@ static void msg_done_handler(struct ssif ssif_info->msg_flags &= ~EVENT_MSG_BUFFER_FULL ;handle_flags (ssif_info, flags); }else { + ssif_info->num_requests_in_a_row++; +if (ssif_info->num_requests_in_a_row >10 ) +/* Stop if we do this too many times. */ + ssif_info->msg_flags &= ~EVENT_MSG_BUFFER_FULL ; +handle_flags (ssif_info, flags);ssif_inc_stat (ssif_info, events);deliver_recv_msg (ssif_info, msg);
@@ -876,6 +890,11 @@ static void msg_done_handler(struct ssif ssif_info->msg_flags &= ~RECEIVE_MSG_AVAIL ;handle_flags (ssif_info, flags); }else { + ssif_info->num_requests_in_a_row++; +if (ssif_info->num_requests_in_a_row >10 ) +/* Stop if we do this too many times. */ + ssif_info->msg_flags &= ~RECEIVE_MSG_AVAIL ; +ssif_inc_stat (ssif_info, incoming_messages);handle_flags (ssif_info, flags);deliver_recv_msg (ssif_info, msg);
Greg Kroah-Hartman
maintainerPATCH 281/969 ipmi: Check event message buffer response for bad data
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Corey Minyard <[email protected]>
commit 36920f30e78e69df01f9691c470b6f3ba8aebf98 upstream.
The event message buffer response data size got checked later when processing, but check it right after the response comes back. It appears some BMCs may return an empty message instead of an error when fetching events.
There are apparently some new BMCs that make this error, so we need to compensate.
--- drivers/char/ipmi/ipmi_si_intf.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/char/ipmi/ipmi_si_intf.c +7 -1
@@ -625,7 +625,13 @@ static void handle_transaction_done(stru*/ msg = smi_info->curr_msg; smi_info->curr_msg =NULL ; -if (msg->rsp[2 ] !=0 ) { +/* +* It appears some BMCs, with no event data, return no +* data in the message and not a 0x80 error as the +* spec says they should. Shut down processing if +* the data is not the right length. +*/ +if (msg->rsp[2 ] !=0 || msg->rsp_size !=19 ) {/* Error getting event, probably done. */ msg->done (msg);
Greg Kroah-Hartman
maintainerPATCH 282/969 ipmi:si: Return state to normal if message allocation fails
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Corey Minyard <[email protected]>
commit 09dd798270ff582d7309f285d4aaf5dbebae01cb upstream.
There were places where nothing would get started if a message allocation failed, so the driver needs to return to normal state.
--- drivers/char/ipmi/ipmi_si_intf.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/char/ipmi/ipmi_si_intf.c +6 -2
@@ -481,15 +481,19 @@ retry: }else if (smi_info->msg_flags &RECEIVE_MSG_AVAIL ) {/* Messages available. */ smi_info->curr_msg =alloc_msg_handle_irq (smi_info); -if (!smi_info->curr_msg) +if (!smi_info->curr_msg) { + smi_info->si_state =SI_NORMAL ;return ; + }start_getting_msg_queue (smi_info); }else if (smi_info->msg_flags &EVENT_MSG_BUFFER_FULL ) {/* Events available. */ smi_info->curr_msg =alloc_msg_handle_irq (smi_info); -if (!smi_info->curr_msg) +if (!smi_info->curr_msg) { + smi_info->si_state =SI_NORMAL ;return ; + }start_getting_events (smi_info); } else if (smi_info->msg_flags & OEM_DATA_AVAIL &&
Greg Kroah-Hartman
maintainerPATCH 283/969 fbdev: udlfb: add vm_ops to dlfb_ops_mmap to prevent use-after-free
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rajat Gupta <[email protected]>
commit 8de779dc40d35d39fa07387b6f921eb11df0f511 upstream.
dlfb_ops_mmap() uses remap_pfn_range() to map vmalloc framebuffer pages to userspace but sets no vm_ops on the VMA. This means the kernel cannot track active mmaps. When dlfb_realloc_framebuffer() replaces the backing buffer via FBIOPUT_VSCREENINFO, existing mmap PTEs are not invalidated. On USB disconnect, dlfb_ops_destroy() calls vfree() on the old pages while userspace PTEs still reference them, resulting in a use-after-free:
the process retains read/write access to freed kernel pages.
Add vm_operations_struct with open/close callbacks that maintain an atomic mmap_count on struct dlfb_data. In dlfb_realloc_framebuffer(), check mmap_count and return -EBUSY if the buffer is currently mapped, preventing buffer replacement while userspace holds stale PTEs.
Tested with PoC using dummy_hcd + raw_gadget USB device emulation.
--- drivers/video/fbdev/udlfb.c | 31 ++++++++++++++++++++++++++++++- include/video/udlfb.h | 1 + 2 files changed, 31 insertions(+), 1 deletion(-)
drivers/video/fbdev/udlfb.c +30 -1
@@ -321,12 +321,32 @@ static int dlfb_set_video_mode(struct dlreturn retval; } +static void dlfb_vm_open (struct vm_area_struct *vma) +{ +struct dlfb_data *dlfb = vma->vm_private_data; + +atomic_inc (&dlfb->mmap_count); +} + +static void dlfb_vm_close (struct vm_area_struct *vma) +{ +struct dlfb_data *dlfb = vma->vm_private_data; + +atomic_dec (&dlfb->mmap_count); +} + +static const struct vm_operations_struct dlfb_vm_ops = { + .open = dlfb_vm_open, + .close = dlfb_vm_close, +}; +static int dlfb_ops_mmap (struct fb_info *info,struct vm_area_struct *vma) {unsigned long start = vma->vm_start;unsigned long size = vma->vm_end - vma->vm_start;unsigned long offset = vma->vm_pgoff <<PAGE_SHIFT ;unsigned long page, pos; +struct dlfb_data *dlfb = info->par;if (info->fbdefio)return fb_deferred_io_mmap (info, vma);
@@ -356,6 +376,9 @@ static int dlfb_ops_mmap(struct fb_info size =0 ; } + vma->vm_ops = &dlfb_vm_ops; + vma->vm_private_data = dlfb; +atomic_inc (&dlfb->mmap_count);return 0 ; }
@@ -1219,7 +1242,6 @@ static void dlfb_deferred_vfree(struct d/* * Assumes &info->lock held by caller -* Assumes no active clients have framebuffer open */ static int dlfb_realloc_framebuffer (struct dlfb_data *dlfb,struct fb_info *info,u32 new_len) {
@@ -1231,6 +1253,13 @@ static int dlfb_realloc_framebuffer(stru new_len =PAGE_ALIGN (new_len);if (new_len > old_len) { +if (atomic_read (&dlfb->mmap_count) >0 ) { +dev_warn (info->dev, +"refusing realloc: %d active mmaps\n" , +atomic_read (&dlfb->mmap_count)); +return -EBUSY ; + } +/* * Alloc system memory for virtual framebuffer */
include/video/udlfb.h +1 -0
@@ -56,6 +56,7 @@ struct dlfb_data {spinlock_t damage_lock;struct work_struct damage_work;struct fb_ops ops; +atomic_t mmap_count;/* blit-only rendering path metrics, exposed through sysfs */ atomic_t bytes_rendered;/* raw pixel-bytes driver asked to render */ atomic_t bytes_identical;/* saved effort with backbuffer comparison */
Greg Kroah-Hartman
maintainerPATCH 284/969 ACPI: scan: Use acpi_dev_put() in object add error paths
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
commit 9c0acc169ac71535477caedea8315f7041c5f07c upstream.
After acpi_init_device_object(), the lifetime of struct acpi_device is managed by the driver core through reference counting.
Both acpi_add_power_resource() and acpi_add_single_object() call acpi_init_device_object() and then invoke acpi_device_add(). If that fails, their error paths call the release callback directly instead of dropping the device reference through acpi_dev_put().
This bypasses the normal device lifetime rules and frees the object without releasing the reference acquired by device_initialize(), which may lead to a refcount leak.
The issue was identified by a static analysis tool I developed and confirmed by manual review.
Fix both error paths by using acpi_dev_put() and let the release callback handle the final cleanup.
--- drivers/acpi/power.c | 2 +- drivers/acpi/scan.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/acpi/power.c +1 -1
@@ -986,7 +986,7 @@ struct acpi_device *acpi_add_power_resoureturn device; err: -acpi_release_power_resource (&device->dev); +acpi_dev_put (device);return NULL ; }
drivers/acpi/scan.c +1 -1
@@ -1856,7 +1856,7 @@ static int acpi_add_single_object(struct result =acpi_device_add (device);if (result) { -acpi_device_release (&device->dev); +acpi_dev_put (device);return result; }
Greg Kroah-Hartman
maintainerPATCH 285/969 ACPI: CPPC: Fix related_cpus inconsistency during CPU hotplug
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jinjie Ruan <[email protected]>
commit 75141a770f4f8225d316f6c7e146723a32e9720e upstream.
When concurrently bringing up and down two SMT threads of a physical core, many warning call traces occur as below:
The issue timeline is as follows:
1. When the system starts,
cpufreq: CPU: 220, policy->related_cpus: 220-221, policy->cpus: 220-221
2. Offline CPU 220 and CPU 221.
3. Online CPU 220
- CPU 221 is now offline, as acpi_get_psd_map() use
for_each_online_cpu(), so the cpu_data->shared_cpu_map,
policy->cpus, and related_cpus has only CPU 220.
cpufreq: CPU: 220, policy->related_cpus: 220, policy->cpus: 2204. Offline CPU 220
5. Online CPU 221, the below call trace occurs:
- Since CPU 220 and CPU 221 share one policy, and policy->related_cpus = 220 after step 3, so CPU 221 is not in policy->related_cpus but per_cpu(cpufreq_cpu_data, cpu221) is not NULL.
After reverting commit 56eb0c0ed345 ("ACPI: CPPC: Fix remaining for_each_possible_cpu() to use online CPUs"), the issue disappeared.
The _PSD (P-State Dependency) defines the hardware-level dependency of frequency control across CPU cores. Since this relationship is a physical attribute of the hardware topology, it remains constant regardless of the online or offline status of the CPUs.
Using for_each_online_cpu() in acpi_get_psd_map() is problematic. If a CPU is offline, it will be excluded from the shared_cpu_map. Consequently, if that CPU is brought online later, the kernel will fail to recognize it as part of any shared frequency domain.
Switch back to for_each_possible_cpu() to ensure that all cores defined in the ACPI tables are correctly mapped into their respective performance domains from the start. This aligns with the logic of policy->related_cpus, which must encompass all potentially available cores in the domain to prevent logic gaps during CPU hotplug operations.
To resolve the original issue regarding the "nosmt" or "nosmt=force" boot parameter, as send_pcc_cmd() function already does if (!desc) continue, so reverting that loop back to for_each_possible_cpu() is ok, only need to change the match_cpc_ptr NULL case in acpi_get_psd_map() to continue as Sean suggested.
How to reproduce, on arm64 machine with SMT support which use acpi cppc cpufreq driver:
bash test.sh 220 & bash test.sh 221 &
The test.sh is as below:
while true
do
echo 0 > /sys/devices/system/cpu/cpu${1}/online
sleep 0.5
cat /sys/devices/system/cpu/cpu${1}/cpufreq/related_cpus
echo 1 > /sys/devices/system/cpu/cpu${1}/online
cat /sys/devices/system/cpu/cpu${1}/cpufreq/related_cpus
done
CPU: 221 PID: 1119 Comm: cpuhp/221 Kdump: loaded Not tainted 6.6.0debug+ #5
Hardware name: To be filled by O.E.M. S920X20/BC83AMDA01-7270Z, BIOS 20.39 09/04/2024
pstate: a1400009 (NzCv daif +PAN -UAO -TCO +DIT -SSBS BTYPE=--)
pc : cpufreq_online+0x8ac/0xa90
lr : cpuhp_cpufreq_online+0x18/0x30
sp : ffff80008739bce0
x29: ffff80008739bce0 x28: 0000000000000000 x27: ffff28400ca32200
x26: 0000000000000000 x25: 0000000000000003 x24: ffffd483503ff000
x23: ffffd483504051a0 x22: ffffd48350024a00 x21: 00000000000000dd
x20: 000000000000001d x19: ffff28400ca32000 x18: 0000000000000000
x17: 0000000000000020 x16: ffffd4834e6a3fc8 x15: 0000000000000020
x14: 0000000000000008 x13: 0000000000000001 x12: 00000000ffffffff
x11: 0000000000000040 x10: ffffd48350430728 x9 : ffffd4834f087c78
x8 : 0000000000000001 x7 : ffff2840092bdf00 x6 : ffffd483504264f0
x5 : ffffd48350405000 x4 : ffff283f7f95cc60 x3 : 0000000000000000
x2 : ffff53bc2f94b000 x1 : 00000000000000dd x0 : 0000000000000000
Call trace:
cpufreq_online+0x8ac/0xa90
cpuhp_cpufreq_online+0x18/0x30
cpuhp_invoke_callback+0x128/0x580
cpuhp_thread_fun+0x110/0x1b0
smpboot_thread_fn+0x140/0x190
kthread+0xec/0x100
ret_from_fork+0x10/0x20
---[ end trace 0000000000000000 ]------ drivers/acpi/cppc_acpi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/acpi/cppc_acpi.c +3 -3
@@ -342,7 +342,7 @@ static int send_pcc_cmd(int pcc_ss_id, u end:if (cmd ==CMD_WRITE ) {if (unlikely (ret)) { -for_each_online_cpu (i) { +for_each_possible_cpu (i) {struct cpc_desc *desc =per_cpu (cpc_desc_ptr, i);if (!desc)
@@ -504,13 +504,13 @@ int acpi_get_psd_map(unsigned int cpu, selse if (pdomain->coord_type ==DOMAIN_COORD_TYPE_SW_ANY ) cpu_data->shared_type =CPUFREQ_SHARED_TYPE_ANY ; -for_each_online_cpu (i) { +for_each_possible_cpu (i) {if (i == cpu)continue ; match_cpc_ptr =per_cpu (cpc_desc_ptr, i);if (!match_cpc_ptr) - goto err_fault; +continue ; match_pdomain = &(match_cpc_ptr->domain_info);if (match_pdomain->domain != pdomain->domain)
Greg Kroah-Hartman
maintainerPATCH 286/969 ACPI: video: force native backlight on HP OMEN 16 (8A44)
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shivam Kalra <[email protected]>
commit 4b506ea5351a1f5937ac632a4a5c35f6f796cc41 upstream.
The HP OMEN 16 Gaming Laptop (board name 8A44) has a mux-less hybrid GPU configuration with AMD Rembrandt (Radeon 680M) and NVIDIA GA104 (RTX 3070 Ti). The internal eDP panel is wired to the AMD iGPU.
When Nouveau loads without GSP firmware, the ACPI video backlight device (acpi_video0) gets registered alongside the native AMD backlight (amdgpu_bl2). In this state, writes to amdgpu_bl2 update the software brightness value but fail to change the physical panel brightness.
Force native backlight to prevent acpi_video0 from registering. Confirmed that booting with acpi_backlight=native resolves the issue.
--- drivers/acpi/video_detect.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/acpi/video_detect.c +8 -0
@@ -776,6 +776,14 @@ static const struct dmi_system_id video_ DMI_MATCH(DMI_PRODUCT_NAME, "Z830"), }, }, + { + .callback = video_detect_force_native, + /* HP OMEN Gaming Laptop 16-n0xxx */ + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "HP"), + DMI_MATCH(DMI_PRODUCT_NAME, "OMEN by HP Gaming Laptop 16-n0xxx"), + }, + },/* * Models which have nvidia-ec-wmi support, but should not use it.
Greg Kroah-Hartman
maintainerPATCH 287/969 ASoC: SOF: Dont allow pointer operations on unconfigured streams
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mark Brown <[email protected]>
commit c5b6285aae050ff1c3ea824ca3d88ac4be1e69c8 upstream.
When reporting the pointer for a compressed stream we report the current I/O frame position by dividing the position by the number of channels multiplied by the number of container bytes. These values default to 0 and are only configured as part of setting the stream parameters so this allows a divide by zero to be configured. Validate that they are non zero, returning an error if not
--- sound/soc/sof/compress.c | 3 +++ 1 file changed, 3 insertions(+)
sound/soc/sof/compress.c +3 -0
@@ -366,6 +366,9 @@ static int sof_compr_pointer(struct snd_if (!spcm)return -EINVAL ; +if (!sstream->channels || !sstream->sample_container_bytes) +return -EBUSY ; + tstamp->sampling_rate = sstream->sampling_rate; tstamp->copied_total = sstream->copied_total; tstamp->pcm_io_frames = div_u64(spcm->stream[cstream->direction].posn.dai_posn,
Greg Kroah-Hartman
maintainerPATCH 288/969 spi: rockchip: fix controller deregistration
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 53e7a16070feb7d1d4d81a583eaac5e25048b9c3 upstream.
Make sure to deregister the controller before freeing underlying resources like DMA channels during driver unbind.
--- drivers/spi/spi-rockchip.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/spi/spi-rockchip.c +3 -1
@@ -921,7 +921,7 @@ static int rockchip_spi_probe(struct plabreak ; } - ret =devm_spi_register_controller (&pdev->dev, ctlr); + ret =spi_register_controller (ctlr);if (ret <0 ) {dev_err (&pdev->dev,"Failed to register controller\n" ); goto err_free_dma_rx;
@@ -957,6 +957,8 @@ static int rockchip_spi_remove(struct plclk_disable_unprepare (rs->spiclk);clk_disable_unprepare (rs->apb_pclk); +spi_unregister_controller (ctlr); +pm_runtime_put_noidle (&pdev->dev);pm_runtime_disable (&pdev->dev);pm_runtime_set_suspended (&pdev->dev);
Greg Kroah-Hartman
maintainerPATCH 289/969 drm/amd/display: Do not skip unrelated mode changes in DSC validation
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yussuf Khalil <[email protected]>
[ Upstream commit aed3d041ab061ec8a64f50a3edda0f4db7280025 ]
Starting with commit 17ce8a6907f7 ("drm/amd/display: Add dsc pre-validation in atomic check"), amdgpu resets the CRTC state mode_changed flag to false when recomputing the DSC configuration results in no timing change for a particular stream.
However, this is incorrect in scenarios where a change in MST/DSC configuration happens in the same KMS commit as another (unrelated) mode change. For example, the integrated panel of a laptop may be configured differently (e.g., HDR enabled/disabled) depending on whether external screens are attached. In this case, plugging in external DP-MST screens may result in the mode_changed flag being dropped incorrectly for the integrated panel if its DSC configuration did not change during precomputation in pre_validate_dsc().
At this point, however, dm_update_crtc_state() has already created new streams for CRTCs with DSC-independent mode changes. In turn, amdgpu_dm_commit_streams() will never release the old stream, resulting in a memory leak. amdgpu_dm_atomic_commit_tail() will never acquire a reference to the new stream either, which manifests as a use-after-free when the stream gets disabled later on:
BUG: KASAN: use-after-free in dc_stream_release+0x25/0x90 [amdgpu] Write of size 4 at addr ffff88813d836524 by task kworker/9:9/29977 Workqueue: events drm_mode_rmfb_work_fn Call Trace: <TASK> dump_stack_lvl+0x6e/0xa0 print_address_description.constprop.0+0x88/0x320 ? dc_stream_release+0x25/0x90 [amdgpu] print_report+0xfc/0x1ff ? srso_alias_return_thunk+0x5/0xfbef5 ? __virt_addr_valid+0x225/0x4e0 ? dc_stream_release+0x25/0x90 [amdgpu] kasan_report+0xe1/0x180 ? dc_stream_release+0x25/0x90 [amdgpu] kasan_check_range+0x125/0x200 dc_stream_release+0x25/0x90 [amdgpu] dc_state_destruct+0x14d/0x5c0 [amdgpu] dc_state_release.part.0+0x4e/0x130 [amdgpu] dm_atomic_destroy_state+0x3f/0x70 [amdgpu] drm_atomic_state_default_clear+0x8ee/0xf30 ? drm_mode_object_put.part.0+0xb1/0x130 __drm_atomic_state_free+0x15c/0x2d0 atomic_remove_fb+0x67e/0x980
Since there is no reliable way of figuring out whether a CRTC has unrelated mode changes pending at the time of DSC validation, remember the value of the mode_changed flag from before the point where a CRTC was marked as potentially affected by a change in DSC configuration. Reset the mode_changed flag to this earlier value instead in pre_validate_dsc().
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 5 +++++ drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h | 1 + .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c | 7 +++++-- 3 files changed, 11 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +5 -0
@@ -9908,6 +9908,11 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev,#if defined(CONFIG_DRM_AMD_DC_DCN )if (dc_resource_is_dsc_encoding_supported (dc)) { +for_each_oldnew_crtc_in_state (state, crtc, old_crtc_state, new_crtc_state, i) { + dm_new_crtc_state =to_dm_crtc_state (new_crtc_state); + dm_new_crtc_state->mode_changed_independent_from_dsc = new_crtc_state->mode_changed; + } +for_each_oldnew_crtc_in_state (state, crtc, old_crtc_state, new_crtc_state, i) {if (drm_atomic_crtc_needs_modeset (new_crtc_state)) { ret =add_affected_mst_dsc_crtcs (state, crtc);
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h +1 -0
@@ -698,6 +698,7 @@ struct dm_crtc_state {bool freesync_vrr_info_changed; +bool mode_changed_independent_from_dsc;bool dsc_force_changed;bool vrr_supported;struct mod_freesync_config freesync_config;
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c +5 -2
@@ -1564,8 +1564,11 @@ int pre_validate_dsc(struct drm_atomic_state *state, }else {int ind =find_crtc_index_in_state_by_stream (state, stream); -if (ind >=0 ) - state->crtcs[ind].new_state->mode_changed =0 ; +if (ind >=0 ) { +struct dm_crtc_state *dm_new_crtc_state =to_dm_crtc_state (state->crtcs[ind].new_state); + + dm_new_crtc_state->base.mode_changed = dm_new_crtc_state->mode_changed_independent_from_dsc; + } } } clean_exit:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 290/969 spi: meson-spicc: Fix double-put in remove path
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felix Gu <[email protected]>
[ Upstream commit 63542bb402b7013171c9f621c28b609eda4dbf1f ]
meson_spicc_probe() registers the controller with devm_spi_register_controller(), so teardown already drops the controller reference via devm cleanup.
Calling spi_controller_put() again in meson_spicc_remove() causes a double-put.
[ In v6.1, commit 68bf3288c7eb ("spi: meson-spicc: switch to use modern name") has not been applied, so the driver still uses the legacy spicc->master field and spi_master_put() API. The line to remove is spi_master_put(spicc->master) rather than spi_controller_put(spicc->host) as in the upstream patch. They are functionally identical. ]
--- drivers/spi/spi-meson-spicc.c | 2 -- 1 file changed, 2 deletions(-)
drivers/spi/spi-meson-spicc.c +0 -2
@@ -883,8 +883,6 @@ static int meson_spicc_remove(struct platform_device *pdev)clk_disable_unprepare (spicc->core);clk_disable_unprepare (spicc->pclk); -spi_master_put (spicc->master); -return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 291/969 ext4: validate p_idx bounds in ext4_ext_correct_indexes
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tejas Bharambe <[email protected]>
[ Upstream commit 2acb5c12ebd860f30e4faf67e6cc8c44ddfe5fe8 ]
ext4_ext_correct_indexes() walks up the extent tree correcting index entries when the first extent in a leaf is modified. Before accessing path[k].p_idx->ei_block, there is no validation that p_idx falls within the valid range of index entries for that level.
If the on-disk extent header contains a corrupted or crafted eh_entries value, p_idx can point past the end of the allocated buffer, causing a slab-out-of-bounds read.
Fix this by validating path[k].p_idx against EXT_LAST_INDEX() at both access sites: before the while loop and inside it. Return -EFSCORRUPTED if the index pointer is out of range, consistent with how other bounds violations are handled in the ext4 extent tree code.
--- fs/ext4/extents.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
fs/ext4/extents.c +15 -0
@@ -1740,6 +1740,13 @@ static int ext4_ext_correct_indexes(handle_t *handle, struct inode *inode, err =ext4_ext_get_access (handle, inode, path + k);if (err)return err; +if (unlikely (path[k].p_idx >EXT_LAST_INDEX (path[k].p_hdr))) { +EXT4_ERROR_INODE (inode, +"path[%d].p_idx %p > EXT_LAST_INDEX %p" , + k, path[k].p_idx, +EXT_LAST_INDEX (path[k].p_hdr)); +return -EFSCORRUPTED ; + } path[k].p_idx->ei_block = border; err =ext4_ext_dirty (handle, inode, path + k);if (err)
@@ -1752,6 +1759,14 @@ static int ext4_ext_correct_indexes(handle_t *handle, struct inode *inode, err =ext4_ext_get_access (handle, inode, path + k);if (err)break ; +if (unlikely (path[k].p_idx >EXT_LAST_INDEX (path[k].p_hdr))) { +EXT4_ERROR_INODE (inode, +"path[%d].p_idx %p > EXT_LAST_INDEX %p" , + k, path[k].p_idx, +EXT_LAST_INDEX (path[k].p_hdr)); + err = -EFSCORRUPTED ; +break ; + } path[k].p_idx->ei_block = border; err =ext4_ext_dirty (handle, inode, path + k);if (err)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 292/969 KVM: x86: Fix shadow paging use-after-free due to unexpected GFN
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Christopherson <[email protected]>
commit 0cb2af2ea66ad8ff195c156ea690f11216285bdf upstream.
The shadow MMU computes GFNs for direct shadow pages using sp->gfn plus the SPTE index. This assumption breaks for shadow paging if the guest page tables are modified between VM entries (similar to commit aad885e77496, "KVM: x86/mmu: Drop/zap existing present SPTE even when creating an MMIO SPTE", 2026-03-27). The flow is as follows:
- a PDE is installed for a 2MB mapping, and a page in that area is accessed. KVM creates a kvm_mmu_page consisting of 512 4KB pages; the kvm_mmu_page is marked by FNAME(fetch) as direct-mapped because the guest's mapping is a huge page (and thus contiguous).
- the PDE mapping is changed from outside the guest.
- the guest accesses another page in the same 2MB area. KVM installs a new leaf SPTE and rmap entry; the SPTE uses the "correct" GFN (i.e. based on the new mapping, as changed in the previous step) but that GFN is outside of the [sp->gfn, sp->gfn + 511] range; therefore the rmap entry cannot be found and removed when the kvm_mmu_page is zapped.
- the memslot that covers the first 2MB mapping is deleted, and the kvm_mmu_page for the now-invalid GPA is zapped. However, rmap_remove() only looks at the [sp->gfn, sp->gfn + 511] range established in step 1, and fails to find the rmap entry that was recorded by step 3.
- any operation that causes an rmap walk for the same page accessed by step 3 then walks a stale rmap and dereferences a freed kvm_mmu_page. This includes dirty logging or MMU notifier invalidations (e.g., from MADV_DONTNEED).
The underlying issue is that KVM's walking of shadow PTEs assumes that if a SPTE is present when KVM wants to install a non-leaf SPTE, then the existing kvm_mmu_page must be for the correct gfn. Because the only way for the gfn to be wrong is if KVM messed up and failed to zap a SPTE... which shouldn't happen, but *actually* only happens in response to a guest write.
That bug dates back literally forever, as even the first version of KVM assumes that the GFN matches and walks into the "wrong" shadow page. However, that was only an imprecision until 2032a93d66fa ("KVM: MMU:
Don't allocate gfns page for direct mmu pages") came along.
Fix it by checking for a target gfn mismatch and zapping the existing SPTE. That way the old SP and rmap entries are gone, KVM installs the rmap in the right location, and everyone is happy.
--- arch/x86/kvm/mmu/mmu.c | 36 ++++++++++++++---------------------- arch/x86/kvm/mmu/spte.h | 5 +++++ 2 files changed, 19 insertions(+), 22 deletions(-)
arch/x86/kvm/mmu/mmu.c +14 -22
@@ -163,6 +163,8 @@ struct kmem_cache *mmu_page_header_cache;static struct percpu_counter kvm_total_used_mmu_pages;static void mmu_spte_set (u64 *sptep,u64 spte); +static int mmu_page_zap_pte (struct kvm *kvm,struct kvm_mmu_page *sp, +u64 *spte,struct list_head *invalid_list);struct kvm_mmu_role_regs {const unsigned long cr0;
@@ -1156,20 +1158,6 @@ static void drop_spte(struct kvm *kvm, u64 *sptep)rmap_remove (kvm, sptep); } -static void drop_large_spte (struct kvm *kvm,u64 *sptep,bool flush) -{ -struct kvm_mmu_page *sp; - - sp =sptep_to_sp (sptep); -WARN_ON (sp->role.level ==PG_LEVEL_4K ); - -drop_spte (kvm, sptep); - -if (flush) -kvm_flush_remote_tlbs_with_address (kvm, sp->gfn, -KVM_PAGES_PER_HPAGE (sp->role.level)); -} -/* * Write-protect on the specified @sptep, @pt_protect indicates whether * spte write-protection is caused by protecting shadow page table.
@@ -2253,7 +2241,8 @@ static struct kvm_mmu_page *kvm_mmu_get_child_sp(struct kvm_vcpu *vcpu, {union kvm_mmu_page_role role; -if (is_shadow_present_pte (*sptep) && !is_large_pte (*sptep)) +if (is_shadow_present_pte (*sptep) && !is_large_pte (*sptep) && +spte_to_child_sp (*sptep) &&spte_to_child_sp (*sptep)->gfn == gfn)return ERR_PTR (-EEXIST ); role =kvm_mmu_child_role (sptep, direct, access);
@@ -2331,13 +2320,16 @@ static void __link_shadow_page(struct kvm *kvm,BUILD_BUG_ON (VMX_EPT_WRITABLE_MASK !=PT_WRITABLE_MASK ); -/* -* If an SPTE is present already, it must be a leaf and therefore -* a large one. Drop it, and flush the TLB if needed, before -* installing sp. -*/ -if (is_shadow_present_pte (*sptep)) -drop_large_spte (kvm, sptep, flush); +if (is_shadow_present_pte (*sptep)) { +struct kvm_mmu_page *parent_sp; +LIST_HEAD (invalid_list); + + parent_sp =sptep_to_sp (sptep); +WARN_ON_ONCE (parent_sp->role.level ==PG_LEVEL_4K ); + +mmu_page_zap_pte (kvm, parent_sp, sptep, &invalid_list); +kvm_mmu_remote_flush_or_zap (kvm, &invalid_list, true); + } spte =make_nonleaf_spte (sp->spt,sp_ad_disabled (sp));
arch/x86/kvm/mmu/spte.h +5 -0
@@ -295,6 +295,11 @@ static inline bool is_executable_pte(u64 spte)return (spte & (shadow_x_mask | shadow_nx_mask)) == shadow_x_mask; } +static inline struct kvm_mmu_page *spte_to_child_sp (u64 spte) +{ +return to_shadow_page (spte &SPTE_BASE_ADDR_MASK ); +} +static inline kvm_pfn_t spte_to_pfn (u64 pte) {return (pte &SPTE_BASE_ADDR_MASK ) >>PAGE_SHIFT ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 293/969 net: Fix icmp host relookup triggering ip_rt_bug
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dong Chenchen <[email protected]>
[ Upstream commit c44daa7e3c73229f7ac74985acb8c7fb909c4e0a ]
arp link failure may trigger ip_rt_bug while xfrm enabled, call trace is:
WARNING: CPU: 0 PID: 0 at net/ipv4/route.c:1241 ip_rt_bug+0x14/0x20 Modules linked in: CPU: 0 UID: 0 PID: 0 Comm: swapper/0 Not tainted 6.12.0-rc6-00077-g2e1b3cc9d7f7 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014 RIP: 0010:ip_rt_bug+0x14/0x20 Call Trace: <IRQ> ip_send_skb+0x14/0x40 __icmp_send+0x42d/0x6a0 ipv4_link_failure+0xe2/0x1d0 arp_error_report+0x3c/0x50 neigh_invalidate+0x8d/0x100 neigh_timer_handler+0x2e1/0x330 call_timer_fn+0x21/0x120 __run_timer_base.part.0+0x1c9/0x270 run_timer_softirq+0x4c/0x80 handle_softirqs+0xac/0x280 irq_exit_rcu+0x62/0x80 sysvec_apic_timer_interrupt+0x77/0x90
The script below reproduces this scenario:
ip xfrm policy add src 0.0.0.0/0 dst 0.0.0.0/0 \
dir out priority 0 ptype main flag localok icmp
ip l a veth1 type veth
ip a a 192.168.141.111/24 dev veth0
ip l s veth0 up
ping 192.168.141.155 -c 1
icmp_route_lookup() create input routes for locally generated packets while xfrm relookup ICMP traffic.Then it will set input route (dst->out = ip_rt_bug) to skb for DESTUNREACH.
For ICMP err triggered by locally generated packets, dst->dev of output route is loopback. Generally, xfrm relookup verification is not required on loopback interfaces (net.ipv4.conf.lo.disable_xfrm = 1).
Skip icmp relookup for locally generated packets to fix it.
--- net/ipv4/icmp.c | 3 +++ 1 file changed, 3 insertions(+)
net/ipv4/icmp.c +3 -0
@@ -518,6 +518,9 @@ static struct rtable *icmp_route_lookup(struct net *net, struct flowi4 *fl4,if (!IS_ERR (rt)) {if (rt != rt2)return rt; +if (inet_addr_type_dev_table (net, route_lookup_dev, + fl4->daddr) ==RTN_LOCAL ) +return rt; }else if (PTR_ERR (rt) == -EPERM ) { rt =NULL ; }else
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 294/969 flow_dissector: do not dissect PPPoE PFC frames
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qingfang Deng <[email protected]>
[ Upstream commit d6c19b31a3c1d519fabdcf0aa239e6b6109b9473 ]
RFC 2516 Section 7 states that Protocol Field Compression (PFC) is NOT RECOMMENDED for PPPoE. In practice, pppd does not support negotiating PFC for PPPoE sessions, and the flow dissector driver has assumed an uncompressed frame until the blamed commit.
During the review process of that commit [1], support for PFC is suggested. However, having a compressed (1-byte) protocol field means the subsequent PPP payload is shifted by one byte, causing 4-byte misalignment for the network header and an unaligned access exception on some architectures.
The exception can be reproduced by sending a PPPoE PFC frame to an ethernet interface of a MIPS board, with RPS enabled, even if no PPPoE session is active on that interface:
$ 0 : 00000000 80c40000 00000000 85144817 $ 4 : 00000008 00000100 80a75758 81dc9bb8 $ 8 : 00000010 8087ae2c 0000003d 00000000 $12 : 000000e0 00000039 00000000 00000000 $16 : 85043240 80a75758 81dc9bb8 00006488 $20 : 0000002f 00000007 85144810 80a70000 $24 : 81d1bda0 00000000 $28 : 81dc8000 81dc9aa8 00000000 805ead08 Hi : 00009d51 Lo : 2163358a epc : 805e91f0 __skb_flow_dissect+0x1b0/0x1b50 ra : 805ead08 __skb_get_hash_net+0x74/0x12c Status: 11000403 KERNEL EXL IE Cause : 40800010 (ExcCode 04) BadVA : 85144817 PrId : 0001992f (MIPS 1004Kc) Call Trace: [<805e91f0>] __skb_flow_dissect+0x1b0/0x1b50 [<805ead08>] __skb_get_hash_net+0x74/0x12c [<805ef330>] get_rps_cpu+0x1b8/0x3fc [<805fca70>] netif_receive_skb_list_internal+0x324/0x364 [<805fd120>] napi_complete_done+0x68/0x2a4 [<8058de5c>] mtk_napi_rx+0x228/0xfec [<805fd398>] __napi_poll+0x3c/0x1c4 [<805fd754>] napi_threaded_poll_loop+0x234/0x29c [<805fd848>] napi_threaded_poll+0x8c/0xb0 [<80053544>] kthread+0x104/0x12c [<80002bd8>] ret_from_kernel_thread+0x14/0x1c
Code: 02d51821 1060045b 00000000 <8c640000> 3084000f 2c820005 144001a2 00042080 8e220000
To reduce the attack surface and maintain performance, do not process PPPoE PFC frames.
[1] https://lore.kernel.org/r/[email protected]
--- net/core/flow_dissector.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
net/core/flow_dissector.c +5 -8
@@ -1270,16 +1270,13 @@ bool __skb_flow_dissect(const struct net *net,break ; } -/* least significant bit of the most significant octet -* indicates if protocol field was compressed +/* PFC (compressed 1-byte protocol) frames are not processed. +* A compressed protocol field has the least significant bit of +* the most significant octet set, which will fail the following +* ppp_proto_is_valid(), returning FLOW_DISSECT_RET_OUT_BAD. */ ppp_proto =ntohs (hdr->proto); -if (ppp_proto &0x0100 ) { - ppp_proto = ppp_proto >>8 ; - nhoff +=PPPOE_SES_HLEN -1 ; - }else { - nhoff +=PPPOE_SES_HLEN ; - } + nhoff +=PPPOE_SES_HLEN ;if (ppp_proto ==PPP_IP ) { proto =htons (ETH_P_IP );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 295/969 net/sched: sch_red: Replace direct dequeue call with peek and qdisc_dequeue_peeked
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jamal Hadi Salim <[email protected]>
commit 458d5615272d3de535748342eb68ca492343048c upstream.
When red qdisc has children (eg qfq qdisc) whose peek() callback is qdisc_peek_dequeued(), we could get a kernel panic. When the parent of such qdiscs (eg illustrated in patch #3 as tbf) wants to retrieve an skb from its child (red in this case), it will do the following:
1a. do a peek() - and when sensing there's an skb the child can offer, then
- the child in this case(red) calls its child's (qfq) peek. qfq does the right thing and will return the gso_skb queue packet.
Note: if there wasnt a gso_skb entry then qfq will store it there.
1b. invoke a dequeue() on the child (red). And herein lies the problem.
- red will call the child's dequeue() which will essentially just try to grab something of qfq's queue.
[ 78.667668][ T363] KASAN: null-ptr-deref in range [0x0000000000000048-0x000000000000004f] [ 78.667927][ T363] CPU: 1 UID: 0 PID: 363 Comm: ping Not tainted 7.1.0-rc1-00033-g46f74a3f7d57-dirty #790 PREEMPT(full) [ 78.668263][ T363] Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011 [ 78.668486][ T363] RIP: 0010:qfq_dequeue+0x446/0xc90 [sch_qfq] [ 78.668718][ T363] Code: 54 c0 e8 dd 90 00 f1 48 c7 c7 e0 03 54 c0 48 89 de e8 ce 90 00 f1 48 8d 7b 48 b8 ff ff 37 00 48 89 fa 48 c1 e0 2a 48 c1 ea 03 <80> 3c 02 00 74 05 e8 ef a1 e1 f1 48 8b 7b 48 48 8d 54 24 58 48 8d [ 78.669312][ T363] RSP: 0018:ffff88810de573e0 EFLAGS: 00010216 [ 78.669533][ T363] RAX: dffffc0000000000 RBX: 0000000000000000 RCX: 0000000000000000 [ 78.669790][ T363] RDX: 0000000000000009 RSI: 0000000000000004 RDI: 0000000000000048 [ 78.670044][ T363] RBP: ffff888110dc4000 R08: ffffffffb1b0885a R09: fffffbfff6ba9078 [ 78.670297][ T363] R10: 0000000000000003 R11: ffff888110e31c80 R12: 0000001880000000 [ 78.670560][ T363] R13: ffff888110dc4150 R14: ffff888110dc42b8 R15: 0000000000000200 [ 78.670814][ T363] FS: 00007f66a8f09c40(0000) GS:ffff888163428000(0000) knlGS:0000000000000000 [ 78.671110][ T363] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 78.671324][ T363] CR2: 000055db4c6a30a8 CR3: 000000010da67000 CR4: 0000000000750ef0 [ 78.671585][ T363] PKRU: 55555554 [ 78.671713][ T363] Call Trace: [ 78.671843][ T363] <TASK> [ 78.671936][ T363] ? __pfx_qfq_dequeue+0x10/0x10 [sch_qfq] [ 78.672148][ T363] ? __pfx__printk+0x10/0x10 [ 78.672322][ T363] ? srso_alias_return_thunk+0x5/0xfbef5 [ 78.672496][ T363] ? lockdep_hardirqs_on_prepare+0xa8/0x1a0 [ 78.672706][ T363] ? srso_alias_return_thunk+0x5/0xfbef5 [ 78.672875][ T363] ? trace_hardirqs_on+0x19/0x1a0 [ 78.673047][ T363] red_dequeue+0x65/0x270 [sch_red] [ 78.673217][ T363] ? srso_alias_return_thunk+0x5/0xfbef5 [ 78.673385][ T363] tbf_dequeue.cold+0xb0/0x70c [sch_tbf] [ 78.673566][ T363] __qdisc_run+0x169/0x1900
The right thing to do in #1b is to grab the skb off gso_skb queue. This patchset fixes that issue by changing #1b to use qdisc_dequeue_peeked() method instead.
--- net/sched/sch_red.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/sched/sch_red.c +1 -1
@@ -153,7 +153,7 @@ static struct sk_buff *red_dequeue(strucstruct red_sched_data *q =qdisc_priv (sch);struct Qdisc *child = q->qdisc; - skb = child->dequeue (child); + skb =qdisc_dequeue_peeked (child);if (skb) {qdisc_bstats_update (sch, skb);qdisc_qstats_backlog_dec (sch, skb);
Greg Kroah-Hartman
maintainerPATCH 296/969 Bluetooth: hci_sync: Remove remaining dependencies of hci_request
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luiz Augusto von Dentz <[email protected]>
[ Upstream commit f2d89775358606c7ab6b6b6c4a02fe1e8cd270b1 ]
This removes the dependencies of hci_req_init and hci_request_cancel_all from hci_sync.c.
--- include/net/bluetooth/hci_sync.h | 17 +++++++++++++++++ net/bluetooth/hci_request.h | 21 --------------------- net/bluetooth/hci_sync.c | 14 +++++++++++--- 3 files changed, 28 insertions(+), 24 deletions(-)
include/net/bluetooth/hci_sync.h +17 -0
@@ -5,6 +5,23 @@* Copyright (C) 2021 Intel Corporation */ +#define HCI_REQ_DONE 0 +#define HCI_REQ_PEND 1 +#define HCI_REQ_CANCELED 2 + +#define hci_req_sync_lock (hdev) mutex_lock(&hdev->req_lock) +#define hci_req_sync_unlock (hdev) mutex_unlock(&hdev->req_lock) + +struct hci_request { +struct hci_dev *hdev; +struct sk_buff_head cmd_q; + +/* If something goes wrong when building the HCI request, the error +* value is stored in this field. +*/ +int err; +}; +typedef int (*hci_cmd_sync_work_func_t )(struct hci_dev *hdev,void *data);typedef void (*hci_cmd_sync_work_destroy_t )(struct hci_dev *hdev,void *data,int err);
net/bluetooth/hci_request.h +0 -21
@@ -22,27 +22,6 @@#include <asm/unaligned.h> -#define HCI_REQ_DONE 0 -#define HCI_REQ_PEND 1 -#define HCI_REQ_CANCELED 2 - -#define hci_req_sync_lock (hdev) mutex_lock(&hdev->req_lock) -#define hci_req_sync_unlock (hdev) mutex_unlock(&hdev->req_lock) - -#define HCI_REQ_DONE 0 -#define HCI_REQ_PEND 1 -#define HCI_REQ_CANCELED 2 - -struct hci_request { -struct hci_dev *hdev; -struct sk_buff_head cmd_q; - -/* If something goes wrong when building the HCI request, the error -* value is stored in this field. -*/ -int err; -}; -void hci_req_init (struct hci_request *req,struct hci_dev *hdev);void hci_req_purge (struct hci_request *req);bool hci_req_status_pend (struct hci_dev *hdev);
net/bluetooth/hci_sync.c +11 -3
@@ -11,7 +11,6 @@#include <net/bluetooth/hci_core.h> #include <net/bluetooth/mgmt.h> -#include "hci_request.h" #include "hci_codec.h" #include "hci_debugfs.h" #include "smp.h"
@@ -142,6 +141,13 @@ static int hci_cmd_sync_run(struct hci_request *req)return 0 ; } +static void hci_request_init (struct hci_request *req,struct hci_dev *hdev) +{ +skb_queue_head_init (&req->cmd_q); + req->hdev = hdev; + req->err =0 ; +} +/* This function requires the caller holds hdev->req_lock. */ struct sk_buff *__hci_cmd_sync_sk(struct hci_dev *hdev, u16 opcode, u32 plen, const void *param, u8 event, u32 timeout,
@@ -153,7 +159,7 @@ struct sk_buff *__hci_cmd_sync_sk(struct hci_dev *hdev, u16 opcode, u32 plen,bt_dev_dbg (hdev,"Opcode 0x%4.4x" , opcode); -hci_req_init (&req, hdev); +hci_request_init (&req, hdev);hci_cmd_sync_add (&req, opcode, plen, param, event, sk);
@@ -5188,7 +5194,9 @@ int hci_dev_close_sync(struct hci_dev *hdev)cancel_delayed_work (&hdev->le_scan_disable);cancel_delayed_work (&hdev->le_scan_restart); -hci_request_cancel_all (hdev); +hci_cmd_sync_cancel_sync (hdev,ENODEV ); + +cancel_interleave_scan (hdev);if (hdev->adv_instance_timeout) {cancel_delayed_work_sync (&hdev->adv_instance_expire);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 297/969 Bluetooth: btintel: serialize btintel_hw_error() with hci_req_sync_lock
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit 94d8e6fe5d0818e9300e514e095a200bd5ff93ae ]
btintel_hw_error() issues two __hci_cmd_sync() calls (HCI_OP_RESET and Intel exception-info retrieval) without holding hci_req_sync_lock(). This lets it race against hci_dev_do_close() -> btintel_shutdown_combined(), which also runs __hci_cmd_sync() under the same lock. When both paths manipulate hdev->req_status/req_rsp concurrently, the close path may free the response skb first, and the still-running hw_error path hits a slab-use-after-free in kfree_skb().
Wrap the whole recovery sequence in hci_req_sync_lock/unlock so it is serialized with every other synchronous HCI command issuer.
Below is the data race report and the kasan report:
BUG: data-race in __hci_cmd_sync_sk / btintel_shutdown_combined
read of hdev->req_rsp at net/bluetooth/hci_sync.c:199 by task kworker/u17:1/83:
__hci_cmd_sync_sk+0x12f2/0x1c30 net/bluetooth/hci_sync.c:200 __hci_cmd_sync+0x55/0x80 net/bluetooth/hci_sync.c:223 btintel_hw_error+0x114/0x670 drivers/bluetooth/btintel.c:254 hci_error_reset+0x348/0xa30 net/bluetooth/hci_core.c:1030
write/free by task ioctl/22580:
btintel_shutdown_combined+0xd0/0x360
drivers/bluetooth/btintel.c:3648
hci_dev_close_sync+0x9ae/0x2c10 net/bluetooth/hci_sync.c:5246
hci_dev_do_close+0x232/0x460 net/bluetooth/hci_core.c:526
BUG: KASAN: slab-use-after-free in
sk_skb_reason_drop+0x43/0x380 net/core/skbuff.c:1202
Read of size 4 at addr ffff888144a738dc
by task kworker/u17:1/83:
__hci_cmd_sync_sk+0x12f2/0x1c30 net/bluetooth/hci_sync.c:200
__hci_cmd_sync+0x55/0x80 net/bluetooth/hci_sync.c:223
btintel_hw_error+0x186/0x670 drivers/bluetooth/btintel.c:260--- drivers/bluetooth/btintel.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/bluetooth/btintel.c +8 -3
@@ -225,11 +225,13 @@ static void btintel_hw_error(struct hci_dev *hdev, u8 code)bt_dev_err (hdev,"Hardware error 0x%2.2x" , code); +hci_req_sync_lock (hdev); + skb =__hci_cmd_sync (hdev,HCI_OP_RESET ,0 ,NULL ,HCI_INIT_TIMEOUT );if (IS_ERR (skb)) {bt_dev_err (hdev,"Reset after hardware error failed (%ld)" ,PTR_ERR (skb)); -return ; + goto unlock; }kfree_skb (skb);
@@ -237,18 +239,21 @@ static void btintel_hw_error(struct hci_dev *hdev, u8 code)if (IS_ERR (skb)) {bt_dev_err (hdev,"Retrieving Intel exception info failed (%ld)" ,PTR_ERR (skb)); -return ; + goto unlock; }if (skb->len !=13 ) {bt_dev_err (hdev,"Exception info size mismatch" );kfree_skb (skb); -return ; + goto unlock; }bt_dev_err (hdev,"Exception info %s" , (char *)(skb->data +1 ));kfree_skb (skb); + +unlock: +hci_req_sync_unlock (hdev); }int btintel_version_info (struct hci_dev *hdev,struct intel_version *ver)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 298/969 ice: Fix memory leak in ice_set_ringparam()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zilin Guan <[email protected]>
[ Upstream commit fe868b499d16f55bbeea89992edb98043c9de416 ]
In ice_set_ringparam, tx_rings and xdp_rings are allocated before rx_rings. If the allocation of rx_rings fails, the code jumps to the done label leaking both tx_rings and xdp_rings. Furthermore, if the setup of an individual Rx ring fails during the loop, the code jumps to the free_tx label which releases tx_rings but leaks xdp_rings.
Fix this by introducing a free_xdp label and updating the error paths to ensure both xdp_rings and tx_rings are properly freed if rx_rings allocation or setup fails.
Compile tested only. Issue found using a prototype static analysis tool and code review.
--- drivers/net/ethernet/intel/ice/ice_ethtool.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/ice/ice_ethtool.c +9 -2
@@ -2891,7 +2891,7 @@ ice_set_ringparam(struct net_device *netdev, struct ethtool_ringparam *ring, rx_rings =kcalloc (vsi->num_rxq,sizeof (*rx_rings),GFP_KERNEL );if (!rx_rings) { err = -ENOMEM ; - goto done; + goto free_xdp; }ice_for_each_rxq (vsi, i) {
@@ -2921,7 +2921,7 @@ ice_set_ringparam(struct net_device *netdev, struct ethtool_ringparam *ring, }kfree (rx_rings); err = -ENOMEM ; - goto free_tx; + goto free_xdp; } }
@@ -2972,6 +2972,13 @@ ice_set_ringparam(struct net_device *netdev, struct ethtool_ringparam *ring, } goto done; +free_xdp: +if (xdp_rings) { +ice_for_each_xdp_txq (vsi, i) +ice_free_tx_ring (&xdp_rings[i]); +kfree (xdp_rings); + } + free_tx:/* error cleanup if the Rx allocations failed after getting Tx */ if (tx_rings) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 299/969 exit: prevent preemption of oopsing TASK_DEAD task
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jann Horn <[email protected]>
commit c1fa0bb633e4a6b11e83ffc57fa5abe8ebb87891 upstream.
When an already-exiting task oopses, make_task_dead() currently calls do_task_dead() with preemption enabled. That is forbidden:do_task_dead() calls __schedule(), which has a comment saying "WARNING:
must be called with preemption disabled!".
If an oopsing task is preempted in do_task_dead(), between becoming TASK_DEAD and entering the scheduler explicitly, bad things happen:finish_task_switch() assumes that once the scheduler has switched away from a TASK_DEAD task, the task can never run again and its stack is no longer needed; but that assumption apparently doesn't hold if the dead task was preempted (the SM_PREEMPT case).
This means that the scheduler ends up repeatedly dropping references on the dead task's stack, which can lead to use-after-free or double-free of the entire task stack; in other words, two tasks can end up running on the same stack, resulting in various kinds of memory corruption.
(This does not just affect "recursively oopsing" tasks; it is enough to oops once during task exit, for example in a file_operations::release handler)
--- kernel/exit.c | 1 + 1 file changed, 1 insertion(+)
kernel/exit.c +1 -0
@@ -979,6 +979,7 @@ void __noreturn make_task_dead(int signrfutex_exit_recursive (tsk); tsk->exit_state =EXIT_DEAD ;refcount_inc (&tsk->rcu_users); +preempt_disable ();do_task_dead (); }
Greg Kroah-Hartman
maintainerPATCH 300/969 wifi: mt76: mt7921: fix a potential clc buffer length underflow
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leon Yen <[email protected]>
commit 5373f8b19e568b5c217832b9bbef165bd2b2df14 upstream.
The buf_len is used to limit the iterations for retrieving the country power setting and may underflow under certain conditions due to changes in the power table in CLC.
This underflow leads to an almost infinite loop or an invalid power setting resulting in driver initialization failure.
--- drivers/net/wireless/mediatek/mt76/mt7921/mcu.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7921/mcu.c +3 -0
@@ -1054,6 +1054,9 @@ int __mt7921_mcu_set_clc(struct mt7921_du16 len =le16_to_cpu (rule->len);u16 offset = len +sizeof (*rule); +if (buf_len < offset) +break ; + pos += offset; buf_len -= offset; if (rule->alpha2[0] != alpha2[0] ||
Greg Kroah-Hartman
maintainerPATCH 301/969 wifi: b43legacy: enforce bounds check on firmware key index in RX path
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tristan Madani <[email protected]>
commit a035766f970bde2d4298346a31a80685be5c0205 upstream.
Same fix as b43: the firmware-controlled key index in b43legacy_rx() can exceed dev->max_nr_keys. The existing B43legacy_WARN_ON is non-enforcing in production builds, allowing an out-of-bounds read of dev->key[].
Make the check enforcing by dropping the frame for invalid indices.
--- drivers/net/wireless/broadcom/b43legacy/xmit.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/broadcom/b43legacy/xmit.c +2 -1
@@ -476,7 +476,8 @@ void b43legacy_rx(struct b43legacy_wldev* key index, but the ucode passed it slightly different. */ keyidx =b43legacy_kidx_to_raw (dev, keyidx); -B43legacy_WARN_ON (keyidx >= dev->max_nr_keys); +if (B43legacy_WARN_ON (keyidx >= dev->max_nr_keys)) + goto drop;if (dev->key[keyidx].algorithm != B43legacy_SEC_ALGO_NONE) {/* Remove PROTECTED flag to mark it as decrypted. */
Greg Kroah-Hartman
maintainerPATCH 302/969 wifi: rsi: fix kthread lifetime race between self-exit and external-stop
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeongjun Park <[email protected]>
commit db57a1aa54ff68669781976e4edb045e09e2b65b upstream.
RSI driver use both self-exit(kthread_complete_and_exit) and external-stop (kthread_stop) when killing a kthread. Generally, kthread_stop() is called first, and in this case, no particular issues occur.
However, in rare instances where kthread_complete_and_exit() is called first and then kthread_stop() is called, a UAF occurs because the kthread object, which has already exited and been freed, is accessed again.
Therefore, to prevent this with minimal modification, you must remove kthread_stop() and change the code to wait until the self-exit operation is completed.
--- drivers/net/wireless/rsi/rsi_common.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/net/wireless/rsi/rsi_common.h +2 -3
@@ -70,12 +70,11 @@ static inline int rsi_create_kthread(strreturn 0 ; } -static inline int rsi_kill_thread (struct rsi_thread *handle) +static inline void rsi_kill_thread (struct rsi_thread *handle) {atomic_inc (&handle->thread_done);rsi_set_event (&handle->event); - -return kthread_stop (handle->task); +wait_for_completion (&handle->completion); }void rsi_mac80211_detach (struct rsi_hw *hw);
Greg Kroah-Hartman
maintainerPATCH 303/969 wifi: ath5k: do not access array OOB
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiri Slaby (SUSE) <[email protected]>
commit d748603f12baff112caa3ab7d39f50100f010dbd upstream.
Vincent reports:
Quoted 12 lines
The ath5k driver seems to do an array-index-out-of-bounds access as shown by the UBSAN kernel message:
UBSAN: array-index-out-of-bounds in drivers/net/wireless/ath/ath5k/base.c:1741:20 index 4 is out of range for type 'ieee80211_tx_rate [4]' ... Call Trace: <TASK> dump_stack_lvl+0x5d/0x80 ubsan_epilogue+0x5/0x2b __ubsan_handle_out_of_bounds.cold+0x46/0x4b ath5k_tasklet_tx+0x4e0/0x560 [ath5k] tasklet_action_common+0xb5/0x1c0
It is real. 'ts->ts_final_idx' can be 3 on 5212, so:
info->status.rates[ts->ts_final_idx + 1].idx = -1;
with the array defined as:
struct ieee80211_tx_rate rates[IEEE80211_TX_MAX_RATES];
while the size is:
#define IEEE80211_TX_MAX_RATES 4
is indeed bogus.
Set this 'idx = -1' sentinel only if the array index is less than the array size. As mac80211 will not look at rates beyond the size (IEEE80211_TX_MAX_RATES).
Note: The effect of the OOB write is negligible. It just overwrites the next member of info->status, i.e. ack_signal.
--- drivers/net/wireless/ath/ath5k/base.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/ath5k/base.c +2 -1
@@ -1738,7 +1738,8 @@ ath5k_tx_frame_completed(struct ath5k_hw } info->status.rates[ts->ts_final_idx].count = ts->ts_final_retry; - info->status.rates[ts->ts_final_idx +1 ].idx =-1 ; +if (ts->ts_final_idx +1 <IEEE80211_TX_MAX_RATES ) + info->status.rates[ts->ts_final_idx +1 ].idx =-1 ;if (unlikely (ts->ts_status)) { ah->stats.ack_fail++;
Greg Kroah-Hartman
maintainerPATCH 304/969 wifi: b43: enforce bounds check on firmware key index in b43_rx()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tristan Madani <[email protected]>
commit 1f4f78bf8549e6ac4f04fba4176854f3a6e0c332 upstream.
The firmware-controlled key index in b43_rx() can exceed the dev->key[] array size (58 entries). The existing B43_WARN_ON is non-enforcing in production builds, allowing an out-of-bounds read.
Make the B43_WARN_ON check enforcing by dropping the frame when the firmware returns an invalid key index.
--- drivers/net/wireless/broadcom/b43/xmit.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/broadcom/b43/xmit.c +2 -1
@@ -702,7 +702,8 @@ void b43_rx(struct b43_wldev *dev, struc* key index, but the ucode passed it slightly different. */ keyidx =b43_kidx_to_raw (dev, keyidx); -B43_WARN_ON (keyidx >=ARRAY_SIZE (dev->key)); +if (B43_WARN_ON (keyidx >=ARRAY_SIZE (dev->key))) + goto drop;if (dev->key[keyidx].algorithm !=B43_SEC_ALGO_NONE ) { wlhdr_len =ieee80211_hdrlen (fctl);
Greg Kroah-Hartman
maintainerPATCH 305/969 usb: usblp: fix heap leak in IEEE 1284 device ID via short response
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Greg Kroah-Hartman <[email protected]>
commit 7a400c6fe3617e31e690e3f7ca37bb335e0498f3 upstream.
usblp_ctrl_msg() collapses the usb_control_msg() return value to 0/-errno, discarding the actual number of bytes transferred. A broken printer can complete the GET_DEVICE_ID control transfer short and the driver has no way to know.
usblp_cache_device_id_string() reads the 2-byte big-endian length prefix from the response and trusts it (clamped only to the buffer bounds). The buffer is kmalloc(1024) at probe time. A device that sends exactly two bytes (e.g. 0x03 0xFF, claiming a 1023-byte ID) leaves device_id_string[2..1022] holding stale kmalloc heap.
That stale data is then exposed:
- via the ieee1284_id sysfs attribute (sprintf("%s", buf+2), truncated at the first NUL in the stale heap), and
- via the IOCNR_GET_DEVICE_ID ioctl, which copy_to_user()s the full claimed length regardless of NULs, up to 1021 bytes of uninitialized heap, with the leak size chosen by the device.
Fix this up by just zapping the buffer with zeros before each request sent to the device.
--- drivers/usb/class/usblp.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/class/usblp.c +1 -0
@@ -1365,6 +1365,7 @@ static int usblp_cache_device_id_string( {int err, length; +memset (usblp->device_id_string,0 ,USBLP_DEVICE_ID_SIZE ); err =usblp_get_id (usblp,0 , usblp->device_id_string,USBLP_DEVICE_ID_SIZE -1 );if (err <0 ) { dev_dbg(&usblp->intf->dev,
Greg Kroah-Hartman
maintainerPATCH 306/969 usb: usblp: fix uninitialized heap leak via LPGETSTATUS ioctl
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Greg Kroah-Hartman <[email protected]>
commit b38e53cbfb9d84732e5984fbd73e128d592415c5 upstream.
Just like in a previous problem in this driver, usblp_ctrl_msg() will collapse the usb_control_msg() return value to 0/-errno, discarding the actual number of bytes transferred.
Ideally that short command should be detected and error out, but many printers are known to send "incorrect" responses back so we can't just do that.
statusbuf is kmalloc(8) at probe time and never filled before the first LPGETSTATUS ioctl.
usblp_read_status() requests 1 byte. If a malicious printer responds with zero bytes, *statusbuf is one byte of stale kmalloc heap, sign-extended into the local int status, which the LPGETSTATUS path then copy_to_user()s directly to the ioctl caller.
Fix this all by just zapping out the memory buffer when allocated at probe time. If a later call does a short read, the data will be identical to what the device sent it the last time, so there is no "leak" of information happening.
--- drivers/usb/class/usblp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/class/usblp.c +1 -1
@@ -1166,7 +1166,7 @@ static int usblp_probe(struct usb_interf }/* Allocate buffer for printer status */ - usblp->statusbuf =kmalloc (STATUS_BUF_SIZE ,GFP_KERNEL ); + usblp->statusbuf =kzalloc (STATUS_BUF_SIZE ,GFP_KERNEL );if (!usblp->statusbuf) { retval = -ENOMEM ; goto abort;
Greg Kroah-Hartman
maintainerPATCH 307/969 ALSA: usb-audio: Avoid potential endless loop in convert_chmap_v3()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 6e7247d8f5fefeceb0bb9cc80a5388a636b219cd upstream.
The convert_chmap_v3() has a loop with its increment size of cs_desc->wLength, but we forgot to validate cs_desc->wLength itself, which may lead to potential endless loop by a malformed descriptor.
Add a proper size check to abort the loop for plugging the hole.
--- sound/usb/stream.c | 2 ++ 1 file changed, 2 insertions(+)
sound/usb/stream.c +2 -0
@@ -352,6 +352,8 @@ snd_pcm_chmap_elem *convert_chmap_v3(strif (len <sizeof (*cs_desc))break ; cs_len =le16_to_cpu (cs_desc->wLength); +if (cs_len <sizeof (*cs_desc)) +break ;if (len < cs_len)break ; cs_type = cs_desc->bSegmentType;
Greg Kroah-Hartman
maintainerPATCH 308/969 ALSA: usb-audio: Fix UAC3 cluster descriptor size check
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cássio Gabriel <[email protected]>
commit 26265dd69da32d88a88d21987853cec899d9e21f upstream.
The UAC3 cluster descriptor length check in snd_usb_get_audioformat_uac3()was added to make sure that the buffer is large enough for a struct uac3_cluster_header_descriptor before the returned data is cast and used.
However, the check uses sizeof(cluster), where cluster is a pointer, not the size of the descriptor header. This makes the validation depend on the architecture pointer size and does not match the intended object size.
Check against sizeof(*cluster) instead.
--- sound/usb/stream.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/usb/stream.c +1 -1
@@ -993,7 +993,7 @@ snd_usb_get_audioformat_uac3(struct snd_* and request Cluster Descriptor */ wLength =le16_to_cpu (hc_header.wLength); -if (wLength <sizeof (cluster)) +if (wLength <sizeof (*cluster))return NULL ; cluster =kzalloc (wLength,GFP_KERNEL );if (!cluster)
Greg Kroah-Hartman
maintainerPATCH 309/969 USB: omap_udc: DMA: Dont enable burst 4 mode
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aaro Koskinen <[email protected]>
commit 3f91484f6c13c434bd573ca6b6779c26adb0ddab upstream.
Commit 65111084c63d7 ("USB: more omap_udc updates (dma and omap1710)") added setting for DMA burst 4 mode. But I think this should be undone for two reasons:
- It breaks DMA on 15xx boards - transfers just silently stall.
- On newer OMAP1 boards, like Nokia 770 (omap1710), there is no measurable performance impact when testing TCP throughput with g_ether with large 15000 byte MTU size.
It's also worth noting that when the original change was made, the OMAP_DMA_DATA_BURST_4 handling in arch/arm/plat-omap/dma.c was broken, and actually resulted in the same as the OMAP_DMA_DATA_BURST_DIS i.e. burst disabled. This was fixed not until a couple kernel releases later in an unrelated commit 1a8bfa1eb998a ("[ARM] 3142/1: OMAP 2/5: Update files common to omap1 and omap2").
So based on this it seems there was never really a very good reason to enable this burst mode in omap_udc, so remove it now to allow 15xx DMA to work again (it provides 2x throughput compared to PIO mode).
--- drivers/usb/gadget/udc/omap_udc.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/usb/gadget/udc/omap_udc.c +0 -4
@@ -734,8 +734,6 @@ static void dma_channel_claim(struct omaif (status ==0 ) {omap_writew (reg,UDC_TXDMA_CFG );/* EMIFF or SDRC */ -omap_set_dma_src_burst_mode (ep->lch, -OMAP_DMA_DATA_BURST_4 );omap_set_dma_src_data_pack (ep->lch,1 );/* TIPB */ omap_set_dma_dest_params(ep->lch,
@@ -757,8 +755,6 @@ static void dma_channel_claim(struct omaUDC_DATA_DMA , 0, 0);/* EMIFF or SDRC */ -omap_set_dma_dest_burst_mode (ep->lch, -OMAP_DMA_DATA_BURST_4 );omap_set_dma_dest_data_pack (ep->lch,1 ); } }
Greg Kroah-Hartman
maintainerPATCH 310/969 USB: serial: option: add Telit Cinterion LE910Cx compositions
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fabio Porcedda <[email protected]>
commit 100201d349edd226ca3470c894c92dccc67ee7a8 upstream.
Add the following Telit Cinterion LE910Cx compositions:
0x1251: RNDIS + tty (AT/NMEA) + tty (AT) + tty (AT) + tty (SAP)
T: Bus=01 Lev=01 Prnt=21 Port=06 Cnt=01 Dev#=108 Spd=480 MxCh= 0 D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1 P: Vendor=1bc7 ProdID=1251 Rev=03.18 S: Manufacturer=Android S: Product=LE910C1-EU S: SerialNumber=0123456789ABCDEF C: #Ifs= 6 Cfg#= 1 Atr=a0 MxPwr=500mA I: If#= 0 Alt= 0 #EPs= 1 Cls=02(commc) Sub=02 Prot=ff Driver=rndis_host E: Ad=82(I) Atr=03(Int.) MxPS= 8 Ivl=32ms I: If#= 1 Alt= 0 #EPs= 2 Cls=0a(data ) Sub=00 Prot=00 Driver=rndis_host E: Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms I: If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option E: Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=83(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=84(I) Atr=03(Int.) MxPS= 10 Ivl=32ms I: If#= 3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option E: Ad=03(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=85(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=86(I) Atr=03(Int.) MxPS= 10 Ivl=32ms I: If#= 4 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option E: Ad=04(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=87(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=88(I) Atr=03(Int.) MxPS= 10 Ivl=32ms I: If#= 5 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option E: Ad=05(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=89(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=8a(I) Atr=03(Int.) MxPS= 10 Ivl=32ms
0x1253: ECM + tty (AT/NMEA) + tty (AT) + tty (AT) + tty (SAP)
T: Bus=01 Lev=01 Prnt=21 Port=06 Cnt=01 Dev#=121 Spd=480 MxCh= 0 D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1 P: Vendor=1bc7 ProdID=1253 Rev=03.18 S: Manufacturer=Android S: Product=LE910C1-EU S: SerialNumber=0123456789ABCDEF C: #Ifs= 6 Cfg#= 1 Atr=a0 MxPwr=500mA I: If#= 0 Alt= 0 #EPs= 1 Cls=02(commc) Sub=06 Prot=00 Driver=cdc_ether E: Ad=82(I) Atr=03(Int.) MxPS= 16 Ivl=32ms I: If#= 1 Alt= 1 #EPs= 2 Cls=0a(data ) Sub=00 Prot=00 Driver=cdc_ether E: Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms I: If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option E: Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=83(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=84(I) Atr=03(Int.) MxPS= 10 Ivl=32ms I: If#= 3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option E: Ad=03(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=85(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=86(I) Atr=03(Int.) MxPS= 10 Ivl=32ms I: If#= 4 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option E: Ad=04(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=87(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=88(I) Atr=03(Int.) MxPS= 10 Ivl=32ms I: If#= 5 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option E: Ad=05(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=89(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=8a(I) Atr=03(Int.) MxPS= 10 Ivl=32ms
0x1254: tty (AT) + tty (AT)
T: Bus=01 Lev=01 Prnt=21 Port=06 Cnt=01 Dev#=122 Spd=480 MxCh= 0 D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1 P: Vendor=1bc7 ProdID=1254 Rev=03.18 S: Manufacturer=Android S: Product=LE910C1-EU S: SerialNumber=0123456789ABCDEF C: #Ifs= 2 Cfg#= 1 Atr=a0 MxPwr=500mA I: If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option E: Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=82(I) Atr=03(Int.) MxPS= 10 Ivl=32ms I: If#= 1 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option E: Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=83(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=84(I) Atr=03(Int.) MxPS= 10 Ivl=32ms
0x1255: tty (AT/NMEA) + tty (AT) + tty (AT) + tty (SAP)
T: Bus=01 Lev=01 Prnt=21 Port=06 Cnt=01 Dev#=123 Spd=480 MxCh= 0 D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1 P: Vendor=1bc7 ProdID=1255 Rev=03.18 S: Manufacturer=Android S: Product=LE910C1-EU S: SerialNumber=0123456789ABCDEF C: #Ifs= 4 Cfg#= 1 Atr=a0 MxPwr=500mA I: If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option E: Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=82(I) Atr=03(Int.) MxPS= 10 Ivl=32ms I: If#= 1 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option E: Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=83(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=84(I) Atr=03(Int.) MxPS= 10 Ivl=32ms I: If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option E: Ad=03(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=85(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=86(I) Atr=03(Int.) MxPS= 10 Ivl=32ms I: If#= 3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option E: Ad=04(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=87(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=88(I) Atr=03(Int.) MxPS= 10 Ivl=32ms
--- drivers/usb/serial/option.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/usb/serial/option.c +4 -0
@@ -1513,7 +1513,11 @@ static const struct usb_device_id option { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1231, 0xff), /* Telit LE910Cx (RNDIS) */ .driver_info = NCTRL(2) | RSVD(3) }, { USB_DEVICE_AND_INTERFACE_INFO(TELIT_VENDOR_ID, 0x1250, 0xff, 0x00, 0x00) }, /* Telit LE910Cx (rmnet) */ + { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1251, 0xff) }, /* Telit LE910Cx (RNDIS) */ { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1252, 0xff) }, /* Telit LE910Cx (MBIM) */ + { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1253, 0xff) }, /* Telit LE910Cx (ECM) */ + { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1254, 0xff) }, /* Telit LE910Cx */ + { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1255, 0xff) }, /* Telit LE910Cx */ { USB_DEVICE(TELIT_VENDOR_ID, 0x1260), .driver_info = NCTRL(0) | RSVD(1) | RSVD(2) }, { USB_DEVICE(TELIT_VENDOR_ID, 0x1261),
Greg Kroah-Hartman
maintainerPATCH 311/969 usb: ulpi: fix memory leak on ulpi_register() error paths
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felix Gu <[email protected]>
commit 0b9fcab1b8608d429e5f239afb197de928d4de7d upstream.
Commit 01af542392b5 ("usb: ulpi: fix double free in ulpi_register_interface() error path") removed kfree(ulpi) from ulpi_register_interface() to fix a double-free when device_register() fails.
But when ulpi_of_register() or ulpi_read_id() fail before device_register() is called, the ulpi allocation is leaked.
Add kfree(ulpi) on both error paths to properly clean up the allocation.
--- drivers/usb/common/ulpi.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/usb/common/ulpi.c +4 -1
@@ -286,12 +286,15 @@ static int ulpi_register(struct device *ACPI_COMPANION_SET (&ulpi->dev,ACPI_COMPANION (dev)); ret =ulpi_of_register (ulpi); -if (ret) +if (ret) { +kfree (ulpi);return ret; + } ret =ulpi_read_id (ulpi);if (ret) {of_node_put (ulpi->dev.of_node); +kfree (ulpi);return ret; }
Greg Kroah-Hartman
maintainerPATCH 312/969 ALSA: firewire-tascam: Do not drop unread control events
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cássio Gabriel <[email protected]>
commit 0749daa8eb5ab90334aaad3b0671efd7150d43b1 upstream.
tscm_hwdep_read_queue() copies as many queued control events as fit in the userspace buffer. When the buffer is smaller than the current contiguous queue segment, length is rounded down to the number of bytes that can be copied.
However, after copying that shortened length, the code advances pull_pos to the original tail_pos, marking the whole contiguous segment as consumed. Any events between the copied portion and tail_pos are lost.
Limit tail_pos to the position after the entries actually copied before updating pull_pos. When the whole segment fits, this is equivalent to the old tail_pos update; when the buffer is smaller, the remaining events stay queued for the next read.
--- sound/firewire/tascam/tascam-hwdep.c | 1 + 1 file changed, 1 insertion(+)
sound/firewire/tascam/tascam-hwdep.c +1 -0
@@ -73,6 +73,7 @@ static long tscm_hwdep_read_queue(struct length =rounddown (remained,sizeof (*entries));if (length ==0 )break ; + tail_pos = head_pos + length /sizeof (*entries);spin_unlock_irq (&tscm->lock);if (copy_to_user (pos, &entries[head_pos], length))
Greg Kroah-Hartman
maintainerPATCH 313/969 powerpc/kdump: fix KASAN sanitization flag for core_$(BITS).o
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sourabh Jain <[email protected]>
commit b3a97f9484080c6e71db9e803e3cc1bb372a9bc7 upstream.
KASAN instrumentation is intended to be disabled for the kexec core code, but the existing Makefile entry misses the object suffix. As a result, the flag is not applied correctly to core_$(BITS).o.
So when KASAN is enabled, kexec_copy_flush and copy_segments in kexec/core_64.c are instrumented, which can result in accesses to shadow memory via normal address translation paths. Since these run with the MMU disabled, such accesses may trigger page faults (bad_page_fault) that cannot be handled in the kdump path, ultimately causing a hang and preventing the kdump kernel from booting. The same is true for kexec as well, since the same functions are used there.
Update the entry to include the “.o” suffix so that KASAN instrumentation is properly disabled for this object file.
--- arch/powerpc/kexec/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/kexec/Makefile +1 -1
@@ -14,4 +14,4 @@ GCOV_PROFILE_core_$(BITS).o := n KCOV_INSTRUMENT_core_$(BITS).o := n UBSAN_SANITIZE_core_$(BITS).o := n KASAN_SANITIZE_core.o := n -KASAN_SANITIZE_core_$(BITS) := n +KASAN_SANITIZE_core_$(BITS).o := n
Greg Kroah-Hartman
maintainerPATCH 314/969 xfrm: provide message size for XFRM_MSG_MAPPING
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ruijie Li <[email protected]>
commit 28465227c80fe417b4013c432be1f3737cb9f9a3 upstream.
The compat 64=>32 translation path handles XFRM_MSG_MAPPING, but xfrm_msg_min[] does not provide the native payload size for this message type.
Add the missing XFRM_MSG_MAPPING entry so compat translation can size and translate mapping notifications correctly.
--- net/xfrm/xfrm_user.c | 1 + 1 file changed, 1 insertion(+)
net/xfrm/xfrm_user.c +1 -0
@@ -2960,6 +2960,7 @@ const int xfrm_msg_min[XFRM_NR_MSGTYPES] [XFRM_MSG_GETSADINFO - XFRM_MSG_BASE] = sizeof(u32), [XFRM_MSG_NEWSPDINFO - XFRM_MSG_BASE] = sizeof(u32), [XFRM_MSG_GETSPDINFO - XFRM_MSG_BASE] = sizeof(u32), + [XFRM_MSG_MAPPING - XFRM_MSG_BASE] = XMSGSIZE(xfrm_user_mapping), [XFRM_MSG_SETDEFAULT - XFRM_MSG_BASE] = XMSGSIZE(xfrm_userpolicy_default), [XFRM_MSG_GETDEFAULT - XFRM_MSG_BASE] = XMSGSIZE(xfrm_userpolicy_default), };
Greg Kroah-Hartman
maintainerPATCH 315/969 ipv6: xfrm6: release dst on error in xfrm6_rcv_encap()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yilin Zhu <[email protected]>
commit bc0fcb9823cd0894934cf968b525c575833d7078 upstream.
xfrm6_rcv_encap() performs an IPv6 route lookup when the skb does not already have a dst attached. ip6_route_input_lookup() returns a referenced dst entry even when the lookup resolves to an error route.
If dst->error is set, xfrm6_rcv_encap() drops the skb without attaching the dst to the skb and without releasing the reference returned by the lookup. Repeated packets hitting this path therefore leak dst entries.
Release the dst before jumping to the drop path.
--- net/ipv6/xfrm6_protocol.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/ipv6/xfrm6_protocol.c +3 -1
@@ -88,8 +88,10 @@ int xfrm6_rcv_encap(struct sk_buff *skb, dst =ip6_route_input_lookup (dev_net (skb->dev), skb->dev, &fl6, skb, flags); -if (dst->error) +if (dst->error) { +dst_release (dst); goto drop; + }skb_dst_set (skb, dst); }
Greg Kroah-Hartman
maintainerPATCH 316/969 Bluetooth: virtio_bt: clamp rx length before skb_put
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Bommarito <[email protected]>
commit 21bd244b6de5d2fe1063c23acc93fbdd2b20d112 upstream.
virtbt_rx_work() calls skb_put(skb, len) where len comes directly from virtqueue_get_buf() with no validation against the buffer we posted to the device. The RX skb is allocated in virtbt_add_inbuf() and exposed to virtio as exactly 1000 bytes via sg_init_one().
Checking len against skb_tailroom(skb) is not sufficient because alloc_skb() can leave more tailroom than the 1000 bytes actually handed to the device. A malicious or buggy backend can therefore report used.len between 1001 and skb_tailroom(skb), causing skb_put() to include uninitialized kernel heap bytes that were never written by the device.
The same path also accepts len == 0, in which case skb_put(skb, 0) leaves the skb empty but virtbt_rx_handle() still reads the pkt_type byte from skb->data, consuming uninitialized memory.
Define VIRTBT_RX_BUF_SIZE once and reuse it in alloc_skb() and sg_init_one(), and gate virtbt_rx_work() on that same constant so the bound checked matches the buffer actually exposed to the device. Reject used.len == 0 in the same gate so an empty completion can no longer reach virtbt_rx_handle().
Use bt_dev_err_ratelimited() because the length value comes from an untrusted backend that can otherwise flood the kernel log.
Same class of bug as commit c04db81cd028 ("net/9p: Fix buffer overflow in USB transport layer"), which hardened the USB 9p transport against unchecked device-reported length.
--- drivers/bluetooth/virtio_bt.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
drivers/bluetooth/virtio_bt.c +12 -4
@@ -12,6 +12,7 @@#include <net/bluetooth/hci_core.h> #define VERSION "0.1" +#define VIRTBT_RX_BUF_SIZE 1000enum {VIRTBT_VQ_TX ,
@@ -33,11 +34,11 @@ static int virtbt_add_inbuf(struct virtistruct sk_buff *skb;int err; - skb =alloc_skb (1000 ,GFP_KERNEL ); + skb =alloc_skb (VIRTBT_RX_BUF_SIZE ,GFP_KERNEL );if (!skb)return -ENOMEM ; -sg_init_one (sg, skb->data,1000 ); +sg_init_one (sg, skb->data,VIRTBT_RX_BUF_SIZE ); err =virtqueue_add_inbuf (vq, sg,1 , skb,GFP_KERNEL );if (err <0 ) {
@@ -219,8 +220,15 @@ static void virtbt_rx_work(struct work_sif (!skb)return ; -skb_put (skb, len); -virtbt_rx_handle (vbt, skb); +if (!len || len >VIRTBT_RX_BUF_SIZE ) { +bt_dev_err_ratelimited (vbt->hdev, +"rx reply len %u outside [1, %u]\n" , + len,VIRTBT_RX_BUF_SIZE ); +kfree_skb (skb); + }else { +skb_put (skb, len); +virtbt_rx_handle (vbt, skb); + }if (virtbt_add_inbuf (vbt) <0 )return ;
Greg Kroah-Hartman
maintainerPATCH 317/969 Bluetooth: virtio_bt: validate rx pkt_type header length
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Bommarito <[email protected]>
commit daf23014e5d975e72ea9c02b5160d3fcf070ea47 upstream.
virtbt_rx_handle() reads the leading pkt_type byte from the RX skb and forwards the remainder to hci_recv_frame() for every event/ACL/SCO/ISO type, without checking that the remaining payload is at least the fixed HCI header for that type.
After the preceding patch bounds the backend-supplied used.len to [1, VIRTBT_RX_BUF_SIZE], a one-byte completion still reaches hci_recv_frame() with skb->len already pulled to 0. If the byte happened to be HCI_ACLDATA_PKT, the ACL-vs-ISO classification fast-path in hci_dev_classify_pkt_type() dereferences hci_acl_hdr(skb)->handle whenever the HCI device has an active CIS_LINK, BIS_LINK, or PA_LINK connection, reading two bytes of uninitialized RX-buffer data. The same hazard exists for every packet type the driver accepts because none of the switch cases in virtbt_rx_handle() check skb->len against the per-type minimum HCI header size before handing the frame to the core.
After stripping pkt_type, require skb->len to cover the fixed header size for the selected type (event 2, ACL 4, SCO 3, ISO 4) before calling hci_recv_frame(); drop ratelimited otherwise. Unknown pkt_type values still take the original kfree_skb() default path.
Use bt_dev_err_ratelimited() because both the length and pkt_type values come from an untrusted backend that can otherwise flood the kernel log.
--- drivers/bluetooth/virtio_bt.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-)
drivers/bluetooth/virtio_bt.c +20 -3
@@ -190,6 +190,7 @@ static int virtbt_shutdown_generic(strucstatic void virtbt_rx_handle (struct virtio_bluetooth *vbt,struct sk_buff *skb) { +size_t min_hdr;__u8 pkt_type; pkt_type = *((__u8 *) skb->data);
@@ -197,16 +198,32 @@ static void virtbt_rx_handle(struct virtswitch (pkt_type) {case HCI_EVENT_PKT : + min_hdr =sizeof (struct hci_event_hdr ); +break ;case HCI_ACLDATA_PKT : + min_hdr =sizeof (struct hci_acl_hdr ); +break ;case HCI_SCODATA_PKT : + min_hdr =sizeof (struct hci_sco_hdr ); +break ;case HCI_ISODATA_PKT : -hci_skb_pkt_type (skb) = pkt_type; -hci_recv_frame (vbt->hdev, skb); + min_hdr =sizeof (struct hci_iso_hdr );break ;default :kfree_skb (skb); -break ; +return ; } + +if (skb->len < min_hdr) { +bt_dev_err_ratelimited (vbt->hdev, +"rx pkt_type 0x%02x payload %u < hdr %zu\n" , + pkt_type, skb->len, min_hdr); +kfree_skb (skb); +return ; + } + +hci_skb_pkt_type (skb) = pkt_type; +hci_recv_frame (vbt->hdev, skb); }static void virtbt_rx_work (struct work_struct *work)
Greg Kroah-Hartman
maintainerPATCH 318/969 Bluetooth: L2CAP: Fix null-ptr-deref in l2cap_sock_new_connection_cb()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Siwei Zhang <[email protected]>
commit 0a120d96166301d7a95be75b52f843837dbd1219 upstream.
Add the same NULL guard already present inl2cap_sock_resume_cb() and l2cap_sock_ready_cb().
--- net/bluetooth/l2cap_sock.c | 3 +++ 1 file changed, 3 insertions(+)
net/bluetooth/l2cap_sock.c +3 -0
@@ -1500,6 +1500,9 @@ static struct l2cap_chan *l2cap_sock_new {struct sock *sk, *parent = chan->data; +if (!parent) +return NULL ; +lock_sock (parent);/* Check for backlog size */
Greg Kroah-Hartman
maintainerPATCH 319/969 Bluetooth: L2CAP: Fix null-ptr-deref in l2cap_sock_state_change_cb()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Siwei Zhang <[email protected]>
commit 2ff1a41a912de8517b4482e946dd951b7d80edbf upstream.
Add the same NULL guard already present inl2cap_sock_resume_cb() and l2cap_sock_ready_cb().
--- net/bluetooth/l2cap_sock.c | 3 +++ 1 file changed, 3 insertions(+)
net/bluetooth/l2cap_sock.c +3 -0
@@ -1663,6 +1663,9 @@ static void l2cap_sock_state_change_cb(s {struct sock *sk = chan->data; +if (!sk) +return ; + sk->sk_state = state;if (err)
Greg Kroah-Hartman
maintainerPATCH 320/969 spi: zynqmp-gqspi: fix controller deregistration
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 6895fc4faafc9082e15e4e624b23dd5f0c98feb5 upstream.
Make sure to deregister the controller before disabling underlying resources like clocks during driver unbind.
--- drivers/spi/spi-zynqmp-gqspi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/spi/spi-zynqmp-gqspi.c +3 -1
@@ -1202,7 +1202,7 @@ static int zynqmp_qspi_probe(struct plat ctlr->dev.of_node = np; ctlr->auto_runtime_pm = true; - ret =devm_spi_register_controller (&pdev->dev, ctlr); + ret =spi_register_controller (ctlr);if (ret) {dev_err (&pdev->dev,"spi_register_controller failed\n" ); goto clk_dis_all;
@@ -1243,6 +1243,8 @@ static int zynqmp_qspi_remove(struct plapm_runtime_get_sync (&pdev->dev); +spi_unregister_controller (xqspi->ctlr); +zynqmp_gqspi_write (xqspi,GQSPI_EN_OFST ,0x0 );pm_runtime_disable (&pdev->dev);
Greg Kroah-Hartman
maintainerPATCH 321/969 staging: vme_user: fix root device leak on init failure
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 32c91e8ee039777d0b95b914633fc6a42607959c upstream.
Make sure to deregister and free the root device in case module initialisation fails.
--- drivers/staging/vme_user/vme_fake.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/staging/vme_user/vme_fake.c +2 -0
@@ -1242,6 +1242,8 @@ err_master: err_driver:kfree (fake_bridge); err_struct: +root_device_unregister (vme_root); +return retval; }
Greg Kroah-Hartman
maintainerPATCH 322/969 fanotify: fix false positive on permission events
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miklos Szeredi <[email protected]>
commit 7746e3bd4cc19b5092e00d32d676e329bfcb6900 upstream.
fsnotify_get_mark_safe() may return false for a mark on an unrelated group, which results in bypassing the permission check.
Fix by skipping over detached marks that are not in the current group.
--- fs/notify/fsnotify.c | 2 +- fs/notify/mark.c | 18 +++++++++++------- include/linux/fsnotify_backend.h | 1 + 3 files changed, 13 insertions(+), 8 deletions(-)
fs/notify/fsnotify.c +1 -1
@@ -398,7 +398,7 @@ static struct fsnotify_mark *fsnotify_fi return hlist_entry_safe(node, struct fsnotify_mark, obj_list); } -static struct fsnotify_mark *fsnotify_next_mark (struct fsnotify_mark *mark) +struct fsnotify_mark *fsnotify_next_mark (struct fsnotify_mark *mark) {struct hlist_node *node =NULL ;
fs/notify/mark.c +11 -7
@@ -380,9 +380,6 @@ EXPORT_SYMBOL_GPL(fsnotify_put_mark);*/ static bool fsnotify_get_mark_safe (struct fsnotify_mark *mark) { -if (!mark) -return true; -if (refcount_inc_not_zero (&mark->refcnt)) {spin_lock (&mark->lock);if (mark->flags &FSNOTIFY_MARK_FLAG_ATTACHED ) {
@@ -423,15 +420,22 @@ bool fsnotify_prepare_user_wait(struct fint type;fsnotify_foreach_iter_type (type) { +struct fsnotify_mark *mark = iter_info->marks[type]; +/* This can fail if mark is being removed */ -if (!fsnotify_get_mark_safe (iter_info->marks[type])) { -__release (&fsnotify_mark_srcu); - goto fail; +while (mark && !fsnotify_get_mark_safe (mark)) { +if (mark->group == iter_info->current_group) { +__release (&fsnotify_mark_srcu); + goto fail; + } +/* This is a mark in an unrelated group, skip */ + mark =fsnotify_next_mark (mark); + iter_info->marks[type] = mark; } }/* -* Now that both marks are pinned by refcount in the inode / vfsmount +* Now that all marks are pinned by refcount in the inode / vfsmount / etc * lists, we can drop SRCU lock, and safely resume the list iteration * once userspace returns. */
include/linux/fsnotify_backend.h +1 -0
@@ -820,6 +820,7 @@ static inline void fsnotify_clear_sb_mar }extern void fsnotify_get_mark (struct fsnotify_mark *mark);extern void fsnotify_put_mark (struct fsnotify_mark *mark); +struct fsnotify_mark *fsnotify_next_mark (struct fsnotify_mark *mark);extern void fsnotify_finish_user_wait (struct fsnotify_iter_info *iter_info);extern bool fsnotify_prepare_user_wait (struct fsnotify_iter_info *iter_info);
Greg Kroah-Hartman
maintainerPATCH 323/969 net: rtnetlink: zero ifla_vf_broadcast to avoid stack infoleak in rtnl_fill_vfinfo
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kai Zen <[email protected]>
commit 4b9e327991815e128ad3af75c3a04630a63ce3e0 upstream.
rtnl_fill_vfinfo() declares struct ifla_vf_broadcast on the stack without initialisation:
struct ifla_vf_broadcast vf_broadcast;
The struct contains a single fixed 32-byte field:
/* include/uapi/linux/if_link.h */
struct ifla_vf_broadcast {
__u8 broadcast[32];
};The function then copies dev->broadcast into it using dev->addr_len as the length:
memcpy(vf_broadcast.broadcast, dev->broadcast, dev->addr_len);
On Ethernet devices (the overwhelming majority of SR-IOV NICs) dev->addr_len is 6, so only the first 6 bytes of broadcast[] are written. The remaining 26 bytes retain whatever was previously on the kernel stack. The full struct is then handed to userspace via:
nla_put(skb, IFLA_VF_BROADCAST,
sizeof(vf_broadcast), &vf_broadcast)
leaking up to 26 bytes of uninitialised kernel stack per VF per RTM_GETLINK request, repeatable.
The other vf_* structs in the same function are explicitly zeroed for exactly this reason - see the memset() calls for ivi, vf_vlan_info, node_guid and port_guid a few lines above. vf_broadcast was simply missed when it was added.
Reachability: any unprivileged local process can open AF_NETLINK / NETLINK_ROUTE without capabilities and send RTM_GETLINK with an IFLA_EXT_MASK attribute carrying RTEXT_FILTER_VF. The kernel walks each VF and emits IFLA_VF_BROADCAST, leaking 26 bytes of stack per VF per request. Stack residue at this call site can include return addresses and transient sensitive data; KASAN with stack instrumentation, or KMSAN, will flag the nla_put() when reproduced.
Zero the on-stack struct before the partial memcpy, matching the existing pattern used for the other vf_* structs in the same function.
--- net/core/rtnetlink.c | 1 + 1 file changed, 1 insertion(+)
net/core/rtnetlink.c +1 -0
@@ -1346,6 +1346,7 @@ static noinline_for_stack int rtnl_fill_ port_guid.vf = ivi.vf;memcpy (vf_mac.mac, ivi.mac,sizeof (ivi.mac)); +memset (&vf_broadcast,0 ,sizeof (vf_broadcast));memcpy (vf_broadcast.broadcast, dev->broadcast, dev->addr_len); vf_vlan.vlan = ivi.vlan; vf_vlan.qos = ivi.qos;
Greg Kroah-Hartman
maintainerPATCH 324/969 sound: ua101: fix division by zero at probe
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: SeungJu Cheon <[email protected]>
commit d1f73f169c1014463b5060e3f60813e13ddc7b87 upstream.
Add a missing sanity check for bNrChannels in detect_usb_format() to prevent a division by zero in playback_urb_complete() and capture_urb_complete().
USB core does not validate class-specific descriptor fields such as bNrChannels, so drivers must verify them before use. If a device provides bNrChannels = 0, frame_bytes becomes zero and is later used as a divisor in the URB completion handlers, leading to a kernel crash.
--- sound/usb/misc/ua101.c | 7 +++++++ 1 file changed, 7 insertions(+)
sound/usb/misc/ua101.c +7 -0
@@ -994,6 +994,13 @@ static int detect_usb_format(struct ua10 ua->capture.channels = fmt_capture->bNrChannels; ua->playback.channels = fmt_playback->bNrChannels; +if (!ua->capture.channels || !ua->playback.channels) { +dev_err (&ua->dev->dev, +"invalid channel count: capture %u, playback %u\n" , + ua->capture.channels, ua->playback.channels); +return -EINVAL ; + } + ua->capture.frame_bytes = fmt_capture->bSubframeSize * ua->capture.channels; ua->playback.frame_bytes =
Greg Kroah-Hartman
maintainerPATCH 325/969 ip6_gre: Use cached t->net in ip6erspan_changelink().
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maoyi Xie <[email protected]>
commit 1d324c2f43f70c965f25c58cc3611c779adbe47e upstream.
After commit 5e72ce3e3980 ("net: ipv6: Use link netns in newlink() of rtnl_link_ops"), ip6erspan_newlink() correctly resolves the per-netns ip6gre hash via link_net. ip6erspan_changelink() was not converted in that series and still uses dev_net(dev), which diverges from the device's creation netns after IFLA_NET_NS_FD migration.
This re-inserts the tunnel into the wrong per-netns hash. The original netns keeps a stale entry. When that netns is later destroyed, ip6gre_exit_rtnl_net() walks the stale entry, producing a slab-use-after-free reported by KASAN, followed by a kernel BUG at net/core/dev.c (LIST_POISON1) in unregister_netdevice_many_notify().
Reachable from an unprivileged user namespace (unshare --user --map-root-user --net).
ip6gre_changelink() earlier in the same file already uses the cached t->net; only ip6erspan_changelink() has the wrong shape.
--- net/ipv6/ip6_gre.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
net/ipv6/ip6_gre.c +3 -2
@@ -2322,10 +2322,11 @@ static int ip6erspan_changelink(struct nstruct nlattr *data[], struct netlink_ext_ack *extack) { - struct ip6gre_net *ign = net_generic(dev_net(dev), ip6gre_net_id); + struct ip6_tnl *t = netdev_priv(dev);struct __ip6_tnl_parm p; -struct ip6_tnl *t; +struct ip6gre_net *ign; + ign =net_generic (t->net, ip6gre_net_id); t =ip6gre_changelink_common (dev, tb, data, &p, extack);if (IS_ERR (t))return PTR_ERR (t);
Greg Kroah-Hartman
maintainerPATCH 326/969 net/rds: handle zerocopy send cleanup before the message is queued
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nan Li <[email protected]>
commit 44b550d88b267320459d518c0743a241ab2108fa upstream.
A zerocopy send can fail after user pages have been pinned but before the message is attached to the sending socket.
The purge path currently infers zerocopy state from rm->m_rs, so an unqueued message can be cleaned up as if it owned normal payload pages. However, zerocopy ownership is really determined by the presence of op_mmp_znotifier, regardless of whether the message has reached the socket queue.
Capture op_mmp_znotifier up front in rds_message_purge() and use it as the cleanup discriminator. If the message is already associated with a socket, keep the existing completion path. Otherwise, drop the pinned page accounting directly and release the notifier before putting the payload pages.
This keeps early send failure cleanup consistent with the zerocopy lifetime rules without changing the normal queued completion path.
--- net/rds/message.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
net/rds/message.c +15 -5
@@ -129,24 +129,34 @@ static void rds_rm_zerocopy_callback(str*/ static void rds_message_purge (struct rds_message *rm) { +struct rds_znotifier *znotifier;unsigned long i, flags; -bool zcopy = false; +bool zcopy;if (unlikely (test_bit (RDS_MSG_PAGEVEC , &rm->m_flags)))return ;spin_lock_irqsave (&rm->m_rs_lock, flags); + znotifier = rm->data.op_mmp_znotifier; + rm->data.op_mmp_znotifier =NULL ; + zcopy = !!znotifier; +if (rm->m_rs) {struct rds_sock *rs = rm->m_rs; -if (rm->data.op_mmp_znotifier) { - zcopy = true; -rds_rm_zerocopy_callback (rs, rm->data.op_mmp_znotifier); +if (znotifier) { +rds_rm_zerocopy_callback (rs, znotifier);rds_wake_sk_sleep (rs); - rm->data.op_mmp_znotifier =NULL ; }sock_put (rds_rs_to_sk (rs)); rm->m_rs =NULL ; + }else if (znotifier) { +/* +* Zerocopy can fail before the message is queued on the +* socket, so there is no rs to carry the notification. +*/ +mm_unaccount_pinned_pages (&znotifier->z_mmp); +kfree (rds_info_from_znotifier (znotifier)); }spin_unlock_irqrestore (&rm->m_rs_lock, flags);
Greg Kroah-Hartman
maintainerPATCH 327/969 parisc: Fix IRQ leak in LASI driver
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hongling Zeng <[email protected]>
commit 37b0dc5e279f35036fb638d1e187197b6c05a76d upstream.
When request_irq() succeeds but gsc_common_setup() fails later, the IRQ is never released. Fix this by adding proper error handling with goto labels to ensure resources are released in LIFO order.
Detected by Smatch:
drivers/parisc/lasi.c:216 lasi_init_chip() warn: 'lasi->gsc_irq.irq'
from request_irq() not released on lines: 207.
--- drivers/parisc/lasi.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/parisc/lasi.c +8 -4
@@ -196,8 +196,7 @@ static int __init lasi_init_chip(struct ret =request_irq (lasi->gsc_irq.irq, gsc_asic_intr,0 ,"lasi" , lasi);if (ret <0 ) { -kfree (lasi); -return ret; + goto err_free; }/* enable IRQ's for devices below LASI */
@@ -206,8 +205,7 @@ static int __init lasi_init_chip(struct/* Done init'ing, register this driver */ ret =gsc_common_setup (dev, lasi);if (ret) { -kfree (lasi); -return ret; + goto err_irq; }gsc_fixup_irqs (dev, lasi, lasi_choose_irq);
@@ -220,6 +218,12 @@ static int __init lasi_init_chip(struct chassis_power_off = lasi_power_off;return ret; + +err_irq: +free_irq (lasi->gsc_irq.irq, lasi); +err_free: +kfree (lasi); +return ret; }static struct parisc_device_id lasi_tbl[]__initdata = {
Greg Kroah-Hartman
maintainerPATCH 328/969 hwmon: (ltc2992) Clamp threshold writes to hardware range
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sanman Pradhan <[email protected]>
commit d6cc7c99bf1f73eda7d565d224d791d16239bb41 upstream.
ltc2992_set_voltage(), ltc2992_set_current(), and ltc2992_set_power() do not validate the user-supplied value before converting it to a register value. This can result in:
1. Negative input values wrapping to large positive register values. For power, the negative long is implicitly cast to u64 in mul_u64_u32_div(), producing an incorrect value. For voltage and current, the negative converted value wraps when passed to ltc2992_write_reg() as a u32.
2. Intermediate arithmetic exceeding the range representable in u64 on 64-bit platforms. In ltc2992_set_voltage(), (u64)val * 1000 can exceed U64_MAX when val is a large positive long. In ltc2992_set_current(), (u64)val * r_sense_uohm can overflow similarly. In ltc2992_set_power(), the computed value may not fit in u64.
3. Register values exceeding the hardware field width. Voltage and current threshold registers are 12-bit (stored left-justified in 16 bits), and power threshold registers are 24-bit. Without clamping, bits above the field width are truncated in ltc2992_write_reg().
Fix by clamping negative values to zero, clamping positive values to the rounded hardware-representable maximum (the value returned by the read path for a full-scale register) to prevent intermediate overflow, and clamping the converted register value to the hardware field width before writing. The existing conversion formula and rounding behavior are preserved.
In the power write path, cancel the factor of 1000 from both the numerator (r_sense_uohm * 1000) and the denominator (VADC_UV_LSB * IADC_NANOV_LSB) to also eliminate a u32 overflow of r_sense_uohm * 1000 when r_sense_uohm exceeds about 4.29 ohms.
--- drivers/hwmon/ltc2992.c | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-)
drivers/hwmon/ltc2992.c +28 -7
@@ -421,10 +421,16 @@ static int ltc2992_get_voltage(struct ltstatic int ltc2992_set_voltage (struct ltc2992_state *st,u32 reg,u32 scale,long val) { - val =DIV_ROUND_CLOSEST (val *1000 , scale); - val = val <<4 ; +u32 reg_val; +long vmax; + + vmax =DIV_ROUND_CLOSEST_ULL (0xFFFULL * scale,1000 ); + val =max (val,0L ); + val =min (val, vmax); + reg_val =min (DIV_ROUND_CLOSEST_ULL ((u64 )val *1000 , scale), +0xFFFULL ) <<4 ; -return ltc2992_write_reg (st, reg,2 , val); +return ltc2992_write_reg (st, reg,2 , reg_val); }static int ltc2992_read_gpio_alarm (struct ltc2992_state *st,int nr_gpio,u32 attr,long *val)
@@ -549,9 +555,15 @@ static int ltc2992_get_current(struct ltstatic int ltc2992_set_current (struct ltc2992_state *st,u32 reg,u32 channel,long val) {u32 reg_val; +long cmax; - reg_val =DIV_ROUND_CLOSEST (val * st->r_sense_uohm[channel],LTC2992_IADC_NANOV_LSB ); - reg_val = reg_val <<4 ; + cmax =DIV_ROUND_CLOSEST_ULL (0xFFFULL *LTC2992_IADC_NANOV_LSB , + st->r_sense_uohm[channel]); + val =max (val,0L ); + val =min (val, cmax); + reg_val =min (DIV_ROUND_CLOSEST_ULL ((u64 )val * st->r_sense_uohm[channel], +LTC2992_IADC_NANOV_LSB ), +0xFFFULL ) <<4 ;return ltc2992_write_reg (st, reg,2 , reg_val); }
@@ -624,9 +636,18 @@ static int ltc2992_get_power(struct ltc2static int ltc2992_set_power (struct ltc2992_state *st,u32 reg,u32 channel,long val) {u32 reg_val; +u64 pmax, uval; - reg_val =mul_u64_u32_div (val, st->r_sense_uohm[channel] *1000 , -LTC2992_VADC_UV_LSB *LTC2992_IADC_NANOV_LSB ); + uval =max (val,0L ); + pmax =mul_u64_u32_div (0xFFFFFFULL , +LTC2992_VADC_UV_LSB /1000 * +LTC2992_IADC_NANOV_LSB , + st->r_sense_uohm[channel]); + uval =min (uval, pmax); + reg_val =min (mul_u64_u32_div (uval, st->r_sense_uohm[channel], +LTC2992_VADC_UV_LSB /1000 * +LTC2992_IADC_NANOV_LSB ), +0xFFFFFFULL );return ltc2992_write_reg (st, reg,3 , reg_val); }
Greg Kroah-Hartman
maintainerPATCH 329/969 hwmon: (ltc2992) Fix u32 overflow in power read path
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sanman Pradhan <[email protected]>
commit 2da0c1fd01dbd6b22844e8676585153dfc660cbe upstream.
ltc2992_get_power() computes the divisor for mul_u64_u32_div() as r_sense_uohm * 1000. This multiplication overflows u32 when r_sense_uohm exceeds about 4.29 ohms (4294967 micro-ohms), producing a truncated divisor and an incorrect power reading.
Cancel the factor of 1000 from both the numerator (VADC_UV_LSB * IADC_NANOV_LSB = 312500000) and the divisor (r_sense_uohm * 1000), giving (VADC_UV_LSB / 1000) * IADC_NANOV_LSB = 312500 as the numerator and plain r_sense_uohm as the divisor. The cancellation is exact because LTC2992_VADC_UV_LSB (25000) is divisible by 1000.
This is the read-path counterpart of the write-path fix applied in the preceding patch.
--- drivers/hwmon/ltc2992.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/hwmon/ltc2992.c +4 -2
@@ -627,8 +627,10 @@ static int ltc2992_get_power(struct ltc2if (reg_val <0 )return reg_val; - *val =mul_u64_u32_div (reg_val,LTC2992_VADC_UV_LSB *LTC2992_IADC_NANOV_LSB , - st->r_sense_uohm[channel] *1000 ); + *val =mul_u64_u32_div (reg_val, +LTC2992_VADC_UV_LSB /1000 * +LTC2992_IADC_NANOV_LSB , + st->r_sense_uohm[channel]);return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 330/969 hwmon: (corsair-psu) Close HID device on probe errors
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
commit 174606451fbb17db506ebaacdd5e203e57773d5f upstream.
corsairpsu_probe() opens the HID device before sending the device init and firmware-info commands. If either command fails, the error path jumps directly to fail_and_stop and skips hid_hw_close().
Use the existing fail_and_close label for those post-open failures so the open count and low-level close callback are balanced before hid_hw_stop().
--- drivers/hwmon/corsair-psu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/hwmon/corsair-psu.c +2 -2
@@ -743,13 +743,13 @@ static int corsairpsu_probe(struct hid_d ret =corsairpsu_init (priv);if (ret <0 ) {dev_err (&hdev->dev,"unable to initialize device (%d)\n" , ret); - goto fail_and_stop; + goto fail_and_close; } ret =corsairpsu_fwinfo (priv);if (ret <0 ) {dev_err (&hdev->dev,"unable to query firmware (%d)\n" , ret); - goto fail_and_stop; + goto fail_and_close; }corsairpsu_get_criticals (priv);
Greg Kroah-Hartman
maintainerPATCH 331/969 cifs: abort open_cached_dir if we dont request leases
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shyam Prasad N <[email protected]>
commit d68ce834f8cf6cb2e77f3331df65166b35466b53 upstream.
It is possible that SMB2_open_init may not set lease context based on the requested oplock level. This can happen when leases have been temporarily or permanently disabled. When this happens, we will have open_cached_dir making an open without lease context and the response will anyway be rejected by open_cached_dir (thereby forcing a close to discard this open). That's unnecessary two round-trips to the server.
This change adds a check before making the open request to the server to make sure that SMB2_open_init did add the expected lease context to the open in open_cached_dir.
--- fs/smb/client/cached_dir.c | 8 ++++++++ 1 file changed, 8 insertions(+)
fs/smb/client/cached_dir.c +8 -0
@@ -228,6 +228,14 @@ int open_cached_dir(unsigned int xid, st &rqst[0], &oplock, &oparms, utf16_path);if (rc) goto oshr_free; + +if (oplock !=SMB2_OPLOCK_LEVEL_II ) { + rc = -EINVAL ; +cifs_dbg (FYI ,"%s: Oplock level %d not suitable for cached directory\n" , + __func__, oplock); + goto oshr_free; + } +smb2_set_next_command (tcon, &rqst[0 ]);memset (&qi_iov,0 ,sizeof (qi_iov));
Greg Kroah-Hartman
maintainerPATCH 332/969 cifs: change_conf needs to be called for session setup
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shyam Prasad N <[email protected]>
commit c208a2b95811d6e1ebae65d0d2fc13f73707f8e7 upstream.
Today we skip calling change_conf for negotiates and session setup requests. This can be a problem for mchan as the immediate next call after session setup could be due to an I/O that is made on the mount point. For single channel, this is not a problem as there will be several calls after setting up session.
This change enforces calling change_conf when the total credits contain enough for reservations for echoes and oplocks. We expect this to happen during the last session setup response. This way, echoes and oplocks are not disabled before the first request to the server. So if that first request is an open, it does not need to disable requesting leases.
--- fs/smb/client/smb2ops.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
fs/smb/client/smb2ops.c +11 -0
@@ -94,10 +94,21 @@ smb2_add_credits(struct TCP_Server_Info add, server->in_flight); } server->in_flight--; + +/* +* Rebalance credits when an op drains in_flight. For session setup, +* do this only when the total accumulated credits are high enough (>2) +* so that a newly established secondary channel can reserve credits for +* echoes and oplocks. We expect this to happen at the end of the final +* session setup response. +*/ if (server->in_flight ==0 && ((optype &CIFS_OP_MASK ) !=CIFS_NEG_OP ) && ((optype &CIFS_OP_MASK ) !=CIFS_SESS_OP )) rc =change_conf (server); +else if (server->in_flight ==0 && + ((optype &CIFS_OP_MASK ) ==CIFS_SESS_OP ) && *val >2 ) + rc =change_conf (server);/* * Sometimes server returns 0 credits on oplock break ack - we need to * rebalance credits in this case.
Greg Kroah-Hartman
maintainerPATCH 333/969 extcon: ptn5150: handle pending IRQ events during system resume
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xu Yang <[email protected]>
commit 4652fefcda3c604c83d1ae28ede94544e2142f06 upstream.
When the system is suspended and ptn5150 wakeup interrupt is disabled, any changes on ptn5150 will only be record in interrupt status registers and won't fire an IRQ since its trigger type is falling edge. So the HW interrupt line will keep at low state and any further changes won't trigger IRQ anymore. To fix it, this will schedule a work to check whether any IRQ are pending and handle it accordingly.
--- drivers/extcon/extcon-ptn5150.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
drivers/extcon/extcon-ptn5150.c +14 -0
@@ -331,6 +331,19 @@ static int ptn5150_i2c_probe(struct i2c_return 0 ; } +static int ptn5150_resume (struct device *dev) +{ +struct i2c_client *i2c =to_i2c_client (dev); +struct ptn5150_info *info =i2c_get_clientdata (i2c); + +/* Need to check possible pending interrupt events */ +schedule_work (&info->irq_work); + +return 0 ; +} + +static DEFINE_SIMPLE_DEV_PM_OPS(ptn5150_pm_ops, NULL, ptn5150_resume); +static const struct of_device_id ptn5150_dt_match[] = { { .compatible ="nxp,ptn5150" }, { },
@@ -346,6 +359,7 @@ MODULE_DEVICE_TABLE(i2c, ptn5150_i2c_id)static struct i2c_driver ptn5150_i2c_driver = { .driver = { .name ="ptn5150" , + .pm =pm_sleep_ptr (&ptn5150_pm_ops), .of_match_table = ptn5150_dt_match, }, .probe_new = ptn5150_i2c_probe,
Greg Kroah-Hartman
maintainerPATCH 334/969 hv_sock: fix ARM64 support
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hamza Mahfooz <[email protected]>
commit b31681206e3f527970a7c7ed807fbf6a028fc25b upstream.
VMBUS ring buffers must be page aligned. Therefore, the current value of 24K presents a challenge on ARM64 kernels (with 64K pages). So, use VMBUS_RING_SIZE() to ensure they are always aligned and large enough to hold all of the relevant data.
--- net/vmw_vsock/hyperv_transport.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/vmw_vsock/hyperv_transport.c +2 -2
@@ -375,10 +375,10 @@ static void hvs_open_connection(struct v }else { sndbuf =max_t (int, sk->sk_sndbuf,RINGBUFFER_HVS_SND_SIZE ); sndbuf =min_t (int, sndbuf,RINGBUFFER_HVS_MAX_SIZE ); - sndbuf =ALIGN (sndbuf,HV_HYP_PAGE_SIZE ); + sndbuf =VMBUS_RING_SIZE (sndbuf); rcvbuf =max_t (int, sk->sk_rcvbuf,RINGBUFFER_HVS_RCV_SIZE ); rcvbuf =min_t (int, rcvbuf,RINGBUFFER_HVS_MAX_SIZE ); - rcvbuf =ALIGN (rcvbuf,HV_HYP_PAGE_SIZE ); + rcvbuf =VMBUS_RING_SIZE (rcvbuf); } chan->max_pkt_size =HVS_MAX_PKT_SIZE ;
Greg Kroah-Hartman
maintainerPATCH 335/969 ibmveth: Disable GSO for packets with small MSS
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mingming Cao <[email protected]>
commit cc427d24ac6442ffdeafd157a63c7c5b73ed4de4 upstream.
Some physical adapters on Power systems do not support segmentation offload when the MSS is less than 224 bytes. Attempting to send such packets causes the adapter to freeze, stopping all traffic until manually reset.
Implement ndo_features_check to disable GSO for packets with small MSS values. The network stack will perform software segmentation instead.
The 224-byte minimum matches ibmvnic
commit <f10b09ef687f> ("ibmvnic: Enforce stronger sanity checks on GSO packets")
which uses the same physical adapters in SEA configurations.
The issue occurs specifically when the hardware attempts to perform segmentation (gso_segs > 1) with a small MSS. Single-segment GSO packets (gso_segs == 1) do not trigger the problematic LSO code path and are transmitted normally without segmentation.
Add an ndo_features_check callback to disable GSO when MSS < 224 bytes. Also call vlan_features_check() to ensure proper handling of VLAN packets, particularly QinQ (802.1ad) configurations where the hardware parser may not support certain offload features.
Validated using iptables to force small MSS values. Without the fix, the adapter freezes. With the fix, packets are segmented in software and transmission succeeds. Comprehensive regression testing completedd (MSS tests, performance, stability).
--- drivers/net/ethernet/ibm/ibmveth.c | 22 ++++++++++++++++++++++ drivers/net/ethernet/ibm/ibmveth.h | 1 + 2 files changed, 23 insertions(+)
drivers/net/ethernet/ibm/ibmveth.c +22 -0
@@ -1637,6 +1637,27 @@ static int ibmveth_set_mac_addr(struct nreturn 0 ; } +static netdev_features_t ibmveth_features_check (struct sk_buff *skb, +struct net_device *dev, +netdev_features_t features) +{ +/* Some physical adapters do not support segmentation offload with +* MSS < 224. Disable GSO for such packets to avoid adapter freeze. +* Note: Single-segment packets (gso_segs == 1) don't need this check +* as they bypass the LSO path and are transmitted without segmentation. +*/ +if (skb_is_gso (skb)) { +if (skb_shinfo (skb)->gso_size <IBMVETH_MIN_LSO_MSS ) { +netdev_warn_once (dev, +"MSS %u too small for LSO, disabling GSO\n" , +skb_shinfo (skb)->gso_size); + features &= ~NETIF_F_GSO_MASK ; + } + } + +return vlan_features_check (skb, features); +} +static const struct net_device_ops ibmveth_netdev_ops = { .ndo_open = ibmveth_open, .ndo_stop = ibmveth_close,
@@ -1648,6 +1669,7 @@ static const struct net_device_ops ibmve .ndo_set_features = ibmveth_set_features, .ndo_validate_addr = eth_validate_addr, .ndo_set_mac_address = ibmveth_set_mac_addr, + .ndo_features_check = ibmveth_features_check,#ifdef CONFIG_NET_POLL_CONTROLLER .ndo_poll_controller = ibmveth_poll_controller,#endif
drivers/net/ethernet/ibm/ibmveth.h +1 -0
@@ -36,6 +36,7 @@#define IBMVETH_ILLAN_IPV4_TCP_CSUM 0x0000000000000002UL#define IBMVETH_ILLAN_ACTIVE_TRUNK 0x0000000000000001UL +#define IBMVETH_MIN_LSO_MSS 224/* Minimum MSS for LSO */ /* hcall macros */ #define h_register_logical_lan (ua, buflst, rxq, fltlst, mac) \ plpar_hcall_norets(H_REGISTER_LOGICAL_LAN, ua, buflst, rxq, fltlst, mac)
Greg Kroah-Hartman
maintainerPATCH 336/969 udf: reject descriptors with oversized CRC length
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Bommarito <[email protected]>
commit 55d41b0a20128e86b9e960dd2e3f0a2d69a18df7 upstream.
udf_read_tagged() skips CRC verification when descCRCLength + sizeof(struct tag) exceeds the block size. A crafted UDF image can set descCRCLength to an oversized value to bypass CRC validation entirely; the descriptor is then accepted based solely on the 8-bit tag checksum, which is trivially recomputable.
Reject such descriptors instead of silently accepting them. A legitimate single-block descriptor should never have a CRC length that exceeds the block.
--- fs/udf/misc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
fs/udf/misc.c +6 -2
@@ -250,8 +250,12 @@ struct buffer_head *udf_read_tagged(stru }/* Verify the descriptor CRC */ -if (le16_to_cpu (tag_p->descCRCLength) +sizeof (struct tag ) > sb->s_blocksize || -le16_to_cpu (tag_p->descCRC) ==crc_itu_t (0 , +if (le16_to_cpu (tag_p->descCRCLength) +sizeof (struct tag ) > sb->s_blocksize) { +udf_err (sb,"block %u: CRC length %u exceeds block size\n" , + block,le16_to_cpu (tag_p->descCRCLength)); + goto error_out; + } +if (le16_to_cpu (tag_p->descCRC) ==crc_itu_t (0 , bh->b_data +sizeof (struct tag ),le16_to_cpu (tag_p->descCRCLength)))return bh;
Greg Kroah-Hartman
maintainerPATCH 337/969 thermal/drivers/sprd: Fix temperature clamping in sprd_thm_temp_to_rawdata
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thorsten Blum <[email protected]>
commit 83c0f9a5d679a6f8d84fc49b2f62ea434ccab4b6 upstream.
The temperature was never clamped to SPRD_THM_TEMP_LOW or SPRD_THM_TEMP_HIGH because the return value of clamp() was not used. Fix this by assigning the clamped value to 'temp'.
Casting SPRD_THM_TEMP_LOW and SPRD_THM_TEMP_HIGH to int is also redundant and can be removed.
--- drivers/thermal/sprd_thermal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thermal/sprd_thermal.c +1 -1
@@ -192,7 +192,7 @@ static int sprd_thm_temp_to_rawdata(int {u32 val; -clamp (temp, (int )SPRD_THM_TEMP_LOW , (int )SPRD_THM_TEMP_HIGH ); + temp =clamp (temp,SPRD_THM_TEMP_LOW ,SPRD_THM_TEMP_HIGH );/* * According to the thermal datasheet, the formula of converting
Greg Kroah-Hartman
maintainerPATCH 338/969 thermal/drivers/sprd: Fix raw temperature clamping in sprd_thm_rawdata_to_temp
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thorsten Blum <[email protected]>
commit b3414148bbc1f9cd56217e58a558c6ac4fd1b4a6 upstream.
The raw temperature data was never clamped to SPRD_THM_RAW_DATA_LOW or SPRD_THM_RAW_DATA_HIGH because the return value of clamp() was not used. Fix this by assigning the clamped value to 'rawdata'.
Casting SPRD_THM_RAW_DATA_LOW and SPRD_THM_RAW_DATA_HIGH to u32 is also redundant and can be removed.
--- drivers/thermal/sprd_thermal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thermal/sprd_thermal.c +1 -1
@@ -178,7 +178,7 @@ static int sprd_thm_sensor_calibration(sstatic int sprd_thm_rawdata_to_temp (struct sprd_thermal_sensor *sen,u32 rawdata) { -clamp (rawdata, (u32 )SPRD_THM_RAW_DATA_LOW , (u32 )SPRD_THM_RAW_DATA_HIGH ); + rawdata =clamp (rawdata,SPRD_THM_RAW_DATA_LOW ,SPRD_THM_RAW_DATA_HIGH );/* * According to the thermal datasheet, the formula of converting
Greg Kroah-Hartman
maintainerPATCH 339/969 spi: topcliff-pch: fix use-after-free on unbind
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 9d72732fe70c11424bc90ed466c7ccfa58b42a9a upstream.
Give the driver a chance to flush its queue before releasing the DMA buffers on driver unbind
--- drivers/spi/spi-topcliff-pch.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/spi/spi-topcliff-pch.c +3 -3
@@ -1406,9 +1406,6 @@ static int pch_spi_pd_remove(struct platdev_dbg (&plat_dev->dev,"%s:[ch%d] irq=%d\n" , __func__, plat_dev->id, board_dat->pdev->irq); -if (use_dma) -pch_free_dma_buf (board_dat, data); -/* check for any pending messages; no action is taken if the queue * is still full; but at least we tried. Unload anyway */ count =500 ;
@@ -1432,6 +1429,9 @@ static int pch_spi_pd_remove(struct platfree_irq (board_dat->pdev->irq, data); } +if (use_dma) +pch_free_dma_buf (board_dat, data); +pci_iounmap (board_dat->pdev, data->io_remap_addr);spi_unregister_master (data->master);
Greg Kroah-Hartman
maintainerPATCH 340/969 clk: microchip: mpfs-ccc: fix out of bounds access during output registration
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Conor Dooley <[email protected]>
commit 2f7ae8ab6aa73daaf080d5332110357c29df9c36 upstream.
UBSAN reported an out of bounds access during registration of the last two outputs. This out of bounds access occurs because space is only allocated in the hws array for two PLLs and the four output dividers that each has, but the defined IDs contain two DLLS and their two outputs each, which are not supported by the driver. The ID order is PLLs -> DLLs -> PLL outputs -> DLL outputs. Decrement the PLL output IDs by two while adding them to the array to avoid the problem.
--- drivers/clk/microchip/clk-mpfs-ccc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/clk/microchip/clk-mpfs-ccc.c +5 -1
@@ -178,7 +178,7 @@ static int mpfs_ccc_register_outputs(struct device *dev, struct mpfs_ccc_out_hw_return dev_err_probe (dev, ret,"failed to register clock id: %d\n" , out_hw->id); - data->hw_data.hws[out_hw->id] = &out_hw->divider.hw; + data->hw_data.hws[out_hw->id -2 ] = &out_hw->divider.hw; }return 0 ;
@@ -234,6 +234,10 @@ static int mpfs_ccc_probe(struct platform_device *pdev)unsigned int num_clks;int ret; +/* +* If DLLs get added here, mpfs_ccc_register_outputs() currently packs +* sparse clock IDs in the hws array +*/ num_clks =ARRAY_SIZE (mpfs_ccc_pll_clks) +ARRAY_SIZE (mpfs_ccc_pll0out_clks) +ARRAY_SIZE (mpfs_ccc_pll1out_clks);
Signature · 1 line
2.54.0
Greg Kroah-Hartman
maintainerPATCH 341/969 cpuidle: powerpc: avoid double clear when breaking snooze
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shrikanth Hegde <[email protected]>
commit 64ed1e3e728afb57ba9acb59e69de930ead847d9 upstream.
snooze_loop is done often in any system which has fair bit of idle time. So it qualifies for even micro-optimizations.
When breaking the snooze due to timeout, TIF_POLLING_NRFLAG is cleared twice. Clearing the bit invokes atomics. Avoid double clear and thereby avoid one atomic write.
dev->poll_time_limit indicates whether the loop was broken due to timeout. Use that instead of defining a new variable.
--- drivers/cpuidle/cpuidle-powernv.c | 5 ++++- drivers/cpuidle/cpuidle-pseries.c | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-)
drivers/cpuidle/cpuidle-powernv.c +4 -1
@@ -93,7 +93,10 @@ static int snooze_loop(struct cpuidle_deHMT_medium ();ppc64_runlatch_on (); -clear_thread_flag (TIF_POLLING_NRFLAG ); + +/* Avoid double clear when breaking */ +if (!dev->poll_time_limit) +clear_thread_flag (TIF_POLLING_NRFLAG );local_irq_disable ();
drivers/cpuidle/cpuidle-pseries.c +4 -1
@@ -61,7 +61,10 @@ static int snooze_loop(struct cpuidle_de }HMT_medium (); -clear_thread_flag (TIF_POLLING_NRFLAG ); + +/* Avoid double clear when breaking */ +if (!dev->poll_time_limit) +clear_thread_flag (TIF_POLLING_NRFLAG );local_irq_disable ();
Greg Kroah-Hartman
maintainerPATCH 342/969 ASoC: amd: yc: Add HP OMEN Gaming Laptop 16-ap0xxx product line in quirk table
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tommaso Soncin <[email protected]>
commit d63c219b7ff39f897da10c160a2edef76320f16c upstream.
Add a DMI quirk for the HP OMEN Gaming Laptop 16-ap0xxx line fixing the issue where the internal microphone was not detected.
--- sound/soc/amd/yc/acp6x-mach.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
sound/soc/amd/yc/acp6x-mach.c +14 -0
@@ -55,6 +55,13 @@ static const struct dmi_system_id yc_acp { .driver_data = &acp6x_card, .matches = { +DMI_MATCH (DMI_BOARD_VENDOR ,"HP" ), + DMI_MATCH(DMI_PRODUCT_NAME, "OMEN Gaming Laptop 16-ap0xxx"), + } + }, + { + .driver_data = &acp6x_card, + .matches = {DMI_MATCH (DMI_BOARD_VENDOR ,"Dell Inc." ), DMI_MATCH(DMI_PRODUCT_NAME, "Dell G15 5525"), }
@@ -578,6 +585,13 @@ static const struct dmi_system_id yc_acp } }, { + .driver_data = &acp6x_card, + .matches = { +DMI_MATCH (DMI_BOARD_VENDOR ,"HP" ), + DMI_MATCH(DMI_BOARD_NAME, "8E35"), + } + }, + { .driver_data = &acp6x_card, .matches = { DMI_MATCH(DMI_BOARD_VENDOR, "Micro-Star International Co., Ltd."),
Greg Kroah-Hartman
maintainerPATCH 343/969 ASoC: fsl_easrc: fix comment typo
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joseph Salisbury <[email protected]>
commit 804dce6c73fdfa44184ee4e8b09abad7f5da408f upstream.
The file contains a spelling error in a source comment (funciton).
Typos in comments reduce readability and make text searches less reliable for developers and maintainers.
Replace 'funciton' with 'function' in the affected comment. This is a comment-only cleanup and does not change behavior.
--- sound/soc/fsl/fsl_easrc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/fsl/fsl_easrc.c +1 -1
@@ -1286,7 +1286,7 @@ static int fsl_easrc_request_context(int/* * Release the context * -* This funciton is mainly doing the revert thing in request context +* This function is mainly doing the revert thing in request context */ static void fsl_easrc_release_context (struct fsl_asrc_pair *ctx) {
Greg Kroah-Hartman
maintainerPATCH 344/969 ASoC: Intel: bytcr_wm5102: Fix MCLK leak on platform_clock_control error
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cássio Gabriel <[email protected]>
commit 13d30682e8dee191ac04e93642f0372a723e8b0c upstream.
If byt_wm5102_prepare_and_enable_pll1() fails in the SND_SOC_DAPM_EVENT_ON() path, platform_clock_control() returns after clk_prepare_enable(priv->mclk) without disabling the clock again.
This leaks an MCLK enable reference on failed power-up attempts. Add the missing clk_disable_unprepare() on the error path, matching the unwind used by the other Intel platform_clock_control() implementations.
--- sound/soc/intel/boards/bytcr_wm5102.c | 1 + 1 file changed, 1 insertion(+)
sound/soc/intel/boards/bytcr_wm5102.c +1 -0
@@ -111,6 +111,7 @@ static int platform_clock_control(struct ret =byt_wm5102_prepare_and_enable_pll1 (codec_dai,48000 );if (ret) {dev_err (card->dev,"Error setting codec sysclk: %d\n" , ret); +clk_disable_unprepare (priv->mclk);return ret; } }else {
Greg Kroah-Hartman
maintainerPATCH 345/969 ASoC: qcom: q6apm-dai: reset queue ptr on trigger stop
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srinivas Kandagatla <[email protected]>
commit cab45ab95ce7600fc0ff84585c77fd45b7b0d67c upstream.
Reset queue pointer on SNDRV_PCM_TRIGGER_STOP event to be inline with resetting appl_ptr. Without this we will end up with a queue_ptr out of sync and driver could try to send data that is not ready yet.
Fix this by resetting the queue_ptr.
--- sound/soc/qcom/qdsp6/q6apm-dai.c | 1 + sound/soc/qcom/qdsp6/q6apm.c | 2 ++ 2 files changed, 3 insertions(+)
sound/soc/qcom/qdsp6/q6apm-dai.c +1 -0
@@ -246,6 +246,7 @@ static int q6apm_dai_trigger(struct snd_case SNDRV_PCM_TRIGGER_STOP :/* TODO support be handled via SoftPause Module */ prtd->state =Q6APM_STREAM_STOPPED ; + prtd->queue_ptr =0 ;break ;case SNDRV_PCM_TRIGGER_SUSPEND :case SNDRV_PCM_TRIGGER_PAUSE_PUSH :
sound/soc/qcom/qdsp6/q6apm.c +2 -0
@@ -294,6 +294,8 @@ int q6apm_map_memory_regions(struct q6apmutex_lock (&graph->lock); + data->dsp_buf =0 ; +if (data->buf) {mutex_unlock (&graph->lock);return 0 ;
Greg Kroah-Hartman
maintainerPATCH 346/969 ASoC: qcom: q6apm-lpass-dai: Fix multiple graph opens
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srinivas Kandagatla <[email protected]>
commit 69acc488aaf39d0ddf6c3cf0e47c1873d39919a2 upstream.
As prepare can be called mulitple times, this can result in multiple graph opens for playback path.
This will result in a memory leaks, fix this by adding a check before opening.
--- sound/soc/qcom/qdsp6/q6apm-lpass-dais.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/qcom/qdsp6/q6apm-lpass-dais.c +1 -1
@@ -144,7 +144,7 @@ static int q6apm_lpass_dai_prepare(struc* It is recommend to load DSP with source graph first and then sink * graph, so sequence for playback and capture will be different */ -if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) { +if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK && dai_data->graph[dai->id] ==NULL ) { graph =q6apm_graph_open (dai->dev,NULL , dai->dev, graph_id);if (IS_ERR (graph)) {dev_err (dai->dev,"Failed to open graph (%d)\n" , graph_id);
Greg Kroah-Hartman
maintainerPATCH 347/969 ASoC: qcom: q6apm: remove child devices when apm is removed
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srinivas Kandagatla <[email protected]>
commit 4a0e1bcc98f7281d1605768bd2fe71eacc34f9b7 upstream.
looks like q6apm driver does not remove the child driver q6apm-dai and q6apm-bedais when the this driver is removed.
Fix this by depopulating them in remove callback.
With this change when the dsp is shutdown all the devices associated with q6apm will now be removed.
--- sound/soc/qcom/qdsp6/q6apm.c | 1 + 1 file changed, 1 insertion(+)
sound/soc/qcom/qdsp6/q6apm.c +1 -0
@@ -763,6 +763,7 @@ static int apm_probe(gpr_device_t *gdev)static void apm_remove (gpr_device_t *gdev) { +of_platform_depopulate (&gdev->dev);snd_soc_unregister_component (&gdev->dev); }
Greg Kroah-Hartman
maintainerPATCH 348/969 btrfs: fix double free in create_space_info() error path
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
commit 3f487be81292702a59ea9dbc4088b3360a50e837 upstream.
When kobject_init_and_add() fails, the call chain is:
create_space_info()
-> btrfs_sysfs_add_space_info_type()
-> kobject_init_and_add()
-> failure
-> kobject_put(&space_info->kobj)
-> space_info_release()
-> kfree(space_info)
Then control returns to create_space_info():
btrfs_sysfs_add_space_info_type() returns error
-> goto out_free
-> kfree(space_info)
This causes a double free.
Keep the direct kfree(space_info) for the earlier failure path, but after btrfs_sysfs_add_space_info_type() has called kobject_put(), let the kobject release callback handle the cleanup.
--- fs/btrfs/space-info.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/space-info.c +1 -1
@@ -290,7 +290,7 @@ static int create_space_info(struct btrf ret =btrfs_sysfs_add_space_info_type (info, space_info);if (ret) - goto out_free; +return ret;list_add (&space_info->list, &info->space_info);if (flags &BTRFS_BLOCK_GROUP_DATA )
Greg Kroah-Hartman
maintainerPATCH 349/969 dm-thin: fix metadata refcount underflow
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikulas Patocka <[email protected]>
commit 09a65adc7d8bbfce06392cb6d375468e2728ead5 upstream.
There's a bug in dm-thin in the function rebalance_children. If the internal btree node has one entry, the code tries to copy all btree entries from the node's child to the node itself and then decrement the child's reference count.
If the child node is shared (it has reference count > 1), we won't free it, so there would be two pointers to each of the grandchildren nodes. But the reference counts of the grandchildren is not increased, thus the reference count doesn't match the number of pointers that point to the grandchildren. This results in "device mapper: space map common: unable to decrement block" errors.
Fix this bug by incrementing reference counts on the grandchildren if the btree node is shared.
--- drivers/md/persistent-data/dm-btree-remove.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/md/persistent-data/dm-btree-remove.c +8 -0
@@ -486,12 +486,20 @@ static int rebalance_children(struct shaif (le32_to_cpu (n->header.nr_entries) ==1 ) {struct dm_block *child; +int is_shared;dm_block_t b =value64 (n,0 ); + r =dm_tm_block_is_shared (info->tm, b, &is_shared); +if (r) +return r; + r =dm_tm_read_lock (info->tm, b, &btree_node_validator, &child);if (r)return r; +if (is_shared) +inc_children (info->tm,dm_block_data (child), vt); +memcpy (n,dm_block_data (child),dm_bm_block_size (dm_tm_get_bm (info->tm)));
Greg Kroah-Hartman
maintainerPATCH 350/969 dm: dont report warning when doing deferred remove
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikulas Patocka <[email protected]>
commit b7cce3e2cca9cd78418f3c3784474b778e7996fe upstream.
If dm_hash_remove_all was called from dm_deferred_remove, it would write a warning "remove_all left %d open device(s)" if there are some other devices active.
The warning is bogus, so let's disable it in this case.
--- drivers/md/dm-ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/dm-ioctl.c +1 -1
@@ -367,7 +367,7 @@ retry:up_write (&_hash_lock); -if (dev_skipped) +if (dev_skipped && !only_deferred)DMWARN ("remove_all left %d open device(s)" , dev_skipped); }
Greg Kroah-Hartman
maintainerPATCH 351/969 dm: fix a buffer overflow in ioctl processing
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikulas Patocka <[email protected]>
commit 2fa49cc884f6496a915c35621ba4da35649bf159 upstream.
Tony Asleson (using Claude) found a buffer overflow in dm-ioctl in the function retrieve_status:
1. The code in retrieve_status checks that the output string fits into the output buffer and writes the output string there
2. Then, the code aligns the "outptr" variable to the next 8-byte boundary:
outptr = align_ptr(outptr); 3. The alignment doesn't check overflow, so outptr could point past the buffer end 4. The "for" loop is iterated again, it executes: remaining = len - (outptr - outbuf);
5. If "outptr" points past "outbuf + len", the arithmetics wraps around and the variable "remaining" contains unusually high number
6. With "remaining" being high, the code writes more data past the end of the buffer
Luckily, this bug has no security implications because:
1. Only root can issue device mapper ioctls
2. The commonly used libraries that communicate with device mapper (libdevmapper and devicemapper-rs) use buffer size that is aligned to 8 bytes - thus, "outptr = align_ptr(outptr)" can't overshoot the input buffer and the bug can't happen accidentally
--- drivers/md/dm-ioctl.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/md/dm-ioctl.c +4 -0
@@ -1316,6 +1316,10 @@ static void retrieve_status(struct dm_ta used = param->data_start + (outptr - outbuf); outptr =align_ptr (outptr); +if (!outptr || outptr > outbuf + len) { + param->flags |=DM_BUFFER_FULL_FLAG ; +break ; + } spec->next = outptr - outbuf; }
Greg Kroah-Hartman
maintainerPATCH 352/969 dm-verity-fec: correctly reject too-small FEC devices
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
commit 2b14e0bb63cc671120e7791658f5c494fc66d072 upstream.
Fix verity_fec_ctr() to reject too-small FEC devices by correctly computing the number of parity blocks as 'f->rounds * f->roots'. Previously it incorrectly used 'div64_u64(f->rounds * f->roots, v->fec->roots << SECTOR_SHIFT)' which is a much smaller value.
Note that the units of 'rounds' are blocks, not bytes. This matches the units of the value returned by dm_bufio_get_device_size(), which are also blocks. A later commit will give 'rounds' a clearer name.
--- drivers/md/dm-verity-fec.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/md/dm-verity-fec.c +2 -3
@@ -684,7 +684,7 @@ int verity_fec_ctr(struct dm_verity *v) {struct dm_verity_fec *f = v->fec;struct dm_target *ti = v->ti; -u64 hash_blocks, fec_blocks; +u64 hash_blocks;int ret;if (!verity_fec_is_enabled (v)) {
@@ -765,8 +765,7 @@ int verity_fec_ctr(struct dm_verity *v)dm_bufio_set_sector_offset (f->bufio, f->start << (v->data_dev_block_bits -SECTOR_SHIFT )); - fec_blocks =div64_u64 (f->rounds * f->roots, v->fec->roots <<SECTOR_SHIFT ); -if (dm_bufio_get_device_size (f->bufio) < fec_blocks) { +if (dm_bufio_get_device_size (f->bufio) < f->rounds * f->roots) { ti->error ="FEC device is too small" ;return -E2BIG ; }
Greg Kroah-Hartman
maintainerPATCH 353/969 dm-verity-fec: correctly reject too-small hash devices
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
commit 4355142245f7e55336dcc005ec03592df4d546f8 upstream.
Fix verity_fec_ctr() to reject too-small hash devices by correctly taking hash_start into account.
Note that this is necessary because dm-verity doesn't call dm_bufio_set_sector_offset() on the hash device's bufio client (v->bufio). Thus, dm_bufio_get_device_size(v->bufio) returns a size relative to 0 rather than hash_start. An alternative fix would be to call dm_bufio_set_sector_offset() on v->bufio, but then all the code that reads from the hash device would have to be adjusted accordingly.
--- drivers/md/dm-verity-fec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/md/dm-verity-fec.c +2 -1
@@ -747,7 +747,8 @@ int verity_fec_ctr(struct dm_verity *v)* it to be large enough. */ f->hash_blocks = f->blocks - v->data_blocks; -if (dm_bufio_get_device_size (v->bufio) < f->hash_blocks) { +if (dm_bufio_get_device_size (v->bufio) < + v->hash_start + f->hash_blocks) { ti->error ="Hash device is too small for " DM_VERITY_OPT_FEC_BLOCKS ;return -E2BIG ;
Greg Kroah-Hartman
maintainerPATCH 354/969 isofs: validate Rock Ridge CE continuation extent against volume size
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Bommarito <[email protected]>
commit a36d990f591320e9dd379ab30063ebfe91d47e1f upstream.
rock_continue() reads rs->cont_extent verbatim from the Rock Ridge CE record and passes it to sb_bread() without checking that the block number is within the mounted ISO 9660 volume. commit e595447e177b ("[PATCH] rock.c: handle corrupted directories") added cont_offset and cont_size rejection for the CE continuation but did not validate the extent block number itself. commit f54e18f1b831 ("isofs: Fix infinite looping over CE entries") later capped the CE chain length at RR_MAX_CE_ENTRIES = 32 but again left the block number unchecked.
With a crafted ISO mounted via udisks2 (desktop optical auto-mount) or via CAP_SYS_ADMIN mount, rs->cont_extent can therefore point at an out-of-range block or at blocks belonging to an adjacent filesystem on the same block device. sb_bread() on an out-of-range block returns NULL cleanly via the block layer EIO path, so there is no memory-safety violation. For in-range reads of adjacent- filesystem data, the CE buffer is parsed as Rock Ridge records and only the text of SL sub-records reaches userspace through readlink(), which makes the info-leak channel narrow and difficult to exploit; still, rejecting the malformed CE outright matches the rejection shape already present in the same function for cont_offset and cont_size.
Add an ISOFS_SB(sb)->s_nzones bounds check to rock_continue() next to the existing offset/size rejection, printing the same corrupted-directory-entry notice.
--- fs/isofs/rock.c | 9 +++++++++ 1 file changed, 9 insertions(+)
fs/isofs/rock.c +9 -0
@@ -101,6 +101,15 @@ static int rock_continue(struct rock_sta goto out; } +if ((unsigned )rs->cont_extent >=ISOFS_SB (rs->inode->i_sb)->s_nzones) { +printk (KERN_NOTICE "rock: corrupted directory entry. " +"extent=%u out of volume (nzones=%lu)\n" , + (unsigned )rs->cont_extent, +ISOFS_SB (rs->inode->i_sb)->s_nzones); + ret = -EIO ; + goto out; + } +if (rs->cont_extent) {struct buffer_head *bh;
Greg Kroah-Hartman
maintainerPATCH 355/969 isofs: validate block number from NFS file handle in isofs_export_iget
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Bommarito <[email protected]>
commit 24376458138387fb251e782e624c7776e9826796 upstream.
isofs_fh_to_dentry() and isofs_fh_to_parent() pass an attacker- controlled block number (ifid->block or ifid->parent_block) from the NFS file handle to isofs_export_iget(), which only rejects block == 0 before calling isofs_iget() and ultimately sb_bread(). A crafted file handle with fh_len sufficient to pass the check added by commit 0405d4b63d08 ("isofs: Prevent the use of too small fid") can still drive the server to read any in-range block on the backing device as if it were an iso_directory_record. That earlier fix was assigned CVE-2025-37780.
sb_bread() on an out-of-range block returns NULL cleanly via the EIO path, so there is no memory-safety violation. For in-range reads of adjacent-partition data on the same block device, the unrelated bytes end up in iso_inode_info fields that reach the NFS client as dentry metadata. The deployment surface (isofs exported over NFS from loop-mounted images) is narrow and requires an authenticated NFS peer, but the malformed-file-handle class is reportable as hardening next to the existing CVE-2025-37780 fix.
Reject block >= ISOFS_SB(sb)->s_nzones in isofs_export_iget() so the check covers both isofs_fh_to_dentry() and isofs_fh_to_parent() call sites with a single line.
--- fs/isofs/export.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/isofs/export.c +1 -1
@@ -24,7 +24,7 @@ isofs_export_iget(struct super_block *sb {struct inode *inode; -if (block ==0 ) +if (block ==0 || block >=ISOFS_SB (sb)->s_nzones)return ERR_PTR (-ESTALE ); inode =isofs_iget (sb, block, offset);if (IS_ERR (inode))
Greg Kroah-Hartman
maintainerPATCH 356/969 libceph: Fix slab-out-of-bounds access in auth message processing
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Raphael Zimmer <[email protected]>
commit 1c439de70b1c3eb3c6bffa8245c16b9fc318f114 upstream.
If a (potentially corrupted) message of type CEPH_MSG_AUTH_REPLY contains a positive value in its result field, it is treated as an error code by ceph_handle_auth_reply() and returned to handle_auth_reply(). Thereafter, an attempt is made to send the preallocated message of type CEPH_MSG_AUTH, where the returned value is interpreted as the size of the front segment to send. If the result value in the message is greater than the size of the memory buffer allocated for the front segment, an out-of-bounds access occurs, and the content of the memory region beyond this buffer is sent out.
This patch fixes the issue by treating only negative values in the result field as errors. Positive values are therefore treated as success in the same way as a zero value. Additionally, a BUG_ON is added to __send_prepared_auth_request() comparing the len parameter to front_alloc_len to prevent sending the message if it exceeds the bounds of the allocation and to make it easier to catch any logic flaws leading to this.
--- net/ceph/auth.c | 2 +- net/ceph/mon_client.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-)
net/ceph/auth.c +1 -1
@@ -257,7 +257,7 @@ int ceph_handle_auth_reply(struct ceph_a ac->negotiating = false; } -if (result) { +if (result <0 ) {pr_err ("auth protocol '%s' mauth authentication failed: %d\n" ,ceph_auth_proto_name (ac->protocol), result); ret = result;
net/ceph/mon_client.c +2 -0
@@ -174,6 +174,8 @@ int ceph_monmap_contains(struct ceph_mon*/ static void __send_prepared_auth_request (struct ceph_mon_client *monc,int len) { +BUG_ON (len > monc->m_auth->front_alloc_len); + monc->pending_auth =1 ; monc->m_auth->front.iov_len = len; monc->m_auth->hdr.front_len =cpu_to_le32 (len);
Greg Kroah-Hartman
maintainerPATCH 357/969 md/raid10: fix divide-by-zero in setup_geo() with zero far_copies
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Junrui Luo <[email protected]>
commit 9aa6d860b0930e2f72795665c42c44252a558a0c upstream.
setup_geo() extracts near_copies (nc) and far_copies (fc) from the user-provided layout parameter without checking for zero. When fc=0 with the "improved" far set layout selected, 'geo->far_set_size = disks / fc' triggers a divide-by-zero.
Validate nc and fc immediately after extraction, returning -1 if either is zero.
--- drivers/md/raid10.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/md/raid10.c +2 -0
@@ -3993,6 +3993,8 @@ static int setup_geo(struct geom *geo, s nc = layout &255 ; fc = (layout >>8 ) &255 ; fo = layout & (1 <<16 ); +if (!nc || !fc) +return -1 ; geo->raid_disks = disks; geo->near_copies = nc; geo->far_copies = fc;
Greg Kroah-Hartman
maintainerPATCH 358/969 nvme-apple: drop invalid put of admin queue reference count
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fedor Pchelkin <[email protected]>
commit ba9d308ccd6732dd97ed8080d834a4a89e758e14 upstream.
Commit 03b3bcd319b3 ("nvme: fix admin request_queue lifetime") moved the admin queue reference ->put call into nvme_free_ctrl() - a controller device release callback performed for every nvme driver doing nvme_init_ctrl().
nvme-apple sets refcount of the admin queue to 1 at allocation during the probe function and then puts it twice now:
nvme_free_ctrl()
blk_put_queue(ctrl->admin_q) // #1
->free_ctrl()
apple_nvme_free_ctrl()
blk_put_queue(anv->ctrl.admin_q) // #2Note that there is a commit 941f7298c70c ("nvme-apple: remove an extra queue reference") which intended to drop taking an extra admin queue reference. Looks like at that moment it accidentally fixed a refcount leak, which existed since the driver's introduction. There were two ->get calls at driver's probe function and a single ->put inside apple_nvme_free_ctrl().
However now after commit 03b3bcd319b3 ("nvme: fix admin request_queue lifetime") the refcount is imbalanced again. Fix it by removing extra ->put call from apple_nvme_free_ctrl(). anv->dev and ctrl->dev point to the same device, so use ctrl->dev directly for simplification. Compile tested only.
Found by Linux Verification Center (linuxtesting.org).
--- drivers/nvme/host/apple.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/nvme/host/apple.c +1 -5
@@ -1194,11 +1194,7 @@ static int apple_nvme_get_address(structstatic void apple_nvme_free_ctrl (struct nvme_ctrl *ctrl) { -struct apple_nvme *anv =ctrl_to_apple_nvme (ctrl); - -if (anv->ctrl.admin_q) -blk_put_queue (anv->ctrl.admin_q); -put_device (anv->dev); +put_device (ctrl->dev); }static const struct nvme_ctrl_ops nvme_ctrl_ops = {
Greg Kroah-Hartman
maintainerPATCH 359/969 nvmet: avoid recursive nvmet-wq flush in nvmet_ctrl_free
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chaitanya Kulkarni <[email protected]>
commit aade8abd8b868b6ffa9697aadaea28ec7f65bee6 upstream.
nvmet_tcp_release_queue_work() runs on nvmet-wq and can drop the final controller reference through nvmet_cq_put(). If that triggers nvmet_ctrl_free(), the teardown path flushes ctrl->async_event_work on the same nvmet-wq.
Call chain:
nvmet_tcp_schedule_release_queue()
kref_put(&queue->kref, nvmet_tcp_release_queue)
nvmet_tcp_release_queue()
queue_work(nvmet_wq, &queue->release_work) <--- nvmet_wq
process_one_work()
nvmet_tcp_release_queue_work()
nvmet_cq_put(&queue->nvme_cq)
nvmet_cq_destroy()
nvmet_ctrl_put(cq->ctrl)
nvmet_ctrl_free()
flush_work(&ctrl->async_event_work) <--- nvmet_wq
Previously Scheduled by :-
nvmet_add_async_event
queue_work(nvmet_wq, &ctrl->async_event_work);This trips lockdep with a possible recursive locking warning.
[ 5223.015876] run blktests nvme/003 at 2026-04-07 20:53:55 [ 5223.061801] loop0: detected capacity change from 0 to 2097152 [ 5223.072206] nvmet: adding nsid 1 to subsystem blktests-subsystem-1 [ 5223.088368] nvmet_tcp: enabling port 0 (127.0.0.1:4420) [ 5223.126086] nvmet: Created discovery controller 1 for subsystem nqn.2014-08.org.nvmexpress.discovery for NQN nqn.2014-08.org.nvmexpress:uuid:0f01fb42-9f7f-4856-b0b3-51e60b8de349. [ 5223.128453] nvme nvme1: new ctrl: NQN "nqn.2014-08.org.nvmexpress.discovery", addr 127.0.0.1:4420, hostnqn: nqn.2014-08.org.nvmexpress:uuid:0f01fb42-9f7f-4856-b0b3-51e60b8de349 [ 5233.199447] nvme nvme1: Removing ctrl: NQN "nqn.2014-08.org.nvmexpress.discovery"
[ 5233.227718] ============================================
[ 5233.231283] WARNING: possible recursive locking detected
[ 5233.234696] 7.0.0-rc3nvme+ #20 Tainted: G O N
[ 5233.238434] --------------------------------------------
[ 5233.241852] kworker/u192:6/2413 is trying to acquire lock:
[ 5233.245429] ffff888111632548 ((wq_completion)nvmet-wq){+.+.}-{0:0}, at: touch_wq_lockdep_map+0x26/0x90
[ 5233.251438]
but task is already holding lock:
[ 5233.255254] ffff888111632548 ((wq_completion)nvmet-wq){+.+.}-{0:0}, at: process_one_work+0x5cc/0x6e0
[ 5233.261125]
other info that might help us debug this:
[ 5233.265333] Possible unsafe locking scenario:[ 5233.269217] CPU0
[ 5233.270795] ----
[ 5233.272436] lock((wq_completion)nvmet-wq);
[ 5233.275241] lock((wq_completion)nvmet-wq);
[ 5233.278020]
*** DEADLOCK ***[ 5233.281793] May be due to missing lock nesting notation
[ 5233.286195] 3 locks held by kworker/u192:6/2413:
[ 5233.289192] #0: ffff888111632548 ((wq_completion)nvmet-wq){+.+.}-{0:0}, at: process_one_work+0x5cc/0x6e0
[ 5233.294569] #1: ffffc9000e2a7e40 ((work_completion)(&queue->release_work)){+.+.}-{0:0}, at: process_one_work+0x1c5/0x6e0
[ 5233.300128] #2: ffffffff82d7dc40 (rcu_read_lock){....}-{1:3}, at: __flush_work+0x62/0x530
[ 5233.304290]
stack backtrace:
[ 5233.306520] CPU: 4 UID: 0 PID: 2413 Comm: kworker/u192:6 Tainted: G O N 7.0.0-rc3nvme+ #20 PREEMPT(full)
[ 5233.306524] Tainted: [O]=OOT_MODULE, [N]=TEST
[ 5233.306525] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.17.0-0-gb52ca86e094d-prebuilt.qemu.org 04/01/2014
[ 5233.306527] Workqueue: nvmet-wq nvmet_tcp_release_queue_work [nvmet_tcp]
[ 5233.306532] Call Trace:
[ 5233.306534] <TASK>
[ 5233.306536] dump_stack_lvl+0x73/0xb0
[ 5233.306552] print_deadlock_bug+0x225/0x2f0
[ 5233.306556] __lock_acquire+0x13f0/0x2290
[ 5233.306563] lock_acquire+0xd0/0x300
[ 5233.306565] ? touch_wq_lockdep_map+0x26/0x90
[ 5233.306571] ? __flush_work+0x20b/0x530
[ 5233.306573] ? touch_wq_lockdep_map+0x26/0x90
[ 5233.306577] touch_wq_lockdep_map+0x3b/0x90
[ 5233.306580] ? touch_wq_lockdep_map+0x26/0x90
[ 5233.306583] ? __flush_work+0x20b/0x530
[ 5233.306585] __flush_work+0x268/0x530
[ 5233.306588] ? __pfx_wq_barrier_func+0x10/0x10
[ 5233.306594] ? xen_error_entry+0x30/0x60
[ 5233.306600] nvmet_ctrl_free+0x140/0x310 [nvmet]
[ 5233.306617] nvmet_cq_put+0x74/0x90 [nvmet]
[ 5233.306629] nvmet_tcp_release_queue_work+0x19f/0x360 [nvmet_tcp]
[ 5233.306634] process_one_work+0x206/0x6e0
[ 5233.306640] worker_thread+0x184/0x320
[ 5233.306643] ? __pfx_worker_thread+0x10/0x10
[ 5233.306646] kthread+0xf1/0x130
[ 5233.306648] ? __pfx_kthread+0x10/0x10
[ 5233.306651] ret_from_fork+0x355/0x450
[ 5233.306653] ? __pfx_kthread+0x10/0x10
[ 5233.306656] ret_from_fork_asm+0x1a/0x30
[ 5233.306664] </TASK>There is also no need to flush async_event_work from controller teardown. The admin queue teardown already fails outstanding AER requests before the final controller put :-
nvmet_sq_destroy(admin sq)
nvmet_async_events_failall(ctrl)
The controller has already been removed from the subsystem list before nvmet_ctrl_free() quiesces outstanding work.
Replace flush_work() with cancel_work_sync() so a pending async_event_work item is canceled and a running instance is waited on without recursing into the same workqueue.
--- drivers/nvme/target/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/target/core.c +1 -1
@@ -1496,7 +1496,7 @@ static void nvmet_ctrl_free(struct krefnvmet_stop_keep_alive_timer (ctrl); -flush_work (&ctrl->async_event_work); +cancel_work_sync (&ctrl->async_event_work);cancel_work_sync (&ctrl->fatal_err_work);nvmet_destroy_auth (ctrl);
Greg Kroah-Hartman
maintainerPATCH 360/969 openvswitch: vport: fix self-deadlock on release of tunnel ports
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilya Maximets <[email protected]>
commit aa69918bd418e700309fdd08509dba324fb24296 upstream.
vports are used concurrently and protected by RCU, so netdev_put() must happen after the RCU grace period. So, either in an RCU call or after the synchronize_net(). The rtnl_delete_link() must happen under RTNL and so can't be executed in RCU context. Calling synchronize_net() while holding RTNL is not a good idea for performance and system stability under load in general, so calling netdev_put() in RCU call is the right solution here.
However,
when the device is deleted, rtnl_unlock() will call netdev_run_todo() and block until all the references are gone. In the current code this means that we never reach the call_rcu() and the vport is never freed and the reference is never released, causing a self-deadlock on device removal.
Fix that by moving the rcu_call() before the rtnl_unlock(), so the scheduled RCU callback will be executed when synchronize_net() is called from the rtnl_unlock()->netdev_run_todo() while the RTNL itself is already released.
--- net/openvswitch/vport-netdev.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
net/openvswitch/vport-netdev.c +5 -1
@@ -189,9 +189,13 @@ void ovs_netdev_tunnel_destroy(struct vp*/ if (vport->dev->reg_state ==NETREG_REGISTERED )rtnl_delete_link (vport->dev,0 ,NULL ); -rtnl_unlock (); +/* We can't put the device reference yet, since it can still be in +* use, but rtnl_unlock()->netdev_run_todo() will block until all +* the references are released, so the RCU call must be before it. +*/ call_rcu (&vport->rcu, vport_netdev_free); +rtnl_unlock (); }EXPORT_SYMBOL_GPL (ovs_netdev_tunnel_destroy);
Greg Kroah-Hartman
maintainerPATCH 361/969 RDMA/hns: Fix unlocked call to hns_roce_qp_remove()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason Gunthorpe <[email protected]>
commit 0c99acbc8b6c6dd526ae475a48ee1897b61072fb upstream.
Sashiko points out that hns_roce_qp_remove() requires the caller to hold locks. The error flow in hns_roce_create_qp_common() doesn't hold those locks for the error unwind so it risks corrupting memory.
Grab the same locks the other two callers use.
--- drivers/infiniband/hw/hns/hns_roce_qp.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/infiniband/hw/hns/hns_roce_qp.c +7 -0
@@ -1146,6 +1146,7 @@ static int hns_roce_create_qp_common(strstruct hns_roce_ib_create_qp_resp resp = {};struct ib_device *ibdev = &hr_dev->ib_dev;struct hns_roce_ib_create_qp ucmd = {}; +unsigned long flags;int ret;mutex_init (&hr_qp->mutex);
@@ -1229,7 +1230,13 @@ static int hns_roce_create_qp_common(strreturn 0 ; err_flow_ctrl: +spin_lock_irqsave (&hr_dev->qp_list_lock, flags); +hns_roce_lock_cqs (init_attr->send_cq ?to_hr_cq (init_attr->send_cq) :NULL , + init_attr->recv_cq ?to_hr_cq (init_attr->recv_cq) :NULL );hns_roce_qp_remove (hr_dev, hr_qp); +hns_roce_unlock_cqs (init_attr->send_cq ?to_hr_cq (init_attr->send_cq) :NULL , + init_attr->recv_cq ?to_hr_cq (init_attr->recv_cq) :NULL ); +spin_unlock_irqrestore (&hr_dev->qp_list_lock, flags); err_store:free_qpc (hr_dev, hr_qp); err_qpc:
Greg Kroah-Hartman
maintainerPATCH 362/969 s390/debug: Reject zero-length input in debug_input_flush_fn()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vasily Gorbik <[email protected]>
commit e14622a7584f9608927c59a7d6ae4a0999dc545e upstream.
debug_input_flush_fn() always copies one byte from the userspace buffer with copy_from_user() regardless of the supplied write length. A zero-length write therefore reads one byte beyond the caller's buffer. If the stale byte happens to be '-' or a digit the debug log is silently flushed. With an unmapped buffer the call returns -EFAULT.
Reject zero-length writes before copying from userspace.
--- arch/s390/kernel/debug.c | 5 +++++ 1 file changed, 5 insertions(+)
arch/s390/kernel/debug.c +5 -0
@@ -1444,6 +1444,11 @@ static int debug_input_flush_fn(debug_inchar input_buf[1 ];int rc = user_len; +if (!user_len) { + rc = -EINVAL ; + goto out; + } +if (user_len >0x10000 ) user_len =0x10000 ;if (*offset !=0 ) {
Greg Kroah-Hartman
maintainerPATCH 363/969 smb/client: fix out-of-bounds read in symlink_data()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zisen Ye <[email protected]>
commit d62b8d236fab503c6fec1d3e9a38bea71feaca20 upstream.
Since smb2_check_message() returns success without length validation for the symlink error response, in symlink_data() it is possible for iov->iov_len to be smaller than sizeof(struct smb2_err_rsp). If the buffer only contains the base SMB2 header (64 bytes), accessing err->ErrorContextCount (at offset 66) or err->ByteCount later in symlink_data() will cause an out-of-bounds read.
--- fs/smb/client/smb2misc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/smb/client/smb2misc.c +2 -1
@@ -239,7 +239,8 @@ smb2_check_message(char *buf, unsigned iif (len != calc_len) {/* create failed on symlink */ if (command ==SMB2_CREATE_HE && - shdr->Status ==STATUS_STOPPED_ON_SYMLINK ) + shdr->Status ==STATUS_STOPPED_ON_SYMLINK && + len > calc_len)return 0 ;/* Windows 7 server returns 24 bytes more */ if (calc_len +24 == len && command ==SMB2_OPLOCK_BREAK_HE )
Greg Kroah-Hartman
maintainerPATCH 364/969 PCI/AER: Clear only error bits in PCIe Device Status
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shuai Xue <[email protected]>
commit a8aeea1bf3c80cc87983689e0118770e019bd4f3 upstream.
Currently, pcie_clear_device_status() clears the entire PCIe Device Status register (PCI_EXP_DEVSTA) by writing back the value read from the register, which affects not only the error status bits but also other writable bits.
According to PCIe r7.0, sec 7.5.3.5, this register contains:
- RW1C error status bits (CED, NFED, FED, URD at bits 0-3): These are the four error status bits that need to be cleared.
- Read-only bits (AUXPD at bit 4, TRPND at bit 5): Writing to these has no effect.
- Emergency Power Reduction Detected (bit 6): A RW1C non-error bit introduced in PCIe r5.0 (2019). This is currently the only writable non-error bit in the Device Status register. Unconditionally clearing this bit can interfere with other software components that rely on this power management indication.
- Reserved bits (RsvdZ): These bits are required to be written as zero. Writing 1s to them (as the current implementation may do) violates the specification.
To prevent unintended side effects, modify pcie_clear_device_status() to only write 1s to the four error status bits (CED, NFED, FED, URD), leaving the Emergency Power Reduction Detected bit and reserved bits unaffected.
--- drivers/pci/pci.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/pci/pci.c +3 -4
@@ -2396,10 +2396,9 @@ EXPORT_SYMBOL_GPL(pci_set_pcie_reset_sta#ifdef CONFIG_PCIEAER void pcie_clear_device_status (struct pci_dev *dev) { -u16 sta; - -pcie_capability_read_word (dev,PCI_EXP_DEVSTA , &sta); -pcie_capability_write_word (dev,PCI_EXP_DEVSTA , sta); +pcie_capability_write_word (dev,PCI_EXP_DEVSTA , +PCI_EXP_DEVSTA_CED |PCI_EXP_DEVSTA_NFED | +PCI_EXP_DEVSTA_FED |PCI_EXP_DEVSTA_URD ); }#endif
Greg Kroah-Hartman
maintainerPATCH 365/969 PCI/AER: Stop ruling out unbound devices as error source
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lukas Wunner <[email protected]>
commit 1ab4a3c805084d752ec571efc78272295a9f2f74 upstream.
When searching for the error source, the AER driver rules out devices whose enable_cnt is zero. This was introduced in 2009 by commit 28eb27cf0839 ("PCI AER: support invalid error source IDs") without providing a rationale.
Drivers typically call pci_enable_device() on probe, hence the enable_cnt check essentially filters out unbound devices. At the time of the commit, drivers had to opt in to AER by calling pci_enable_pcie_error_reporting() and so any AER-enabled device could be assumed to be bound to a driver. The check thus made sense because it allowed skipping config space accesses to devices which were known not to be the error source.
But since 2022, AER is universally enabled on all devices when they are enumerated, cf. commit f26e58bf6f54 ("PCI/AER: Enable error reporting when AER is native").
Errors may very well be reported by unbound devices, e.g. due to link instability. By ruling them out as error source, errors reported by them are neither logged nor cleared. When they do get bound and another error occurs, the earlier error is reported together with the new error, which may confuse users. Stop doing so.
--- drivers/pci/pcie/aer.c | 2 -- 1 file changed, 2 deletions(-)
drivers/pci/pcie/aer.c +0 -2
@@ -857,8 +857,6 @@ static bool is_error_source(struct pci_d* 3) There are multiple errors and prior ID comparing fails; * We check AER status registers to find possible reporter. */ -if (atomic_read (&dev->enable_cnt) ==0 ) -return false;/* Check if AER is enabled */ pcie_capability_read_word (dev,PCI_EXP_DEVCTL , ®16);
Greg Kroah-Hartman
maintainerPATCH 366/969 power: supply: max17042: avoid overflow when determining health
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: André Draszik <[email protected]>
commit 9a44949da669708f19d29141e65b3ac774d08f5a upstream.
If vmax has the default value of INT_MAX (e.g. because not specified in DT), battery health is reported as over-voltage. This is because adding any value to vmax (the vmax tolerance in this case) causes it to wrap around, making it negative and smaller than the measured battery voltage.
Avoid that by using size_add().
--- drivers/power/supply/max17042_battery.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/power/supply/max17042_battery.c +1 -1
@@ -199,7 +199,7 @@ static int max17042_get_battery_health(s goto out; } -if (vbatt > chip->pdata->vmax +MAX17042_VMAX_TOLERANCE ) { +if (vbatt >size_add (chip->pdata->vmax,MAX17042_VMAX_TOLERANCE )) { *health =POWER_SUPPLY_HEALTH_OVERVOLTAGE ; goto out; }
Greg Kroah-Hartman
maintainerPATCH 367/969 RDMA/mlx4: Fix resource leak on error in mlx4_ib_create_srq()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason Gunthorpe <[email protected]>
commit c54c7e4cb679c0aaa1cb489b9c3f2cd98e63a44c upstream.
Sashiko points out that mlx4_srq_alloc() was not undone during error unwind, add the missing call to mlx4_srq_free().
--- drivers/infiniband/hw/mlx4/srq.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/infiniband/hw/mlx4/srq.c +3 -1
@@ -193,13 +193,15 @@ int mlx4_ib_create_srq(struct ib_srq *ibif (udata)if (ib_copy_to_udata (udata, &srq->msrq.srqn,sizeof (__u32))) { err = -EFAULT ; - goto err_wrid; + goto err_srq; } init_attr->attr.max_wr = srq->msrq.max -1 ;return 0 ; +err_srq: +mlx4_srq_free (dev->dev, &srq->msrq); err_wrid:if (udata)mlx4_ib_db_unmap_user (ucontext, &srq->db);
Greg Kroah-Hartman
maintainerPATCH 368/969 RDMA/ocrdma: Dont NULL deref uctx on errors in ocrdma_copy_pd_uresp()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason Gunthorpe <[email protected]>
commit 34fbf48cf3b410d2a6e8c586fa952a36331ca5ba upstream.
Sashiko points out that pd->uctx isn't initialized until late in the function so all these error flow references are NULL and will crash. Use the uctx that isn't NULL.
--- drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +2 -2
@@ -620,9 +620,9 @@ static int ocrdma_copy_pd_uresp(struct o ucopy_err:if (pd->dpp_enabled) -ocrdma_del_mmap (pd->uctx, dpp_page_addr,PAGE_SIZE ); +ocrdma_del_mmap (uctx, dpp_page_addr,PAGE_SIZE ); dpp_map_err: -ocrdma_del_mmap (pd->uctx, db_page_addr, db_page_size); +ocrdma_del_mmap (uctx, db_page_addr, db_page_size);return status; }
Greg Kroah-Hartman
maintainerPATCH 369/969 RDMA/rxe: Reject unknown opcodes before ICRC processing
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Bommarito <[email protected]>
commit 4c6f86d85d03cdb33addce86aa69aa795ca6c47a upstream.
Even after applying commit 7244491dab34 ("RDMA/rxe: Validate pad and ICRC before payload_size() in rxe_rcv"), a single unauthenticated UDP packet can still trigger panic. That patch handled payload_size() underflow only for valid opcodes with short packets, not for packets carrying an unknown opcode. The unknown-opcode OOB read described below predates that commit and reaches back to the initial Soft RoCE driver.
The check added there reads
pkt->paylen < header_size(pkt) + bth_pad(pkt) + RXE_ICRC_SIZE
where header_size(pkt) expands to rxe_opcode[pkt->opcode].length. The rxe_opcode[] array has 256 entries but is only populated for defined IB opcodes; any other entry (for example opcode 0xff) is zero-initialized, so length == 0 and the check degenerates to
pkt->paylen < 0 + bth_pad(pkt) + RXE_ICRC_SIZE
which does not constrain pkt->paylen enough. rxe_icrc_hdr() then computes
rxe_opcode[pkt->opcode].length - RXE_BTH_BYTES
which underflows when length == 0 and passes a huge value to rxe_crc32(), causing an out-of-bounds read of the skb payload.
Reproduced on v7.0-rc7 with that fix applied, QEMU/KVM with CONFIG_RDMA_RXE=y and CONFIG_KASAN=y, after
rdma link add rxe0 type rxe netdev eth0
A single 48-byte UDP packet to port 4791 with BTH opcode=0xff and QPN=IB_MULTICAST_QPN triggers:
BUG: KASAN: slab-out-of-bounds in crc32_le+0x115/0x170
Read of size 1 at addr ...
The buggy address is located 0 bytes to the right of
allocated 704-byte region
Call Trace:
crc32_le+0x115/0x170
rxe_icrc_hdr.isra.0+0x226/0x300
rxe_icrc_check+0x13f/0x3a0
rxe_rcv+0x6e1/0x16e0
rxe_udp_encap_recv+0x20a/0x320
udp_queue_rcv_one_skb+0x7ed/0x12c0Subsequent packets with the same shape fault on unmapped memory and panic the kernel. The trigger requires only module load and "rdma link add"; no QP, no connection, and no authentication.
Fix this by rejecting packets whose opcode has no rxe_opcode[] entry, detected via the zero mask or zero length, before any length arithmetic runs.
--- drivers/infiniband/sw/rxe/rxe_recv.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/infiniband/sw/rxe/rxe_recv.c +11 -0
@@ -322,6 +322,17 @@ void rxe_rcv(struct sk_buff *skb) pkt->qp =NULL ; pkt->mask |= rxe_opcode[pkt->opcode].mask; +/* +* Unknown opcodes have a zero-initialized rxe_opcode[] entry, so +* both mask and length are 0. Reject them before any length math: +* rxe_icrc_hdr() would otherwise compute length - RXE_BTH_BYTES +* and pass the underflowed value to rxe_crc32(), producing an +* out-of-bounds read. +*/ +if (unlikely (!rxe_opcode[pkt->opcode].mask || + !rxe_opcode[pkt->opcode].length)) + goto drop; +if (unlikely (pkt->paylen <header_size (pkt) +bth_pad (pkt) +RXE_ICRC_SIZE )) goto drop;
Greg Kroah-Hartman
maintainerPATCH 370/969 RDMA/vmw_pvrdma: Fix double free on pvrdma_alloc_ucontext() error path
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason Gunthorpe <[email protected]>
commit e38e86995df27f1f854063dab1f0c6a513db3faf upstream.
Sashiko points out that pvrdma_uar_free() is already called within pvrdma_dealloc_ucontext(), so calling it before triggers a double free.
--- drivers/infiniband/hw/vmw_pvrdma/pvrdma_verbs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/vmw_pvrdma/pvrdma_verbs.c +1 -1
@@ -350,7 +350,7 @@ int pvrdma_alloc_ucontext(struct ib_ucon uresp.qp_tab_size = vdev->dsr->caps.max_qp; ret =ib_copy_to_udata (udata, &uresp,sizeof (uresp));if (ret) { -pvrdma_uar_free (vdev, &context->uar); +/* pvrdma_dealloc_ucontext() also frees the UAR */ pvrdma_dealloc_ucontext (&context->ibucontext);return -EFAULT ; }
Greg Kroah-Hartman
maintainerPATCH 371/969 mptcp: use MPJoinSynAckHMacFailure for SynAck HMAC failure
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shardul Bankar <[email protected]>
commit c4a99a921949cddc590b22bb14eeb23dffcc3ba6 upstream.
In subflow_finish_connect(), HMAC validation of the server's HMAC in SYN/ACK + MP_JOIN increments MPTCP_MIB_JOINACKMAC ("HMAC was wrong on ACK + MP_JOIN") on failure. The function processes the SYN/ACK, not the ACK; the matching MPTCP_MIB_JOINSYNACKMAC counter ("HMAC was wrong on SYN/ACK + MP_JOIN") exists but is not incremented anywhere in the tree.
The mirror site on the server, subflow_syn_recv_sock(), already uses JOINACKMAC correctly for ACK HMAC failure. Use JOINSYNACKMAC at the SYN/ACK validation site so each counter reflects the packet whose HMAC actually failed.
--- net/mptcp/subflow.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/mptcp/subflow.c +1 -1
@@ -469,7 +469,7 @@ static void subflow_finish_connect(struc subflow->backup);if (!subflow_thmac_valid (subflow)) { -MPTCP_INC_STATS (sock_net (sk),MPTCP_MIB_JOINACKMAC ); +MPTCP_INC_STATS (sock_net (sk),MPTCP_MIB_JOINSYNACKMAC ); subflow->reset_reason =MPTCP_RST_EMPTCP ; goto do_reset; }
Greg Kroah-Hartman
maintainerPATCH 372/969 mptcp: use MPTCP_RST_EMPTCP for ACK HMAC validation failure
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shardul Bankar <[email protected]>
commit a6da02d4c00fdda2417e42ad2b762a9209e6cc49 upstream.
When HMAC validation fails on a received ACK + MP_JOIN in subflow_syn_recv_sock(), the subflow is reset with reason MPTCP_RST_EPROHIBIT ("Administratively prohibited"). This is
incorrect: HMAC validation failure is an MPTCP protocol-level error, not an administrative policy denial.
The mirror site on the client, in subflow_finish_connect(), already uses MPTCP_RST_EMPTCP ("MPTCP-specific error") for the same kind of HMAC failure on the SYN/ACK + MP_JOIN. Use the same reason on the server side for symmetry and accuracy.
--- net/mptcp/subflow.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/mptcp/subflow.c +1 -1
@@ -796,7 +796,7 @@ create_child:if (!subflow_hmac_valid (req, &mp_opt)) {SUBFLOW_REQ_INC_STATS (req,MPTCP_MIB_JOINACKMAC ); -subflow_add_reset_reason (skb,MPTCP_RST_EPROHIBIT ); +subflow_add_reset_reason (skb,MPTCP_RST_EMPTCP ); goto dispose_child; }
Greg Kroah-Hartman
maintainerPATCH 373/969 mptcp: sockopt: set timestamp flags on subflow socket, not msk
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gang Yan <[email protected]>
commit 5f95c21fc23a7ef22b4d27d1ed9bb55557ffb926 upstream.
Both mptcp_setsockopt_sol_socket_tstamp() and mptcp_setsockopt_sol_socket_timestamping() iterate over subflows, acquire the subflow socket lock, but then erroneously pass the MPTCP msk socket to sock_set_timestamp() / sock_set_timestamping() instead of the subflow ssk. As a result, the timestamp flags are set on the wrong socket and have no effect on the actual subflows.
Pass ssk instead of sk to both helpers.
--- net/mptcp/sockopt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/mptcp/sockopt.c +2 -2
@@ -159,7 +159,7 @@ static int mptcp_setsockopt_sol_socket_tstruct sock *ssk =mptcp_subflow_tcp_sock (subflow);bool slow =lock_sock_fast (ssk); -sock_set_timestamp (sk, optname, !!val); +sock_set_timestamp (ssk, optname, !!val);unlock_sock_fast (ssk, slow); }
@@ -235,7 +235,7 @@ static int mptcp_setsockopt_sol_socket_tstruct sock *ssk =mptcp_subflow_tcp_sock (subflow);bool slow =lock_sock_fast (ssk); -sock_set_timestamping (sk, optname, timestamping); +sock_set_timestamping (ssk, optname, timestamping);unlock_sock_fast (ssk, slow); }
Greg Kroah-Hartman
maintainerPATCH 374/969 mptcp: fix scheduling with atomic in timestamp sockopt
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gang Yan <[email protected]>
commit b5c52908d52c6c8eb8933264aa6087a0600fd892 upstream.
Using lock_sock_fast() (atomic context) around sock_set_timestamp() and sock_set_timestamping() is unsafe, as both helpers can sleep.
Replace lock_sock_fast() with sleepable lock_sock()/release_sock() to avoid scheduling while atomic panic.
--- net/mptcp/sockopt.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
net/mptcp/sockopt.c +4 -4
@@ -157,10 +157,10 @@ static int mptcp_setsockopt_sol_socket_tlock_sock (sk);mptcp_for_each_subflow (msk, subflow) {struct sock *ssk =mptcp_subflow_tcp_sock (subflow); -bool slow =lock_sock_fast (ssk); +lock_sock (ssk);sock_set_timestamp (ssk, optname, !!val); -unlock_sock_fast (ssk, slow); +release_sock (ssk); }release_sock (sk);
@@ -233,10 +233,10 @@ static int mptcp_setsockopt_sol_socket_tmptcp_for_each_subflow (msk, subflow) {struct sock *ssk =mptcp_subflow_tcp_sock (subflow); -bool slow =lock_sock_fast (ssk); +lock_sock (ssk);sock_set_timestamping (ssk, optname, timestamping); -unlock_sock_fast (ssk, slow); +release_sock (ssk); }release_sock (sk);
Greg Kroah-Hartman
maintainerPATCH 375/969 f2fs: add READ_ONCE() for i_blocks in f2fs_update_inode()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
commit 5471834a96fb697874be2ca0b052e74bcf3c23d1 upstream.
f2fs_update_inode() reads inode->i_blocks without holding i_lock to serialize it to the on-disk inode, while concurrent truncate or allocation paths may modify i_blocks under i_lock. Since blkcnt_t is u64, this risks torn reads on 32-bit architectures.
Following the approach in ext4_inode_blocks_set(), add READ_ONCE() to prevent potential compiler-induced tearing.
--- fs/f2fs/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/inode.c +1 -1
@@ -597,7 +597,7 @@ void f2fs_update_inode(struct inode *ino ri->i_uid =cpu_to_le32 (i_uid_read (inode)); ri->i_gid =cpu_to_le32 (i_gid_read (inode)); ri->i_links =cpu_to_le32 (inode->i_nlink); - ri->i_blocks =cpu_to_le64 (SECTOR_TO_BLOCK (inode->i_blocks) +1 ); + ri->i_blocks =cpu_to_le64 (SECTOR_TO_BLOCK (READ_ONCE (inode->i_blocks)) +1 );if (!f2fs_is_atomic_file (inode) ||is_inode_flag_set (inode,FI_ATOMIC_COMMITTED ))
Greg Kroah-Hartman
maintainerPATCH 376/969 f2fs: fix fiemap boundary handling when read extent cache is incomplete
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yongpeng Yang <[email protected]>
commit 95e159ad3e52f7478cfd22e44ec37c9f334f8993 upstream.
f2fs_fiemap() calls f2fs_map_blocks() to obtain the block mapping a file, and then merges contiguous mappings into extents. If the mapping is found in the read extent cache, node blocks do not need to be read. However, in the following scenario, a contiguous extent can be split into two extents:
$ dd if=/dev/zero of=data.128M bs=1M count=128 $ losetup -f data.128M $ mkfs.f2fs /dev/loop0 -f $ mount -o mode=lfs /dev/loop0 /mnt/f2fs/ $ cd /mnt/f2fs/ $ dd if=/dev/zero of=data.72M bs=1M count=72 && sync $ dd if=/dev/zero of=data.4M bs=1M count=4 && sync $ dd if=/dev/zero of=data.4M bs=1M count=2 seek=2 conv=notrunc && sync $ echo 3 > /proc/sys/vm/drop_caches $ dd if=/dev/zero of=data.4M bs=1M count=2 seek=0 conv=notrunc && sync $ dd if=/dev/zero of=data.4M bs=1M count=2 seek=0 conv=notrunc && sync $ f2fs_io fiemap 0 1024 data.4M Fiemap: offset = 0 len = 1024 logical addr. physical addr. length flags 0 0000000000000000 0000000006400000 0000000000200000 00001000 1 0000000000200000 0000000006600000 0000000000200000 00001001
Although the physical addresses of the ranges 0~2MB and 2M~4MB are contiguous, the mapping for the 2M~4MB range is not present in memory. When the physical addresses for the 0~2MB range are updated, no merge happens because the adjacent mapping is missing from the in-memory cache. As a result, fiemap reports two separate extents instead of a single contiguous one.
The root cause is that the read extent cache does not guarantee that all blocks of an extent are present in memory. Therefore, when the extent length returned by f2fs_map_blocks_cached() is smaller than maxblocks, the remaining mappings are retrieved via f2fs_get_dnode_of_data() to ensure correct fiemap extent boundary handling.
--- fs/f2fs/data.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-)
fs/f2fs/data.c +22 -3
@@ -1522,8 +1522,26 @@ int f2fs_map_blocks(struct inode *inode,if (!maxblocks)return 0 ; -if (!map->m_may_create &&f2fs_map_blocks_cached (inode, map, flag)) - goto out; +if (!map->m_may_create &&f2fs_map_blocks_cached (inode, map, flag)) { +struct extent_info ei; + +/* +* 1. If map->m_multidev_dio is true, map->m_pblk cannot be +* waitted by f2fs_wait_on_block_writeback_range() and are not +* mergeable. +* 2. If pgofs hits the read extent cache, it means the mapping +* is already cached in the extent cache, but it is not +* mergeable, and there is no need to query the mapping again +* via f2fs_get_dnode_of_data(). +*/ + pgofs = (pgoff_t )map->m_lblk + map->m_len; +if (map->m_len == maxblocks || + map->m_multidev_dio || +f2fs_lookup_read_extent_cache (inode, pgofs, &ei)) + goto out; + ofs = map->m_len; + goto map_more; + } map->m_bdev = inode->i_sb->s_bdev; map->m_multidev_dio =
@@ -1534,7 +1552,8 @@ int f2fs_map_blocks(struct inode *inode,/* it only supports block size == page size */ pgofs = (pgoff_t )map->m_lblk; - end = pgofs + maxblocks; +map_more: + end = (pgoff_t )map->m_lblk + maxblocks; next_dnode:if (map->m_may_create) {
Greg Kroah-Hartman
maintainerPATCH 377/969 f2fs: fix incorrect multidevice info in trace_f2fs_map_blocks()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yongpeng Yang <[email protected]>
commit eb2ca3ca983551a80e16a4a25df5a4ce59df8484 upstream.
When f2fs_map_blocks()->f2fs_map_blocks_cached() hits the read extent cache, map->m_multidev_dio is not updated, which leads to incorrect multidevice information being reported by trace_f2fs_map_blocks().
This patch updates map->m_multidev_dio in f2fs_map_blocks_cached() when the read extent cache is hit.
--- fs/f2fs/data.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/f2fs/data.c +2 -1
@@ -1487,7 +1487,8 @@ static bool f2fs_map_blocks_cached(strucf2fs_wait_on_block_writeback_range (inode, map->m_pblk, map->m_len); -if (f2fs_allow_multi_device_dio (sbi, flag)) { + map->m_multidev_dio =f2fs_allow_multi_device_dio (sbi, flag); +if (map->m_multidev_dio) {int bidx =f2fs_target_device_index (sbi, map->m_pblk);struct f2fs_dev_info *dev = &sbi->devs[bidx];
Greg Kroah-Hartman
maintainerPATCH 378/969 KVM: arm64: vgic: Fix IIDR revision field extracted from wrong value
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Woodhouse <[email protected]>
commit a0e6ae45af17e8b27958830595799c702ffbab8d upstream.
The uaccess write handlers for GICD_IIDR in both GICv2 and GICv3 extract the revision field from 'reg' (the current IIDR value read back from the emulated distributor) instead of 'val' (the value userspace is trying to write). This means userspace can never actually change the implementation revision — the extracted value is always the current one.
Fix the FIELD_GET to use 'val' so that userspace can select a different revision for migration compatibility.
--- arch/arm64/kvm/vgic/vgic-mmio-v2.c | 2 +- arch/arm64/kvm/vgic/vgic-mmio-v3.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm64/kvm/vgic/vgic-mmio-v2.c +1 -1
@@ -91,7 +91,7 @@ static int vgic_mmio_uaccess_write_v2_mi* migration from old kernels to new kernels with legacy * userspace. */ - reg =FIELD_GET (GICD_IIDR_REVISION_MASK , reg); + reg =FIELD_GET (GICD_IIDR_REVISION_MASK , val);switch (reg) {case KVM_VGIC_IMP_REV_2 :case KVM_VGIC_IMP_REV_3 :
arch/arm64/kvm/vgic/vgic-mmio-v3.c +1 -1
@@ -167,7 +167,7 @@ static int vgic_mmio_uaccess_write_v3_miif ((reg ^ val) & ~GICD_IIDR_REVISION_MASK )return -EINVAL ; - reg =FIELD_GET (GICD_IIDR_REVISION_MASK , reg); + reg =FIELD_GET (GICD_IIDR_REVISION_MASK , val);switch (reg) {case KVM_VGIC_IMP_REV_2 :case KVM_VGIC_IMP_REV_3 :
Greg Kroah-Hartman
maintainerPATCH 379/969 LoongArch: Fix potential ADE in loongson_gpu_fixup_dma_hang()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Guan <[email protected]>
commit 8dfa2f8780e486d05b9a0ffce70b8f5fbd62053e upstream.
The switch case in loongson_gpu_fixup_dma_hang() may not DC2 or DC3, and readl(crtc_reg) will access with random address, because the "device" is from "base+PCI_DEVICE_ID", "base" is from "pdev->devfn+1". This is wrong when my platform inserts a discrete GPU:
lspci -tv
-[0000:00]-+-00.0 Loongson Technology LLC Hyper Transport Bridge Controller
...
+-06.0 Loongson Technology LLC LG100 GPU
+-06.2 Loongson Technology LLC Device 7a37...
Add a default switch case to fix the panic as below:
Kernel ade access[#1]:
CPU: 0 PID: 1 Comm: swapper/0 Not tainted 6.6.136-loong64-desktop-hwe+ #4
pc 90000000017e5534 ra 90000000017e54c0 tp 90000001002f8000 sp 90000001002fb6c0
a0 80000efe00003100 a1 0000000000003100 a2 0000000000000000 a3 0000000000000002
a4 90000001002fb6b4 a5 900000087cdb58fd a6 90000000027af000 a7 0000000000000001
t0 00000000000085b9 t1 000000000000ffff t2 0000000000000000 t3 0000000000000000
t4 fffffffffffffffd t5 00000000fffb6d9c t6 0000000000083b00 t7 00000000000070c0
t8 900000087cdb4d94 u0 900000087cdb58fd s9 90000001002fb826 s0 90000000031c12c8
s1 7fffffffffffff00 s2 90000000031c12d0 s3 0000000000002710 s4 0000000000000000
s5 0000000000000000 s6 9000000100053000 s7 7fffffffffffff00 s8 90000000030d4000
ra: 90000000017e54c0 loongson_gpu_fixup_dma_hang+0x40/0x210
ERA: 90000000017e5534 loongson_gpu_fixup_dma_hang+0xb4/0x210
CRMD: 000000b0 (PLV0 -IE -DA +PG DACF=CC DACM=CC -WE)
PRMD: 00000004 (PPLV0 +PIE -PWE)
EUEN: 00000000 (-FPE -SXE -ASXE -BTE)
ECFG: 00071c1d (LIE=0,2-4,10-12 VS=7)
ESTAT: 00480000 [ADEM] (IS= ECode=8 EsubCode=1)
BADV: 7fffffffffffff00
PRID: 0014d000 (Loongson-64bit, Loongson-3A6000-HV)
Modules linked in:
Process swapper/0 (pid: 1, threadinfo=(____ptrval____), task=(____ptrval____))
Stack : 0000000000000006 90000001002fb778 90000001002fb704 0000000000000007
0000000016a65700 90000000017e5690 000000000000ffff ffffffffffffffff
900000000209f7c0 9000000100053000 900000000209f7a8 9000000000eebc08
0000000000000000 0000000000000000 0000000000000006 90000001002fb778
90000001000530b8 90000000027af000 0000000000000000 9000000100054000
9000000100053000 9000000000ebb70c 9000000100004c00 9000000004000001
90000001002fb7e4 bae765461f31cb12 0000000000000000 0000000000000000
0000000000000006 90000000027af000 0000000000000030 90000000027af000
900000087cd6f800 9000000100053000 0000000000000000 9000000000ebc560
7a2500147cdaf720 bae765461f31cb12 0000000000000001 0000000000000030
...
Call Trace:
[<90000000017e5534>] loongson_gpu_fixup_dma_hang+0xb4/0x210
[<9000000000eebc08>] pci_fixup_device+0x108/0x280
[<9000000000ebb70c>] pci_setup_device+0x24c/0x690
[<9000000000ebc560>] pci_scan_single_device+0xe0/0x140
[<9000000000ebc684>] pci_scan_slot+0xc4/0x280
[<9000000000ebdd00>] pci_scan_child_bus_extend+0x60/0x3f0
[<9000000000f5bc94>] acpi_pci_root_create+0x2b4/0x420
[<90000000017e5e74>] pci_acpi_scan_root+0x2d4/0x440
[<9000000000f5b02c>] acpi_pci_root_add+0x21c/0x3a0
[<9000000000f4ee54>] acpi_bus_attach+0x1a4/0x3c0
[<90000000010e200c>] device_for_each_child+0x6c/0xe0
[<9000000000f4bbf4>] acpi_dev_for_each_child+0x44/0x70
[<9000000000f4ef40>] acpi_bus_attach+0x290/0x3c0
[<90000000010e200c>] device_for_each_child+0x6c/0xe0
[<9000000000f4bbf4>] acpi_dev_for_each_child+0x44/0x70
[<9000000000f4ef40>] acpi_bus_attach+0x290/0x3c0
[<9000000000f5211c>] acpi_bus_scan+0x6c/0x280
[<900000000189c028>] acpi_scan_init+0x194/0x310
[<900000000189bc6c>] acpi_init+0xcc/0x140
[<9000000000220cdc>] do_one_initcall+0x4c/0x310
[<90000000018618fc>] kernel_init_freeable+0x258/0x2d4
[<900000000184326c>] kernel_init+0x28/0x13c
[<9000000000222008>] ret_from_kernel_thread+0xc/0xa4--- arch/loongarch/pci/pci.c | 3 +++ 1 file changed, 3 insertions(+)
arch/loongarch/pci/pci.c +3 -0
@@ -133,6 +133,9 @@ static void loongson_gpu_fixup_dma_hang( crtc_reg = regbase; crtc_offset =0x400 ;break ; +default : +iounmap (regbase); +return ; }for (i =0 ; i <CRTC_NUM_MAX ; i++, crtc_reg += crtc_offset) {
Greg Kroah-Hartman
maintainerPATCH 380/969 LoongArch: Use per-root-bridge PCIH flag to skip mem resource fixup
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Huacai Chen <[email protected]>
commit 49f33840dcc907d21313d369e34872880846b61c upstream.
When firmware enables 64-bit PCI host bridge support, some root bridges already provide valid 64-bit mem resource windows through ACPI.
In this case, the LoongArch-specific mem resource high-bits fixup in acpi_prepare_root_resources() should not be applied unconditionally. Otherwise, the kernel may override the native resource layout derived from firmware, and later BAR assignment can fail to place device BARs into the intended 64-bit address space correctly.
Add a per-root-bridge ACPI flag, PCIH, and evaluate it from the current root bridge device scope. When PCIH is set, skip the mem resource high- bits fixup path and let the kernel use the firmware-provided resource description directly. When PCIH is absent or cleared, keep the existing behavior and continue filling the high address bits from the host bridge address.
This makes the behavior per-root-bridge configurable and avoids breaking valid 64-bit BAR space allocation on bridges whose 64-bit windows have already been fully described by firmware.
--- arch/loongarch/pci/acpi.c | 5 +++++ 1 file changed, 5 insertions(+)
arch/loongarch/pci/acpi.c +5 -0
@@ -58,11 +58,16 @@ static void acpi_release_root_info(strucstatic int acpi_prepare_root_resources (struct acpi_pci_root_info *ci) {int status; +unsigned long long pci_h =0 ;struct resource_entry *entry, *tmp;struct acpi_device *device = ci->bridge; status =acpi_pci_probe_root_resources (ci);if (status >0 ) { +acpi_evaluate_integer (device->handle,"PCIH" ,NULL , &pci_h); +if (pci_h) +return status; +resource_list_for_each_entry_safe (entry, tmp, &ci->resources) {if (entry->res->flags &IORESOURCE_MEM ) { entry->offset = ci->root->mcfg_addr &GENMASK_ULL (63 ,40 );
Greg Kroah-Hartman
maintainerPATCH 381/969 f2fs: compress: change the first parameter of page_array_{alloc,free} to sbi
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhiguo Niu <[email protected]>
[ Upstream commit 8e2a9b656474d67c55010f2c003ea2cf889a19ff ]
No logic changes, just cleanup and prepare for fixing the UAF issue in f2fs_free_dic.
--- fs/f2fs/compress.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-)
fs/f2fs/compress.c +20 -20
@@ -23,20 +23,18 @@static struct kmem_cache *cic_entry_slab;static struct kmem_cache *dic_entry_slab; -static void *page_array_alloc (struct inode *inode,int nr) +static void *page_array_alloc (struct f2fs_sb_info *sbi,int nr) { -struct f2fs_sb_info *sbi =F2FS_I_SB (inode);unsigned int size =sizeof (struct page *) * nr;if (likely (size <= sbi->page_array_slab_size))return f2fs_kmem_cache_alloc (sbi->page_array_slab, -GFP_F2FS_ZERO , false,F2FS_I_SB (inode)); +GFP_F2FS_ZERO , false, sbi);return f2fs_kzalloc (sbi, size,GFP_NOFS ); } -static void page_array_free (struct inode *inode,void *pages,int nr) +static void page_array_free (struct f2fs_sb_info *sbi,void *pages,int nr) { -struct f2fs_sb_info *sbi =F2FS_I_SB (inode);unsigned int size =sizeof (struct page *) * nr;if (!pages)
@@ -145,13 +143,13 @@ int f2fs_init_compress_ctx(struct compress_ctx *cc)if (cc->rpages)return 0 ; - cc->rpages =page_array_alloc (cc->inode, cc->cluster_size); + cc->rpages =page_array_alloc (F2FS_I_SB (cc->inode), cc->cluster_size);return cc->rpages ?0 : -ENOMEM ; }void f2fs_destroy_compress_ctx (struct compress_ctx *cc,bool reuse) { -page_array_free (cc->inode, cc->rpages, cc->cluster_size); +page_array_free (F2FS_I_SB (cc->inode), cc->rpages, cc->cluster_size); cc->rpages =NULL ; cc->nr_rpages =0 ; cc->nr_cpages =0 ;
@@ -640,6 +638,7 @@ static void *f2fs_vmap(struct page **pages, unsigned int count)static int f2fs_compress_pages (struct compress_ctx *cc) { +struct f2fs_sb_info *sbi =F2FS_I_SB (cc->inode);struct f2fs_inode_info *fi =F2FS_I (cc->inode);const struct f2fs_compress_ops *cops = f2fs_cops[fi->i_compress_algorithm];
@@ -660,7 +659,7 @@ static int f2fs_compress_pages(struct compress_ctx *cc) cc->nr_cpages =DIV_ROUND_UP (max_len,PAGE_SIZE ); cc->valid_nr_cpages = cc->nr_cpages; - cc->cpages =page_array_alloc (cc->inode, cc->nr_cpages); + cc->cpages =page_array_alloc (sbi, cc->nr_cpages);if (!cc->cpages) { ret = -ENOMEM ; goto destroy_compress_ctx;
@@ -742,7 +741,7 @@ static int f2fs_compress_pages(struct compress_ctx *cc)if (cc->cpages[i])f2fs_compress_free_page (cc->cpages[i]); } -page_array_free (cc->inode, cc->cpages, cc->nr_cpages); +page_array_free (sbi, cc->cpages, cc->nr_cpages); cc->cpages =NULL ; destroy_compress_ctx:if (cops->destroy_compress_ctx)
@@ -1308,7 +1307,7 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc, cic->magic =F2FS_COMPRESSED_PAGE_MAGIC ; cic->inode = inode;atomic_set (&cic->pending_pages, cc->valid_nr_cpages); - cic->rpages =page_array_alloc (cc->inode, cc->cluster_size); + cic->rpages =page_array_alloc (sbi, cc->cluster_size);if (!cic->rpages) goto out_put_cic;
@@ -1401,13 +1400,13 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc,spin_unlock (&fi->i_size_lock);f2fs_put_rpages (cc); -page_array_free (cc->inode, cc->cpages, cc->nr_cpages); +page_array_free (sbi, cc->cpages, cc->nr_cpages); cc->cpages =NULL ;f2fs_destroy_compress_ctx (cc, false);return 0 ; out_destroy_crypt: -page_array_free (cc->inode, cic->rpages, cc->cluster_size); +page_array_free (sbi, cic->rpages, cc->cluster_size);for (--i; i >=0 ; i--)fscrypt_finalize_bounce_page (&cc->cpages[i]);
@@ -1425,7 +1424,7 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc,f2fs_compress_free_page (cc->cpages[i]); cc->cpages[i] =NULL ; } -page_array_free (cc->inode, cc->cpages, cc->nr_cpages); +page_array_free (sbi, cc->cpages, cc->nr_cpages); cc->cpages =NULL ;return -EAGAIN ; }
@@ -1455,7 +1454,7 @@ void f2fs_compress_write_end_io(struct bio *bio, struct page *page)end_page_writeback (cic->rpages[i]); } -page_array_free (cic->inode, cic->rpages, cic->nr_rpages); +page_array_free (sbi, cic->rpages, cic->nr_rpages);kmem_cache_free (cic_entry_slab, cic);/*
@@ -1601,7 +1600,7 @@ static int f2fs_prepare_decomp_mem(struct decompress_io_ctx *dic,if (!allow_memalloc_for_decomp (F2FS_I_SB (dic->inode), pre_alloc))return 0 ; - dic->tpages =page_array_alloc (dic->inode, dic->cluster_size); + dic->tpages =page_array_alloc (F2FS_I_SB (dic->inode), dic->cluster_size);if (!dic->tpages)return -ENOMEM ;
@@ -1663,7 +1662,7 @@ struct decompress_io_ctx *f2fs_alloc_dic(struct compress_ctx *cc)if (!dic)return ERR_PTR (-ENOMEM ); - dic->rpages =page_array_alloc (cc->inode, cc->cluster_size); + dic->rpages =page_array_alloc (sbi, cc->cluster_size);if (!dic->rpages) {kmem_cache_free (dic_entry_slab, dic);return ERR_PTR (-ENOMEM );
@@ -1684,7 +1683,7 @@ struct decompress_io_ctx *f2fs_alloc_dic(struct compress_ctx *cc) dic->rpages[i] = cc->rpages[i]; dic->nr_rpages = cc->cluster_size; - dic->cpages =page_array_alloc (dic->inode, dic->nr_cpages); + dic->cpages =page_array_alloc (sbi, dic->nr_cpages);if (!dic->cpages) { ret = -ENOMEM ; goto out_free;
@@ -1719,6 +1718,7 @@ static void f2fs_free_dic(struct decompress_io_ctx *dic, bool bypass_destroy_callback) {int i; +struct f2fs_sb_info *sbi =F2FS_I_SB (dic->inode);f2fs_release_decomp_mem (dic, bypass_destroy_callback, true);
@@ -1730,7 +1730,7 @@ static void f2fs_free_dic(struct decompress_io_ctx *dic,continue ;f2fs_compress_free_page (dic->tpages[i]); } -page_array_free (dic->inode, dic->tpages, dic->cluster_size); +page_array_free (sbi, dic->tpages, dic->cluster_size); }if (dic->cpages) {
@@ -1739,10 +1739,10 @@ static void f2fs_free_dic(struct decompress_io_ctx *dic,continue ;f2fs_compress_free_page (dic->cpages[i]); } -page_array_free (dic->inode, dic->cpages, dic->nr_cpages); +page_array_free (sbi, dic->cpages, dic->nr_cpages); } -page_array_free (dic->inode, dic->rpages, dic->nr_rpages); +page_array_free (sbi, dic->rpages, dic->nr_rpages);kmem_cache_free (dic_entry_slab, dic); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 382/969 f2fs: compress: fix UAF of f2fs_inode_info in f2fs_free_dic
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhiguo Niu <[email protected]>
[ Upstream commit 39868685c2a94a70762bc6d77dc81d781d05bff5 ]
The decompress_io_ctx may be released asynchronously after I/O completion. If this file is deleted immediately after read, and the kworker of processing post_read_wq has not been executed yet due to high workloads, It is possible that the inode(f2fs_inode_info) is evicted and freed before it is used f2fs_free_dic.
The UAF case as below:
Thread A Thread B
- f2fs_decompress_end_io
- f2fs_put_dic
- queue_work
add free_dic work to post_read_wq
- do_unlink
- iput
- evict
- call_rcu
This file is deleted after read.
Thread C kworker to process post_read_wq
- rcu_do_batch
- f2fs_free_inode
- kmem_cache_free
inode is freed by rcu
- process_scheduled_works
- f2fs_late_free_dic
- f2fs_free_dic
- f2fs_release_decomp_mem
read (dic->inode)->i_compress_algorithm
This patch store compress_algorithm and sbi in dic to avoid inode UAF.
In addition, the previous solution is deprecated in [1] may cause system hang.
[1] https://lore.kernel.org/all/[email protected]
[ No changes are made to the code logic; F2FS_I_SB(dic->inode) is replaced with dic->sbi in v6.1. ]
--- fs/f2fs/compress.c | 40 ++++++++++++++++++++-------------------- fs/f2fs/f2fs.h | 2 ++ 2 files changed, 22 insertions(+), 20 deletions(-)
fs/f2fs/compress.c +20 -20
@@ -211,14 +211,14 @@ static int lzo_decompress_pages(struct decompress_io_ctx *dic) dic->rbuf, &dic->rlen);if (ret !=LZO_E_OK ) {printk_ratelimited ("%sF2FS-fs (%s): lzo decompress failed, ret:%d\n" , -KERN_ERR ,F2FS_I_SB (dic->inode)->sb->s_id, ret); +KERN_ERR , dic->sbi->sb->s_id, ret);return -EIO ; }if (dic->rlen !=PAGE_SIZE << dic->log_cluster_size) {printk_ratelimited ("%sF2FS-fs (%s): lzo invalid rlen:%zu, " "expected:%lu\n" ,KERN_ERR , -F2FS_I_SB (dic->inode)->sb->s_id, + dic->sbi->sb->s_id, dic->rlen,PAGE_SIZE << dic->log_cluster_size);return -EIO ;
@@ -307,14 +307,14 @@ static int lz4_decompress_pages(struct decompress_io_ctx *dic) dic->clen, dic->rlen);if (ret <0 ) {printk_ratelimited ("%sF2FS-fs (%s): lz4 decompress failed, ret:%d\n" , -KERN_ERR ,F2FS_I_SB (dic->inode)->sb->s_id, ret); +KERN_ERR , dic->sbi->sb->s_id, ret);return -EIO ; }if (ret !=PAGE_SIZE << dic->log_cluster_size) {printk_ratelimited ("%sF2FS-fs (%s): lz4 invalid ret:%d, " "expected:%lu\n" ,KERN_ERR , -F2FS_I_SB (dic->inode)->sb->s_id, ret, + dic->sbi->sb->s_id, ret,PAGE_SIZE << dic->log_cluster_size);return -EIO ; }
@@ -437,7 +437,7 @@ static int zstd_init_decompress_ctx(struct decompress_io_ctx *dic) workspace_size =zstd_dstream_workspace_bound (max_window_size); - workspace =f2fs_kvmalloc (F2FS_I_SB (dic->inode), + workspace =f2fs_kvmalloc (dic->sbi, workspace_size,GFP_NOFS );if (!workspace)return -ENOMEM ;
@@ -445,7 +445,7 @@ static int zstd_init_decompress_ctx(struct decompress_io_ctx *dic) stream =zstd_init_dstream (max_window_size, workspace, workspace_size);if (!stream) {printk_ratelimited ("%sF2FS-fs (%s): %s zstd_init_dstream failed\n" , -KERN_ERR ,F2FS_I_SB (dic->inode)->sb->s_id, +KERN_ERR , dic->sbi->sb->s_id, __func__);kvfree (workspace);return -EIO ;
@@ -482,7 +482,7 @@ static int zstd_decompress_pages(struct decompress_io_ctx *dic) ret =zstd_decompress_stream (stream, &outbuf, &inbuf);if (zstd_is_error (ret)) {printk_ratelimited ("%sF2FS-fs (%s): %s zstd_decompress_stream failed, ret: %d\n" , -KERN_ERR ,F2FS_I_SB (dic->inode)->sb->s_id, +KERN_ERR , dic->sbi->sb->s_id, __func__,zstd_get_error_code (ret));return -EIO ; }
@@ -490,7 +490,7 @@ static int zstd_decompress_pages(struct decompress_io_ctx *dic)if (dic->rlen != outbuf.pos) {printk_ratelimited ("%sF2FS-fs (%s): %s ZSTD invalid rlen:%zu, " "expected:%lu\n" ,KERN_ERR , -F2FS_I_SB (dic->inode)->sb->s_id, + dic->sbi->sb->s_id, __func__, dic->rlen,PAGE_SIZE << dic->log_cluster_size);return -EIO ;
@@ -759,7 +759,7 @@ static void f2fs_release_decomp_mem(struct decompress_io_ctx *dic,void f2fs_decompress_cluster (struct decompress_io_ctx *dic,bool in_task) { -struct f2fs_sb_info *sbi =F2FS_I_SB (dic->inode); +struct f2fs_sb_info *sbi = dic->sbi;struct f2fs_inode_info *fi =F2FS_I (dic->inode);const struct f2fs_compress_ops *cops = f2fs_cops[fi->i_compress_algorithm];
@@ -832,7 +832,7 @@ void f2fs_end_read_compressed_page(struct page *page, bool failed, {struct decompress_io_ctx *dic = (struct decompress_io_ctx *)page_private (page); -struct f2fs_sb_info *sbi =F2FS_I_SB (dic->inode); +struct f2fs_sb_info *sbi = dic->sbi;dec_page_count (sbi,F2FS_RD_DATA );
@@ -1593,14 +1593,13 @@ static inline bool allow_memalloc_for_decomp(struct f2fs_sb_info *sbi,static int f2fs_prepare_decomp_mem (struct decompress_io_ctx *dic,bool pre_alloc) { -const struct f2fs_compress_ops *cops = - f2fs_cops[F2FS_I (dic->inode)->i_compress_algorithm]; +const struct f2fs_compress_ops *cops = f2fs_cops[dic->compress_algorithm];int i; -if (!allow_memalloc_for_decomp (F2FS_I_SB (dic->inode), pre_alloc)) +if (!allow_memalloc_for_decomp (dic->sbi, pre_alloc))return 0 ; - dic->tpages =page_array_alloc (F2FS_I_SB (dic->inode), dic->cluster_size); + dic->tpages =page_array_alloc (dic->sbi, dic->cluster_size);if (!dic->tpages)return -ENOMEM ;
@@ -1632,10 +1631,9 @@ static int f2fs_prepare_decomp_mem(struct decompress_io_ctx *dic,static void f2fs_release_decomp_mem (struct decompress_io_ctx *dic,bool bypass_destroy_callback,bool pre_alloc) { -const struct f2fs_compress_ops *cops = - f2fs_cops[F2FS_I (dic->inode)->i_compress_algorithm]; +const struct f2fs_compress_ops *cops = f2fs_cops[dic->compress_algorithm]; -if (!allow_memalloc_for_decomp (F2FS_I_SB (dic->inode), pre_alloc)) +if (!allow_memalloc_for_decomp (dic->sbi, pre_alloc))return ;if (!bypass_destroy_callback && cops->destroy_decompress_ctx)
@@ -1670,6 +1668,8 @@ struct decompress_io_ctx *f2fs_alloc_dic(struct compress_ctx *cc) dic->magic =F2FS_COMPRESSED_PAGE_MAGIC ; dic->inode = cc->inode; + dic->sbi = sbi; + dic->compress_algorithm =F2FS_I (cc->inode)->i_compress_algorithm;atomic_set (&dic->remaining_pages, cc->nr_cpages); dic->cluster_idx = cc->cluster_idx; dic->cluster_size = cc->cluster_size;
@@ -1718,7 +1718,8 @@ static void f2fs_free_dic(struct decompress_io_ctx *dic, bool bypass_destroy_callback) {int i; -struct f2fs_sb_info *sbi =F2FS_I_SB (dic->inode); +/* use sbi in dic to avoid UFA of dic->inode*/ +struct f2fs_sb_info *sbi = dic->sbi;f2fs_release_decomp_mem (dic, bypass_destroy_callback, true);
@@ -1761,8 +1762,7 @@ static void f2fs_put_dic(struct decompress_io_ctx *dic, bool in_task)f2fs_free_dic (dic, false); }else {INIT_WORK (&dic->free_work, f2fs_late_free_dic); -queue_work (F2FS_I_SB (dic->inode)->post_read_wq, - &dic->free_work); +queue_work (dic->sbi->post_read_wq, &dic->free_work); } } }
fs/f2fs/f2fs.h +2 -0
@@ -1546,6 +1546,7 @@ struct compress_io_ctx {struct decompress_io_ctx {u32 magic;/* magic number to indicate page is compressed */ struct inode *inode;/* inode the context belong to */ +struct f2fs_sb_info *sbi;/* f2fs_sb_info pointer */ pgoff_t cluster_idx;/* cluster index number */ unsigned int cluster_size;/* page count in cluster */ unsigned int log_cluster_size;/* log of cluster size */
@@ -1586,6 +1587,7 @@ struct decompress_io_ctx {bool failed;/* IO error occurred before decompression? */ bool need_verity;/* need fs-verity verification after decompression? */ +unsigned char compress_algorithm;/* backup algorithm type */ void *private;/* payload buffer for specified decompression algorithm */ void *private2;/* extra payload buffer */ struct work_struct verity_work;/* work to verify the decompressed pages */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 383/969 exit: Sleep at TASK_IDLE when waiting for application core dump
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paul E. McKenney <[email protected]>
commit b8e753128ed074fcb48e9ceded940752f6b1c19f upstream.
Currently, the coredump_task_exit() function sets the task state to TASK_UNINTERRUPTIBLE|TASK_FREEZABLE, which usually works well. But a combination of large memory and slow (and/or highly contended) mass storage can cause application core dumps to take more than two minutes, which can cause check_hung_task(), which is invoked by check_hung_uninterruptible_tasks(), to produce task-blocked splats. There does not seem to be any reasonable benefit to getting these splats.
Furthermore, as Oleg Nesterov points out, TASK_UNINTERRUPTIBLE could be misleading because the task sleeping in coredump_task_exit() really is killable, albeit indirectly. See the check of signal->core_state in prepare_signal() and the check of fatal_signal_pending() in dump_interrupted(), which bypass the normal unkillability of TASK_UNINTERRUPTIBLE, resulting in coredump_finish() invoking wake_up_process() on any threads sleeping in coredump_task_exit().
Therefore, change that TASK_UNINTERRUPTIBLE to TASK_IDLE.
--- kernel/exit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/exit.c +1 -1
@@ -426,7 +426,7 @@ static void coredump_task_exit(struct tacomplete (&core_state->startup);for (;;) { -set_current_state (TASK_UNINTERRUPTIBLE |TASK_FREEZABLE ); +set_current_state (TASK_IDLE |TASK_FREEZABLE );if (!self.task)/* see coredump_finish() */ break ;schedule ();
Greg Kroah-Hartman
maintainerPATCH 384/969 media: uvcvideo: Enable VB2_DMABUF for metadata stream
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ricardo Ribalda <[email protected]>
commit fbac03467e53d8d72e5099c03df26d9adae11416 upstream.
The UVC driver has two video streams, one for the frames and another one for the metadata. Both streams share most of the codebase, but only the data stream declares support for DMABUF transfer mode.
I have tried the DMABUF transfer mode with CONFIG_DMABUF_HEAPS_SYSTEM and the frames looked correct.
This patch announces the support for DMABUF for the metadata stream. This is useful for apps/HALs that only want to support DMABUF.
--- drivers/media/usb/uvc/uvc_queue.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/media/usb/uvc/uvc_queue.c +1 -2
@@ -218,7 +218,7 @@ int uvc_queue_init(struct uvc_video_queuint ret; queue->queue.type = type; - queue->queue.io_modes =VB2_MMAP |VB2_USERPTR ; + queue->queue.io_modes =VB2_MMAP |VB2_USERPTR |VB2_DMABUF ; queue->queue.drv_priv = queue; queue->queue.buf_struct_size =sizeof (struct uvc_buffer ); queue->queue.mem_ops = &vb2_vmalloc_memops;
@@ -231,7 +231,6 @@ int uvc_queue_init(struct uvc_video_queu queue->queue.ops = &uvc_meta_queue_qops;break ;default : - queue->queue.io_modes |=VB2_DMABUF ; queue->queue.ops = &uvc_queue_qops;break ; }
Greg Kroah-Hartman
maintainerPATCH 385/969 media: i2c: ov8856: free control handler on error in ov8856_init_controls()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Koskovich <[email protected]>
commit f75e160745663ce9b13362ae6e90bd439c58df69 upstream.
The control handler wasn't freed if adding controls failed, add an error exit label and convert the existing error return to use it.
--- drivers/media/i2c/ov8856.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/media/i2c/ov8856.c +8 -2
@@ -1954,12 +1954,18 @@ static int ov8856_init_controls(struct o V4L2_CID_HFLIP, 0, 1, 1, 0);v4l2_ctrl_new_std (ctrl_hdlr, &ov8856_ctrl_ops,V4L2_CID_VFLIP ,0 ,1 ,1 ,0 ); -if (ctrl_hdlr->error) -return ctrl_hdlr->error; +if (ctrl_hdlr->error) { + ret = ctrl_hdlr->error; + goto err_ctrl_handler_free; + } ov8856->sd.ctrl_handler = ctrl_hdlr;return 0 ; + +err_ctrl_handler_free: +v4l2_ctrl_handler_free (ctrl_hdlr); +return ret; } static void ov8856_update_pad_format(struct ov8856 *ov8856,
Greg Kroah-Hartman
maintainerPATCH 386/969 staging: media: atomisp: Disallow all private IOCTLs
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sakari Ailus <[email protected]>
commit 2b7eb2c5dc72f0fc954ac4aa155f9e285e937f7c upstream.
Disallow all private IOCTLs. These aren't quite as safe as one could assume of IOCTL handlers; disable them for now. Instead of removing the code, return in the beginning of the function if cmd is non-zero in order to keep static checkers happy.
--- drivers/staging/media/atomisp/pci/atomisp_ioctl.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/staging/media/atomisp/pci/atomisp_ioctl.c +4 -0
@@ -2456,6 +2456,10 @@ static long atomisp_vidioc_default(strucstruct v4l2_subdev *motor;int err; +/* Disable all private IOCTLs for now! */ +if (cmd) +return -EINVAL ; +if (!IS_ISP2401 ) motor = isp->inputs[asd->input_curr].motor;else
Greg Kroah-Hartman
maintainerPATCH 387/969 regulator: max77650: fix OF node reference imbalance
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 2edaf5f7ada0ab5c9ec1f0836bd19779a8d85262 upstream.
The driver reuses the OF node of the parent multi-function device but fails to take another reference to balance the one dropped by the platform bus code when unbinding the MFD and deregistering the child devices.
Fix this by using the intended helper for reusing OF nodes.
--- drivers/regulator/max77650-regulator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/regulator/max77650-regulator.c +1 -1
@@ -339,7 +339,7 @@ static int max77650_regulator_probe(stru parent = dev->parent;if (!dev->of_node) - dev->of_node = parent->of_node; +device_set_of_node_from_dev (dev, parent); rdescs =devm_kcalloc (dev,MAX77650_REGULATOR_NUM_REGULATORS ,sizeof (*rdescs),GFP_KERNEL );
Greg Kroah-Hartman
maintainerPATCH 388/969 media: rc: xbox_remote: heed DMA restrictions
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Neukum <[email protected]>
commit e280d1e5e3f2595bbb43fe6e1bce00c59a43c0ff upstream.
The buffer for IO must not be part of the device structure because that violates the DMA coherency rules.
--- drivers/media/rc/xbox_remote.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/media/rc/xbox_remote.c +8 -1
@@ -55,7 +55,7 @@ struct xbox_remote {struct usb_interface *interface;struct urb *irq_urb; -unsigned char inbuf[DATA_BUFSIZE ]__aligned(sizeof(u16)) ; +u8 *inbuf;char rc_name[NAME_BUFSIZE ];char rc_phys[NAME_BUFSIZE ];
@@ -218,6 +218,10 @@ static int xbox_remote_probe(struct usb_if (!xbox_remote || !rc_dev) goto exit_free_dev_rdev; + xbox_remote->inbuf =kzalloc (DATA_BUFSIZE ,GFP_KERNEL ); +if (!xbox_remote->inbuf) + goto exit_free_inbuf; +/* Allocate URB buffer */ xbox_remote->irq_urb =usb_alloc_urb (0 ,GFP_KERNEL );if (!xbox_remote->irq_urb)
@@ -262,6 +266,8 @@ exit_kill_urbs:usb_kill_urb (xbox_remote->irq_urb); exit_free_buffers:usb_free_urb (xbox_remote->irq_urb); +exit_free_inbuf: +kfree (xbox_remote->inbuf); exit_free_dev_rdev:rc_free_device (rc_dev);kfree (xbox_remote);
@@ -286,6 +292,7 @@ static void xbox_remote_disconnect(strucusb_kill_urb (xbox_remote->irq_urb);rc_unregister_device (xbox_remote->rdev);usb_free_urb (xbox_remote->irq_urb); +kfree (xbox_remote->inbuf);kfree (xbox_remote); }
Greg Kroah-Hartman
maintainerPATCH 389/969 media: rc: streamzap: Error handling in probe
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Neukum <[email protected]>
commit 42844992664f03ef9f930e64f7370fa481e9c267 upstream.
If submitting the URB fails, the device will be unusable. Probe() must fail.
--- drivers/media/rc/streamzap.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/media/rc/streamzap.c +8 -4
@@ -219,9 +219,8 @@ static void streamzap_callback(struct urcase -ESHUTDOWN :/* * this urb is terminated, clean up. -* sz might already be invalid at this point */ -dev_err (sz->dev,"urb terminated, status: %d\n" , urb->status); +dev_dbg (sz->dev,"urb terminated, status: %d\n" , urb->status);return ;default :break ;
@@ -358,11 +357,16 @@ static int streamzap_probe(struct usb_inusb_set_intfdata (intf, sz); -if (usb_submit_urb (sz->urb_in,GFP_ATOMIC )) + retval =usb_submit_urb (sz->urb_in,GFP_ATOMIC ); +if (retval <0 ) {dev_err (sz->dev,"urb submit failed\n" ); + goto rc_submit_fail; + }return 0 ; - +rc_submit_fail: +rc_free_device (sz->rdev); +usb_set_intfdata (intf,NULL ); rc_dev_fail:usb_free_urb (sz->urb_in); free_buf_in:
Greg Kroah-Hartman
maintainerPATCH 390/969 regulator: act8945a: fix OF node reference imbalance
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 0d15ce31375ccef4162f960b34547a821b7619d2 upstream.
The driver reuses the OF node of the parent multi-function device but fails to take another reference to balance the one dropped by the platform bus code when unbinding the MFD and deregistering the child devices.
Fix this by using the intended helper for reusing OF nodes.
--- drivers/regulator/act8945a-regulator.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/regulator/act8945a-regulator.c +2 -1
@@ -302,8 +302,9 @@ static int act8945a_pmic_probe(struct pl num_regulators =ARRAY_SIZE (act8945a_regulators); } +device_set_of_node_from_dev (&pdev->dev, pdev->dev.parent); + config.dev = &pdev->dev; - config.dev->of_node = pdev->dev.parent->of_node; config.driver_data = act8945a;for (i =0 ; i < num_regulators; i++) { rdev = devm_regulator_register(&pdev->dev, ®ulators[i],
Greg Kroah-Hartman
maintainerPATCH 391/969 regulator: bd9571mwv: fix OF node reference imbalance
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 8498100ee1d00422b8c5b161b3e332278b92a59a upstream.
The driver reuses the OF node of the parent multi-function device but fails to take another reference to balance the one dropped by the platform bus code when unbinding the MFD and deregistering the child devices.
Fix this by using the intended helper for reusing OF nodes.
--- drivers/regulator/bd9571mwv-regulator.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/regulator/bd9571mwv-regulator.c +2 -1
@@ -288,8 +288,9 @@ static int bd9571mwv_regulator_probe(strplatform_set_drvdata (pdev, bdreg); +device_set_of_node_from_dev (&pdev->dev, pdev->dev.parent); + config.dev = &pdev->dev; - config.dev->of_node = pdev->dev.parent->of_node; config.driver_data = bdreg; config.regmap = bdreg->regmap;
Greg Kroah-Hartman
maintainerPATCH 392/969 media: saa7164: add ioremap return checks and cleanups
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wang Jun <[email protected]>
commit d51c60a498e83c9a79884c8e420f97e3885c9583 upstream.
Add checks for ioremap return values in saa7164_dev_setup(). If ioremap for BAR0 or BAR2 fails, release the already allocated PCI memory regions, remove the device from the global list, decrement the device count, and return -ENODEV.
This prevents potential null pointer dereferences and ensures proper cleanup on memory mapping failures.
--- drivers/media/pci/saa7164/saa7164-core.c | 47 +++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 12 deletions(-)
drivers/media/pci/saa7164/saa7164-core.c +35 -12
@@ -890,6 +890,15 @@ static int get_resources(struct saa7164_return -EBUSY ; } +static void release_resources (struct saa7164_dev *dev) +{ +release_mem_region (pci_resource_start (dev->pci,0 ), +pci_resource_len (dev->pci,0 )); + +release_mem_region (pci_resource_start (dev->pci,2 ), +pci_resource_len (dev->pci,2 )); +} +static int saa7164_port_init (struct saa7164_dev *dev,int portnr) {struct saa7164_port *port =NULL ;
@@ -949,9 +958,9 @@ static int saa7164_dev_setup(struct saa7snprintf (dev->name,sizeof (dev->name),"saa7164[%d]" , dev->nr); -mutex_lock (&devlist); -list_add_tail (&dev->devlist, &saa7164_devlist); -mutex_unlock (&devlist); + scoped_guard(mutex, &devlist) { +list_add_tail (&dev->devlist, &saa7164_devlist); + }/* board config */ dev->board =UNSET ;
@@ -998,11 +1007,17 @@ static int saa7164_dev_setup(struct saa7 }/* PCI/e allocations */ - dev->lmmio =ioremap (pci_resource_start (dev->pci,0 ), -pci_resource_len (dev->pci,0 )); + dev->lmmio =pci_ioremap_bar (dev->pci,0 ); +if (!dev->lmmio) { +dev_err (&dev->pci->dev,"Failed to remap MMIO BAR 0\n" ); + goto err_ioremap_bar0; + } - dev->lmmio2 =ioremap (pci_resource_start (dev->pci,2 ), -pci_resource_len (dev->pci,2 )); + dev->lmmio2 =pci_ioremap_bar (dev->pci,2 ); +if (!dev->lmmio2) { +dev_err (&dev->pci->dev,"Failed to remap MMIO BAR 2\n" ); + goto err_ioremap_bar2; + } dev->bmmio = (u8 __iomem *)dev->lmmio; dev->bmmio2 = (u8 __iomem *)dev->lmmio2;
@@ -1021,17 +1036,25 @@ static int saa7164_dev_setup(struct saa7saa7164_pci_quirks (dev);return 0 ; + +err_ioremap_bar2: +iounmap (dev->lmmio); +err_ioremap_bar0: +release_resources (dev); + + scoped_guard(mutex, &devlist) { +list_del (&dev->devlist); + } + saa7164_devcount--; + +return -ENODEV ; }static void saa7164_dev_unregister (struct saa7164_dev *dev) {dprintk (1 ,"%s()\n" , __func__); -release_mem_region (pci_resource_start (dev->pci,0 ), -pci_resource_len (dev->pci,0 )); - -release_mem_region (pci_resource_start (dev->pci,2 ), -pci_resource_len (dev->pci,2 )); +release_resources (dev);if (!atomic_dec_and_test (&dev->refcount))return ;
Greg Kroah-Hartman
maintainerPATCH 393/969 platform/x86: hp-wmi: Ignore backlight and FnLock events
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krishna Chomal <[email protected]>
commit e8c597368b8500a824c639bfb5ed0044068c6870 upstream.
On HP OmniBook 7 the keyboard backlight and FnLock keys are handled directly by the firmware. However, they still trigger WMI events which results in "Unknown key code" warnings in dmesg.
Add these key codes to the keymap with KE_IGNORE to silence the warnings since no software action is needed.
--- drivers/platform/x86/hp/hp-wmi.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/platform/x86/hp/hp-wmi.c +5 -0
@@ -223,6 +223,11 @@ static const struct key_entry hp_wmi_key { KE_KEY, 0x21a9, { KEY_TOUCHPAD_OFF } }, { KE_KEY, 0x121a9, { KEY_TOUCHPAD_ON } }, { KE_KEY, 0x231b, { KEY_HELP } }, + { KE_IGNORE, 0x21ab, }, /* FnLock on */ + { KE_IGNORE, 0x121ab, }, /* FnLock off */ + { KE_IGNORE, 0x30021aa, }, /* kbd backlight: level 2 -> off */ + { KE_IGNORE, 0x33221aa, }, /* kbd backlight: off -> level 1 */ + { KE_IGNORE, 0x36421aa, }, /* kbd backlight: level 1 -> level 2*/ { KE_END, 0 } };
Greg Kroah-Hartman
maintainerPATCH 394/969 media: pci: zoran: fix potential memory leak in zoran_probe()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abdun Nihaal <[email protected]>
commit 8ea21435fe36fb853706f4935d78bc11beb63fb4 upstream.
The memory allocated for codec in videocodec_attach() is not freed in one of the error paths, due to an incorrect goto label. Fix the label to free it on error.
--- drivers/media/pci/zoran/zoran_card.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/pci/zoran/zoran_card.c +1 -1
@@ -1377,7 +1377,7 @@ static int zoran_probe(struct pci_dev *p }if (zr->codec->type != zr->card.video_codec) {pci_err (pdev,"%s - wrong codec\n" , __func__); - goto zr_unreg_videocodec; + goto zr_detach_codec; } }if (zr->card.video_vfe !=0 ) {
Greg Kroah-Hartman
maintainerPATCH 395/969 media: dib8000: avoid division by 0 in dib8000_set_dds()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sergey Shtylyov <[email protected]>
commit dde3c37af95cd6fa301c4906f33d627bc9dd874c upstream.
In dib8000_set_dds(), 1 << 26 (67108864) divided by e.g. 1 apparently can't fit into 16-bit variable unit_khz_dds_val, being truncated to 0; this will cause division by 0 while calling dprintk() with debugging enabled (via the module parameter). Use s32 instead of s16 to declare the variable, getting rid of the cast to u16 in the *else* branch as well...
Found by Linux Verification Center (linuxtesting.org) with the Svace static analysis tool.
--- drivers/media/dvb-frontends/dib8000.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/dvb-frontends/dib8000.c +2 -2
@@ -2694,7 +2694,7 @@ static void dib8000_viterbi_state(structstatic void dib8000_set_dds (struct dib8000_state *state,s32 offset_khz) { -s16 unit_khz_dds_val; +s32 unit_khz_dds_val;u32 abs_offset_khz =abs (offset_khz);u32 dds = state->cfg.pll->ifreq &0x1ffffff ;u8 invert = !!(state->cfg.pll->ifreq & (1 <<25 ));
@@ -2715,7 +2715,7 @@ static void dib8000_set_dds(struct dib80 dds = (1 <<26 ) - dds; }else { ratio =2 ; - unit_khz_dds_val = (u16) (67108864 / state->cfg.pll->internal); + unit_khz_dds_val =67108864 / state->cfg.pll->internal;if (offset_khz <0 ) unit_khz_dds_val *=-1 ;
Greg Kroah-Hartman
maintainerPATCH 396/969 media: i2c: imx412: Assert reset GPIO during probe
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wenmeng Liu <[email protected]>
commit 8467c5ff5acae28513bc1e0af535e06b41b04344 upstream.
Assert the reset GPIO before first power up. This avoids a mismatch where the first power up (when the reset GPIO defaults deasserted) differs from subsequent cycles.
--- drivers/media/i2c/imx412.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/i2c/imx412.c +1 -1
@@ -934,7 +934,7 @@ static int imx412_parse_hw_config(struct/* Request optional reset pin */ imx412->reset_gpio =devm_gpiod_get_optional (imx412->dev,"reset" , -GPIOD_OUT_LOW ); +GPIOD_OUT_HIGH );if (IS_ERR (imx412->reset_gpio)) {dev_err (imx412->dev,"failed to get reset gpio %ld\n" ,PTR_ERR (imx412->reset_gpio));
Greg Kroah-Hartman
maintainerPATCH 397/969 media: i2c: ov08d10: fix image vertical start setting
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthias Fend <[email protected]>
commit 5d150fa0f16096d736bd24d13e04495da5116fab upstream.
The current settings for the "image vertical start" register appear to be incorrect. While this only results in an incorrect start line for native modes, this faulty setting causes actual problems in binning mode. At least on an i.MX8MP test system, only corrupted frames could be received. To correct this, the recommended settings from the reference register sets are used for all modes. Since this shifts the start by one line, the Bayer pattern also changes, which has also been corrected.
--- drivers/media/i2c/ov08d10.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/media/i2c/ov08d10.c +5 -5
@@ -217,7 +217,7 @@ static const struct ov08d10_reg lane_2_m {0x9a, 0x30}, {0xa8, 0x02}, {0xfd, 0x02}, - {0xa1, 0x01}, + {0xa1, 0x00}, {0xa2, 0x09}, {0xa3, 0x9c}, {0xa5, 0x00},
@@ -335,7 +335,7 @@ static const struct ov08d10_reg lane_2_m {0x9a, 0x30}, {0xa8, 0x02}, {0xfd, 0x02}, - {0xa1, 0x09}, + {0xa1, 0x08}, {0xa2, 0x09}, {0xa3, 0x90}, {0xa5, 0x08},
@@ -467,7 +467,7 @@ static const struct ov08d10_reg lane_2_m {0xaa, 0xd0}, {0xab, 0x06}, {0xac, 0x68}, - {0xa1, 0x09}, + {0xa1, 0x04}, {0xa2, 0x04}, {0xa3, 0xc8}, {0xa5, 0x04},
@@ -615,8 +615,8 @@ static const struct ov08d10_lane_cfg lanstatic u32 ov08d10_get_format_code (struct ov08d10 *ov08d10) {static const u32 codes[2 ][2 ] = { - {MEDIA_BUS_FMT_SGRBG10_1X10 ,MEDIA_BUS_FMT_SRGGB10_1X10 }, - {MEDIA_BUS_FMT_SBGGR10_1X10 ,MEDIA_BUS_FMT_SGBRG10_1X10 }, + {MEDIA_BUS_FMT_SBGGR10_1X10 ,MEDIA_BUS_FMT_SGBRG10_1X10 }, + {MEDIA_BUS_FMT_SGRBG10_1X10 ,MEDIA_BUS_FMT_SRGGB10_1X10 }, };return codes[ov08d10->vflip->val][ov08d10->hflip->val];
Greg Kroah-Hartman
maintainerPATCH 398/969 media: omap3isp: drop the use count of v4l2 pipeline
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haoxiang Li <[email protected]>
commit 9da49bd9d4224035cff39b40d7395310abb10201 upstream.
In isp_video_open(), drop the use count of v4l2
pipeline if vb2_queue_init() fails.
--- drivers/media/platform/ti/omap3isp/ispvideo.c | 1 + 1 file changed, 1 insertion(+)
drivers/media/platform/ti/omap3isp/ispvideo.c +1 -0
@@ -1328,6 +1328,7 @@ static int isp_video_open(struct file *f ret =vb2_queue_init (&handle->queue);if (ret <0 ) { +v4l2_pipeline_pm_put (&video->video.entity);omap3isp_put (video->isp); goto done; }
Greg Kroah-Hartman
maintainerPATCH 399/969 spi: mtk-nor: fix controller deregistration
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 76336f24934621db286cabb20b483773ee01dcaa upstream.
Make sure to deregister the controller before disabling underlying resources like clocks during driver unbind.
--- drivers/spi/spi-mtk-nor.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/spi/spi-mtk-nor.c +3 -1
@@ -900,7 +900,7 @@ static int mtk_nor_probe(struct platformpm_runtime_enable (&pdev->dev);pm_runtime_get_noresume (&pdev->dev); - ret =devm_spi_register_controller (&pdev->dev, ctlr); + ret =spi_register_controller (ctlr);if (ret <0 ) goto err_probe;
@@ -926,6 +926,8 @@ static int mtk_nor_remove(struct platforstruct spi_controller *ctlr =dev_get_drvdata (&pdev->dev);struct mtk_nor *sp =spi_controller_get_devdata (ctlr); +spi_unregister_controller (ctlr); +pm_runtime_disable (&pdev->dev);pm_runtime_set_suspended (&pdev->dev);pm_runtime_dont_use_autosuspend (&pdev->dev);
Greg Kroah-Hartman
maintainerPATCH 400/969 spi: imx: fix runtime pm leak on probe deferral
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit a1d50a37d3b1df84f536a982f692371039df4a48 upstream.
Make sure to balance the runtime PM usage count before returning on probe failure (e.g. probe deferral) so that the controller can be suspended when a driver is later bound.
--- drivers/spi/spi-imx.c | 1 + 1 file changed, 1 insertion(+)
drivers/spi/spi-imx.c +1 -0
@@ -1867,6 +1867,7 @@ out_register_controller: out_runtime_pm_put:pm_runtime_dont_use_autosuspend (spi_imx->dev);pm_runtime_disable (spi_imx->dev); +pm_runtime_put_noidle (spi_imx->dev);pm_runtime_set_suspended (&pdev->dev);clk_disable_unprepare (spi_imx->clk_ipg);
Greg Kroah-Hartman
maintainerPATCH 401/969 spi: orion: fix clock imbalance on registration failure
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 443cde0dc59c5d154156ac9f27a7dadef8ebc0c2 upstream.
Make sure that the controller is not runtime suspended before disabling clocks on probe failure.
Also restore the autosuspend setting.
--- drivers/spi/spi-orion.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/spi/spi-orion.c +6 -0
@@ -780,6 +780,7 @@ static int orion_spi_probe(struct platfopm_runtime_set_active (&pdev->dev);pm_runtime_use_autosuspend (&pdev->dev);pm_runtime_set_autosuspend_delay (&pdev->dev,SPI_AUTOSUSPEND_TIMEOUT ); +pm_runtime_get_noresume (&pdev->dev);pm_runtime_enable (&pdev->dev); status =orion_spi_reset (spi);
@@ -791,10 +792,15 @@ static int orion_spi_probe(struct platfoif (status <0 ) goto out_rel_pm; +pm_runtime_put_autosuspend (&pdev->dev); +return status; out_rel_pm:pm_runtime_disable (&pdev->dev); +pm_runtime_put_noidle (&pdev->dev); +pm_runtime_set_suspended (&pdev->dev); +pm_runtime_dont_use_autosuspend (&pdev->dev); out_rel_axi_clk:clk_disable_unprepare (spi->axi_clk); out_rel_clk:
Greg Kroah-Hartman
maintainerPATCH 402/969 spi: mpc52xx: fix use-after-free on unbind
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 706b3dc2ac7a998c55e14b3fd2e8f934c367e6e0 upstream.
The state machine work is scheduled by the interrupt handler and therefore needs to be cancelled after disabling interrupts to avoid a potential use-after-free.
--- drivers/spi/spi-mpc52xx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/spi/spi-mpc52xx.c +2 -1
@@ -519,10 +519,11 @@ static int mpc52xx_spi_remove(struct plastruct mpc52xx_spi *ms =spi_master_get_devdata (master);int i; -cancel_work_sync (&ms->work);free_irq (ms->irq0, ms);free_irq (ms->irq1, ms); +cancel_work_sync (&ms->work); +for (i =0 ; i < ms->gpio_cs_count; i++)gpiod_put (ms->gpio_cs[i]);
Greg Kroah-Hartman
maintainerPATCH 403/969 drm/amdgpu: Add bounds checking to ib_{get,set}_value
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Benjamin Cheng <[email protected]>
commit 66085e206431ef88ce36f53c1f53d570790ccc9e upstream.
The uvd/vce/vcn code accesses the IB at predefined offsets without checking that the IB is large enough. Check the bounds here. The caller is responsible for making sure it can handle arbitrary return values.
Also make the idx a uint32_t to prevent overflows causing the condition to fail.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +7 -4
@@ -392,15 +392,18 @@ void amdgpu_debugfs_ring_init(struct amdint amdgpu_ring_init_mqd (struct amdgpu_ring *ring); -static inline u32 amdgpu_ib_get_value (struct amdgpu_ib *ib,int idx) +static inline u32 amdgpu_ib_get_value (struct amdgpu_ib *ib,uint32_t idx) { -return ib->ptr[idx]; +if (idx < ib->length_dw) +return ib->ptr[idx]; +return 0 ; } -static inline void amdgpu_ib_set_value (struct amdgpu_ib *ib,int idx, +static inline void amdgpu_ib_set_value (struct amdgpu_ib *ib,uint32_t idx,uint32_t value) { - ib->ptr[idx] = value; +if (idx < ib->length_dw) + ib->ptr[idx] = value; } int amdgpu_ib_get(struct amdgpu_device *adev, struct amdgpu_vm *vm,
Greg Kroah-Hartman
maintainerPATCH 404/969 drm/amdgpu/vce: Prevent partial address patches
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Benjamin Cheng <[email protected]>
commit de2a02cc28d6d5d37db07d00a9a684c754a5fd74 upstream.
In the case that only one of lo/hi is valid, the patching could result in a bad address written to in FW.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c +3 -0
@@ -658,6 +658,9 @@ static int amdgpu_vce_cs_reloc(struct amuint64_t addr;int r; +if (lo >= ib->length_dw || hi >= ib->length_dw) +return -EINVAL ; +if (index ==0xffffffff ) index =0 ;
Greg Kroah-Hartman
maintainerPATCH 405/969 drm/amdgpu/vcn4: Prevent OOB reads when parsing dec msg
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Benjamin Cheng <[email protected]>
commit 0a78f2bac1424deb7c9d5e09c6b8e849d8e8b648 upstream.
Check bounds against the end of the BO whenever we access the msg.
--- drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c +18 -3
@@ -1612,7 +1612,7 @@ static int vcn_v4_0_dec_msg(struct amdgp {struct ttm_operation_ctx ctx = { false, false };struct amdgpu_bo_va_mapping *map; -uint32_t *msg, num_buffers; +uint32_t *msg, num_buffers, len_dw;struct amdgpu_bo *bo;uint64_t start, end;unsigned int i;
@@ -1633,6 +1633,11 @@ static int vcn_v4_0_dec_msg(struct amdgpreturn -EINVAL ; } +if (end - addr <16 ) { +DRM_ERROR ("VCN messages must be at least 4 DWORDs!\n" ); +return -EINVAL ; + } + bo->flags |=AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED ;amdgpu_bo_placement_from_domain (bo, bo->allowed_domains); r =ttm_bo_validate (&bo->tbo, &bo->placement, &ctx);
@@ -1649,8 +1654,8 @@ static int vcn_v4_0_dec_msg(struct amdgp msg = ptr + addr - start; -/* Check length */ if (msg[1 ] > end - addr) { +DRM_ERROR ("VCN message header does not fit in BO!\n" ); r = -EINVAL ; goto out; }
@@ -1658,7 +1663,16 @@ static int vcn_v4_0_dec_msg(struct amdgpif (msg[3 ] !=RDECODE_MSG_CREATE ) goto out; + len_dw = msg[1 ] /4 ; num_buffers = msg[2 ]; + +/* Verify that all indices fit within the claimed length. Each index is 4 DWORDs */ +if (num_buffers > len_dw ||6 + num_buffers *4 > len_dw) { +DRM_ERROR ("VCN message has too many buffers!\n" ); + r = -EINVAL ; + goto out; + } +for (i =0 , msg = &msg[6 ]; i < num_buffers; ++i, msg +=4 ) {uint32_t offset, size, *create;
@@ -1668,7 +1682,8 @@ static int vcn_v4_0_dec_msg(struct amdgp offset = msg[1 ]; size = msg[2 ]; -if (offset + size > end) { +if (size <4 || offset + size > end - addr) { +DRM_ERROR ("VCN message buffer exceeds BO bounds!\n" ); r = -EINVAL ; goto out; }
Greg Kroah-Hartman
maintainerPATCH 406/969 drm/amdgpu/vcn3: Prevent OOB reads when parsing dec msg
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Benjamin Cheng <[email protected]>
commit b193019860d61e92da395eae2011f2f6716b182f upstream.
Check bounds against the end of the BO whenever we access the msg.
--- drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c +19 -4
@@ -1781,7 +1781,7 @@ static int vcn_v3_0_dec_msg(struct amdgp {struct ttm_operation_ctx ctx = { false, false };struct amdgpu_bo_va_mapping *map; -uint32_t *msg, num_buffers; +uint32_t *msg, num_buffers, len_dw;struct amdgpu_bo *bo;uint64_t start, end;unsigned int i;
@@ -1802,6 +1802,11 @@ static int vcn_v3_0_dec_msg(struct amdgpreturn -EINVAL ; } +if (end - addr <16 ) { +DRM_ERROR ("VCN messages must be at least 4 DWORDs!\n" ); +return -EINVAL ; + } + bo->flags |=AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED ;amdgpu_bo_placement_from_domain (bo, bo->allowed_domains); r =ttm_bo_validate (&bo->tbo, &bo->placement, &ctx);
@@ -1818,8 +1823,8 @@ static int vcn_v3_0_dec_msg(struct amdgp msg = ptr + addr - start; -/* Check length */ if (msg[1 ] > end - addr) { +DRM_ERROR ("VCN message header does not fit in BO!\n" ); r = -EINVAL ; goto out; }
@@ -1827,7 +1832,16 @@ static int vcn_v3_0_dec_msg(struct amdgpif (msg[3 ] !=RDECODE_MSG_CREATE ) goto out; + len_dw = msg[1 ] /4 ; num_buffers = msg[2 ]; + +/* Verify that all indices fit within the claimed length. Each index is 4 DWORDs */ +if (num_buffers > len_dw ||6 + num_buffers *4 > len_dw) { +DRM_ERROR ("VCN message has too many buffers!\n" ); + r = -EINVAL ; + goto out; + } +for (i =0 , msg = &msg[6 ]; i < num_buffers; ++i, msg +=4 ) {uint32_t offset, size, *create;
@@ -1837,14 +1851,15 @@ static int vcn_v3_0_dec_msg(struct amdgp offset = msg[1 ]; size = msg[2 ]; -if (offset + size > end) { +if (size <4 || offset + size > end - addr) { +DRM_ERROR ("VCN message buffer exceeds BO bounds!\n" ); r = -EINVAL ; goto out; } create = ptr + addr + offset - start; -/* H246, HEVC and VP9 can run on any instance */ +/* H264, HEVC and VP9 can run on any instance */ if (create[0 ] ==0x7 || create[0 ] ==0x10 || create[0 ] ==0x11 )continue ;
Greg Kroah-Hartman
maintainerPATCH 407/969 drm/gem: Fix inconsistent plane dimension calculation in drm_gem_fb_init_with_funcs()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ashutosh Desai <[email protected]>
commit 3d4c2268bd7243c3780fe32bf24ff876da272acf upstream.
drm_gem_fb_init_with_funcs() computes sub-sampled plane dimensions using plain integer division:
unsigned int width = mode_cmd->width / (i ? info->hsub : 1); unsigned int height = mode_cmd->height / (i ? info->vsub : 1);
However, the ioctl-level framebuffer_check() in drm_framebuffer.c uses drm_format_info_plane_width/height() which round up dimensions via DIV_ROUND_UP(). This inconsistency corrupts the subsequent GEM object size check for certain pixel format and dimension combinations.
For example, with NV12 (vsub=2) and a 1-pixel-tall framebuffer the GEM size validation path sees height=0 instead of height=1. The expression (height - 1) then wraps to UINT_MAX as an unsigned int, causing min_size to overflow and wrap back to a small value. A tiny GEM object therefore passes the size guard, yet when the GPU accesses the chroma plane it will read or write memory beyond the object's bounds.
Fix by replacing the open-coded divisions with drm_format_info_plane_width() and drm_format_info_plane_height(), which use DIV_ROUND_UP() and match the calculation already used in framebuffer_check().
--- drivers/gpu/drm/drm_gem_framebuffer_helper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_gem_framebuffer_helper.c +2 -2
@@ -166,8 +166,8 @@ int drm_gem_fb_init_with_funcs(struct dr }for (i =0 ; i < info->num_planes; i++) { -unsigned int width = mode_cmd->width / (i ? info->hsub :1 ); -unsigned int height = mode_cmd->height / (i ? info->vsub :1 ); +unsigned int width =drm_format_info_plane_width (info, mode_cmd->width, i); +unsigned int height =drm_format_info_plane_height (info, mode_cmd->height, i);unsigned int min_size; objs[i] =drm_gem_object_lookup (file, mode_cmd->handles[i]);