6.6.163-rc1 review
Subsystems (6)
Greg Kroah-Hartman
maintainerPATCH 759/3318 smb: client: do not pass a NULL buf to is_oplock_break()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zikang Gao <[email protected]>
[ Upstream commit 2225ab306575e424b3dad2ee1be2521c89249d15 ]
receive_encrypted_read() sets *num_mids = 1 and never writes the caller's bufs[]. Offload returns -1 with *num_mids = 0, so the demultiplex thread skips the frame. The inline decrypt path returns 0 even when smb2_find_mid() fails.
cifs_demultiplex_thread() then treats mids[i] == NULL as an oplock break and calls is_oplock_break(bufs[i], server) with bufs[i] still NULL. smb2_is_valid_oplock_break() reads hdr.Command at offset 12 and oopses.
A large encrypted READ whose MessageId does not match is enough to panic cifsd.
Oops: general protection fault, probably for non-canonical address
0xdffffc0000000001: 0000 [#1] SMP KASAN PTI
KASAN: null-ptr-deref in range
[0x0000000000000008-0x000000000000000f]
CPU: 0 PID: 100 Comm: cifsd
RIP: smb2_is_valid_oplock_break+0xc8/0x2270 [cifs]
cifs_demultiplex_thread
Kernel panic - not syncing: Fatal exceptionReturn -1 when inline decrypt finds no mid, and skip is_oplock_break() plus the unknown-frame dump when bufs[i] is NULL. receive_encrypted_standard() already assigns bufs[*num_mids].
--- fs/smb/client/connect.c | 4 +++- fs/smb/client/smb2ops.c | 1 + 2 files changed, 4 insertions(+), 1 deletion(-)
fs/smb/client/connect.c +3 -1
@@ -1335,12 +1335,14 @@ cifs_demultiplex_thread(void *p) mids[i]->callback (mids[i]);release_mid (mids[i]); - }else if (server->ops->is_oplock_break && + }else if (bufs[i] && server->ops->is_oplock_break && server->ops->is_oplock_break (bufs[i], server)) {smb2_add_credits_from_hdr (bufs[i], server);cifs_dbg (FYI ,"Received oplock break\n" ); }else { +if (!bufs[i]) +continue ;cifs_server_dbg (VFS ,"No task to wake, unknown frame received! NumMids %d\n" ,atomic_read (&mid_count)); cifs_dump_mem("Received Data is: ", bufs[i],
fs/smb/client/smb2ops.c +1 -0
@@ -5051,6 +5051,7 @@ receive_encrypted_read(struct TCP_Server_Info *server, struct mid_q_entry **mid, *mid =smb2_find_mid (server, buf);if (*mid ==NULL ) {cifs_dbg (FYI ,"mid not found\n" ); + rc =-1 ; }else {cifs_dbg (FYI ,"mid found\n" ); (*mid)->decrypted = true;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 760/3318 ksmbd: prevent stale data from being written by SMB2 WRITE requests
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namjae Jeon <[email protected]>
[ Upstream commit bc0e0f5ac1d7b044d403f859406b4b66d4b1ce9b ]
Initialize the compatibility byte in request buffers without zeroing the entire allocation. Keep the one-byte compatibility exception for SMB2 messages so valid zero-length WRITE requests remain compatible, and validate the data range in the WRITE handlers against the current compound request before accessing it.
This prevents stale request-buffer data from being written to files or sent to IPC pipes.
--- fs/smb/server/connection.c | 1 + fs/smb/server/smb2pdu.c | 34 +++++++++++++++++++++++++--------- 2 files changed, 26 insertions(+), 9 deletions(-)
fs/smb/server/connection.c +1 -0
@@ -520,6 +520,7 @@ int ksmbd_conn_handler_loop(void *p)if (!conn->request_buf)break ; + conn->request_buf[pdu_size +4 ] =0 ;memcpy (conn->request_buf, hdr_buf,sizeof (hdr_buf));/*
fs/smb/server/smb2pdu.c +25 -9
@@ -7145,23 +7145,28 @@ static noinline int smb2_write_pipe(struct ksmbd_work *work)int err =0 , ret =0 ;char *data_buf;size_t length; +unsigned int data_offset, req_len;WORK_BUFFERS (work, req, rsp); length =le32_to_cpu (req->Length); id = req->VolatileFileId; + data_offset =le16_to_cpu (req->DataOffset); + req_len =le32_to_cpu (req->hdr.NextCommand); +if (!req_len) + req_len =get_rfc1002_len (work->request_buf) - + work->next_smb2_rcv_hdr_off; -if ((u64 )le16_to_cpu (req->DataOffset) + length > -get_rfc1002_len (work->request_buf)) { -pr_err ("invalid write data offset %u, smb_len %u\n" , -le16_to_cpu (req->DataOffset), -get_rfc1002_len (work->request_buf)); +if (data_offset < offsetof(struct smb2_write_req , Buffer) || + data_offset > req_len || length > req_len - data_offset) { +pr_err ("invalid write data offset %u, length %zu, req_len %u\n" , + data_offset, length, req_len); err = -EINVAL ; goto out; } data_buf = (char *)(((char *)&req->hdr.ProtocolId) + -le16_to_cpu (req->DataOffset)); + data_offset); rpc_resp =ksmbd_rpc_write (work->sess, id, data_buf, length);if (rpc_resp) {
@@ -7312,14 +7317,25 @@ int smb2_write(struct ksmbd_work *work) writethrough = true;if (is_rdma_channel == false) { -if (le16_to_cpu (req->DataOffset) < - offsetof(struct smb2_write_req , Buffer)) { +unsigned int data_offset =le16_to_cpu (req->DataOffset); +unsigned int req_len =le32_to_cpu (req->hdr.NextCommand); + +if (!req_len) + req_len =get_rfc1002_len (work->request_buf) - + work->next_smb2_rcv_hdr_off; + +if (data_offset < offsetof(struct smb2_write_req , Buffer) || + data_offset > req_len || + length > req_len - data_offset) { +ksmbd_debug (SMB , +"invalid write data offset %u, length %zu, req_len %u\n" , + data_offset, length, req_len); err = -EINVAL ; goto out; } data_buf = (char *)(((char *)&req->hdr.ProtocolId) + -le16_to_cpu (req->DataOffset)); + data_offset);ksmbd_debug (SMB ,"filename %pD, offset %lld, len %zu\n" , fp->filp, offset, length);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 761/3318 ksmbd: prevent share root removal through empty paths
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namjae Jeon <[email protected]>
[ Upstream commit 9fd1fcbbf84986a7bcf601a2b90540899069d263 ]
A FileLinkInformation request can supply "/" as the new link name. smb2_get_name() strips the trailing slash and passes an empty string to ksmbd_vfs_kern_path_start_removing().
ksmbd_vfs_path_lookup() resolves an empty pathname as the configured share path, without LOOKUP_BENEATH. With ReplaceIfExists set, smb2_create_link() can therefore remove the share root from its parent before link creation fails. An authenticated client with a writable share and DELETE access to a file can trigger this if the share root is empty and the mapped user has write and search permission on its parent directory.
Return -EINVAL for empty pathnames when for_remove is set, before resolving the share path or acquiring removal resources. Ordinary lookups continue to accept empty pathnames for opening the share root.
--- fs/smb/server/smb2pdu.c | 6 ++++++ 1 file changed, 6 insertions(+)
fs/smb/server/smb2pdu.c +6 -0
@@ -6303,6 +6303,12 @@ static int smb2_create_link(struct ksmbd_work *work, goto out; } +/* The share root must never be removed. */ +if (link_name[0 ] =='\0' ) { + rc = -EINVAL ; + goto out; + } +ksmbd_debug (SMB ,"link name is %s\n" , link_name); target_name =file_path (filp, pathname,PATH_MAX );if (IS_ERR (target_name)) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 762/3318 ksmbd: fix out-of-bounds read when padding the final compound response
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Bridges <[email protected]>
[ Upstream commit 714f27729121d59f103ca4dad7b0c2d1c125cd71 ]
Compound response handling pads the last response of a compound to an 8-byte boundary by growing the final iov and the RFC1002 length. smb2_allocate_rsp_buf() allocates exactly response_sz. A command can fill the response buffer to within 7 bytes of its end, for example a QUERY_INFO whose output is bounded only by the space left. The padding can then run past the allocation, and ksmbd_tcp_writev() reads those bytes when it sends the response.
BUG: KASAN: slab-out-of-bounds in _copy_from_iter+0x744/0x10e0 Call Trace: _copy_from_iter+0x744/0x10e0 tcp_sendmsg_locked+0x2290/0x3f80 ksmbd_tcp_writev+0x10c7/0x1ab0 [ksmbd]
Allocate room for the padding when the request is a compound, as smb2_read() and smb2_read_pipe() do for their payloads. response_sz is unchanged, so commands still fill only up to it, and kvzalloc() zeroes the padding.
--- fs/smb/server/smb2pdu.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
fs/smb/server/smb2pdu.c +10 -3
@@ -538,7 +538,7 @@ int smb2_allocate_rsp_buf(struct ksmbd_work *work)struct smb2_hdr *hdr =smb_get_msg (work->request_buf);size_t small_sz =MAX_CIFS_SMALL_BUFFER_SIZE ;size_t large_sz = small_sz + work->conn->vals->max_trans_size; -size_t sz = small_sz; +size_t sz = small_sz, pad_sz =0 ;int cmd =le16_to_cpu (hdr->Command);if (cmd ==SMB2_IOCTL_HE || cmd ==SMB2_QUERY_DIRECTORY_HE )
@@ -560,10 +560,17 @@ int smb2_allocate_rsp_buf(struct ksmbd_work *work) }/* allocate large response buf for chained commands */ -if (le32_to_cpu (hdr->NextCommand) >0 ) +if (le32_to_cpu (hdr->NextCommand) >0 ) { sz = large_sz; +/* +* is_chained_smb2_message() pads the last response of a +* compound to 8 bytes, which can take it past response_sz. +* Leave room for the padding. kvzalloc() zeroes it. +*/ + pad_sz =ALIGN (sz -sizeof (__be32),8 ) - (sz -sizeof (__be32)); + } - work->response_buf =kvzalloc (sz,GFP_KERNEL ); + work->response_buf =kvzalloc (sz + pad_sz,GFP_KERNEL );if (!work->response_buf)return -ENOMEM ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 763/3318 ksmbd: verify transform SessionId matches the decrypted header
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dairui Zhang <[email protected]>
[ Upstream commit 798214e6fafcdcc29f5ba2661a473232b5e70cfb ]
When an encrypted request comes in, the decryption key is picked by the SessionId in the transform header, but the request is then authorized under whatever session the decrypted inner header names. Nothing ever compares the two, so on a connection with more than one session a client can get a request decrypted with one session's key and run it as another session. Encrypted requests are exempt from signing too, so a valid AEAD tag is the only proof of session identity, and it is checked against the wrong session.
MS-SMB2 says the server must check that the transform SessionId matches the one in the decrypted SMB2 header and treat a mismatch as a protocol error. Add that check in __handle_ksmbd_work() after decryption, before dispatching: the message has to be at least one fixed SMB2 header, the first operation must not set SMB2_FLAGS_RELATED_OPERATIONS and its SessionId must match the transform SessionId, and every following non-related operation in a compound chain must carry the same SessionId. NextCommand offsets must be 8-byte aligned and stay inside the message; the bounds check is done by subtraction so it cannot wrap.
When the decrypted payload is a compression transform, the existing decompression step runs first and the decompressed SMB2 message is checked instead, since a compression transform header carries no SessionId.
--- fs/smb/server/server.c | 16 ++++++++++++ fs/smb/server/smb2pdu.c | 54 +++++++++++++++++++++++++++++++++++++++++ fs/smb/server/smb2pdu.h | 1 + 3 files changed, 71 insertions(+)
fs/smb/server/server.c +16 -0
@@ -169,12 +169,28 @@ static void __handle_ksmbd_work(struct ksmbd_work *work,if (conn->ops->is_transform_hdr && conn->ops->is_transform_hdr (work->request_buf)) { +u64 tr_sess_id; + +if (get_rfc1002_len (work->request_buf) < +sizeof (struct smb2_transform_hdr )) { +ksmbd_conn_abort (conn); +return ; + } + tr_sess_id =le64_to_cpu (((struct smb2_transform_hdr *) +smb_get_msg (work->request_buf))->SessionId); + rc = conn->ops->decrypt_req (work);if (rc <0 ) {ksmbd_conn_abort (conn);return ; } work->encrypted = true; + + rc =ksmbd_check_transform_session (work, tr_sess_id); +if (rc <0 ) { +ksmbd_conn_abort (conn); +return ; + } }if (conn->ops->allocate_rsp_buf (work))
fs/smb/server/smb2pdu.c +54 -0
60 lines not on this page · raw message
fs/smb/server/smb2pdu.h +1 -0
@@ -467,6 +467,7 @@ struct channel *lookup_chann_list(struct ksmbd_session *sess,void smb3_preauth_hash_rsp (struct ksmbd_work *work);bool smb3_is_transform_hdr (void *buf);int smb3_decrypt_req (struct ksmbd_work *work); +int ksmbd_check_transform_session (struct ksmbd_work *work,u64 tr_sess_id);int smb3_encrypt_resp (struct ksmbd_work *work);bool smb3_11_final_sess_setup_resp (struct ksmbd_work *work);int smb2_set_rsp_credits (struct ksmbd_work *work);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 764/3318 ksmbd: fix use-after-free after a failed durable reconnect
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Bridges <[email protected]>
[ Upstream commit 248b5819591c577727930e4e255a455235fab50a ]
ksmbd_reopen_durable_fd() republishes a detached durable handle in the reconnecting session's file table and takes no reference for that entry. If smb2_open() then fails, cleanup relies on the final ksmbd_fd_put() to remove the volatile id.
Two reconnects of the same handle can both take a lookup reference before either attaches it. If the one that reopens first then fails and drops its references first, the other request makes the final put through ksmbd_put_durable_fd(). That frees the handle without removing the first session's table entry, so tearing that session down writes to freed memory.
BUG: KASAN: slab-use-after-free in __close_file_table_ids+0x14d/0x740 [ksmbd] Call Trace: __close_file_table_ids+0x14d/0x740 [ksmbd] ksmbd_destroy_file_table+0x76/0x100 [ksmbd] ksmbd_session_destroy+0xf8/0x480 [ksmbd] ksmbd_dispose_sessions+0x13e/0x200 [ksmbd] ksmbd_conn_sessions_cleanup+0x4c3/0x6d0 [ksmbd] Freed by task 1030: __ksmbd_close_fd+0x97d/0x1000 [ksmbd] smb2_open+0x14eb/0xd9f0 [ksmbd]
Commit 3515503322f4 ("ksmbd: fix durable reconnect error path file lifetime") handles a final put made by the reconnecting request, but not one made by another holder.
Remove the volatile id under the file-table lock on this error path, before the references are dropped, as ksmbd_close_fd() does on the request_open path just above. Removal then no longer depends on which holder makes the final put. The stale comment in the reconnect cleanup is updated to match. A successful reconnect is unchanged.
--- fs/smb/server/smb2pdu.c | 12 +++++++----- fs/smb/server/vfs_cache.c | 28 ++++++++++++++++++++++++++++ fs/smb/server/vfs_cache.h | 2 ++ 3 files changed, 37 insertions(+), 5 deletions(-)
fs/smb/server/smb2pdu.c +7 -5
@@ -3872,8 +3872,11 @@ int smb2_open(struct ksmbd_work *work)if (!rsp->hdr.Status) rsp->hdr.Status =STATUS_UNEXPECTED_IO_ERROR ; -if (fp) +if (fp) { +if (dh_info.reconnected && fp == dh_info.fp) +ksmbd_unpublish_reopened_fd (work, fp);ksmbd_fd_put (work, fp); + }smb2_set_err_rsp (work);ksmbd_debug (SMB ,"Error response: %x\n" , rsp->hdr.Status); }
@@ -3881,10 +3884,9 @@ int smb2_open(struct ksmbd_work *work)if (dh_info.reconnected) {/* * If reconnect succeeded, fp was republished in the -* session file table. On a later error, ksmbd_fd_put() -* above drops the session reference; drop the durable -* lookup reference through the same session-aware path so -* final close removes the volatile id before freeing fp. +* session file table, and the error path above has +* already removed its volatile id. Drop the durable +* lookup reference through the same session-aware path. */ if (rc && fp == dh_info.fp)ksmbd_fd_put (work, dh_info.fp);
fs/smb/server/vfs_cache.c +28 -0
@@ -486,6 +486,34 @@ static void set_close_state_blocked_works(struct ksmbd_file *fp)spin_unlock (&fp->f_lock); } +/** +* ksmbd_unpublish_reopened_fd() - remove a reopened durable handle from the +* session file table after its CREATE failed +* @work: smb work of the failed CREATE +* @fp: durable handle republished by ksmbd_reopen_durable_fd() +* +* The reopen publishes @fp in this session's table without taking a reference +* for the entry, so the CREATE error path's puts need not be the last ones. +* Another holder of a global-table reference, such as a concurrent reconnect +* of the same handle, can drop the last one through ksmbd_put_durable_fd(), +* which frees @fp without touching this table. Remove the id here, while +* the caller still holds its references. +* +* Every path that removes the id before the final put also clears +* @fp->volatile_id under ft->lock, so a valid id is still @fp's entry. +*/ +void ksmbd_unpublish_reopened_fd (struct ksmbd_work *work,struct ksmbd_file *fp) +{ +struct ksmbd_file_table *ft = &work->sess->file_table; + +write_lock (&ft->lock); +if (has_file_id (fp->volatile_id)) { +idr_remove (ft->idr, fp->volatile_id); + fp->volatile_id =KSMBD_NO_FID ; + } +write_unlock (&ft->lock); +} +int ksmbd_close_fd (struct ksmbd_work *work,u64 id) {struct ksmbd_file *fp;
fs/smb/server/vfs_cache.h +2 -0
@@ -155,6 +155,8 @@ static inline bool ksmbd_stream_fd(struct ksmbd_file *fp)int ksmbd_init_file_table (struct ksmbd_file_table *ft);void ksmbd_destroy_file_table (struct ksmbd_session *sess);int ksmbd_close_fd (struct ksmbd_work *work,u64 id); +void ksmbd_unpublish_reopened_fd (struct ksmbd_work *work, +struct ksmbd_file *fp);struct ksmbd_file *ksmbd_lookup_fd_fast (struct ksmbd_work *work,u64 id);struct ksmbd_file *ksmbd_lookup_foreign_fd (struct ksmbd_work *work,u64 id); struct ksmbd_file *ksmbd_lookup_fd_slow(struct ksmbd_work *work, u64 id,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 765/3318 KVM: VMX: Preserve negative return value in vmx_handle_exit() with bus lock detected
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiaoyao Li <[email protected]>
[ Upstream commit cef48693da1e964e9f192bfc16cd0ed287c48337 ]
Preserve the negative return value from __vmx_handle_exit() when a bus lock is detected, instead of always overwriting it with 0.
The purpose of bus_lock_detected handling is to force a userspace exit to inform userspace that a bus lock happened. The negative return value can achieve this purpose, and changing the negative value to 0 fails to return an error to userspace. So, preserve the negative return value.
--- arch/x86/kvm/vmx/vmx.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/x86/kvm/vmx/vmx.c +3 -2
@@ -6622,11 +6622,12 @@ static int vmx_handle_exit(struct kvm_vcpu *vcpu, fastpath_t exit_fastpath)* a bus lock in guest. */ if (to_vmx (vcpu)->exit_reason.bus_lock_detected) { -if (ret >0 ) +if (ret >0 ) { vcpu->run->exit_reason =KVM_EXIT_X86_BUS_LOCK ; + ret =0 ; + } vcpu->run->flags |=KVM_RUN_X86_BUS_LOCK ; -return 0 ; }return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 766/3318 driver core: Check drivers_autoprobe for all added devices
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vincent Liu <[email protected]>
[ Upstream commit ea34511aaf755349999a1067b2984a541bee1492 ]
When a device is hot-plugged, the drivers_autoprobe sysfs attribute is not checked (at least for PCI devices). This means that drivers_autoprobe is not working as intended, e.g. hot-plugged PCI devices will still be autoprobed and bound to drivers even with drivers_autoprobe disabled.
The problem likely started when device_add() was removed from pci_bus_add_device() in commit 4f535093cf8f ("PCI: Put pci_dev in device tree as early as possible") which means that the check for drivers_autoprobe which used to happen in bus_probe_device() is no longer present (previously bus_add_device() calls bus_probe_device()). Conveniently, in commit 91703041697c ("PCI: Allow built-in drivers to use async initial probing") device_attach() was replaced with device_initial_probe() which faciliates this change to push the check for drivers_autoprobe into device_initial_probe().
Make sure all devices check drivers_autoprobe by pushing the drivers_autoprobe check into device_initial_probe(). This will only affect devices on the PCI bus for now as device_initial_probe() is only called by pci_bus_add_device() and bus_probe_device(), but bus_probe_device() already checks for autoprobe, so callers of bus_probe_device() should not observe changes on autoprobing. Note also that pushing this check into device_initial_probe() rather than device_attach() makes it only affect automatic probing of drivers (e.g. when a device is hot-plugged), userspace can still choose to manually bind a driver by writing to drivers_probe sysfs attribute, even with autoprobe disabled.
Any future callers of device_initial_probe() will respect the drivers_autoprobe sysfs attribute, which is the intended purpose of drivers_autoprobe.
Apply the bus-side change to the existing shared probe helper, preserving the deferred-probe parent locking. PCI still calls device_attach(), so its probe behaviour is unchanged. Retain this change to prepare device_initial_probe() for the async-attach retry handling.
Stable-dep-of: 187a62f99da2 ("driver core: take parent lock in async device attach")
--- drivers/base/bus.c | 3 +-- drivers/base/dd.c | 10 +++++++++- 2 files changed, 10 insertions(+), 3 deletions(-)
drivers/base/bus.c +1 -2
@@ -570,8 +570,7 @@ static void __bus_probe_device(struct device *dev)if (!sp)return ; -if (sp->drivers_autoprobe) -device_initial_probe (dev); +device_initial_probe (dev);mutex_lock (&sp->mutex);list_for_each_entry (sif, &sp->interfaces, node)
drivers/base/dd.c +9 -1
@@ -1156,7 +1156,15 @@ EXPORT_SYMBOL_GPL(device_attach);void device_initial_probe (struct device *dev) { -__device_attach (dev, true); +struct subsys_private *sp =bus_to_subsys (dev->bus); + +if (!sp) +return ; + +if (sp->drivers_autoprobe) +__device_attach (dev, true); + +subsys_put (sp); }/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 767/3318 driver core: take parent lock in async device attach
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mario Peter <[email protected]>
[ Upstream commit 187a62f99da29b1a55602b0d401a783d8dc86161 ]
For device types with need_parent_lock set (only USB interfaces), probe() must run with the parent device locked. A synchronous attach after device_add() gets this from the caller, e.g. usb_set_configuration() holds the udev lock while adding interfaces. __device_attach_async_helper() runs the probe from an async worker instead, where that lock isn't held, and only takes device_lock(dev).
With async probing enabled for the hub driver (e.g. driver_async_probe=* or driver_async_probe=hub), this races when a multi-TT hub is configured. For multi-TT hubs, hub_probe() calls usb_set_interface(hdev, 0, 1) to select the TT-per-port altsetting, and usb_set_interface() creates the endpoint devices of the interface a second time:
usb_set_configuration() async worker
[udev locked]
device_add(intf)
queues the probe ----------> __device_attach_async_helper()
[intf locked, udev not locked]
hub_probe()
usb_set_interface(hdev, 0, 1)
create_intf_ep_devs(intf) create_intf_ep_devs(intf)create_intf_ep_devs() checks and sets intf->ep_devs_created without a lock of its own. If usb_set_configuration() has created ep_81 but not yet set the flag, usb_set_interface() skips removing the endpoint devices of the old altsetting and creates ep_81 again. With a synchronous probe, hub_probe() runs inside device_add() with the udev lock held, and usb_set_configuration() then finds ep_devs_created already set.
Single-TT hubs don't call usb_set_interface() from hub_probe() and don't show this warning, but their probe runs without the udev lock as well.
On an i.MX8MM board with an onboard USB2514 hub this hit 11 of 100 boots:
sysfs: cannot create duplicate filename '.../1-1/1-1:1.0/ep_81'
Call trace: sysfs_warn_dup usb_create_ep_devs create_intf_ep_devs usb_set_interface hub_probe usb_probe_interface really_probe __device_attach_async_helper async_run_entry_fn
It also shows on v7.3-rc6 in QEMU, with dummy_hcd and a raw-gadget program emulating a multi-TT hub: re-authorizing the hub in a loop, while a SCHED_FIFO task preempts the writing task at random points for 3 ms, hit the warning in 29 of 6000 iterations.
Take the parent lock in __device_attach_async_helper() as well, like __driver_attach_async_helper() does, and move __device_driver_lock/unlock() up for that. With this the warning was gone in 300 boots on the board and in 6000 iterations in QEMU.
[ johan: switch to async_schedule_dev_nocall() to avoid deadlock if
async_schedule_dev() runs synchronously when parent lock is held ]
[ Fold the nested conditions into a single if statement; correct commit
message to mention "device types" rather than "buses" for "need_parent_lock". - Danilo ]
--- drivers/base/dd.c | 83 +++++++++++++++++++++++++---------------------- 1 file changed, 45 insertions(+), 38 deletions(-)
drivers/base/dd.c +45 -38
@@ -1041,6 +1041,38 @@ static int __device_attach_driver(struct device_driver *drv, void *_data)return ret ==0 ; } +/* +* __device_driver_lock - acquire locks needed to manipulate dev->drv +* @dev: Device we will update driver info for +* @parent: Parent device. Needed if the device type requires parent lock +* +* This function will take the required locks for manipulating dev->drv. +* Normally this will just be the @dev lock, but when called for a USB +* interface, @parent lock will be held as well. +*/ +static void __device_driver_lock (struct device *dev,struct device *parent) +{ +if (dev->type && dev->type->need_parent_lock && parent) +device_lock (parent); +device_lock (dev); +} + +/* +* __device_driver_unlock - release locks needed to manipulate dev->drv +* @dev: Device we will update driver info for +* @parent: Parent device. Needed if the device type requires parent lock +* +* This function will release the required locks for manipulating dev->drv. +* Normally this will just be the @dev lock, but when called for a +* USB interface, @parent lock will be released as well. +*/ +static void __device_driver_unlock (struct device *dev,struct device *parent) +{ +device_unlock (dev); +if (dev->type && dev->type->need_parent_lock && parent) +device_unlock (parent); +} +static void __device_attach_async_helper (void *_dev,async_cookie_t cookie) {struct device *dev = _dev;
@@ -1050,7 +1082,7 @@ static void __device_attach_async_helper(void *_dev, async_cookie_t cookie) .want_async = true, }; -device_lock (dev); +__device_driver_lock (dev, dev->parent);/* * Check if device has already been removed or claimed. This may
@@ -1072,7 +1104,7 @@ static void __device_attach_async_helper(void *_dev, async_cookie_t cookie)if (dev->parent)pm_runtime_put (dev->parent); out_unlock: -device_unlock (dev); +__device_driver_unlock (dev, dev->parent);put_device (dev); }
@@ -1129,8 +1161,11 @@ static int __device_attach(struct device *dev, bool allow_async) } out_unlock:device_unlock (dev); -if (async) -async_schedule_dev (__device_attach_async_helper, dev); +if (async && !async_schedule_dev_nocall (__device_attach_async_helper, dev)) { +put_device (dev); + ret =2 ;/* retry synchronously */ + } +return ret; }
@@ -1157,48 +1192,20 @@ EXPORT_SYMBOL_GPL(device_attach);void device_initial_probe (struct device *dev) {struct subsys_private *sp =bus_to_subsys (dev->bus); +int ret;if (!sp)return ; -if (sp->drivers_autoprobe) -__device_attach (dev, true); +if (sp->drivers_autoprobe) { + ret =__device_attach (dev, true); +if (ret ==2 ) +__device_attach (dev, false); + }subsys_put (sp); } -/* -* __device_driver_lock - acquire locks needed to manipulate dev->drv -* @dev: Device we will update driver info for -* @parent: Parent device. Needed if the device type requires parent lock -* -* This function will take the required locks for manipulating dev->drv. -* Normally this will just be the @dev lock, but when called for a USB -* interface, @parent lock will be held as well. -*/ -static void __device_driver_lock (struct device *dev,struct device *parent) -{ -if (dev->type && dev->type->need_parent_lock && parent) -device_lock (parent); -device_lock (dev); -} - -/* -* __device_driver_unlock - release locks needed to manipulate dev->drv -* @dev: Device we will update driver info for -* @parent: Parent device. Needed if the device type requires parent lock -* -* This function will release the required locks for manipulating dev->drv. -* Normally this will just be the @dev lock, but when called for a -* USB interface, @parent lock will be released as well. -*/ -static void __device_driver_unlock (struct device *dev,struct device *parent) -{ -device_unlock (dev); -if (dev->type && dev->type->need_parent_lock && parent) -device_unlock (parent); -} -/** * device_driver_attach - attach a specific driver to a specific device * @drv: Driver to attach
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 768/3318 ksmbd: fix session reference leak on compounded SESSION_SETUP
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Bridges <[email protected]>
[ Upstream commit 03bd8f5279e490e15e0c0f0fa388ffbd2fbacd65 ]
A compound request can place SESSION_SETUP after another command. That earlier command leaves a reference to its session in work->sess. smb2_sess_setup() then overwrites work->sess with the session it looks up or creates, and the dispatcher later puts work->sess only once. The inherited reference is never dropped. That leaks the session, together with its setup connection and socket, and every repeat of the compound leaks another.
unreferenced object (size 512):
__kmalloc_cache_noprof+0x32c/0x3a0
ksmbd_smb2_session_create+0xf6/0x9c0 [ksmbd]
smb2_sess_setup+0xda4/0x6280 [ksmbd]
handle_ksmbd_work+0x88c/0x1cb0 [ksmbd]Save the inherited session on entry. After the request has been processed, release it once, but only when smb2_sess_setup() has replaced work->sess with its own session or cleared it. Do this after ksmbd_conn_unlock() so the put does not run under srv_mutex. An error path may instead leave the inherited session in work->sess. Keep it there, so the dispatcher still puts it and the error response is still signed or encrypted with it as before.
--- fs/smb/server/smb2pdu.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
fs/smb/server/smb2pdu.c +11 -0
@@ -1704,6 +1704,8 @@ int smb2_sess_setup(struct ksmbd_work *work)struct smb2_sess_setup_req *req;struct smb2_sess_setup_rsp *rsp;struct ksmbd_session *sess; +struct ksmbd_session *prev_sess = work->sess; +bool installed = false;struct negotiate_message *negblob;unsigned int negblob_len, negblob_off;int rc =0 ;
@@ -1826,6 +1828,7 @@ int smb2_sess_setup(struct ksmbd_work *work) conn->binding = false; } work->sess = sess; + installed = true; negblob_off =le16_to_cpu (req->SecurityBufferOffset); negblob_len =le16_to_cpu (req->SecurityBufferLength);
@@ -1979,6 +1982,14 @@ int smb2_sess_setup(struct ksmbd_work *work) }ksmbd_conn_unlock (conn); + +/* +* Later in a compound, work->sess holds the reference that an +* earlier command took. Drop it once this request has installed +* its own session there or cleared it. +*/ +if (prev_sess && (installed || !work->sess)) +ksmbd_user_session_put (prev_sess);return rc; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 769/3318 ksmbd: fix invalid pointer dereference when get_inode_acl() fails
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Henry Hu <[email protected]>
[ Upstream commit 19d180c7baab7126af5848ed87d5f7b5add0cef2 ]
When get_inode_acl() fails, it returns an ERR_PTR(), but ksmbd_acls_fattr() stored that pointer in smb_fattr without checking for errors. Later callers then passed the error pointer to security descriptor helpers or posix_acl_release(), resulting in an invalid pointer dereference.
This was reproduced on an XFS-backed share when xfs_get_acl() returned ERR_PTR(-ENOMEM). Querying the SMB ACL from a CIFS client triggered the crash:
BUG: unable to handle page fault for address: fffffffffffffff8 RIP: smb_acl_sec_desc_scratch_len+0x58/0x90 [ksmbd] Call Trace: smb2_query_info+0x40d/0x17c0 [ksmbd] handle_ksmbd_work+0x1ca/0x770 [ksmbd]
Fix this by checking the return values from get_inode_acl() in ksmbd_acls_fattr(). Treat -EOPNOTSUPP as indicating that no ACL is available, and propagate all other errors to the callers. Update smb2_open() and smb2_get_info_sec() to handle these errors.
--- fs/smb/server/smb2pdu.c | 42 +++++++++++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 8 deletions(-)
fs/smb/server/smb2pdu.c +34 -8
@@ -2714,10 +2714,11 @@ static int smb2_create_sd_buffer(struct ksmbd_work *work, le32_to_cpu(sd_buf->ccontext.DataLength), true, false); } -static void ksmbd_acls_fattr (struct smb_fattr *fattr, -struct mnt_idmap *idmap, -struct inode *inode) +static int ksmbd_acls_fattr (struct smb_fattr *fattr, +struct mnt_idmap *idmap, +struct inode *inode) { +struct posix_acl *acl;vfsuid_t vfsuid =i_uid_into_vfsuid (idmap, inode);vfsgid_t vfsgid =i_gid_into_vfsgid (idmap, inode);
@@ -2728,10 +2729,28 @@ static void ksmbd_acls_fattr(struct smb_fattr *fattr, fattr->cf_dacls =NULL ;if (IS_ENABLED (CONFIG_FS_POSIX_ACL )) { - fattr->cf_acls =get_inode_acl (inode,ACL_TYPE_ACCESS ); -if (S_ISDIR (inode->i_mode)) - fattr->cf_dacls =get_inode_acl (inode,ACL_TYPE_DEFAULT ); + acl =get_inode_acl (inode,ACL_TYPE_ACCESS ); +if (IS_ERR (acl)) { +if (acl !=ERR_PTR (-EOPNOTSUPP )) +return PTR_ERR (acl); + acl =NULL ; + } + fattr->cf_acls = acl; + +if (S_ISDIR (inode->i_mode)) { + acl =get_inode_acl (inode,ACL_TYPE_DEFAULT ); +if (IS_ERR (acl)) { +if (acl !=ERR_PTR (-EOPNOTSUPP )) { +posix_acl_release (fattr->cf_acls); +return PTR_ERR (acl); + } + acl =NULL ; + } + fattr->cf_dacls = acl; + } } + +return 0 ; }enum {
@@ -3464,7 +3483,10 @@ int smb2_open(struct ksmbd_work *work)int pntsd_size;size_t scratch_len; -ksmbd_acls_fattr (&fattr, idmap, inode); + rc =ksmbd_acls_fattr (&fattr, idmap, inode); +if (rc) + goto err_out; + scratch_len = smb_acl_sec_desc_scratch_len(&fattr, NULL, 0, OWNER_SECINFO | GROUP_SECINFO |
@@ -5920,7 +5942,11 @@ static int smb2_get_info_sec(struct ksmbd_work *work, idmap =file_mnt_idmap (fp->filp); inode =file_inode (fp->filp); -ksmbd_acls_fattr (&fattr, idmap, inode); + rc =ksmbd_acls_fattr (&fattr, idmap, inode); +if (rc) { +ksmbd_fd_put (work, fp); +return rc; + }if (test_share_config_flag (work->tcon->share_conf,KSMBD_SHARE_FLAG_ACL_XATTR ))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 770/3318 ksmbd: use the existing xattr name for a named stream
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: DaeMyung Kang <[email protected]>
[ Upstream commit a7d1d52748e0fe4d06fdb871fc9899904fbba93f ]
SMB stream names are case-insensitive, but ksmbd stores each named stream in an xattr whose name is case-sensitive. Opening an existing stream finds its xattr with a case-insensitive match, yet the handle keeps the name as the client spelled it, and every later operation that needs an exact name uses that spelling:
- a WRITE or an end-of-file change creates a second xattr, so a stream created as "Foo" and written through "foo" ends up stored twice, and which value a later lookup returns depends on xattr list order;
- delete-on-close and delete-pending removal can fail with -ENODATA, or remove only a case-variant copy and leave the original;
- the share mode check compares stream names with strcmp(), so two opens of the same stream that differ only in case do not conflict.
Have ksmbd_vfs_casexattr_len() copy the matching xattr's name into the handle when the stream is opened, so later operations use the name already on disk. The match must have the same length as the name it replaces; the stream lookup passes a length that includes the terminating NUL, which already guarantees that, and the check makes the copy safe for any caller. A stream that does not exist yet keeps the client's spelling, as before.
smb2_rename() compares and looks up fp->stream.name case-insensitively, so it behaves the same with either spelling.
--- fs/smb/server/smb2pdu.c | 8 ++++---- fs/smb/server/vfs.c | 7 ++++++- fs/smb/server/vfs.h | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-)
fs/smb/server/smb2pdu.c +4 -4
@@ -2459,7 +2459,7 @@ static int smb2_set_ea(struct smb2_ea_info *eabuf, unsigned int buf_len, path->dentry, attr_name,XATTR_USER_PREFIX_LEN + - eabuf->EaNameLength); + eabuf->EaNameLength, NULL);/* delete the EA only when it exits */ if (rc >0 ) {
@@ -2531,11 +2531,11 @@ static noinline int smb2_set_stream_name_xattr(const struct path *path, fp->stream.name = xattr_stream_name; fp->stream.size = xattr_stream_size; -/* Check if there is stream prefix in xattr space */ +/* Keep the existing xattr's case for subsequent writes and removal. */ rc =ksmbd_vfs_casexattr_len (idmap, path->dentry, xattr_stream_name, - xattr_stream_size); + xattr_stream_size, xattr_stream_name);if (rc >=0 )return 0 ;if (rc != -ENOENT && rc != -ENODATA )
@@ -5257,7 +5257,7 @@ static int get_file_stream_info(struct ksmbd_work *work,*/ slen =ksmbd_vfs_casexattr_len (file_mnt_idmap (fp->filp), path->dentry, stream_name, -strlen (stream_name) +1 ); +strlen (stream_name) +1 ,NULL ); ssize = slen <0 ?0 : (loff_t )slen; file_info->StreamSize =cpu_to_le64 (ssize); file_info->StreamAllocationSize =cpu_to_le64 (ssize);
fs/smb/server/vfs.c +6 -1
@@ -1806,7 +1806,7 @@ int ksmbd_vfs_fill_dentry_attrs(struct ksmbd_work *work,ssize_t ksmbd_vfs_casexattr_len (struct mnt_idmap *idmap,struct dentry *dentry,char *attr_name, -int attr_name_len) +int attr_name_len,char *actual_name) {char *name, *xattr_list =NULL ;ssize_t value_len = -ENOENT , xattr_list_len;
@@ -1824,8 +1824,13 @@ ssize_t ksmbd_vfs_casexattr_len(struct mnt_idmap *idmap,ksmbd_debug (VFS ,"%s, len %zd\n" , name,strlen (name));if (strncasecmp (attr_name, name, attr_name_len))continue ; +if (actual_name &&strlen (name) +1 != attr_name_len) +continue ; value_len =ksmbd_vfs_xattr_len (idmap, dentry, name); +/* The caller provides attr_name_len bytes for the actual name. */ +if (value_len >=0 && actual_name) +memcpy (actual_name, name, attr_name_len);break ; }
fs/smb/server/vfs.h +1 -1
@@ -107,7 +107,7 @@ ssize_t ksmbd_vfs_getxattr(struct mnt_idmap *idmap, char **xattr_buf);ssize_t ksmbd_vfs_casexattr_len (struct mnt_idmap *idmap,struct dentry *dentry,char *attr_name, -int attr_name_len); +int attr_name_len,char *actual_name); int ksmbd_vfs_setxattr(struct mnt_idmap *idmap, const struct path *path, const char *attr_name, void *attr_value, size_t attr_size, int flags,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 771/3318 ksmbd: fix named stream write and EOF handling
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: DaeMyung Kang <[email protected]>
[ Upstream commit 02165c8d402392278a5cd2cf97645ed73a7ad4a1 ]
An SMB WRITE to an existing named stream can silently discard data after its written range. ksmbd stores streams as xattr values, but the write path passes offset + count as the length of the replacement xattr even when the old stream is longer. Writing 26 bytes at offset 0 to a 60-byte stream reports 26 bytes written while discarding the remaining 34 bytes.
Keep the existing xattr length when an in-place write ends before EOF. Reject writes that cross XATTR_SIZE_MAX rather than storing only the portion that fits while reporting the full requested count.
Commit 4ea0bb8aaedf ("ksmbd: handle set/get info file for streamed file") intentionally skipped ordinary inode truncation for stream handles: an EOF SetInfo on an ADS had truncated the base file. That fixed the base file corruption but left stream EOF changes reporting success without resizing the stream. Handle these requests by resizing only the stream xattr; the base file size remains untouched. Zero-fill stream extensions. This is needed alongside the write fix: a short write's accidental truncation previously masked an ignored explicit EOF change. The stream resize helper returns xattr errors directly rather than using the base-file truncate path's EBADF conversion.
--- fs/smb/server/smb2pdu.c | 2 ++ fs/smb/server/vfs.c | 72 ++++++++++++++++++++++++++++++++++++----- fs/smb/server/vfs.h | 1 + 3 files changed, 67 insertions(+), 8 deletions(-)
fs/smb/server/smb2pdu.c +2 -0
@@ -6549,6 +6549,8 @@ static int set_end_of_file_info(struct ksmbd_work *work, struct ksmbd_file *fp, newsize =le64_to_cpu (file_eof_info->EndOfFile); inode =file_inode (fp->filp); +if (ksmbd_stream_fd (fp)) +return ksmbd_vfs_stream_truncate (fp, newsize);/* * If FILE_END_OF_FILE_INFORMATION of set_info_file is called
fs/smb/server/vfs.c +64 -8
106 lines not on this page · raw message
fs/smb/server/vfs.h +1 -0
@@ -82,6 +82,7 @@ int ksmbd_vfs_read(struct ksmbd_work *work, struct ksmbd_file *fp, size_t count,int ksmbd_vfs_write (struct ksmbd_work *work,struct ksmbd_file *fp,char *buf,size_t count,loff_t *pos,bool sync,ssize_t *written); +int ksmbd_vfs_stream_truncate (struct ksmbd_file *fp,loff_t newsize);int ksmbd_vfs_fsync (struct ksmbd_work *work,u64 fid,u64 p_id);int ksmbd_vfs_remove_file (struct ksmbd_work *work,const struct path *path); int ksmbd_vfs_link(struct ksmbd_work *work,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 772/3318 inet: reject unhashed sockets during established lookups
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hyunwoo Kim <[email protected]>
[ Upstream commit 4e2b3ef19e0e04adca38442f07dd6bc93c712bf1 ]
TCP established ehash lookups are lockless. The socket caches involved use SLAB_TYPESAFE_BY_RCU, so memory can be reused before an RCU reader that retained its old address has finished.
After a tuple match, __inet_lookup_established() and __inet6_lookup_established() acquire a reference and repeat the tuple check. They do not check whether the new object is hashed. If the address is reused for a socket with the same tuple, the lookup can acquire a reference to the new object and return it while its nulls node is unhashed.
A PoC that drives reuse with a SYN cookie request socket reproduced the crash. The new request socket is unhashed and has a NULL rsk_listener. A lookup that had loaded the address of the old request socket acquired the reference published by tcp_get_cookie_sock() and returned the new object. tcp_v4_rcv() then read sk_state through the NULL listener.
The resulting crash was:
BUG: kernel NULL pointer dereference, address: 0000000000000012 #PF: supervisor read access in kernel mode #PF: error_code(0x0000) - not-present page ... Oops: Oops: 0000 [#1] SMP NOPTI CPU: 4 UID: 0 PID: 0 Comm: swapper/4 Not tainted 7.3.0-00591-g0e135910deec #1 PREEMPT(lazy) ... RIP: 0010:tcp_v4_rcv+0x44e/0x1280 ... R10: 0000000000000001 R11: 00000000024ca8c0 R12: 0000000000000000 ... CR2: 0000000000000012 CR3: 0000000103d50004 CR4: 0000000000770ef0 ... Call Trace: <IRQ> ? raw_local_deliver+0xae/0x240 ip_protocol_deliver_rcu+0x2d/0x180 ip_local_deliver_finish+0x84/0x100 ip_sublist_rcv_finish+0x5f/0x70 ip_sublist_rcv+0x12a/0x1d0 ip_list_rcv+0xfd/0x130 __netif_receive_skb_list_core+0x223/0x250 netif_receive_skb_list_internal+0x1d2/0x2c0 ? try_fill_recv+0x39/0x7b0 napi_complete_done+0x74/0x170 virtnet_poll+0x445/0x600 __napi_poll+0x27/0x1e0 net_rx_action+0x2fe/0x3b0 handle_softirqs+0xc2/0x2c0 __irq_exit_rcu+0x74/0xd0 common_interrupt+0x7f/0x90 </IRQ> ... Kernel panic - not syncing: Fatal exception in interrupt
After taking a reference, check whether the nulls node is unhashed in both IPv4 and IPv6 established lookups. If it is unhashed or the tuple no longer matches, drop the reference and restart the lookup.
Lookups racing with the TIME_WAIT hashdance, or with a request being replaced by its child, now restart and find the new socket instead of returning the old one.
Request sockets that were never inserted into ehash can have a nonzero refcount, and a stale lookup can hold a transient reference. Therefore, when SYN cookie, Fast Open, and request migration paths fail after setting a nonzero refcount, release the references held by those paths with reqsk_put() instead of freeing the request directly.
--- net/ipv4/inet_connection_sock.c | 10 +++++++--- net/ipv4/inet_hashtables.c | 5 +++-- net/ipv4/syncookies.c | 2 ++ net/ipv4/tcp_input.c | 4 +++- net/ipv6/inet6_hashtables.c | 4 +++- 5 files changed, 18 insertions(+), 7 deletions(-)
net/ipv4/inet_connection_sock.c +7 -3
@@ -1120,10 +1120,14 @@ static void reqsk_timer_handler(struct timer_list *t)*/ if (nreq) {__NET_INC_STATS (net,LINUX_MIB_TCPMIGRATEREQFAILURE ); +/* The timer was not armed, drop its reference here. */ +reqsk_put (nreq); no_ownership:reqsk_migrate_reset (nreq);reqsk_queue_removed (queue, nreq); -__reqsk_free (nreq); +/* Drop the temporary reference and the one reserved for ehash. */ +reqsk_put (nreq); +reqsk_put (nreq); } drop:
@@ -1404,7 +1408,7 @@ struct sock *inet_csk_complete_hashdance(struct sock *sk, struct sock *child,__NET_INC_STATS (sock_net (sk),LINUX_MIB_TCPMIGRATEREQFAILURE );reqsk_migrate_reset (nreq); -__reqsk_free (nreq); +reqsk_put (nreq); }else if (inet_csk_reqsk_queue_add (sk, req, child)) {return child; }
@@ -1460,7 +1464,7 @@ void inet_csk_listen_stop(struct sock *sk)__NET_INC_STATS (sock_net (nsk),LINUX_MIB_TCPMIGRATEREQFAILURE );reqsk_migrate_reset (nreq); -__reqsk_free (nreq); +reqsk_put (nreq); }rcu_read_unlock ();
net/ipv4/inet_hashtables.c +3 -2
@@ -518,8 +518,9 @@ struct sock *__inet_lookup_established(struct net *net,if (likely (inet_match (net, sk, acookie, ports, dif, sdif))) {if (unlikely (!refcount_inc_not_zero (&sk->sk_refcnt))) goto out; -if (unlikely (!inet_match (net, sk, acookie, - ports, dif, sdif))) { +if (unlikely (hlist_nulls_unhashed_lockless (&sk->sk_nulls_node) || + !inet_match (net, sk, acookie, ports, dif, + sdif))) {sock_gen_put (sk); goto begin; }
net/ipv4/syncookies.c +2 -0
@@ -215,6 +215,8 @@ struct sock *tcp_get_cookie_sock(struct sock *sk, struct sk_buff *skb,bh_unlock_sock (child);sock_put (child); +reqsk_put (req); +return NULL ; }__reqsk_free (req);
net/ipv4/tcp_input.c +3 -1
@@ -7257,7 +7257,9 @@ int tcp_conn_request(struct request_sock_ops *rsk_ops,if (!inet_csk_reqsk_queue_add (sk, req, fastopen_sk)) {bh_unlock_sock (fastopen_sk);sock_put (fastopen_sk); - goto drop_and_free; +/* tcp_disconnect() already dropped one reqsk ref. */ +reqsk_put (req); + goto drop; }READ_ONCE (sk->sk_data_ready)(sk);bh_unlock_sock (fastopen_sk);
net/ipv6/inet6_hashtables.c +3 -1
@@ -75,7 +75,9 @@ struct sock *__inet6_lookup_established(struct net *net,if (unlikely (!refcount_inc_not_zero (&sk->sk_refcnt))) goto out; -if (unlikely (!inet6_match (net, sk, saddr, daddr, ports, dif, sdif))) { +if (unlikely (hlist_nulls_unhashed_lockless (&sk->sk_nulls_node) || + !inet6_match (net, sk, saddr, daddr, ports, dif, + sdif))) {sock_gen_put (sk); goto begin; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 773/3318 ovl: check that the parents of volatile/dirty are dirs
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Mason <[email protected]>
commit e34d2ef818e4c7676d8d8e1bf43e6a1ed39efb2a upstream.
An unprivileged user crashes the kernel by mounting overlayfs with the volatile option.
A dentry that serves as the parent of a lookup must be a directory. ovl_create_volatile_dirty() walks work/incompat/volatile/dirty by name, and ovl_lookup_or_create() returns an existing entry whatever its type. A file or a symlink that another task creates during the mount becomes the parent of the next lookup, which calls a NULL ->lookup.
An unprivileged user mounted overlayfs with "volatile" in a user namespace while a second process created a symlink named work/incompat, and the mount task oopsed on a NULL ->lookup call.
Fix this by returning -ENOTDIR from ovl_lookup_or_create() when the caller asked for a directory and the existing entry is a non-dir.
[backport: no ovl_start_creating_upper(), check the child of
ovl_lookup_upper() in ovl_lookup_or_create() instead]
--- fs/overlayfs/super.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
fs/overlayfs/super.c +12 -5
@@ -660,16 +660,23 @@ static int ovl_check_rename_whiteout(struct ovl_fs *ofs)static struct dentry *ovl_lookup_or_create (struct ovl_fs *ofs,struct dentry *parent, -const char *name,umode_t mode) +const char *name,bool is_dir) {size_t len =strlen (name);struct dentry *child;inode_lock_nested (parent->d_inode,I_MUTEX_PARENT ); child =ovl_lookup_upper (ofs, name, parent, len); -if (!IS_ERR (child) && !child->d_inode) - child =ovl_create_real (ofs, parent->d_inode, child, -OVL_CATTR (mode)); +if (!IS_ERR (child)) { +if (!child->d_inode) { + child =ovl_create_real (ofs, parent->d_inode, child, +OVL_CATTR (is_dir ?S_IFDIR : +S_IFREG )); + }else if (is_dir && !d_can_lookup (child)) { +dput (child); + child =ERR_PTR (-ENOTDIR ); + } + }inode_unlock (parent->d_inode);dput (parent);
@@ -690,7 +697,7 @@ static int ovl_create_volatile_dirty(struct ovl_fs *ofs)const char *const *name = volatile_path;for (ctr =ARRAY_SIZE (volatile_path); ctr; ctr--, name++) { - d =ovl_lookup_or_create (ofs, d, *name, ctr >1 ?S_IFDIR :S_IFREG ); + d =ovl_lookup_or_create (ofs, d, *name, ctr >1 );if (IS_ERR (d))return PTR_ERR (d); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 774/3318 ovl: hold a reference on the parent in readdir
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Mason <[email protected]>
commit 16d319e12328acafeafd3eecdf09c46d7fb43452 upstream.
Listing a directory on an overlay uses a freed dentry and crashes the kernel when a lookup moves the directory at the same time.
Code that can sleep may only use d_parent without a reference while something stops a move of the dentry. ovl_iterate_real(), ovl_need_adjust_d_ino() and ovl_cache_update() use the d_parent of the listed directory and hold only the lock of that directory. When a lookup finds the directory under another parent after a change to a layer, d_splice_alias() moves it without that lock and drops its reference on the old parent.
With a delay in ovl_iterate_real(), getdents64 on an overlay directory raced a rename in the lower layer and a lookup that moved its dentry, and after an rmdir of the old parent KASAN reported a use-after-free in security_inode_getattr().
Fix this by using dget_parent() in the three functions.
[backport: no ovl_need_adjust_d_ino(), take the parent with dget_parent()
in ovl_iterate() and test a local flag]
--- fs/overlayfs/readdir.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-)
fs/overlayfs/readdir.c +19 -7
@@ -476,8 +476,8 @@ static int ovl_cache_update_ino(const struct path *path, struct ovl_cache_entry goto get; }if (p->len ==2 && p->name[1 ] =='.' ) { -/* we shall not be moved */ - this =dget (dir->d_parent); +/* d_splice_alias() can move even a locked dir */ + this =dget_parent (dir); goto get; } }
@@ -697,6 +697,7 @@ static int ovl_iterate_real(struct file *file, struct dir_context *ctx)struct dentry *dir = file->f_path.dentry;struct ovl_fs *ofs =OVL_FS (dir->d_sb);const struct ovl_layer *lower_layer =ovl_layer_lower (dir); +struct dentry *parent;struct ovl_readdir_translate rdt = { .ctx.actor = ovl_fill_real, .orig_ctx = ctx,
@@ -707,18 +708,26 @@ static int ovl_iterate_real(struct file *file, struct dir_context *ctx)if (rdt.xinobits && lower_layer) rdt.fsid = lower_layer->fsid; -if (OVL_TYPE_MERGE (ovl_path_type (dir->d_parent))) { +/* +* The lock on dir does not stop d_splice_alias() from moving it to +* another parent, which drops the reference dir holds on this one. +*/ + parent =dget_parent (dir); +if (OVL_TYPE_MERGE (ovl_path_type (parent))) {struct kstat stat;struct path statpath = file->f_path; - statpath.dentry = dir->d_parent; + statpath.dentry = parent; err =vfs_getattr (&statpath, &stat,STATX_INO ,0 ); -if (err) +if (err) { +dput (parent);return err; + }WARN_ON_ONCE (dir->d_sb->s_dev != stat.dev); rdt.parent_ino = stat.ino; } +dput (parent);if (ovl_is_impure_dir (file)) { rdt.cache =ovl_cache_get_impure (&file->f_path);
@@ -747,6 +756,10 @@ static int ovl_iterate(struct file *file, struct dir_context *ctx)ovl_dir_reset (file);if (od->is_real) { +struct dentry *parent =dget_parent (dentry); +bool parent_merge =OVL_TYPE_MERGE (ovl_path_type (parent)); + +dput (parent);/* * If parent is merge, then need to adjust d_ino for '..', if * dir is impure then need to adjust d_ino for copied up
@@ -754,8 +767,7 @@ static int ovl_iterate(struct file *file, struct dir_context *ctx)*/ if (ovl_xino_bits (ofs) || (ovl_same_fs (ofs) && - (ovl_is_impure_dir (file) || -OVL_TYPE_MERGE (ovl_path_type (dentry->d_parent))))) { + (ovl_is_impure_dir (file) || parent_merge))) { err =ovl_iterate_real (file, ctx); }else { err =iterate_dir (od->realfile, ctx);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 775/3318 ovl: do not copy up a dentry that was removed
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Mason <[email protected]>
commit f635192ad223d2009ee640b63adf5ce3198aa338 upstream.
A change to a removed file through an open descriptor replaces whatever has its old name in the upper layer.
Copy up must only create a name in the upper directory, never replace one. After an unlink, an rmdir or a rename over a lower dentry, a dentry that an open file keeps alive still has its old parent and name, but in the upper directory that name is now a whiteout or a new object. ovl_copy_up_workdir() renames the copy over it, which brings back the removed object and destroys whatever took its name.
An unprivileged user opened a lower FIFO and unlinked it, root created a file at that name, and fchmod on the old descriptor replaced the file of root with the FIFO.
Fix this by looking up the target name of the rename in ovl_copy_up_workdir() with LOOKUP_EXCL, so that copy up fails with -EEXIST if the name is taken, as copy up with O_TMPFILE already does when it links the copy to the name.
[backport: no start_renaming_dentry() and LOOKUP_EXCL, fail with -EEXIST if
the target of ovl_lookup_upper() is positive]
--- fs/overlayfs/copy_up.c | 7 +++++++ 1 file changed, 7 insertions(+)
fs/overlayfs/copy_up.c +7 -0
@@ -758,6 +758,13 @@ static int ovl_copy_up_workdir(struct ovl_copy_up_ctx *c)if (IS_ERR (upper)) goto cleanup; +/* The name may have been taken since lookup, never replace it */ + err = -EEXIST ; +if (d_is_positive (upper)) { +dput (upper); + goto cleanup; + } + err =ovl_do_rename (ofs, wdir, temp, udir, upper,0 );dput (upper);if (err)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 776/3318 smb: smbdirect: fix buffer length underflow in RDMA transfers
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stefan Metzmacher <[email protected]>
[ Upstream commit 7193241a49c958782ba4b8df06da3734d1e317d2 ]
When a remote buffer descriptor is larger than the remaining local buffer, smbdirect_connection_rdma_xmit() clamps its length and sets buf_len to zero. The common accounting code then subtracts the clamped length from buf_len, causing it to underflow. If another descriptor follows, the loop processes it with a wrapped remaining length and includes memory beyond the local buffer in the RDMA transfer.
A client can trigger an out-of-bounds kernel write with an SMB WRITE request, or an out-of-bounds kernel read with an SMB READ request, by supplying multiple RDMA buffer descriptors with an oversized descriptor before the last one.
Remove the premature assignment to buf_len. Subtracting the clamped length already consumes the remaining buffer, so the next iteration stops and only descriptors within the local buffer are used to build work requests.
[ metze: in 6.6 the code is smb_direct_rdma_xmit() in
fs/smb/server/transport_rdma.c ]
--- fs/smb/server/transport_rdma.c | 1 - 1 file changed, 1 deletion(-)
fs/smb/server/transport_rdma.c +0 -1
@@ -1388,7 +1388,6 @@ static int smb_direct_rdma_xmit(struct smb_direct_transport *t,if (desc_buf_len > buf_len) { desc_buf_len = buf_len; desc[i].length =cpu_to_le32 (desc_buf_len); - buf_len =0 ; } credits_needed +=calc_rw_credits (t, desc_buf, desc_buf_len);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 777/3318 mm/hugetlb: fix use-after-free of a new anon folio
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josef Bacik <[email protected]>
[ Upstream commit 824cc56bf43c714319992bad3558803cac6e77c0 ]
For a fault in a private mapping with nothing in the page cache, hugetlb_no_page() allocates a folio, locks it and maps it. The folio has one reference, which belongs to the page table entry from then on. After dropping the page table lock the function still sets the migratable flag of the folio and unlocks it.
Whoever zaps the entry in between frees the folio. The fault holds the fault mutex and the lock of the vma. MADV_DONTNEED and the first unmap of a hole punch, hugetlb_vmdelete_list(), do not take the fault mutex, and a private vma only has a lock if it owns a reservation map: not with MAP_NORESERVE, and not in the child after fork().
Then the flag is set in, and folio_unlock() is called on, a folio that is free or has a new owner. A surplus page goes back to the page allocator while it is locked:
BUG: Bad page state in process init pfn:108e00 flags: 0x200000000000059(locked|uptodate|dirty|head|node=0|zone=2) page dumped because: PAGE_FLAGS_CHECK_AT_FREE flag(s) set
A page of the pool can be given to the next user, of any file, who locks it and loses the lock to the late folio_unlock():
kernel BUG at mm/filemap.c:1532!
hugetlb_no_page+0x111b/0x23e0 hugetlb_fault+0x3a9/0x14a0
An unprivileged process is enough: threads that write to a MAP_PRIVATE | MAP_NORESERVE hugetlb mapping, threads that call MADV_DONTNEED on it, and one that takes the freed pages for another file.
Until commit 3a47c54f09c4 ("hugetlbfs: revert use i_mmap_rwsem for more pmd sharing synchronization") the fault held i_mmap_rwsem for reading, which everybody who zaps takes for writing. The lock that commit bf4916922c60 ("hugetlbfs: extend hugetlb_vma_lock to private VMAs") gave to private vmas closed the window again, but only for those with a reservation map.
Be done with the folio before the page table lock is dropped, as hugetlb_wp() is with its copy. The function already unlocks page cache folios under that lock.
Original fix generated by an LLM and sent in private by Josef.
--- mm/hugetlb.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
mm/hugetlb.c +6 -2
@@ -6041,8 +6041,6 @@ static vm_fault_t hugetlb_no_page(struct mm_struct *mm, ret =hugetlb_wp (mm, vma, address, ptep, flags, folio, ptl); } -spin_unlock (ptl); -/* * Only set hugetlb_migratable in newly allocated pages. Existing pages * found in the pagecache may not have hugetlb_migratable if they have
@@ -6052,6 +6050,12 @@ static vm_fault_t hugetlb_no_page(struct mm_struct *mm,folio_set_hugetlb_migratable (folio);folio_unlock (folio); + +/* +* Hold the PTL until we're done with the folio: the page table owns the +* folio reference now. +*/ +spin_unlock (ptl); out:hugetlb_vma_unlock_read (vma);mutex_unlock (&hugetlb_fault_mutex_table[hash]);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 778/3318 staging: rtl8723bs: fix spacing around operators in rtw_recv.c
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Khasar Munkh-Erdene <[email protected]>
[ Upstream commit 393b267e6f04a11d4b18b7dc1423fa59f173f72b ]
Fix coding style issues by adding missing spaces around binary and ternary operators, as reported by checkpatch.pl.
Stable-dep-of: 495cb31c791b ("staging: rtl8723bs: fix protected RX frame validation in decrypt path")
--- drivers/staging/rtl8723bs/core/rtw_recv.c | 82 +++++++++++------------ 1 file changed, 41 insertions(+), 41 deletions(-)
drivers/staging/rtl8723bs/core/rtw_recv.c +41 -41
@@ -333,13 +333,13 @@ static signed int recvframe_chkmic(struct adapter *adapter, union recv_frame *p mickey = &stainfo->dot11tkiprxmickey.skey[0 ]; } - datalen = precvframe->u.hdr.len-prxattrib->hdrlen-prxattrib->iv_len-prxattrib->icv_len-8 ;/* icv_len included the mic code */ + datalen = precvframe->u.hdr.len - prxattrib->hdrlen - prxattrib->iv_len - prxattrib->icv_len -8 ;/* icv_len included the mic code */ pframe = precvframe->u.hdr.rx_data; - payload = pframe+prxattrib->hdrlen+prxattrib->iv_len; + payload = pframe + prxattrib->hdrlen + prxattrib->iv_len;rtw_seccalctkipmic (mickey, pframe, payload, datalen, &miccode[0 ], (unsigned char )prxattrib->priority);/* care the length of the data */ - pframemic = payload+datalen; + pframemic = payload + datalen; bmic_err = false;
@@ -387,9 +387,9 @@ static union recv_frame *decryptor(struct adapter *padapter, union recv_frame *pu32 res = _SUCCESS;if (prxattrib->encrypt >0 ) { -u8 *iv = precv_frame->u.hdr.rx_data+prxattrib->hdrlen; +u8 *iv = precv_frame->u.hdr.rx_data + prxattrib->hdrlen; - prxattrib->key_index = (((iv[3 ])>>6 )&0x3 ); + prxattrib->key_index = (((iv[3 ]) >>6 ) &0x3 );if (prxattrib->key_index >WEP_KEYS ) {switch (prxattrib->encrypt) {
@@ -511,7 +511,7 @@ static signed int recv_decache(union recv_frame *precv_frame, u8 bretry, struct {signed int tid = precv_frame->u.hdr.attrib.priority; -u16 seq_ctrl = ((precv_frame->u.hdr.attrib.seq_num&0xffff ) <<4 ) | +u16 seq_ctrl = ((precv_frame->u.hdr.attrib.seq_num &0xffff ) <<4 ) | (precv_frame->u.hdr.attrib.frag_num &0xf );if (tid >15 )
@@ -575,29 +575,29 @@ static void process_wmmps_data(struct adapter *padapter, union recv_frame *precvif (!psta->qos_option)return ; -if (!(psta->qos_info&0xf )) +if (!(psta->qos_info &0xf ))return ; -if (psta->state&WIFI_SLEEP_STATE ) { +if (psta->state &WIFI_SLEEP_STATE ) {u8 wmmps_ac =0 ;switch (pattrib->priority) {case 1 :case 2 : - wmmps_ac = psta->uapsd_bk&BIT (1 ); + wmmps_ac = psta->uapsd_bk &BIT (1 );break ;case 4 :case 5 : - wmmps_ac = psta->uapsd_vi&BIT (1 ); + wmmps_ac = psta->uapsd_vi &BIT (1 );break ;case 6 :case 7 : - wmmps_ac = psta->uapsd_vo&BIT (1 ); + wmmps_ac = psta->uapsd_vo &BIT (1 );break ;case 0 :case 3 :default : - wmmps_ac = psta->uapsd_be&BIT (1 ); + wmmps_ac = psta->uapsd_be &BIT (1 );break ; }
@@ -922,20 +922,20 @@ static signed int validate_recv_ctrl_frame(struct adapter *padapter, union recv_switch (pattrib->priority) {case 1 :case 2 : - wmmps_ac = psta->uapsd_bk&BIT (0 ); + wmmps_ac = psta->uapsd_bk &BIT (0 );break ;case 4 :case 5 : - wmmps_ac = psta->uapsd_vi&BIT (0 ); + wmmps_ac = psta->uapsd_vi &BIT (0 );break ;case 6 :case 7 : - wmmps_ac = psta->uapsd_vo&BIT (0 ); + wmmps_ac = psta->uapsd_vo &BIT (0 );break ;case 0 :case 3 :default : - wmmps_ac = psta->uapsd_be&BIT (0 ); + wmmps_ac = psta->uapsd_be &BIT (0 );break ; }
@@ -947,7 +947,7 @@ static signed int validate_recv_ctrl_frame(struct adapter *padapter, union recv_ psta->state ^=WIFI_STA_ALIVE_CHK_STATE ; } -if ((psta->state&WIFI_SLEEP_STATE ) && (pstapriv->sta_dz_bitmap&BIT (psta->aid))) { +if ((psta->state &WIFI_SLEEP_STATE ) && (pstapriv->sta_dz_bitmap &BIT (psta->aid))) {struct list_head *xmitframe_plist, *xmitframe_phead;struct xmit_frame *pxmitframe =NULL ;struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
@@ -991,7 +991,7 @@ static signed int validate_recv_ctrl_frame(struct adapter *padapter, union recv_/* spin_unlock_bh(&psta->sleep_q.lock); */ spin_unlock_bh (&pxmitpriv->lock); -if (pstapriv->tim_bitmap&BIT (psta->aid)) { +if (pstapriv->tim_bitmap &BIT (psta->aid)) {if (psta->sleepq_len ==0 ) {/* issue nulldata with More data bit = 0 to indicate we have no buffered packets */ issue_nulldata_in_interrupt (padapter, psta->hwaddr);
@@ -1373,9 +1373,9 @@ static signed int validate_80211w_mgmt(struct adapter *adapter, union recv_frame goto validate_80211w_fail; precv_frame =decryptor (adapter, precv_frame);/* save actual management data frame body */ -memcpy (mgmt_DATA, ptr+pattrib->hdrlen+pattrib->iv_len, data_len); +memcpy (mgmt_DATA, ptr + pattrib->hdrlen + pattrib->iv_len, data_len);/* overwrite the iv field */ -memcpy (ptr+pattrib->hdrlen, mgmt_DATA, data_len); +memcpy (ptr + pattrib->hdrlen, mgmt_DATA, data_len);/* remove the iv and icv length */ pattrib->pkt_len = pattrib->pkt_len - pattrib->iv_len - pattrib->icv_len;kfree (mgmt_DATA);
@@ -1431,7 +1431,7 @@ static signed int validate_recv_frame(struct adapter *adapter, union recv_framestruct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib;u8 *ptr = precv_frame->u.hdr.rx_data; -u8 ver = (unsigned char ) (*ptr)&0x3 ; +u8 ver = (unsigned char ) (*ptr) &0x3 ;/* add version chk */ if (ver !=0 ) {
@@ -1469,7 +1469,7 @@ static signed int validate_recv_frame(struct adapter *adapter, union recv_frame retval = _FAIL;/* only data frame return _SUCCESS */ break ;case WIFI_DATA_TYPE :/* data */ - pattrib->qos = (subtype &BIT (7 )) ?1 :0 ; + pattrib->qos = (subtype &BIT (7 )) ?1 :0 ; retval =validate_recv_data_frame (adapter, precv_frame);if (retval == _FAIL) {struct recv_priv *precvpriv = &adapter->recvpriv;
@@ -1514,8 +1514,8 @@ static signed int wlanhdr_to_ethhdr(union recv_frame *precvframe)if (pattrib->encrypt)recvframe_pull_tail (precvframe, pattrib->icv_len); - psnap = (struct ieee80211_snap_hdr *)(ptr+pattrib->hdrlen + pattrib->iv_len); - psnap_type = ptr+pattrib->hdrlen + pattrib->iv_len+SNAP_SIZE ; + psnap = (struct ieee80211_snap_hdr *)(ptr + pattrib->hdrlen + pattrib->iv_len); + psnap_type = ptr + pattrib->hdrlen + pattrib->iv_len +SNAP_SIZE ;/* convert hdr + possible LLC headers into Ethernet header */ /* eth_type = (psnap_type[0] << 8) | psnap_type[1]; */ if ((!memcmp(psnap, rfc1042_header, SNAP_SIZE) &&
@@ -1529,37 +1529,37 @@ static signed int wlanhdr_to_ethhdr(union recv_frame *precvframe)/* Leave Ethernet header part of hdr and full payload */ bsnaphdr = false; - rmv_len = pattrib->hdrlen + pattrib->iv_len + (bsnaphdr?SNAP_SIZE :0 ); + rmv_len = pattrib->hdrlen + pattrib->iv_len + (bsnaphdr ?SNAP_SIZE :0 ); len = precvframe->u.hdr.len - rmv_len; -memcpy (&be_tmp, ptr+rmv_len,2 ); +memcpy (&be_tmp, ptr + rmv_len,2 ); eth_type =ntohs (be_tmp);/* pattrib->ether_type */ pattrib->eth_type = eth_type;if ((check_fwstate (pmlmepriv,WIFI_MP_STATE ) == true)) { ptr += rmv_len; *ptr =0x87 ; - *(ptr+1 ) =0x12 ; + *(ptr +1 ) =0x12 ; eth_type =0x8712 ;/* append rx status for mp test packets */ - ptr =recvframe_pull (precvframe, (rmv_len-sizeof (struct ethhdr )+2 )-24 ); + ptr =recvframe_pull (precvframe, (rmv_len -sizeof (struct ethhdr ) +2 ) -24 );if (!ptr)return _FAIL;memcpy (ptr,get_rxmem (precvframe),24 ); ptr +=24 ; }else { - ptr =recvframe_pull (precvframe, (rmv_len-sizeof (struct ethhdr ) + (bsnaphdr?2 :0 ))); + ptr =recvframe_pull (precvframe, (rmv_len -sizeof (struct ethhdr ) + (bsnaphdr ?2 :0 )));if (!ptr)return _FAIL; }memcpy (ptr, pattrib->dst,ETH_ALEN ); -memcpy (ptr+ETH_ALEN , pattrib->src,ETH_ALEN ); +memcpy (ptr +ETH_ALEN , pattrib->src,ETH_ALEN );if (!bsnaphdr) { be_tmp =htons (len); -memcpy (ptr+12 , &be_tmp,2 ); +memcpy (ptr +12 , &be_tmp,2 ); }return _SUCCESS;
@@ -1610,7 +1610,7 @@ static int amsdu_to_msdu(struct adapter *padapter, union recv_frame *prframe) pdata += nSubframe_Length; a_len -= nSubframe_Length;if (a_len !=0 ) { - padding_len =4 - ((nSubframe_Length +ETH_HLEN ) & (4 -1 )); + padding_len =4 - ((nSubframe_Length +ETH_HLEN ) & (4 -1 ));if (padding_len ==4 ) padding_len =0 ;
@@ -1842,7 +1842,7 @@ static int recv_indicatepkt_reorder(struct adapter *padapter, union recv_frame *rtw_recv_indicatepkt (padapter, prframe); - preorder_ctrl->indicate_seq = (preorder_ctrl->indicate_seq +1 )%4096 ; + preorder_ctrl->indicate_seq = (preorder_ctrl->indicate_seq +1 ) %4096 ;return _SUCCESS; }
@@ -1852,7 +1852,7 @@ static int recv_indicatepkt_reorder(struct adapter *padapter, union recv_frame * retval =amsdu_to_msdu (padapter, prframe); - preorder_ctrl->indicate_seq = (preorder_ctrl->indicate_seq +1 )%4096 ; + preorder_ctrl->indicate_seq = (preorder_ctrl->indicate_seq +1 ) %4096 ;if (retval != _SUCCESS) { }
@@ -2047,7 +2047,7 @@ static int recv_func(struct adapter *padapter, union recv_frame *rframe) !psecuritypriv->busetkipkey) {rtw_enqueue_recvframe (rframe, &padapter->recvpriv.uc_swdec_pending_queue); -if (recvpriv->free_recvframe_cnt <NR_RECVFRAME /4 ) { +if (recvpriv->free_recvframe_cnt <NR_RECVFRAME /4 ) {/* to prevent from recvframe starvation, get recvframe from uc_swdec_pending_queue to free_recvframe_cnt */ rframe =rtw_alloc_recvframe (&padapter->recvpriv.uc_swdec_pending_queue);if (rframe)
@@ -2136,19 +2136,19 @@ static void rtw_signal_stat_timer_hdl(struct timer_list *t) }/* update value of signal_strength, rssi, signal_qual */ - tmp_s = (avg_signal_strength+(_alpha-1 )*recvpriv->signal_strength); + tmp_s = (avg_signal_strength + (_alpha -1 ) * recvpriv->signal_strength);if (tmp_s % _alpha) - tmp_s = tmp_s/_alpha +1 ; + tmp_s = tmp_s / _alpha +1 ;else - tmp_s = tmp_s/_alpha; + tmp_s = tmp_s / _alpha;if (tmp_s >100 ) tmp_s =100 ; - tmp_q = (avg_signal_qual+(_alpha-1 )*recvpriv->signal_qual); + tmp_q = (avg_signal_qual + (_alpha -1 ) * recvpriv->signal_qual);if (tmp_q % _alpha) - tmp_q = tmp_q/_alpha +1 ; + tmp_q = tmp_q / _alpha +1 ;else - tmp_q = tmp_q/_alpha; + tmp_q = tmp_q / _alpha;if (tmp_q >100 ) tmp_q =100 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 779/3318 staging: rtl8723bs: fix protected RX frame validation in decrypt path
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tianchu Chen <[email protected]>
[ Upstream commit 495cb31c791bdf3f9efef255a9587b05b0526c9d ]
The RX software decrypt path mishandles crafted protected frames from a malicious AP in two ways:
1) decryptor() never checks that a protected frame is long enough to hold the 802.11 header plus the per-cipher trailer. All of rtw_wep_decrypt(), rtw_tkip_decrypt() and rtw_aes_decrypt() compute
length = hdr.len - hdrlen - iv_len;
and act on the result, and recvframe_chkmic() similarly computes
datalen = hdr.len - hdrlen - iv_len - icv_len - 8;
for TKIP (the 8-byte Michael MIC is not accounted for in icv_len). A frame shorter than hdrlen + iv_len + icv_len (+ 8 for TKIP) underflows these unsigned subtractions, turning into a ~4 GiB iteration count in aes_decipher()/arc4_crypt()/rtw_seccalctkipmic() or a ~4 GiB crc32_le() length, causing out-of-bounds reads/writes of up to ~4 GiB starting from the rx skb. Reject such frames in decryptor() before touching the IV; this covers all three ciphers and the TKIP MIC check, and also keeps the unconditional iv[3] access within the frame.
2) validate_80211w_mgmt() keeps using the frame - two memcpys through the stale rx_data pointer and a pkt_len update - before checking whether decryptor() returned NULL. On decrypt failure (e.g. a unicast protected deauth/disassoc/action frame with a bad MIC, which this path always software-decrypts) the skb has already been freed, so this is a use-after-free read/write, and the caller's error path frees the frame a second time, drifting free_recvframe_cnt. Bail out immediately when decryptor() fails, freeing the temporary mgmt_DATA buffer first.
Discovered by Atuin - Automated Vulnerability Discovery Engine.
--- drivers/staging/rtl8723bs/core/rtw_recv.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-)
drivers/staging/rtl8723bs/core/rtw_recv.c +18 -3
@@ -387,8 +387,21 @@ static union recv_frame *decryptor(struct adapter *padapter, union recv_frame *pu32 res = _SUCCESS;if (prxattrib->encrypt >0 ) { -u8 *iv = precv_frame->u.hdr.rx_data + prxattrib->hdrlen; +u8 *iv; +u32 min_len = prxattrib->hdrlen + prxattrib->iv_len + prxattrib->icv_len; +/* TKIP appends an 8-byte Michael MIC that icv_len doesn't account for */ +if (prxattrib->encrypt == _TKIP_) + min_len +=8 ; + +/* a protected frame must be long enough to hold the IV and ICV/MIC */ +if (precv_frame->u.hdr.len < min_len) { +rtw_free_recvframe (precv_frame, + &padapter->recvpriv.free_recv_queue); +return NULL ; + } + + iv = precv_frame->u.hdr.rx_data + prxattrib->hdrlen; prxattrib->key_index = (((iv[3 ]) >>6 ) &0x3 );if (prxattrib->key_index >WEP_KEYS ) {
@@ -1372,6 +1385,10 @@ static signed int validate_80211w_mgmt(struct adapter *adapter, union recv_frameif (!mgmt_DATA) goto validate_80211w_fail; precv_frame =decryptor (adapter, precv_frame); +if (!precv_frame) { +kfree (mgmt_DATA); + goto validate_80211w_fail; + }/* save actual management data frame body */ memcpy (mgmt_DATA, ptr + pattrib->hdrlen + pattrib->iv_len, data_len);/* overwrite the iv field */
@@ -1379,8 +1396,6 @@ static signed int validate_80211w_mgmt(struct adapter *adapter, union recv_frame/* remove the iv and icv length */ pattrib->pkt_len = pattrib->pkt_len - pattrib->iv_len - pattrib->icv_len;kfree (mgmt_DATA); -if (!precv_frame) - goto validate_80211w_fail; }else if (is_multicast_ether_addr (GetAddr1Ptr (ptr)) && (subtype ==WIFI_DEAUTH || subtype ==WIFI_DISASSOC )) {signed int BIP_ret = _SUCCESS;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 780/3318 wifi: mt76: mt7996: unlink TWT flow if the MCU rejects the agreement
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhao Li <[email protected]>
[ Upstream commit 022f5f8b7a0580da50fcbc34da853d03d4321fe2 ]
mt7996_mac_add_twt_setup() links a new flow into dev->twt_list before asking the MCU to add the agreement, but exits without unlinking the flow if the request fails. The flow-ID and table masks are only committed after MCU success, so the still-linked flow is invisible to the mask-gated teardown paths.
If the station retries the setup, the same slot is cleared and its embedded list node reinitialized while it is still linked, corrupting dev->twt_list. If the station disassociates instead, teardown skips the flow and station storage can be freed while the node remains linked. A later scheduling or debugfs twt_stats walk can then dereference the freed flow, resulting in a use-after-free.
Unlink the flow when the MCU rejects the agreement. This restores the list to its pre-request state while leaving the unchanged mask and agreement accounting untouched.
--- drivers/net/wireless/mediatek/mt76/mt7996/mac.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7996/mac.c +3 -1
@@ -2551,8 +2551,10 @@ void mt7996_mac_add_twt_setup(struct ieee80211_hw *hw, } flow->tsf =le64_to_cpu (twt_agrt->twt); -if (mt7996_mcu_twt_agrt_update (dev, msta->vif, flow,MCU_TWT_AGRT_ADD )) +if (mt7996_mcu_twt_agrt_update (dev, msta->vif, flow,MCU_TWT_AGRT_ADD )) { +list_del (&flow->list); goto unlock; + } setup_cmd =TWT_SETUP_CMD_ACCEPT ; dev->twt.table_mask |=BIT (table_id);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 781/3318 mptcp: hold MP_JOIN msk ref when cloning reqsk
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ruide Cao <[email protected]>
[ Upstream commit c9c90cf437a9e6597611b6d3aad6e255fad22867 ]
TCP request migration clones pending request sockets with inet_reqsk_clone(). For MPTCP MP_JOIN requests this byte-copies subflow_req->msk, but the clone does not own a reference.
The original and cloned requests can consequently drop the same msk reference, leaving one request with a dangling pointer. This manifests as a KASAN slab-use-after-free in subflow_req_destructor():
BUG: KASAN: slab-use-after-free in subflow_req_destructor (net/mptcp/subflow.c:45) Write of size 4 at addr ff1100010e008d40 by task swapper/0/0 CPU: 0 UID: 0 PID: 0 Comm: swapper/0 Not tainted 7.2.0-rc5-00353-gc27e36054537 #10 PREEMPT(full) Call Trace: subflow_req_destructor (net/mptcp/subflow.c:45) subflow_v4_req_destructor (net/mptcp/subflow.c:694) __reqsk_free (net/ipv4/inet_connection_sock.c:906) reqsk_timer_handler (include/net/request_sock.h:137 net/ipv4/inet_connection_sock.c:1147) Allocated by task 10014: sk_prot_alloc (net/core/sock.c:2246) sk_clone (net/core/sock.c:2488) mptcp_sk_clone_init (include/net/sock.h:1848 net/mptcp/protocol.c:3564) subflow_syn_recv_sock (net/mptcp/subflow.c:883) tcp_check_req (net/ipv4/tcp_minisocks.c:934) Freed by task 0: slab_free_after_rcu_debug (include/linux/kasan.h:235 mm/slub.c:2677 mm/slub.c:6439) rcu_core (kernel/rcu/tree.c:2645 kernel/rcu/tree.c:2897) Last potentially related work creation: kmem_cache_free (mm/slub.c:2638 mm/slub.c:6377 mm/slub.c:6504) __sk_destruct (net/core/sock.c:2289 net/core/sock.c:2391) sk_destruct (net/core/sock.c:2419) __sk_free (net/core/sock.c:2430) sk_free (net/core/sock.c:2441) mptcp_close (include/net/sock.h:2020 net/mptcp/protocol.c:3399) inet_release (net/ipv4/af_inet.c:442) The buggy address belongs to the cache MPTCP of size 2968 The buggy address is 128 bytes inside a freed 2968-byte region
A non-NULL subflow_req->msk means that the request owns one reference. The third ACK can concurrently transfer the original request reference to the child and release it, so taking an unconditional hold on the copied pointer is unsafe.
MPTCP sockets use SLAB_TYPESAFE_BY_RCU and all current inet_reqsk_clone() callers run in an RCU read-side critical section. Document and lockdep-check that calling-context requirement. Read the pointer from the original request and acquire a reference only if it is still live. Use refcount_inc_not_zero_acquire() so the subsequent ownership validation cannot be reordered before the try-get, then re-read the original request to verify that it still owns the same msk. If either check fails, clear the clone pointer; otherwise its normal destructor balances the new reference. Mark the ownership-transfer store with WRITE_ONCE() to match the lockless reads.
The following patch completes the clone fixup for MP_CAPABLE token ownership. Both patches carry the same Fixes tag and are required for stable backports.
--- include/net/mptcp.h | 9 ++++++++ net/ipv4/inet_connection_sock.c | 4 ++++ net/mptcp/subflow.c | 38 ++++++++++++++++++++++++++++++++- 3 files changed, 50 insertions(+), 1 deletion(-)
include/net/mptcp.h +9 -0
@@ -210,6 +210,9 @@ int mptcp_subflow_init_cookie_req(struct request_sock *req,struct request_sock *mptcp_subflow_reqsk_alloc (const struct request_sock_ops *ops,struct sock *sk_listener,bool attach_listener); +/* Caller must hold an RCU read-side lock. */ +void mptcp_subflow_reqsk_clone (struct request_sock *req, +struct request_sock *new_req);__be32 mptcp_get_reset_option (const struct sk_buff *skb);
@@ -303,6 +306,12 @@ static inline struct request_sock *mptcp_subflow_reqsk_alloc(const struct reques return NULL; } +/* Caller must hold an RCU read-side lock. */ +static inline void mptcp_subflow_reqsk_clone (struct request_sock *req, +struct request_sock *new_req) +{ +} +static inline __be32 mptcp_reset_option (const struct sk_buff *skb) {return htonl (0u ); }#endif /* CONFIG_MPTCP */
net/ipv4/inet_connection_sock.c +4 -0
@@ -20,6 +20,7 @@#include <net/tcp_states.h> #include <net/xfrm.h> #include <net/tcp.h> +#include <net/mptcp.h> #include <net/sock_reuseport.h> #include <net/addrconf.h>
@@ -948,6 +949,9 @@ static struct request_sock *inet_reqsk_clone(struct request_sock *req,rcu_assign_pointer (tcp_sk (nreq->sk)->fastopen_rsk, nreq); } +if (rsk_is_mptcp (req)) +mptcp_subflow_reqsk_clone (req, nreq); +return nreq; }
net/mptcp/subflow.c +37 -1
@@ -48,6 +48,42 @@ static void subflow_req_destructor(struct request_sock *req)mptcp_token_destroy_request (req); } +void mptcp_subflow_reqsk_clone (struct request_sock *req, +struct request_sock *new_req) +{ +struct mptcp_subflow_request_sock *subflow_req =mptcp_subflow_rsk (req); +struct mptcp_subflow_request_sock *new_subflow_req; +struct mptcp_sock *msk; + + new_subflow_req =mptcp_subflow_rsk (new_req); +RCU_LOCKDEP_WARN (!rcu_read_lock_any_held (), +"MPTCP reqsk clone called without RCU" ); + +/* A non-NULL ->msk means the request owns one reference. The clone +* copied only the pointer, while the original request can concurrently +* transfer its reference to the child. Acquire a reference for the +* clone, then verify that the original request still owns the same msk. +* MPTCP sockets use SLAB_TYPESAFE_BY_RCU and all clone callers run in +* an RCU read-side critical section, keeping the memory stable here. +*/ + msk =READ_ONCE (subflow_req->msk); +if (msk) { +struct sock *sk = (struct sock *)msk; + +if (!refcount_inc_not_zero (&sk->sk_refcnt)) { + msk =NULL ; + }else { +smp_acquire__after_ctrl_dep (); +if (READ_ONCE (subflow_req->msk) != msk) { +sock_put (sk); + msk =NULL ; + } + } + } + + new_subflow_req->msk = msk; +} +static void subflow_generate_hmac (u64 key1,u64 key2,u32 nonce1,u32 nonce2,void *hmac) {
@@ -901,7 +937,7 @@ static struct sock *subflow_syn_recv_sock(const struct sock *sk, }/* move the msk reference ownership to the subflow */ - subflow_req->msk =NULL ; +WRITE_ONCE (subflow_req->msk,NULL ); ctx->conn = (struct sock *)owner;if (subflow_use_different_sport (owner, sk)) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 782/3318 nvmet: replace use of system_wq with system_percpu_wq
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marco Crivellari <[email protected]>
[ Upstream commit 3d553be6d295b6cca8fd35cb673fd13934ac4cbc ]
This patch continues the effort to refactor workqueue APIs, which has begun with the changes introducing new workqueues and a new alloc_workqueue flag:
commit 128ea9f6ccfb ("workqueue: Add system_percpu_wq and system_dfl_wq") commit 930c2ea566af ("workqueue: Add new WQ_PERCPU flag")
The point of the refactoring is to eventually alter the default behavior of workqueues to become unbound by default so that their workload placement is optimized by the scheduler.
Before that to happen, workqueue users must be converted to the better named new workqueues with no intended behaviour changes:
system_wq -> system_percpu_wq
system_unbound_wq -> system_dfl_wq
This way the old obsolete workqueues (system_wq, system_unbound_wq) can be removed in the future.
Stable-dep-of: 53f6efe00cea ("nvmet-auth: serialize access to DH-HMAC-CHAP state to fix UAF")
--- drivers/nvme/target/admin-cmd.c | 2 +- drivers/nvme/target/fabrics-cmd-auth.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/nvme/target/admin-cmd.c +1 -1
@@ -993,7 +993,7 @@ void nvmet_execute_keep_alive(struct nvmet_req *req)pr_debug ("ctrl %d update keep-alive timer for %d secs\n" , ctrl->cntlid, ctrl->kato); -mod_delayed_work (system_wq, &ctrl->ka_work, ctrl->kato *HZ ); +mod_delayed_work (system_percpu_wq, &ctrl->ka_work, ctrl->kato *HZ ); out:nvmet_req_complete (req, status); }
drivers/nvme/target/fabrics-cmd-auth.c +1 -1
@@ -360,7 +360,7 @@ void nvmet_execute_auth_send(struct nvmet_req *req) req->sq->dhchap_step != NVME_AUTH_DHCHAP_MESSAGE_FAILURE2) {unsigned long auth_expire_secs = ctrl->kato ? ctrl->kato :120 ; -mod_delayed_work (system_wq, &req->sq->auth_expired_work, +mod_delayed_work (system_percpu_wq, &req->sq->auth_expired_work, auth_expire_secs *HZ ); goto complete; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 783/3318 nvmet-auth: serialize access to DH-HMAC-CHAP state to fix UAF
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jérémy Jean <[email protected]>
[ Upstream commit 53f6efe00cea0c0cf7bd99debe3cdac8567170b5 ]
A REPLY AUTH_SEND command can derive a dhchap_skey key while a concurrent AUTH_RECEIVE command observing this REPLY state executes the failure path and frees that key. The REPLY command then continues and writes into freed memory, causing a use-after-free. KASAN reports it as:
BUG: KASAN: slab-use-after-free in __sha256_final Write of size 4 at addr ffff88800359c540 ... nvmet_auth_sq_free (drivers/nvme/target/auth.c:237) nvmet_execute_auth_receive (drivers/nvme/target/fabrics-cmd-auth.c:621)
Add a mutex to each submission queue to serialize authentication commands and timeout handling. Unlock the mutex before completing requests and ignore outdated timeout callbacks. Limit timeout delays to prevent immediate expiry on 32-bit kernels.
--- drivers/nvme/target/auth.c | 1 + drivers/nvme/target/fabrics-cmd-auth.c | 32 ++++++++++++++++++++++---- drivers/nvme/target/nvmet.h | 2 ++ 3 files changed, 31 insertions(+), 4 deletions(-)
drivers/nvme/target/auth.c +1 -0
@@ -218,6 +218,7 @@ u8 nvmet_setup_auth(struct nvmet_ctrl *ctrl)void nvmet_auth_sq_free (struct nvmet_sq *sq) { + sq->auth_expiry_active = false;cancel_delayed_work (&sq->auth_expired_work);kfree (sq->dhchap_c1); sq->dhchap_c1 =NULL ;
drivers/nvme/target/fabrics-cmd-auth.c +28 -4
@@ -6,6 +6,7 @@*/ #define pr_fmt (fmt) KBUILD_MODNAME ": " fmt#include <linux/blkdev.h> +#include <linux/jiffies.h> #include <linux/random.h> #include <linux/nvme-auth.h> #include <crypto/hash.h>
@@ -18,16 +19,27 @@ static void nvmet_auth_expired_work(struct work_struct *work)struct nvmet_sq *sq =container_of (to_delayed_work (work), struct nvmet_sq, auth_expired_work); +mutex_lock (&sq->auth_lock); +/* A command may have cancelled or rearmed this timeout. */ +if (!sq->auth_expiry_active || +delayed_work_pending (&sq->auth_expired_work)) + goto out_unlock; + sq->auth_expiry_active = false; +pr_debug ("%s: ctrl %d qid %d transaction %u expired, resetting\n" , __func__, sq->ctrl->cntlid, sq->qid, sq->dhchap_tid); sq->dhchap_step =NVME_AUTH_DHCHAP_MESSAGE_NEGOTIATE ; sq->dhchap_tid =-1 ; +out_unlock: +mutex_unlock (&sq->auth_lock); }void nvmet_auth_sq_init (struct nvmet_sq *sq) {/* Initialize in-band authentication */ +mutex_init (&sq->auth_lock);INIT_DELAYED_WORK (&sq->auth_expired_work, nvmet_auth_expired_work); + sq->auth_expiry_active = false; sq->authenticated = false; sq->dhchap_step =NVME_AUTH_DHCHAP_MESSAGE_NEGOTIATE ; }
@@ -211,6 +223,8 @@ void nvmet_execute_auth_send(struct nvmet_req *req)u16 status =0 ;u8 dhchap_status; +mutex_lock (&req->sq->auth_lock); +if (req->cmd->auth_send.secp !=NVME_AUTH_DHCHAP_PROTOCOL_IDENTIFIER ) { status =NVME_SC_INVALID_FIELD |NVME_STATUS_DNR ; req->error_loc =
@@ -236,8 +250,10 @@ void nvmet_execute_auth_send(struct nvmet_req *req) offsetof(struct nvmf_auth_send_command , tl); goto done; } -if (!nvmet_check_transfer_len (req, tl)) { +if (unlikely (tl != req->transfer_len)) {pr_debug ("%s: transfer length mismatch (%u)\n" , __func__, tl); +mutex_unlock (&req->sq->auth_lock); +nvmet_check_transfer_len (req, tl);return ; }
@@ -358,10 +374,12 @@ void nvmet_execute_auth_send(struct nvmet_req *req) status, req->error_loc);if (req->sq->dhchap_step !=NVME_AUTH_DHCHAP_MESSAGE_SUCCESS2 && req->sq->dhchap_step !=NVME_AUTH_DHCHAP_MESSAGE_FAILURE2 ) { -unsigned long auth_expire_secs = ctrl->kato ? ctrl->kato :120 ; +unsigned long auth_expire =min_t (u64,MAX_JIFFY_OFFSET , + (u64)(ctrl->kato ? ctrl->kato :120 ) *HZ ); + req->sq->auth_expiry_active = true;mod_delayed_work (system_percpu_wq, &req->sq->auth_expired_work, - auth_expire_secs *HZ ); + auth_expire); goto complete; }/* Final states, clear up variables */
@@ -370,6 +388,7 @@ void nvmet_execute_auth_send(struct nvmet_req *req)nvmet_ctrl_fatal_error (ctrl); complete: +mutex_unlock (&req->sq->auth_lock);nvmet_req_complete (req, status); }
@@ -488,6 +507,8 @@ void nvmet_execute_auth_receive(struct nvmet_req *req)u32 al;u16 status =0 ; +mutex_lock (&req->sq->auth_lock); +if (req->cmd->auth_receive.secp !=NVME_AUTH_DHCHAP_PROTOCOL_IDENTIFIER ) { status =NVME_SC_INVALID_FIELD |NVME_STATUS_DNR ; req->error_loc =
@@ -513,8 +534,10 @@ void nvmet_execute_auth_receive(struct nvmet_req *req) offsetof(struct nvmf_auth_receive_command , al); goto done; } -if (!nvmet_check_transfer_len (req, al)) { +if (unlikely (al != req->transfer_len)) {pr_debug ("%s: transfer length mismatch (%u)\n" , __func__, al); +mutex_unlock (&req->sq->auth_lock); +nvmet_check_transfer_len (req, al);return ; }
@@ -573,5 +596,6 @@ void nvmet_execute_auth_receive(struct nvmet_req *req)nvmet_auth_sq_free (req->sq);nvmet_ctrl_fatal_error (ctrl); } +mutex_unlock (&req->sq->auth_lock);nvmet_req_complete (req, status); }
drivers/nvme/target/nvmet.h +2 -0
@@ -109,8 +109,10 @@ struct nvmet_sq {u32 sqhd;bool sqhd_disabled;#ifdef CONFIG_NVME_TARGET_AUTH +struct mutex auth_lock;bool authenticated;struct delayed_work auth_expired_work; +bool auth_expiry_active;u16 dhchap_tid;u8 dhchap_status;u8 dhchap_step;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 784/3318 media: ipu-bridge: Fix use-after-free in IVSC error path
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yibo Tan <[email protected]>
[ Upstream commit 3d42d1c82717f0853379b516a7fab54b636e09cc ]
ipu_bridge_get_ivsc_acpi_dev() returns an ACPI device with a reference held. If no matching CSI device is found, ipu_bridge_check_ivsc_dev() drops that reference before passing the device to dev_err(). Concurrent CSI device and ACPI namespace removal can drop the other references, making this the final put. dev_err() then reads the freed struct acpi_device and its kobject name.
This was reproduced without kprobes by racing normal CSI platform-device unregistration and ACPI configfs table removal against the production ipu_bridge_init() entry. KASAN reported the final free through device_release(), followed by invalid reads through _dev_err().
Emit the error message while the lookup reference is still held, then drop the reference as before.
Source reproducers and vulnerable/fixed serial logs, with only the build hostname redacted, are available at:
https://github.com/kimaiden1984-boop/linux-ipu-bridge-acpi-uaf-reproducer
The fixed target builds with W=1 on x86-64. This was not tested on physical IPU hardware. The tests establish runtime reachability but do not measure occurrence frequency on shipping systems or establish exploitability.
--- drivers/media/pci/intel/ipu-bridge.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/pci/intel/ipu-bridge.c +1 -1
@@ -168,8 +168,8 @@ static int ipu_bridge_check_ivsc_dev(struct ipu_sensor *sensor,if (adev) { csi_dev =ipu_bridge_get_ivsc_csi_dev (adev);if (!csi_dev) { -acpi_dev_put (adev);dev_err (ADEV_DEV (adev),"Failed to find MEI CSI dev\n" ); +acpi_dev_put (adev);return -ENODEV ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 785/3318 media: platform: microchip: use for_each_endpoint_of_node()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuninori Morimoto <[email protected]>
[ Upstream commit 68a1560c3b7f8bb23423b272334fc19279e82d9a ]
We already have for_each_endpoint_of_node(), don't use of_graph_get_next_endpoint() directly. Replace it.
Stable-dep-of: f2eb2fd388bf ("media: microchip-isc: take a reference on the parsed endpoints")
--- .../microchip/microchip-sama5d2-isc.c | 21 +++++++------------ .../microchip/microchip-sama7g5-isc.c | 21 +++++++------------ 2 files changed, 16 insertions(+), 26 deletions(-)
drivers/media/platform/microchip/microchip-sama5d2-isc.c +8 -13
@@ -353,33 +353,29 @@ static const u32 isc_sama5d2_gamma_table[][GAMMA_ENTRIES] = {static int isc_parse_dt (struct device *dev,struct isc_device *isc) {struct device_node *np = dev->of_node; -struct device_node *epn =NULL ; +struct device_node *epn;struct isc_subdev_entity *subdev_entity;unsigned int flags; -int ret;INIT_LIST_HEAD (&isc->subdev_entities); -while (1 ) { +for_each_endpoint_of_node (np, epn) {struct v4l2_fwnode_endpoint v4l2_epn = { .bus_type =0 }; - - epn =of_graph_get_next_endpoint (np, epn); -if (!epn) -return 0 ; +int ret; ret =v4l2_fwnode_endpoint_parse (of_fwnode_handle (epn), &v4l2_epn);if (ret) { - ret = -EINVAL ; +of_node_put (epn);dev_err (dev,"Could not parse the endpoint\n" ); -break ; +return -EINVAL ; } subdev_entity =devm_kzalloc (dev,sizeof (*subdev_entity),GFP_KERNEL );if (!subdev_entity) { - ret = -ENOMEM ; -break ; +of_node_put (epn); +return -ENOMEM ; } subdev_entity->epn = epn;
@@ -400,9 +396,8 @@ static int isc_parse_dt(struct device *dev, struct isc_device *isc)list_add_tail (&subdev_entity->list, &isc->subdev_entities); } -of_node_put (epn); -return ret; +return 0 ; }static int microchip_isc_probe (struct platform_device *pdev)
drivers/media/platform/microchip/microchip-sama7g5-isc.c +8 -13
@@ -336,36 +336,32 @@ static const u32 isc_sama7g5_gamma_table[][GAMMA_ENTRIES] = {static int xisc_parse_dt (struct device *dev,struct isc_device *isc) {struct device_node *np = dev->of_node; -struct device_node *epn =NULL ; +struct device_node *epn;struct isc_subdev_entity *subdev_entity;unsigned int flags; -int ret;bool mipi_mode;INIT_LIST_HEAD (&isc->subdev_entities); mipi_mode =of_property_read_bool (np,"microchip,mipi-mode" ); -while (1 ) { +for_each_endpoint_of_node (np, epn) {struct v4l2_fwnode_endpoint v4l2_epn = { .bus_type =0 }; - - epn =of_graph_get_next_endpoint (np, epn); -if (!epn) -return 0 ; +int ret; ret =v4l2_fwnode_endpoint_parse (of_fwnode_handle (epn), &v4l2_epn);if (ret) { - ret = -EINVAL ; +of_node_put (epn);dev_err (dev,"Could not parse the endpoint\n" ); -break ; +return -EINVAL ; } subdev_entity =devm_kzalloc (dev,sizeof (*subdev_entity),GFP_KERNEL );if (!subdev_entity) { - ret = -ENOMEM ; -break ; +of_node_put (epn); +return -ENOMEM ; } subdev_entity->epn = epn;
@@ -389,9 +385,8 @@ static int xisc_parse_dt(struct device *dev, struct isc_device *isc)list_add_tail (&subdev_entity->list, &isc->subdev_entities); } -of_node_put (epn); -return ret; +return 0 ; }static int microchip_xisc_probe (struct platform_device *pdev)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 786/3318 media: microchip-isc: take a reference on the parsed endpoints
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Balakrishnan Sambath <[email protected]>
[ Upstream commit f2eb2fd388bf3f1959556a326e797cacca341c86 ]
for_each_endpoint_of_node() drops the reference on the current node as it advances. xisc_parse_dt() and isc_parse_dt() store the node in subdev_entity->epn and release it later with of_node_put(), but never took their own reference, so the stored pointer refers to an already-released node. This underflows the refcount and can use-after-free, reachable through the camera device tree overlay.
Take a reference with of_node_get() when storing the node, and drop it in microchip_isc_subdev_cleanup() so the entities the bind loop never reaches on an early exit do not leak it.
--- .../platform/microchip/microchip-isc-base.c | 6 ++++++ .../platform/microchip/microchip-sama5d2-isc.c | 17 ++++++++++++----- .../platform/microchip/microchip-sama7g5-isc.c | 17 ++++++++++++----- 3 files changed, 30 insertions(+), 10 deletions(-)
drivers/media/platform/microchip/microchip-isc-base.c +6 -0
@@ -1902,6 +1902,12 @@ void microchip_isc_subdev_cleanup(struct isc_device *isc)list_for_each_entry (subdev_entity, &isc->subdev_entities, list) {v4l2_async_nf_unregister (&subdev_entity->notifier);v4l2_async_nf_cleanup (&subdev_entity->notifier); +/* +* Release the endpoint reference taken while parsing. It is +* NULL for entities the bind loop already consumed, so this +* only drops the ones left over on an early exit. +*/ +of_node_put (subdev_entity->epn); }INIT_LIST_HEAD (&isc->subdev_entities);
drivers/media/platform/microchip/microchip-sama5d2-isc.c +12 -5
@@ -356,28 +356,30 @@ static int isc_parse_dt(struct device *dev, struct isc_device *isc)struct device_node *epn;struct isc_subdev_entity *subdev_entity;unsigned int flags; +int ret;INIT_LIST_HEAD (&isc->subdev_entities);for_each_endpoint_of_node (np, epn) {struct v4l2_fwnode_endpoint v4l2_epn = { .bus_type =0 }; -int ret; ret =v4l2_fwnode_endpoint_parse (of_fwnode_handle (epn), &v4l2_epn);if (ret) { -of_node_put (epn);dev_err (dev,"Could not parse the endpoint\n" ); -return -EINVAL ; +of_node_put (epn); + ret = -EINVAL ; + goto err_cleanup; } subdev_entity =devm_kzalloc (dev,sizeof (*subdev_entity),GFP_KERNEL );if (!subdev_entity) {of_node_put (epn); -return -ENOMEM ; + ret = -ENOMEM ; + goto err_cleanup; } - subdev_entity->epn = epn; + subdev_entity->epn =of_node_get (epn); flags = v4l2_epn.bus.parallel.flags;
@@ -398,6 +400,11 @@ static int isc_parse_dt(struct device *dev, struct isc_device *isc) }return 0 ; + +err_cleanup: +list_for_each_entry (subdev_entity, &isc->subdev_entities, list) +of_node_put (subdev_entity->epn); +return ret; }static int microchip_isc_probe (struct platform_device *pdev)
drivers/media/platform/microchip/microchip-sama7g5-isc.c +12 -5
@@ -340,6 +340,7 @@ static int xisc_parse_dt(struct device *dev, struct isc_device *isc)struct isc_subdev_entity *subdev_entity;unsigned int flags;bool mipi_mode; +int ret;INIT_LIST_HEAD (&isc->subdev_entities);
@@ -347,23 +348,24 @@ static int xisc_parse_dt(struct device *dev, struct isc_device *isc)for_each_endpoint_of_node (np, epn) {struct v4l2_fwnode_endpoint v4l2_epn = { .bus_type =0 }; -int ret; ret =v4l2_fwnode_endpoint_parse (of_fwnode_handle (epn), &v4l2_epn);if (ret) { -of_node_put (epn);dev_err (dev,"Could not parse the endpoint\n" ); -return -EINVAL ; +of_node_put (epn); + ret = -EINVAL ; + goto err_cleanup; } subdev_entity =devm_kzalloc (dev,sizeof (*subdev_entity),GFP_KERNEL );if (!subdev_entity) {of_node_put (epn); -return -ENOMEM ; + ret = -ENOMEM ; + goto err_cleanup; } - subdev_entity->epn = epn; + subdev_entity->epn =of_node_get (epn); flags = v4l2_epn.bus.parallel.flags;
@@ -387,6 +389,11 @@ static int xisc_parse_dt(struct device *dev, struct isc_device *isc) }return 0 ; + +err_cleanup: +list_for_each_entry (subdev_entity, &isc->subdev_entities, list) +of_node_put (subdev_entity->epn); +return ret; }static int microchip_xisc_probe (struct platform_device *pdev)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 787/3318 mm: khugepaged: fix swap entry value to folio_pfn()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vernon Yang <[email protected]>
[ Upstream commit 942c8ec27aa4ffc587511650718349964e1696e6 ]
Patch series "mm: khugepaged: fix tracepoint UAF", v5.
The khugepaged tracepoints take a folio pointer and call folio_pfn(), but by then the folio may no longer be valid: freed after folio_put(), folio_unlock() or pte_unmap_unlock(), or not a folio at all but an xarray-encoded swap entry. On classic SPARSEMEM, dereferencing it oopses khugepaged as soon as the trace event is enabled; on other memory models it merely prints a bogus pfn.
Pass the pfn to the tracepoints directly, captured while the folio is still pinned, closing the use-after-free windows in mm_khugepaged_scan_file(), mm_khugepaged_scan_pmd() and mm_khugepaged_collapse_file().
This patch (of 3):
When the swap entries found exceed max_ptes_swap, the loop is left via break with folio still holding the xarray value that encodes the swap entry, not valid folio pointer.
That value is passed to trace_mm_khugepaged_scan_file(), which feeds it to folio_pfn(). On FLATMEM and SPARSEMEM_VMEMMAP, the page_to_pfn() is plain pointer arithmetic, so the trace event merely prints bogus scan_pfn. On classic SPARSEMEM, the page_to_pfn() reads page->flags, dereferencing the tiny encoded integer and oopsing khugepaged whenever the trace event is enabled.
So when folio is the swap entry value, simply set pfn to -1, just like exhausted scan naturally.
And the folio_put() has maybe dropped the last reference of folio. The trace_mm_khugepaged_scan_file() is left with a dangling folio pointer. so using the folio_pfn() before dropping the reference, closing use-after-free window.
--- include/trace/events/huge_memory.h | 6 +++--- mm/khugepaged.c | 7 ++++++- 2 files changed, 9 insertions(+), 4 deletions(-)
include/trace/events/huge_memory.h +3 -3
@@ -174,10 +174,10 @@ TRACE_EVENT(mm_collapse_huge_page_swapin, TRACE_EVENT(mm_khugepaged_scan_file, - TP_PROTO(struct mm_struct *mm, struct page *page, struct file *file, + TP_PROTO(struct mm_struct *mm, unsigned long pfn, struct file *file, int present, int swap, int result), - TP_ARGS(mm, page, file, present, swap, result), + TP_ARGS(mm, pfn, file, present, swap, result), TP_STRUCT__entry( __field(struct mm_struct *, mm)
@@ -190,7 +190,7 @@ TRACE_EVENT(mm_khugepaged_scan_file,TP_fast_assign ( __entry->mm = mm; - __entry->pfn = page ?page_to_pfn (page) :-1 ; + __entry->pfn = pfn;__assign_str (filename, file->f_path.dentry->d_iname); __entry->present = present; __entry->swap = swap;
mm/khugepaged.c +6 -1
@@ -2221,6 +2221,7 @@ static int hpage_collapse_scan_file(struct mm_struct *mm, unsigned long addr,int present, swap;int node =NUMA_NO_NODE ;int result =SCAN_SUCCEED ; +unsigned long failed_pfn =-1 ; present =0 ; swap =0 ;
@@ -2254,6 +2255,7 @@ static int hpage_collapse_scan_file(struct mm_struct *mm, unsigned long addr,/* Maybe PMD-mapped */ ? SCAN_PTE_MAPPED_HUGEPAGE :SCAN_PAGE_COMPOUND ; + failed_pfn =page_to_pfn (page);/* * For SCAN_PTE_MAPPED_HUGEPAGE, further processing * by the caller won't touch the page cache, and so
@@ -2266,18 +2268,21 @@ static int hpage_collapse_scan_file(struct mm_struct *mm, unsigned long addr, node =page_to_nid (page);if (hpage_collapse_scan_abort (node, cc)) { result =SCAN_SCAN_ABORT ; + failed_pfn =page_to_pfn (page);break ; } cc->node_load[node]++;if (!PageLRU (page)) { result =SCAN_PAGE_LRU ; + failed_pfn =page_to_pfn (page);break ; }if (page_count (page) !=1 +page_mapcount (page) +page_has_private (page)) { result =SCAN_PAGE_COUNT ; + failed_pfn =page_to_pfn (page);break ; }
@@ -2306,7 +2311,7 @@ static int hpage_collapse_scan_file(struct mm_struct *mm, unsigned long addr, } } -trace_mm_khugepaged_scan_file (mm, page, file, present, swap, result); +trace_mm_khugepaged_scan_file (mm, failed_pfn, file, present, swap, result);return result; }#else
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 788/3318 mm: khugepaged: fix folio is used after folio_put/unlock()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vernon Yang <[email protected]>
[ Upstream commit 9010383e71e6ce75fcd3c8f87133c8ce6c0e6ab4 ]
On the rollback path, folio_put() has already dropped the last reference of new_folio. On the success path, new_folio is already unlocked and can be freed concurrently. The trace_mm_khugepaged_collapse_file() is left with a dangling folio pointer.
So using the folio_pfn() before dropping the reference, closing use-after-free window.
--- include/trace/events/huge_memory.h | 6 +++--- mm/khugepaged.c | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-)
include/trace/events/huge_memory.h +3 -3
@@ -207,10 +207,10 @@ TRACE_EVENT(mm_khugepaged_scan_file, ); TRACE_EVENT(mm_khugepaged_collapse_file, - TP_PROTO(struct mm_struct *mm, struct folio *new_folio, pgoff_t index, + TP_PROTO(struct mm_struct *mm, unsigned long new_pfn, pgoff_t index, unsigned long addr, bool is_shmem, struct file *file, int nr, int result), - TP_ARGS(mm, new_folio, index, addr, is_shmem, file, nr, result), + TP_ARGS(mm, new_pfn, index, addr, is_shmem, file, nr, result), TP_STRUCT__entry( __field(struct mm_struct *, mm) __field(unsigned long, hpfn)
@@ -224,7 +224,7 @@ TRACE_EVENT(mm_khugepaged_collapse_file,TP_fast_assign ( __entry->mm = mm; - __entry->hpfn = new_folio ?folio_pfn (new_folio) :-1 ; + __entry->hpfn = new_pfn; __entry->index = index; __entry->addr = addr; __entry->is_shmem = is_shmem;
mm/khugepaged.c +3 -1
@@ -1788,6 +1788,7 @@ static int collapse_file(struct mm_struct *mm, unsigned long addr,struct page *page;struct page *tmp, *dst;struct folio *folio, *new_folio; +unsigned long new_pfn =-1 ;pgoff_t index =0 , end = start +HPAGE_PMD_NR ;LIST_HEAD (pagelist);XA_STATE_ORDER (xas, &mapping->i_pages, start,HPAGE_PMD_ORDER );
@@ -1800,6 +1801,7 @@ static int collapse_file(struct mm_struct *mm, unsigned long addr, result =alloc_charge_folio (&new_folio, mm, cc);if (result !=SCAN_SUCCEED ) goto out; + new_pfn =folio_pfn (new_folio);mapping_set_update (&xas, mapping);
@@ -2207,7 +2209,7 @@ static int collapse_file(struct mm_struct *mm, unsigned long addr,folio_put (new_folio); out:VM_BUG_ON (!list_empty (&pagelist)); -trace_mm_khugepaged_collapse_file (mm, new_folio, index, addr, is_shmem, file,HPAGE_PMD_NR , result); +trace_mm_khugepaged_collapse_file (mm, new_pfn, index, addr, is_shmem, file,HPAGE_PMD_NR , result);return result; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 789/3318 media: s5p-mfc: use timer_shutdown_sync() for the self-rearming watchdog
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fan Wu <[email protected]>
[ Upstream commit 63069b5917cba2e15b1a78b3f4ff99e45102c56f ]
The MFC watchdog timer (s5p_mfc_watchdog) is self-rearming: every callback re-arms itself with add_timer() and, on a timeout, schedules watchdog_work. s5p_mfc_remove() tears this down with timer_delete_sync() followed by flush_work().
timer_delete_sync() dequeues the timer and waits for a callback that is already running, but it does not prevent a subsequent re-arm. Because the watchdog callback re-arms via add_timer(), this is the wrong shutdown
primitive: once the wait returns nothing guarantees a just-queued re-arm will not fire later, dereferencing dev (clock on/off, deinit_hw, load_firmware, init_hw) after video_unregister_device(), DMA teardown and s5p_mfc_final_pm() have run, a potential use-after-free.
Use timer_shutdown_sync(), which puts the timer into a shutdown state so that any add_timer()/mod_timer() from the callback becomes a no-op and no later firing is possible. Switch flush_work() to cancel_work_sync() so any watchdog_work that was already queued before the timer was stopped is cancelled rather than allowed to run to completion against the torn-down device.
This issue was found by an in-house static analysis tool. No runtime reproducer is available.
--- drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c +2 -2
@@ -1454,8 +1454,8 @@ static void s5p_mfc_remove(struct platform_device *pdev) }mutex_unlock (&dev->mfc_mutex); -del_timer_sync (&dev->watchdog_timer); -flush_work (&dev->watchdog_work); +timer_shutdown_sync (&dev->watchdog_timer); +cancel_work_sync (&dev->watchdog_work);video_unregister_device (dev->vfd_enc);video_unregister_device (dev->vfd_dec);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 790/3318 scsi: dc395x: sync the waiting_timer before freeing the host
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fan Wu <[email protected]>
[ Upstream commit 0b1a79f2791a06f139dce5450e487307cf0e241f ]
The waiting_timer callback re-arms itself and takes the host lock. adapter_uninit() currently stops it with timer_delete(), which does not wait for a callback already running on another CPU. The final scsi_host_put() that frees the host (and the host lock the callback dereferences) runs right after adapter_uninit(), so a concurrent or just re-armed callback can fire after the free, leaving a potential use-after-free window.
Replace timer_delete() with timer_shutdown_sync() at the top of adapter_uninit(), before the host-lock section: the timer is dequeued, a running callback is waited for and rearming is blocked before the chip is halted, so it cannot fire at all once the adapter has ceased to function. Waiting outside the lock avoids the self-deadlock that would result from syncing a callback blocked on the lock we still hold.
No shutdown is needed for selto_timer because it has no reachable armer or callback.
This issue was found by an in-house static analysis tool.
--- drivers/scsi/dc395x.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/scsi/dc395x.c +4 -6
@@ -4411,13 +4411,11 @@ static void adapter_uninit_chip(struct AdapterCtlBlk *acb)static void adapter_uninit (struct AdapterCtlBlk *acb) {unsigned long flags; -DC395x_LOCK_IO (acb->scsi_host, flags); -/* remove timers */ -if (timer_pending (&acb->waiting_timer)) -del_timer (&acb->waiting_timer); -if (timer_pending (&acb->selto_timer)) -del_timer (&acb->selto_timer); +/* Drain the self-rearming timer; must not run under host_lock. */ +timer_shutdown_sync (&acb->waiting_timer); + +DC395x_LOCK_IO (acb->scsi_host, flags);adapter_uninit_chip (acb);adapter_remove_and_free_all_devices (acb);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 791/3318 media: rc: Fix race between bpf(BPG_PROG_ATTACH) and device unregister
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Young <[email protected]>
[ Upstream commit b3f5daf3222999d3f92f606a4eb5e35ab90fd0e4 ]
Mark the device as unregistered before tearing down raw IR/bpf state, so that racing bpf(BPF_PROG_{ATTACH,DETACH,QUERY}) calls cannot slip in between ir_raw_event_unregister() completing and dev->registered being cleared.
--- drivers/media/rc/rc-main.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/media/rc/rc-main.c +6 -6
@@ -2030,18 +2030,18 @@ void rc_unregister_device(struct rc_dev *dev)if (!dev)return ; +mutex_lock (&dev->lock); + dev->registered = false; +if (dev->users && dev->close) + dev->close (dev); +mutex_unlock (&dev->lock); +if (dev->driver_type ==RC_DRIVER_IR_RAW )ir_raw_event_unregister (dev);del_timer_sync (&dev->timer_keyup);del_timer_sync (&dev->timer_repeat); -mutex_lock (&dev->lock); -if (dev->users && dev->close) - dev->close (dev); - dev->registered = false; -mutex_unlock (&dev->lock); -rc_free_rx_device (dev);/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 792/3318 drm/nouveau: reject zero-size notifier object allocation
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhenhao Wan <[email protected]>
[ Upstream commit 38125d38d850bd2fdd5d7840c3bd52d9d208995b ]
nouveau_abi16_ioctl_notifierobj_alloc() passes the userspace-controlled info->size to nvkm_mm_head() as both size_max and size_min without a lower bound. A zero size satisfies the allocator's "e - s < size_min" gate (size_min == 0 makes the unsigned comparison inert) and yields a zero-length node, after which
args.limit = ntfy->node->offset + ntfy->node->length - 1;
underflows (offset 0, length 0 -> 0xffffffff) into an oversized ~4 GiB DMA window. The dma object constructor only rejects start > limit, so the validly ordered [base, base + 0xffffffff] range passes and is programmed into the GPU DMA context. The ioctl is DRM_RENDER_ALLOW, so any render node client can trigger this on pre-Fermi hardware.
Reject a zero-size request before allocating anything.
--- drivers/gpu/drm/nouveau/nouveau_abi16.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/nouveau/nouveau_abi16.c +4 -0
@@ -614,6 +614,10 @@ nouveau_abi16_ioctl_notifierobj_alloc(ABI16_IOCTL_ARGS)return nouveau_abi16_put (abi16, -EINVAL ); client = abi16->device.object.client; +/* zero size yields a zero-length node, underflowing args.limit */ +if (unlikely (!info->size)) +return nouveau_abi16_put (abi16, -EINVAL ); + chan =nouveau_abi16_chan (abi16, info->channel);if (!chan)return nouveau_abi16_put (abi16, -ENOENT );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 793/3318 drm/nouveau/svm: drain fault handler before freeing svmm
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhenhao Wan <[email protected]>
[ Upstream commit b46ddaf0823405f81e681eb26ec98508f3eb9a07 ]
The SVM fault handler nouveau_svm_fault() looks up each fault's nouveau_svmm under svm->mutex, caches it in the fault array, then drops svm->mutex and dereferences the svmm across blocking faults (mmu_interval_notifier_insert(), hmm_range_fault()).
nouveau_svmm is not refcounted. On DRM file close nouveau_svmm_fini() -> mmu_notifier_put() frees it asynchronously via call_srcu() without waiting for the handler, and mmget_not_zero() pins the mm, not the svmm. flush_work() on the fault buffer otherwise runs only at device removal and suspend, never on close, so a fault handled concurrently with a close can dereference a freed svmm.
The instance is already unlinked by nouveau_svmm_part() earlier in the same close, so no new fault can resolve to it. Drain the handler in nouveau_svmm_fini() before the free, guarding the flush with a NULL check on drm->svm: on device teardown nouveau_svm_fini() runs first and frees drm->svm (NULL) after blocking the notify and flushing the buffer, so the handler is already drained; on per-client close drm->svm is alive and the flush runs.
--- drivers/gpu/drm/nouveau/nouveau_svm.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/gpu/drm/nouveau/nouveau_svm.c +13 -0
@@ -307,6 +307,19 @@ nouveau_svmm_fini(struct nouveau_svmm **psvmm) {struct nouveau_svmm *svmm = *psvmm;if (svmm) { +struct nouveau_svm *svm = svmm->vmm->cli->drm->svm; + +/* The fault handler caches svmm pointers under svm->mutex and +* dereferences them after dropping it, across blocking faults. +* The instance is already unlinked (nouveau_svmm_part), so drain +* the handler before the free to release any in-flight reference. +* +* On device teardown nouveau_svm_fini() ran first and freed +* drm->svm (NULL) after draining the buffer; nothing to flush. +*/ +if (svm) +flush_work (&svm->buffer[0 ].work); +mutex_lock (&svmm->mutex); svmm->vmm =NULL ;mutex_unlock (&svmm->mutex);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 794/3318 drm/nouveau: cancel the DP IRQ work before freeing the connector
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Czernohous <[email protected]>
[ Upstream commit f60849975a886d70883bcb6b3658c0fa83c6971f ]
nouveau_connector_destroy() tears the two nvif events down and then frees the connector, but never cancels the work the IRQ event queues:
nvif_event_dtor(&nv_connector->irq); nvif_event_dtor(&nv_connector->hpd); kfree(nv_connector->edid); ... kfree(connector);
nouveau_connector_irq() queues that work unconditionally:
schedule_work(&nv_connector->irq_work); return NVIF_EVENT_KEEP;
A DP IRQ arriving just before nvif_event_dtor() therefore leaves nv_connector->irq_work on the system queue past the kfree(). When it runs, nouveau_dp_irq() derives both nv_connector and connector from the work_struct and dereferences them, and goes on to take outp->dp.hpd_irq_lock.
There is no cancel_work_sync() for irq_work anywhere in the driver, so nothing else covers this. Add it after the event teardown, where no further work can be queued, and before anything is freed.
Reported by the Sashiko review bot as a pre-existing issue, in its review of an earlier nv04 FIFO series of mine, and confirmed against the source.
--- drivers/gpu/drm/nouveau/nouveau_connector.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/nouveau/nouveau_connector.c +1 -0
@@ -397,6 +397,7 @@ nouveau_connector_destroy(struct drm_connector *connector)struct nouveau_connector *nv_connector =nouveau_connector (connector);nvif_event_dtor (&nv_connector->irq);nvif_event_dtor (&nv_connector->hpd); +cancel_work_sync (&nv_connector->irq_work);kfree (nv_connector->edid);drm_connector_unregister (connector);drm_connector_cleanup (connector);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 795/3318 drm/nouveau: dont dereference outp before checking it in nouveau_dp_irq
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Czernohous <[email protected]>
[ Upstream commit 843bc34db94bff0612c8294861b156489958897b ]
nouveau_dp_irq() looks the encoder up and dereferences it in the same breath, five lines before testing it:
struct nouveau_encoder *outp = find_encoder(connector, DCB_OUTPUT_DP); struct nouveau_drm *drm = nouveau_drm(outp->base.base.dev); ... if (!outp) return;
find_encoder() walks the connector's possible encoders and returns NULL when none of them matches the requested type, so the NULL test is not
decoration: it is the author saying this can happen. The initialiser above it dereferences the same pointer regardless.
The NULL test predates the dereference. commit 773eb04d14a1 ("drm/nouveau/disp: expose conn event class") turned nouveau_dp_irq() into a work callback, and since the drm pointer was no longer passed in as an argument it was recovered from the encoder in the declaration block, which put the dereference above the existing test.
Move the drm lookup below the test. No functional change when outp is non-NULL.
--- drivers/gpu/drm/nouveau/nouveau_dp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/nouveau/nouveau_dp.c +3 -1
@@ -232,7 +232,7 @@ nouveau_dp_irq(struct work_struct *work)container_of (work,typeof (*nv_connector), irq_work);struct drm_connector *connector = &nv_connector->base;struct nouveau_encoder *outp =find_encoder (connector,DCB_OUTPUT_DP ); -struct nouveau_drm *drm =nouveau_drm (outp->base.base.dev); +struct nouveau_drm *drm;struct nv50_mstm *mstm;u64 hpd =0 ;int ret;
@@ -240,6 +240,8 @@ nouveau_dp_irq(struct work_struct *work)if (!outp)return ; + drm =nouveau_drm (outp->base.base.dev); + mstm = outp->dp.mstm;NV_DEBUG (drm,"service %s\n" , connector->name);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 796/3318 drm/amdgpu: recompute the dw estimate after allocating a new VM update job
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: YuBiao Wang <[email protected]>
[ Upstream commit a74c7832b11827907de560169c7d4ac94505fd87 ]
amdgpu_vm_sdma_update() keeps the number of free dwords of the current job in a local variable. When the job runs out of room it is committed and a new one is allocated, but that local variable is not refreshed and still describes the job which was just submitted.
The stale value is then used to decide how many PTEs fit into the new job. If it happens to be copy_pte_num_dw + 7, or one more than that, the result is zero. copy_pte() encodes the transfer size as count * 8 - 1, so a count of zero asks the engine for a 1GB copy starting inside the IB pool. That runs off the end of the pool, faults on the first unmapped GART page above it and hangs the ring.
Re-initialize the estimate from the newly allocated job, which is empty and therefore has its full budget available.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm_sdma.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm_sdma.c +5 -0
@@ -265,6 +265,11 @@ static int amdgpu_vm_sdma_update(struct amdgpu_vm_update_params *p, r =amdgpu_vm_sdma_alloc_job (p, count);if (r)return r; + +/* The estimate above describes the job which was just +* submitted, take the budget of the newly allocated one. +*/ + ndw = p->num_dw_left; }if (!p->pages_addr) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 797/3318 drm/amd/display: Force GAMCOR for subsampled surfaces with PQ/Gamma22/HLG
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Harry Wentland <[email protected]>
[ Upstream commit 2ffaa7c4050605cb27756f5336f778d1b21268b9 ]
The ROM early-return checks for PQ, Gamma 2.2, and HLG in mod_color_calculate_degamma_params() do not consider the map_user_ramp parameter. When map_user_ramp is true (indicating a subsampled surface that requires post-scaler degamma via GAMCOR), the function still takes the ROM path, programming PRE_DEGAM instead.
For subsampled formats the chroma channels must be upsampled by the scaler before degamma is applied. PRE_DEGAM sits before the scaler in the pipeline (CNVC domain), while GAMCOR sits after it (CM domain). Using the ROM for subsampled surfaces means degamma is applied to subsampled chroma before upsampling, producing incorrect results.
Fix by gating the dcn_arch ROM capability checks on !map_user_ramp, forcing PQ/Gamma22/HLG through the GAMCOR LUT path when the surface is subsampled.
--- drivers/gpu/drm/amd/display/modules/color/color_gamma.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/modules/color/color_gamma.c +2 -1
@@ -1899,7 +1899,8 @@ bool mod_color_calculate_degamma_params(struct dc_color_caps *dc_caps,return true;if (dc_caps !=NULL && - dc_caps->dpp.dcn_arch ==1 ) { + dc_caps->dpp.dcn_arch ==1 && + !map_user_ramp) {if (input_tf->tf ==TRANSFER_FUNCTION_PQ && dc_caps->dpp.dgam_rom_caps.pq ==1 )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 798/3318 media: streamzap: Add missing rc_unregister_device()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Young <[email protected]>
[ Upstream commit 3982d2eeb1bdf7a9c14e4ff69015cb456f11da51 ]
If usb_submit_urb() fails during probe, then the error path is missing a call to rc_unregister_device(), which will leak various things like the input device.
--- drivers/media/rc/streamzap.c | 1 + 1 file changed, 1 insertion(+)
drivers/media/rc/streamzap.c +1 -0
@@ -365,6 +365,7 @@ static int streamzap_probe(struct usb_interface *intf,return 0 ; rc_submit_fail: +rc_unregister_device (sz->rdev);rc_free_device (sz->rdev);usb_set_intfdata (intf,NULL ); rc_dev_fail:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 799/3318 media: redrat3: Ensure we dont read beyond the end of the packet
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Young <[email protected]>
[ Upstream commit cd49f62f4161c7340d9c9f53b67757575900c0bc ]
The length and offset is provided by the usb device, so it should be validated.
--- drivers/media/rc/redrat3.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
drivers/media/rc/redrat3.c +16 -0
@@ -358,8 +358,24 @@ static void redrat3_process_ir_data(struct redrat3_dev *rr3)/* process each rr3 encoded byte into an int */ sig_size =be16_to_cpu (rr3->irdata.sig_size); + +/* +* Note we are not checking if we are reading beyond the end of the +* packet which was sent, and reading stale data. If the device +* sends a packet which is short then we get garbage IR, but no +* out of bounds read. +*/ +if (sig_size >RR3_MAX_SIG_SIZE ) { +dev_err (dev,"length %u is incorrect\n" , sig_size); +return ; + } +for (i =0 ; i < sig_size; i++) { offset = rr3->irdata.sigdata[i]; +if (offset >=RR3_DRIVER_MAXLENS ) { +dev_err (dev,"offset %u is incorrect\n" , offset); +return ; + } val =get_unaligned_be16 (&rr3->irdata.lens[offset]);/* we should always get pulse/space/pulse/space samples */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 800/3318 media: redrat3: Ensure all urbs are suspended
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Young <[email protected]>
[ Upstream commit 1582f545273f2aa4eb4ee6f3a89b433f5c85c68f ]
Ensure that the learn urb is stopped before suspend.
--- drivers/media/rc/redrat3.c | 1 + 1 file changed, 1 insertion(+)
drivers/media/rc/redrat3.c +1 -0
@@ -1170,6 +1170,7 @@ static int redrat3_dev_suspend(struct usb_interface *intf, pm_message_t message)usb_kill_urb (rr3->narrow_urb);usb_kill_urb (rr3->wide_urb);usb_kill_urb (rr3->flash_urb); +usb_kill_urb (rr3->learn_urb);return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 801/3318 media: sunxi-cir: Ensure no more interrupts can occur before free
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Young <[email protected]>
[ Upstream commit f9b33ec404200c03dd490ec133b8f9bf599c5444 ]
Only call rc_free_device() once the hardware has been stopped.
--- drivers/media/rc/sunxi-cir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/rc/sunxi-cir.c +1 -1
@@ -373,8 +373,8 @@ static void sunxi_ir_remove(struct platform_device *pdev)struct sunxi_ir *ir =platform_get_drvdata (pdev);rc_unregister_device (ir->rc); -rc_free_device (ir->rc);sunxi_ir_hw_exit (&pdev->dev); +rc_free_device (ir->rc); }static void sunxi_ir_shutdown (struct platform_device *pdev)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 802/3318 media: meson-ir-tx: Ensure clock is disabled on unbind
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Young <[email protected]>
[ Upstream commit 1517326fcc9dfdb9acb24f42472366ac1b4b8237 ]
clk_prepare_enable() needs a call to clk_disable_unprepare() on driver unbind. Make it devm managed.
--- drivers/media/rc/meson-ir-tx.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/media/rc/meson-ir-tx.c +4 -3
@@ -288,11 +288,12 @@ static int meson_irtx_mod_clock_probe(struct meson_irtx *ir,if (!np)return -ENODEV ; - clock =devm_clk_get (ir->dev,"xtal" ); -if (IS_ERR (clock) ||clk_prepare_enable (clock)) + *clk_nr =IRB_MOD_XTAL3_CLK ; + + clock =devm_clk_get_enabled (ir->dev,"xtal" ); +if (IS_ERR (clock))return -ENODEV ; - *clk_nr =IRB_MOD_XTAL3_CLK ; ir->clk_rate =clk_get_rate (clock) /3 ;if (ir->clk_rate <IRB_MOD_1US_CLK_RATE ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 803/3318 media: meson-ir-tx: Ensure probe error is propagated
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Young <[email protected]>
[ Upstream commit 2eb8a4cba70f521a8217021e227cfa28ba17724b ]
devm_clk_get_enabled() may return -EPROBE_DEFER which needs to be propagated else the probe will not be deferred, it will fail instead.
--- drivers/media/rc/meson-ir-tx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/rc/meson-ir-tx.c +2 -2
@@ -292,7 +292,7 @@ static int meson_irtx_mod_clock_probe(struct meson_irtx *ir, clock =devm_clk_get_enabled (ir->dev,"xtal" );if (IS_ERR (clock)) -return -ENODEV ; +return PTR_ERR (clock); ir->clk_rate =clk_get_rate (clock) /3 ;
@@ -325,7 +325,7 @@ static int __init meson_irtx_probe(struct platform_device *pdev) irq =platform_get_irq (pdev,0 );if (irq <0 ) -return -ENODEV ; +return irq; ir->dev = dev; ir->carrier =MIRTX_DEFAULT_CARRIER ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 804/3318 media: ir-hix5hd2: Ensure rdev is setup before interrupts are enabled
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Young <[email protected]>
[ Upstream commit f7509d2567cf92eeccc31c363a2e2ae43188930c ]
Once the interrupt handler is enabled, priv->rdev can be used. Ensure it is setup correctly so there is no race condition.
--- drivers/media/rc/ir-hix5hd2.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/media/rc/ir-hix5hd2.c +3 -2
@@ -316,6 +316,9 @@ static int hix5hd2_ir_probe(struct platform_device *pdev)if (ret <0 ) goto clkerr; + priv->rdev = rdev; + priv->dev = dev; +if (devm_request_irq (dev, priv->irq, hix5hd2_ir_rx_interrupt,0 , pdev->name, priv) <0 ) {dev_err (dev,"IRQ %d register failed\n" , priv->irq);
@@ -323,8 +326,6 @@ static int hix5hd2_ir_probe(struct platform_device *pdev) goto regerr; } - priv->rdev = rdev; - priv->dev = dev;platform_set_drvdata (pdev, priv);return ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 805/3318 media: imx-jpeg: finish the job on device_run() error paths
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fan Wu <[email protected]>
[ Upstream commit 30b35fd2b999e1b8c26f8191d974d20c8848d2d6 ]
mxc_jpeg_device_run() returns early through a shared "end" label on several error paths (no free slot, mxc_jpeg_alloc_slot_data() failure, or missing buffers or queue data), and none of them calls v4l2_m2m_job_finish(). Since the delayed work is queued only after the hardware is started, those paths neither finish the job directly nor queue timeout work that could finish it later. The job is left with TRANS_RUNNING set, so the wait_event() in v4l2_m2m_cancel_job() (reached from v4l2_m2m_ctx_release() at close) waits indefinitely and the close hangs.
mxc_jpeg_alloc_slot_data() uses dma_alloc_coherent(), so the failure path is reachable under memory pressure.
Return the src/dst buffers with VB2_BUF_STATE_ERROR and call v4l2_m2m_job_finish() on those paths: paths that have buffers use a "buf_finish" label; the no-buffer path uses "job_finish" directly. This mirrors the existing jpeg_parse_error path.
This bug was found by static analysis.
--- .../media/platform/nxp/imx-jpeg/mxc-jpeg.c | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)
drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c +15 -6
@@ -1448,15 +1448,15 @@ static void mxc_jpeg_device_run(void *priv) dst_buf =v4l2_m2m_next_dst_buf (ctx->fh.m2m_ctx);if (!src_buf || !dst_buf) {dev_err (dev,"Null src or dst buf\n" ); - goto end; + goto job_finish; } q_data_cap =mxc_jpeg_get_q_data (ctx,V4L2_BUF_TYPE_VIDEO_CAPTURE );if (!q_data_cap) - goto end; + goto buf_finish; q_data_out =mxc_jpeg_get_q_data (ctx,V4L2_BUF_TYPE_VIDEO_OUTPUT );if (!q_data_out) - goto end; + goto buf_finish; src_buf->sequence = q_data_out->sequence++; dst_buf->sequence = q_data_cap->sequence++;
@@ -1494,11 +1494,11 @@ static void mxc_jpeg_device_run(void *priv) ctx->slot =mxc_get_free_slot (&jpeg->slot_data);if (ctx->slot <0 ) {dev_err (dev,"No more free slots\n" ); - goto end; + goto buf_finish; }if (!mxc_jpeg_alloc_slot_data (jpeg)) {dev_err (dev,"Cannot allocate slot data\n" ); - goto end; + goto buf_finish; }mxc_jpeg_enable_slot (reg, ctx->slot);
@@ -1520,8 +1520,17 @@ static void mxc_jpeg_device_run(void *priv)mxc_jpeg_dec_mode_go (dev, reg); }schedule_delayed_work (&ctx->task_timer,msecs_to_jiffies (hw_timeout)); -end: +spin_unlock_irqrestore (&ctx->mxc_jpeg->hw_lock, flags); +return ; +buf_finish: +v4l2_m2m_src_buf_remove (ctx->fh.m2m_ctx); +v4l2_m2m_dst_buf_remove (ctx->fh.m2m_ctx); +v4l2_m2m_buf_done (src_buf,VB2_BUF_STATE_ERROR ); +v4l2_m2m_buf_done (dst_buf,VB2_BUF_STATE_ERROR ); +job_finish: +spin_unlock_irqrestore (&ctx->mxc_jpeg->hw_lock, flags); +v4l2_m2m_job_finish (jpeg->m2m_dev, ctx->fh.m2m_ctx); } static int mxc_jpeg_decoder_cmd(struct file *file, void *priv,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 806/3318 microblaze: Fix MB_MANAGER build with older binutils
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 79c8aa4da3d5453dd956d2170d1c9c716311ea06 ]
Commit 88707ebe77e2 ("microblaze: Add custom break vector handler for mb manager") added the suspend mnemonic to the MB Manager break handler.
GNU as only learned this mnemonic in binutils 2.42. Linux supports binutils 2.30, where enabling CONFIG_MB_MANAGER fails:
arch/microblaze/kernel/entry.S:946: Error: unknown opcode "suspend"
The suspend mnemonic is an alias for mbar 24, and both encode as 0xbb020004. Use the underlying instruction, which GNU as 2.30 already supports.
--- arch/microblaze/kernel/entry.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/microblaze/kernel/entry.S +1 -1
@@ -943,7 +943,7 @@ ret_from_break: mbar 1 mbar 2 bri 4 - suspend + mbar 24 /* suspend */ nop #endif
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 807/3318 aio: prevent eventfd/epoll recursion on poll
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daehyeon Ko <[email protected]>
[ Upstream commit 398e3fa789aa5ffddc8689d8cbc7b31e1824130c ]
aio_poll_wake() can complete a keyed poll request inline while the provider waitqueue lock is held. If the polled file is an epoll instance and the AIO result eventfd is watched by that same instance, signaling the result can feed back into epoll and try to take the provider waitqueue lock again.
For example, a timerfd wake can follow this path:
timerfd -> ep_poll_callback -> aio_poll_wake -> aio_complete
-> eventfd_signal -> ep_poll_callback -> ep_poll_safewake
The second ep_poll_safewake() recursively acquires ep->poll_wait.lock. eventfd_signal_allowed() does not prevent this because the wake chain did not begin in eventfd, so the task's eventfd recursion bit is still clear when aio_poll_wake() decides to complete inline.
An unprivileged process can construct this graph and make a CPU spin on the recursive lock. DEBUG_SPINLOCK reports "BUG: spinlock recursion", and lockdep reports the same epoll waitqueue lock as both held and requested.
Always defer eventfd-backed poll completions through the existing aio_poll_put_work() path. At this point the request has already been detached from the waitqueue and active request list, so the work item can publish the completion after the provider callback releases its lock. Poll completions without a result eventfd remain inline.
--- fs/aio.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
fs/aio.c +6 -1
@@ -1775,7 +1775,12 @@ static int aio_poll_wake(struct wait_queue_entry *wait, unsigned mode, int sync,list_del_init (&req->wait.entry);list_del (&iocb->ki_list); iocb->ki_res.res =mangle_poll (mask); -if (iocb->ki_eventfd && !eventfd_signal_allowed ()) { +/* +* We hold an arbitrary provider waitqueue lock here. Signaling a +* result eventfd can feed back through epoll and try to take the same +* lock again. Defer all eventfd-backed poll completions. +*/ +if (iocb->ki_eventfd) { iocb =NULL ;INIT_WORK (&req->work, aio_poll_put_work);schedule_work (&req->work);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 808/3318 ipc/mqueue: release notification resources during inode eviction
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daehyeon Ko <[email protected]>
[ Upstream commit eb85469f0dd69ca145d63117450e14c31f67f698 ]
mqueue_flush_file() removes an mq_notify() registration only when the closing task belongs to the thread group stored in notify_owner.
A task in a separate thread group created with CLONE_FILES can register SIGEV_THREAD notification and exit without closing the shared file table. If another thread group then unlinks and last-closes the queue, ->flush() skips the registration and inode eviction loses the only pointers to its resources.
The orphaned registration permanently retains the notification skb, its netlink socket, a pid reference and a user namespace reference. An unprivileged process can repeat the sequence with new queues and sockets.
No inode users remain during eviction. Remove any stale registration there after dropping info->lock, since netlink_sendskb() may release the final socket reference.
--- ipc/mqueue.c | 7 +++++++ 1 file changed, 7 insertions(+)
ipc/mqueue.c +7 -0
@@ -528,6 +528,13 @@ static void mqueue_evict_inode(struct inode *inode)list_add_tail (&msg->m_list, &tmp_msg);kfree (info->node_cache);spin_unlock (&info->lock); +/* +* A shared file table can let the notification owner exit without +* running ->flush(). No users of the inode remain during eviction, so +* tear down any stale notification after dropping info->lock because +* netlink_sendskb() may release the final socket reference. +*/ +remove_notification (info);list_for_each_entry_safe (msg, nmsg, &tmp_msg, m_list) {list_del (&msg->m_list);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 809/3318 remoteproc: elf_loader: Bound the section header table
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit b32177ead5f8925aa66ceed2bd533a85196f4f0c ]
The rproc_elf_sanity_check() only checks the image is big enough to hold one section header. But find_table() walks e_shnum of them, and first dereferences the header at e_shstrndx to locate the section name table. Both fields are u16 and both come from the image, so an e_shstrndx of 65535 reads about 4 MB past the buffer.
The commit 9f9967fed9d0 ("soc: qcom: mdt_loader: Ensure we don't read past the ELF header") added the same check to the MDT loader, and says the header "is sanitized beforehand" under remoteproc. That is what this patch makes true.
Check e_shoff against the image size first, so the two bounds can use size_add() without an e_shoff above SIZE_MAX wrapping on 32-bit. The bounds are separate because e_shnum may be zero while find_table() still reads the e_shstrndx header.
--- drivers/remoteproc/remoteproc_elf_loader.c | 23 ++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-)
drivers/remoteproc/remoteproc_elf_loader.c +21 -2
@@ -46,8 +46,9 @@ int rproc_elf_sanity_check(struct rproc *rproc, const struct firmware *fw)struct elf32_hdr *ehdr;u32 elf_shdr_get_size;u64 phoff, shoff; +size_t shend;char class; -u16 phnum; +u16 phnum, shnum, shstrndx;if (!fw) {dev_err (dev,"failed to load %s\n" , name);
@@ -90,9 +91,27 @@ int rproc_elf_sanity_check(struct rproc *rproc, const struct firmware *fw) phoff =elf_hdr_get_e_phoff (class, fw->data); shoff =elf_hdr_get_e_shoff (class, fw->data); phnum =elf_hdr_get_e_phnum (class, fw->data); + shnum =elf_hdr_get_e_shnum (class, fw->data); + shstrndx =elf_hdr_get_e_shstrndx (class, fw->data); elf_shdr_get_size =elf_size_of_shdr (class); -if (fw->size < shoff + elf_shdr_get_size) { +/* keeps shoff in size_t range for the two bounds below */ +if (shoff > fw->size) { +dev_err (dev,"Section header table is out of bounds\n" ); +return -EINVAL ; + } + +if (shnum) { + shend =size_add (size_mul (elf_shdr_get_size, shnum), shoff); +if (shend > fw->size) { +dev_err (dev,"Section headers are out of bounds\n" ); +return -EINVAL ; + } + } + +/* find_table() reads the header at shstrndx even with no sections */ + shend =size_add (size_mul (elf_shdr_get_size, (size_t )shstrndx +1 ), shoff); +if (shend > fw->size) {dev_err (dev,"Image is too small\n" );return -EINVAL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 810/3318 microblaze: reserve the ABI argument-home area in the signal frame
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ramin Moussavi <[email protected]>
[ Upstream commit c5947d28c20955de897eeb98430f96db0494f7d7 ]
The MicroBlaze procedure call standard reserves [r1+0] for the return address and lets a callee store its incoming register arguments r5..r10 into the caller-provided home slots at [r1+4]..[r1+24]. When the kernel enters a signal handler it sets r1 to point at struct rt_sigframe, whose leading member is the siginfo prepared for the handler. A handler that homes its arguments - which an unoptimised (-O0) build always does - therefore overwrites the first 24 bytes of that siginfo, so an SA_SIGINFO handler reads corrupted values. The stores stay within siginfo (128 bytes) and do not reach the ucontext behind it.
Reserve the home area by making a seven-word gap -- the return-address slot plus the six argument slots, 28 bytes -- the first member of struct rt_sigframe, so the handler's argument stores land in scratch space instead of clobbering siginfo.
Tested on qemu-system-microblazeel (petalogix-s3adsp1800) with the uClibc-ng NPTL test suite: tst-timer4, tst-timer5, tst-mqueue5 and tst-signal6 pass; before this change they failed because the handler clobbered the signal frame.
--- arch/microblaze/kernel/signal.c | 8 ++++++++ 1 file changed, 8 insertions(+)
arch/microblaze/kernel/signal.c +8 -0
@@ -49,6 +49,14 @@ struct sigframe { };struct rt_sigframe { +/* +* Home area for the handler's register arguments: the MicroBlaze +* ABI reserves [r1+0] for the return address and lets the callee +* store r5..r10 at [r1+4]..[r1+24], and r1 points at this frame +* when the handler is entered. Without the gap those stores +* corrupt frame->info. +*/ +unsigned long abi_gap[7 ];struct siginfo info;struct ucontext uc;unsigned long tramp[2 ];/* signal trampoline */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 811/3318 microblaze: dont clobber r3/r4 restored by rt_sigreturn
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ramin Moussavi <[email protected]>
[ Upstream commit da6829138a39fa3b9ec318ca54ff89af9d94d350 ]
ret_from_trap begins by storing the system call return values r3 and r4 back into the saved user pt_regs. That is right for an ordinary system call, but sys_rt_sigreturn() returns through the same path and has to be
transparent: restore_sigcontext() has just filled pt_regs from the signal frame, and every register must reach userspace exactly as saved. The two stores overwrite the restored r3/r4 with whatever the C function left in those registers.
Only r4 is actually lost, and that follows from how sigreturn is written everywhere rather than from chance. Architectures have sys_rt_sigreturn() return the restored return-value register precisely so that this writeback stores the restored value -- arm returns regs->ARM_r0, riscv and csky regs->a0, arc regs->r0 -- and microblaze does the same through *rval_p = regs->r3 in restore_sigcontext(). But the entry macros treat r3 and r4 as a pair, so ret_from_trap writes back two registers while a C function has only one return value; nothing carries the restored r4.
Commit 791d0a169b91 ("microblaze: Fix sys_rt_sigreturn_wrapper") introduced this in v2.6.37. The old wrapper saved r3/r4 before the call and reloaded them from pt_regs afterwards; switching brlid to brid removed the only point where they were reloaded, and the stores have been overwriting them ever since.
Fix it the way the sibling paths already behave: ret_from_irq and ret_from_exc restore the full register set and do not perform these stores at all. Label the instruction after the stores ret_from_trap_no_rval and enter there, biasing r15 by -8 so that the ABI return "rtsd r15, 8" lands on it; naming the entry rather than computing ret_from_trap + 8 keeps it correct if the number of stores ever changes. Restoring the old save/reload would work too, but costs four memory accesses and a branch to undo damage that is better not done.
Any value the compiler keeps in r4 across a signal is lost. The tightest windows are the lwx/swx compare-and-swap retry loops gcc emits for atomics:
in uClibc-ng's libc.so alone, 50 of 364 such loops hold the address in r4. This is not specific to one libc -- musl passes the address as "r"(p), and glibc has no microblaze atomic-machine.h and so uses gcc's __atomic builtins, which expand the same way. Triggering it needs threads plus a signal storm, which is why it survived 15 years.
Reproduced on qemu-system-microblazeel (petalogix-s3adsp1800) by running the uClibc-ng NPTL test tst-eintr1 40 times against an unchanged userspace:
on v7.2 built with gcc 16.2.0, 23 of 40 iterations died with SIGSEGV without this patch and 0 of 40 with it; on v7.0 built with gcc 12.5.0 the same comparison gave 6 of 40 against 0 of 40. The register dump of a failing iteration shows the signature: a zero r4 and a fault at address 0, while r3 came back intact.
--- arch/microblaze/kernel/entry.S | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
arch/microblaze/kernel/entry.S +16 -1
@@ -434,7 +434,13 @@ C_ENTRY(_user_exception): C_ENTRY(ret_from_trap): swi r3, r1, PT_R3 swi r4, r1, PT_R4 - +/* + * Entry point for returns that must not store r3/r4 back into pt_regs, + * i.e. rt_sigreturn, which has already restored them from the signal + * context. Reached as "rtsd r15, 8" with r15 set to this label minus 8, + * so it stays correct if the number of stores above ever changes. + */ +ret_from_trap_no_rval: lwi r11, r1, PT_MODE; /* See if returning to kernel mode, if so, skip resched &c. */ bnei r11, 2f;
@@ -518,6 +524,15 @@ C_ENTRY(ret_from_kernel_thread): C_ENTRY(sys_rt_sigreturn_wrapper): addik r30, r0, 0 /* no restarts */ + /* + * rt_sigreturn restores the full register set from the signal + * context, so it must skip the r3/r4 syscall-return stores at the + * head of ret_from_trap which would otherwise overwrite the + * just-restored r3/r4. Every C function returns with "rtsd r15, 8" + * -- the ABI return, where the 8 skips the caller's branch and its + * delay slot -- so bias r15 by -8 to land on ret_from_trap_no_rval. + */ + addik r15, r0, ret_from_trap_no_rval - 8 brid sys_rt_sigreturn /* Do real work */ addik r5, r1, 0; /* add user context as 1st arg */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 812/3318 microblaze: preserve the MSR carry flags across signals
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sam Price <[email protected]>
[ Upstream commit ca35dd21a5f8343f47a23e4e5b3f0ffccf76a4ae ]
setup_sigcontext() and restore_sigcontext() copy r0-r31, pc, ear, esr and fsr to and from the signal frame but never touch MSR. The interrupted MSR is therefore dropped from the signal context entirely: the handler's ucontext does not expose it, a handler cannot adjust the resumed arithmetic flags through uc_mcontext.regs.msr, and -- because restore_sigcontext() leaves regs->msr as whatever the rt_sigreturn trap left in it -- the interrupted context resumes with the carry produced by the syscall entry path (_user_exception does "addi r14, r14, 4", which writes carry), not with its own.
Other architectures round-trip the user-visible flags through the signal frame (arm's cpsr, csky's carry, x86's eflags), so a handler can both read and adjust the resumed flags; purely privileged status registers such as riscv's sstatus are left out. MicroBlaze should do the same for the user-writable bits.
Concretely, MSR[C] (carry) is lost across signal delivery. Code that keeps a live carry across a point where a signal can be delivered -- for example an lwx/swx compare-and-swap retry loop, between the swx and the carry test -- resumes with the handler's carry and mis-evaluates the result; the same failure class as the rt_sigreturn r3/r4 clobber, reached through a different register. Demonstrated under qemu-system-microblazeel (machine petalogix-s3adsp1800): a handler that sets MSR_C in uc_mcontext.regs.msr has no effect before this change (0 of 132 in-window signals propagated) and takes effect after (130 of 132).
Save MSR in setup_sigcontext() so the handler's ucontext exposes it. The signal frame is user-writable, so restore_sigcontext() must not restore it
verbatim: MicroBlaze packs the user-writable carry (MSR_C, MSR_CC) and the privileged control bits (MSR_UM, MSR_VM, MSR_IE, MSR_EE, ...) into the one register, and a verbatim restore would let userspace alter privileged return state -- rtbd derives the resumed mode from MSR_UMS/MSR_VMS. Restore only MSR_C | MSR_CC from the frame and keep the rest from the current regs->msr. This mirrors x86'srestore_sigcontext(), which masks the restored EFLAGS to FIX_EFLAGS for the same reason; arches whose status register is purely privileged (e.g. riscv sstatus) simply do not restore it at all.
Comment on the exposed MSR reworded: it is not read-only, restore_sigcontext() applies MSR_C|MSR_CC from the frame. Author's Signed-off-by kept; he agreed to comment and changelog cleanups.
--- arch/microblaze/kernel/signal.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
arch/microblaze/kernel/signal.c +18 -0
@@ -33,6 +33,7 @@#include <linux/linkage.h> #include <linux/resume_user_mode.h> #include <asm/entry.h> +#include <asm/registers.h> #include <asm/ucontext.h> #include <linux/uaccess.h> #include <linux/syscalls.h>
@@ -81,6 +82,22 @@ static int restore_sigcontext(struct pt_regs *regs,COPY (pc);COPY (ear);COPY (esr);COPY (fsr);#undef COPY +/* +* The frame is user-writable, so restore only the user-writable +* status flags (carry) and keep the kernel-controlled MSR bits +* (UMS/VMS/IE/EE/...) from regs->msr: rtbd derives the resumed mode +* from UMS/VMS, so a verbatim restore would hand userspace the +* privileged return state. Same idea as x86 masking the restored +* EFLAGS to FIX_EFLAGS. +*/ + { +unsigned long msr; + + err |=__get_user (msr, &sc->regs.msr); + regs->msr = (regs->msr & ~(MSR_C |MSR_CC )) | + (msr & (MSR_C |MSR_CC )); + } + *rval_p = regs->r3;return err;
@@ -140,6 +157,7 @@ setup_sigcontext(struct sigcontext __user *sc, struct pt_regs *regs,COPY (r26);COPY (r27);COPY (r28);COPY (r29);COPY (r30);COPY (r31);COPY (pc);COPY (ear);COPY (esr);COPY (fsr); +COPY (msr);/* restore_sigcontext() accepts only carry state */ #undef COPY err |=__put_user (mask, &sc->oldmask);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 813/3318 memory: brcmstb_dpfe: Fix out-of-bounds access due to DCPU offset
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Justin Chen <[email protected]>
[ Upstream commit 7c0b82d087908765c6c7daeb06943e21b78d523e ]
On API v1/v2 boards, the DCPU coprocessor can steer kernel readl_relaxed() and writel_relaxed() to any address within 256 MB of the ioremapped DPFE dmem or regs base. The DCPU firmware provides a 28-bit offset which the driver adds to the ioremap base without any bounds checking in get_msg_ptr().
This allows a compromised DCPU firmware to trick the host kernel into reading or writing arbitrary memory-mapped I/O registers in vmalloc space. When combined with a root-writable sysfs file like dpfe_refresh, it provides an arbitrary MMIO write primitive. Similarly, world-readable sysfs files can be used to leak other devices' register contents.
Fix this by recording the resource_size() of the dmem and regs ioremaps at probe time, and rejecting any offset that, along with the largest field accessed (DRAM_VENDOR_ERROR + sizeof(u32)), exceeds the recorded mapping size.
--- drivers/memory/brcmstb_dpfe.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-)
drivers/memory/brcmstb_dpfe.c +20 -2
@@ -182,6 +182,8 @@ struct brcmstb_dpfe_priv {void __iomem *regs;void __iomem *dmem;void __iomem *imem; +resource_size_t regs_size; +resource_size_t dmem_size;struct device *dev;const struct dpfe_api *dpfe_api;struct mutex lock;
@@ -401,9 +403,14 @@ static void __iomem *get_msg_ptr(struct brcmstb_dpfe_priv *priv, u32 response,*/ switch (msg_type) {case 1 : +if (DCPU_MSG_RAM_START + offset +DRAM_VENDOR_ERROR + +sizeof (u32) > priv->regs_size) + goto bad_offset; ptr = priv->regs +DCPU_MSG_RAM_START + offset;break ;case 0 : +if (offset +DRAM_VENDOR_ERROR +sizeof (u32) > priv->dmem_size) + goto bad_offset; ptr = priv->dmem + offset;break ;default :
@@ -415,6 +422,12 @@ static void __iomem *get_msg_ptr(struct brcmstb_dpfe_priv *priv, u32 response, }return ptr; + +bad_offset: +dev_err (priv->dev,"DCPU returned out-of-range offset %#x\n" , offset); +if (buf && size) + *size =sprintf (buf,"ERROR: DCPU offset out of range\n" ); +return NULL ; }static void __finalize_command (struct brcmstb_dpfe_priv *priv)
@@ -858,6 +871,7 @@ static int brcmstb_dpfe_probe(struct platform_device *pdev) {struct device *dev = &pdev->dev;struct brcmstb_dpfe_priv *priv; +struct resource *res;int ret; priv =devm_kzalloc (dev,sizeof (*priv),GFP_KERNEL );
@@ -869,17 +883,21 @@ static int brcmstb_dpfe_probe(struct platform_device *pdev)mutex_init (&priv->lock);platform_set_drvdata (pdev, priv); - priv->regs =devm_platform_ioremap_resource_byname (pdev,"dpfe-cpu" ); + res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"dpfe-cpu" ); + priv->regs =devm_ioremap_resource (dev, res);if (IS_ERR (priv->regs)) {dev_err (dev,"couldn't map DCPU registers\n" );return -ENODEV ; } + priv->regs_size =resource_size (res); - priv->dmem =devm_platform_ioremap_resource_byname (pdev,"dpfe-dmem" ); + res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"dpfe-dmem" ); + priv->dmem =devm_ioremap_resource (dev, res);if (IS_ERR (priv->dmem)) {dev_err (dev,"Couldn't map DCPU data memory\n" );return -ENOENT ; } + priv->dmem_size =resource_size (res); priv->imem =devm_platform_ioremap_resource_byname (pdev,"dpfe-imem" );if (IS_ERR (priv->imem)) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 814/3318 memory: brcmstb_dpfe: Bounds check DCPU-supplied MSG_ARG_COUNT
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Justin Chen <[email protected]>
[ Upstream commit 6b07f8c06caca015a0db69e3f323b5186469bc66 ]
A compromised or buggy DCPU coprocessor can make any user who reads world-readable /sys/devices/.../dpfe_info|dpfe_dram trigger a kernel stack out-of-bounds read of arbitrary extent. This bounds checks chksum_idx against MSG_FIELD_MAX after reading the response from DCPU message RAM.
--- drivers/memory/brcmstb_dpfe.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/memory/brcmstb_dpfe.c +2 -0
@@ -503,6 +503,8 @@ static int __send_command(struct brcmstb_dpfe_priv *priv, unsigned int cmd,for (i =0 ; i <MSG_FIELD_MAX ; i++) result[i] =readl_relaxed (regs +DCPU_MSG_RAM (i)); chksum_idx = result[MSG_ARG_COUNT ] +MSG_ARG_COUNT +1 ; +if (chksum_idx >=MSG_FIELD_MAX ) + ret = -EINVAL ; }/* Tell DCPU we are done */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 815/3318 wifi: rtw88: fix out-of-bounds CAM write when key table is full
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: イムティヤズ <[email protected]>
[ Upstream commit 10d58823cb44681466c022054030b8e68d94ce2f ]
In rtw_ops_set_key(), when the CAM table is full, rtw_sec_get_free_cam() returns RTW_MAX_SEC_CAM_NUM (32) because find_next_zero_bit()/find_first_zero_bit() return the bitmap size when no free slot exists. The bounds check compares the returned index with ">" against total_cam_num (32), so the invalid index 32 passes the check.
rtw_sec_write_cam() then indexes cam_table[32], an array declared with RTW_MAX_SEC_CAM_NUM (32) entries, causing an out-of-bounds write that corrupts the cam_map allocation bitmap. The write also sets bit 32 of cam_map, which overruns the bitmap as well.
Fix the off-by-one by rejecting indices >= total_cam_num.
Tested on: RTL8821CE (PCIe) on kernel 7.2.0-rc6-rtw88test-00059-g0d8395707651. The patched module loaded and associated to a WPA2 network; ping traffic passed with 0% packet loss. Reassociation and disconnect/reconnect cycles completed without errors, and the CAM table (debugfs dump_cam) showed valid key entries. The CAM-full boundary (28+ pairwise keys) requires an access point with 28+ clients and is not reachable in a single-client setup, so that path was verified by code inspection.
--- drivers/net/wireless/realtek/rtw88/mac80211.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/realtek/rtw88/mac80211.c +1 -1
@@ -584,7 +584,7 @@ static int rtw_ops_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, hw_key_idx = key->keyidx; } -if (hw_key_idx > sec->total_cam_num) { +if (hw_key_idx >= sec->total_cam_num) { ret = -ENOSPC ; goto out; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 816/3318 wifi: rtw89: 8851b: fix swapped DPK channel/bandwidth backup fields
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yi Cong <[email protected]>
[ Upstream commit 7e080e17ca38b72f6cf01e3bc750c243573e69a7 ]
The .ch and .bw backup fields are swapped; .ch should store the channel and .bw the bandwidth, matching all other chips.
--- drivers/net/wireless/realtek/rtw89/rtw8851b_rfk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/realtek/rtw89/rtw8851b_rfk.c +2 -2
@@ -1754,8 +1754,8 @@ static void _dpk_information(struct rtw89_dev *rtwdev, enum rtw89_phy_idx phy,u8 kidx = dpk->cur_idx[path]; dpk->bp[path][kidx].band = chan->band_type; - dpk->bp[path][kidx].ch = chan->band_width; - dpk->bp[path][kidx].bw = chan->channel; + dpk->bp[path][kidx].ch = chan->channel; + dpk->bp[path][kidx].bw = chan->band_width; rtw89_debug(rtwdev, RTW89_DBG_RFK, "[DPK] S%d[%d] (PHY%d): TSSI %s/ DBCC %s/ %s/ CH%d/ %s\n",
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 817/3318 clk: mstar: msc313-mpll: fix off-by-one in clock array allocation
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: hanzhijian <[email protected]>
[ Upstream commit 712b75152c00a8ab0c56dbfe34caf88e3870ddde ]
The hws array of mpll->clk_data is allocated with struct_size() using ARRAY_SIZE(output_dividers) as the element count, giving it 7 elements. But the probe function stores the MPLL clock at hws[0] and one fixed-factor clock for each output divider at hws[i + 1] for i in [0, ARRAY_SIZE(output_dividers)), writing 8 elements in total. The final write to hws[7] is past the end of the allocation.
clk_data->num is also set to NUMOUTPUTS (8), so the clock framework reads hws[0..7], again accessing hws[7] out of bounds.
Use NUMOUTPUTS as the element count so the allocation matches the number of clocks actually stored and exposed.
Found by smatch:
drivers/clk/mstar/clk-msc313-mpll.c:134 msc313_mpll_probe()
error: buffer overflow 'mpll->clk_data->hws' 7 <= 7
--- drivers/clk/mstar/clk-msc313-mpll.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/mstar/clk-msc313-mpll.c +1 -1
@@ -105,7 +105,7 @@ static int msc313_mpll_probe(struct platform_device *pdev)return PTR_ERR (mpll->loop_div_second); mpll->clk_data =devm_kzalloc (dev,struct_size (mpll->clk_data, hws, -ARRAY_SIZE (output_dividers)),GFP_KERNEL ); +NUMOUTPUTS ),GFP_KERNEL );if (!mpll->clk_data)return -ENOMEM ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 818/3318 bpf: Fix queue/stack map u32 index overflow
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuan Chen <[email protected]>
[ Upstream commit 802a30c5db726639df7f93b3a1982ecc64202abe ]
The queue/stack map addresses elements[] with the product of a u32 head/tail index and value_size, but the storage itself is allocated in 64-bit arithmetic. When max_entries * value_size reaches or exceeds U32_MAX, the product wraps and push/peek/pop operate on the wrong element, corrupting map data and leaking stale values to user space. max_entries == U32_MAX would also make the u32 capacity counter qs->size (max_entries + 1) wrap to 0 and permanently break the map.
The original bound check was removed by commit a37fb7ef24a4 ("bpf:
Eliminate rlimit-based memory accounting for queue_stack_maps maps"), which deleted the bpf_map_charge_init() call and with it the U32_MAX - PAGE_SIZE check that had earlier been moved into bpf_map_charge_init() by c85d69135a91. Oversized queue/stack maps can therefore be created again.
Restore the bound in queue_stack_map_alloc_check() with a single comparison that rejects any max_entries/value_size combination whose element storage would reach or exceed U32_MAX bytes, keeping the u32 index multiplication overflow-free and the capacity counter valid.
--- kernel/bpf/queue_stack_maps.c | 3 +++ 1 file changed, 3 insertions(+)
kernel/bpf/queue_stack_maps.c +3 -0
@@ -58,6 +58,9 @@ static int queue_stack_map_alloc_check(union bpf_attr *attr)*/ return -E2BIG ; +if (attr->max_entries >=U32_MAX / attr->value_size) +return -E2BIG ; +return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 819/3318 hte: tegra194: Initialize slice locks before registering chip
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Runyu Xiao <[email protected]>
[ Upstream commit 1329abe1bae416ab2cff89c3312d33f745d341c7 ]
Registering the HTE chip publishes its request callbacks to consumers. Initialize every slice lock before registration so a concurrent HTE request cannot use an uninitialized lock.
--- drivers/hte/hte-tegra194.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/hte/hte-tegra194.c +5 -5
@@ -784,17 +784,17 @@ static int tegra_hte_probe(struct platform_device *pdev) hte_dev->chip = gc; +for (i =0 ; i < slices; i++) { + hte_dev->sl[i].flags =0 ; +spin_lock_init (&hte_dev->sl[i].s_lock); + } + ret =devm_hte_register_chip (hte_dev->chip);if (ret) {dev_err (gc->dev,"hte chip register failed" );return ret; } -for (i =0 ; i < slices; i++) { - hte_dev->sl[i].flags =0 ; -spin_lock_init (&hte_dev->sl[i].s_lock); - } - val =HTE_TECTRL_ENABLE_ENABLE | (HTE_TECTRL_INTR_ENABLE <<HTE_TECTRL_INTR_SHIFT ) | (hte_dev->itr_thrshld <<HTE_TECTRL_OCCU_SHIFT );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 820/3318 wifi: ath11k: Fix possible memory leak in ath11k_dp_srng_setup()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abdun Nihaal <[email protected]>
[ Upstream commit 6132d70d0890c03546f6970893fd71938efb2a2f ]
In ath11k_dp_srng_setup(), the memory allocated for ring->vaddr_unaligned is not freed in the error paths that follow. Fix that by calling ath11k_dp_srng_cleanup() in those error paths.
Compile tested only. Issue found using a prototype static analysis tool built on the LLVM compiler infrastructure.
--- drivers/net/wireless/ath/ath11k/dp.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/wireless/ath/ath11k/dp.c +2 -0
@@ -313,6 +313,7 @@ int ath11k_dp_srng_setup(struct ath11k_base *ab, struct dp_srng *ring,case HAL_RXDMA_DIR_BUF :break ;default : +ath11k_dp_srng_cleanup (ab, ring);ath11k_warn (ab,"Not a valid ring type in dp :%d\n" , type);return -EINVAL ; }
@@ -324,6 +325,7 @@ int ath11k_dp_srng_setup(struct ath11k_base *ab, struct dp_srng *ring, ret =ath11k_hal_srng_setup (ab, type, ring_num, mac_id, ¶ms);if (ret <0 ) { +ath11k_dp_srng_cleanup (ab, ring);ath11k_warn (ab,"failed to setup srng: %d ring_id %d\n" , ret, ring_num);return ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 821/3318 media: i2c: ov8856: fix debug message to report actual CSI-2 lane count
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Serin Yeh <[email protected]>
[ Upstream commit a15976e69b1c70ea16ef1f7172a846f6ef5dfa14 ]
The driver currently prints the number of data lanes using ov8856->cur_mode->data_lanes in ov8856_get_hwcfg(). However, the ov8856->cur_mode structure is not assigned to a clearly supported mode at that point. Due to the missing pointer, enabling dynamic debug may lead to a kernel panic.
Instead, the correct number of CSI-2 data lanes should be taken from bus_cfg.bus.mipi_csi2.num_data_lanes, which represents the real hardware configuration determined at runtime.
--- drivers/media/i2c/ov8856.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/media/i2c/ov8856.c +2 -1
@@ -2374,7 +2374,8 @@ static int ov8856_get_hwcfg(struct ov8856 *ov8856, struct device *dev) goto check_hwcfg_error; } -dev_dbg (dev,"Using %u data lanes\n" , ov8856->cur_mode->data_lanes); +dev_dbg (dev,"Using %u data lanes\n" , + bus_cfg.bus.mipi_csi2.num_data_lanes);if (bus_cfg.bus.mipi_csi2.num_data_lanes ==2 ) ov8856->priv_lane = &lane_cfg_2;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 822/3318 mtd: spi-nor: sfdp: check the length of the xSPI Profile 1.0 table
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit b9f34a95a81021fa1f3c9cb8cfd458e66824cad6 ]
The spi_nor_parse_profile1() sizes its buffer from the table length the flash reports in the SFDP parameter header. But it then reads DWORD1, DWORD4 and DWORD5 without ever checking the table is that long.
So if a flash reports a length of one, the buffer is only four bytes while DWORD4 and DWORD5 sit at byte offsets 12 and 16. With a length of zero kmalloc() returns ZERO_SIZE_PTR rather than an error, so the NULL check doesn't catch it and the first read dereferences it. And the value doesn't just get thrown away. It ends up as the dummy cycle count for 8D-8D-8D fast reads.
To fix this, reject a table that's too short for the highest DWORD the parser reads, the way spi_nor_parse_4bait() already does. The table is optional, so this isn't fatal. The spi_nor_parse_sfdp() warns and carries on.
--- drivers/mtd/spi-nor/sfdp.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/mtd/spi-nor/sfdp.c +4 -0
@@ -1157,6 +1157,7 @@ static int spi_nor_parse_4bait(struct spi_nor *nor,#define PROFILE1_DWORD5_DUMMY_166MHZ GENMASK(31, 27)#define PROFILE1_DWORD5_DUMMY_133MHZ GENMASK(21, 17)#define PROFILE1_DWORD5_DUMMY_100MHZ GENMASK(11, 7) +#define SFDP_PROFILE1_DWORD_MIN 5/** * spi_nor_parse_profile1() - parse the xSPI Profile 1.0 table
@@ -1174,6 +1175,9 @@ static int spi_nor_parse_profile1(struct spi_nor *nor,int ret;u8 dummy, opcode; +if (profile1_header->length <SFDP_PROFILE1_DWORD_MIN ) +return -EINVAL ; + len = profile1_header->length *sizeof (*dwords); dwords =kmalloc (len,GFP_KERNEL );if (!dwords)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 823/3318 mtd: spi-nor: sfdp: check the length of the SCCR map
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit 1413f38f37194673502e61cd3749e091c031370b ]
The spi_nor_parse_sccr() sizes its buffer from the table length the flash reports in the SFDP parameter header. But it then reads DWORD1 and DWORD22 without ever checking the table is that long.
So if a flash reports a length of one, the buffer is only four bytes while DWORD22 sits at byte offset 84. With a length of zero kmalloc() returns ZERO_SIZE_PTR rather than an error, so the NULL check doesn't catch it and the first read dereferences it.
To fix this, reject a table that's too short for the highest DWORD the parser reads, the way spi_nor_parse_4bait() already does. The table is optional, so this isn't fatal. The spi_nor_parse_sfdp() warns and carries on.
The spi_nor_parse_sccr_mc() doesn't need the same check. It works out the number of dice from the length it allocated with, so its highest index stays inside the buffer.
--- drivers/mtd/spi-nor/sfdp.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/mtd/spi-nor/sfdp.c +4 -0
@@ -1248,6 +1248,7 @@ static int spi_nor_parse_profile1(struct spi_nor *nor, }#define SCCR_DWORD22_OCTAL_DTR_EN_VOLATILE BIT(31) +#define SFDP_SCCR_DWORD_MIN 22/** * spi_nor_parse_sccr() - Parse the Status, Control and Configuration Register
@@ -1266,6 +1267,9 @@ static int spi_nor_parse_sccr(struct spi_nor *nor,size_t len;int ret; +if (sccr_header->length <SFDP_SCCR_DWORD_MIN ) +return -EINVAL ; + len = sccr_header->length *sizeof (*dwords); dwords =kmalloc (len,GFP_KERNEL );if (!dwords)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 824/3318 mtd: spi-nor: Unprepare legacy controllers upon RWW wait interruption
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miquel Raynal <[email protected]>
[ Upstream commit f594a33f9721f08facd98d0a31adc14ff6da9d70 ]
All the parallel locking helpers (spi_nor_prep_and_lock(), spi_nor_prep_and_lock_pe() and spi_nor_prep_and_lock_rd()) call spi_nor_prep() then wait with a killable sleep. If the sleep gets killed, we leave the controller in its prepared state.
Call ->unprepare() in these cases.
--- drivers/mtd/spi-nor/core.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/mtd/spi-nor/core.c +9 -0
@@ -1284,6 +1284,9 @@ int spi_nor_prep_and_lock(struct spi_nor *nor) ret =wait_event_killable (nor->rww.wait,spi_nor_rww_start_exclusive (nor)); +if (ret) +spi_nor_unprep (nor); +return ret; }
@@ -1361,6 +1364,9 @@ static int spi_nor_prep_and_lock_pe(struct spi_nor *nor, loff_t start, size_t le ret =wait_event_killable (nor->rww.wait,spi_nor_rww_start_pe (nor, start, len)); +if (ret) +spi_nor_unprep (nor); +return ret; }
@@ -1440,6 +1446,9 @@ static int spi_nor_prep_and_lock_rd(struct spi_nor *nor, loff_t start, size_t le ret =wait_event_killable (nor->rww.wait,spi_nor_rww_start_rd (nor, start, len)); +if (ret) +spi_nor_unprep (nor); +return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 825/3318 fs_pin: publish pins with RCU list helpers
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 8d01d6b4c17c406f37a9b6edac93dfb858af30d0 ]
pin_insert() initializes a pin before adding it under pin_lock. The kill paths read the list heads under RCU without taking that lock. Plain hlist insertion does not publish the earlier initialization to those readers.
KCSAN weak-memory checking reported acct_on() callback initialization racing with pin_kill() after the superblock-list publication. The corresponding LKMM model permits the stale read with plain publication; the RCU release/acquire pair forbids it.
Use the RCU hlist add and dereference helpers for both pin lists.
--- fs/fs_pin.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
fs/fs_pin.c +5 -4
@@ -1,5 +1,6 @@// SPDX-License-Identifier: GPL-2.0 #include <linux/fs.h> +#include <linux/rculist.h> #include <linux/sched.h> #include <linux/slab.h> #include "internal.h"
@@ -22,8 +23,8 @@ void pin_remove(struct fs_pin *pin)void pin_insert (struct fs_pin *pin,struct vfsmount *m) {spin_lock (&pin_lock); -hlist_add_head (&pin->s_list, &m->mnt_sb->s_pins); -hlist_add_head (&pin->m_list, &real_mount (m)->mnt_pins); +hlist_add_head_rcu (&pin->s_list, &m->mnt_sb->s_pins); +hlist_add_head_rcu (&pin->m_list, &real_mount (m)->mnt_pins);spin_unlock (&pin_lock); }
@@ -73,7 +74,7 @@ void mnt_pin_kill(struct mount *m)while (1 ) {struct hlist_node *p;rcu_read_lock (); - p =READ_ONCE (m->mnt_pins.first); + p =rcu_dereference (hlist_first_rcu (&m->mnt_pins));if (!p) {rcu_read_unlock ();break ;
@@ -87,7 +88,7 @@ void group_pin_kill(struct hlist_head *p)while (1 ) {struct hlist_node *q;rcu_read_lock (); - q =READ_ONCE (p->first); + q =rcu_dereference (hlist_first_rcu (p));if (!q) {rcu_read_unlock ();break ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 826/3318 arm64: dts: ti: k3-am62-verdin: Set MMC clock pins as OUTPUT
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Francesco Dolcini <[email protected]>
[ Upstream commit 0ddd661c19ec1465e1f2c204fa9b2488acfabf4b ]
MMC clock pins must be configured as OUTPUT-only per TRM [0] with receiver disabled (RXACTIVE bit = 0). Change MMC CLK pins from PIN_INPUT to PIN_OUTPUT to match documentation.
--- arch/arm64/boot/dts/ti/k3-am62-verdin.dtsi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/arm64/boot/dts/ti/k3-am62-verdin.dtsi +3 -3
@@ -508,7 +508,7 @@ AM62X_IOPAD(0x15c, PIN_INPUT, 0) /* (AB22) MDIO0_MDIO */ /* ETH_1_MDIO, SODIMM pinctrl_sdhci0: main-mmc0-default-pins { pinctrl-single,pins = < AM62X_IOPAD(0x220, PIN_INPUT, 0) /* (Y3) MMC0_CMD */ - AM62X_IOPAD(0x218, PIN_INPUT, 0) /* (AB1) MMC0_CLK */ + AM62X_IOPAD(0x218, PIN_OUTPUT, 0) /* (AB1) MMC0_CLK */ AM62X_IOPAD(0x214, PIN_INPUT, 0) /* (AA2) MMC0_DAT0 */ AM62X_IOPAD(0x210, PIN_INPUT_PULLUP, 0) /* (AA1) MMC0_DAT1 */ AM62X_IOPAD(0x20c, PIN_INPUT_PULLUP, 0) /* (AA3) MMC0_DAT2 */
@@ -524,7 +524,7 @@ AM62X_IOPAD(0x1f8, PIN_INPUT_PULLUP, 0) /* (AC2) MMC0_DAT7 */ pinctrl_sdhci1: main-mmc1-default-pins { pinctrl-single,pins = < AM62X_IOPAD(0x23c, PIN_INPUT, 0) /* (A21) MMC1_CMD */ /* SODIMM 74 */ - AM62X_IOPAD(0x234, PIN_INPUT, 0) /* (B22) MMC1_CLK */ /* SODIMM 78 */ + AM62X_IOPAD(0x234, PIN_OUTPUT, 0) /* (B22) MMC1_CLK */ /* SODIMM 78 */ AM62X_IOPAD(0x230, PIN_INPUT, 0) /* (A22) MMC1_DAT0 */ /* SODIMM 80 */ AM62X_IOPAD(0x22c, PIN_INPUT, 0) /* (B21) MMC1_DAT1 */ /* SODIMM 82 */ AM62X_IOPAD(0x228, PIN_INPUT, 0) /* (C21) MMC1_DAT2 */ /* SODIMM 70 */
@@ -537,7 +537,7 @@ AM62X_IOPAD(0x240, PIN_INPUT_PULLUP, 0) /* (D17) MMC1_SDCD */ /* SODIMM 84 */ pinctrl_sdhci2: main-mmc2-default-pins { pinctrl-single,pins = < AM62X_IOPAD(0x120, PIN_INPUT, 0) /* (C24) MMC2_CMD */ /* WiFi_SDIO_CMD */ - AM62X_IOPAD(0x118, PIN_INPUT, 0) /* (D25) MMC2_CLK */ /* WiFi_SDIO_CLK */ + AM62X_IOPAD(0x118, PIN_OUTPUT,0) /* (D25) MMC2_CLK */ /* WiFi_SDIO_CLK */ AM62X_IOPAD(0x114, PIN_INPUT, 0) /* (B24) MMC2_DAT0 */ /* WiFi_SDIO_DATA0 */ AM62X_IOPAD(0x110, PIN_INPUT, 0) /* (C25) MMC2_DAT1 */ /* WiFi_SDIO_DATA1 */ AM62X_IOPAD(0x10c, PIN_INPUT, 0) /* (E23) MMC2_DAT2 */ /* WiFi_SDIO_DATA2 */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 827/3318 thermal: intel: powerclamp: Reject invalid window_size values
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thorsten Blum <[email protected]>
[ Upstream commit 40989202104e498ff9adfb8c575d6cd159f13988 ]
window_size_set() sets ret to -EINVAL if new_window_size is outside the valid range, but then falls through and still updates window_size to the clamped value.
Return -EINVAL immediately and do not update window_size. Also drop the now-redundant clamp() call.
--- drivers/thermal/intel/intel_powerclamp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/thermal/intel/intel_powerclamp.c +2 -1
@@ -291,9 +291,10 @@ static int window_size_set(const char *arg, const struct kernel_param *kp)pr_err ("Out of recommended window size %lu, between 2-10\n" , new_window_size); ret = -EINVAL ; + goto exit_win; } - window_size =clamp (new_window_size,2ul ,10ul ); + window_size = new_window_size;smp_mb (); exit_win:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 828/3318 thermal: intel: int340x: Fix temperature selection around 0 C
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thorsten Blum <[email protected]>
[ Upstream commit e56e2b49c67d132728e52ce493079e83cc914657 ]
Since commit 7251b9e8a007 ("thermal/intel: Fix intel_tcc_get_temp() to support negative CPU temperature"), intel_tcc_get_temp() can report negative temperatures.
proc_thermal_get_zone_temp() still uses *temp as the current maximum and as an implicit "no reading yet" marker. However, this breaks when a CPU reports 0 C, because a subsequent negative reading can overwrite it.
Use bool temp_valid to track whether a valid temperature has been read. Initialize *temp with the first valid reading and only update it with warmer readings.
--- .../intel/int340x_thermal/processor_thermal_device.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/thermal/intel/int340x_thermal/processor_thermal_device.c +7 -3
@@ -114,17 +114,21 @@ static int proc_thermal_get_zone_temp(struct thermal_zone_device *zone, {int cpu;int curr_temp, ret; - - *temp =0 ; +bool temp_valid = false;for_each_online_cpu (cpu) { ret =intel_tcc_get_temp (cpu, &curr_temp, false);if (ret <0 )return ret; -if (!*temp || curr_temp > *temp) +if (!temp_valid || curr_temp > *temp) { *temp = curr_temp; + temp_valid = true; + } } +if (!temp_valid) +return -ENODATA ; + *temp *=1000 ;return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 829/3318 isofs: fix Rock Ridge CE extent validation on multisession media
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baolin Liu <[email protected]>
[ Upstream commit 43de050fa4a31f7e7a73cf8974dcf6037e161a39 ]
Commit a36d990f5913 ("isofs: validate Rock Ridge CE continuation extent against volume size") compares the CE extent directly with s_nzones. The extent is an absolute block number, while s_nzones is the number of blocks relative to the selected ISO session. The comparison is therefore wrong when a multisession disc starts at a non-zero block.
isofs_get_last_session() selects the last session on multisession media, and its volume descriptors describe a volume beginning at that session's LBA.
For example, a session beginning at LBA 45447 with 64 blocks can contain a valid CE at absolute LBA 45467. The existing check rejects that CE, so the ER continuation record is not read, Rock Ridge is disabled, and the mount falls back to Joliet names.
Save the selected session start in filesystem-block units and validate the CE extent against the half-open interval [session_start, session_end). Scale the session length to the same block units and retain a separate block-device limit. The lower bound is intentional: accepting arbitrary blocks before the selected session could make a CE read data from a previous session or another filesystem on the device.
Only apply the bounds check when cont_extent is non-zero. A zero extent is the in-memory sentinel indicating that no CE continuation was found, rather than a request to read block zero.
For a single-session image, session_start is zero and the effective volume boundary remains unchanged.
Build-tested with:
make CONFIG_RUST= CONFIG_RUST_DRIVERS= fs/isofs/
--- fs/isofs/inode.c | 2 ++ fs/isofs/isofs.h | 2 ++ fs/isofs/rock.c | 11 +++++++++-- 3 files changed, 13 insertions(+), 2 deletions(-)
fs/isofs/inode.c +2 -0
@@ -862,6 +862,8 @@ static int isofs_fill_super(struct super_block *s, void *data, int silent)if (!sb_set_blocksize (s, orig_zonesize)) goto out_freesbi; + sbi->s_session_start = (sector_t )vol_desc_start << + (ISOFS_BLOCK_BITS - s->s_blocksize_bits); sbi->s_nls_iocharset =NULL ;#ifdef CONFIG_JOLIET
fs/isofs/isofs.h +2 -0
@@ -35,6 +35,8 @@ struct isofs_sb_info {unsigned long s_firstdatazone;unsigned long s_log_zone_size;unsigned long s_max_size; +/* Session start in filesystem block units. */ +sector_t s_session_start;int s_rock_offset;/* offset of SUSP fields within SU area */ s32 s_sbsector;
fs/isofs/rock.c +9 -2
@@ -9,6 +9,7 @@#include <linux/slab.h> #include <linux/pagemap.h> +#include <linux/blkdev.h> #include "isofs.h" #include "rock.h"
@@ -84,6 +85,10 @@ static void init_rock_state(struct rock_state *rs, struct inode *inode)*/ static int rock_continue (struct rock_state *rs) { +struct super_block *sb = rs->inode->i_sb; +struct isofs_sb_info *sbi =ISOFS_SB (sb); +sector_t session_end = sbi->s_session_start + + ((sector_t )sbi->s_nzones << (ISOFS_BLOCK_BITS - sb->s_blocksize_bits));int ret =1 ;int blocksize =1 << rs->inode->i_blkbits;const int min_de_size = offsetof(struct rock_ridge , u);
@@ -101,11 +106,13 @@ static int rock_continue(struct rock_state *rs) goto out; } -if ((unsigned )rs->cont_extent >=ISOFS_SB (rs->inode->i_sb)->s_nzones) { +if (rs->cont_extent && + (rs->cont_extent < sbi->s_session_start || + rs->cont_extent >= session_end)) {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); + sbi->s_nzones); ret = -EIO ; goto out; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 830/3318 arm64: dts: mediatek: mt7986: correct timer frequency
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrea Pesaresi <[email protected]>
[ Upstream commit 1cf18e4b9815beaf0439c5b57b65b45151c82ad7 ]
The MT7986 architected timer runs at 12,986,200 Hz rather than 13 MHz. Firmware reports 13 MHz through CNTFRQ_EL0, causing the system clock to run slow by about 1062 ppm. This exceeds the kernel's 500 ppm NTP correction limit and leaves clock discipline saturated.
The corrected rate comes from MediaTek's downstream OpenWrt feed, where it is applied to both MT7986A and MT7986B. Since upstream mt7986b.dtsi includes mt7986a.dtsi, add it once to the common timer node so the architected timer driver uses the actual counter rate.
--- arch/arm64/boot/dts/mediatek/mt7986a.dtsi | 1 + 1 file changed, 1 insertion(+)
arch/arm64/boot/dts/mediatek/mt7986a.dtsi +1 -0
@@ -637,6 +637,7 @@ cpu_trip_active_low: active-low { timer { compatible = "arm,armv8-timer"; interrupt-parent = <&gic>; + clock-frequency = <12986200>; interrupts = <GIC_PPI 13 IRQ_TYPE_LEVEL_LOW>, <GIC_PPI 14 IRQ_TYPE_LEVEL_LOW>, <GIC_PPI 11 IRQ_TYPE_LEVEL_LOW>,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 831/3318 media: cx231xx: Fix cleanup path on failure
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andi Shyti <[email protected]>
[ Upstream commit 6e30287eaf3e41b86dfb86df3b811526693d74b4 ]
If cx231xx_init_v4l2() fails the probe currently jumps to err_init, which only unregisters the V4L2 device. The analog devices and I2C resources are left registered while the driver state can be released.
A subsequent driver bind attempts to create the same I2C mux channel links and triggers a warning when the existing "channel-0" link is encountered. The remaining devices may also access released driver state. This produces the following warning
can't create symlink to channel 0
WARNING: drivers/i2c/i2c-mux.c:403 at i2c_mux_add_adapter+0xcd8/0xeb0
Call Trace:
i2c_mux_add_adapter+0xcdc/0xeb0
cx231xx_dev_init+0x2fb/0x1260
cx231xx_usb_probe+0xc48/0x2140
usb_probe_interface+0x657/0xc70
...Jump to err_video_alt instead, which performs the full device cleanup before unregistering the V4L2 device.
--- drivers/media/usb/cx231xx/cx231xx-cards.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/usb/cx231xx/cx231xx-cards.c +1 -1
@@ -1830,7 +1830,7 @@ static int cx231xx_usb_probe(struct usb_interface *interface, retval =cx231xx_init_v4l2 (dev, udev, interface, isoc_pipe);if (retval) - goto err_init; + goto err_video_alt;if (dev->current_pcb_config.ts1_source !=0xff ) {/* compute alternate max packet sizes for TS1 */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 832/3318 media: au0828: Free URBs when starting DVB streaming fails
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ruoyu Wang <[email protected]>
[ Upstream commit b8dd133d96a40012f4b67fd48d8ddd7306a3e024 ]
start_urb_transfer() stores each allocated URB in dev->urbs[], but sets urb_streaming only after all URBs have been submitted. If a later URB or transfer buffer allocation fails, earlier entries are left allocated. A submission failure calls stop_urb_transfer(), but that function returns immediately while urb_streaming is false, leaving both submitted and unsubmitted URBs behind.
Make stop_urb_transfer() release every populated slot regardless of the streaming flag and clear each slot after release. Route all start errors through this cleanup. usb_kill_urb() safely handles both submitted and unsubmitted URBs, while the existing preallocation check preserves the lifetime of shared transfer buffers.
This issue was found by a static analysis checker and confirmed by manual source review.
--- drivers/media/usb/au0828/au0828-dvb.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-)
drivers/media/usb/au0828/au0828-dvb.c +11 -8
@@ -163,9 +163,6 @@ static int stop_urb_transfer(struct au0828_dev *dev)dprintk (2 ,"%s()\n" , __func__); -if (!dev->urb_streaming) -return 0 ; -if (dev->bulk_timeout_running ==1 ) { dev->bulk_timeout_running =0 ;del_timer (&dev->bulk_timeout);
@@ -179,6 +176,7 @@ static int stop_urb_transfer(struct au0828_dev *dev)kfree (dev->urbs[i]->transfer_buffer);usb_free_urb (dev->urbs[i]); + dev->urbs[i] =NULL ; } }
@@ -200,8 +198,10 @@ static int start_urb_transfer(struct au0828_dev *dev)for (i =0 ; i <URB_COUNT ; i++) { dev->urbs[i] =usb_alloc_urb (0 ,GFP_KERNEL ); -if (!dev->urbs[i]) -return -ENOMEM ; +if (!dev->urbs[i]) { + ret = -ENOMEM ; + goto err; + } purb = dev->urbs[i];
@@ -217,7 +217,7 @@ static int start_urb_transfer(struct au0828_dev *dev) ret = -ENOMEM ;pr_err ("%s: failed big buffer allocation, err = %d\n" , __func__, ret); -return ret; + goto err; } purb->status = -EINPROGRESS ;
@@ -235,10 +235,9 @@ static int start_urb_transfer(struct au0828_dev *dev)for (i =0 ; i <URB_COUNT ; i++) { ret =usb_submit_urb (dev->urbs[i],GFP_ATOMIC );if (ret !=0 ) { -stop_urb_transfer (dev);pr_err ("%s: failed urb submission, err = %d\n" , __func__, ret); -return ret; + goto err; } }
@@ -249,6 +248,10 @@ static int start_urb_transfer(struct au0828_dev *dev) dev->bulk_timeout_running =1 ;return 0 ; + +err: +stop_urb_transfer (dev); +return ret; }static void au0828_start_transport (struct au0828_dev *dev)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 833/3318 media: i2c: tc358743: add missing color-space strings
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linkai Gong <[email protected]>
[ Upstream commit cb37e83f1bbdf0964ed0a9524ce45a0694f98205 ]
VI_STATUS3 S_V_COLOR is four bits, so the index after the shift is 0-15. input_color_space[] only has 14 entries. Add the two reserved values so log_status() cannot walk off the table.
--- drivers/media/i2c/tc358743.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/media/i2c/tc358743.c +2 -1
@@ -1266,7 +1266,8 @@ static int tc358743_log_status(struct v4l2_subdev *sd)static const char *const input_color_space[] = {"RGB" ,"YCbCr 601" ,"opRGB" ,"YCbCr 709" ,"NA (4)" ,"xvYCC 601" ,"NA(6)" ,"xvYCC 709" ,"NA(8)" ,"sYCC601" , -"NA(10)" ,"NA(11)" ,"NA(12)" ,"opYCC 601" }; +"NA(10)" ,"NA(11)" ,"NA(12)" ,"opYCC 601" ,"NA(14)" , +"NA(15)" };v4l2_info (sd,"-----Chip status-----\n" ); v4l2_info(sd, "Chip ID: 0x%02x\n",
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 834/3318 media: go7007: bound EZ-USB I2C transfers to the usb_buf size
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shengzhuo Wei <[email protected]>
[ Upstream commit 816c4628b23e8c3d925978433f4dd1a13620c01b ]
go7007_usb_i2c_master_xfer() copies msgs[i].len bytes into go->usb_buf, a 16-byte buffer embedded in struct go7007, without any length check. The adapter declares no transfer limits, so an SMBus block transfer issued through /dev/i2c-N can write up to 34 bytes into it and corrupt the struct fields that follow the buffer.
Bound the transfer size with i2c_adapter_quirks so the I2C core rejects oversized messages before they reach the driver.
--- drivers/media/usb/go7007/go7007-usb.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/media/usb/go7007/go7007-usb.c +6 -0
@@ -1029,10 +1029,16 @@ static const struct i2c_algorithm go7007_usb_algo = { .functionality = go7007_usb_functionality, }; +static const struct i2c_adapter_quirks go7007_usb_quirks = { + .max_write_len =12 , + .max_read_len =15 , +}; +static struct i2c_adapter go7007_usb_adap_templ = { .owner =THIS_MODULE , .name ="WIS GO7007SB EZ-USB" , .algo = &go7007_usb_algo, + .quirks = &go7007_usb_quirks, };/********************* USB add/remove functions *********************/
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 835/3318 media: saa7146: Initialize interrupt lock before requesting IRQ
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Runyu Xiao <[email protected]>
[ Upstream commit e07c75a6bc4adf1ed09ede31756261e2c6bdede5 ]
The saa7146 interrupt handler can call SAA7146_IER_DISABLE(), which serializes register access with dev->int_slock. request_irq() allows the shared handler to run before saa7146_init_one() reaches the current lock initialization block.
Initialize dev->int_slock before requesting the interrupt so every handler path sees an initialized lock.
--- drivers/media/common/saa7146/saa7146_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/media/common/saa7146/saa7146_core.c +2 -1
@@ -340,6 +340,8 @@ static int saa7146_init_one(struct pci_dev *pci, const struct pci_device_id *ent goto out; } +spin_lock_init (&dev->int_slock); +/* create a nice device name */ sprintf (dev->name,"saa7146 (%d)" , saa7146_num);
@@ -425,7 +427,6 @@ static int saa7146_init_one(struct pci_dev *pci, const struct pci_device_id *ent dev->ext = ext;mutex_init (&dev->v4l2_lock); -spin_lock_init (&dev->int_slock);spin_lock_init (&dev->slock);mutex_init (&dev->i2c_lock);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 836/3318 media: vim2m: keep transaction buffer count stable while streaming
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Younho Choi <[email protected]>
[ Upstream commit 50f5fed44d8e24081e8feed5154746fe193f11b8 ]
V4L2_CID_TRANS_NUM_BUFS controls how many buffer pairs a vim2m mem2mem job processes before the job is completed. The driver stores the value in ctx->translen and device_work() uses it later to decide whether the current transaction should continue.
Letting userspace change this control while streaming is active can make a queued job observe a different transaction length than the one it started with. That leaves the transaction state inconsistent with the buffers currently queued for the job.
Grab the transaction buffer count control while either queue is streaming, and release it only after both queues have stopped streaming. The V4L2 control framework then rejects changes with -EBUSY while the value is in use, while still allowing userspace to configure the value before streaming starts.
Keep the control handler alive until after v4l2_m2m_ctx_release(), since releasing the mem2mem context can call stop_streaming(), which now ungrabs the control.
--- drivers/media/test-drivers/vim2m.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-)
drivers/media/test-drivers/vim2m.c +26 -3
@@ -200,6 +200,7 @@ struct vim2m_ctx {struct vim2m_dev *dev;struct v4l2_ctrl_handler hdl; +struct v4l2_ctrl *trans_num_bufs_ctrl;/* Processed buffers in this transaction */ u8 num_processed;
@@ -1063,9 +1064,27 @@ static int vim2m_start_streaming(struct vb2_queue *q, unsigned int count) ctx->aborting =0 ; q_data->sequence =0 ; +v4l2_ctrl_grab (ctx->trans_num_bufs_ctrl, true); +return 0 ; } +static bool vim2m_other_queue_is_streaming (struct vim2m_ctx *ctx, +struct vb2_queue *q) +{ +struct vb2_queue *other_vq; + +if (!ctx->fh.m2m_ctx) +return false; + +if (V4L2_TYPE_IS_OUTPUT (q->type)) + other_vq =v4l2_m2m_get_dst_vq (ctx->fh.m2m_ctx); +else + other_vq =v4l2_m2m_get_src_vq (ctx->fh.m2m_ctx); + +return vb2_is_streaming (other_vq); +} +static void vim2m_stop_streaming (struct vb2_queue *q) {struct vim2m_ctx *ctx =vb2_get_drv_priv (q);
@@ -1079,11 +1098,14 @@ static void vim2m_stop_streaming(struct vb2_queue *q)else vbuf =v4l2_m2m_dst_buf_remove (ctx->fh.m2m_ctx);if (!vbuf) -return ; +break ;v4l2_ctrl_request_complete (vbuf->vb2_buf.req_obj.req, &ctx->hdl);v4l2_m2m_buf_done (vbuf,VB2_BUF_STATE_ERROR ); } + +if (!vim2m_other_queue_is_streaming (ctx, q)) +v4l2_ctrl_grab (ctx->trans_num_bufs_ctrl, false); }static void vim2m_buf_request_complete (struct vb2_buffer *vb)
@@ -1186,7 +1208,8 @@ static int vim2m_open(struct file *file) vim2m_ctrl_trans_time_msec.def = default_transtime;v4l2_ctrl_new_custom (hdl, &vim2m_ctrl_trans_time_msec,NULL ); -v4l2_ctrl_new_custom (hdl, &vim2m_ctrl_trans_num_bufs,NULL ); + ctx->trans_num_bufs_ctrl = +v4l2_ctrl_new_custom (hdl, &vim2m_ctrl_trans_num_bufs,NULL );if (hdl->error) { rc = hdl->error;v4l2_ctrl_handler_free (hdl);
@@ -1240,10 +1263,10 @@ static int vim2m_release(struct file *file)v4l2_fh_del (&ctx->fh);v4l2_fh_exit (&ctx->fh); -v4l2_ctrl_handler_free (&ctx->hdl);mutex_lock (&dev->dev_mutex);v4l2_m2m_ctx_release (ctx->fh.m2m_ctx);mutex_unlock (&dev->dev_mutex); +v4l2_ctrl_handler_free (&ctx->hdl);kfree (ctx);atomic_dec (&dev->num_inst);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 837/3318 media: vicodec: fix out-of-bounds write on under-rounded coded dimensions
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Junrui Luo <[email protected]>
[ Upstream commit 0183746ebca4c478027e2261b904f844f1443b19 ]
A capture format whose width or height is one more than a multiple of 16 makes the FWHT codec write one 8x8 block row, or column, past the end of the capture plane, and read the same block out of the reference frame for P-coded frames.
vic_round_dim() is documented to round a frame dimension up so that both the luma and the chroma plane end up a multiple of 8, but it only rounds the chroma plane:
round_up((dim) / (div), 8) * (div)
For div == 2 the result is a multiple of 16 in every case but one: when dim % 16 == 1, dim / div is already a multiple of 8 and the macro returns dim - 1. encode_plane() and decode_plane() round the same dimension with round_up(dim, 8), which yields dim + 7 -- one block more than the coded dimension that sized the buffer.
On a KASAN-enabled kernel, a 641x360 YUYV P-frame triggers:
BUG: KASAN: slab-out-of-bounds in add_deltas+0x450/0xcc0 Read of size 1 at addr ffff888009070800 by task trigger_bin/70 Call Trace: add_deltas+0x450/0xcc0 decode_plane+0x1916/0x3390 fwht_decode_frame+0x173/0x620 v4l2_fwht_decode+0x751/0x1120 device_run+0x6bb/0x1850
Round the dimension itself up to a multiple of 8 * div. The rounding changes only for div == 2 and dim % 16 == 1, and MAX_WIDTH and MAX_HEIGHT are both multiples of 16, so the rounded value still fits the advertised limits.
--- drivers/media/test-drivers/vicodec/codec-fwht.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/test-drivers/vicodec/codec-fwht.h +1 -1
@@ -61,7 +61,7 @@* both luma and chroma components resolutions are rounded up to * a multiple of 8 */ -#define vic_round_dim (dim, div) (round_up((dim) / (div), 8) * (div)) +#define vic_round_dim (dim, div) round_up(dim, 8 * (div))struct fwht_cframe_hdr {u32 magic1;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 838/3318 media: vicodec: make encoder CAPTURE dimensions read-only
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Junrui Luo <[email protected]>
[ Upstream commit 2532e9d2f8ccb330a9c924b1ee34c5629240d352 ]
Setting the encoder's compressed CAPTURE format to a smaller resolution than the raw OUTPUT format makes the encoder write past the end of the CAPTURE buffer.
For a stateful encoder the CAPTURE width and height are not client-settable; Documentation/userspace-api/media/v4l/dev-encoder.rst specifies them as "ignored (read-only)" on VIDIOC_S_FMT. vicodec only implements half of that: vidioc_s_fmt_vid_out() derives the CAPTURE coded size and sizeimage from the OUTPUT format, but S_FMT on the CAPTURE queue overwrites them. The encoder then takes its geometry from the OUTPUT queue alone, and v4l2_fwht_encode() gets no destination length.
Overwrite the requested width and height with the OUTPUT queue's coded dimensions in vidioc_try_fmt_vid_cap(), making them read-only as the interface requires.
--- drivers/media/test-drivers/vicodec/vicodec-core.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/media/test-drivers/vicodec/vicodec-core.c +10 -0
@@ -891,6 +891,8 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, struct v4l2_format *f) {struct vicodec_ctx *ctx =file2ctx (file); +struct vicodec_q_data *q_data_out = +get_q_data (ctx,V4L2_BUF_TYPE_VIDEO_OUTPUT );struct v4l2_pix_format_mplane *pix_mp;struct v4l2_pix_format *pix;
@@ -901,6 +903,10 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, pix = &f->fmt.pix; pix->pixelformat = ctx->is_enc ?V4L2_PIX_FMT_FWHT :find_fmt (f->fmt.pix.pixelformat)->id; +if (ctx->is_enc) { + pix->width = q_data_out->coded_width; + pix->height = q_data_out->coded_height; + } pix->colorspace = ctx->state.colorspace; pix->xfer_func = ctx->state.xfer_func; pix->ycbcr_enc = ctx->state.ycbcr_enc;
@@ -912,6 +918,10 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, pix_mp = &f->fmt.pix_mp; pix_mp->pixelformat = ctx->is_enc ?V4L2_PIX_FMT_FWHT :find_fmt (pix_mp->pixelformat)->id; +if (ctx->is_enc) { + pix_mp->width = q_data_out->coded_width; + pix_mp->height = q_data_out->coded_height; + } pix_mp->colorspace = ctx->state.colorspace; pix_mp->xfer_func = ctx->state.xfer_func; pix_mp->ycbcr_enc = ctx->state.ycbcr_enc;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 839/3318 media: vidtv: fix frontend reference leak on unbind
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Piyush Patle <[email protected]>
[ Upstream commit 6f412f9fe6a1f3ce9694757f50353bbec221d832 ]
dvb_register_frontend() keeps two references to the frontend. One is released by dvb_unregister_frontend(), and the other by dvb_frontend_detach(). vidtv only called dvb_unregister_frontend(), so the second reference was never released. As a result, __dvb_frontend_free() was never called, leaking the frontend private data and its struct dvb_device.
The detach call was removed by commit 63101b756893 ("media: vidtv: fix driver unbind/remove") because it caused an OOPS. The demod .release callback freed vidtv_demod_state, and the I2C remove callbacks then accessed the freed state.
That commit also removed those accesses from the I2C remove callbacks. Restore the detach call, but remove the demod .release callback. vidtv_demod_state is owned by the I2C client and is already freed by vidtv_demod_i2c_remove(), so the frontend detach path should not free it.
Tested with kmemleak and KASAN over 10 bind/unbind cycles. The reported frontend and dvb_device leaks were present before the fix and were gone after it, with no KASAN reports.
--- drivers/media/test-drivers/vidtv/vidtv_bridge.c | 2 ++ drivers/media/test-drivers/vidtv/vidtv_demod.c | 9 --------- 2 files changed, 2 insertions(+), 9 deletions(-)
drivers/media/test-drivers/vidtv/vidtv_bridge.c +2 -0
@@ -474,6 +474,7 @@ static int vidtv_bridge_dvb_init(struct vidtv_dvb *dvb) fail_demod_probe:for (i = i -1 ; i >=0 ; --i) {dvb_unregister_frontend (dvb->fe[i]); +dvb_frontend_detach (dvb->fe[i]); fail_fe:dvb_module_release (dvb->i2c_client_tuner[i]); fail_tuner_probe:
@@ -552,6 +553,7 @@ static void vidtv_bridge_remove(struct platform_device *pdev)for (i =0 ; i <NUM_FE ; ++i) {dvb_unregister_frontend (dvb->fe[i]); +dvb_frontend_detach (dvb->fe[i]);dvb_module_release (dvb->i2c_client_tuner[i]);dvb_module_release (dvb->i2c_client_demod[i]); }
drivers/media/test-drivers/vidtv/vidtv_demod.c +0 -9
@@ -343,13 +343,6 @@ static int vidtv_diseqc_send_burst(struct dvb_frontend *fe,return 0 ; } -static void vidtv_demod_release (struct dvb_frontend *fe) -{ -struct vidtv_demod_state *state = fe->demodulator_priv; - -kfree (state); -} -static const struct dvb_frontend_ops vidtv_demod_ops = { .delsys = {SYS_DVBT ,
@@ -390,8 +383,6 @@ static const struct dvb_frontend_ops vidtv_demod_ops = { FE_CAN_HIERARCHY_AUTO, }, - .release = vidtv_demod_release, - .set_frontend = vidtv_demod_set_frontend, .get_frontend = vidtv_demod_get_frontend,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 840/3318 media: vidtv: fix uaf in vidtv_bridge_on_new_pkts_avail
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeffin Philip <[email protected]>
[ Upstream commit 2af02ccd048b77713695d7817cf645ca50bf349e ]
Attempting to unbind a dvbdevice that is in the process of feeding data causes a UAF as we free the underlying device without stopping the feed first. Fix this by stopping the stream first using vidtv_stop_streaming(). However, our codepath in the reproducer (mentioned in the below reply) does not decrement our users (dmxdev->dvr_dvbdev->users) to 1 after it has been incremented to 2 by our read() in the reproducer, that is only possible on .release. This can cause a task hang as dvb_dmxdev_release() uses wait_event() in the wait_queue unless we use a close(fd)(in the reproducer). Is this a problem? Please advise.
--- drivers/media/test-drivers/vidtv/vidtv_bridge.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/test-drivers/vidtv/vidtv_bridge.c +2 -0
@@ -551,6 +551,8 @@ static void vidtv_bridge_remove(struct platform_device *pdev)mutex_destroy (&dvb->feed_lock); +vidtv_stop_streaming (dvb); +for (i =0 ; i <NUM_FE ; ++i) {dvb_unregister_frontend (dvb->fe[i]);dvb_frontend_detach (dvb->fe[i]);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 841/3318 media: marvell-cam: fix unmet dependency for VIDEO_MMP_CAMERA
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Julian Braha <[email protected]>
[ Upstream commit 1179929b3abd4adb6ca7fae91d649c64a7293aca ]
VIDEO_MMP_CAMERA selects I2C_GPIO without ensuring
'GPIOLIB || COMPILE_TEST' is enabled, despite I2C_GPIO depending on it.
Let's add the same dependency to VIDEO_MMP_CAMERA.
This unmet dependency bug was found by kconfirm, a static analysis tool for Kconfig.
--- drivers/media/platform/marvell/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/media/platform/marvell/Kconfig +1 -0
@@ -21,6 +21,7 @@ config VIDEO_MMP_CAMERA depends on V4L_PLATFORM_DRIVERS depends on I2C && VIDEO_DEV depends on ARCH_MMP || COMPILE_TEST + depends on GPIOLIB || COMPILE_TEST depends on COMMON_CLK select VIDEO_OV7670 if MEDIA_SUBDRV_AUTOSELECT && VIDEO_CAMERA_SENSOR select I2C_GPIO
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 842/3318 staging: media: av7110: fix corrupted BER reporting in sp8870
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Punnay Sharma <[email protected]>
[ Upstream commit 5764f9bd7b7a72c6df49db6c8c00d4f9994a55ba ]
In sp8870_read_ber(), the 14-bit Bit Error Rate (BER) is assembled by reading two I2C registers: 0xC08 (lower 6 bits) and 0xC07 (upper 8 bits).
The current implementation masks the lower bits via tmp = ret & 0x3F; but subsequently overwrites tmp entirely when processing the upper bits using a direct assignment (tmp = ret << 6;). This logical error causes the lower 6 bits of the BER hardware metric to be silently discarded.
Fix this by using a bitwise OR (tmp |= ret << 6;) to correctly merge the MSB and LSB payloads before returning the metric to the DVB core.
--- drivers/staging/media/av7110/sp8870.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/media/av7110/sp8870.c +1 -1
@@ -384,7 +384,7 @@ static int sp8870_read_ber (struct dvb_frontend* fe, u32 * ber)if (ret <0 )return -EIO ; - tmp = ret <<6 ; + tmp |= ret <<6 ;if (tmp >=0x3FFF0 ) tmp = ~0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 843/3318 media: m2m-deinterlace: fix default capture field
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xu Rao <[email protected]>
[ Upstream commit 4ee3ebede5d01efdcdd88c94f9df271d2eb237de ]
queue_init() initializes default formats for both the source and capture queues. It first sets the source field to V4L2_FIELD_SEQ_TB, but then stores the capture default, V4L2_FIELD_INTERLACED_TB, in the source queue again while initializing the capture queue.
This overwrites the valid source default and leaves the capture field at its zero-initialized value, V4L2_FIELD_ANY. vidioc_streamon() accepts only V4L2_FIELD_SEQ_TB or V4L2_FIELD_SEQ_BT on the source queue, and requires the capture queue to use a compatible interlaced or NONE field. Userspace that relies on the default formats can therefore get -EINVAL when starting streaming.
Initialize the capture field instead. The bug is usually hidden because mem2mem applications commonly call S_FMT on both queues before streaming; the TRY_FMT paths normalize the fields and S_FMT overwrites q_data[].field.
--- drivers/media/platform/m2m-deinterlace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/m2m-deinterlace.c +1 -1
@@ -830,7 +830,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq, q_data[V4L2_M2M_DST ].width =640 ; q_data[V4L2_M2M_DST ].height =480 ; q_data[V4L2_M2M_DST ].sizeimage = (640 *480 *3 ) /2 ; - q_data[V4L2_M2M_SRC ].field =V4L2_FIELD_INTERLACED_TB ; + q_data[V4L2_M2M_DST ].field =V4L2_FIELD_INTERLACED_TB ;return vb2_queue_init (dst_vq); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 844/3318 media: microchip-isc: fix awb_mutex and lock lifecycle
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Balakrishnan Sambath <[email protected]>
[ Upstream commit 5540b48c0702f6a1389db3d473d7fd0db930422a ]
isc->lock and awb_mutex were initialised in isc_async_complete() and destroyed in isc_async_unbind(), tying their lifetime to the subdev bind/unbind cycle instead of the device:
- isc_async_unbind() destroyed awb_mutex before cancel_work_sync(), which takes it;
- a failed .complete() left them initialised, and isc->lock was destroyed only on the .complete() error path, so the normal unbind path leaked it;
- a rebind runs .complete() again and reinitialises a live mutex.
Initialise both with devm_mutex_init() at probe so they live for the whole device lifetime and are freed at remove, and drop the init and destroy from the .complete()/.unbind() callbacks.
isc_async_complete_err then only returned ret, so drop the label and return directly at each error site.
--- .../media/platform/microchip/microchip-isc-base.c | 15 ++++----------- .../platform/microchip/microchip-sama5d2-isc.c | 9 +++++++++ .../platform/microchip/microchip-sama7g5-isc.c | 9 +++++++++ 3 files changed, 22 insertions(+), 11 deletions(-)
drivers/media/platform/microchip/microchip-isc-base.c +4 -11
@@ -1745,7 +1745,6 @@ static void isc_async_unbind(struct v4l2_async_notifier *notifier, {struct isc_device *isc =container_of (notifier->v4l2_dev, struct isc_device, v4l2_dev); -mutex_destroy (&isc->awb_mutex);cancel_work_sync (&isc->awb_work);video_unregister_device (&isc->video_dev);v4l2_ctrl_handler_free (&isc->ctrls.handler);
@@ -1809,8 +1808,6 @@ static int isc_async_complete(struct v4l2_async_notifier *notifier) isc->current_subdev =container_of (notifier, struct isc_subdev_entity, notifier); -mutex_init (&isc->lock); -mutex_init (&isc->awb_mutex);init_completion (&isc->comp);
@@ -1829,7 +1826,7 @@ static int isc_async_complete(struct v4l2_async_notifier *notifier) ret =vb2_queue_init (q);if (ret <0 ) {dev_err (isc->dev,"vb2_queue_init() failed: %d\n" , ret); - goto isc_async_complete_err; +return ret; }/* Init video dma queues */
@@ -1840,13 +1837,13 @@ static int isc_async_complete(struct v4l2_async_notifier *notifier) ret =isc_set_default_fmt (isc);if (ret) {dev_err (isc->dev,"Could not set default format\n" ); - goto isc_async_complete_err; +return ret; } ret =isc_ctrl_init (isc);if (ret) {dev_err (isc->dev,"Init isc ctrols failed: %d\n" , ret); - goto isc_async_complete_err; +return ret; }/* Register video device */
@@ -1866,7 +1863,7 @@ static int isc_async_complete(struct v4l2_async_notifier *notifier) ret =video_register_device (vdev,VFL_TYPE_VIDEO ,-1 );if (ret <0 ) {dev_err (isc->dev,"video_register_device failed: %d\n" , ret); - goto isc_async_complete_err; +return ret; } ret =isc_scaler_link (isc);
@@ -1881,10 +1878,6 @@ static int isc_async_complete(struct v4l2_async_notifier *notifier) isc_async_complete_unregister_device:video_unregister_device (vdev); - -isc_async_complete_err: -mutex_destroy (&isc->awb_mutex); -mutex_destroy (&isc->lock);return ret; }
drivers/media/platform/microchip/microchip-sama5d2-isc.c +9 -0
@@ -30,6 +30,7 @@#include <linux/interrupt.h> #include <linux/math64.h> #include <linux/module.h> +#include <linux/mutex.h> #include <linux/of.h> #include <linux/of_graph.h> #include <linux/platform_device.h>
@@ -424,6 +425,14 @@ static int microchip_isc_probe(struct platform_device *pdev)platform_set_drvdata (pdev, isc); isc->dev = dev; + ret =devm_mutex_init (dev, &isc->lock); +if (ret) +return ret; + + ret =devm_mutex_init (dev, &isc->awb_mutex); +if (ret) +return ret; + io_base =devm_platform_ioremap_resource (pdev,0 );if (IS_ERR (io_base))return PTR_ERR (io_base);
drivers/media/platform/microchip/microchip-sama7g5-isc.c +9 -0
@@ -33,6 +33,7 @@#include <linux/interrupt.h> #include <linux/math64.h> #include <linux/module.h> +#include <linux/mutex.h> #include <linux/of.h> #include <linux/of_graph.h> #include <linux/platform_device.h>
@@ -413,6 +414,14 @@ static int microchip_xisc_probe(struct platform_device *pdev)platform_set_drvdata (pdev, isc); isc->dev = dev; + ret =devm_mutex_init (dev, &isc->lock); +if (ret) +return ret; + + ret =devm_mutex_init (dev, &isc->awb_mutex); +if (ret) +return ret; + io_base =devm_platform_ioremap_resource (pdev,0 );if (IS_ERR (io_base))return PTR_ERR (io_base);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 845/3318 media: microchip-isc: synchronize the IRQ before disabling clocks on stop
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Balakrishnan Sambath <[email protected]>
[ Upstream commit 19fa5407da5ef3e605cacfcd90f70d8b2c121cd7 ]
isc_stop_streaming() masks the DMA interrupt and then drops the runtime PM reference, which disables the ISC clocks. microchip_isc_interrupt() may still be executing on another CPU at that point; it reads ISC_INTSR over regmap, and touching the unclocked registers triggers an external abort.
Store the IRQ number at probe and call synchronize_irq() after masking the interrupt, before dropping the PM reference.
--- drivers/media/platform/microchip/microchip-isc-base.c | 3 +++ drivers/media/platform/microchip/microchip-isc.h | 1 + drivers/media/platform/microchip/microchip-sama5d2-isc.c | 2 ++ drivers/media/platform/microchip/microchip-sama7g5-isc.c | 2 ++ 4 files changed, 8 insertions(+)
drivers/media/platform/microchip/microchip-isc-base.c +3 -0
@@ -425,6 +425,9 @@ static void isc_stop_streaming(struct vb2_queue *vq)/* Disable DMA interrupt */ regmap_write (isc->regmap,ISC_INTDIS ,ISC_INT_DDONE ); +/* let a running IRQ handler finish before the clock is disabled */ +synchronize_irq (isc->irq); +pm_runtime_put_sync (isc->dev);/* Disable stream on the sub device */
drivers/media/platform/microchip/microchip-isc.h +1 -0
@@ -287,6 +287,7 @@ struct isc_device {u32 dcfg;struct device *dev; +int irq;struct v4l2_device v4l2_dev;struct video_device video_dev;
drivers/media/platform/microchip/microchip-sama5d2-isc.c +2 -0
@@ -448,6 +448,8 @@ static int microchip_isc_probe(struct platform_device *pdev)if (irq <0 )return irq; + isc->irq = irq; + ret =devm_request_irq (dev, irq, microchip_isc_interrupt,0 ,"microchip-sama5d2-isc" , isc);if (ret <0 ) {
drivers/media/platform/microchip/microchip-sama7g5-isc.c +2 -0
@@ -437,6 +437,8 @@ static int microchip_xisc_probe(struct platform_device *pdev)if (irq <0 )return irq; + isc->irq = irq; + ret =devm_request_irq (dev, irq, microchip_isc_interrupt,0 ,"microchip-sama7g5-xisc" , isc);if (ret <0 ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 846/3318 media: microchip-isc: disable histogram and flush AWB work on teardown
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Balakrishnan Sambath <[email protected]>
[ Upstream commit 00d87c379915a3689b2488bd37f490875d79e20f ]
isc_stop_streaming() and the isc_start_streaming() error path dropped the runtime PM reference with the histogram still enabled. A HISDONE firing just before the stop, or a failed isc_update_profile() on the start path, can queue isc_awb_work(), which reads the histogram registers before taking its own PM reference and faults on the unclocked device.
Disable the histogram, synchronize the IRQ and flush the work before the device is left unclocked. isc_configure() is the one enabling the histogram and then calling isc_update_profile(), so do the cleanup in its own failure path; isc_stop_streaming() does the same on teardown. synchronize_irq() must come before cancel_work_sync(), so an in-flight handler cannot re-queue awb_work after it is cancelled.
--- .../media/platform/microchip/microchip-isc-base.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
drivers/media/platform/microchip/microchip-isc-base.c +14 -1
@@ -289,6 +289,7 @@ static int isc_configure(struct isc_device *isc)struct regmap *regmap = isc->regmap;u32 pfe_cfg0, dcfg, mask, pipeline;struct isc_subdev_entity *subdev = isc->current_subdev; +int ret; pfe_cfg0 = isc->config.sd_format->pfe_cfg0_bps; pipeline = isc->config.bits_pipeline;
@@ -321,7 +322,15 @@ static int isc_configure(struct isc_device *isc)isc_set_histogram (isc, false);/* Update profile */ -return isc_update_profile (isc); + ret =isc_update_profile (isc); +if (ret) { +/* flush the histogram work before the clocks are gated */ +isc_set_histogram (isc, false); +synchronize_irq (isc->irq); +cancel_work_sync (&isc->awb_work); + } + +return ret; }static int isc_prepare_streaming (struct vb2_queue *vq)
@@ -425,9 +434,13 @@ static void isc_stop_streaming(struct vb2_queue *vq)/* Disable DMA interrupt */ regmap_write (isc->regmap,ISC_INTDIS ,ISC_INT_DDONE ); +isc_set_histogram (isc, false); +/* let a running IRQ handler finish before the clock is disabled */ synchronize_irq (isc->irq); +cancel_work_sync (&isc->awb_work); +pm_runtime_put_sync (isc->dev);/* Disable stream on the sub device */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 847/3318 media: microchip-isc: do not touch WB registers when not streaming
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Balakrishnan Sambath <[email protected]>
[ Upstream commit d8983c47d4d95eb1ed889dbb7516d3738fa854d8 ]
isc_s_awb_ctrl() called isc_update_awb_ctrls() unconditionally, writing the white balance registers even when the device is runtime suspended; on many ARM platforms accessing the unclocked registers is an external abort. The write was also done without awb_lock, racing isc_awb_work(), which holds it so the DMA done IRQ cannot latch a half-updated pipeline.
Write the registers only while streaming and not stopping, under awb_lock, and update the profile there. The isc->stop check covers the window where isc_stop_streaming() has gated the clocks but vb2 still reports streaming. Otherwise the new values stay cached and isc_configure() programs them at the next stream start.
--- .../platform/microchip/microchip-isc-base.c | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-)
drivers/media/platform/microchip/microchip-isc-base.c +12 -8
@@ -1553,20 +1553,24 @@ static int isc_s_awb_ctrl(struct v4l2_ctrl *ctrl)if (ctrl->cluster[ISC_CTRL_GB_OFF ]->is_new) ctrls->offset[ISC_HIS_CFG_MODE_GB ] = isc->gb_off_ctrl->val; -isc_update_awb_ctrls (isc); -mutex_lock (&isc->awb_mutex); -if (vb2_is_streaming (&isc->vb2_vidq)) { +if (vb2_is_streaming (&isc->vb2_vidq) && !isc->stop) { +unsigned long flags; +/* -* If we are streaming, we can update profile to -* have the new settings in place. +* awb_lock keeps the DMA done IRQ from latching a +* partially written WB pipeline. */ +spin_lock_irqsave (&isc->awb_lock, flags); +isc_update_awb_ctrls (isc); +spin_unlock_irqrestore (&isc->awb_lock, flags); +isc_update_profile (isc); }else {/* -* The auto cluster will activate automatically this -* control. This has to be deactivated when not -* streaming. +* Not streaming: keep the cached values for the next +* stream start and deactivate the cluster-activated +* do_white_balance button. */ v4l2_ctrl_activate (isc->do_wb_ctrl, false); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 848/3318 media: microchip-isc: fix PM runtime leak in AWB work handler
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Balakrishnan Sambath <[email protected]>
[ Upstream commit 21ad8225822a892c4c273bf1368d477a83a19dbb ]
Early return when streaming stops skips pm_runtime_put_sync(), leaking the reference and preventing runtime suspend.
--- drivers/media/platform/microchip/microchip-isc-base.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/media/platform/microchip/microchip-isc-base.c +2 -1
@@ -1474,7 +1474,7 @@ static void isc_awb_work(struct work_struct *w)/* streaming is not active anymore */ if (isc->stop) {mutex_unlock (&isc->awb_mutex); -return ; + goto out_pm_put; }isc_update_profile (isc);
@@ -1485,6 +1485,7 @@ static void isc_awb_work(struct work_struct *w)if (ctrls->awb)regmap_write (regmap,ISC_CTRLEN ,ISC_CTRL_HISREQ ); +out_pm_put:pm_runtime_put_sync (isc->dev); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 849/3318 media: microchip-isc: dont sleep in the clk .is_enabled callback
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Balakrishnan Sambath <[email protected]>
[ Upstream commit 61490ff518c7b3ea3ff1cd16bbc012e9e4f1ab74 ]
isc_clk_is_enabled() calls pm_runtime_resume_and_get() and pm_runtime_put_sync(), which can sleep and are not safe here, as .is_enabled must run in atomic context. clk_disable_unused() calls it so at boot, and CONFIG_DEBUG_ATOMIC_SLEEP reports a "sleeping function called from invalid context" BUG.
Use the atomic-safe pm_runtime_get_if_active() and pm_runtime_put() instead. A suspended ISC has its clocks gated, so report the clock disabled when the device is not already active.
--- drivers/media/platform/microchip/microchip-isc-clk.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/media/platform/microchip/microchip-isc-clk.c +3 -4
@@ -98,15 +98,14 @@ static int isc_clk_is_enabled(struct clk_hw *hw) {struct isc_clk *isc_clk =to_isc_clk (hw);u32 status; -int ret; - ret =pm_runtime_resume_and_get (isc_clk->dev); -if (ret <0 ) +/* Runs in atomic context, so must not sleep to resume the ISC. */ +if (pm_runtime_get_if_active (isc_clk->dev) <=0 )return 0 ;regmap_read (isc_clk->regmap,ISC_CLKSR , &status); -pm_runtime_put_sync (isc_clk->dev); +pm_runtime_put (isc_clk->dev);return status &ISC_CLK (isc_clk->id) ?1 :0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 850/3318 mtd: rawnand: sunxi: reject ECC maximization on small pages
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: James Hilliard <[email protected]>
[ Upstream commit a3c84084a73e170374b7dd493947efdef4ee57bc ]
When nand-ecc-maximize is set, the driver selects a 1024-byte ECC step and divides the available OOB bytes by the resulting number of steps. A NAND with a smaller page therefore produces zero steps and a division by zero.
The older controllers also provide a 512-byte ECC block mode, but the hardware documentation describes that as an ECC block size within NAND pages whose supported sizes start at 1024 bytes. It does not document a 512-byte NAND page mode.
Reject pages smaller than 1024 bytes before deriving the step count. This prevents the division by zero at the point where the incompatible maximized geometry is selected without changing explicitly configured 512-byte ECC block handling.
--- drivers/mtd/nand/raw/sunxi_nand.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/mtd/nand/raw/sunxi_nand.c +3 -0
@@ -1631,6 +1631,9 @@ static int sunxi_nand_hw_ecc_ctrl_init(struct nand_chip *nand,if (nanddev->ecc.user_conf.flags &NAND_ECC_MAXIMIZE_STRENGTH ) {int bytes; +if (mtd->writesize <1024 ) +return -EINVAL ; + ecc->size =1024 ; nsectors = mtd->writesize / ecc->size;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 851/3318 media: adv7604: avoid negative array index in log_status when cp_read fails
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Greg Kroah-Hartman <[email protected]>
[ Upstream commit 10d8dfda1c08f6788049aa100685e223d857f901 ]
cp_read() returns the negative errno from regmap_read() on I2C failure. adv76xx_log_status() shifts the result right by 4 and uses it directly to index csc_coeff_sel_rb[16] causing the right shift of a negative number to result in -1, reading a negative place in the array.
Commit 8163419e3e05 ("media: adv7842: Avoid possible out-of-bounds array accesses in adv7842_cp_log_status()") fixed the identical pattern in the adv7842, so do the same thing here.
--- drivers/media/i2c/adv7604.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/media/i2c/adv7604.c +2 -1
@@ -2637,8 +2637,9 @@ static int adv76xx_log_status(struct v4l2_subdev *sd) "(16-235)" : "(0-255)", (reg_io_0x02 & 0x08) ? "enabled" : "disabled"); } + ret =cp_read (sd, info->cp_csc) >>4 ;v4l2_info (sd,"Color space conversion: %s\n" , - csc_coeff_sel_rb[cp_read (sd, info->cp_csc) >>4 ]); + ret <0 ?"" : csc_coeff_sel_rb[ret]);if (!is_digital_input (sd))return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 852/3318 media: stv090x: bound DiSEqC reply length to msg[] size
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Greg Kroah-Hartman <[email protected]>
[ Upstream commit bad6ce6e0856f344910ba95b006e6c0ebee2d9c8 ]
The FIFO_BYTENBR_FIELD register field is 4 bits wide, giving a length of 0..15, but reply->msg is __u8[4] in struct dvb_diseqc_slave_reply. A faulty or malicious DiSEqC slave (or i2c bus glitch) reporting more than 4 bytes will the array and clobber the stack.
The stb0899, tda10071, and s5h1420 drivers all properly bound the FIFO count against sizeof(reply->msg) before the read loop, so do the same thing in this driver.
--- drivers/media/dvb-frontends/stv090x.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/dvb-frontends/stv090x.c +2 -0
@@ -3897,6 +3897,8 @@ static int stv090x_recv_slave_reply(struct dvb_frontend *fe, struct dvb_diseqc_sif (rx_end) { reply->msg_len =STV090x_GETFIELD_Px (reg,FIFO_BYTENBR_FIELD ); +if (reply->msg_len >sizeof (reply->msg)) + reply->msg_len =sizeof (reply->msg);for (i =0 ; i < reply->msg_len; i++) reply->msg[i] =STV090x_READ_DEMOD (state,DISRXDATA ); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 853/3318 media: stv0900: bound DiSEqC reply length to msg[] size
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Greg Kroah-Hartman <[email protected]>
[ Upstream commit 6d7e70111b9c80a9e4cb17fe6a6c4f5470847722 ]
The FIFO_BYTENBR field is 4 bits (mask 0x0f), giving a length of 0..15 but reply->msg is __u8[4] in struct dvb_diseqc_slave_reply. A faulty or malicious device reporting more than 4 bytes will the array and clobber the stack.
The stb0899, tda10071, and s5h1420 drivers all properly bound the FIFO count against sizeof(reply->msg) before the read loop, so do the same thing in this driver.
--- drivers/media/dvb-frontends/stv0900_core.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/dvb-frontends/stv0900_core.c +2 -0
@@ -1775,6 +1775,8 @@ static int stv0900_recv_slave_reply(struct dvb_frontend *fe,if (stv0900_get_bits (intp,RX_END )) { reply->msg_len =stv0900_get_bits (intp,FIFO_BYTENBR ); +if (reply->msg_len >sizeof (reply->msg)) + reply->msg_len =sizeof (reply->msg);for (i =0 ; i < reply->msg_len; i++) reply->msg[i] =stv0900_read_reg (intp,DISRXDATA );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 854/3318 drm/bridge: analogix_dp: Restore mandatory samsung DP DT properties
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Damon Ding <[email protected]>
[ Upstream commit 02f569dd66c94dd67b2586f776235cf4177409ed ]
Revert the change that made samsung,link-rate and samsung,lane-count optional for Exynos DP. Add error checking to fail probe early if the required DT properties are missing.
If these properties are missing, video_info->max_link_rate and video_info->max_lane_count remain zero, and so do link_train.link_rate and link_train.lane_count used in the subsequent link training flow, resulting in link training failure.
There is no way at all a device can work without these properties. Here is the code flow when either max_link_rate or max_lane_count is 0:
analogix_dp_commit()
-> analogix_dp_full_link_train(dp, max_lanes = 0, max_rate = 0)
analogix_dp_full_link_train(max_lanes, max_rate):
// Read sink capabilities via DPCD and sanitize them
link_rate = read_dpcd(DP_MAX_LINK_RATE); // >= 0x06 after fixup
lane_count = read_dpcd(DP_MAX_LANE_COUNT); // >= 1 after fixup
// Clamp by the limits from DT
if (link_rate > max_rate) // 0x06 > 0, always true
link_rate = max_rate; // link_rate = 0
if (lane_count > max_lanes) // 1 > 0, always true
lane_count = max_lanes; // lane_count = 0
// Configure TX with the zeroed values
set_link_bandwidth(link_rate = 0)
// writel() is only executed for bwtype == 0x06/0x0a,
// so LINK_BW_SET is never written and stays at
// reset value; phy_configure() gets link_rate = 0.
set_lane_count(lane_count = 0)
// writel(0, ANALOGIX_DP_LANE_COUNT_SET) enables 0 lanes;
// phy_configure() is called with lanes = 0.
// Program sink for link training
drm_dp_dpcd_write(DP_LINK_BW_SET, {link_rate = 0/lane_count = 0})
// DP spec requires link rate in {0x06, 0x0a, 0x14} and
// lane count in {1, 2, 4}. Writing zeros is illegal, so
// the sink cannot enter the training state.
// Training loop
for (lane = 0; lane < lane_count /* 0 */; lane++)
// loop body never executes; training_lane[] stays
// uninitialized and no training register is programmedSince the sanitized sink values are always non-zero (link_rate >= 0x06, lane_count >= 1), the clamping with a zero maximum unconditionally forces the training parameters to zero. Clock recovery can never be achieved, so link training fails deterministically.
Consequently, making these properties mandatory again cannot break any existing device: a DT without them could never have worked in the first place. Failing probe early with a clear error message is more helpful than a silent link training failure at runtime.
--- drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +9 -4
@@ -1635,6 +1635,7 @@ static int analogix_dp_dt_parse_pdata(struct analogix_dp_device *dp) {struct device_node *dp_node = dp->dev->of_node;struct video_info *video_info = &dp->video_info; +u32 val;switch (dp->plat_data->dev_type) {case RK3288_DP :
@@ -1651,10 +1652,14 @@ static int analogix_dp_dt_parse_pdata(struct analogix_dp_device *dp)* NOTE: those property parseing code is used for * providing backward compatibility for samsung platform. */ -of_property_read_u32 (dp_node,"samsung,link-rate" , - &video_info->max_link_rate); -of_property_read_u32 (dp_node,"samsung,lane-count" , - &video_info->max_lane_count); +if (of_property_read_u32 (dp_node,"samsung,link-rate" , &val)) +return dev_err_probe (dp->dev, -EINVAL , +"Failed to get samsung,link-rate\n" ); + video_info->max_link_rate = val; +if (of_property_read_u32 (dp_node,"samsung,lane-count" , &val)) +return dev_err_probe (dp->dev, -EINVAL , +"Failed to get samsung,lane-count\n" ); + video_info->max_lane_count = val;break ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 855/3318 dmaengine: altera-msgdma: initialize state before requesting IRQ
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Runyu Xiao <[email protected]>
[ Upstream commit a5f8e3471fc20567df888267885dec3eb340eb37 ]
msgdma_probe() registers the IRQ before initializing the tasklet, lock, and descriptor lists used by the interrupt handler. A pending interrupt can access incomplete state during probe.
Initialize the handler state before requesting the IRQ so the interrupt path observes ready software state.
--- drivers/dma/altera-msgdma.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/dma/altera-msgdma.c +5 -5
@@ -838,11 +838,6 @@ static int msgdma_probe(struct platform_device *pdev)if (mdev->irq <0 )return -ENXIO ; - ret =devm_request_irq (&pdev->dev, mdev->irq, msgdma_irq_handler, -0 ,dev_name (&pdev->dev), mdev); -if (ret) -return ret; -tasklet_setup (&mdev->irq_tasklet, msgdma_tasklet);dma_cookie_init (&mdev->dmachan);
@@ -854,6 +849,11 @@ static int msgdma_probe(struct platform_device *pdev)INIT_LIST_HEAD (&mdev->done_list);INIT_LIST_HEAD (&mdev->free_list); + ret =devm_request_irq (&pdev->dev, mdev->irq, msgdma_irq_handler, +0 ,dev_name (&pdev->dev), mdev); +if (ret) +return ret; + dma_dev = &mdev->dmadev;/* Set DMA capabilities */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 856/3318 ACPI: pfr_update: zero-initialize capability query result
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit d776369a9eded071df83e4738e1572c4c5b912d7 ]
query_capability() copies four ACPI buffers into fixed-size fields using the firmware-supplied lengths. The existing overflow guard rejects oversized buffers, but shorter buffers are accepted and leave trailing bytes of the stack-allocated cap_hdr uninitialized. PFRU_IOC_QUERY_CAP then copies the entire structure to userspace.
Zero-initialize cap_hdr before querying the firmware. This preserves the existing handling of short firmware responses while preventing disclosure of kernel stack data. Oversized buffers remain rejected.
A QEMU _DSM returning one-byte buffers reproduced nonzero stack suffix bytes in all four fields. With this change, the ioctl still succeeds and each unwritten suffix is zero-filled, while 64-byte buffers continue to return -EINVAL.
--- drivers/acpi/pfr_update.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/pfr_update.c +1 -1
@@ -395,7 +395,7 @@ static int start_update(int action, struct pfru_device *pfru_dev)static long pfru_ioctl (struct file *file,unsigned int cmd,unsigned long arg) { -struct pfru_update_cap_info cap_hdr; +struct pfru_update_cap_info cap_hdr = {};struct pfru_device *pfru_dev =to_pfru_dev (file);void __user *p = (void __user *)arg;u32 rev;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 857/3318 power: supply: qcom_smbx: include base when petting watchdog
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Robin Snyders <[email protected]>
[ Upstream commit 2f0dec12007891398e6e3041aca0b8656918973d ]
BARK_BITE_WDOG_PET is an offset from the charger peripheral base, but the watchdog bark handler writes it as an absolute SPMI address. This can write another PMIC peripheral and leave the charger watchdog unserviced.
Add the charger base, as all other qcom_smbx register accesses do.
--- drivers/power/supply/qcom_pmi8998_charger.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/power/supply/qcom_pmi8998_charger.c +1 -1
@@ -764,7 +764,7 @@ static irqreturn_t smb2_handle_wdog_bark(int irq, void *data)power_supply_changed (chip->chg_psy); - rc =regmap_write (chip->regmap,BARK_BITE_WDOG_PET , + rc =regmap_write (chip->regmap, chip->base +BARK_BITE_WDOG_PET ,BARK_BITE_WDOG_PET_BIT );if (rc <0 )dev_err (chip->dev,"Couldn't pet the dog rc=%d\n" , rc);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 858/3318 power: supply: qcom_smbx: test battery health status bits
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Robin Snyders <[email protected]>
[ Upstream commit 68f645192f64e1037685dbdb0dffb41a5a012056 ]
BATTERY_CHARGER_STATUS_2 contains independent status and fault bits. Switching on the complete register only recognizes a fault when it is the sole asserted bit, and can report a healthy battery when another status bit is set at the same time.
Test the relevant fault bits in priority order, matching the Qualcomm downstream driver handling.
--- drivers/power/supply/qcom_pmi8998_charger.c | 22 ++++++++------------- 1 file changed, 8 insertions(+), 14 deletions(-)
drivers/power/supply/qcom_pmi8998_charger.c +8 -14
@@ -636,26 +636,20 @@ static int smb2_get_prop_health(struct smb2_chip *chip, int *val)return rc; } -switch (stat) { -case CHARGER_ERROR_STATUS_BAT_OV_BIT : +if (stat &CHARGER_ERROR_STATUS_BAT_OV_BIT ) *val =POWER_SUPPLY_HEALTH_OVERVOLTAGE ; -return 0 ; -case BAT_TEMP_STATUS_TOO_COLD_BIT : +else if (stat &BAT_TEMP_STATUS_TOO_COLD_BIT ) *val =POWER_SUPPLY_HEALTH_COLD ; -return 0 ; -case BAT_TEMP_STATUS_TOO_HOT_BIT : +else if (stat &BAT_TEMP_STATUS_TOO_HOT_BIT ) *val =POWER_SUPPLY_HEALTH_OVERHEAT ; -return 0 ; -case BAT_TEMP_STATUS_COLD_SOFT_LIMIT_BIT : +else if (stat &BAT_TEMP_STATUS_COLD_SOFT_LIMIT_BIT ) *val =POWER_SUPPLY_HEALTH_COOL ; -return 0 ; -case BAT_TEMP_STATUS_HOT_SOFT_LIMIT_BIT : +else if (stat &BAT_TEMP_STATUS_HOT_SOFT_LIMIT_BIT ) *val =POWER_SUPPLY_HEALTH_WARM ; -return 0 ; -default : +else *val =POWER_SUPPLY_HEALTH_GOOD ; -return 0 ; - } + +return 0 ; } static int smb2_get_property(struct power_supply *psy,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 859/3318 power: supply: qcom_smbx: fix float voltage selector
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Robin Snyders <[email protected]>
[ Upstream commit 2a26d260e72a95e9f13b9e475f63aa404600fcb2 ]
FLOAT_VOLTAGE_CFG encodes 3,487,500 uV as selector zero and advances in 7,500 uV steps. The current calculation adds one to that selector, so it programs the requested float voltage one step too high.
Remove the extra offset and name the hardware encoding constants.
--- drivers/power/supply/qcom_pmi8998_charger.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/power/supply/qcom_pmi8998_charger.c +4 -1
@@ -349,6 +349,8 @@/* pmi8998 registers represent current in increments of 1/40th of an amp */ #define CURRENT_SCALE_FACTOR 25000 +#define SMB2_FLOAT_VOLTAGE_MIN_UV 3487500 +#define SMB2_FLOAT_VOLTAGE_STEP_UV 7500/* clang-format on */ enum charger_status {
@@ -993,7 +995,8 @@ static int smb2_probe(struct platform_device *pdev)return dev_err_probe (chip->dev, rc,"Failed to init status change work\n" ); - rc = (chip->batt_info->voltage_max_design_uv -3487500 ) /7500 +1 ; + rc = (chip->batt_info->voltage_max_design_uv - +SMB2_FLOAT_VOLTAGE_MIN_UV ) /SMB2_FLOAT_VOLTAGE_STEP_UV ; rc =regmap_update_bits (chip->regmap, chip->base +FLOAT_VOLTAGE_CFG ,FLOAT_VOLTAGE_SETTING_MASK , rc);if (rc <0 )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 860/3318 power: supply: qcom_smbx: notify battery overvoltage recovery
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Robin Snyders <[email protected]>
[ Upstream commit 2548e4fa576a87a3b0d1b15a9c3f909bc54887b5 ]
The battery-overvoltage IRQ is configured for both edges, but its handler only notifies the power-supply core while the fault bit is asserted. The falling edge therefore does not publish the recovered health and status. The handler also ignores register-read failures before testing status.
Handle read errors, log only an asserted fault, and notify the power-supply core after every successful edge read.
--- drivers/power/supply/qcom_pmi8998_charger.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/power/supply/qcom_pmi8998_charger.c +9 -3
@@ -719,16 +719,22 @@ static irqreturn_t smb2_handle_batt_overvoltage(int irq, void *data) {struct smb2_chip *chip = data;unsigned int status; +int rc; -regmap_read (chip->regmap, chip->base +BATTERY_CHARGER_STATUS_2 , - &status); + rc =regmap_read (chip->regmap, + chip->base +BATTERY_CHARGER_STATUS_2 , &status); +if (rc <0 ) { +dev_err (chip->dev,"Couldn't read charger status: %d\n" , rc); +return IRQ_HANDLED ; + }if (status &CHARGER_ERROR_STATUS_BAT_OV_BIT ) {/* The hardware stops charging automatically */ dev_err (chip->dev,"battery overvoltage detected\n" ); -power_supply_changed (chip->chg_psy); } +power_supply_changed (chip->chg_psy); +return IRQ_HANDLED ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 861/3318 iio: imu: inv_icm42600: fix odr change not caught in certain cases
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jean-Baptiste Maneyrol <[email protected]>
[ Upstream commit f670d4d3477386d62017936f0121909f93ac17f8 ]
When using both accel and gyro with different frequencies, the ODR change flag in the FIFO header can be sometime in a packet with invalid data. Since we are ignoring these packets, we miss the ODR change and any further change are blocked until sensor is turned off.
Fix this by moving the packet data validity check after the ODR change flag check.
--- drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c | 8 ++++---- drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-)
drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c +4 -4
@@ -768,15 +768,15 @@ int inv_icm42600_accel_parse_fifo(struct iio_dev *indio_dev)if (size <=0 )return size; -/* skip packet if no accel data or data is invalid */ -if (accel ==NULL || !inv_icm42600_fifo_is_data_valid (accel)) -continue ; -/* update odr */ if (odr &INV_ICM42600_SENSOR_ACCEL )inv_sensors_timestamp_apply_odr (ts, st->fifo.period, st->fifo.nb.total, no); +/* skip packet if no accel data or data is invalid */ +if (accel ==NULL || !inv_icm42600_fifo_is_data_valid (accel)) +continue ; +memcpy (&buffer.accel, accel,sizeof (buffer.accel));/* convert 8 bits FIFO temperature in high resolution format */ buffer.temp = temp ? (*temp *64 ) :0 ;
drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c +4 -4
@@ -780,15 +780,15 @@ int inv_icm42600_gyro_parse_fifo(struct iio_dev *indio_dev)if (size <=0 )return size; -/* skip packet if no gyro data or data is invalid */ -if (gyro ==NULL || !inv_icm42600_fifo_is_data_valid (gyro)) -continue ; -/* update odr */ if (odr &INV_ICM42600_SENSOR_GYRO )inv_sensors_timestamp_apply_odr (ts, st->fifo.period, st->fifo.nb.total, no); +/* skip packet if no gyro data or data is invalid */ +if (gyro ==NULL || !inv_icm42600_fifo_is_data_valid (gyro)) +continue ; +memcpy (&buffer.gyro, gyro,sizeof (buffer.gyro));/* convert 8 bits FIFO temperature in high resolution format */ buffer.temp = temp ? (*temp *64 ) :0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 862/3318 sched/fair: Reset NUMA fault locality after scan period update
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Kim <[email protected]>
[ Upstream commit e81ee06308379a5f2ededf997bcf17551bce5db7 ]
When updating the task scan period for NUMA locality checks, update_task_scan_period() checks whether there were no faults or failed migration on the last scan window, at which it prolongs the scan period.
However, p->numa_faults_locality, which is used to check for migration failure and number of faults at the previous scan window is not cleared after changing the scan period, which unintentionally increases numa_scan_period up to numa_scan_period_max even when there were no migration failures or no faults at previous scan.
Fix this by jumping to the out label on early exit at this case to ensure p->numa_faults_locality is always cleared before returning.
--- kernel/sched/fair.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
kernel/sched/fair.c +5 -2
@@ -2668,7 +2668,7 @@ static void update_task_scan_period(struct task_struct *p, p->mm->numa_next_scan = jiffies +msecs_to_jiffies (p->numa_scan_period); -return ; + goto out; }/*
@@ -2712,7 +2712,10 @@ static void update_task_scan_period(struct task_struct *p, p->numa_scan_period =clamp (p->numa_scan_period + diff,task_scan_min (p),task_scan_max (p)); -memset (p->numa_faults_locality,0 ,sizeof (p->numa_faults_locality)); + +out: +memset (p->numa_faults_locality,0 , +sizeof (p->numa_faults_locality)); }/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 863/3318 media: vivid: round the height down to the vertical subsampling factor
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maxim Skokov <[email protected]>
[ Upstream commit a2ec28dd2a88d0721fc4a30242861e2be01d4023 ]
syzbot reports a vmalloc out-of-bounds write in the test pattern generator:
BUG: KASAN: vmalloc-out-of-bounds in tpg_fill_plane_pattern drivers/media/common/v4l2-tpg/v4l2-tpg-core.c:2617 [inline] BUG: KASAN: vmalloc-out-of-bounds in tpg_fill_plane_buffer+0x2063/0x4160 drivers/media/common/v4l2-tpg/v4l2-tpg-core.c:2705 Write of size 720 at addr ffffc900038f9d50 by task vivid-000-vid-c/6017
The reproducer requests a 720x49 NV12 capture format, i.e. an odd height for a format whose chroma plane is vertically subsampled.
The buffer size is derived from the height by a truncating division:
sizes[p] = (tpg_g_line_width(&dev->tpg, p) * h) / dev->fmt_cap->vdownsampling[p] + dev->fmt_cap->data_offset[p];
For a single buffer holding both planes tpg_g_line_width() returns 720 + 720 / 2 = 1080, so 1080 * 49 = 52920 bytes get allocated.
tpg_fill_plane_buffer() however emits one chroma line for every two luma lines, i.e. DIV_ROUND_UP(49, 2) = 25 lines, and thus needs 49 * 720 + 25 * 720 = 53280 bytes. The memcpy() of the last chroma line runs 360 bytes past the end of the buffer.
An odd height is not meaningful for a 4:2:0 format in the first place, since the chroma plane would have to hold half a line. Rather than fixing up each of the ~10 sites that divide the height by vdownsampling[], round the height down to a multiple of the vertical subsampling factor where it enters the driver. Adjusting the format is what TRY_FMT/S_FMT are for, and it keeps every later division exact.
Formats without vertical subsampling are unaffected and keep accepting odd heights.
Tested with the syzbot reproducer, which no longer triggers the splat, and by streaming NV12, NV21, YUV420, YVU420 and YUYV at heights 47, 48, 49, 51, 480, 481 and 1081. v4l2-compliance gives identical results before and after (48 of 50 succeeded on the vivid device in both cases; the two failures are pre-existing and unrelated).
--- drivers/media/test-drivers/vivid/vivid-vid-cap.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/media/test-drivers/vivid/vivid-vid-cap.c +13 -0
@@ -574,6 +574,7 @@ int vivid_try_fmt_vid_cap(struct file *file, void *priv,const struct vivid_fmt *fmt;unsigned bytesperline, max_bpl;unsigned factor =1 ; +unsigned int vdiv =1 ;unsigned w, h;unsigned p;bool user_set_csc = !!(mp->flags &V4L2_PIX_FMT_FLAG_SET_CSC );
@@ -626,6 +627,18 @@ int vivid_try_fmt_vid_cap(struct file *file, void *priv, mp->height = r.height / factor; } +/* +* The chroma planes of vertically subsampled formats hold +* height / vdownsampling lines. If the height is not a multiple of +* the subsampling factor, then the buffer size calculations round +* that number down while the test pattern generator rounds it up, +* so the generator writes one line past the end of the buffer. +* Round the height down to keep both in sync. +*/ +for (p =0 ; p < fmt->planes; p++) + vdiv =max (vdiv, fmt->vdownsampling[p]); + mp->height =rounddown (mp->height, vdiv); +/* This driver supports custom bytesperline values */ mp->num_planes = fmt->buffers;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 864/3318 media: cx231xx: preserve I2C transfer length
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Juan Perdomo <[email protected]>
[ Upstream commit a19c9502a69bbd42c18816b09cbefdeb4cb68066 ]
The I2C core stores message lengths in u16, but cx231xx truncates them to u8 when populating cx231xx_i2c_xfer_data. A 0x700-byte read therefore becomes a zero-length request. USB treats zero-length control transfers as OUT regardless of bRequestType, so the IN control pipe trips the usb_submit_urb() direction warning.
Use u16 for buf_size, matching both i2c_msg.len and VENDOR_REQUEST_IN.wLength. Oversized transfers then reach the existing URB_MAX_CTRL_SIZE check and return -EINVAL.
--- drivers/media/usb/cx231xx/cx231xx.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/usb/cx231xx/cx231xx.h +1 -1
@@ -460,7 +460,7 @@ struct cx231xx_i2c_xfer_data {u8 direction;/* 1 - IN, 0 - OUT */ u8 saddr_len;/* sub address len */ u16 saddr_dat;/* sub addr data */ -u8 buf_size;/* buffer size */ +u16 buf_size;/* buffer size */ u8 *p_buffer;/* pointer to the buffer */ };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 865/3318 media: vicodec: zero-initialize stateful decoder heap buffers
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Junrui Luo <[email protected]>
[ Upstream commit 27953c044974baf7e24dee3e9342fe0103dea80c ]
The stateful decoder leaks uninitialized kernel heap memory to userspace. A process that can open the decoder video node gets it back in the CAPTURE buffers it dequeues.
The reference frame and the compressed frame buffer are allocated with kvmalloc() in vicodec_start_streaming(), and the decoder can read them before they have been written. The first frame is allowed to be a P-frame, in which case it is decoded against a reference frame that was never produced, and the padding rows below the visible area are never written for any frame.
Use kvzalloc() for both allocations.
--- drivers/media/test-drivers/vicodec/vicodec-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/test-drivers/vicodec/vicodec-core.c +2 -2
@@ -1599,9 +1599,9 @@ static int vicodec_start_streaming(struct vb2_queue *q, } state->ref_stride = q_data->coded_width * info->luma_alpha_step; - state->ref_frame.buf =kvmalloc (total_planes_size,GFP_KERNEL ); + state->ref_frame.buf =kvzalloc (total_planes_size,GFP_KERNEL ); state->ref_frame.luma = state->ref_frame.buf; - new_comp_frame =kvmalloc (ctx->comp_max_size,GFP_KERNEL ); + new_comp_frame =kvzalloc (ctx->comp_max_size,GFP_KERNEL );if (!state->ref_frame.luma || !new_comp_frame) {kvfree (state->ref_frame.luma);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 866/3318 crypto: atmel-tdes - zero-initialize device state
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit dbe70508d507acd677e67eaf029040f5e3a3b2b3 ]
Commit c659d07f11a3 ("crypto: atmel-tdes - Switch to managed version of kzalloc") accidentally replaced kzalloc() with devm_kmalloc(), so the device state is no longer zeroed.
atmel_tdes_hw_init() tests dd->flags during probe: a stale TDES_FLAGS_INIT skips the hardware reset, and a stale TDES_FLAGS_BUSY makes atmel_tdes_handle_queue() treat the engine as permanently busy, leaving every request queued and never dispatched.
Seen on a SAM9X75 Curiosity: the first TDES request after boot never completes and the TDES interrupt count stays at zero, while the AES and SHA engines on the same SoC work normally.
Switch to devm_kzalloc(), matching the Atmel AES and SHA drivers.
--- drivers/crypto/atmel-tdes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/crypto/atmel-tdes.c +1 -1
@@ -945,7 +945,7 @@ static int atmel_tdes_probe(struct platform_device *pdev)struct resource *tdes_res;int err; - tdes_dd =devm_kmalloc (&pdev->dev,sizeof (*tdes_dd),GFP_KERNEL ); + tdes_dd =devm_kzalloc (&pdev->dev,sizeof (*tdes_dd),GFP_KERNEL );if (!tdes_dd)return -ENOMEM ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 867/3318 crypto: atmel-aes - fix AADLENR for standalone GHASH
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 0dd8cded0e6f8c9635fe1d79d60dc7b2599b099b ]
atmel_aes_gcm_ghash_init() writes dd->total, the request's text length, to AES_AADLENR. But the GHASH it runs hashes the dd->datalen bytes passed
in: the 16-byte length block, or the padded IV when the IV is not 96 bits. The data sheet requires AES_AADLENR to hold the length of that input.
With empty plaintext and empty AAD, dd->total is 0 and the tag comes out wrong. Later requests only pass because dd->total still holds the previous request's length.
This is testmgr's first gcm(aes) vector, so CONFIG_CRYPTO_SELFTESTS=y fails at boot:
alg: aead: atmel-gcm-aes encryption test failed (wrong result) on test vector 0, cfg="in-place (one sglist)"
Without selftests the broken atmel-gcm-aes is preferred at priority 300. Seen on a SAM9X75 Curiosity with 6.18 and current mainline.
Write dd->datalen instead.
--- drivers/crypto/atmel-aes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/crypto/atmel-aes.c +1 -1
@@ -1272,7 +1272,7 @@ static int atmel_aes_gcm_ghash_init(struct atmel_aes_dev *dd)struct atmel_aes_gcm_ctx *ctx =atmel_aes_gcm_ctx_cast (dd->ctx);/* Set the data length. */ -atmel_aes_write (dd,AES_AADLENR , dd->total); +atmel_aes_write (dd,AES_AADLENR , dd->datalen);atmel_aes_write (dd,AES_CLENR ,0 );/* If needed, overwrite the GCM Intermediate Hash Word Registers */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 868/3318 lib/842: reject output overflows from index and short data
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 38ed7182f3491ec1449ff246551e11ad82adba45 ]
The output length passed to sw842_decompress() is the caller's buffer capacity. Indexed copies write 2, 4 or 8 bytes and short-data templates write up to 7, but neither checks that capacity before writing and decrementing p->olen.
Overwriting an undersized destination then underflows p->olen, which is unsigned, so every later bounds check in the stream passes. Subsequent operations keep writing past the destination, and a matching CRC lets sw842_decompress() return success with an output length larger than the capacity the caller supplied.
This is reachable through zram's compressed writeback path. With 842 selected, targeted corruption of the compressed data on its backing device made a KASAN kernel report vmalloc-out-of-bounds writes in __do_index() and sw842_decompress() when zram read the page back.
Check the remaining output before both operations and return -ENOSPC, matching the other output-producing templates.
--- lib/842/842_decompress.c | 5 +++++ 1 file changed, 5 insertions(+)
lib/842/842_decompress.c +5 -0
@@ -165,6 +165,9 @@ static int __do_index(struct sw842_param *p, u8 size, u8 bits, u64 fsize)u64 index, offset, total =round_down (p->out - p->ostart,8 );int ret; +if (size > p->olen) +return -ENOSPC ; + ret =next_bits (p, &index, bits);if (ret)return ret;
@@ -344,6 +347,8 @@ int sw842_decompress(const u8 *in, unsigned int ilen,if (!bytes || bytes >SHORT_DATA_BITS_MAX )return -EINVAL ; +if (bytes > p.olen) +return -ENOSPC ;while (bytes-- >0 ) { ret =next_bits (&p, &tmp,8 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 869/3318 lib/842: require a complete history block for repeat templates
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit deb631649882bbf43f7c2fc79b5990139fd744ba ]
An 842 repeat template copies the preceding eight-byte output block. The decoder rejects a repeat only when no output has been produced. A short-data operation can produce between one and seven bytes before a repeat.
Such a stream makes the repeat copy read before the start of the output buffer. Depending on the surrounding mapping, this can fault or bring preceding memory into the decompressed data.
This is also reachable through zram's compressed writeback path. With 842 selected, targeted corruption of the compressed data on its backing device to a short-data-then-repeat stream made a KASAN kernel report a vmalloc-out-of-bounds read when zram read the page back.
Require at least one complete output block before accepting a repeat.
--- lib/842/842_decompress.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/842/842_decompress.c +1 -1
@@ -309,7 +309,7 @@ int sw842_decompress(const u8 *in, unsigned int ilen,if (ret)return ret; -if (p.out == out)/* no previous bytes */ +if (p.out - p.ostart <8 )/* no complete previous block */ return -EINVAL ;/* copy rep + 1 */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 870/3318 crypto: ccp - Initialize DBC ioctl mutex before registering device
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Runyu Xiao <[email protected]>
[ Upstream commit e9b1d168f2a70c0764d5748893fdf631c504c171 ]
dbc_dev_init() registers the DBC misc device before initializing ioctl_mutex. Once misc_register() publishes the device, userspace can open it and invoke dbc_ioctl() while the mutex is still uninitialized.
Initialize ioctl_mutex before calling misc_register() so the published ioctl callback always sees an initialized mutex.
--- drivers/crypto/ccp/dbc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/crypto/ccp/dbc.c +2 -2
@@ -227,6 +227,8 @@ int dbc_dev_init(struct psp_device *psp) goto cleanup_mbox; } +mutex_init (&dbc_dev->ioctl_mutex); + dbc_dev->char_dev.minor =MISC_DYNAMIC_MINOR ; dbc_dev->char_dev.name ="dbc" ; dbc_dev->char_dev.fops = &dbc_fops;
@@ -235,8 +237,6 @@ int dbc_dev_init(struct psp_device *psp)if (ret) goto cleanup_mbox; -mutex_init (&dbc_dev->ioctl_mutex); -return 0 ; cleanup_mbox:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 871/3318 PM: CPU: Restore synchronize_rcu() to cpu_pm_unregister_notifier()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bradley Morgan <[email protected]>
[ Upstream commit 61f7eee7d4664079fbce821576891c3ee5ccf597 ]
cpu_pm_notify() walks the notifier chain lockless under only rcu_read_lock(). That only works if a removed notifier block is not freed until every concurrent walker is done with it.
The chain used to be an atomic_notifier, whose unregister ends in synchronize_rcu(). Commit b2f6662ac08d ("PM: cpu: Make notifier chain use a raw_spinlock_t") switched it over to a raw_notifier, and in doing so replaced that with raw_notifier_chain_unregister(), which does not synchronize. The grace period quietly went away, so a driver that frees the memory holding its notifier block right after cpu_pm_unregister_notifier() returns can race with a concurrent walker:
cpu1 (idle exit) cpu2 (driver remove)
---------------- --------------------
cpu_pm_notify(CPU_PM_EXIT)
rcu_read_lock()
nb = rcu_dereference_raw(*nl)
cpu_pm_unregister_notifier(&od->nb)
unlink, no grace period
remove() frees od (devm)
nb->notifier_call(nb, ...)
/* use after free */The rcu_read_lock() on cpu1 does not stop cpu2 from freeing the block, and nothing else does. The read side is the idle exit path, so this can hit on any system where a driver with a cpu_pm notifier gets unbound.
Add the grace period back. It is only needed when a notifier was actually removed, so wait on success and return -ENOENT without waiting otherwise. The kerneldoc gets back the "may sleep" note that the same commit dropped.
--- kernel/cpu_pm.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
kernel/cpu_pm.c +8 -1
@@ -10,6 +10,7 @@#include <linux/cpu_pm.h> #include <linux/module.h> #include <linux/notifier.h> +#include <linux/rcupdate.h> #include <linux/spinlock.h> #include <linux/syscore_ops.h>
@@ -76,7 +77,8 @@ EXPORT_SYMBOL_GPL(cpu_pm_register_notifier);* * Remove a driver from the CPU PM notifier list. * -* This function has the same return conditions as raw_notifier_chain_unregister. +* This function may sleep, and has the same return conditions as +* raw_notifier_chain_unregister. */ int cpu_pm_unregister_notifier (struct notifier_block *nb) {
@@ -86,6 +88,11 @@ int cpu_pm_unregister_notifier(struct notifier_block *nb)raw_spin_lock_irqsave (&cpu_pm_notifier.lock, flags); ret =raw_notifier_chain_unregister (&cpu_pm_notifier.chain, nb);raw_spin_unlock_irqrestore (&cpu_pm_notifier.lock, flags); + +/* Wait for the rcu_read_lock() walkers in cpu_pm_notify(). */ +if (!ret) +synchronize_rcu (); +return ret; }EXPORT_SYMBOL_GPL (cpu_pm_unregister_notifier);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 872/3318 affs: validate blocks before freeing them
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kyle Zeng <[email protected]>
[ Upstream commit 78ea2058abf3ee053c0bd9c1b9a77304cb4ae58b ]
affs_free_block() accepts block numbers from on-disk file block tables when truncating or unlinking files. The function currently rejects only block numbers greater than s_partition_size before subtracting s_reserved and using the result to index the in-memory bitmap descriptor array.
That check still accepts reserved blocks and the one-past-end block at s_partition_size. A crafted image can therefore make the subtraction underflow or make the computed bitmap index equal to s_bmap_count, leading to an out-of-bounds access on s_bitmap before the bitmap block is read and updated.
Use the existing AFFS block validity helper so freeing uses the same range as block reads and writes: s_reserved <= block < s_partition_size.
--- fs/affs/bitmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/affs/bitmap.c +1 -1
@@ -46,7 +46,7 @@ affs_free_block(struct super_block *sb, u32 block)pr_debug ("%s(%u)\n" , __func__, block); -if (block > sbi->s_partition_size) +if (!affs_validblock (sb, block)) goto err_range; blk = block - sbi->s_reserved;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 873/3318 f2fs: compress: fix to handle race between truncate and writeback
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chao Yu <[email protected]>
[ Upstream commit c0337e331b065074ce20e4258a578e07dd7e4083 ]
fsstress reports a kernel BUG in f2fs_truncate_partial_cluster():
kernel BUG at fs/f2fs/compress.c:1238!
RIP: 0010:f2fs_truncate_partial_cluster+0x292/0x2a0 Call Trace: <TASK> f2fs_truncate+0xf6/0x210 f2fs_setattr+0x6b7/0x770 notify_change+0x33b/0x520 do_truncate+0xc2/0xf0 vfs_truncate+0x153/0x1d0 ksys_truncate+0x78/0xd0 __x64_sys_truncate+0x16/0x20 do_syscall_64+0xbe/0x540
The root cause is that Thread A (truncate) and Thread B (background writeback or fsync) can race as follows:
Thread A Thread B
- f2fs_setattr
- f2fs_truncate
- f2fs_truncate_blocks
- f2fs_truncate_partial_cluster
- f2fs_is_compressed_cluster
return 1
- f2fs_write_cache_pages
- f2fs_write_multi_pages
- f2fs_write_raw_pages
- f2fs_write_single_data_page dn.data_blkaddr != COMPRESS_ADDR (cluster converted to normal)
- f2fs_prepare_compress_overwrite
- f2fs_is_compressed_cluster
return 0
- return 0
- f2fs_bug_on(sbi, err == 0): BUG!
Writeback path does not acquire i_gc_rwsem or filemap_invalidate_lock. When a compressed cluster fails compression during writeback, it is overwritten with raw data blocks. If Thread A checked f2fs_is_compressed_cluster() before the conversion, but calls f2fs_prepare_compress_overwrite() after the conversion, f2fs_prepare_compress_overwrite() returns 0 because the cluster is no longer a compressed cluster.
To fix this, remove the f2fs_bug_on() and retry checking the cluster status when f2fs_prepare_compress_overwrite() returns 0, so that it can fall back to f2fs_do_truncate_blocks() to handle it as a normal cluster.
--- fs/f2fs/compress.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
fs/f2fs/compress.c +5 -5
@@ -1182,6 +1182,7 @@ int f2fs_truncate_partial_cluster(struct inode *inode, u64 from, bool lock) log_cluster_size;int err; +repeat: err =f2fs_is_compressed_cluster (inode, start_idx);if (err <0 )return err;
@@ -1193,12 +1194,11 @@ int f2fs_truncate_partial_cluster(struct inode *inode, u64 from, bool lock)/* truncate compressed cluster */ err =f2fs_prepare_compress_overwrite (inode, &pagep, start_idx, &fsdata); - -/* should not be a normal cluster */ -f2fs_bug_on (F2FS_I_SB (inode), err ==0 ); - -if (err <=0 ) +if (err <0 )return err; +else if (err ==0 ) +/* the cluster became non-compressed one due to race case */ + goto repeat;if (err >0 ) {struct page **rpages = fsdata;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 874/3318 ata: ahci_st: Do not ignore errors when getting the reset controls
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Niklas Cassel <[email protected]>
[ Upstream commit c74ee9230a8d1d2f6fcbceff55f56f7dd9b9cccd ]
st_ahci_probe_resets() treats any error from devm_reset_control_get() as "reset control not defined" and continues with a NULL reset control:
drv_data->pwr = devm_reset_control_get(dev, "pwr-dwn");
if (IS_ERR(drv_data->pwr)) {
dev_info(dev, "power reset control not defined\n");
drv_data->pwr = NULL;
}This also swallows -EPROBE_DEFER, which is returned when the reset controller providing the reset has not been probed yet. probe() then continues as if the device tree did not specify any reset, so the resets of the SATA IP are never deasserted, and st_ahci_configure_oob() and ahci_platform_init_host() access the MMIO of an IP which is still held in reset and powered down, which can result in an external abort.
The resets are optional in the binding, as they are not part of its required properties, so use devm_reset_control_get_optional(), which returns NULL if the reset is not specified in the device tree, and propagate all other errors.
Note that an absent reset is now indicated by a NULL reset control instead of an error, so the "reset control not defined" messages are dropped.
--- drivers/ata/ahci_st.c | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-)
drivers/ata/ahci_st.c +14 -17
@@ -105,23 +105,20 @@ static int st_ahci_probe_resets(struct ahci_host_priv *hpriv, {struct st_ahci_drv_data *drv_data = hpriv->plat_data; - drv_data->pwr =devm_reset_control_get (dev,"pwr-dwn" ); -if (IS_ERR (drv_data->pwr)) { -dev_info (dev,"power reset control not defined\n" ); - drv_data->pwr =NULL ; - } - - drv_data->sw_rst =devm_reset_control_get (dev,"sw-rst" ); -if (IS_ERR (drv_data->sw_rst)) { -dev_info (dev,"soft reset control not defined\n" ); - drv_data->sw_rst =NULL ; - } - - drv_data->pwr_rst =devm_reset_control_get (dev,"pwr-rst" ); -if (IS_ERR (drv_data->pwr_rst)) { -dev_dbg (dev,"power soft reset control not defined\n" ); - drv_data->pwr_rst =NULL ; - } + drv_data->pwr =devm_reset_control_get_optional (dev,"pwr-dwn" ); +if (IS_ERR (drv_data->pwr)) +return dev_err_probe (dev,PTR_ERR (drv_data->pwr), +"failed to get pwr-dwn reset\n" ); + + drv_data->sw_rst =devm_reset_control_get_optional (dev,"sw-rst" ); +if (IS_ERR (drv_data->sw_rst)) +return dev_err_probe (dev,PTR_ERR (drv_data->sw_rst), +"failed to get sw-rst reset\n" ); + + drv_data->pwr_rst =devm_reset_control_get_optional (dev,"pwr-rst" ); +if (IS_ERR (drv_data->pwr_rst)) +return dev_err_probe (dev,PTR_ERR (drv_data->pwr_rst), +"failed to get pwr-rst reset\n" );return st_ahci_deassert_resets (hpriv, dev); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 875/3318 ata: ahci_st: Assert the power down reset in the probe() error path
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Niklas Cassel <[email protected]>
[ Upstream commit 91e0a7452d7a81e924a499b23f30f3bf85fddbd2 ]
st_ahci_probe_resets() deasserts the "pwr-dwn" reset, but the probe() error path of st_ahci_probe() only releases the host resources, so the SATA IP is left powered up when probe() fails after st_ahci_probe_resets() has succeeded, e.g. when ahci_platform_enable_resources() fails.
The reset is asserted by st_ahci_host_stop(), however ->host_stop() is only called through the ata_host_stop() devres action registered by ata_host_start(), so it does not cover any failure happening before the host has been started.
Factor the assert out into st_ahci_assert_pwrdwn() and call it when either ahci_platform_enable_resources() or ahci_platform_init_host() fails. The "pwr-dwn" reset control is an exclusive one, so asserting it once more from st_ahci_host_stop() is harmless.
No functional change intended for ->host_stop() and st_ahci_suspend().
--- drivers/ata/ahci_st.c | 51 +++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 21 deletions(-)
drivers/ata/ahci_st.c +30 -21
@@ -84,18 +84,27 @@ static int st_ahci_deassert_resets(struct ahci_host_priv *hpriv,return 0 ; } -static void st_ahci_host_stop (struct ata_host *host) +static int st_ahci_assert_pwrdwn (struct ahci_host_priv *hpriv, +struct device *dev) { -struct ahci_host_priv *hpriv = host->private_data;struct st_ahci_drv_data *drv_data = hpriv->plat_data; -struct device *dev = host->dev;int err; -if (drv_data->pwr) { - err =reset_control_assert (drv_data->pwr); -if (err) -dev_err (dev,"unable to pwrdwn\n" ); - } +if (!drv_data->pwr) +return 0 ; + + err =reset_control_assert (drv_data->pwr); +if (err) +dev_err (dev,"unable to pwrdwn\n" ); + +return err; +} + +static void st_ahci_host_stop (struct ata_host *host) +{ +struct ahci_host_priv *hpriv = host->private_data; + +st_ahci_assert_pwrdwn (hpriv, host->dev);ahci_platform_disable_resources (hpriv); }
@@ -160,18 +169,23 @@ static int st_ahci_probe(struct platform_device *pdev) err =ahci_platform_enable_resources (hpriv);if (err) -return err; + goto assert_pwrdwn;st_ahci_configure_oob (hpriv->mmio); err =ahci_platform_init_host (pdev, hpriv, &st_ahci_port_info, &ahci_platform_sht); -if (err) { -ahci_platform_disable_resources (hpriv); -return err; - } +if (err) + goto disable_resources;return 0 ; + +disable_resources: +ahci_platform_disable_resources (hpriv); +assert_pwrdwn: +st_ahci_assert_pwrdwn (hpriv, &pdev->dev); + +return err; }#ifdef CONFIG_PM_SLEEP
@@ -179,20 +193,15 @@ static int st_ahci_suspend(struct device *dev) {struct ata_host *host =dev_get_drvdata (dev);struct ahci_host_priv *hpriv = host->private_data; -struct st_ahci_drv_data *drv_data = hpriv->plat_data;int err; err =ahci_platform_suspend_host (dev);if (err)return err; -if (drv_data->pwr) { - err =reset_control_assert (drv_data->pwr); -if (err) { -dev_err (dev,"unable to pwrdwn" ); -return err; - } - } + err =st_ahci_assert_pwrdwn (hpriv, dev); +if (err) +return err;ahci_platform_disable_resources (hpriv);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 876/3318 platform/x86: hp-bioscfg: fix slab-out-of-bounds write in hp_convert_hexstr_to_str()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Muhammad Bilal <[email protected]>
[ Upstream commit 6a6f3051e705b5c8facb0bf5984d5b981509e0b7 ]
hp_convert_hexstr_to_str() decodes an ACPI string made up of space-separated ASCII hex-byte tokens of the form "0xHH". For example, the four-byte input "0x41" decodes to the single character 'A', and the nine-byte input "0x09 0x41" decodes to "\tA": each token is read in a five-byte step (four characters for the token, one for the trailing delimiter), and produces one output byte, or two if that byte is '\\', '\r', '\n', or '\t', which are written back out as a backslash followed by the matching letter.
The output buffer is sized with kmalloc(input_len, GFP_KERNEL), the raw encoded length of the input, not the decoded length. For well-formed input this is generous, since five input bytes never decode to more than two output bytes. But input_len comes directly from the ACPI string length reported by firmware and isn't guaranteed to respect the five-byte encoding, so a short input_len can undersize the allocation. With input_len == 1, only one byte is allocated, yet decoding still produces at least one output byte plus the NUL terminator written unconditionally afterwards, so two bytes are needed. That terminator write then lands one byte past the end of the allocation.
KASAN caught exactly this during BIOS attribute enumeration on boot, triggered by a one-byte encoded input value:
BUG: KASAN: slab-out-of-bounds in hp_convert_hexstr_to_str+0x6d8/0x710 [hp_bioscfg] Write of size 1 at addr ffff8881032e5d81 by task (udev-worker)/520
The buggy address is located 0 bytes to the right of allocated 1-byte region [ffff8881032e5d80, ffff8881032e5d81)
Size the allocation to the worst-case decoded length instead of the raw input length: two output bytes for every five-byte input chunk (DIV_ROUND_UP(input_len, 5)), plus one byte for the terminator.
--- drivers/platform/x86/hp/hp-bioscfg/bioscfg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/x86/hp/hp-bioscfg/bioscfg.c +1 -1
@@ -445,7 +445,7 @@ int hp_convert_hexstr_to_str(const char *input, u32 input_len, char **str, int * *len =0 ; *str =NULL ; - new_str =kmalloc (input_len,GFP_KERNEL ); + new_str =kmalloc (2 *DIV_ROUND_UP (input_len,5 ) +1 ,GFP_KERNEL );if (!new_str)return -ENOMEM ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 877/3318 ntfs3: bound index head insertions by buffer capacity
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yousef Alhouseen <[email protected]>
[ Upstream commit 2f497d23652ff23da07b08cfb4b4a1c2a87f1892 ]
hdr_insert_head() shifts the existing index entries by ins_bytes without checking that the resulting used size fits within hdr->total. A directory index root larger than the newly allocated index buffer can therefore make the memmove write beyond the buffer.
Reject insertions whose size would exceed the index header capacity and make both split callers unwind the new node when that happens.
--- fs/ntfs3/index.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
fs/ntfs3/index.c +11 -2
@@ -596,6 +596,8 @@ static const struct NTFS_DE *hdr_insert_head(struct INDEX_HDR *hdr,if (!e)return NULL ; +if (size_add (used, ins_bytes) >le32_to_cpu (hdr->total)) +return NULL ;/* Now we just make room for the inserted entries and jam it in. */ to_move = used -le32_to_cpu (hdr->de_off);
@@ -1802,7 +1804,10 @@ static int indx_insert_into_root(struct ntfs_index *indx, struct ntfs_inode *ni, }/* Copy root entries into new buffer. */ -hdr_insert_head (hdr, re, to_move); +if (!hdr_insert_head (hdr, re, to_move)) { + err = -EINVAL ; + goto out_put_n; + }/* Update bitmap attribute. */ indx_mark_used (indx, ni, new_vbn >> indx->idx2vbn_bits);
@@ -1954,7 +1959,11 @@ indx_insert_into_buffer(struct ntfs_index *indx, struct ntfs_inode *ni,/* Copy all the entries <= sp into the new buffer. */ de_t =hdr_first_de (hdr1); to_copy =PtrOffset (de_t, sp); -hdr_insert_head (hdr2, de_t, to_copy); +if (!hdr_insert_head (hdr2, de_t, to_copy)) { + err = -EINVAL ; +put_indx_node (n2); + goto out; + }/* Remove all entries (sp including) from hdr1. */ used = used1 - to_copy - sp_size;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 878/3318 crypto: atmel-tdes - sync output bounce buffer before DMA
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit a38fdcb9c944525ca71e6aaf35e708586d0ae87d ]
The slow path maps its output bounce buffer once at probe time with dma_map_single() and DMA_FROM_DEVICE, then reuses the mapping for every request. After the CPU copies a result from the buffer, dma_sync_single_for_device() must hand the buffer back to the device before the next DMA transfer. The driver omits this call, so cache lines from the previous result can remain valid while the device writes the next one.
This bug was masked by the completion paths calling dma_sync_single_for_device() immediately before the CPU copied the output, where dma_sync_single_for_cpu() was required. For DMA_FROM_DEVICE on ARM926, dma_sync_single_for_device() invokes arm926_dma_map_area(), which invalidates the cache lines. The misplaced call therefore discarded the stale lines before every copy-out.
Commit c8a9a647532f ("crypto: atmel-tdes - fix DMA sync direction") correctly changed the completion paths to call dma_sync_single_for_cpu(). On ARM926, that function invokes arm926_dma_unmap_area(), which is a no-op. The missing pre-DMA dma_sync_single_for_device() was therefore exposed on ARM926-based SAM9X60 and SAM9X7 SoCs.
With CONFIG_CRYPTO_SELFTESTS=y all four DES/TDES algorithms fail on SAM9X75:
alg: skcipher: atmel-ecb-tdes encryption test failed (wrong result) on test vector 2, cfg="unaligned buffer, offset=1"
Call dma_sync_single_for_device() for the output buffer before starting DMA in both atmel_tdes_crypt_pdc() and atmel_tdes_crypt_dma().
--- drivers/crypto/atmel-tdes.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/crypto/atmel-tdes.c +4 -0
@@ -373,6 +373,8 @@ static int atmel_tdes_crypt_pdc(struct atmel_tdes_dev *dd,if (!(dd->flags &TDES_FLAGS_FAST )) {dma_sync_single_for_device (dd->dev, dma_addr_in, length,DMA_TO_DEVICE ); +dma_sync_single_for_device (dd->dev, dma_addr_out, length, +DMA_FROM_DEVICE ); } len32 =DIV_ROUND_UP (length,sizeof (u32));
@@ -405,6 +407,8 @@ static int atmel_tdes_crypt_dma(struct atmel_tdes_dev *dd,if (!(dd->flags &TDES_FLAGS_FAST )) {dma_sync_single_for_device (dd->dev, dma_addr_in, length,DMA_TO_DEVICE ); +dma_sync_single_for_device (dd->dev, dma_addr_out, length, +DMA_FROM_DEVICE ); } addr_width =DMA_SLAVE_BUSWIDTH_4_BYTES ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 879/3318 usb: fotg210: validate endpoint index in ep0 handlers
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Liu Chao <[email protected]>
[ Upstream commit bbddb219b00af0792242a0ad1dc7fb3344f38733 ]
fotg210_set_feature(), fotg210_clear_feature() and fotg210_get_status() use wIndex from the USB setup packet to index the fotg210->ep[] array without verifying that the endpoint number falls below FOTG210_MAX_NUM_EP (5). USB_ENDPOINT_NUMBER_MASK is 0x0f, so a malicious host can issue a setup packet with wIndex 5..15, resulting in an out-of-bounds array read. The resulting wild pointer is then dereferenced in fotg210_set_epnstall() or fotg210_is_epnstall(), which compute an MMIO register offset from ep->epnum and perform iowrite32 through it.
fotg210_clear_feature() is especially problematic: the out-of-bounds access occurs at function entry (source-level) regardless of which USB_RECIP_* case is taken, because the ep pointer is computed before the switch statement.
Add upper-bound checks on the endpoint number derived from wIndex in all three functions. Invalid endpoint numbers in clear_feature now trigger fotg210_request_error() (STALL) instead of silently falling through to fotg210_set_cxdone(). Also add the missing le16_to_cpu() conversion for ctrl->wIndex in fotg210_get_status() to fix a sparse endianness warning.
--- drivers/usb/fotg210/fotg210-udc.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
drivers/usb/fotg210/fotg210-udc.c +11 -6
@@ -661,7 +661,7 @@ static void fotg210_set_feature(struct fotg210_udc *fotg210,case USB_RECIP_ENDPOINT : {u8 epnum; epnum =le16_to_cpu (ctrl->wIndex) &USB_ENDPOINT_NUMBER_MASK ; -if (epnum) +if (epnum && epnum <FOTG210_MAX_NUM_EP )fotg210_set_epnstall (fotg210->ep[epnum]);else fotg210_set_cxstall (fotg210);
@@ -677,8 +677,8 @@ static void fotg210_set_feature(struct fotg210_udc *fotg210,static void fotg210_clear_feature (struct fotg210_udc *fotg210,struct usb_ctrlrequest *ctrl) { -struct fotg210_ep *ep = - fotg210->ep[ctrl->wIndex &USB_ENDPOINT_NUMBER_MASK ]; +u8 epnum =le16_to_cpu (ctrl->wIndex) &USB_ENDPOINT_NUMBER_MASK ; +struct fotg210_ep *ep;switch (ctrl->bRequestType &USB_RECIP_MASK ) {case USB_RECIP_DEVICE :
@@ -688,7 +688,12 @@ static void fotg210_clear_feature(struct fotg210_udc *fotg210,fotg210_set_cxdone (fotg210);break ;case USB_RECIP_ENDPOINT : -if (ctrl->wIndex &USB_ENDPOINT_NUMBER_MASK ) { +if (epnum >=FOTG210_MAX_NUM_EP ) { +fotg210_request_error (fotg210); +break ; + } +if (epnum) { + ep = fotg210->ep[epnum];if (ep->wedged) {fotg210_set_cxdone (fotg210);break ;
@@ -744,8 +749,8 @@ static void fotg210_get_status(struct fotg210_udc *fotg210, fotg210->ep0_data =cpu_to_le16 (0 );break ;case USB_RECIP_ENDPOINT : - epnum = ctrl->wIndex &USB_ENDPOINT_NUMBER_MASK ; -if (epnum) + epnum =le16_to_cpu (ctrl->wIndex) &USB_ENDPOINT_NUMBER_MASK ; +if (epnum && epnum <FOTG210_MAX_NUM_EP ) fotg210->ep0_data =cpu_to_le16 (fotg210_is_epnstall (fotg210->ep[epnum]) <<USB_ENDPOINT_HALT );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 880/3318 ASoC: wm8994: Fix runtime PM imbalance in wm8994_component_probe()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit 480a5528cb6268d626632d45d4a1f29b4c0c11df ]
In wm8994_component_probe(), pm_runtime_get_sync() is invoked before reading the GPIO configuration registers. If either regmap_read() fails, the function jumps to err_irq without calling pm_runtime_put(), leaving the runtime PM usage count incremented and causing a leak.
Add pm_runtime_put() on both GPIO read failure paths before jumping to err_irq.
--- sound/soc/codecs/wm8994.c | 2 ++ 1 file changed, 2 insertions(+)
sound/soc/codecs/wm8994.c +2 -0
@@ -4352,6 +4352,7 @@ static int wm8994_component_probe(struct snd_soc_component *component) ret =regmap_read (control->regmap,WM8994_GPIO_1 , ®);if (ret <0 ) {dev_err (component->dev,"Failed to read GPIO1 state: %d\n" , ret); +pm_runtime_put (component->dev); goto err_irq; }if ((reg &WM8994_GPN_FN_MASK ) !=WM8994_GP_FN_PIN_SPECIFIC ) {
@@ -4364,6 +4365,7 @@ static int wm8994_component_probe(struct snd_soc_component *component) ret =regmap_read (control->regmap,WM8994_GPIO_6 , ®);if (ret <0 ) {dev_err (component->dev,"Failed to read GPIO6 state: %d\n" , ret); +pm_runtime_put (component->dev); goto err_irq; }if ((reg &WM8994_GPN_FN_MASK ) !=WM8994_GP_FN_PIN_SPECIFIC ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 881/3318 ASoC: arizona-jack: Fix runtime PM imbalance in arizona_start_hpdet_acc_id()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit e04dcb895b4622d67164e218a1179785e2c75999 ]
In arizona_start_hpdet_acc_id(), pm_runtime_get_sync() is called to keep the device powered during headphone detection. If setting the HPDET mode or starting the measurement fails and the function jumps to err, pm_runtime_put_autosuspend() was not called while info->hpdet_active was set to false, resulting in a runtime PM usage count leak.
Add pm_runtime_put_autosuspend() in the err error path to keep runtime PM balanced.
--- sound/soc/codecs/arizona-jack.c | 1 + 1 file changed, 1 insertion(+)
sound/soc/codecs/arizona-jack.c +1 -0
@@ -704,6 +704,7 @@ static void arizona_start_hpdet_acc_id(struct arizona_priv *info)snd_soc_jack_report (info->jack,SND_JACK_HEADPHONE ,SND_JACK_LINEOUT |SND_JACK_HEADPHONE ); +pm_runtime_put_autosuspend (arizona->dev); info->hpdet_active = false; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 882/3318 iio: accel: kxcjk-1013: Disable autosuspend on remove
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
[ Upstream commit 1de1206a42741adfb72ca8b37dc71a6bc80cb074 ]
kxcjk1013_probe() enables runtime PM autosuspend with pm_runtime_use_autosuspend(). The probe error path correctly undoes this setting with pm_runtime_dont_use_autosuspend(), but the normal remove path only disables runtime PM.
The runtime PM API requires pm_runtime_use_autosuspend() to be undone with pm_runtime_dont_use_autosuspend() at driver exit unless runtime PM was enabled with devm_pm_runtime_enable(). Leaving the autosuspend flag set therefore leaves the runtime PM state incompletely cleaned up after the driver is unbound.
Add the missing pm_runtime_dont_use_autosuspend() call to the remove path.
This issue was found by manual code inspection.
--- drivers/iio/accel/kxcjk-1013.c | 1 + 1 file changed, 1 insertion(+)
drivers/iio/accel/kxcjk-1013.c +1 -0
@@ -1601,6 +1601,7 @@ static void kxcjk1013_remove(struct i2c_client *client)iio_device_unregister (indio_dev); +pm_runtime_dont_use_autosuspend (&client->dev);pm_runtime_disable (&client->dev);pm_runtime_set_suspended (&client->dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 883/3318 iio: accel: mma9551: disable autosuspend on remove
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
[ Upstream commit 8061720f6be1811478914f8b6143778d70f6033f ]
mma9551_probe() enables runtime PM autosuspend with pm_runtime_use_autosuspend(). The probe error path correctly undoes this setting with pm_runtime_dont_use_autosuspend(), but the normal remove path only disables runtime PM.
The runtime PM API requires pm_runtime_use_autosuspend() to be undone with pm_runtime_dont_use_autosuspend() at driver exit unless runtime PM was enabled with devm_pm_runtime_enable(). Leaving the autosuspend flag set therefore leaves the runtime PM state incompletely cleaned up after the driver is unbound.
Add the missing pm_runtime_dont_use_autosuspend() call to the remove path.
This issue was found by manual code inspection.
--- drivers/iio/accel/mma9551.c | 1 + 1 file changed, 1 insertion(+)
drivers/iio/accel/mma9551.c +1 -0
@@ -516,6 +516,7 @@ static void mma9551_remove(struct i2c_client *client)iio_device_unregister (indio_dev); +pm_runtime_dont_use_autosuspend (&client->dev);pm_runtime_disable (&client->dev);pm_runtime_set_suspended (&client->dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 884/3318 iio: accel: mma9553: disable autosuspend on remove
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
[ Upstream commit 4dda1f9d25fb889649e81bbf015809daa512a049 ]
mma9553_probe() enables runtime PM autosuspend with pm_runtime_use_autosuspend(). The probe error path correctly undoes this setting with pm_runtime_dont_use_autosuspend(), but the normal remove path only disables runtime PM.
The runtime PM API requires pm_runtime_use_autosuspend() to be undone with pm_runtime_dont_use_autosuspend() at driver exit unless runtime PM was enabled with devm_pm_runtime_enable(). Leaving the autosuspend flag set therefore leaves the runtime PM state incompletely cleaned up after the driver is unbound.
Add the missing pm_runtime_dont_use_autosuspend() call to the remove path.
This issue was found by manual code inspection.
--- drivers/iio/accel/mma9553.c | 1 + 1 file changed, 1 insertion(+)
drivers/iio/accel/mma9553.c +1 -0
@@ -1155,6 +1155,7 @@ static void mma9553_remove(struct i2c_client *client)iio_device_unregister (indio_dev); +pm_runtime_dont_use_autosuspend (&client->dev);pm_runtime_disable (&client->dev);pm_runtime_set_suspended (&client->dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 885/3318 iio: adc: at91-sama5d2: disable autosuspend on remove
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
[ Upstream commit 022996906e70c6bc9a7968ee663ebbe314fe1524 ]
at91_adc_probe() enables runtime PM autosuspend with pm_runtime_use_autosuspend(). The probe error path correctly undoes this setting with pm_runtime_dont_use_autosuspend(), but the normal remove path only disables runtime PM.
The runtime PM API requires pm_runtime_use_autosuspend() to be undone with pm_runtime_dont_use_autosuspend() at driver exit unless runtime PM was enabled with devm_pm_runtime_enable(). Leaving the autosuspend flag set therefore leaves the runtime PM state incompletely cleaned up after the driver is unbound.
Add the missing pm_runtime_dont_use_autosuspend() call to the remove path.
This issue was found by manual code inspection.
--- drivers/iio/adc/at91-sama5d2_adc.c | 1 + 1 file changed, 1 insertion(+)
drivers/iio/adc/at91-sama5d2_adc.c +1 -0
@@ -2510,6 +2510,7 @@ static int at91_adc_remove(struct platform_device *pdev)pm_runtime_disable (st->dev);pm_runtime_set_suspended (st->dev); +pm_runtime_dont_use_autosuspend (st->dev);clk_disable_unprepare (st->per_clk);regulator_disable (st->vref);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 886/3318 md/raid5: track disks array size to fix extra_page leak on error paths
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cao Guanghui <[email protected]>
[ Upstream commit 5028ceee173bfcf844469cfb0d1c151d3f6d0296 ]
free_conf() iterates conf->pool_size entries to free extra_page allocations, but pool_size may not reflect the actual size of the conf->disks array. Two scenarios cause a mismatch:
1. setup_conf() early abort: pool_size is 0 (not yet set by grow_stripes) but conf->disks has max_disks entries with extra_page allocated. The loop iterates 0 times, leaking all pages.
2. resize_stripes() Step 4 failure: conf->disks was replaced with a newsize-entry array in Step 3, but pool_size is only updated on success. The loop iterates pool_size (old, smaller value) times, leaking (newsize - pool_size) pages.
Add a dedicated disks_cnt field to track the actual number of entries in conf->disks. Set it immediately after each allocation or replacement (in setup_conf and resize_stripes Step 3, where the array is safely stalled with no concurrent access), and use it in free_conf() instead of pool_size.
This leaves pool_size untouched, preserving the check_reshape() retry behavior that depends on pool_size only being updated on full success.
--- drivers/md/raid5.c | 5 +++-- drivers/md/raid5.h | 1 + 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/md/raid5.c +3 -2
@@ -2649,6 +2649,7 @@ static int resize_stripes(struct r5conf *conf, int newsize) }else {kfree (conf->disks); conf->disks = ndisks; + conf->disks_cnt = newsize; } }else err = -ENOMEM ;
@@ -7454,7 +7455,7 @@ static void free_conf(struct r5conf *conf)free_thread_groups (conf);shrink_stripes (conf);raid5_free_percpu (conf); -for (i =0 ; i < conf->pool_size; i++) +for (i =0 ; i < conf->disks_cnt; i++)if (conf->disks[i].extra_page)put_page (conf->disks[i].extra_page);kfree (conf->disks);
@@ -7637,7 +7638,7 @@ static struct r5conf *setup_conf(struct mddev *mddev)if (!conf->disks) goto abort; - + conf->disks_cnt = max_disks;for (i =0 ; i < max_disks; i++) { conf->disks[i].extra_page =alloc_page (GFP_KERNEL );if (!conf->disks[i].extra_page)
drivers/md/raid5.h +1 -0
@@ -668,6 +668,7 @@ struct r5conf {unsigned long cache_state;struct shrinker shrinker;int pool_size;/* number of disks in stripeheads in pool */ +int disks_cnt;/* number of entries in disks[] array */ spinlock_t device_lock;struct disk_info *disks;struct bio_set bio_split;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 887/3318 md/raid5: fix NULL pointer dereference in raid5_free_percpu
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cao Guanghui <[email protected]>
[ Upstream commit 41742e35268d6a45161b187f51f42bc2ade14d0d ]
If cpuhp_state_add_instance() fails in raid5_alloc_percpu() (e.g., the startup callback raid456_cpu_up_prepare fails due to an allocation failure), conf->node is never added to the cpuhp instance list and its pprev remains NULL (from kzalloc initialization).
When setup_conf() then jumps to abort, free_conf() calls raid5_free_percpu(), which checks conf->percpu (non-NULL, since it was allocated before the cpuhp failure) and proceeds to call cpuhp_state_remove_instance(). This calls hlist_del() on the unhashed node, which dereferences node->pprev (NULL), causing a kernel panic.
Guard the removal with hlist_unhashed_lockless() so that the cpuhp instance is only removed if it was actually added. The lockless variant uses READ_ONCE() for the pprev read, which is safe here because the actual removal is synchronized by cpuhp_state_mutex inside cpuhp_state_remove_instance().
--- drivers/md/raid5.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/md/raid5.c +2 -1
@@ -7441,7 +7441,8 @@ static void raid5_free_percpu(struct r5conf *conf)if (!conf->percpu)return ; -cpuhp_state_remove_instance (CPUHP_MD_RAID5_PREPARE , &conf->node); +if (!hlist_unhashed_lockless (&conf->node)) +cpuhp_state_remove_instance (CPUHP_MD_RAID5_PREPARE , &conf->node);free_percpu (conf->percpu); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 888/3318 md/raid5: validate payload size before calculating payload_len
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Martin Wilck <[email protected]>
[ Upstream commit 38c795105992bbaa3418dd39cbff7348ad17537c ]
Commit b0cc3ae97e89 ("md/raid5: validate payload size before accessing journal metadata") introduced a bounds check to verify that a given payload fits into the current metadata block. In order to calculate the payload size, it has to access the members payload->header.type and payload->size, the offset of which may already be past the end of the metadata block, because the loop condition only checks that the first byte of the payload is inside, and the payload entries have variable sizes. Later on, payload->checksum[0] and payload->checksum[1] are accessed without verifying that payload->size is large enough.
Add another check to make sure that payload->size can be safely accessed, and make sure that the checksum fields are accessible.
This issue has been found by AI (gemma4, Gemini) during a backport review.
--- drivers/md/raid5-cache.c | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-)
drivers/md/raid5-cache.c +26 -8
@@ -2009,27 +2009,36 @@ r5l_recovery_verify_data_checksum_for_mb(struct r5l_log *log,if (!page)return -ENOMEM ; -while (mb_offset <le32_to_cpu (mb->meta_size)) { +while (mb_offset +sizeof (struct r5l_payload_header ) <=le32_to_cpu (mb->meta_size)) { +u32 payload_size;sector_t payload_len; payload = (void *)mb + mb_offset; payload_flush = (void *)mb + mb_offset;if (le16_to_cpu (payload->header.type) ==R5LOG_PAYLOAD_DATA ) { +if (mb_offset +sizeof (struct r5l_payload_data_parity ) + >le32_to_cpu (mb->meta_size)) + goto mismatch; + payload_size =le32_to_cpu (payload->size) >> (PAGE_SHIFT -9 ); payload_len =sizeof (struct r5l_payload_data_parity ) + - (sector_t )sizeof (__le32) * - (le32_to_cpu (payload->size) >> (PAGE_SHIFT -9 )); -if (mb_offset + payload_len >le32_to_cpu (mb->meta_size)) + (sector_t )sizeof (__le32) * payload_size; +if (mb_offset + payload_len >le32_to_cpu (mb->meta_size) || + payload_size <1 ) goto mismatch;if (r5l_recovery_verify_data_checksum ( log, ctx, page, log_offset, payload->checksum[0 ]) <0 ) goto mismatch; }else if (le16_to_cpu (payload->header.type) ==R5LOG_PAYLOAD_PARITY ) { +if (mb_offset +sizeof (struct r5l_payload_data_parity ) + >le32_to_cpu (mb->meta_size)) + goto mismatch; + payload_size =le32_to_cpu (payload->size) >> (PAGE_SHIFT -9 ); payload_len =sizeof (struct r5l_payload_data_parity ) + - (sector_t )sizeof (__le32) * - (le32_to_cpu (payload->size) >> (PAGE_SHIFT -9 )); -if (mb_offset + payload_len >le32_to_cpu (mb->meta_size)) + (sector_t )sizeof (__le32) * payload_size; +if (mb_offset + payload_len >le32_to_cpu (mb->meta_size) || + payload_size < conf->max_degraded) goto mismatch; if (r5l_recovery_verify_data_checksum( log, ctx, page, log_offset,
@@ -2043,6 +2052,9 @@ r5l_recovery_verify_data_checksum_for_mb(struct r5l_log *log, payload->checksum[1]) < 0) goto mismatch; }else if (le16_to_cpu (payload->header.type) ==R5LOG_PAYLOAD_FLUSH ) { +if (mb_offset +sizeof (struct r5l_payload_flush ) + >le32_to_cpu (mb->meta_size)) + goto mismatch; payload_len =sizeof (struct r5l_payload_flush ) + (sector_t )le32_to_cpu (payload_flush->size);if (mb_offset + payload_len >le32_to_cpu (mb->meta_size))
@@ -2104,7 +2116,7 @@ r5c_recovery_analyze_meta_block(struct r5l_log *log, mb_offset =sizeof (struct r5l_meta_block ); log_offset =r5l_ring_add (log, ctx->pos,BLOCK_SECTORS ); -while (mb_offset <le32_to_cpu (mb->meta_size)) { +while (mb_offset +sizeof (struct r5l_payload_header ) <le32_to_cpu (mb->meta_size)) {sector_t payload_len;int dd;
@@ -2114,6 +2126,9 @@ r5c_recovery_analyze_meta_block(struct r5l_log *log,if (le16_to_cpu (payload->header.type) ==R5LOG_PAYLOAD_FLUSH ) {int i, count; +if (mb_offset +sizeof (struct r5l_payload_flush ) > +le32_to_cpu (mb->meta_size)) +return -EINVAL ; payload_len =sizeof (struct r5l_payload_flush ) + (sector_t )le32_to_cpu (payload_flush->size); if (mb_offset + payload_len >
@@ -2138,6 +2153,9 @@ r5c_recovery_analyze_meta_block(struct r5l_log *log, }/* DATA or PARITY payload */ +if (mb_offset +sizeof (struct r5l_payload_data_parity ) > +le32_to_cpu (mb->meta_size)) +return -EINVAL ; payload_len =sizeof (struct r5l_payload_data_parity ) + (sector_t )sizeof (__le32) * (le32_to_cpu (payload->size) >> (PAGE_SHIFT -9 ));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 889/3318 cpufreq: conservative: Restrict deferred downscaling to low load
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shengming Hu <[email protected]>
[ Upstream commit 0fa55c5539173bceaeb400c69b1974aaa0cdb8dc ]
For a shared cpufreq policy, dbs_update() derives the load used for the frequency decision from the maximum load among its CPUs, but it may also record deferred idle periods accumulated by an idle CPU in the policy.
Consequently, a single update can contain both a high decision load from one CPU and multiple deferred idle periods from another CPU. The conservative governor applies the deferred down steps before evaluating the decision load. If that load subsequently triggers an up step, the deferred down steps can outweigh the single up step and produce a net frequency reduction.
This was observed on a policy shared by CPUs 2 and 3. A CPU-bound SCHED_EXT task kept CPU 2 fully utilized while CPU 3 remained idle. On this system, SCHED_EXT generated update-util callbacks less frequently than CFS, resulting in sparse DBS updates such as:
load=100 idle_periods=7 interval=59 ms
load=100 idle_periods=4 interval=39 ms
load=100 idle_periods=2 interval=19 ms
load=100 idle_periods=7 interval=59 ms
With the default 5% frequency step and a 2.6 GHz policy maximum, seven deferred periods reduce the requested frequency by seven 130 MHz steps before the high decision load adds only one step. Repeated updates therefore keep the policy near 530 MHz even though CPU 2 is fully utilized.
There are two load values relevant to this behavior:
* sample_load is calculated from the busy and elapsed time of the current sample.
* decision_load is returned by dbs_update() for the governor's frequency decision. After a long idle interval, it may reuse prev_load to improve the response to a waking task and can therefore differ from sample_load.
The problem is that idle_periods is derived from accumulated idle time and is applied independently of whether the current sample load is in the conservative governor's downscaling region. A high sample load and multiple deferred idle periods can therefore coexist, particularly when updates are sparse.
As suggested by Zhongqiu Han, calculate the sample load separately from the decision load. If no time has elapsed, use prev_load for the sample load as the existing load calculation does, since no load can be calculated for that interval.
Record the maximum sample load for the policy and apply deferred down steps only when it is below down_threshold. This makes deferred downscaling follow the same threshold that the conservative governor normally uses to determine whether the policy load is low enough to reduce the frequency.
The existing code applies deferred down steps whenever idle_periods is valid, regardless of the sample load. When the decision load is in the hold region, the locally adjusted frequency is not submitted unless another frequency-update branch is taken. Thus, when the sample and decision loads are the same and both are in the hold region, this change does not alter the requested frequency.
The difference becomes visible when the decision load causes a frequency update. In particular, if it exceeds up_threshold, the governor applies a single up step after the deferred down steps and submits the resulting request. Multiple deferred down steps can then outweigh that up step and cause a frequency reduction even when the sample load is above down_threshold.
With this change, deferred down steps are skipped whenever the maximum sample load is at or above down_threshold, keeping deferred downscaling consistent with the conservative governor's threshold semantics. The requested frequency may therefore be higher than with the existing behavior when deferred idle periods are present and the decision load causes a frequency update. This is intentional, because the lower request previously resulted from applying deferred downscaling while the sampled policy load was outside the governor's downscaling region. Accelerated deferred downscaling remains available when the policy sample load is below down_threshold, including after a workload has completed and the policy has become idle.
--- drivers/cpufreq/cpufreq_conservative.c | 8 ++++--- drivers/cpufreq/cpufreq_governor.c | 29 +++++++++++++++++++------- drivers/cpufreq/cpufreq_governor.h | 2 ++ 3 files changed, 29 insertions(+), 10 deletions(-)
drivers/cpufreq/cpufreq_conservative.c +5 -3
@@ -85,10 +85,12 @@ static unsigned int cs_dbs_update(struct cpufreq_policy *policy) freq_step =get_freq_step (cs_tuners, policy);/* -* Decrease requested_freq one freq_step for each idle period that -* we didn't update the frequency. +* Apply deferred down steps only when the policy sample load is +* below down_threshold. Otherwise, multiple deferred down steps may +* cause a net frequency decrease outside the downscaling region. */ -if (policy_dbs->idle_periods <UINT_MAX ) { +if (policy_dbs->max_sample_load < cs_tuners->down_threshold && + policy_dbs->idle_periods <UINT_MAX ) {unsigned int freq_steps = policy_dbs->idle_periods * freq_step;if (requested_freq > policy->min + freq_steps)
drivers/cpufreq/cpufreq_governor.c +22 -7
@@ -116,7 +116,8 @@ unsigned int dbs_update(struct cpufreq_policy *policy)struct policy_dbs_info *policy_dbs = policy->governor_data;struct dbs_data *dbs_data = policy_dbs->dbs_data;unsigned int ignore_nice = dbs_data->ignore_nice_load; -unsigned int max_load =0 , idle_periods =UINT_MAX ; +unsigned int max_load =0 , max_sample_load =0 ; +unsigned int idle_periods =UINT_MAX ;unsigned int sampling_rate, io_busy, j;/*
@@ -138,7 +139,7 @@ unsigned int dbs_update(struct cpufreq_policy *policy)struct cpu_dbs_info *j_cdbs = &per_cpu (cpu_dbs, j);u64 update_time, cur_idle_time;unsigned int idle_time, time_elapsed; -unsigned int load; +unsigned int load, sample_load; cur_idle_time =get_cpu_idle_time (j, &update_time, io_busy);
@@ -171,6 +172,20 @@ unsigned int dbs_update(struct cpufreq_policy *policy) j_cdbs->prev_cpu_nice = cur_nice; } +/* +* Compute the sample load separately from the prev_load value +* that may be reused after a long idle interval. The conservative +* governor uses it to decide whether to apply deferred down steps. +* If no time has elapsed, retain the existing behavior and use +* prev_load. +*/ +if (unlikely (!time_elapsed)) + sample_load = j_cdbs->prev_load; +else if (time_elapsed > idle_time) + sample_load =100 * (time_elapsed - idle_time) / time_elapsed; +else + sample_load =0 ; +if (unlikely (!time_elapsed)) {/* * That can only happen when this function is called
@@ -205,11 +220,7 @@ unsigned int dbs_update(struct cpufreq_policy *policy) load = j_cdbs->prev_load; j_cdbs->prev_load =0 ; }else { -if (time_elapsed > idle_time) - load =100 * (time_elapsed - idle_time) / time_elapsed; -else - load =0 ; - + load = sample_load; j_cdbs->prev_load = load; }
@@ -222,9 +233,13 @@ unsigned int dbs_update(struct cpufreq_policy *policy)if (load > max_load) max_load = load; + +if (sample_load > max_sample_load) + max_sample_load = sample_load; } policy_dbs->idle_periods = idle_periods; + policy_dbs->max_sample_load = max_sample_load;return max_load; }
drivers/cpufreq/cpufreq_governor.h +2 -0
@@ -94,6 +94,8 @@ struct policy_dbs_info {/* Multiplier for increasing sample delay temporarily. */ unsigned int rate_mult;unsigned int idle_periods;/* For conservative */ +/* Maximum load from the current policy sample. */ +unsigned int max_sample_load;/* Status indicators */ bool is_shared;/* This object is used by multiple CPUs */ bool work_in_progress;/* Work is being queued up or in progress */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 890/3318 regulator: core: Fix c_rdev reference leak in regulator_resolve_coupling()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit c41b69e9f76fd9632662714c1d37860468e8d773 ]
of_parse_coupled_regulator() returns the coupled regulator with its device reference incremented, but regulator_resolve_coupling() returns without dropping it when the coupled regulator belongs to a different coupler, leaking the reference.
--- drivers/regulator/core.c | 1 + 1 file changed, 1 insertion(+)
drivers/regulator/core.c +1 -0
@@ -5411,6 +5411,7 @@ static void regulator_resolve_coupling(struct regulator_dev *rdev)if (c_rdev->coupling_desc.coupler != coupler) {rdev_err (rdev,"coupler mismatch with %s\n" ,rdev_get_name (c_rdev)); +put_device (&c_rdev->dev);return ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 891/3318 regulator: core: Fix rdev reference leak in regulator_resolve_supply()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit 195bbe5e1c29aa1349655a6162958149c1176034 ]
regulator_resolve_supply() takes a reference on the looked-up regulator with regulator_dev_lookup(), but when the supply resolves to the regulator itself that reference is never dropped: it leaks on the early return and is lost as well when r is replaced with the dummy regulator.
Release the reference before handling the self-referent case.
--- drivers/regulator/core.c | 1 + 1 file changed, 1 insertion(+)
drivers/regulator/core.c +1 -0
@@ -2130,6 +2130,7 @@ static int regulator_resolve_supply(struct regulator_dev *rdev)if (r == rdev) {dev_err (dev,"Supply for %s (%s) resolved to itself\n" , rdev->desc->name, rdev->supply_name); +put_device (&rdev->dev);if (!have_full_constraints ()) { ret = -EINVAL ; goto out;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 892/3318 ASoC: codecs: wm8994: Fix runtime PM leak in wm8994_mic_detect()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit b2c0e5bf750e33b0e1dcdfbb2df8103a06c7caab ]
wm8994_mic_detect() resumes the component before configuring the MICBIAS pins, but the default case of the micbias switch returns -EINVAL right after taking that reference, skipping the pm_runtime_put() on the success path. This leaks a runtime PM reference on every call with an invalid micbias.
Release the reference before returning -EINVAL.
--- sound/soc/codecs/wm8994.c | 1 + 1 file changed, 1 insertion(+)
sound/soc/codecs/wm8994.c +1 -0
@@ -3533,6 +3533,7 @@ int wm8994_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *break ;default :dev_warn (component->dev,"Invalid MICBIAS %d\n" , micbias); +pm_runtime_put (component->dev);return -EINVAL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 893/3318 fpga: Fix of_fpga_mgr_get() reference in fpga_mgr_lock() docs
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit ac02245b0ca28388ba16273f2fa683c90da2e5dc ]
The fpga_mgr_lock() comment lists of_fpga_mgr_put() as a source of a manager pointer. The helper which obtains that pointer is of_fpga_mgr_get(). Correct the reference.
--- drivers/fpga/fpga-mgr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/fpga/fpga-mgr.c +1 -1
@@ -744,7 +744,7 @@ EXPORT_SYMBOL_GPL(fpga_mgr_put);* @mgr: fpga manager * * Given a pointer to FPGA Manager (from fpga_mgr_get() or -* of_fpga_mgr_put()) attempt to get the mutex. The user should call +* of_fpga_mgr_get()) attempt to get the mutex. The user should call * fpga_mgr_lock() and verify that it returns 0 before attempting to * program the FPGA. Likewise, the user should call fpga_mgr_unlock * when done programming the FPGA.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 894/3318 regulator: rt6190: Fix runtime PM imbalance in rt6190_out_enable()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit e0d673e5a5c4084f0da90c06ed3b0bc45e47d679 ]
In rt6190_out_enable(), pm_runtime_get_sync() is called at the start of the function. However, if any subsequent regmap or regulator operation fails, the function returns directly without dropping the runtime PM reference, causing a runtime PM reference leak.
Add an error handling path with pm_runtime_put() to keep the reference count balanced on failure.
--- drivers/regulator/rt6190-regulator.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
drivers/regulator/rt6190-regulator.c +13 -5
@@ -109,19 +109,27 @@ static int rt6190_out_enable(struct regulator_dev *rdev) ret =regmap_raw_read (regmap,RT6190_REG_OUTV , out_cfg,sizeof (out_cfg));if (ret) -return ret; + goto err_pm_put; ret =regulator_enable_regmap (rdev);if (ret) -return ret; + goto err_pm_put; ret =regmap_raw_write (regmap,RT6190_REG_OUTV , out_cfg,sizeof (out_cfg));if (ret) -return ret; + goto err_pm_put; + + ret =regmap_update_bits (regmap,RT6190_REG_SET5 ,RT6190_ENGCP_MASK , +RT6190_ENGCP_MASK ); +if (ret) + goto err_pm_put; + +return 0 ; -return regmap_update_bits (regmap,RT6190_REG_SET5 ,RT6190_ENGCP_MASK , -RT6190_ENGCP_MASK ); +err_pm_put: +pm_runtime_put (data->dev); +return ret; }static int rt6190_out_disable (struct regulator_dev *rdev)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 895/3318 iio: accel: adis16201: fix channel order for buffer mode
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shehryar Ahmad <[email protected]>
[ Upstream commit a4b9f1137b76faab6891ce0bd3f5c02dda7c392d ]
Reshuffle adis16201_channels to ascending scan_index order to avoid data corruption during IIO core demultiplexing since the ADIS driver builds the buffer in channel array order, while the IIO core demultiplexes it in scan_index order.
This changes the raw buffer byte layout for existing adis16201 users reading buffered data directly.
--- drivers/iio/accel/adis16201.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/iio/accel/adis16201.c +5 -5
@@ -202,19 +202,19 @@ static int adis16201_write_raw(struct iio_dev *indio_dev, }static const struct iio_chan_spec adis16201_channels[] = { -ADIS_SUPPLY_CHAN (ADIS16201_SUPPLY_OUT_REG ,ADIS16201_SCAN_SUPPLY ,0 , -12 ), -ADIS_TEMP_CHAN (ADIS16201_TEMP_OUT_REG ,ADIS16201_SCAN_TEMP ,0 ,12 ),ADIS_ACCEL_CHAN (X ,ADIS16201_XACCL_OUT_REG ,ADIS16201_SCAN_ACC_X ,BIT (IIO_CHAN_INFO_CALIBBIAS ),0 ,14 ),ADIS_ACCEL_CHAN (Y ,ADIS16201_YACCL_OUT_REG ,ADIS16201_SCAN_ACC_Y ,BIT (IIO_CHAN_INFO_CALIBBIAS ),0 ,14 ), -ADIS_AUX_ADC_CHAN (ADIS16201_AUX_ADC_REG ,ADIS16201_SCAN_AUX_ADC ,0 ,12 ),ADIS_INCLI_CHAN (X ,ADIS16201_XINCL_OUT_REG ,ADIS16201_SCAN_INCLI_X ,BIT (IIO_CHAN_INFO_CALIBBIAS ),0 ,12 ),ADIS_INCLI_CHAN (Y ,ADIS16201_YINCL_OUT_REG ,ADIS16201_SCAN_INCLI_Y ,BIT (IIO_CHAN_INFO_CALIBBIAS ),0 ,12 ), -IIO_CHAN_SOFT_TIMESTAMP (7 ) +ADIS_SUPPLY_CHAN (ADIS16201_SUPPLY_OUT_REG ,ADIS16201_SCAN_SUPPLY ,0 , +12 ), +ADIS_AUX_ADC_CHAN (ADIS16201_AUX_ADC_REG ,ADIS16201_SCAN_AUX_ADC ,0 ,12 ), +ADIS_TEMP_CHAN (ADIS16201_TEMP_OUT_REG ,ADIS16201_SCAN_TEMP ,0 ,12 ), +IIO_CHAN_SOFT_TIMESTAMP (7 ), };static const struct iio_info adis16201_info = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 896/3318 ata: libata-scsi: abort multi-sector pass-through commands when multi_count is 0
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hui Peng <[email protected]>
[ Upstream commit 3bab8c7e0c6ba187a47163a1f71477213a278c48 ]
When an ATA_12, ATA_16, or ATA_32 pass-through command with a multi-sector PIO command opcode (ATA_CMD_READ_MULTI, ATA_CMD_WRITE_MULTI, ATA_CMD_READ_MULTI_EXT, ATA_CMD_WRITE_MULTI_EXT, or ATA_CMD_WRITE_MULTI_FUA_EXT) is submitted via SG_IO on a device where multiple-sector mode is not configured (dev->multi_count == 0), ata_scsi_pass_thru() currently logs a warning and still dispatches the taskfile. When the DRQ interrupt fires, ata_pio_sectors() triggers WARN_ON_ONCE(qc->dev->multi_count == 0) and computes
nsect = min((qc->nbytes - qc->curbytes) / qc->sect_size, 0) = 0, failing to transfer any sectors:
ata1.00: invalid multi_count 1 ignored
WARNING: drivers/ata/libata-sff.c:666 at ata_pio_sectors+0x27d/0x300 Call Trace: <IRQ> ata_sff_hsm_move+0x211/0x22e0 __ata_sff_port_intr+0x1c8/0x520 ata_bmdma_port_intr+0xa1/0x5b0 ata_bmdma_interrupt+0x1f5/0x550
Per ACS-3 section 7.12.7.21, if IDENTIFY DEVICE word 59 bit 8 is cleared to zero (multi_count == 0) and a READ MULTIPLE or WRITE MULTIPLE command is received without a preceding successful SET MULTIPLE MODE command, the device returns command aborted (ABRT). Per the SAT specification, an ABRT error translates to the ABORTED COMMAND sense key with NO ADDITIONAL SENSE INFORMATION (0x00, 0x00).
Fail multi-sector taskfile commands in ata_scsi_pass_thru() with ata_scsi_set_sense(dev, scmd, ABORTED_COMMAND, 0, 0) when dev->multi_count == 0.
--- drivers/ata/libata-scsi.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/ata/libata-scsi.c +5 -0
@@ -3156,6 +3156,11 @@ static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc)if (is_multi_taskfile (tf)) {unsigned int multi_count =1 << (cdb[1 ] >>5 ); +if (!dev->multi_count) { +ata_scsi_set_sense (dev, scmd,ABORTED_COMMAND ,0 ,0 ); +return 1 ; + } +/* compare the passed through multi_count * with the cached multi_count of libata */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 897/3318 PCI: pciehp: Make pciehp_poll_mode parameter read-only
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Runyu Xiao <[email protected]>
[ Upstream commit 5ab17178fca6026d329cb6ced33c30f3b7d3e50a ]
pciehp_request_irq() and pciehp_free_irq() select different resources based on the global pciehp_poll_mode parameter. The parameter is currently writable through sysfs, so changing it while a controller is active can make teardown try to stop a nonexistent polling thread or call free_irq() for an IRQ that was not requested.
Keep the parameter available for boot and module configuration, but prevent runtime changes to the registration mode.
Reproducer:
Boot an x86_64 guest in QEMU with a native PCIe hotplug root port and an e1000 device, using these device options:
-device pcie-root-port,id=rp1,chassis=1,slot=1 -device e1000,bus=rp1
Pass "pcie_ports=native pciehp.pciehp_poll_mode=1" to the guest kernel. As root in the guest, replace the device name below with a bound pciehp service device and run:
# dev=0000:00:1c.0:pcie004
# driver=/sys/bus/pci_express/drivers/pciehp
# echo 0 > /sys/module/pciehp/parameters/poll_mode # echo "$dev" > "$driver/unbind" # dmesg | grep 'Trying to free already-free IRQ'
The unfixed kernel accepts the runtime mode change and reports the warning when the service device is removed. The fixed kernel rejects the write and removes the device without the warning. The mode change is a deliberate privileged test action and is not expected during ordinary operation.
--- drivers/pci/hotplug/pciehp_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/hotplug/pciehp_core.c +1 -1
@@ -37,7 +37,7 @@ int pciehp_poll_time;* not really modular, but the easiest way to keep compat with existing * bootargs behaviour is to continue using module_param here. */ -module_param (pciehp_poll_mode, bool,0644 ); +module_param (pciehp_poll_mode, bool,0444 );module_param (pciehp_poll_time, int,0644 );MODULE_PARM_DESC (pciehp_poll_mode,"Using polling mechanism for hot-plug events or not" );MODULE_PARM_DESC (pciehp_poll_time,"Polling mechanism frequency, in seconds" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 898/3318 seccomp: restore knotif->state when SECCOMP_ADDFD_FLAG_SEND is interrupted
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hui Peng <[email protected]>
[ Upstream commit 832b9b176be06a20747a267db6bc0010a24b74f4 ]
In seccomp_notify_addfd(), when SECCOMP_ADDFD_FLAG_SEND is set in addfd.flags, knotif->state is optimistically transitioned from SECCOMP_NOTIFY_SENT to SECCOMP_NOTIFY_REPLIED before waking the tracee and waiting on kaddfd.completion:
if (addfd.flags & SECCOMP_ADDFD_FLAG_SEND) {
knotif->state = SECCOMP_NOTIFY_REPLIED;
...
}If wait_for_completion_interruptible(&kaddfd.completion) is interrupted by a signal before the tracee dequeues the kaddfd request (!list_empty(&kaddfd.list)), seccomp_notify_addfd() removes kaddfd from knotif->addfd and returns -EINTR to the supervisor without having installed the file descriptor.
However, knotif->state is left as SECCOMP_NOTIFY_REPLIED (with knotif->error == 0 and knotif->val == 0). This causes two problems:
1. When the tracee runs in do_user_notif(), it checks
if (knotif.state != SECCOMP_NOTIFY_REPLIED) after calling seccomp_handle_addfd(). Because knotif->state is already SECCOMP_NOTIFY_REPLIED, the tracee exits the notification wait loop prematurely and returns 0 from the trapped syscall without the file descriptor ever having been installed.
2. If the supervisor retries SECCOMP_IOCTL_NOTIF_ADDFD or SECCOMP_IOCTL_NOTIF_SEND before the tracee runs, it fails with -EINPROGRESS because knotif->state is no longer SECCOMP_NOTIFY_SENT.
Fix this by restoring knotif->state back to SECCOMP_NOTIFY_SENT if SECCOMP_ADDFD_FLAG_SEND was set and kaddfd was not consumed before the interrupted wait. Also add a seccomp_bpf selftest (user_notification_addfd_send_interrupted) covering this race.
Tested in QEMU against Linux 7.3.0-rc3 using the user_notification_addfd_send_interrupted selftest added in this patch (./seccomp_bpf -t user_notification_addfd_send_interrupted): on the unfixed kernel the test fails because the retry ioctl(listener, SECCOMP_IOCTL_NOTIF_ADDFD, &addfd) returns -EINPROGRESS (-1) and the tracee prematurely exits do_user_notif() with return value 0 instead of FD 42, whereas with this patch applied the test passes.
--- kernel/seccomp.c | 7 +- tools/testing/selftests/seccomp/seccomp_bpf.c | 179 ++++++++++++++++++ 2 files changed, 184 insertions(+), 2 deletions(-)
kernel/seccomp.c +5 -2
@@ -1753,10 +1753,13 @@ static long seccomp_notify_addfd(struct seccomp_filter *filter,* We need to check again if the addfd request has been handled, * and if not, we will remove it from the queue. */ -if (list_empty (&kaddfd.list)) +if (list_empty (&kaddfd.list)) { ret = kaddfd.ret; -else + }else {list_del (&kaddfd.list); +if (addfd.flags &SECCOMP_ADDFD_FLAG_SEND ) + knotif->state =SECCOMP_NOTIFY_SENT ; + } out_unlock:mutex_unlock (&filter->notify_lock);
tools/testing/selftests/seccomp/seccomp_bpf.c +179 -0
185 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 899/3318 staging: media: imx: csc-scaler: fix ipu_image_convert_run leak on queue error
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cong Nguyen <[email protected]>
[ Upstream commit 07643be7b1eff94f7a49e142c1e92a1029d3db21 ]
device_run() allocates an ipu_image_convert_run object and, on the success path, hands it to the IPU image conversion core via ipu_image_convert_queue(); the run object is then freed asynchronously by the completion callback ipu_ic_pp_complete().
However, if ipu_image_convert_queue() fails, the core never takes ownership of the run object and the completion callback is never invoked. The "err" label finishes the mem2mem job and reports the buffers as errored, but never frees the run object that was just allocated, leaking it on every queue failure.
Free the run object in the error path. There is no risk of a double
free: the completion callback only runs after the object was successfully queued, which is mutually exclusive with reaching the error path. It is also safe for the earlier "goto err" on allocation failure, since run is NULL there and kfree(NULL) is a no-op.
--- drivers/staging/media/imx/imx-media-csc-scaler.c | 1 + 1 file changed, 1 insertion(+)
drivers/staging/media/imx/imx-media-csc-scaler.c +1 -0
@@ -144,6 +144,7 @@ static void device_run(void *_ctx)v4l2_m2m_buf_done (src_buf,VB2_BUF_STATE_ERROR );v4l2_m2m_buf_done (dst_buf,VB2_BUF_STATE_ERROR );v4l2_m2m_job_finish (priv->m2m_dev, ctx->fh.m2m_ctx); +kfree (run); }/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 900/3318 media: ir_toy: Validate the maximum tx carrier
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Young <[email protected]>
[ Upstream commit 27303392aa87b61692faadec8b00e0ca66bf98dd ]
Reject any carrier the hardware cannot generate. This also fixes a divide by zero if a carrier of U32_MAX/16 is set.
--- drivers/media/rc/ir_toy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/rc/ir_toy.c +1 -1
@@ -373,7 +373,7 @@ static int irtoy_tx_carrier(struct rc_dev *rc, uint32_t carrier)u8 buf[3 ];int err; -if (carrier <11800 ) +if (carrier <11800 || carrier >3000000 )return -EINVAL ; buf[0 ] =0x06 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 901/3318 media: meson-ir-tx: Prevent divide by zero in meson_irtx_prepare_pulse()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Young <[email protected]>
[ Upstream commit 05d9c515cf13056875abbf73adb4a19dd7ba32eb ]
If an excesively high carrier is set, meson_irtx_prepare_pulse() will cause a divide by zero if tb_us is 0. Prevent such a carrier from being set.
--- drivers/media/rc/meson-ir-tx.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/media/rc/meson-ir-tx.c +3 -0
@@ -219,6 +219,9 @@ static int meson_irtx_set_carrier(struct rc_dev *rc, u32 carrier)if (carrier ==0 )return -EINVAL ; +if (!DIV_ROUND_CLOSEST (USEC_PER_SEC , carrier)) +return -EINVAL ; + ir->carrier = carrier;meson_irtx_set_mod (ir);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 902/3318 ASoC: ti: davinci-mcasp: Fix runtime PM imbalance in __davinci_mcasp_set_clkdiv()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit ba593d662183de74d2b733b4c6e8cd26f04f0a65 ]
In __davinci_mcasp_set_clkdiv(), pm_runtime_get_sync() is called at the entry of the function. If an invalid div_id is provided, the function hits the default switch case and directly returns -EINVAL without calling pm_runtime_put(), resulting in a runtime PM reference leak.
Add pm_runtime_put() in the default case before returning -EINVAL.
--- sound/soc/ti/davinci-mcasp.c | 1 + 1 file changed, 1 insertion(+)
sound/soc/ti/davinci-mcasp.c +1 -0
@@ -649,6 +649,7 @@ static int __davinci_mcasp_set_clkdiv(struct davinci_mcasp *mcasp, int div_id,break ;default : +pm_runtime_put (mcasp->dev);return -EINVAL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 903/3318 arm64: dts: ti: k3-am62a7-sk: Set SD clock pin as OUTPUT
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Judith Mendez <[email protected]>
[ Upstream commit cfad4f39124b218c2cbbbe17e742971abc9ac8b4 ]
MMC clock pins must be configured as OUTPUT-only per TRM [0] with receiver disabled (RXACTIVE bit = 0). Change MMC CLK pins from PIN_INPUT to PIN_OUTPUT to match documentation.
[0] https://www.ti.com/lit/pdf/spruj16 Rev. C: Table 12-257. MMCSDi I/O Signals
--- arch/arm64/boot/dts/ti/k3-am62a7-sk.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/ti/k3-am62a7-sk.dts +1 -1
@@ -175,7 +175,7 @@ AM62AX_IOPAD(0x0b4, PIN_INPUT_PULLUP, 1) /* (K24) GPMC0_CSn3.I2C2_SDA */ main_mmc1_pins_default: main-mmc1-default-pins { pinctrl-single,pins = < AM62AX_IOPAD(0x23c, PIN_INPUT, 0) /* (A21) MMC1_CMD */ - AM62AX_IOPAD(0x234, PIN_INPUT, 0) /* (B22) MMC1_CLK */ + AM62AX_IOPAD(0x234, PIN_OUTPUT, 0) /* (B22) MMC1_CLK */ AM62AX_IOPAD(0x230, PIN_INPUT, 0) /* (A22) MMC1_DAT0 */ AM62AX_IOPAD(0x22c, PIN_INPUT, 0) /* (B21) MMC1_DAT1 */ AM62AX_IOPAD(0x228, PIN_INPUT, 0) /* (C21) MMC1_DAT2 */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 904/3318 arm64: dts: ti: k3-am625-beagleplay: Set MMC clock pins as OUTPUT
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Judith Mendez <[email protected]>
[ Upstream commit c074abebc76f0e59d13dea499f582806c6a3d94d ]
MMC clock pins must be configured as OUTPUT-only per TRM [0] with receiver disabled (RXACTIVE bit = 0). Change MMC CLK pins from PIN_INPUT to PIN_OUTPUT to match documentation.
[0] https://www.ti.com/lit/pdf/spruiv7 Rev. C: Table 12-246. MMCSDi I/O Signals
--- arch/arm64/boot/dts/ti/k3-am625-beagleplay.dts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/arm64/boot/dts/ti/k3-am625-beagleplay.dts +3 -3
@@ -323,7 +323,7 @@ AM62X_IOPAD(0x012c, PIN_OUTPUT, 0) /* (AD19) RGMII1_TX_CTL */ emmc_pins_default: emmc-default-pins { pinctrl-single,pins = < AM62X_IOPAD(0x0220, PIN_INPUT, 0) /* (Y3) MMC0_CMD */ - AM62X_IOPAD(0x0218, PIN_INPUT, 0) /* (AB1) MMC0_CLK */ + AM62X_IOPAD(0x0218, PIN_OUTPUT, 0) /* (AB1) MMC0_CLK */ AM62X_IOPAD(0x0214, PIN_INPUT, 0) /* (AA2) MMC0_DAT0 */ AM62X_IOPAD(0x0210, PIN_INPUT, 0) /* (AA1) MMC0_DAT1 */ AM62X_IOPAD(0x020c, PIN_INPUT, 0) /* (AA3) MMC0_DAT2 */
@@ -344,7 +344,7 @@ AM62X_IOPAD(0x01c4, PIN_INPUT, 7) /* (B14) SPI0_D1_GPIO1_19 */ sd_pins_default: sd-default-pins { pinctrl-single,pins = < AM62X_IOPAD(0x023c, PIN_INPUT, 0) /* (A21) MMC1_CMD */ - AM62X_IOPAD(0x0234, PIN_INPUT, 0) /* (B22) MMC1_CLK */ + AM62X_IOPAD(0x0234, PIN_OUTPUT, 0) /* (B22) MMC1_CLK */ AM62X_IOPAD(0x0230, PIN_INPUT, 0) /* (A22) MMC1_DAT0 */ AM62X_IOPAD(0x022c, PIN_INPUT, 0) /* (B21) MMC1_DAT1 */ AM62X_IOPAD(0x0228, PIN_INPUT, 0) /* (C21) MMC1_DAT2 */
@@ -356,7 +356,7 @@ AM62X_IOPAD(0x0240, PIN_INPUT, 7) /* (D17) MMC1_SDCD.GPIO1_48 */ wifi_pins_default: wifi-default-pins { pinctrl-single,pins = < AM62X_IOPAD(0x0120, PIN_INPUT, 0) /* (C24) MMC2_CMD */ - AM62X_IOPAD(0x0118, PIN_INPUT, 0) /* (D25) MMC2_CLK */ + AM62X_IOPAD(0x0118, PIN_OUTPUT, 0) /* (D25) MMC2_CLK */ AM62X_IOPAD(0x0114, PIN_INPUT, 0) /* (B24) MMC2_DAT0 */ AM62X_IOPAD(0x0110, PIN_INPUT, 0) /* (C25) MMC2_DAT1 */ AM62X_IOPAD(0x010c, PIN_INPUT, 0) /* (E23) MMC2_DAT2 */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 905/3318 arm64: dts: ti: k3-am62x-sk-common: Set SD clock pin as OUTPUT
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Judith Mendez <[email protected]>
[ Upstream commit 1e2e5016bda94b2bcd86258b5eb77fe3006639a0 ]
MMC clock pins must be configured as OUTPUT-only per TRM [0] with receiver disabled (RXACTIVE bit = 0). Change MMC CLK pins from PIN_INPUT to PIN_OUTPUT to match documentation.
[0] https://www.ti.com/lit/pdf/spruiv7 Rev. C: Table 12-246. MMCSDi I/O Signals
--- arch/arm64/boot/dts/ti/k3-am62x-sk-common.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/ti/k3-am62x-sk-common.dtsi +1 -1
@@ -184,7 +184,7 @@ AM62X_IOPAD(0x1f8, PIN_INPUT, 0) /* (AC2/V4) MMC0_DAT7 */ main_mmc1_pins_default: main-mmc1-default-pins { pinctrl-single,pins = < AM62X_IOPAD(0x23c, PIN_INPUT, 0) /* (A21/C18) MMC1_CMD */ - AM62X_IOPAD(0x234, PIN_INPUT, 0) /* (B22/A20) MMC1_CLK */ + AM62X_IOPAD(0x234, PIN_OUTPUT, 0) /* (B22/A20) MMC1_CLK */ AM62X_IOPAD(0x230, PIN_INPUT, 0) /* (A22/A19) MMC1_DAT0 */ AM62X_IOPAD(0x22c, PIN_INPUT, 0) /* (B21/B19) MMC1_DAT1 */ AM62X_IOPAD(0x228, PIN_INPUT, 0) /* (C21/B20) MMC1_DAT2 */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 906/3318 arm64: dts: ti: k3-am62-phycore-som: Set eMMC clock pin as OUTPUT
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Judith Mendez <[email protected]>
[ Upstream commit a3c2b6c52e02d58941c0b91bfba052788aeff890 ]
MMC clock pins must be configured as OUTPUT-only per TRM [0] with receiver disabled (RXACTIVE bit = 0). Change MMC CLK pins from PIN_INPUT to PIN_OUTPUT to match documentation.
[0] https://www.ti.com/lit/pdf/spruiv7 Rev. C: Table 12-246. MMCSDi I/O Signals
--- arch/arm64/boot/dts/ti/k3-am62-phycore-som.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/ti/k3-am62-phycore-som.dtsi +1 -1
@@ -121,7 +121,7 @@ AM62X_IOPAD(0x15c, PIN_INPUT, 0) /* (AB22) MDIO0_MDIO */ main_mmc0_pins_default: main-mmc0-default-pins { pinctrl-single,pins = < AM62X_IOPAD(0x220, PIN_INPUT_PULLUP, 0) /* (Y3) MMC0_CMD */ - AM62X_IOPAD(0x218, PIN_INPUT_PULLDOWN, 0) /* (AB1) MMC0_CLK */ + AM62X_IOPAD(0x218, PIN_OUTPUT_PULLDOWN, 0) /* (AB1) MMC0_CLK */ AM62X_IOPAD(0x214, PIN_INPUT_PULLUP, 0) /* (AA2) MMC0_DAT0 */ AM62X_IOPAD(0x210, PIN_INPUT_PULLUP, 0) /* (AA1) MMC0_DAT1 */ AM62X_IOPAD(0x20c, PIN_INPUT_PULLUP, 0) /* (AA3) MMC0_DAT2 */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 907/3318 drm/mali-dp: Fix runtime PM leak in malidp_crtc_atomic_enable()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit 73ef663c75688168e31dbe9c585b939be410a945 ]
malidp_crtc_atomic_enable() resumes the device with pm_runtime_get_sync() and returns early when the resume fails. The runtime PM usage count is incremented by pm_runtime_get_sync() even when the resume fails, so returning without dropping the reference leaks it and, once the error has been hit, prevents the device from ever suspending again.
Drop the runtime PM reference with pm_runtime_put_noidle() on the resume failure path before returning.
--- drivers/gpu/drm/arm/malidp_crtc.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/arm/malidp_crtc.c +1 -0
@@ -56,6 +56,7 @@ static void malidp_crtc_atomic_enable(struct drm_crtc *crtc,if (err <0 ) {DRM_DEBUG_DRIVER ("Failed to enable runtime power management: %d\n" , err); +pm_runtime_put_noidle (crtc->dev->dev);return ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 908/3318 nilfs2: fix checkpoint root lifetime on sysfs errors
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aldo Ariel Panzardo <[email protected]>
[ Upstream commit 2cb947450e0e5a88bb6bb5fca6dbfda1910e74b0 ]
nilfs_find_or_create_root() links a new checkpoint root into the checkpoint tree and drops ns_cptree_lock before creating the root's sysfs group. If nilfs_sysfs_create_snapshot_group() then fails, the root is freed while it is still reachable from ns_cptree, so a concurrent nilfs_lookup_root() can dereference freed memory.
nilfs_sysfs_create_snapshot_group() allocates memory and creates sysfs nodes and may sleep, so it cannot run under the ns_cptree_lock spinlock. Reorder the creation path so that the sysfs group is set up before the root is published: initialize the root, create its sysfs group outside the lock, and only then take ns_cptree_lock to link it into the tree. On sysfs failure the root was never visible and is freed directly; in the unlikely case a root with the same checkpoint number is already present, the sysfs group of the new root is removed before it is freed. Concurrent insertions are already serialized by ns_snapshot_mount_mutex, so only the race against nilfs_lookup_root() needs to be closed.
Because kobject_put() does not guarantee that the embedded kobject's release callback has run by the time it returns (CONFIG_DEBUG_KOBJECT_RELEASE defers it), the container must not be freed until the release completes. Keep that wait_for_completion() of snapshot_kobj_unregister inside the sysfs helpers, so both the creation error path and nilfs_sysfs_delete_snapshot_group() wait for the release before their callers free the root.
--- fs/nilfs2/sysfs.c | 5 ++++- fs/nilfs2/the_nilfs.c | 34 +++++++++++++++++++++------------- 2 files changed, 25 insertions(+), 14 deletions(-)
fs/nilfs2/sysfs.c +4 -1
@@ -195,8 +195,10 @@ int nilfs_sysfs_create_snapshot_group(struct nilfs_root *root) "%llu", root->cno); } -if (err) +if (err) {kobject_put (&root->snapshot_kobj); +wait_for_completion (&root->snapshot_kobj_unregister); + }return err; }
@@ -204,6 +206,7 @@ int nilfs_sysfs_create_snapshot_group(struct nilfs_root *root)void nilfs_sysfs_delete_snapshot_group (struct nilfs_root *root) {kobject_put (&root->snapshot_kobj); +wait_for_completion (&root->snapshot_kobj_unregister); }/************************************************************************
fs/nilfs2/the_nilfs.c +21 -13
@@ -865,6 +865,26 @@ nilfs_find_or_create_root(struct the_nilfs *nilfs, __u64 cno)if (!new)return NULL ; + new->cno = cno; + new->ifile =NULL ; + new->nilfs = nilfs; +refcount_set (&new->count,1 ); +atomic64_set (&new->inodes_count,0 ); +atomic64_set (&new->blocks_count,0 ); + +/* +* Register the sysfs group before publishing the root in the +* checkpoint tree. nilfs_sysfs_create_snapshot_group() can sleep, +* so it must run outside ns_cptree_lock; creating it first also +* ensures a concurrent nilfs_lookup_root() can never observe a root +* whose sysfs registration later fails and gets freed. +*/ + err =nilfs_sysfs_create_snapshot_group (new); +if (err) { +kfree (new); +return NULL ; + } +spin_lock (&nilfs->ns_cptree_lock); p = &nilfs->ns_cptree.rb_node;
@@ -881,29 +901,17 @@ nilfs_find_or_create_root(struct the_nilfs *nilfs, __u64 cno) }else {refcount_inc (&root->count);spin_unlock (&nilfs->ns_cptree_lock); +nilfs_sysfs_delete_snapshot_group (new);kfree (new);return root; } } - new->cno = cno; - new->ifile =NULL ; - new->nilfs = nilfs; -refcount_set (&new->count,1 ); -atomic64_set (&new->inodes_count,0 ); -atomic64_set (&new->blocks_count,0 ); -rb_link_node (&new->rb_node, parent, p);rb_insert_color (&new->rb_node, &nilfs->ns_cptree);spin_unlock (&nilfs->ns_cptree_lock); - err =nilfs_sysfs_create_snapshot_group (new); -if (err) { -kfree (new); - new =NULL ; - } -return new; }
Signature · 1 line
2.53.0