6.18.64-rc1 review
Subsystems (3)
Greg Kroah-Hartman
maintainerPATCH 583/686 xfarray: dont crash when sorting if array element crosses a folio
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Darrick J. Wong <[email protected]>
[ Upstream commit 329750292e9dfbb594b375d7b30cf5ddb58b7bb9 ]
LOLLM points out that if an array element crosses a folio boundary, xfile_get_folio returns a NULL folio pointer. If this happens, si->folio is also set to NULL, and calling folio_pos/folio_address will just crash the kernel. Teach this function to handle this condition by falling back to reading the array element into scratchpad memory.
--- fs/xfs/scrub/xfarray.c | 69 ++++++++++++++++++++++++++++-------------- 1 file changed, 47 insertions(+), 22 deletions(-)
fs/xfs/scrub/xfarray.c +47 -22
@@ -794,6 +794,46 @@ xfarray_sort_scan_done( si->folio =NULL ; } +static int +xfarray_sort_load_folio ( +struct xfarray_sortinfo *si, +xfarray_idx_t idx, +loff_t idx_pos) +{ +struct folio *folio; +loff_t next_pos; + + folio =xfile_get_folio (si->array->xfile, idx_pos, si->array->obj_size, +XFILE_ALLOC ); +if (IS_ERR (folio)) +return PTR_ERR (folio); + si->folio = folio; + +/* No folio? Get the caller to read into the scratchpad. */ +if (!si->folio) +return 0 ; + + si->first_folio_idx =xfarray_idx (si->array, +folio_pos (si->folio) + si->array->obj_size -1 ); + + next_pos =folio_next_pos (si->folio); + si->last_folio_idx =xfarray_idx (si->array, next_pos -1 ); +if (xfarray_pos (si->array, si->last_folio_idx +1 ) > next_pos) + si->last_folio_idx--; + +/* +* If this folio still doesn't cover the desired element, it must cross +* a folio boundary. Get the caller to read into the scratchpad. +*/ +if (idx < si->first_folio_idx || idx > si->last_folio_idx) { +xfarray_sort_scan_done (si); +return 0 ; + } + +trace_xfarray_sort_scan (si, idx); +return 0 ; +} +/* * Cache the folio backing the start of the given array element. If the array * element is contained entirely within the folio, return a pointer to the
@@ -819,33 +859,18 @@ xfarray_sort_scan( (idx < si->first_folio_idx || idx > si->last_folio_idx))xfarray_sort_scan_done (si); -/* Grab the first folio that backs this array element. */ +/* Grab the folio that backs this array element. */ if (!si->folio) { -struct folio *folio; -loff_t next_pos; - - folio =xfile_get_folio (si->array->xfile, idx_pos, - si->array->obj_size,XFILE_ALLOC ); -if (IS_ERR (folio)) -return PTR_ERR (folio); - si->folio = folio; - - si->first_folio_idx =xfarray_idx (si->array, -folio_pos (si->folio) + si->array->obj_size -1 ); - - next_pos =folio_next_pos (si->folio); - si->last_folio_idx =xfarray_idx (si->array, next_pos -1 ); -if (xfarray_pos (si->array, si->last_folio_idx +1 ) > next_pos) - si->last_folio_idx--; - -trace_xfarray_sort_scan (si, idx); + error =xfarray_sort_load_folio (si, idx, idx_pos); +if (error) +return error; }/* -* If this folio still doesn't cover the desired element, it must cross -* a folio boundary. Read into the scratchpad and we're done. +* If we don't have a folio mapping the entire array element, read into +* the scratchpad and we're done. */ -if (idx < si->first_folio_idx || idx > si->last_folio_idx) { +if (!si->folio) {void *temp =xfarray_scratch (si->array); error = xfile_load(si->array->xfile, temp, si->array->obj_size,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 584/686 s390/pci: Add error cleanup in zpci_directed_irq_init()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tobias Schumacher <[email protected]>
[ Upstream commit 769f66f595c11185c66913ea5d96420504bfebc3 ]
If per-CPU airq_iv allocation fails in the loop, previously allocated vectors and arrays leak. Add proper error path to release all resources on failure.
The error path frees zpci_sbv, but SIC_IRQ_MODE_DIRECT has already programmed its address into the hardware. Set the directed interrupt mode only after all allocations have succeeded, so a failed init leaves no freed memory registered with the hardware.
--- arch/s390/pci/pci_irq.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-)
arch/s390/pci/pci_irq.c +19 -7
@@ -450,15 +450,10 @@ static int __init zpci_directed_irq_init(void)if (!zpci_sbv)return -ENOMEM ; - iib.diib.isc =PCI_ISC ; - iib.diib.nr_cpus =num_possible_cpus (); - iib.diib.disb_addr =virt_to_phys (zpci_sbv->vector); -zpci_set_irq_ctrl (SIC_IRQ_MODE_DIRECT ,0 , &iib); - zpci_ibv =kcalloc (num_possible_cpus (),sizeof (*zpci_ibv),GFP_KERNEL );if (!zpci_ibv) -return -ENOMEM ; + goto out_free_sbv;for_each_possible_cpu (cpu) {/*
@@ -470,13 +465,30 @@ static int __init zpci_directed_irq_init(void)AIRQ_IV_CACHELINE | (!cpu ? AIRQ_IV_ALLOC : 0), NULL);if (!zpci_ibv[cpu]) -return -ENOMEM ; + goto out_free_dibv; } + + iib.diib.isc =PCI_ISC ; + iib.diib.nr_cpus =num_possible_cpus (); + iib.diib.disb_addr =virt_to_phys (zpci_sbv->vector); +zpci_set_irq_ctrl (SIC_IRQ_MODE_DIRECT ,0 , &iib);on_each_cpu (cpu_enable_directed_irq,NULL ,1 ); zpci_irq_chip.irq_set_affinity = zpci_set_irq_affinity;return 0 ; + +out_free_dibv: +for_each_possible_cpu (cpu) { +if (zpci_ibv[cpu]) +airq_iv_release (zpci_ibv[cpu]); + } +kfree (zpci_ibv); + zpci_ibv =NULL ; +out_free_sbv: +airq_iv_release (zpci_sbv); + zpci_sbv =NULL ; +return -ENOMEM ; }static int __init zpci_floating_irq_init (void )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 585/686 serial: sc16is7xx: declare SPR/TLR/XOFF2 register as volatile
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hugo Villeneuve <[email protected]>
[ Upstream commit 983f91e5f13149ade6dbd9568053ecd0ab5e9265 ]
SPR shares the same address space as TLR and XOFF2. If SPR or TLR were to be used eventually, this could lead to incorrect read value from the cache.
Prevent this potential bug by declaring SPR/TLR/XOFF2 as volatile.
Stable-dep-of: 1c41d09dcd07 ("serial: sc16is7xx: declare MCR and IER as volatile registers")
--- drivers/tty/serial/sc16is7xx.c | 1 + 1 file changed, 1 insertion(+)
drivers/tty/serial/sc16is7xx.c +1 -0
@@ -542,6 +542,7 @@ static bool sc16is7xx_regmap_volatile(struct device *dev, unsigned int reg)case SC16IS7XX_IIR_REG :case SC16IS7XX_LSR_REG :case SC16IS7XX_MSR_REG : +case SC16IS7XX_SPR_REG :/* Shared address space with TLR & XOFF2 */ case SC16IS7XX_TXLVL_REG :case SC16IS7XX_RXLVL_REG :case SC16IS7XX_IOSTATE_REG :
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 586/686 serial: sc16is7xx: add comments for lock requirements
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hugo Villeneuve <[email protected]>
[ Upstream commit 42405cb77fd35b5acc0e5a11d74eef68c2afa484 ]
Indicate why lock needs to be asserted when accessing
MSR register, as this is not immediately obvious when looking at this register in the device datasheet.
Stable-dep-of: 1c41d09dcd07 ("serial: sc16is7xx: declare MCR and IER as volatile registers")
--- drivers/tty/serial/sc16is7xx.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/tty/serial/sc16is7xx.c +5 -4
@@ -538,10 +538,10 @@ EXPORT_SYMBOL_GPL(sc16is762_devtype);static bool sc16is7xx_regmap_volatile (struct device *dev,unsigned int reg) {switch (reg) { -case SC16IS7XX_RHR_REG : -case SC16IS7XX_IIR_REG : -case SC16IS7XX_LSR_REG : -case SC16IS7XX_MSR_REG : +case SC16IS7XX_RHR_REG :/* Shared address space with THR & DLL */ +case SC16IS7XX_IIR_REG :/* Shared address space with FCR & EFR */ +case SC16IS7XX_LSR_REG :/* Shared address space with XON2 */ +case SC16IS7XX_MSR_REG :/* Shared address space with TCR & XOFF1 */ case SC16IS7XX_SPR_REG :/* Shared address space with TLR & XOFF2 */ case SC16IS7XX_TXLVL_REG :case SC16IS7XX_RXLVL_REG :
@@ -785,6 +785,7 @@ static void sc16is7xx_update_mlines(struct sc16is7xx_one *one)unsigned long flags;unsigned int status, changed; +/* Lock required as MSR address is shared with TCR and XOFF1. */ lockdep_assert_held_once (&one->lock); status =sc16is7xx_get_hwmctrl (port);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 587/686 serial: sc16is7xx: declare MCR and IER as volatile registers
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hugo Villeneuve <[email protected]>
[ Upstream commit 1c41d09dcd07ee9648e20aa8238e404c2e6a12fb ]
MCR register has the same address as XON1 register. IER register has the same address as DLH register.
Which register is accessed depends on bits configuration in some other registers.
To prevent potential access errors, declare MCR and IER as volatile registers.
--- drivers/tty/serial/sc16is7xx.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/tty/serial/sc16is7xx.c +2 -0
@@ -539,7 +539,9 @@ static bool sc16is7xx_regmap_volatile(struct device *dev, unsigned int reg) {switch (reg) {case SC16IS7XX_RHR_REG :/* Shared address space with THR & DLL */ +case SC16IS7XX_IER_REG :/* Shared address space with DLH */ case SC16IS7XX_IIR_REG :/* Shared address space with FCR & EFR */ +case SC16IS7XX_MCR_REG :/* Shared address space with XON1 */ case SC16IS7XX_LSR_REG :/* Shared address space with XON2 */ case SC16IS7XX_MSR_REG :/* Shared address space with TCR & XOFF1 */ case SC16IS7XX_SPR_REG :/* Shared address space with TLR & XOFF2 */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 588/686 virtiofs: add FUSE protocol validation
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuto Ohnuki <[email protected]>
[ Upstream commit 68b69fa0edb241a946cd4c850110990f30705164 ]
Add virtio_fs_verify_response() to validate that the server properly follows the FUSE protocol by checking:
- Response length is at least sizeof(struct fuse_out_header).
- oh.len matches the actual response length.
- oh.unique matches the request's unique identifier.
On validation failure, set error to -EIO and normalize oh.len to prevent underflow in copy_args_from_argbuf().
Addresses the TODO comment in virtio_fs_request_complete().
Stable-dep-of: 5364d081125a ("virtiofs: validate fixed-output response length")
--- fs/fuse/virtio_fs.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-)
fs/fuse/virtio_fs.c +25 -4
@@ -755,6 +755,27 @@ static void copy_args_from_argbuf(struct fuse_args *args, struct fuse_req *req) req->argbuf =NULL ; } +/* Verify that the server properly follows the FUSE protocol */ +static bool virtio_fs_verify_response (struct fuse_req *req,unsigned int len) +{ +struct fuse_out_header *oh = &req->out.h; + +if (len <sizeof (*oh)) { +pr_warn ("virtio-fs: response too short (%u)\n" , len); +return false; + } +if (oh->len != len) { +pr_warn ("virtio-fs: oh.len mismatch (%u != %u)\n" , oh->len, len); +return false; + } +if (oh->unique != req->in.h.unique) { +pr_warn ("virtio-fs: oh.unique mismatch (%llu != %llu)\n" , + oh->unique, req->in.h.unique); +return false; + } +return true; +} +/* Work function for request completion */ static void virtio_fs_request_complete (struct fuse_req *req,struct virtio_fs_vq *fsvq)
@@ -764,10 +785,6 @@ static void virtio_fs_request_complete(struct fuse_req *req,unsigned int len, i, thislen;struct folio *folio; -/* -* TODO verify that server properly follows FUSE protocol -* (oh.uniq, oh.len) -*/ args = req->args;copy_args_from_argbuf (args, req);
@@ -821,6 +838,10 @@ static void virtio_fs_requests_done_work(struct work_struct *work)virtqueue_disable_cb (vq);while ((req =virtqueue_get_buf (vq, &len)) !=NULL ) { +if (!virtio_fs_verify_response (req, len)) { + req->out.h.error = -EIO ; + req->out.h.len =sizeof (struct fuse_out_header ); + }spin_lock (&fpq->lock);list_move_tail (&req->list, &reqs);spin_unlock (&fpq->lock);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 589/686 virtiofs: validate fixed-output response length
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sung Byeongchan <[email protected]>
[ Upstream commit 5364d081125a34e90851fbb46ecc93f79339ce78 ]
A short successful virtiofs response can leave the fixed-output portion of the request argument buffer unwritten. The completion path nevertheless copies the full declared output to the request destination, allowing stale allocator contents to reach callers such as fuse_statfs().
Require successful fixed-output responses to contain their complete declared output. Continue to permit a shorter final argument only for out_argvar requests. Reject positive and internal restart error values and require valid error replies to be header-only. The error already stored in the FUSE output header is returned by fuse_request_end(), so do not copy output arguments from an error reply.
This was found by source review with AI assistance. A header-only successful FUSE_STATFS reply returned stale fields in nine of nine calls across three boots. The fixed kernel rejected the short response and preserved complete replies, valid negative-error replies, and variable-output replies.
--- fs/fuse/virtio_fs.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)
fs/fuse/virtio_fs.c +30 -0
@@ -726,6 +726,10 @@ static void copy_args_from_argbuf(struct fuse_args *args, struct fuse_req *req)unsigned int num_out;unsigned int i; +/* fuse_request_end() returns this error; there are no args to copy. */ +if (req->out.h.error) + goto out; + remaining = req->out.h.len -sizeof (req->out.h); num_in = args->in_numargs - args->in_pages; num_out = args->out_numargs - args->out_pages;
@@ -751,6 +755,7 @@ static void copy_args_from_argbuf(struct fuse_args *args, struct fuse_req *req)if (args->out_argvar) args->out_args[args->out_numargs -1 ].size = remaining; +out:kfree (req->argbuf); req->argbuf =NULL ; }
@@ -758,7 +763,9 @@ static void copy_args_from_argbuf(struct fuse_args *args, struct fuse_req *req)/* Verify that the server properly follows the FUSE protocol */ static bool virtio_fs_verify_response (struct fuse_req *req,unsigned int len) { +struct fuse_args *args = req->args;struct fuse_out_header *oh = &req->out.h; +unsigned int expected;if (len <sizeof (*oh)) {pr_warn ("virtio-fs: response too short (%u)\n" , len);
@@ -773,6 +780,29 @@ static bool virtio_fs_verify_response(struct fuse_req *req, unsigned int len) oh->unique, req->in.h.unique);return false; } +if (oh->error <= -ERESTARTSYS || oh->error >0 ) { +pr_warn ("virtio-fs: invalid error value (%d)\n" , oh->error); +return false; + } + +if (oh->error) { +if (len !=sizeof (*oh)) { +pr_warn ("virtio-fs: error response too long (%u)\n" , len); +return false; + } +return true; + } + + expected =sizeof (*oh) + +fuse_len_args (args->out_numargs, args->out_args); +if (len > expected || + (len < expected && + (!args->out_argvar || + expected - len > args->out_args[args->out_numargs -1 ].size))) { +pr_warn ("virtio-fs: invalid response length (%u, expected %u)\n" , + len, expected); +return false; + }return true; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 590/686 rculist: Add hlist_nulls_replace_rcu() and hlist_nulls_replace_init_rcu()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xuanqiang Luo <[email protected]>
[ Upstream commit 9c4609225ec1cb551006d6a03c7c4ad8cb5584c0 ]
Add two functions to atomically replace RCU-protected hlist_nulls entries.
Keep using WRITE_ONCE() to assign values to ->next and ->pprev, as mentioned in the patch below:
commit efd04f8a8b45 ("rcu: Use WRITE_ONCE() for assignments to ->next for rculist_nulls")
commit 860c8802ace1 ("rcu: Use WRITE_ONCE() for assignments to ->pprev for hlist_nulls")
Stable-dep-of: 2093bc7fa500 ("mptcp: fix MP_CAPABLE token migration when cloning reqsk")
--- include/linux/rculist_nulls.h | 59 +++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+)
include/linux/rculist_nulls.h +59 -0
@@ -52,6 +52,13 @@ static inline void hlist_nulls_del_init_rcu(struct hlist_nulls_node *n)#define hlist_nulls_next_rcu (node) \ (*((struct hlist_nulls_node __rcu __force **)&(node)->next)) +/** +* hlist_nulls_pprev_rcu - returns the dereferenced pprev of @node. +* @node: element of the list. +*/ +#define hlist_nulls_pprev_rcu (node) \ + (*((struct hlist_nulls_node __rcu __force **)(node)->pprev)) +/** * hlist_nulls_del_rcu - deletes entry from hash list without re-initialization * @n: the element to delete from the hash list.
@@ -152,6 +159,58 @@ static inline void hlist_nulls_add_fake(struct hlist_nulls_node *n) n->next = (struct hlist_nulls_node *)NULLS_MARKER (NULL ); } +/** +* hlist_nulls_replace_rcu - replace an old entry by a new one +* @old: the element to be replaced +* @new: the new element to insert +* +* Description: +* Replace the old entry with the new one in a RCU-protected hlist_nulls, while +* permitting racing traversals. +* +* The caller must take whatever precautions are necessary (such as holding +* appropriate locks) to avoid racing with another list-mutation primitive, such +* as hlist_nulls_add_head_rcu() or hlist_nulls_del_rcu(), running on this same +* list. However, it is perfectly legal to run concurrently with the _rcu +* list-traversal primitives, such as hlist_nulls_for_each_entry_rcu(). +*/ +static inline void hlist_nulls_replace_rcu (struct hlist_nulls_node *old, +struct hlist_nulls_node *new) +{ +struct hlist_nulls_node *next = old->next; + +WRITE_ONCE (new->next, next); +WRITE_ONCE (new->pprev, old->pprev); +rcu_assign_pointer (hlist_nulls_pprev_rcu (new), new); +if (!is_a_nulls (next)) +WRITE_ONCE (next->pprev, &new->next); +} + +/** +* hlist_nulls_replace_init_rcu - replace an old entry by a new one and +* initialize the old +* @old: the element to be replaced +* @new: the new element to insert +* +* Description: +* Replace the old entry with the new one in a RCU-protected hlist_nulls, while +* permitting racing traversals, and reinitialize the old entry. +* +* Note: @old must be hashed. +* +* The caller must take whatever precautions are necessary (such as holding +* appropriate locks) to avoid racing with another list-mutation primitive, such +* as hlist_nulls_add_head_rcu() or hlist_nulls_del_rcu(), running on this same +* list. However, it is perfectly legal to run concurrently with the _rcu +* list-traversal primitives, such as hlist_nulls_for_each_entry_rcu(). +*/ +static inline void hlist_nulls_replace_init_rcu (struct hlist_nulls_node *old, +struct hlist_nulls_node *new) +{ +hlist_nulls_replace_rcu (old, new); +WRITE_ONCE (old->pprev,NULL ); +} +/** * hlist_nulls_for_each_entry_rcu - iterate over rcu list of given type * @tpos: the type * to use as a loop cursor.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 591/686 mptcp: fix MP_CAPABLE token migration when cloning reqsk
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ruide Cao <[email protected]>
[ Upstream commit 2093bc7fa50056fef8620d2b82bcb2e9a0a5575d ]
TCP request migration clones pending request sockets with inet_reqsk_clone(). For MPTCP MP_CAPABLE requests this byte-copies the token_node hlist state into the clone even though the token table still names the original request, and the following warning can be seen:
WARNING: net/mptcp/token.c:364 at mptcp_token_destroy_request+0x2b0/0x330, CPU#2: swapper/2/0 CPU: 2 UID: 0 PID: 0 Comm: swapper/2 Not tainted 7.2.0-rc5-00353-gc27e36054537 #10 PREEMPT(full) RIP: 0010:mptcp_token_destroy_request (net/mptcp/token.c:364 (discriminator 1)) Call Trace: <IRQ> 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) call_timer_fn (kernel/time/timer.c:1748)
Move token request ownership from the original request to the clone under the token bucket lock. Make mptcp_token_accept() and mptcp_token_destroy_request() re-check token_node under the same lock and treat an already moved or removed request as a normal race instead of warning. This also keeps token bucket chain_len accounting balanced.
If a passive MP_CAPABLE socket cannot claim the token, destroy the provisional MPTCP socket and let the subflow fall back rather than installing a socket with mismatched token ownership. Mark that path as a passive handshake fallback so MPCapableFallbackACK records the downgrade.
If the speculative clone later loses the inet_ehash_insert() ownership arbitration, the original request may find that its token was already moved and fall back to plain TCP. The clone destructor then releases the token reservation and keeps chain_len balanced. This trades an exceptionally rare fallback for eliminating the warning and persistent accounting drift.
--- net/mptcp/protocol.c | 31 +++++++++++++++---- net/mptcp/protocol.h | 4 ++- net/mptcp/subflow.c | 6 +++- net/mptcp/token.c | 68 +++++++++++++++++++++++++++++++++++++----- net/mptcp/token_test.c | 4 +-- 5 files changed, 97 insertions(+), 16 deletions(-)
net/mptcp/protocol.c +26 -5
@@ -3410,6 +3410,24 @@ static void mptcp_copy_ip_options(struct sock *newsk, const struct sock *sk)rcu_read_unlock (); } +static void mptcp_sk_clone_destroy (struct sock *nsk) +{ +struct mptcp_sock *msk =mptcp_sk (nsk); + +mptcp_release_sched (msk); +mptcp_set_state (nsk,TCP_CLOSE ); +/* inet_csk_prepare_forced_close() clears TCP sock_ops state via +* tcp_sk(), but nsk is an MPTCP master socket; keep the inet-level +* destroy preparation here. +*/ +bh_unlock_sock (nsk); +sock_put (nsk); +sock_set_flag (nsk,SOCK_DEAD ); +tcp_orphan_count_inc (); +inet_sk (nsk)->inet_num =0 ; +inet_csk_destroy_sock (nsk); +} + struct sock *mptcp_sk_clone_init(const struct sock *sk, const struct mptcp_options_received *mp_opt, struct sock *ssk,
@@ -3469,11 +3487,6 @@ struct sock *mptcp_sk_clone_init(const struct sock *sk,list_add (&subflow->node, &msk->conn_list);sock_hold (ssk); -/* new mpc subflow takes ownership of the newly -* created mptcp socket -*/ -mptcp_token_accept (subflow_req, msk); -/* set msk addresses early to ensure mptcp_pm_get_local_id() * uses the correct data */
@@ -3482,6 +3495,14 @@ struct sock *mptcp_sk_clone_init(const struct sock *sk,mptcp_rcv_space_init (msk, ssk); msk->rcvq_space.time =mptcp_stamp (); +if (!mptcp_token_accept (subflow_req, msk)) { +list_del_init (&subflow->node); +WRITE_ONCE (msk->first,NULL ); +sock_put (ssk); +mptcp_sk_clone_destroy (nsk); +return NULL ; + } +if (mp_opt->suboptions &OPTION_MPTCP_MPC_ACK )__mptcp_subflow_fully_established (msk, subflow, mp_opt);bh_unlock_sock (nsk);
net/mptcp/protocol.h +3 -1
@@ -1033,9 +1033,11 @@ static inline void mptcp_token_init_request(struct request_sock *req) }int mptcp_token_new_request (struct request_sock *req); +void mptcp_token_move_request (struct request_sock *req, +struct request_sock *new_req);void mptcp_token_destroy_request (struct request_sock *req);int mptcp_token_new_connect (struct sock *ssk); -void mptcp_token_accept (struct mptcp_subflow_request_sock *r, +bool mptcp_token_accept (struct mptcp_subflow_request_sock *r,struct mptcp_sock *msk);bool mptcp_token_exists (u32 token);struct mptcp_sock *mptcp_token_get_sock (struct net *net,u32 token);
net/mptcp/subflow.c +5 -1
@@ -78,6 +78,8 @@ void mptcp_subflow_reqsk_clone(struct request_sock *req, } new_subflow_req->msk = msk; + +mptcp_token_move_request (req, new_req); } static void subflow_generate_hmac(u64 key1, u64 key2, u32 nonce1, u32 nonce2,
@@ -931,8 +933,10 @@ static struct sock *subflow_syn_recv_sock(const struct sock *sk,if (ctx->mp_capable) { ctx->conn =mptcp_sk_clone_init (listener->conn, &mp_opt, child, req); -if (!ctx->conn) +if (!ctx->conn) { + fallback = true; goto fallback; + } ctx->subflow_id =1 ; owner =mptcp_sk (ctx->conn);
net/mptcp/token.c +61 -7
107 lines not on this page · raw message
net/mptcp/token_test.c +2 -2
@@ -99,7 +99,7 @@ static void mptcp_token_test_accept(struct kunit *test)KUNIT_ASSERT_EQ (test,0 ,mptcp_token_new_request ((struct request_sock *)req)); msk->token = req->token; -mptcp_token_accept (req, msk); +KUNIT_EXPECT_TRUE (test,mptcp_token_accept (req, msk));KUNIT_EXPECT_PTR_EQ (test, msk,mptcp_token_get_sock (&init_net, msk->token));/* this is now a no-op */
@@ -122,7 +122,7 @@ static void mptcp_token_test_destroyed(struct kunit *test)KUNIT_ASSERT_EQ (test,0 ,mptcp_token_new_request ((struct request_sock *)req)); msk->token = req->token; -mptcp_token_accept (req, msk); +KUNIT_EXPECT_TRUE (test,mptcp_token_accept (req, msk));/* simulate race on removal */ refcount_set (&sk->sk_refcnt,0 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 592/686 ALSA: ua101: Bound packet copies by the PCM buffer size
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sinan Turunc <[email protected]>
[ Upstream commit 493a77a9f20fca07ca5654f61c1b03bef035df25 ]
copy_capture_data() and copy_playback_data() wrap the ring buffer position once and split the memcpy() in two at the buffer end, which is only correct when one packet holds at most buffer_size frames. The capture packet size is the device's (actual_length up to wMaxPacketSize, divided by 3 * bNrChannels from its own descriptor), the playback packet size is taken from the capture packets, and set_stream_hw() lets the PCM client pick period_bytes_min 1, periods_min 2 and a period time of 1.5 packet intervals: 9 frames at 44.1 kHz high speed, an 18-frame buffer. A device sending 672-byte mono 24-bit packets delivers 224 frames per packet.
After the first packet buffer_pos is 206 and stays beyond buffer_size. On the next packet frames1 = buffer_size - buffer_pos wraps and memcpy() runs away:
snd-ua101 2-1:1.0: invalid position: , pos = 206, buffer size = 18,
period size = 9
BUG: KASAN: slab-out-of-bounds in capture_urb_complete+0x9eb/0xcb0 Read of size 4294966732 at addr ffff88800d73e7e0 by task vhci_rx/81
and for playback:
BUG: KASAN: vmalloc-out-of-bounds in playback_work+0x789/0xac0 Read of size 4294966732 at addr ffffc9000002626a by task kworker/0:1H/80
Clamp the capture copy to buffer_size. On playback, copy at most one buffer and fill the rest of the packet with silence, so the URB length, the delay accounting and the data sent stay consistent. With that bound the single wrap and both memcpy() halves stay inside the buffer. A device whose packets do not fit the buffer never played correctly anyway.
Reproduced on 7.3-rc7 with a USB/IP device presenting the UA-101 interface layout and a 672-byte isochronous endpoint.
--- sound/usb/misc/ua101.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-)
sound/usb/misc/ua101.c +26 -3
@@ -282,13 +282,29 @@ static void playback_work(struct work_struct *work)/* fill packet with data or silence */ urb->urb.iso_frame_desc[0 ].length = frames * ua->playback.frame_bytes; -if (test_bit (ALSA_PLAYBACK_RUNNING , &ua->states)) +if (test_bit (ALSA_PLAYBACK_RUNNING , &ua->states)) { +/* +* The packet size comes from the capture stream, +* i.e. from the device, while the ring buffer can +* be as small as two tiny periods. The single wrap +* in copy_playback_data() is only valid for +* frames <= buffer_size, so copy at most one +* buffer and send silence for the rest. +*/ +unsigned int copy_frames =min (frames, + ua->playback.substream->runtime->buffer_size); + do_period_elapsed |=copy_playback_data (&ua->playback, &urb->urb, - frames); -else + copy_frames); +memset (urb->urb.transfer_buffer + + copy_frames * ua->playback.frame_bytes,0 , + (frames - copy_frames) * + ua->playback.frame_bytes); + }else {memset (urb->urb.transfer_buffer,0 , urb->urb.iso_frame_desc[0 ].length); + }/* and off you go ... */ err =usb_submit_urb (&urb->urb,GFP_ATOMIC );
@@ -317,6 +333,13 @@ static bool copy_capture_data(struct ua101_stream *stream, struct urb *urb, runtime = stream->substream->runtime; frame_bytes = stream->frame_bytes; +/* +* A packet can carry up to max_packet_bytes, the device's +* wMaxPacketSize, which may exceed the whole ring buffer; keep what +* fits so the single wrap below stays valid. +*/ +if (unlikely (frames > runtime->buffer_size)) + frames = runtime->buffer_size; dest = runtime->dma_area + stream->buffer_pos * frame_bytes;if (stream->buffer_pos + frames <= runtime->buffer_size) {memcpy (dest, urb->transfer_buffer, frames * frame_bytes);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 593/686 serial: sc16is7xx: fix data corruption due to unexpected xon/xoff
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Martin Fuzzey <[email protected]>
[ Upstream commit 8bb50e95c0abd44607bc60a43032c1dbf7470d5a ]
The hardware supports automatically sending XON/OFF based on the FIFO status and that is already implemented by the driver. However that capability was not announced with the UPF_SOFT_FLOW bit.
When the port is opened with the default of XON enabled the driver configures that in the hardware.
If userspace does not want XON/OFF (which is normally the case) it will use TCSETS to disactivate it. However the serial core optimises this to only notify the driver if someting imporant has changed, and for XON/XOFF thit is only if the driver declares UPF_SOFT_FLOW.
So we end up with unwanted XON/XOFF in the data stream.
The problem only occurs if nothing else needed to be set by termios, ie if the user space requested values are the same as the default values, except for XON/XOFF.
Since the default speed is 9600 this means that the problem only occurs when requesting 9600, otherwise the call to the driver will be made to change the speed, and that will also clear the XON/XOFF.
As 9600 is quite rare these days that probably explains why this hasn't already been seen.
It also only occurs on the first port open after boot since the subsequent opens will use the "logical state" set by TCSETS but not communicated to the driver the first time.
--- drivers/tty/serial/sc16is7xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/sc16is7xx.c +1 -1
@@ -1650,7 +1650,7 @@ int sc16is7xx_probe(struct device *dev, const struct sc16is7xx_devtype *devtype, s->p[i].port.irq = irq; s->p[i].port.type =PORT_SC16IS7XX ; s->p[i].port.fifosize =SC16IS7XX_FIFO_SIZE ; - s->p[i].port.flags =UPF_FIXED_TYPE |UPF_LOW_LATENCY ; + s->p[i].port.flags =UPF_FIXED_TYPE |UPF_LOW_LATENCY |UPF_SOFT_FLOW ; s->p[i].port.iobase = i;/* * Use all ones as membase to make sure uart_configure_port() in
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 594/686 media: iris: Fix power-off ordering to disable power domain after clocks
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vishnu Reddy <[email protected]>
[ Upstream commit 9cfae7726a9a9f526e8905dbddde355be2674e3d ]
In iris_vpu_power_off_hw(), iris_disable_power_domains() was called before the associated clocks (IRIS_BSE_HW_CLK, IRIS_HW_AHB_CLK, IRIS_HW_CLK) were disabled and unprepared. This reverses the correct power-down sequence: with the power domain already removed, the subsequent clk_disable_unprepare() calls end up operating on clock-controller hardware that is no longer powered, which can hang or behave unpredictably.
Reorder the calls so iris_disable_power_domains() runs after all three clocks are disabled, ensuring clocks are always turned off while their power domain is still active, and mirroring the reverse of the power-on sequence.
--- drivers/media/platform/qcom/iris/iris_vpu_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/qcom/iris/iris_vpu_common.c +1 -1
@@ -260,8 +260,8 @@ int iris_vpu_power_off_controller(struct iris_core *core)void iris_vpu_power_off_hw (struct iris_core *core) {dev_pm_genpd_set_hwmode (core->pmdomain_tbl->pd_devs[IRIS_HW_POWER_DOMAIN ], false); -iris_disable_power_domains (core, core->pmdomain_tbl->pd_devs[IRIS_HW_POWER_DOMAIN ]);iris_disable_unprepare_clock (core,IRIS_HW_CLK ); +iris_disable_power_domains (core, core->pmdomain_tbl->pd_devs[IRIS_HW_POWER_DOMAIN ]); }void iris_vpu_power_off (struct iris_core *core)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 595/686 ASoC: qcom: q6apm-dai: wrap the position of a full ring to 0
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vladyslav Tymoshchuk <[email protected]>
[ Upstream commit 0ea3e0b196f9dcc17b40ac881a6efef06459975b ]
q6apm_dai_pointer() turns the number of period buffers the DSP has returned in the current lap, 1..periods, into a position and reports one frame less than that. Commit a93dad6f4e6a ("ASoC: q6apm-dai: make use of q6apm_get_hw_pointer") added the "- 1" so that the end of the ring is not reported as a position equal to the buffer size.
One frame short has a cost once the application stops feeding the stream. The DSP returns the last queued buffer and the position stops at appl_ptr - 1, so avail stays at buffer_size - 1, below the default stop_threshold. The DSP sends nothing more as its queue is empty, so no period interrupt comes either: ALSA never detects the underrun and the stream stays RUNNING. A poll-driven application that missed its last wakeup waits forever, and drain only ends on its timeout, with -EIO. On capture, the last frame of each period is held back until the next one.
Before that commit the position wrapped to 0 at the end of the ring. Do that again. A full lap is the start of the ring, and snd_pcm_update_hw_ptr0() accounts for the wrap: the position cannot move by more than one lap between two updates, as each returned buffer calls snd_pcm_period_elapsed() and the DSP holds at most periods buffers.
Seen on a OnePlus Pad 3 (SM8750) with PipeWire in interrupt-driven
scheduling: after a stall the PCM sat at hw_ptr 78239, appl_ptr 78240 (avail 3839 of 3840) for two hours.
--- sound/soc/qcom/qdsp6/q6apm-dai.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
sound/soc/qcom/qdsp6/q6apm-dai.c +8 -4
@@ -442,11 +442,15 @@ static snd_pcm_uframes_t q6apm_dai_pointer(struct snd_soc_component *component,struct q6apm_dai_rtd *prtd = runtime->private_data;snd_pcm_uframes_t ptr; - ptr =q6apm_get_hw_pointer (prtd->graph, substream->stream) * runtime->period_size; -if (ptr) -return ptr -1 ; +/* +* The hw pointer counts the period buffers the DSP has returned in +* this lap, 1..periods. A full lap is the start of the ring again: +* report 0 rather than one frame less, so that the position of a +* drained buffer reaches appl_ptr and ALSA sees the underrun. +*/ + ptr =q6apm_get_hw_pointer (prtd->graph, substream->stream) % runtime->periods; -return 0 ; +return ptr * runtime->period_size; } static int q6apm_dai_hw_params(struct snd_soc_component *component,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 596/686 iomap: use largest_zero_folio() in iomap_dio_zero()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pankaj Raghav <[email protected]>
[ Upstream commit 10436adf9df60ae73390754b47a4bdebf728529f ]
iomap_dio_zero() uses a custom allocated memory of zeroes for padding zeroes. This was a temporary solution until there was a way to request a zero folio that was greater than the PAGE_SIZE.
Use largest_zero_folio() function instead of using the custom allocated memory of zeroes. There is no guarantee from largest_zero_folio() function that it will always return a PMD sized folio. Adapt the code so that it can also work if largest_zero_folio() returns a ZERO_PAGE.
Stable-dep-of: a9fd24bcbe69 ("iomap: don't lose a failed direct I/O bio's error when zeroing the tail")
--- fs/iomap/direct-io.c | 38 +++++++++++++++----------------------- 1 file changed, 15 insertions(+), 23 deletions(-)
fs/iomap/direct-io.c +15 -23
@@ -24,13 +24,6 @@#define IOMAP_DIO_WRITE (1U << 30)#define IOMAP_DIO_DIRTY (1U << 31) -/* -* Used for sub block zeroing in iomap_dio_zero() -*/ -#define IOMAP_ZERO_PAGE_SIZE (SZ_64K) -#define IOMAP_ZERO_PAGE_ORDER (get_order(IOMAP_ZERO_PAGE_SIZE)) -static struct page *zero_page; -struct iomap_dio {struct kiocb *iocb;const struct iomap_dio_ops *dops;
@@ -296,24 +289,35 @@ static int iomap_dio_zero(const struct iomap_iter *iter, struct iomap_dio *dio, {struct inode *inode =file_inode (dio->iocb->ki_filp);struct bio *bio; +struct folio *zero_folio =largest_zero_folio (); +int nr_vecs =max (1 ,i_blocksize (inode) /folio_size (zero_folio));if (!len)return 0 ; +/* -* Max block size supported is 64k +* This limit shall never be reached as most filesystems have a +* maximum blocksize of 64k. */ -if (WARN_ON_ONCE (len >IOMAP_ZERO_PAGE_SIZE )) +if (WARN_ON_ONCE (nr_vecs >BIO_MAX_VECS ))return -EINVAL ; - bio =iomap_dio_alloc_bio (iter, dio,1 ,REQ_OP_WRITE |REQ_SYNC |REQ_IDLE ); + bio =iomap_dio_alloc_bio (iter, dio, nr_vecs, +REQ_OP_WRITE |REQ_SYNC |REQ_IDLE );fscrypt_set_bio_crypt_ctx (bio, inode, pos >> inode->i_blkbits,GFP_KERNEL ); bio->bi_iter.bi_sector =iomap_sector (&iter->iomap, pos); bio->bi_private = dio; bio->bi_end_io = iomap_dio_bio_end_io; -__bio_add_page (bio, zero_page, len,0 ); +while (len >0 ) { +unsigned int io_len =min (len,folio_size (zero_folio)); + +bio_add_folio_nofail (bio, zero_folio, io_len,0 ); + len -= io_len; + }iomap_dio_submit_bio (iter, dio, bio, pos); +return 0 ; }
@@ -841,15 +845,3 @@ iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter,return iomap_dio_complete (dio); }EXPORT_SYMBOL_GPL (iomap_dio_rw); - -static int __init iomap_dio_init (void ) -{ - zero_page =alloc_pages (GFP_KERNEL | __GFP_ZERO, -IOMAP_ZERO_PAGE_ORDER ); - -if (!zero_page) -return -ENOMEM ; - -return 0 ; -} -fs_initcall (iomap_dio_init);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 597/686 iomap: dont lose a failed direct I/O bios error when zeroing the tail
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrea Parri <[email protected]>
[ Upstream commit a9fd24bcbe690ed4a5b8ea6a7516fa297fae9360 ]
iomap_dio_bio_iter() falls through to the sub-block tail zeroing when the data bio submission fails, so that the rest of the block is still zeroed and stale data is not exposed. The zeroing result was assigned to ret, which overwrote the submission error with the successful zeroing result (zero) and the failed write was reported as success.
iomap_dio_zero() can only return an error from a can't-happen WARN_ON_ONCE() (nr_vecs exceeding BIO_MAX_VECS, which the existing comment there says "shall never be reached" for any in-tree filesystem), so it isn't a real runtime failure worth reporting to userspace, let alone one worth losing the actual submission error for. Make iomap_dio_zero() return void and drop the error handling at both call sites instead of threading the result through a separate variable.
--- fs/iomap/direct-io.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-)
fs/iomap/direct-io.c +5 -11
@@ -284,7 +284,7 @@ u32 iomap_finish_ioend_direct(struct iomap_ioend *ioend)return vec_count; } -static int iomap_dio_zero (const struct iomap_iter *iter,struct iomap_dio *dio, +static void iomap_dio_zero (const struct iomap_iter *iter,struct iomap_dio *dio,loff_t pos,unsigned len) {struct inode *inode =file_inode (dio->iocb->ki_filp);
@@ -293,14 +293,14 @@ static int iomap_dio_zero(const struct iomap_iter *iter, struct iomap_dio *dio,int nr_vecs =max (1 ,i_blocksize (inode) /folio_size (zero_folio));if (!len) -return 0 ; +return ;/* * This limit shall never be reached as most filesystems have a * maximum blocksize of 64k. */ if (WARN_ON_ONCE (nr_vecs >BIO_MAX_VECS )) -return -EINVAL ; +return ; bio =iomap_dio_alloc_bio (iter, dio, nr_vecs,REQ_OP_WRITE |REQ_SYNC |REQ_IDLE );
@@ -317,8 +317,6 @@ static int iomap_dio_zero(const struct iomap_iter *iter, struct iomap_dio *dio, len -= io_len; }iomap_dio_submit_bio (iter, dio, bio, pos); - -return 0 ; }/*
@@ -424,10 +422,7 @@ static int iomap_dio_bio_iter(struct iomap_iter *iter, struct iomap_dio *dio)if (need_zeroout) {/* zero out from the start of the block to the write offset */ pad = pos & (fs_block_size -1 ); - - ret =iomap_dio_zero (iter, dio, pos - pad, pad); -if (ret) - goto out; +iomap_dio_zero (iter, dio, pos - pad, pad); } nr_pages =bio_iov_vecs_to_alloc (dio->submit.iter,BIO_MAX_VECS );
@@ -509,8 +504,7 @@ static int iomap_dio_bio_iter(struct iomap_iter *iter, struct iomap_dio *dio)/* zero out from the end of the write to the end of the block */ pad = pos & (fs_block_size -1 );if (pad) - ret =iomap_dio_zero (iter, dio, pos, - fs_block_size - pad); +iomap_dio_zero (iter, dio, pos, fs_block_size - pad); } out:/* Undo iter limitation to current extent */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 598/686 exfat: advance valid_size to EOF for append writes
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chi Zhiling <[email protected]>
[ Upstream commit b70ab407503706289163dd59f1ac3e942bacc37d ]
For an append write, the write position is recalculated by generic_write_checks(). Therefore, the write position must be obtained after generic_write_checks() returns.
Using the original write position to advance valid_size may cause the valid_size update to be skipped, potentially exposing stale data.
Also move the truncate_pagecache() check below the recalculated position, so that pos is never read before it is assigned.
--- fs/exfat/file.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-)
fs/exfat/file.c +8 -10
@@ -633,23 +633,18 @@ static ssize_t exfat_file_write_iter(struct kiocb *iocb, struct iov_iter *iter)struct file *file = iocb->ki_filp;struct inode *inode =file_inode (file);struct exfat_inode_info *ei =EXFAT_I (inode); -loff_t pos = iocb->ki_pos; -loff_t valid_size; +loff_t pos, valid_size;if (unlikely (exfat_forced_shutdown (inode->i_sb)))return -EIO ;inode_lock (inode); -if (pos >i_size_read (inode)) -truncate_pagecache (inode,i_size_read (inode)); - - valid_size = ei->valid_size; - ret =generic_write_checks (iocb, iter);if (ret <=0 ) goto unlock; + pos = iocb->ki_pos;if (iocb->ki_flags &IOCB_DIRECT ) {unsigned long align = pos |iov_iter_alignment (iter);
@@ -660,6 +655,10 @@ static ssize_t exfat_file_write_iter(struct kiocb *iocb, struct iov_iter *iter) } } +if (pos >i_size_read (inode)) +truncate_pagecache (inode,i_size_read (inode)); + + valid_size = ei->valid_size;if (pos > valid_size) { ret =exfat_extend_valid_size (inode, pos);if (ret <0 && ret != -ENOSPC ) {
@@ -669,6 +668,8 @@ static ssize_t exfat_file_write_iter(struct kiocb *iocb, struct iov_iter *iter) }if (ret <0 ) goto unlock; + + pos = valid_size; } ret =__generic_file_write_iter (iocb, iter);
@@ -677,9 +678,6 @@ static ssize_t exfat_file_write_iter(struct kiocb *iocb, struct iov_iter *iter)inode_unlock (inode); -if (pos > valid_size) - pos = valid_size; -if (iocb->ki_pos > pos) {ssize_t err =generic_write_sync (iocb, iocb->ki_pos - pos);if (err <0 )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 599/686 f2fs: bound the SIT/NAT bitmaps by the checkpoint pack
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kaixuan Li <[email protected]>
[ Upstream commit 080833a32fd5dc10b3acf2fa9af9b3213e6cb617 ]
sit_ver_bitmap_bytesize and nat_ver_bitmap_bytesize are used as memcpy lengths into and out of sbi->ckpt, which is sized from cp_payload alone, and nothing compares either length against that allocation.
sanity_check_ckpt() has checked these two fields since c77ec61ca0a4, which added them after a crafted image overran build_sit_info(). That check ties each length to a segment count; it never compares either against the allocation, which is the half this adds.
Mounting over-reads in build_sit_info() and build_node_manager(), and the first checkpoint writes the same lengths back through the same pointers, so the over-read's contents reach the on-disk checkpoint. An unmount is enough; the filesystem does not have to be used.
Bound both ends the way __bitmap_ptr() lays them out. The three branches differ, so a single sum of the two lengths would still admit a small overflow when cp_payload is non-zero.
--- fs/f2fs/super.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
fs/f2fs/super.c +24 -0
@@ -4128,6 +4128,7 @@ int f2fs_sanity_check_ckpt(struct f2fs_sb_info *sbi)block_t avail_node_count, valid_node_count;unsigned int nat_blocks, nat_bits_bytes, nat_bits_blocks;unsigned int sit_blk_cnt; +unsigned long long ckpt_size, sit_end, nat_end;int i, j; total =le32_to_cpu (raw_super->segment_count);
@@ -4259,6 +4260,29 @@ int f2fs_sanity_check_ckpt(struct f2fs_sb_info *sbi)return 1 ; } +/* +* Nothing above ties the bitmap lengths to sbi->ckpt, which is +* (1 + cp_payload) blocks. Bound both ends the way __bitmap_ptr() +* lays them out. +*/ + ckpt_size = (unsigned long long )(cp_payload +1 ) *F2FS_BLKSIZE ; +if (__is_set_ckpt_flags (ckpt,CP_LARGE_NAT_BITMAP_FLAG )) { + nat_end =CP_MIN_CHKSUM_OFFSET +sizeof (__le32) + nat_bitmap_size; + sit_end = nat_end + sit_bitmap_size; + }else if (cp_payload >0 ) { + nat_end =CP_MIN_CHKSUM_OFFSET + nat_bitmap_size; + sit_end =F2FS_BLKSIZE + sit_bitmap_size; + }else { + sit_end =CP_MIN_CHKSUM_OFFSET + sit_bitmap_size; + nat_end = sit_end + nat_bitmap_size; + } + +if (sit_end > ckpt_size || nat_end > ckpt_size) { +f2fs_err (sbi,"Bitmaps do not fit the checkpoint pack: sit ends at %llu, nat at %llu, pack is %llu bytes" , + sit_end, nat_end, ckpt_size); +return 1 ; + } +if (__is_set_ckpt_flags (ckpt,CP_LARGE_NAT_BITMAP_FLAG ) &&le32_to_cpu (ckpt->checksum_offset) !=CP_MIN_CHKSUM_OFFSET ) { f2fs_warn(sbi, "using deprecated layout of large_nat_bitmap, "
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 600/686 block: introduce bio_in_atomic()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tal Zussman <[email protected]>
[ Upstream commit 8ed0831b5263e1aa48d99063795a1f20e4e69b50 ]
Move the atomic context detection logic from erofs's z_erofs_in_atomic() into the block layer as bio_in_atomic(). This helper returns true when the current context is unsafe for sleeping bio completion handlers (e.g., hard/soft IRQ, preempt-disabled).
The logic was originally added to erofs in commit c99fab6e80b7 ("erofs:
fix atomic context detection when !CONFIG_DEBUG_LOCK_ALLOC"). A subsequent patch will use it in the block layer's bio completion infrastructure, so move it to include/linux/bio.h where both subsystems can share it.
Convert erofs to call the new bio_in_atomic() directly.
Stable-dep-of: a605d5d71a6d ("f2fs: fix to use bio_in_atomic() in f2fs_read_end_io()")
--- fs/erofs/zdata.c | 11 +---------- include/linux/bio.h | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 10 deletions(-)
fs/erofs/zdata.c +1 -10
@@ -1414,15 +1414,6 @@ static void z_erofs_decompressqueue_kthread_work(struct kthread_work *work) }#endif -/* Use (kthread_)work in atomic contexts to minimize scheduling overhead */ -static inline bool z_erofs_in_atomic (void ) -{ -if (IS_ENABLED (CONFIG_PREEMPTION ) &&rcu_preempt_depth ()) -return true; -if (!IS_ENABLED (CONFIG_PREEMPT_COUNT )) -return true; -return !preemptible (); -}static void z_erofs_decompress_kickoff (struct z_erofs_decompressqueue *io,int bios)
@@ -1439,7 +1430,7 @@ static void z_erofs_decompress_kickoff(struct z_erofs_decompressqueue *io,if (atomic_add_return (bios, &io->pending_bios))return ; -if (z_erofs_in_atomic ()) { +if (bio_in_atomic ()) {/* See `sync_decompress` in sysfs-fs-erofs for more details */ if (sbi->sync_decompress ==EROFS_SYNC_DECOMPRESS_AUTO ) sbi->sync_decompress =EROFS_SYNC_DECOMPRESS_FORCE_ON ;
include/linux/bio.h +15 -0
@@ -376,6 +376,21 @@ static inline struct bio *bio_alloc(struct block_device *bdev,void submit_bio (struct bio *bio); +/** +* bio_in_atomic - check if the current context is unsafe for bio completion +* +* Return: %true in atomic contexts (e.g. hard/soft IRQ, preempt-disabled); +* %false when a bio can be safely completed in the current context. +*/ +static inline bool bio_in_atomic (void ) +{ +if (IS_ENABLED (CONFIG_PREEMPTION ) &&rcu_preempt_depth ()) +return true; +if (!IS_ENABLED (CONFIG_PREEMPT_COUNT )) +return true; +return !preemptible (); +} +extern void bio_endio (struct bio *);/**
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 601/686 f2fs: fix to use bio_in_atomic() in f2fs_read_end_io()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chao Yu <[email protected]>
[ Upstream commit a605d5d71a6d280c43c7ede9778dda63fb5c3f22 ]
f2fs_read_end_io() uses "in_task() && !irqs_disabled()" to decide whether it is safe to sleep, the result is passed down as @in_task to:
- f2fs_put_dic() -> f2fs_free_dic() -> f2fs_release_decomp_mem() -> vm_unmap_ram(), which may sleep.
- f2fs_end_read_compressed_page() -> f2fs_cache_compressed_page() -> f2fs_grab_cache() -> f2fs_lock_cache(), which may sleep in wait_on_bit_lock().
However, the check still treats below task contexts as sleepable:
- with spinlock held via spin_lock(), i.e. preempt count != 0 while irqs are enabled.
- with BH disabled via local_bh_disable().
- inside an RCU read lock on kernels with CONFIG_PREEMPTION.
- with any spinlock held on kernels without CONFIG_PREEMPT_COUNT.
So the "sleeping function called from invalid context" issue fixed by commit 08a7efc5b02a ("f2fs: vm_unmap_ram() may be called from an invalid context") can still be triggered.
The block layer provides bio_in_atomic() for exactly this purpose, it checks rcu_preempt_depth() and preemptible(), and conservatively returns true if CONFIG_PREEMPT_COUNT is disabled, let's use it instead. The difference is as below:
old: intask = in_task() && !irqs_disabled()
new: intask = !bio_in_atomic()
Context | old intask | new intask
-------------------------------------+----------------+----------------
Hard IRQ / softirq | false | false IRQs disabled | false | false spin_lock() held, IRQs enabled | true (wrong) | false BH disabled by local_bh_disable() | true (wrong) | false RCU read lock (CONFIG_PREEMPTION) | true (wrong) | false Spinlock held, w/o PREEMPT_COUNT | true (wrong) | false
Note that on kernels without CONFIG_PREEMPT_COUNT, bio_in_atomic() always returns true, so dic freeing will always be offloaded to sbi->wq, and compressed pages will not be cached in f2fs_read_end_io(); this is the price of correctness, since there is no way to tell whether the current context can sleep.
--- fs/f2fs/data.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/data.c +1 -1
@@ -288,7 +288,7 @@ static void f2fs_read_end_io(struct bio *bio) {struct f2fs_sb_info *sbi =F2FS_F_SB (bio_first_folio_all (bio));struct bio_post_read_ctx *ctx; -bool intask =in_task () && !irqs_disabled (); +bool intask = !bio_in_atomic ();iostat_update_and_unbind_ctx (bio); ctx = bio->bi_private;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 602/686 scsi: ufs: core: Add a helper for clearing hba->outstanding_reqs
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stanley Jhu <[email protected]>
[ Upstream commit 22d14117ec1845a81acb3a5c4be325f7e8332f70 ]
ufshcd_poll() and ufshcd_abort() each have their own copy of the code that clears bits in hba->outstanding_reqs under hba->outstanding_lock.
Move that code into ufshcd_clear_outstanding_reqs() and its locked variant __ufshcd_clear_outstanding_reqs(), and use them in both functions. No functional change.
--- drivers/ufs/core/ufshcd.c | 48 +++++++++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 12 deletions(-)
drivers/ufs/core/ufshcd.c +36 -12
@@ -5694,6 +5694,37 @@ static void ufshcd_clear_polled(struct ufs_hba *hba, } } +/* +* Return a bitmask of the transfer requests cleared from +* @hba->outstanding_reqs. +*/ +static unsigned long __ufshcd_clear_outstanding_reqs (struct ufs_hba *hba, +unsigned long mask, +bool from_irq) + __must_hold(&hba->outstanding_lock) +{ +unsigned long completed_reqs = mask & hba->outstanding_reqs; + +if (from_irq) { +/* Do not complete polled requests from interrupt context. */ +ufshcd_clear_polled (hba, &completed_reqs); + } + hba->outstanding_reqs &= ~completed_reqs; + +return completed_reqs; +} + +/* +* Return a bitmask of the transfer requests cleared from +* @hba->outstanding_reqs. +*/ +static unsigned long ufshcd_clear_outstanding_reqs (struct ufs_hba *hba, +unsigned long mask) +{ +guard (spinlock_irqsave)(&hba->outstanding_lock); +return __ufshcd_clear_outstanding_reqs (hba, mask, false); +} +/* * Return: > 0 if one or more commands have been completed or 0 if no * requests have been completed.
@@ -5704,6 +5735,7 @@ static int ufshcd_poll(struct Scsi_Host *shost, unsigned int queue_num)unsigned long completed_reqs, flags;u32 tr_doorbell;struct ufs_hw_queue *hwq; +bool from_irq;if (hba->mcq_enabled) { hwq = &hba->uhq[queue_num];
@@ -5713,12 +5745,9 @@ static int ufshcd_poll(struct Scsi_Host *shost, unsigned int queue_num)spin_lock_irqsave (&hba->outstanding_lock, flags); tr_doorbell =ufshcd_readl (hba,REG_UTP_TRANSFER_REQ_DOOR_BELL ); - completed_reqs = ~tr_doorbell & hba->outstanding_reqs; -if (queue_num ==UFSHCD_POLL_FROM_INTERRUPT_CONTEXT ) { -/* Do not complete polled requests from interrupt context. */ -ufshcd_clear_polled (hba, &completed_reqs); - } - hba->outstanding_reqs &= ~completed_reqs; + from_irq = queue_num ==UFSHCD_POLL_FROM_INTERRUPT_CONTEXT ; + completed_reqs =__ufshcd_clear_outstanding_reqs (hba, ~tr_doorbell, + from_irq);spin_unlock_irqrestore (&hba->outstanding_lock, flags);if (completed_reqs)
@@ -7739,7 +7768,6 @@ static int ufshcd_abort(struct scsi_cmnd *cmd)struct ufshcd_lrb *lrbp = &hba->lrb[tag];unsigned long flags;int err =FAILED ; -bool outstanding;u32 reg;ufshcd_hold (hba);
@@ -7820,11 +7848,7 @@ static int ufshcd_abort(struct scsi_cmnd *cmd)* Clear the corresponding bit from outstanding_reqs since the command * has been aborted successfully. */ -spin_lock_irqsave (&hba->outstanding_lock, flags); - outstanding =__test_and_clear_bit (tag, &hba->outstanding_reqs); -spin_unlock_irqrestore (&hba->outstanding_lock, flags); - -if (outstanding) +if (ufshcd_clear_outstanding_reqs (hba,BIT (tag)))ufshcd_release_scsi_cmd (hba, lrbp); err =SUCCESS ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 603/686 wifi: mt76: mt7921: assert sniffer on chanctx change
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Devin Wittmayer <[email protected]>
[ Upstream commit a7d35545c2ce11849de4b4397abaf664d79acd28 ]
mt7921_change_chanctx() configures the channel for monitor vifs but does not re-assert sniffer mode. mt7925_change_chanctx() does. Match mt7925 by adding the missing mt7921_mcu_set_sniffer(true) call, completing the architectural pattern from commit 914189af23b8 ("wifi:
mt76: mt7921: fix channel switch fail in monitor mode").
The user-visible regression this asymmetry produced on v6.17 and v6.18 was addressed by commit cdb2941a516c ("Revert "wifi: mt76: mt792x:
improve monitor interface handling"") in v6.19 and backported to the 6.17.y and 6.18.y stable trees. This patch is defense in depth in case the NO_VIRTUAL_MONITOR change is reintroduced in a future series.
Tested-on: RasPi4B, RasPiOS 64 bit, Alfa AWUS036AXML mt7921u
Tested-on: RasPi4B, RasPiOS 64 bit, Netgear A9000 mt7925u
Stable-dep-of: 68342a7bd7e5 ("wifi: mt76: move the channel survey when the channel changes")
--- drivers/net/wireless/mediatek/mt76/mt7921/main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7921/main.c +4 -2
@@ -1405,10 +1405,12 @@ mt7921_change_chanctx(struct ieee80211_hw *hw, vif = container_of((void *)mvif, struct ieee80211_vif, drv_priv);mt792x_mutex_acquire (phy->dev); -if (vif->type ==NL80211_IFTYPE_MONITOR ) +if (vif->type ==NL80211_IFTYPE_MONITOR ) { +mt7921_mcu_set_sniffer (mvif->phy->dev, vif, true);mt7921_mcu_config_sniffer (mvif, ctx); -else + }else {mt76_connac_mcu_uni_set_chctx (mvif->phy->mt76, &mvif->bss_conf.mt76, ctx); + }mt792x_mutex_release (phy->dev); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 604/686 wifi: mt76: move the channel survey when the channel changes
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Devin Wittmayer <[email protected]>
[ Upstream commit 68342a7bd7e5e273e2969e3c0f4c62ee3d006ce8 ]
mt7921 and mt7925 report every survey counter against one channel and never mark the one in use. With firmware channel management, both use channel contexts and never call __mt76_set_channel(), so phy->chan_state, phy->chandef and phy->main_chandef keep the first channel of the band.
Update them when a context is assigned or changed, after booking the time spent on the old channel. This also makes the legacy rate lookup in mt76_connac2_mac_fill_txs() and mt7925_mac_add_txs_skb() use the band of the current channel.
With two channel contexts (multi-channel or MLO), the survey follows the context that was assigned or changed last, since the driver reads the band 0 counters only.
Tested on MT7922 over PCIe, MT7921AU and MT7925 over USB.
--- drivers/net/wireless/mediatek/mt76/mac80211.c | 14 ++++++++++++++ drivers/net/wireless/mediatek/mt76/mt76.h | 2 ++ drivers/net/wireless/mediatek/mt76/mt7921/main.c | 1 + drivers/net/wireless/mediatek/mt76/mt7925/main.c | 2 ++ drivers/net/wireless/mediatek/mt76/mt792x_core.c | 1 + 5 files changed, 20 insertions(+)
drivers/net/wireless/mediatek/mt76/mac80211.c +14 -0
@@ -1034,6 +1034,20 @@ void mt76_update_survey(struct mt76_phy *phy) }EXPORT_SYMBOL_GPL (mt76_update_survey); +void mt76_phy_chandef_set (struct mt76_phy *phy, +struct cfg80211_chan_def *chandef) +{ +if (!chandef->chan) +return ; + +mt76_update_survey (phy); + + phy->chandef = *chandef; + phy->main_chandef = *chandef; + phy->chan_state =mt76_channel_state (phy, chandef->chan); +} +EXPORT_SYMBOL_GPL (mt76_phy_chandef_set); +int __mt76_set_channel (struct mt76_phy *phy,struct cfg80211_chan_def *chandef,bool offchannel) {
drivers/net/wireless/mediatek/mt76/mt76.h +2 -0
@@ -1531,6 +1531,8 @@ void mt76_sta_ps_transition(struct mt76_dev *dev, struct mt76_wcid *wcid,bool mt76_has_tx_pending (struct mt76_phy *phy);int mt76_update_channel (struct mt76_phy *phy);void mt76_update_survey (struct mt76_phy *phy); +void mt76_phy_chandef_set (struct mt76_phy *phy, +struct cfg80211_chan_def *chandef);void mt76_update_survey_active_time (struct mt76_phy *phy,ktime_t time);int mt76_get_survey (struct ieee80211_hw *hw,int idx,struct survey_info *survey);
drivers/net/wireless/mediatek/mt76/mt7921/main.c +1 -0
@@ -1411,6 +1411,7 @@ mt7921_change_chanctx(struct ieee80211_hw *hw, }else {mt76_connac_mcu_uni_set_chctx (mvif->phy->mt76, &mvif->bss_conf.mt76, ctx); } +mt76_phy_chandef_set (mvif->phy->mt76, &ctx->def);mt792x_mutex_release (phy->dev); }
drivers/net/wireless/mediatek/mt76/mt7925/main.c +2 -0
@@ -1864,6 +1864,7 @@ mt7925_change_chanctx(struct ieee80211_hw *hw, link_conf, ctx); } } +mt76_phy_chandef_set (mvif->phy->mt76, &ctx->def);mt792x_mutex_release (phy->dev); }
@@ -2176,6 +2177,7 @@ static int mt7925_assign_vif_chanctx(struct ieee80211_hw *hw, mconf->mt76.ctx = ctx; mctx->bss_conf = mconf; +mt76_phy_chandef_set (mvif->phy->mt76, &ctx->def);mutex_unlock (&dev->mt76.mutex);return 0 ;
drivers/net/wireless/mediatek/mt76/mt792x_core.c +1 -0
@@ -342,6 +342,7 @@ int mt792x_assign_vif_chanctx(struct ieee80211_hw *hw,mutex_lock (&dev->mt76.mutex); mvif->bss_conf.mt76.ctx = ctx; mctx->bss_conf = &mvif->bss_conf; +mt76_phy_chandef_set (&dev->mphy, &ctx->def);mutex_unlock (&dev->mt76.mutex);return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 605/686 ASoC: amd: acp: add DMI override for ACP70 flag
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hasun Park <[email protected]>
[ Upstream commit d0426510a9e1fabf074e274ceff26ffc6500980a ]
Some ASUS ProArt PX13 systems expose ACP ACPI config flags that can select a non-working fallback path.
Add a DMI override in snd_amd_acp_find_config() for ACP70+ boards and return 0 so ACP ACPI flag-based selection is skipped on this platform.
This keeps machine driver selection on the intended SoundWire path.
Stable-dep-of: 38cb2ef26b64 ("ASoC: amd: acp-config: force SoundWire probe on Dell 14S DS14265")
--- sound/soc/amd/acp-config.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
sound/soc/amd/acp-config.c +14 -1
@@ -23,6 +23,16 @@static int acp_quirk_data; +static const struct dmi_system_id acp70_acpi_flag_override_table[] = { + { + .matches = { +DMI_MATCH (DMI_BOARD_VENDOR ,"ASUSTeK COMPUTER INC." ), +DMI_MATCH (DMI_PRODUCT_NAME ,"HN7306EA" ), + }, + }, + {} +}; +static const struct config_entry config_table[] = { { .flags =FLAG_AMD_SOF ,
@@ -200,8 +210,11 @@ int snd_amd_acp_find_config(struct pci_dev *pci)*/ if (!pci->revision)return 0 ; -else if (pci->revision >=ACP_7_0_REV ) +else if (pci->revision >=ACP_7_0_REV ) { +if (dmi_check_system (acp70_acpi_flag_override_table)) +return 0 ;return snd_amd_acp_acpi_find_config (pci); + }for (i =0 ; i <ARRAY_SIZE (config_table); i++, table++) {if (table->device != device)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 606/686 ASoC: amd: acp: Add DMI quirk for ASUS Zenbook S16 UM5606GA
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jasper Smet <[email protected]>
[ Upstream commit 6e4bfd9da8851f562f04503d8e43221957f96eeb ]
The ASUS Zenbook S16 (UM5606GA) with AMD Ryzen AI 9 465 (Strix Point, ACP 7.0) has a BIOS that incorrectly sets the ACPI property 'acp-audio-config-flag' to 0x10 (FLAG_AMD_LEGACY_ONLY_DMIC) for the ACP device. This prevents snd_pci_ps from probing the SoundWire bus, resulting in no internal audio (dummy output only).
The hardware uses a Cirrus Logic CS42L43 (headphone/jack) and four CS35L56 smart amplifiers (speakers), all on SoundWire link 1. The corresponding machine table entry (acp70_cs42l43_l1u0_cs35l56x4_l1u0123) already exists in amd-acp70-acpi-match.c and correctly describes this topology.
Add a DMI quirk to override the flag to 0, consistent with the existing entry for the HN7306EA.
Stable-dep-of: 38cb2ef26b64 ("ASoC: amd: acp-config: force SoundWire probe on Dell 14S DS14265")
--- sound/soc/amd/acp-config.c | 7 +++++++ 1 file changed, 7 insertions(+)
sound/soc/amd/acp-config.c +7 -0
@@ -30,6 +30,13 @@ static const struct dmi_system_id acp70_acpi_flag_override_table[] = { DMI_MATCH(DMI_PRODUCT_NAME, "HN7306EA"), }, }, + { + /* ASUS Zenbook S16 UM5606GA (Strix Point, ACP 7.0) */ + .matches = { + DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK COMPUTER INC."), + DMI_MATCH(DMI_PRODUCT_NAME, "Zenbook S16 UM5606GA"), + }, + }, {} };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 607/686 ASoC: amd: acp: Add DMI quirk for Lenovo Yoga Pro 7 15ASH11
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jackie Dong <[email protected]>
[ Upstream commit fc12cf16df9af867e1455b011cdd9310474a612e ]
Lenovo Yoga Pro 7 15ASH11 with AMD RYZEN AI MAX+ 388 (Strix Halo, ACP 7.0) uses Realtek ALC287 series codec and no any DMIC connected by ACP. All DMICs directly connet with ALC codec.
Without this quirk, Input Device of Gnome Sound settings shows Internal Stereo Microphone and Digital Microphone by default. In fact, Digital Microphone of ACP doesn't work due to no connecting with ALC287 codec, the Internal Stereo Microphone as analog device based on snd_hda_intel driver can work well.
Add a DMI quirk to override the flag to 0, consistent with the existing entry for the HN7306EA.
Stable-dep-of: 38cb2ef26b64 ("ASoC: amd: acp-config: force SoundWire probe on Dell 14S DS14265")
--- sound/soc/amd/acp-config.c | 7 +++++++ 1 file changed, 7 insertions(+)
sound/soc/amd/acp-config.c +7 -0
@@ -37,6 +37,13 @@ static const struct dmi_system_id acp70_acpi_flag_override_table[] = { DMI_MATCH(DMI_PRODUCT_NAME, "Zenbook S16 UM5606GA"), }, }, + { + /* Lenovo Yoga Pro 7 15ASH11 (Strix Halo, ACP 7.0) */ + .matches = { + DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"), + DMI_MATCH(DMI_PRODUCT_NAME, "83W5"), + }, + }, {} };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 608/686 ASoC: amd: acp-config: force SoundWire probe on HP OmniBook X Flip 16
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sehat Mahde <[email protected]>
[ Upstream commit 4d6642d64cd00f276549ec2c0b0278aea2f8c1aa ]
The BIOS on the HP OmniBook X Flip 16-cc0xxx (board 8EA2) reports acp-audio-config-flag = FLAG_AMD_LEGACY_ONLY_DMIC. This binds the legacy ACP driver and registers a PDM-only card, so the SoundWire links are never scanned and the two TAS2783 speaker amplifiers and RT712-VB codec do not enumerate.
Add a DMI entry for board 8EA2 to the ACP70 ACPI flag override table so the firmware-provided flag is overridden and snd_pci_ps probes instead.
On the affected system, an otherwise identical upstream kernel without this entry binds snd_acp_pci, enumerates no SoundWire slave devices and exposes no internal speaker PCM. With the entry added, snd_pci_ps binds, both TAS2783 amplifiers and the RT712-VB enumerate over SoundWire, and the amd-soundwire card exposes the internal speaker playback PCM.
Developed with AI assistance. ChatGPT helped analyze the ACP and SoundWire behavior, structure the controlled A/B testing, and draft the patch changelog. All hardware measurements, kernel builds, reboots and playback tests were performed by the submitter. The submitter has reviewed the change, understands it and takes responsibility for it.
Stable-dep-of: 38cb2ef26b64 ("ASoC: amd: acp-config: force SoundWire probe on Dell 14S DS14265")
--- sound/soc/amd/acp-config.c | 7 +++++++ 1 file changed, 7 insertions(+)
sound/soc/amd/acp-config.c +7 -0
@@ -44,6 +44,13 @@ static const struct dmi_system_id acp70_acpi_flag_override_table[] = { DMI_MATCH(DMI_PRODUCT_NAME, "83W5"), }, }, + { + /* HP OmniBook X Flip 16-cc0xxx */ + .matches = { + DMI_MATCH(DMI_BOARD_VENDOR, "HP"), + DMI_MATCH(DMI_BOARD_NAME, "8EA2"), + }, + }, {} };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 609/686 ASoC: amd: acp-config: force SoundWire probe on Dell 14S DS14265
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Art O Cathain <[email protected]>
[ Upstream commit 38cb2ef26b6411277826da54c6bcf94523541058 ]
The BIOS on the Dell 14S DS14265 (ACP PCI revision 0x72) reports acp-audio-config-flag = FLAG_AMD_LEGACY_ONLY_DMIC. As a result snd_pci_ps returns early and the SoundWire links are never scanned, while the legacy snd_acp_pci driver probes the device, finds no matching machine driver ("No matching ASoC machine driver found") and no internal sound card is created. The CS42L45 headset codec on link 0 and the two CS35L63 speaker amplifiers on link 1 never enumerate.
Add a DMI entry for the model to the ACP70 ACPI flag override table so the firmware-provided flag is overridden and snd_pci_ps probes instead. Match on the product name rather than the board name, as the same symptom has been reported on several boards of this model (09PVND, 0M0J65, 0C7F12).
Tested on a DS14265 (board 09PVND, BIOS 1.5.3) with Debian's 7.2.6 kernel, with and without this entry. With it, snd_pci_ps binds, both SoundWire links come up, the CS42L45 and both CS35L63 enumerate, the existing CS42L45 + 2x CS35L63 machine entry matches, the amplifiers load their firmware and calibration, and the amd-soundwire card plays through both the internal speakers and the headphone jack. Also build-tested on asoc-next with W=1.
Developed with AI assistance. Claude read the ACP driver source, identified the BIOS flag as the cause and the override table as the fix, wrote the DMI entry and the out-of-tree test module, and drafted this changelog. All hardware testing was done by the submitter, who has reviewed the change, understands it and takes responsibility for it.
--- sound/soc/amd/acp-config.c | 7 +++++++ 1 file changed, 7 insertions(+)
sound/soc/amd/acp-config.c +7 -0
@@ -51,6 +51,13 @@ static const struct dmi_system_id acp70_acpi_flag_override_table[] = { DMI_MATCH(DMI_BOARD_NAME, "8EA2"), }, }, + { + /* Dell 14S DS14265 */ + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + DMI_MATCH(DMI_PRODUCT_NAME, "Dell 14S DS14265"), + }, + }, {} };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 610/686 perf evsel: Restrict incremental open error unwind
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hui Su <[email protected]>
[ Upstream commit d023b2110d0d7232ba952a486c497ba8817f6f66 ]
evsel__open_cpu(), evsel__tool_pmu_open() and evsel__hwmon_pmu_open() support opening a subrange of a CPU map, bounded by [start_cpu_map_idx, end_cpu_map_idx).
Their error paths, however, unwind using "while (--idx >= 0)" all the way back to CPU index 0 regardless of start_cpu_map_idx. If lower CPU indices were opened by an earlier invocation, a later incremental open failure therefore closes those existing file descriptors and overwrites their slots with -1.
Before this fix, running the new incremental open test demonstrates this corruption:
$ perf test -v "Tool PMU"
12: Tool PMU:
12.1: Tool PMU : Ok
12.2: Tool PMU leader : Ok
12.3: Incremental open error unwind boundary:
FAILED: CPU 0 FD overwritten: FD(evsel, 0, 0)=-1, expected 4
FAILED!Stop the unwind at start_cpu_map_idx so that only file descriptors opened by the current invocation are rolled back.
After this fix:
$ perf test -v "Tool PMU" 12: Tool PMU: 12.1: Tool PMU : Ok 12.2: Tool PMU leader : Ok 12.3: Incremental open error unwind boundary : Ok
Stable-dep-of: 16d1234793d4 ("perf evsel: Close the fds opened so far when disabling missing features")
--- tools/perf/tests/tool_pmu.c | 79 +++++++++++++++++++++++++++++++++++++ tools/perf/util/evsel.c | 2 +- tools/perf/util/hwmon_pmu.c | 2 +- tools/perf/util/tool_pmu.c | 2 +- 4 files changed, 82 insertions(+), 3 deletions(-)
tools/perf/tests/tool_pmu.c +79 -0
@@ -1,8 +1,16 @@// SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) +#include <errno.h> +#include <fcntl.h> +#include <string.h> +#include <unistd.h> +#include <internal/xyarray.h> +#include "cpumap.h" #include "debug.h" #include "evlist.h" +#include "evsel.h" #include "parse-events.h" #include "tests.h" +#include "thread_map.h" #include "tool_pmu.h" static int do_test (enum tool_pmu_event ev,bool with_pmu)
@@ -99,9 +107,80 @@ static int test__tool_pmu_with_pmu(struct test_suite *test __maybe_unused,return TEST_OK ; } +static int test__tool_pmu_incremental_open_unwind (struct test_suite *test__maybe_unused , +int subtest__maybe_unused ) +{ +struct evlist *evlist =evlist__new (); +struct parse_events_error err; +struct perf_cpu_map *cpus =NULL ; +struct perf_thread_map *threads =NULL ; +struct evsel *evsel; +int ret =TEST_FAIL , fd0 =-1 ; + +if (!evlist) +return TEST_FAIL ; + +parse_events_error__init (&err); +if (parse_events (evlist,"tool/user_time/" , &err)) { +parse_events_error__exit (&err); +evlist__delete (evlist); +return TEST_FAIL ; + } +parse_events_error__exit (&err); + + evsel =evlist__first (evlist); + cpus =perf_cpu_map__new ("0,1" ); + threads =thread_map__new_by_tid (getpid ()); +if (!cpus || !threads) + goto out; + +/* Step 1: Open CPU index 0 successfully */ +if (evsel__open_per_cpu_and_thread (evsel, cpus,0 , threads) <0 ) { +pr_debug ("Failed to open CPU index 0\n" ); + goto out; + } + + fd0 = (*(int *)xyarray__entry (evsel->core.fd,0 ,0 )); +if (fd0 <0 ||fcntl (fd0,F_GETFD ) <0 ) { +pr_debug ("CPU index 0 FD is invalid (%d)\n" , fd0); + goto out; + } + +/* Step 2: Intentionally trigger failure on CPU index 1 */ + evsel->core.attr.sample_period =1 ;/* Not supported for tool PMU -> -EINVAL */ +if (evsel__open_per_cpu_and_thread (evsel, cpus,1 , threads) >=0 ) { +pr_debug ("Unexpected success opening CPU index 1 with sample_period=1\n" ); + goto out; + } + +/* +* Step 3: Check that CPU index 0's FD was NOT destroyed by CPU index 1's unwind. +*/ +if ((*(int *)xyarray__entry (evsel->core.fd,0 ,0 )) != fd0) { +pr_debug ("FAILED: CPU 0 FD overwritten: FD(evsel, 0, 0)=%d, expected %d\n" , + (*(int *)xyarray__entry (evsel->core.fd,0 ,0 )), fd0); + goto out; + } + +if (fcntl (fd0,F_GETFD ) <0 ) { +pr_debug ("FAILED: CPU 0 FD %d was closed by error unwind! errno=%d (%s)\n" , + fd0, errno,strerror (errno)); + goto out; + } + + ret =TEST_OK ; +out: +evsel__close (evsel); +perf_cpu_map__put (cpus); +perf_thread_map__put (threads); +evlist__delete (evlist); +return ret; +} +static struct test_case tests__tool_pmu[] = {TEST_CASE ("Parsing without PMU name" , tool_pmu_without_pmu),TEST_CASE ("Parsing with PMU name" , tool_pmu_with_pmu), +TEST_CASE ("Incremental open error unwind boundary" , tool_pmu_incremental_open_unwind), { .name =NULL , } };
tools/perf/util/evsel.c +1 -1
@@ -2810,7 +2810,7 @@ static int evsel__open_cpu(struct evsel *evsel, struct perf_cpu_map *cpus,FD (evsel, idx, thread) =-1 ; } thread = nthreads; - }while (--idx >=0 ); + }while (--idx >= start_cpu_map_idx); errno = old_errno; out:if (err)
tools/perf/util/hwmon_pmu.c +1 -1
@@ -803,7 +803,7 @@ int evsel__hwmon_pmu_open(struct evsel *evsel,FD (evsel, idx, thread) =-1 ; } thread = nthreads; - }while (--idx >=0 ); + }while (--idx >= start_cpu_map_idx);close (dir);return err; }
tools/perf/util/tool_pmu.c +1 -1
@@ -296,7 +296,7 @@ int evsel__tool_pmu_open(struct evsel *evsel,FD (evsel, idx, thread) =-1 ; } thread = nthreads; - }while (--idx >=0 ); + }while (--idx >= start_cpu_map_idx); errno = old_errno;return err; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 611/686 perf evsel: Close the fds opened so far when disabling missing features
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnaldo Carvalho de Melo <[email protected]>
[ Upstream commit 16d1234793d42a5a594db99522845996ab8e0d29 ]
evsel__open_cpu() opens the events one by one and, when an open fails with EINVAL and evsel__detect_missing_features() has a feature to leave out, goes back to fallback_missing_features to open them all again from start_cpu_map_idx, without closing what the abandoned attempt opened:
the fd of every CPU or thread that was opened before the failing one is overwritten in the FD() array, leaking it.
Close them first, the same way out_close does when returning an error, leaving the entries at -1 for the retry.
--- tools/perf/util/evsel.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-)
tools/perf/util/evsel.c +21 -9
@@ -2642,6 +2642,19 @@ static bool evsel__detect_missing_features(struct evsel *evsel, struct perf_cpureturn false; } +static void evsel__close_fds (struct evsel *evsel,int start_cpu_map_idx, +int cpu_map_idx,int thread,int nthreads) +{ +do { +while (--thread >=0 ) { +if (FD (evsel, cpu_map_idx, thread) >=0 ) +close (FD (evsel, cpu_map_idx, thread)); +FD (evsel, cpu_map_idx, thread) =-1 ; + } + thread = nthreads; + }while (--cpu_map_idx >= start_cpu_map_idx); +} +static int evsel__open_cpu (struct evsel *evsel,struct perf_cpu_map *cpus,struct perf_thread_map *threads,int start_cpu_map_idx,int end_cpu_map_idx)
@@ -2792,8 +2805,14 @@ static int evsel__open_cpu(struct evsel *evsel, struct perf_cpu_map *cpus,if (err == -EMFILE &&rlimit__increase_nofile (&set_rlimit)) goto retry_open; -if (err == -EINVAL &&evsel__detect_missing_features (evsel, cpu)) +if (err == -EINVAL &&evsel__detect_missing_features (evsel, cpu)) { +/* +* The restart opens the events again, so close what this +* attempt opened before its entries are overwritten. +*/ +evsel__close_fds (evsel, start_cpu_map_idx, idx, thread, nthreads); goto fallback_missing_features; + }if (evsel__precise_ip_fallback (evsel)) goto retry_open;
@@ -2803,14 +2822,7 @@ static int evsel__open_cpu(struct evsel *evsel, struct perf_cpu_map *cpus, threads->err_thread = thread; old_errno = errno; -do { -while (--thread >=0 ) { -if (FD (evsel, idx, thread) >=0 ) -close (FD (evsel, idx, thread)); -FD (evsel, idx, thread) =-1 ; - } - thread = nthreads; - }while (--idx >= start_cpu_map_idx); +evsel__close_fds (evsel, start_cpu_map_idx, idx, thread, nthreads); errno = old_errno; out:if (err)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 612/686 KVM: arm64: vgic: Stop the target vcpu when disabling LPIs
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marc Zyngier <[email protected]>
[ Upstream commit a1b4bd2c2c262b8094c86afb99364d16ac08cb66 ]
Disabling LPIs is pretty nasty, as it directly messes with the AP list of the affected CPU, which could be running... This has the potential to lead to really bad behaviours, and we should not be doing that.
Take example on the way the Active state is handled and simply pause the the vcpu so that we are sure it is in a quiescent state, and the state be safely manipulated.
Nobody has any expectation of performance for this anyway.
--- arch/arm64/kvm/vgic/vgic-mmio-v3.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
arch/arm64/kvm/vgic/vgic-mmio-v3.c +10 -0
@@ -303,9 +303,19 @@ static void vgic_mmio_write_v3r_ctlr(struct kvm_vcpu *vcpu,if (ctlr !=GICR_CTLR_ENABLE_LPIS )return ; +/* +* Yes, disabling LPIs is painful, since it can be done from +* a *remote* vcpu! So let's not take any chance, and make +* sure that the target vCPU has written their LRs back to the +* irq structures, and release any reference they would have. +* +* If it hurts, don't do it. +*/ +kvm_arm_halt_guest (vcpu->kvm);vgic_flush_pending_lpis (vcpu);vgic_its_invalidate_all_caches (vcpu->kvm);atomic_set_release (&vgic_cpu->ctlr,0 ); +kvm_arm_resume_guest (vcpu->kvm); }else { ctlr =atomic_cmpxchg_acquire (&vgic_cpu->ctlr,0 ,GICR_CTLR_ENABLE_LPIS );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 613/686 platform/x86: Rename lenovo-wmi-capdata01 to lenovo-wmi-capdata
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rong Zhang <[email protected]>
[ Upstream commit f28d76b17561bd5f1b7b2c8f139a00158218c2d2 ]
Prepare for the upcoming changes to make it suitable to retrieve and provide other Capability Data as well.
Stable-dep-of: 3b53e691e907 ("platform/x86: lenovo-wmi-capdata: Do not stop the AC notifier chain on error")
---
drivers/platform/x86/lenovo/Kconfig | 4 +-
drivers/platform/x86/lenovo/Makefile | 2 +-
.../lenovo/{wmi-capdata01.c => wmi-capdata.c} | 124 +++++++++---------
.../lenovo/{wmi-capdata01.h => wmi-capdata.h} | 10 +-
drivers/platform/x86/lenovo/wmi-other.c | 11 +-
5 files changed, 78 insertions(+), 73 deletions(-)
rename drivers/platform/x86/lenovo/{wmi-capdata01.c => wmi-capdata.c} (60%)
rename drivers/platform/x86/lenovo/{wmi-capdata01.h => wmi-capdata.h} (60%)drivers/platform/x86/lenovo/Kconfig +2 -2
@@ -233,7 +233,7 @@ config YT2_1380 To compile this driver as a module, choose M here: the module will be called lenovo-yogabook. -config LENOVO_WMI_DATA01 +config LENOVO_WMI_CAPDATA tristate depends on ACPI_WMI
@@ -264,7 +264,7 @@ config LENOVO_WMI_TUNING tristate "Lenovo Other Mode WMI Driver" depends on ACPI_WMI select FW_ATTR_CLASS - select LENOVO_WMI_DATA01 + select LENOVO_WMI_CAPDATA select LENOVO_WMI_EVENTS select LENOVO_WMI_HELPERS help
drivers/platform/x86/lenovo/Makefile +1 -1
@@ -12,7 +12,7 @@ lenovo-target-$(CONFIG_LENOVO_YMC) += ymc.o lenovo-target-$(CONFIG_YOGABOOK) += yogabook.o lenovo-target-$(CONFIG_YT2_1380) += yoga-tab2-pro-1380-fastcharger.o lenovo-target-$(CONFIG_LENOVO_WMI_CAMERA) += wmi-camera.o -lenovo-target-$(CONFIG_LENOVO_WMI_DATA01) += wmi-capdata01.o +lenovo-target-$(CONFIG_LENOVO_WMI_CAPDATA) += wmi-capdata.o lenovo-target-$(CONFIG_LENOVO_WMI_EVENTS) += wmi-events.o lenovo-target-$(CONFIG_LENOVO_WMI_HELPERS) += wmi-helpers.o lenovo-target-$(CONFIG_LENOVO_WMI_GAMEZONE) += wmi-gamezone.o
drivers/platform/x86/lenovo/wmi-capdata.c renamed from drivers/platform/x86/lenovo/wmi-capdata01.c +63 -61
275 lines not on this page · raw message
drivers/platform/x86/lenovo/wmi-capdata.h renamed from drivers/platform/x86/lenovo/wmi-capdata01.h +5 -5
@@ -2,13 +2,13 @@/* Copyright (C) 2025 Derek J. Clark <[email protected]> */ -#ifndef _LENOVO_WMI_CAPDATA01_H_ -#define _LENOVO_WMI_CAPDATA01_H_ +#ifndef _LENOVO_WMI_CAPDATA_H_ +#define _LENOVO_WMI_CAPDATA_H_ #include <linux/types.h> struct device; -struct cd01_list; +struct cd_list; struct capdata01 { u32 id;
@@ -19,7 +19,7 @@ struct capdata01 { u32 max_value; }; -int lwmi_cd01_get_data (struct cd01_list *list,u32 attribute_id,struct capdata01 *output); +int lwmi_cd01_get_data (struct cd_list *list,u32 attribute_id,struct capdata01 *output);int lwmi_cd01_match (struct device *dev,void *data); -#endif /* !_LENOVO_WMI_CAPDATA01_H_ */ +#endif /* !_LENOVO_WMI_CAPDATA_H_ */
drivers/platform/x86/lenovo/wmi-other.c +7 -4
@@ -34,7 +34,7 @@#include <linux/types.h> #include <linux/wmi.h> -#include "wmi-capdata01.h" +#include "wmi-capdata.h" #include "wmi-events.h" #include "wmi-helpers.h" #include "wmi-other.h"
@@ -73,7 +73,10 @@ enum attribute_property {struct lwmi_om_priv {struct component_master_ops *ops; -struct cd01_list *cd01_list;/* only valid after capdata01 bind */ + +/* only valid after capdata bind */ +struct cd_list *cd01_list; +struct device *fw_attr_dev;struct kset *fw_attr_kset;struct notifier_block nb;
@@ -574,7 +577,7 @@ static void lwmi_om_fw_attr_remove(struct lwmi_om_priv *priv)static int lwmi_om_master_bind (struct device *dev) {struct lwmi_om_priv *priv =dev_get_drvdata (dev); -struct cd01_list *tmp_list; +struct cd_list *tmp_list;int ret; ret =component_bind_all (dev, &tmp_list);
@@ -655,7 +658,7 @@ static struct wmi_driver lwmi_other_driver = {module_wmi_driver (lwmi_other_driver); -MODULE_IMPORT_NS ("LENOVO_WMI_CD01" ); +MODULE_IMPORT_NS ("LENOVO_WMI_CAPDATA" );MODULE_IMPORT_NS ("LENOVO_WMI_HELPERS" );MODULE_DEVICE_TABLE (wmi, lwmi_other_id_table);MODULE_AUTHOR ("Derek J. Clark <[email protected]>" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 614/686 platform/x86: lenovo-wmi-capdata: Do not stop the AC notifier chain on error
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rong Zhang <[email protected]>
[ Upstream commit 3b53e691e907086672b72d0544e4bf27efd4250d ]
Returning NOTIFY_BAD to the AC notifier chain stops it by preventing later notifier blocks from being called, but our error is non-fatal for other AC notifier blocks, which should continue to consume the event.
Return NOTIFY_DONE and add a dev_warn() on error, so that the AC notifier chain continues. This also aligns with hp-wmi.
The function documentation was copied from elsewhere and makes no sense here, so correct it as well.
--- drivers/platform/x86/lenovo/wmi-capdata.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
drivers/platform/x86/lenovo/wmi-capdata.c +12 -6
@@ -188,13 +188,11 @@ static int lwmi_cd_setup(struct lwmi_cd_priv *priv)/** * lwmi_cd01_notifier_call() - Call method for cd01 notifier. -* block call chain. -* @nb: The notifier_block registered to lenovo-wmi-events driver. +* @nb: The cd01 ACPI notifier_block. * @action: Unused. * @data: The ACPI event. * -* For LWMI_EVENT_THERMAL_MODE, set current_mode and notify platform_profile -* of a change. +* Refresh cached capdata on AC status change. * * Return: notifier_block status. */
@@ -213,8 +211,16 @@ static int lwmi_cd01_notifier_call(struct notifier_block *nb, unsigned long actiswitch (event->type) {case ACPI_AC_NOTIFY_STATUS : ret =lwmi_cd_cache (priv); -if (ret) -return NOTIFY_BAD ; +if (ret) { +dev_warn (&priv->wdev->dev, +"failed to refresh capdata on AC change: %d\n" , ret); + +/* +* Our error is non-fatal for others, and we still want +* the other event consumers to process it. +*/ +return NOTIFY_DONE ; + }return NOTIFY_OK ;default :
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 615/686 iio: adc: ad4080: enable address ascension for chip identification
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Antoniu Miclaus <[email protected]>
[ Upstream commit c051d08d98771132868abf0cb95b6de95ab3060a ]
The two byte bulk read at AD4080_REG_PRODUCT_ID_L expects PRODUCT_ID_L followed by PRODUCT_ID_H. After a software reset the AD408x defaults to descending address mode, so the second byte comes from CHIP_TYPE (0x03) instead. CHIP_TYPE reads 0x07 on all AD408x parts, so an AD4080 reports 0x0750 rather than 0x0050 and every part logs "Unrecognized CHIP_ID".
Set ADDR_ASC along with SDO_ENABLE before the read. This is the only multi byte transfer in the driver, so no other access is affected.
--- drivers/iio/adc/ad4080.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iio/adc/ad4080.c +2 -1
@@ -455,7 +455,8 @@ static int ad4080_setup(struct iio_dev *indio_dev)return ret; ret =regmap_write (st->regmap,AD4080_REG_INTERFACE_CONFIG_A , -AD4080_INTERFACE_CONFIG_A_SDO_ENABLE ); +AD4080_INTERFACE_CONFIG_A_SDO_ENABLE | +AD4080_INTERFACE_CONFIG_A_ADDR_ASC );if (ret)return ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 616/686 fbcon: Retry rotated font allocation after failure
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yao Yiqi <[email protected]>
[ Upstream commit 7935db1a4a0f83a63590a222500e5016e2f6c85e ]
fbcon_rotate_font() records the font, its geometry and the rotation in par->rotated before calling font_data_rotate(). If the allocation fails, the error path clears par->rotated.buf, but the recorded key already looks up to date, so the next call takes the early-out and never retries. The rotated putcs/cursor ops keep returning early on the NULL buffer, and the console stays blank even after memory is available again.
Also test par->rotated.buf in the early-out, so a failed allocation is retried on the next call: at the next fbcon_switch(), fbcon_modechanged() or font change.
--- drivers/video/fbdev/core/fbcon_rotate.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/video/fbdev/core/fbcon_rotate.c +2 -1
@@ -27,7 +27,8 @@ static int fbcon_rotate_font(struct fb_info *info, struct vc_data *vc)u8 *dst;if (vc->vc_font.data == par->fontdata && - par->p->con_rotate == par->cur_rotate) + par->p->con_rotate == par->cur_rotate && + par->fontbuffer) goto finished; src = par->fontdata = vc->vc_font.data;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 617/686 mm: hugetlb: return -ENOSPC on memcg charge failure
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ackerley Tng <[email protected]>
[ Upstream commit 956aeff185e7e16b989202bde0bb29859adba99d ]
Patch series "Fix bugs in HugeTLB allocation whenmem_cgroup_charge_hugetlb() fails", v2.
In hugetlb_alloc_folio(), when mem_cgroup_charge_hugetlb() fails, there are 2 issues:
1. free_huge_folio() expects a non-refcounted folio and will VM_BUG_ON_FOLIO().
2. -ENOMEM is returned, causing an infinite loop retrying the fault.
This patch (of 2):
When mem_cgroup_charge_hugetlb() fails with -ENOMEM, alloc_hugetlb_folio() currently propagates this error. This results in the page fault handler returning VM_FAULT_OOM.
Because HugeTLB allocations are high-order and use __GFP_RETRY_MAYFAIL, they bypass the OOM killer. Returning VM_FAULT_OOM to the #PF handler without triggering the OOM killer (or having it make progress) leads to an infinite loop of retrying the fault.
Avoid this loop by returning -ENOSPC when charging fails, which maps to VM_FAULT_SIGBUS, terminating the process cleanly.
Make mem_cgroup_charge_hugetlb() fault handling use a common error handling path, the same handling used for hugetlb_cgroup_uncharge_cgroup{,_rsvd}(), which also don't trigger the OOM killer and hence opt to terminate the process with a SIGBUS.
--- mm/hugetlb.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
mm/hugetlb.c +5 -1
@@ -3134,7 +3134,11 @@ struct folio *alloc_hugetlb_folio(struct vm_area_struct *vma,if (ret == -ENOMEM ) {free_huge_folio (folio); -return ERR_PTR (-ENOMEM ); +/* +* Return -ENOSPC, since retrying the fault is futile: +* the OOM killer is not triggered for HugeTLB. +*/ +return ERR_PTR (-ENOSPC ); }return folio;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 618/686 mm: hugetlb: drop refcount before freeing on memcg charge failure
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ackerley Tng <[email protected]>
[ Upstream commit e95d29c5df84f19881cd30b491fc81aa98f44b45 ]
When mem_cgroup_charge_hugetlb(folio, gfp) returns -ENOMEM, the folio has its refcount set to 1 via folio_ref_unfreeze(folio, 1).
The error path calls free_huge_folio(folio) directly, which expects a refcount of 0. Hence, VM_BUG_ON_FOLIO(folio_ref_count(folio), folio) is triggered.
Even with CONFIG_DEBUG_VM disabled, returning a folio with refcount 1 to the freelist can corrupt allocator state later.
Use folio_put(folio) instead of free_huge_folio(folio) to properly drop the reference before freeing it.
--- mm/hugetlb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/hugetlb.c +1 -1
@@ -3133,7 +3133,7 @@ struct folio *alloc_hugetlb_folio(struct vm_area_struct *vma,lruvec_stat_mod_folio (folio,NR_HUGETLB ,pages_per_huge_page (h));if (ret == -ENOMEM ) { -free_huge_folio (folio); +folio_put (folio);/* * Return -ENOSPC, since retrying the fault is futile: * the OOM killer is not triggered for HugeTLB.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 619/686 xen/gntdev: Fix gntdev_dmabuf ref leak in dmabuf_exp_wait_released()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit 6f165abe2b40ede71c98956cd74cd17c18505e75 ]
dmabuf_exp_wait_released() takes a reference on the exported gntdev_dmabuf with dmabuf_exp_wait_obj_get_dmabuf() and passes it to dmabuf_exp_wait_obj_new(), which drops that reference after adding the wait object to the wait list. When the wait object allocation fails, dmabuf_exp_wait_obj_new() returns ERR_PTR(-ENOMEM) early and the reference is never dropped, leaking a reference to the exported gntdev_dmabuf.
Drop the reference on the allocation failure path so the reference is consumed whether the wait object is created or not.
Message-ID: <[email protected]>
--- drivers/xen/gntdev-dmabuf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/xen/gntdev-dmabuf.c +3 -1
@@ -96,8 +96,10 @@ dmabuf_exp_wait_obj_new(struct gntdev_dmabuf_priv *priv,struct gntdev_dmabuf_wait_obj *obj; obj =kzalloc (sizeof (*obj),GFP_KERNEL ); -if (!obj) +if (!obj) { +kref_put (&gntdev_dmabuf->u.exp.refcount, dmabuf_exp_release);return ERR_PTR (-ENOMEM ); + }init_completion (&obj->completion); obj->gntdev_dmabuf = gntdev_dmabuf;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 620/686 mm/mempolicy: use vm_normal_folio_pmd() in queue_folios_pmd()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gregory Price <[email protected]>
[ Upstream commit 9057170a941f0c5f4058f6fb9ab5d5fc9fcc9e83 ]
Patch series "mm: stop calling pmd_folio() on special PMDs", v3.
Two page table walkers resolve the folio behind a PMD with pmd_folio(), which is only valid for a PMD mapping a refcounted struct page:
madvise_cold_or_pageout_pte_range() mm/madvise.c queue_folios_pmd() mm/mempolicy.c
vmf_insert_pfn_pmd() installs special PMDs holding a raw pfn that need not have a memmap entry at all. Both walkers can reach one and fault on the first folio field read. The PTE halves of both already use vm_normal_folio(); these two patches make the PMD halves match.
The four callers of vmf_insert_pfn_pmd(), and which walker each reaches:
drivers/vfio/pci/vfio_pci_core.c VM_PFNMAP mempolicy drivers/gpu/drm/drm_gem_shmem_helper.c VM_PFNMAP mempolicy drivers/gpu/drm/panthor/panthor_gem.c VM_PFNMAP mempolicy drivers/hv/mshv_vtl_main.c VM_MIXEDMAP both
can_madv_lru_vma() rejects VM_PFNMAP, so only mshv_vtl_low reaches the madvise walker, and that needs CAP_SYS_ADMIN. queue_pages_walk_ops supplies its own ->test_walk, so walk_page_test()'s generic VM_PFNMAP skip never runs and vfio-pci is reachable by any process holding the device fd. Hence the different stable tags.
One behaviour change: mbind(MPOL_MF_STRICT) over a PMD mapped VM_PFNMAP region now returns 0 rather than -EIO. The PTE loop already returned 0 there. drm_gem_shmem and panthor are where this is observable, since they PMD map pages that do have a memmap entry and so never faulted.
Reproducer
==========
No hardware needed. An out of tree module stands in for the drivers
above: three misc devices, each with a ->huge_fault calling vmf_insert_pfn_pmd(), plus VM_HUGEPAGE so the fault path takes the PMD branch.
/dev/pmdspec_mixed VM_MIXEDMAP, pfn at the 1 TiB mark, no memmap /dev/pmdspec_pfnmap VM_PFNMAP, pfn at the 1 TiB mark, no memmap /dev/pmdspec_real VM_PFNMAP, real alloc_pages(PMD_ORDER) on node 0
Userspace maps the device into a PMD aligned window, reads one byte to fault the PMD in, checks a module parameter to confirm it went in, then issues the operation.
vng --run <bzImage> --user root --memory 4G --verbose \
--append "numa=fake=2" \
--exec "insmod pmdspec.ko && ./pmdspec_test <subtest>"numa=fake=2 gives a node 1 to bind to; the module allocates its real page on node 0, which is what makes queue_folio_required() true.
subtest operation parent series
--------------------------------------------------------------------
madv_cold madvise(MADV_COLD) oops ret=0 madv_pageout madvise(MADV_PAGEOUT) oops ret=0 mbind_mixed mbind(MPOL_BIND, n1, MPOL_MF_MOVE) oops ret=0 mbind_pfnmap mbind(MPOL_BIND, n1, MPOL_MF_STRICT) oops ret=0 mbind_real mbind(MPOL_BIND, n1, MPOL_MF_STRICT) -EIO ret=0
Two things the table shows that are easy to miss in the code:
- mbind_mixed passes only MPOL_MF_MOVE. MPOL_MF_STRICT is not needed for a VM_MIXEDMAP vma: walk_page_test() only skips VM_PFNMAP, and vma_migratable() is true for VM_MIXEDMAP.
- mbind_real demonstrates the user visible change (-EIO -> 0)
This patch (of 2):
mmap a VM_PFNMAP region whose ->huge_fault installs a PMD through vmf_insert_pfn_pmd() - a vfio-pci MMIO BAR does this - then
mbind(p, len, MPOL_BIND, &mask, maxnode, MPOL_MF_STRICT);
With a stand-in module for the driver:
BUG: unable to handle page fault for address: fffff96dc0000008 RIP: 0010:queue_folios_pte_range+0xaf/0x440 walk_pgd_range+0x52b/0xaf0 __walk_page_range+0x6a/0x1d0 walk_page_range_mm_unsafe+0x193/0x230 queue_pages_range+0x64/0xa0 do_mbind+0x25e/0x640
queue_folios_pmd(), inlined above, calls pmd_folio() on that PMD. The pfn is raw MMIO with no memmap entry, so the folio lands in unpopulated vmemmap. Neither guard stops the walk:
walk_page_test() skips VM_PFNMAP, but queue_pages_walk_ops
supplies ->test_walk, so it never runs
queue_pages_test_walk() honours vma_migratable(), but only while
MPOL_MF_STRICT is clear
A VM_MIXEDMAP vma needs neither flag, being vma_migratable(), so plain mbind(MPOL_MF_MOVE) reaches this too - and there the bad folio carries on into migrate_folio_add() and folio_isolate_lru(). mshv_vtl_low is such a mapping.
Use vm_normal_folio_pmd() and skip on NULL, as the PTE loop in queue_folios_pte_range() already does with vm_normal_folio(). This also filters the huge zero PMD, so its separate check is no longer needed.
mbind(MPOL_MF_STRICT) over a PMD mapped VM_PFNMAP region now returns 0 rather than -EIO. The PTE loop already returned 0 there.
--- mm/mempolicy.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
mm/mempolicy.c +5 -6
@@ -646,7 +646,8 @@ static inline bool queue_folio_required(struct folio *folio,return node_isset (nid, *qp->nmask) == !(flags &MPOL_MF_INVERT ); } -static void queue_folios_pmd (pmd_t *pmd,struct mm_walk *walk) +static void queue_folios_pmd (pmd_t *pmd,unsigned long addr, +struct mm_walk *walk) {struct folio *folio;struct queue_pages *qp = walk->private;
@@ -655,11 +656,9 @@ static void queue_folios_pmd(pmd_t *pmd, struct mm_walk *walk) qp->nr_failed++;return ; } - folio =pmd_folio (*pmd); -if (is_huge_zero_folio (folio)) { - walk->action =ACTION_CONTINUE ; + folio =vm_normal_folio_pmd (walk->vma, addr, *pmd); +if (!folio ||folio_is_zone_device (folio))return ; - }if (!queue_folio_required (folio, qp))return ; if (!(qp->flags & (MPOL_MF_MOVE | MPOL_MF_MOVE_ALL)) ||
@@ -692,7 +691,7 @@ static int queue_folios_pte_range(pmd_t *pmd, unsigned long addr, ptl =pmd_trans_huge_lock (pmd, vma);if (ptl) { -queue_folios_pmd (pmd, walk); +queue_folios_pmd (pmd, addr, walk);spin_unlock (ptl); goto out; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 621/686 ublk: mark the io command cancelable before publishing it
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ming Lei <[email protected]>
[ Upstream commit a261f0cacacc022e4fab5b8e38c59f74ce4942e8 ]
FETCH, COMMIT_AND_FETCH and NEED_GET_DATA publish the command in io->cmd before marking it cancelable. A cancel from the control path (STOP_DEV, QUIESCE_DEV) can complete it in between:
issue path control-path cancel
io->cmd = C
take C, io_uring_cmd_done(C):
C not marked, nothing to unlink
ublk_prep_cancel(C)
the completed C is linked on the cancelable list
ring exit: the cancel walk hits it → GPF (KASAN, with a delay added)
Mark the command before ublk_fill_io_cmd() publishes it. The handlers run with uring_lock held, as io_uring's cancel walk does, so marking takes no lock and the walk can't see a marked command before it is published. smp_wmb() orders the mark before the io->cmd store; the cancel loads cmd with READ_ONCE(io->cmd) before reading cmd->flags.
A marked command has to be completed by io_uring_cmd_done(), so a failed FETCH and the inline UBLK_IO_RES_OK of NEED_GET_DATA now do that. The CQE is the same.
--- drivers/block/ublk_drv.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-)
drivers/block/ublk_drv.c +22 -6
@@ -2003,8 +2003,10 @@ static void ublk_cancel_cmd(struct ublk_queue *ubq, unsigned tag, io->flags |=UBLK_IO_FLAG_CANCELED ;spin_unlock (&ubq->cancel_lock); +/* dependency ordered against smp_wmb() in ublk_prep_cancel() */ if (!done) -io_uring_cmd_done (io->cmd,UBLK_IO_RES_ABORT , issue_flags); +io_uring_cmd_done (READ_ONCE (io->cmd),UBLK_IO_RES_ABORT , + issue_flags); }/*
@@ -2274,6 +2276,12 @@ ublk_fill_io_cmd(struct ublk_io *io, struct io_uring_cmd *cmd)return req; } +/* +* Call before ublk_fill_io_cmd() publishes @cmd in io->cmd: a control-path +* cancel may complete any command found there, and io_uring_cmd_done() only +* takes it off the cancelable list if it is marked already. The handlers +* hold uring_lock, so marking takes no lock. +*/ static inline void ublk_prep_cancel (struct io_uring_cmd *cmd,unsigned int issue_flags,struct ublk_queue *ubq,unsigned int tag)
@@ -2287,6 +2295,8 @@ static inline void ublk_prep_cancel(struct io_uring_cmd *cmd, pdu->ubq = ubq; pdu->tag = tag;io_uring_cmd_mark_cancelable (cmd, issue_flags); +/* pairs with the cancel loading cmd from io->cmd, then cmd->flags */ +smp_wmb (); }static void ublk_io_release (void *priv)
@@ -2527,11 +2537,11 @@ static int ublk_ch_uring_cmd_local(struct io_uring_cmd *cmd, ret =ublk_check_fetch_buf (ub, addr);if (ret) goto out; +/* before ublk_fetch() publishes io->cmd, see ublk_prep_cancel() */ +ublk_prep_cancel (cmd, issue_flags, ubq, tag); ret =ublk_fetch (cmd, ub, ubq, io, addr);if (ret) - goto out; - -ublk_prep_cancel (cmd, issue_flags, ubq, tag); + goto out_done;return -EIOCBQUEUED ; }
@@ -2575,6 +2585,7 @@ static int ublk_ch_uring_cmd_local(struct io_uring_cmd *cmd,if (ret) goto out; io->res = result; +ublk_prep_cancel (cmd, issue_flags, ubq, tag); req =ublk_fill_io_cmd (io, cmd);ublk_apply_io_buf (ub, io, cmd, addr, &auto_buf, &buf_idx);if (buf_idx !=UBLK_INVALID_BUF_IDX )
@@ -2594,19 +2605,24 @@ static int ublk_ch_uring_cmd_local(struct io_uring_cmd *cmd,* uring_cmd active first and prepare for handling new requeued * request */ +ublk_prep_cancel (cmd, issue_flags, ubq, tag); req =ublk_fill_io_cmd (io, cmd); io->buf.addr = addr;if (likely (ublk_get_data (ubq, io, req))) {__ublk_prep_compl_io_cmd (io, req); -return UBLK_IO_RES_OK ; + ret =UBLK_IO_RES_OK ; + goto out_done; }break ;default : goto out; } -ublk_prep_cancel (cmd, issue_flags, ubq, tag);return -EIOCBQUEUED ; + out_done: +/* marked cancelable: complete through io_uring_cmd_done() */ +io_uring_cmd_done (cmd, ret, issue_flags); +return -EIOCBQUEUED ; out:pr_devel ("%s: complete: cmd op %d, tag %d ret %x io_flags %x\n" , __func__, cmd_op, tag, ret, io ? io->flags :0 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 622/686 nvmem: rockchip-otp: alloc clks with main struct
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rosen Penev <[email protected]>
[ Upstream commit 9f99bb979f930e52e6861114fe03535d4bc2f374 ]
Use a flexible array member to simplify allocation slightly. No need for a separate calloc.
Stable-dep-of: 9fc6a1592d84 ("nvmem: rockchip-otp: Serialize reads")
--- drivers/nvmem/rockchip-otp.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/nvmem/rockchip-otp.c +2 -7
@@ -77,9 +77,9 @@ struct rockchip_data {struct rockchip_otp {struct device *dev;void __iomem *base; -struct clk_bulk_data *clks;struct reset_control *rst;const struct rockchip_data *data; +struct clk_bulk_data clks[]; };static int rockchip_otp_reset (struct rockchip_otp *otp)
@@ -327,7 +327,7 @@ static int rockchip_otp_probe(struct platform_device *pdev)if (!data)return dev_err_probe (dev, -EINVAL ,"failed to get match data\n" ); - otp =devm_kzalloc (&pdev->dev,sizeof (struct rockchip_otp ), + otp =devm_kzalloc (&pdev->dev,struct_size (otp, clks, data->num_clks),GFP_KERNEL );if (!otp)return -ENOMEM ;
@@ -339,11 +339,6 @@ static int rockchip_otp_probe(struct platform_device *pdev)return dev_err_probe (dev,PTR_ERR (otp->base),"failed to ioremap resource\n" ); - otp->clks =devm_kcalloc (dev, data->num_clks,sizeof (*otp->clks), -GFP_KERNEL ); -if (!otp->clks) -return -ENOMEM ; -for (i =0 ; i < data->num_clks; ++i) otp->clks[i].id = data->clks[i];
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 623/686 nvmem: rockchip-otp: Serialize reads
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexey Charkov <[email protected]>
[ Upstream commit 9fc6a1592d844c0397f115ee8cbd935169b9a71e ]
The OTP controller is driven through a single set of registers holding a state machine which has to be stepped through for every word read, yet nothing keeps two readers out of each other's way. Concurrent reads interleave, and the outcome is either a reader bailing out:
rockchip-otp 2a580000.otp: timeout during read setup
or, worse, one of them silently taking delivery of the other's data.
Reading two cells in parallel from userspace on RK3576 reproduces both within 150 iterations - 53 read errors and 9 corrupted results, the latter either losing their first word or, in one case, ending in the two bytes which belong to the other reader's cell - whereas the same reads issued sequentially never fail. Concurrency is not hypothetical here, as six thermal sensors source their trim values from the OTP and reach the driver straight from asynchronous driver probing.
Guard the read path with a mutex. Reads are the only way into the hardware, as the driver registers no write callback, and they always run in process context, so a plain mutex spanning the whole clock-enable, read, clock-disable sequence is enough.
--- drivers/nvmem/rockchip-otp.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
drivers/nvmem/rockchip-otp.c +14 -1
@@ -12,6 +12,7 @@#include <linux/io.h> #include <linux/iopoll.h> #include <linux/module.h> +#include <linux/mutex.h> #include <linux/nvmem-provider.h> #include <linux/reset.h> #include <linux/slab.h>
@@ -79,6 +80,8 @@ struct rockchip_otp {void __iomem *base;struct reset_control *rst;const struct rockchip_data *data; +/* Serializes access to the OTP controller state machine */ +struct mutex mutex;struct clk_bulk_data clks[]; };
@@ -239,16 +242,21 @@ static int rockchip_otp_read(void *context, unsigned int offset,if (!otp->data || !otp->data->reg_read)return -EINVAL ; +mutex_lock (&otp->mutex); + ret =clk_bulk_prepare_enable (otp->data->num_clks, otp->clks);if (ret <0 ) {dev_err (otp->dev,"failed to prepare/enable clks\n" ); -return ret; + goto unlock; } ret = otp->data->reg_read (context, offset, val, bytes);clk_bulk_disable_unprepare (otp->data->num_clks, otp->clks); +unlock: +mutex_unlock (&otp->mutex); +return ret; }
@@ -334,6 +342,11 @@ static int rockchip_otp_probe(struct platform_device *pdev) otp->data = data; otp->dev = dev; + + ret =devm_mutex_init (dev, &otp->mutex); +if (ret) +return ret; + otp->base =devm_platform_ioremap_resource (pdev,0 );if (IS_ERR (otp->base)) return dev_err_probe(dev, PTR_ERR(otp->base),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 624/686 tpm: tpm2_probe: propagate transport errors
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Sverdlin <[email protected]>
[ Upstream commit 7d4f1cbfe063af5581dac66abe9e9c965e1031cc ]
tpm2_probe() reads the protocol version from the response tag and is documented to return -errno on failure, but it always returns 0. A transport error (tpm_transmit_cmd() < 0) is thus swallowed together with the intentionally ignored TPM response code, leaving TPM_CHIP_FLAG_TPM2 unset. A transient bus failure on the first command then misdetects a TPM 2.0 as a 1.2 and the probe fails on the TPM 1.2 path:
tpm_tis_i2c 0-002e: 1.2 TPM (device-id 0x1C, rev-id 22)
tpm tpm0: A TPM error (-62) occurred attempting to determine the timeouts
Return the transport error instead; rc >= 0 still means a valid header was received and the TPM's own response code is still ignored.
--- drivers/char/tpm/tpm2-cmd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/char/tpm/tpm2-cmd.c +2 -1
@@ -487,9 +487,10 @@ int tpm2_probe(struct tpm_chip *chip) out = (struct tpm_header *)buf.data;if (be16_to_cpu (out->tag) ==TPM2_ST_NO_SESSIONS ) chip->flags |=TPM_CHIP_FLAG_TPM2 ; + rc =0 ; }tpm_buf_destroy (&buf); -return 0 ; +return rc; }EXPORT_SYMBOL_GPL (tpm2_probe);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 625/686 fs: assert on ->i_count in iput_final()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mateusz Guzik <[email protected]>
[ Upstream commit be97a4b63ca8c3ed8f5c3f5606a15a8379c78afb ]
Notably make sure the count is 0 after the return from ->drop_inode(), provided we are going to drop.
Inspired by suspicious games played by f2fs.
Stable-dep-of: 8ee09f597763 ("fs: rotate inodes whose page cache could not be dropped")
--- fs/inode.c | 7 +++++++ 1 file changed, 7 insertions(+)
fs/inode.c +7 -0
@@ -1875,6 +1875,7 @@ static void iput_final(struct inode *inode)int drop;WARN_ON (inode->i_state &I_NEW ); +VFS_BUG_ON_INODE (atomic_read (&inode->i_count) !=0 , inode);if (op->drop_inode) drop = op->drop_inode (inode);
@@ -1889,6 +1890,12 @@ static void iput_final(struct inode *inode)return ; } +/* +* Re-check ->i_count in case the ->drop_inode() hooks played games. +* Note we only execute this if the verdict was to drop the inode. +*/ +VFS_BUG_ON_INODE (atomic_read (&inode->i_count) !=0 , inode); + state = inode->i_state;if (!drop) {WRITE_ONCE (inode->i_state, state |I_WILL_FREE );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 626/686 fs: add missing fences to I_NEW handling
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mateusz Guzik <[email protected]>
[ Upstream commit 31e332b911fca54df467d264d7e2a2ef9317f3ca ]
Suppose there are 2 CPUs racing inode hash lookup func (say ilookup5()) and unlock_new_inode().
In principle the latter can clear the I_NEW flag before prior stores into the inode were made visible.
The former can in turn observe I_NEW is cleared and proceed to use the inode, while possibly reading from not-yet-published areas.
Stable-dep-of: 8ee09f597763 ("fs: rotate inodes whose page cache could not be dropped")
--- fs/dcache.c | 4 ++++ fs/inode.c | 8 ++++++++ include/linux/writeback.h | 4 ++++ 3 files changed, 16 insertions(+)
fs/dcache.c +4 -0
@@ -1995,6 +1995,10 @@ void d_instantiate_new(struct dentry *entry, struct inode *inode)spin_lock (&inode->i_lock);__d_instantiate (entry, inode);WARN_ON (!(inode->i_state &I_NEW )); +/* +* Pairs with smp_rmb in wait_on_inode(). +*/ +smp_wmb (); inode->i_state &= ~I_NEW & ~I_CREATING ;/* * Pairs with the barrier in prepare_to_wait_event() to make sure
fs/inode.c +8 -0
@@ -1177,6 +1177,10 @@ void unlock_new_inode(struct inode *inode)lockdep_annotate_inode_mutex_key (inode);spin_lock (&inode->i_lock);WARN_ON (!(inode->i_state &I_NEW )); +/* +* Pairs with smp_rmb in wait_on_inode(). +*/ +smp_wmb (); inode->i_state &= ~I_NEW & ~I_CREATING ;/* * Pairs with the barrier in prepare_to_wait_event() to make sure
@@ -1194,6 +1198,10 @@ void discard_new_inode(struct inode *inode)lockdep_annotate_inode_mutex_key (inode);spin_lock (&inode->i_lock);WARN_ON (!(inode->i_state &I_NEW )); +/* +* Pairs with smp_rmb in wait_on_inode(). +*/ +smp_wmb (); inode->i_state &= ~I_NEW ;/* * Pairs with the barrier in prepare_to_wait_event() to make sure
include/linux/writeback.h +4 -0
@@ -194,6 +194,10 @@ static inline void wait_on_inode(struct inode *inode) {wait_var_event (inode_state_wait_address (inode, __I_NEW), !(READ_ONCE (inode->i_state) &I_NEW )); +/* +* Pairs with routines clearing I_NEW. +*/ +smp_rmb (); }#ifdef CONFIG_CGROUP_WRITEBACK
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 627/686 fs: spell out fenced ->i_state accesses with explicit smp_wmb/smp_rmb
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mateusz Guzik <[email protected]>
[ Upstream commit cb5db358ab5769cbd3e8e864f14af321126cccdb ]
The incomming helpers don't ship with _release/_acquire variants, for the time being anyway.
Stable-dep-of: 8ee09f597763 ("fs: rotate inodes whose page cache could not be dropped")
--- fs/fs-writeback.c | 5 +++-- include/linux/backing-dev.h | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-)
fs/fs-writeback.c +3 -2
@@ -476,10 +476,11 @@ static bool inode_do_switch_wbs(struct inode *inode, switched = true; skip_switch:/* -* Paired with load_acquire in unlocked_inode_to_wb_begin() and +* Paired with an acquire fence in unlocked_inode_to_wb_begin() and * ensures that the new wb is visible if they see !I_WB_SWITCH. */ -smp_store_release (&inode->i_state, inode->i_state & ~I_WB_SWITCH ); +smp_wmb (); + inode->i_state &= ~I_WB_SWITCH ;xa_unlock_irq (&mapping->i_pages);spin_unlock (&inode->i_lock);
include/linux/backing-dev.h +3 -2
@@ -277,10 +277,11 @@ unlocked_inode_to_wb_begin(struct inode *inode, struct wb_lock_cookie *cookie)rcu_read_lock ();/* -* Paired with store_release in inode_switch_wbs_work_fn() and +* Paired with a release fence in inode_do_switch_wbs() and * ensures that we see the new wb if we see cleared I_WB_SWITCH. */ - cookie->locked =smp_load_acquire (&inode->i_state) &I_WB_SWITCH ; + cookie->locked = inode->i_state &I_WB_SWITCH ; +smp_rmb ();if (unlikely (cookie->locked))xa_lock_irqsave (&inode->i_mapping->i_pages, cookie->flags);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 628/686 fs: provide accessors for ->i_state
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mateusz Guzik <[email protected]>
[ Upstream commit d8753f788ab4916341d9fab81795be9f2f49c264 ]
Open-coded accesses prevent asserting they are done correctly. One obvious aspect is locking, but significantly more can checked. For example it can be detected when the code is clearing flags which are already missing, or is setting flags when it is illegal (e.g., I_FREEING when ->i_count > 0).
In order to keep things manageable this patchset merely gets the thing off the ground with only lockdep checks baked in.
Current consumers can be trivially converted.
Suppose flags I_A and I_B are to be handled.
If ->i_lock is held, then:
state = inode->i_state => state = inode_state_read(inode)inode->i_state |= (I_A | I_B) => inode_state_set(inode, I_A | I_B)inode->i_state &= ~(I_A | I_B) => inode_state_clear(inode, I_A | I_B)inode->i_state = I_A | I_B => inode_state_assign(inode, I_A | I_B)
If ->i_lock is not held or only held conditionally:
state = inode->i_state => state = inode_state_read_once(inode)inode->i_state |= (I_A | I_B) => inode_state_set_raw(inode, I_A | I_B)inode->i_state &= ~(I_A | I_B) => inode_state_clear_raw(inode, I_A | I_B)inode->i_state = I_A | I_B => inode_state_assign_raw(inode, I_A | I_B)
The "_once" vs "_raw" discrepancy stems from the read variant differing by READ_ONCE as opposed to just lockdep checks.
Finally, if you want to atomically clear flags and set new ones, the following:
state = inode->i_state;
state &= ~I_A;
state |= I_B;inode->i_state = state;
turns into:
inode_state_replace(inode, I_A, I_B);
Stable-dep-of: 8ee09f597763 ("fs: rotate inodes whose page cache could not be dropped")
--- include/linux/fs.h | 78 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 76 insertions(+), 2 deletions(-)
include/linux/fs.h +76 -2
@@ -759,7 +759,7 @@ enum inode_state_bits {/* reserved wait address bit 3 */ }; -enum inode_state_flags_t { +enum inode_state_flags_enum {I_NEW = (1U << __I_NEW),I_SYNC = (1U << __I_SYNC),I_LRU_ISOLATING = (1U << __I_LRU_ISOLATING),
@@ -843,7 +843,7 @@ struct inode {#endif /* Misc */ -enum inode_state_flags_t i_state; +enum inode_state_flags_enum i_state;/* 32-bit hole */ struct rw_semaphore i_rwsem;
@@ -904,6 +904,80 @@ struct inode {void *i_private;/* fs or device private pointer */ } __randomize_layout; +/* +* i_state handling +* +* We hide all of it behind helpers so that we can validate consumers. +*/ +static inline enum inode_state_flags_enum inode_state_read_once (struct inode *inode) +{ +return READ_ONCE (inode->i_state); +} + +static inline enum inode_state_flags_enum inode_state_read (struct inode *inode) +{ +lockdep_assert_held (&inode->i_lock); +return inode->i_state; +} + +static inline void inode_state_set_raw (struct inode *inode, +enum inode_state_flags_enum flags) +{ +WRITE_ONCE (inode->i_state, inode->i_state | flags); +} + +static inline void inode_state_set (struct inode *inode, +enum inode_state_flags_enum flags) +{ +lockdep_assert_held (&inode->i_lock); +inode_state_set_raw (inode, flags); +} + +static inline void inode_state_clear_raw (struct inode *inode, +enum inode_state_flags_enum flags) +{ +WRITE_ONCE (inode->i_state, inode->i_state & ~flags); +} + +static inline void inode_state_clear (struct inode *inode, +enum inode_state_flags_enum flags) +{ +lockdep_assert_held (&inode->i_lock); +inode_state_clear_raw (inode, flags); +} + +static inline void inode_state_assign_raw (struct inode *inode, +enum inode_state_flags_enum flags) +{ +WRITE_ONCE (inode->i_state, flags); +} + +static inline void inode_state_assign (struct inode *inode, +enum inode_state_flags_enum flags) +{ +lockdep_assert_held (&inode->i_lock); +inode_state_assign_raw (inode, flags); +} + +static inline void inode_state_replace_raw (struct inode *inode, +enum inode_state_flags_enum clearflags, +enum inode_state_flags_enum setflags) +{ +enum inode_state_flags_enum flags; + flags = inode->i_state; + flags &= ~clearflags; + flags |= setflags; +inode_state_assign_raw (inode, flags); +} + +static inline void inode_state_replace (struct inode *inode, +enum inode_state_flags_enum clearflags, +enum inode_state_flags_enum setflags) +{ +lockdep_assert_held (&inode->i_lock); +inode_state_replace_raw (inode, clearflags, setflags); +} +static inline void inode_set_cached_link (struct inode *inode,char *link,int linklen) {VFS_WARN_ON_INODE (strlen (link) != linklen, inode);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 629/686 fs: Ignore inode metadata buffers in inode_lru_isolate()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Kara <[email protected]>
[ Upstream commit 972b9dd4e4180fbb2352bf2f0e015b7b63f5cca0 ]
There are only a few filesystems that use generic tracking of inode metadata buffer heads. As such the logic to reclaim tracked metadata buffer heads in inode_lru_isolate() doesn't bring a benefit big enough to justify intertwining of inode reclaim and metadata buffer head tracking. Just treat tracked metadata buffer heads as any other metadata filesystem has to properly clean up on inode eviction and stop handling it in inode_lru_isolate(). As a result filesystems using generic tracking of metadata buffer heads may now see dirty metadata buffers in their .evict methods more often which can slow down inode reclaim but given these filesystems aren't used in performance demanding setups we should be fine.
Stable-dep-of: 8ee09f597763 ("fs: rotate inodes whose page cache could not be dropped")
--- fs/buffer.c | 29 ----------------------------- fs/inode.c | 21 +++++++++------------ include/linux/buffer_head.h | 3 --- 3 files changed, 9 insertions(+), 44 deletions(-)
fs/buffer.c +0 -29
@@ -880,35 +880,6 @@ void invalidate_inode_buffers(struct inode *inode) }EXPORT_SYMBOL (invalidate_inode_buffers); -/* -* Remove any clean buffers from the inode's buffer list. This is called -* when we're trying to free the inode itself. Those buffers can pin it. -* -* Returns true if all buffers were removed. -*/ -int remove_inode_buffers (struct inode *inode) -{ -int ret =1 ; - -if (inode_has_buffers (inode)) { -struct address_space *mapping = &inode->i_data; -struct list_head *list = &mapping->i_private_list; -struct address_space *buffer_mapping = mapping->i_private_data; - -spin_lock (&buffer_mapping->i_private_lock); -while (!list_empty (list)) { -struct buffer_head *bh =BH_ENTRY (list->next); -if (buffer_dirty (bh)) { - ret =0 ; -break ; - } -__remove_assoc_queue (bh); - } -spin_unlock (&buffer_mapping->i_private_lock); - } -return ret; -} -/* * Create the appropriate buffers when given a folio for data area and * the size of each buffer.. Use the bh->b_this_page linked list to
fs/inode.c +9 -12
@@ -16,7 +16,6 @@#include <linux/fsnotify.h> #include <linux/mount.h> #include <linux/posix_acl.h> -#include <linux/buffer_head.h> /* for inode_has_buffers */ #include <linux/ratelimit.h> #include <linux/list_lru.h> #include <linux/iversion.h>
@@ -366,7 +365,6 @@ struct inode *alloc_inode(struct super_block *sb)void __destroy_inode (struct inode *inode) { -BUG_ON (inode_has_buffers (inode));inode_detach_wb (inode);security_inode_free (inode);fsnotify_inode_delete (inode);
@@ -954,19 +952,18 @@ static enum lru_status inode_lru_isolate(struct list_head *item,* page cache in order to free up struct inodes: lowmem might * be under pressure before the cache inside the highmem zone. */ -if (inode_has_buffers (inode) || !mapping_empty (&inode->i_data)) { +if (!mapping_empty (&inode->i_data)) { +unsigned long reap; +inode_pin_lru_isolating (inode);spin_unlock (&inode->i_lock);spin_unlock (&lru->lock); -if (remove_inode_buffers (inode)) { -unsigned long reap; - reap =invalidate_mapping_pages (&inode->i_data,0 ,-1 ); -if (current_is_kswapd ()) -__count_vm_events (KSWAPD_INODESTEAL , reap); -else -__count_vm_events (PGINODESTEAL , reap); -mm_account_reclaimed_pages (reap); - } + reap =invalidate_mapping_pages (&inode->i_data,0 ,-1 ); +if (current_is_kswapd ()) +__count_vm_events (KSWAPD_INODESTEAL , reap); +else +__count_vm_events (PGINODESTEAL , reap); +mm_account_reclaimed_pages (reap);inode_unpin_lru_isolating (inode);return LRU_RETRY ; }
include/linux/buffer_head.h +0 -3
@@ -517,7 +517,6 @@ void buffer_init(void);bool try_to_free_buffers (struct folio *folio);int inode_has_buffers (struct inode *inode);void invalidate_inode_buffers (struct inode *inode); -int remove_inode_buffers (struct inode *inode);int sync_mapping_buffers (struct address_space *mapping);void invalidate_bh_lrus (void );void invalidate_bh_lrus_cpu (void );
@@ -528,9 +527,7 @@ extern int buffer_heads_over_limit;static inline void buffer_init (void ) {}static inline bool try_to_free_buffers (struct folio *folio) {return true; } -static inline int inode_has_buffers (struct inode *inode) {return 0 ; }static inline void invalidate_inode_buffers (struct inode *inode) {} -static inline int remove_inode_buffers (struct inode *inode) {return 1 ; }static inline int sync_mapping_buffers (struct address_space *mapping) {return 0 ; }static inline void invalidate_bh_lrus (void ) {}static inline void invalidate_bh_lrus_cpu (void ) {}
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 630/686 fs: rotate inodes whose page cache could not be dropped
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nikolaos Karaolidis <[email protected]>
[ Upstream commit 8ee09f597763acfd31c62a578ba88b792fc41b24 ]
When inode_lru_isolate() drops the page cache of an unused inode, it has to unlock the list, so it returns LRU_RETRY and the walk restarts at the head of the list, where the inode still is. If invalidate_mapping_pages() could not empty the mapping, the restarted walk strips the same inode again, and so on until nr_to_walk runs out. Every walk of that list then ends on this inode, and nothing behind it is reclaimed for as long as its cache stays.
Before commit 2a0629834cd8 ("vfs: Don't evict inode under the inode lru traversing context") the walker pinned the inode with a reference, and dropping it in iput_final() set I_REFERENCED, so the restarted walk rotated the inode to the tail. Set I_REFERENCED again when the mapping is still populated after the invalidation, in the same i_lock section that clears I_LRU_ISOLATING. inode_unpin_lru_isolating() now expects i_lock to be held, like inode_pin_lru_isolating().
On CONFIG_HIGHMEM kernels this can happen to any unused inode: a folio is left behind if it is locked, under writeback, spliced into a pipe, or still in another CPU's LRU-add batch after being read. Without HIGHMEM it happens to DAX inodes whose only entry is at index 0, which mapping_shrinkable() lets onto the LRU and invalidate_mapping_pages() never removes.
--- fs/inode.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
fs/inode.c +7 -2
@@ -581,12 +581,11 @@ static void inode_pin_lru_isolating(struct inode *inode)static void inode_unpin_lru_isolating (struct inode *inode) { -spin_lock (&inode->i_lock); +lockdep_assert_held (&inode->i_lock);WARN_ON (!(inode->i_state &I_LRU_ISOLATING )); inode->i_state &= ~I_LRU_ISOLATING ;/* Called with inode->i_lock which ensures memory ordering. */ inode_wake_up_bit (inode, __I_LRU_ISOLATING); -spin_unlock (&inode->i_lock); }static void inode_wait_for_lru_isolating (struct inode *inode)
@@ -964,7 +963,13 @@ static enum lru_status inode_lru_isolate(struct list_head *item,else __count_vm_events (PGINODESTEAL , reap);mm_account_reclaimed_pages (reap); + +spin_lock (&inode->i_lock); +/* The walk restarts here: don't retry leftovers right away */ +if (!mapping_empty (&inode->i_data)) +inode_state_set (inode,I_REFERENCED );inode_unpin_lru_isolating (inode); +spin_unlock (&inode->i_lock);return LRU_RETRY ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 631/686 mm: memcontrol: refactor mod_memcg_state() and mod_memcg_lruvec_state()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qi Zheng <[email protected]>
[ Upstream commit 5371e350fda70bbdbee364215ca37b7fea25047b ]
Refactor the memcg_reparent_objcgs() to facilitate subsequent reparenting non-hierarchical stats.
Stable-dep-of: 02e0c8cc2815 ("mm/memcg: migrate per-node hugetlb lruvec stat together with hugetlb folio")
--- mm/memcontrol.c | 50 ++++++++++++++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 19 deletions(-)
mm/memcontrol.c +31 -19
@@ -678,21 +678,12 @@ static int memcg_state_val_in_pages(int idx, int val)return max (val * unit /PAGE_SIZE ,1UL ); } -/** -* mod_memcg_state - update cgroup memory statistics -* @memcg: the memory cgroup -* @idx: the stat item - can be enum memcg_stat_item or enum node_stat_item -* @val: delta to add to the counter, can be negative -*/ -void mod_memcg_state (struct mem_cgroup *memcg,enum memcg_stat_item idx, -int val) +static void __mod_memcg_state (struct mem_cgroup *memcg, +enum memcg_stat_item idx,int val) {int i =memcg_stats_index (idx);int cpu; -if (mem_cgroup_disabled ()) -return ; -if (WARN_ONCE (BAD_STAT_IDX (i),"%s: missing stat item %d\n" , __func__, idx))return ;
@@ -706,6 +697,21 @@ void mod_memcg_state(struct mem_cgroup *memcg, enum memcg_stat_item idx,put_cpu (); } +/** +* mod_memcg_state - update cgroup memory statistics +* @memcg: the memory cgroup +* @idx: the stat item - can be enum memcg_stat_item or enum node_stat_item +* @val: delta to add to the counter, can be negative +*/ +void mod_memcg_state (struct mem_cgroup *memcg,enum memcg_stat_item idx, +int val) +{ +if (mem_cgroup_disabled ()) +return ; + +__mod_memcg_state (memcg, idx, val); +} +#ifdef CONFIG_MEMCG_V1 /* idx can be of type enum memcg_stat_item or node_stat_item. */ unsigned long memcg_page_state_local (struct mem_cgroup *memcg,int idx)
@@ -725,21 +731,16 @@ unsigned long memcg_page_state_local(struct mem_cgroup *memcg, int idx) }#endif -static void mod_memcg_lruvec_state (struct lruvec *lruvec, -enum node_stat_item idx, -int val) +static void __mod_memcg_lruvec_state (struct mem_cgroup_per_node *pn, +enum node_stat_item idx,int val) { -struct mem_cgroup_per_node *pn; -struct mem_cgroup *memcg; +struct mem_cgroup *memcg = pn->memcg;int i =memcg_stats_index (idx);int cpu;if (WARN_ONCE (BAD_STAT_IDX (i),"%s: missing stat item %d\n" , __func__, idx))return ; - pn = container_of(lruvec, struct mem_cgroup_per_node, lruvec); - memcg = pn->memcg; - cpu =get_cpu ();/* Update memcg */
@@ -755,6 +756,17 @@ static void mod_memcg_lruvec_state(struct lruvec *lruvec,put_cpu (); } +static void mod_memcg_lruvec_state (struct lruvec *lruvec, +enum node_stat_item idx, +int val) +{ +struct mem_cgroup_per_node *pn; + + pn = container_of(lruvec, struct mem_cgroup_per_node, lruvec); + +__mod_memcg_lruvec_state (pn, idx, val); +} +/** * __mod_lruvec_state - update lruvec memory statistics * @lruvec: the lruvec
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 632/686 mm: use enum migrate_reason instead of int for migration reason parameters
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ye Liu <[email protected]>
[ Upstream commit c95dc0a84b4c84103bd688a93b28d84e8b752568 ]
Replace all 'int reason' function parameters that carry migrate_reason values with the proper 'enum migrate_reason' type. This makes the intent explicit and leverages compiler type checking. The affected subsystems are:
- page_owner: __folio_set_owner_migrate_reason(), folio_set_owner_migrate_reason()
- migrate: migrate_pages(), migrate_pages_sync(), migrate_pages_batch(), migrate_folios_move(), migrate_hugetlbs(), unmap_and_move_huge_page()
- hugetlb: move_hugetlb_state(), htlb_allow_alloc_fallback()
- trace: mm_migrate_pages and mm_migrate_pages_start events
The 'short last_migrate_reason' struct field and internal helper parameter in page_owner are intentionally left as 'short' since they store per-page metadata where size matters.
No functional change.
Stable-dep-of: 02e0c8cc2815 ("mm/memcg: migrate per-node hugetlb lruvec stat together with hugetlb folio")
--- include/linux/hugetlb.h | 9 +++++---- include/linux/migrate.h | 8 +++++--- include/linux/page_owner.h | 7 ++++--- include/trace/events/migrate.h | 8 ++++---- mm/hugetlb.c | 3 ++- mm/migrate.c | 12 ++++++------ mm/page_owner.c | 2 +- 7 files changed, 27 insertions(+), 22 deletions(-)
include/linux/hugetlb.h +5 -4
@@ -156,7 +156,8 @@ long hugetlb_unreserve_pages(struct inode *inode, long start, long end,bool folio_isolate_hugetlb (struct folio *folio,struct list_head *list);int get_hwpoison_hugetlb_folio (struct folio *folio,bool *hugetlb,bool unpoison);void folio_putback_hugetlb (struct folio *folio); -void move_hugetlb_state (struct folio *old_folio,struct folio *new_folio,int reason); +void move_hugetlb_state (struct folio *old_folio,struct folio *new_folio, +enum migrate_reason reason);void hugetlb_fix_reserve_counts (struct inode *inode);extern struct mutex *hugetlb_fault_mutex_table;u32 hugetlb_fault_mutex_hash (struct address_space *mapping,pgoff_t idx);
@@ -425,7 +426,7 @@ static inline void folio_putback_hugetlb(struct folio *folio) }static inline void move_hugetlb_state (struct folio *old_folio, -struct folio *new_folio,int reason) +struct folio *new_folio,enum migrate_reason reason) { }
@@ -960,7 +961,7 @@ static inline gfp_t htlb_modify_alloc_mask(struct hstate *h, gfp_t gfp_mask)return modified_mask; } -static inline bool htlb_allow_alloc_fallback (int reason) +static inline bool htlb_allow_alloc_fallback (enum migrate_reason reason) {bool allowed_fallback = false;
@@ -1252,7 +1253,7 @@ static inline gfp_t htlb_modify_alloc_mask(struct hstate *h, gfp_t gfp_mask)return 0 ; } -static inline bool htlb_allow_alloc_fallback (int reason) +static inline bool htlb_allow_alloc_fallback (enum migrate_reason reason) {return false; }
include/linux/migrate.h +5 -3
@@ -57,8 +57,9 @@ void putback_movable_pages(struct list_head *l);int migrate_folio (struct address_space *mapping,struct folio *dst,struct folio *src,enum migrate_mode mode);int migrate_pages (struct list_head *l,new_folio_t new,free_folio_t free, -unsigned long private,enum migrate_mode mode,int reason, -unsigned int *ret_succeeded); +unsigned long private,enum migrate_mode mode, +enum migrate_reason reason, +unsigned int *ret_succeeded);struct folio *alloc_migration_target (struct folio *src,unsigned long private);bool isolate_movable_ops_page (struct page *page,isolate_mode_t mode);bool isolate_folio_to_list (struct folio *folio,struct list_head *list);
@@ -77,7 +78,8 @@ int set_movable_ops(const struct movable_operations *ops, enum pagetype type);static inline void putback_movable_pages (struct list_head *l) {}static inline int migrate_pages (struct list_head *l,new_folio_t new,free_folio_t free,unsigned long private, -enum migrate_mode mode,int reason,unsigned int *ret_succeeded) +enum migrate_mode mode,enum migrate_reason reason, +unsigned int *ret_succeeded) {return -ENOSYS ; }static inline struct folio *alloc_migration_target (struct folio *src,unsigned long private)
include/linux/page_owner.h +4 -3
@@ -3,6 +3,7 @@#define __LINUX_PAGE_OWNER_H#include <linux/jump_label.h> +#include <linux/migrate_mode.h> #ifdef CONFIG_PAGE_OWNER extern struct static_key_false page_owner_inited;
@@ -14,7 +15,7 @@ extern void __set_page_owner(struct page *page,extern void __split_page_owner (struct page *page,int old_order,int new_order);extern void __folio_copy_owner (struct folio *newfolio,struct folio *old); -extern void __folio_set_owner_migrate_reason (struct folio *folio,int reason); +void __folio_set_owner_migrate_reason (struct folio *folio,enum migrate_reason reason);extern void __dump_page_owner (const struct page *page);extern void pagetypeinfo_showmixedcount_print (struct seq_file *m,pg_data_t *pgdat,struct zone *zone);
@@ -43,7 +44,7 @@ static inline void folio_copy_owner(struct folio *newfolio, struct folio *old)if (static_branch_unlikely (&page_owner_inited))__folio_copy_owner (newfolio, old); } -static inline void folio_set_owner_migrate_reason (struct folio *folio,int reason) +static inline void folio_set_owner_migrate_reason (struct folio *folio,enum migrate_reason reason) {if (static_branch_unlikely (&page_owner_inited))__folio_set_owner_migrate_reason (folio, reason);
@@ -68,7 +69,7 @@ static inline void split_page_owner(struct page *page, int old_order,static inline void folio_copy_owner (struct folio *newfolio,struct folio *folio) { } -static inline void folio_set_owner_migrate_reason (struct folio *folio,int reason) +static inline void folio_set_owner_migrate_reason (struct folio *folio,enum migrate_reason reason) { }static inline void dump_page_owner (const struct page *page)
include/trace/events/migrate.h +4 -4
@@ -51,7 +51,7 @@ TRACE_EVENT(mm_migrate_pages, TP_PROTO(unsigned long succeeded, unsigned long failed, unsigned long thp_succeeded, unsigned long thp_failed, unsigned long thp_split, unsigned long large_folio_split, - enum migrate_mode mode, int reason), + enum migrate_mode mode, enum migrate_reason reason),TP_ARGS (succeeded, failed, thp_succeeded, thp_failed, thp_split, large_folio_split, mode, reason),
@@ -64,7 +64,7 @@ TRACE_EVENT(mm_migrate_pages, __field( unsigned long, thp_split) __field( unsigned long, large_folio_split) __field( enum migrate_mode, mode) - __field( int, reason) + __field( enum migrate_reason, reason) ), TP_fast_assign(
@@ -91,13 +91,13 @@ TRACE_EVENT(mm_migrate_pages, TRACE_EVENT(mm_migrate_pages_start, - TP_PROTO(enum migrate_mode mode, int reason), + TP_PROTO(enum migrate_mode mode, enum migrate_reason reason), TP_ARGS(mode, reason), TP_STRUCT__entry( __field(enum migrate_mode, mode) - __field(int, reason) + __field(enum migrate_reason, reason) ), TP_fast_assign(
mm/hugetlb.c +2 -1
@@ -7970,7 +7970,8 @@ void folio_putback_hugetlb(struct folio *folio)folio_put (folio); } -void move_hugetlb_state (struct folio *old_folio,struct folio *new_folio,int reason) +void move_hugetlb_state (struct folio *old_folio,struct folio *new_folio, +enum migrate_reason reason) {struct hstate *h =folio_hstate (old_folio);
mm/migrate.c +6 -6
@@ -1465,7 +1465,7 @@ static int migrate_folio_move(free_folio_t put_new_folio, unsigned long private,static int unmap_and_move_huge_page (new_folio_t get_new_folio,free_folio_t put_new_folio,unsigned long private,struct folio *src,int force,enum migrate_mode mode, -int reason,struct list_head *ret) +enum migrate_reason reason,struct list_head *ret) {struct folio *dst;int rc = -EAGAIN ;
@@ -1622,7 +1622,7 @@ struct migrate_pages_stats {*/ static int migrate_hugetlbs (struct list_head *from,new_folio_t get_new_folio,free_folio_t put_new_folio,unsigned long private, -enum migrate_mode mode,int reason, +enum migrate_mode mode,enum migrate_reason reason,struct migrate_pages_stats *stats,struct list_head *ret_folios) {
@@ -1712,7 +1712,7 @@ static int migrate_hugetlbs(struct list_head *from, new_folio_t get_new_folio, static void migrate_folios_move(struct list_head *src_folios, struct list_head *dst_folios, free_folio_t put_new_folio, unsigned long private, - enum migrate_mode mode, int reason, + enum migrate_mode mode, enum migrate_reason reason, struct list_head *ret_folios, struct migrate_pages_stats *stats, int *retry, int *thp_retry, int *nr_failed,
@@ -1795,7 +1795,7 @@ static void migrate_folios_undo(struct list_head *src_folios,*/ static int migrate_pages_batch (struct list_head *from,new_folio_t get_new_folio,free_folio_t put_new_folio, -unsigned long private,enum migrate_mode mode,int reason, +unsigned long private,enum migrate_mode mode,enum migrate_reason reason,struct list_head *ret_folios,struct list_head *split_folios,struct migrate_pages_stats *stats,int nr_pass) {
@@ -2007,7 +2007,7 @@ static int migrate_pages_batch(struct list_head *from,static int migrate_pages_sync (struct list_head *from,new_folio_t get_new_folio,free_folio_t put_new_folio,unsigned long private, -enum migrate_mode mode,int reason, +enum migrate_mode mode,enum migrate_reason reason,struct list_head *ret_folios,struct list_head *split_folios,struct migrate_pages_stats *stats) {
@@ -2084,7 +2084,7 @@ static int migrate_pages_sync(struct list_head *from, new_folio_t get_new_folio,*/ int migrate_pages (struct list_head *from,new_folio_t get_new_folio,free_folio_t put_new_folio,unsigned long private, -enum migrate_mode mode,int reason,unsigned int *ret_succeeded) +enum migrate_mode mode,enum migrate_reason reason,unsigned int *ret_succeeded) {int rc, rc_gather;int nr_pages;
mm/page_owner.c +1 -1
@@ -336,7 +336,7 @@ noinline void __set_page_owner(struct page *page, unsigned short order,inc_stack_record_count (handle, gfp_mask,1 << order); } -void __folio_set_owner_migrate_reason (struct folio *folio,int reason) +void __folio_set_owner_migrate_reason (struct folio *folio,enum migrate_reason reason) {struct page_ext *page_ext =page_ext_get (&folio->page);struct page_owner *page_owner;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 633/686 mm/memcg: migrate per-node hugetlb lruvec stat together with hugetlb folio
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hongfu Li <[email protected]>
[ Upstream commit 02e0c8cc2815f0082b5b5aabafe3b46688082adc ]
memory.numa_stat exposes per-node hugetlb counters from per-node lruvec stats. These stats are accounted against folio_nid(): incremented on the folio's node when handed to a user, decremented when the folio is returned to the pool.
During hugetlb folio migration, mem_cgroup_migrate() moves the charge to the new folio and drops the memcg data of the old one, so the free of the old folio right after the migration skips the memcg per-node lruvec decrement. The hugetlb count stays attributed to the old node for the rest of the life of the charge, while the target folio gets no increment on the new node; its later free decrements a counter that was never incremented.
Migrate the per-node lruvec accounting alongside migration. Global memcg totals remain balanced because they track resource consumption, not node placement.
--- include/linux/memcontrol.h | 8 ++++++++ mm/hugetlb.c | 25 +++++++++++++++++++++++++ mm/memcontrol.c | 5 ++--- 3 files changed, 35 insertions(+), 3 deletions(-)
include/linux/memcontrol.h +8 -0
@@ -953,6 +953,9 @@ unsigned long lruvec_page_state(struct lruvec *lruvec, enum node_stat_item idx);unsigned long lruvec_page_state_local (struct lruvec *lruvec,enum node_stat_item idx); +void mod_memcg_lruvec_state (struct lruvec *lruvec, +enum node_stat_item idx,int val); +void mem_cgroup_flush_stats (struct mem_cgroup *memcg);void mem_cgroup_flush_stats_ratelimited (struct mem_cgroup *memcg);
@@ -1422,6 +1425,11 @@ static inline unsigned long lruvec_page_state_local(struct lruvec *lruvec,return node_page_state (lruvec_pgdat (lruvec), idx); } +static inline void mod_memcg_lruvec_state (struct lruvec *lruvec, +enum node_stat_item idx,int val) +{ +} +static inline void mem_cgroup_flush_stats (struct mem_cgroup *memcg) { }
mm/hugetlb.c +25 -0
@@ -25,6 +25,7 @@#include <linux/mmdebug.h> #include <linux/sched/signal.h> #include <linux/rmap.h> +#include <linux/rcupdate.h> #include <linux/string_choices.h> #include <linux/string_helpers.h> #include <linux/swap.h>
@@ -7970,12 +7971,36 @@ void folio_putback_hugetlb(struct folio *folio)folio_put (folio); } +static void move_hugetlb_lruvec_stat (struct folio *old_folio, +struct folio *new_folio) +{ +struct mem_cgroup *memcg; +long nr_pages =folio_nr_pages (old_folio); +int old_nid =folio_nid (old_folio); +int new_nid =folio_nid (new_folio); + +if (old_nid == new_nid) +return ; + +guard (rcu)(); + + memcg =folio_memcg (new_folio); +if (!memcg) +return ; + +mod_memcg_lruvec_state (mem_cgroup_lruvec (memcg,NODE_DATA (old_nid)), +NR_HUGETLB , -nr_pages); +mod_memcg_lruvec_state (mem_cgroup_lruvec (memcg,NODE_DATA (new_nid)), +NR_HUGETLB , nr_pages); +} +void move_hugetlb_state (struct folio *old_folio,struct folio *new_folio,enum migrate_reason reason) {struct hstate *h =folio_hstate (old_folio);hugetlb_cgroup_migrate (old_folio, new_folio); +move_hugetlb_lruvec_stat (old_folio, new_folio);folio_set_owner_migrate_reason (new_folio, reason);/*
mm/memcontrol.c +2 -3
@@ -756,9 +756,8 @@ static void __mod_memcg_lruvec_state(struct mem_cgroup_per_node *pn,put_cpu (); } -static void mod_memcg_lruvec_state (struct lruvec *lruvec, -enum node_stat_item idx, -int val) +void mod_memcg_lruvec_state (struct lruvec *lruvec, +enum node_stat_item idx,int val) {struct mem_cgroup_per_node *pn;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 634/686 mm/vma: dont leak the commit charge on mmap failure
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josef Bacik <[email protected]>
[ Upstream commit aa09311c40f6d3aa6037065e17d257ffa48b9402 ]
Patch series "mm: various (urgent?) fixes", v1.
Here are various MM fixes. The majority was reported by Josef at Anthrophic, the remainder was found while reviewing/overhauling them.
Two issues/fixes reported are not included, as we are discussing (better) alternatives on the list already.
I left most of the original commit messages as schloppy as they are: I don't particularly care as long as the code is in good shape and as long as they are not actively wrong. But I (and Mike) could not be stopped from overhauling at least some of them.
While I don't think there is anything too critical in here, I think this is a good opportunity to see how fast we can get pre-screened/pre-reviewed fixes upstream that might be security-related.
The majority are hugetlb + uffd issues, that are not actually that relevant for most installations. But all things that should just get fixed. Some uffd fixes need proper follow ups to fix some more of the root causes of leftover UFFD PTE bits (or proof that there are none remaining).
This patch (of 10):
When an accountable mapping replaces existing mappings (MAP_FIXED), __mmap_setup() only charges the difference between the size of the new mapping and the VM_ACCOUNT pages it replaces. It then zeroes vms->nr_accounted so that unmapping the old VMAs does not return their charge, which now backs the new mapping.
If the operation fails after that point, the error path returns map->charged, i.e. only the difference. By then vms_clean_up_area() has zapped the page tables and closed the old VMAs, so vms_abort_munmap_vmas() cannot reattach them. It leaves a gap and finishes the unmap with vms_complete_munmap_vmas(), which uncharges vms->nr_accounted == 0 pages. The old VMAs are gone, the new one was never created, and the charge of the old ones is never returned, not even when the process exits.
No privilege is needed to hit this, only a file whose mmap hook fails, for example a socket (sock_no_mmap() returns -ENODEV):
p = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); mmap(p, len, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_FIXED, socket_fd, 0);
Every iteration adds len to Committed_AS for good. With vm.overcommit_memory=2 this lets any user make all further accountable allocations in the system fail with -ENOMEM.
Once the new mapping has taken over the charge of the mappings it replaces, it owns the charge for all of its pages. Record that in map->charged, so that the error path returns all of it.
A failure in __mmap_setup() itself is not affected: it happens before the charge is taken over and the old VMAs are reattached with their charge intact.
Original fix generated by an LLM and sent in private by Josef.
--- mm/vma.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
mm/vma.c +7 -4
@@ -2462,14 +2462,17 @@ static int __mmap_setup(struct mmap_state *map, struct list_head *uf)/* Private writable mapping: check memory availability. */ if (accountable_mapping (map->file, map->vm_flags)) { - map->charged = map->pglen; - map->charged -= vms->nr_accounted; -if (map->charged) { - error =security_vm_enough_memory_mm (map->mm, map->charged); +const unsigned long uncharged = map->pglen - vms->nr_accounted; + +/* Charge only what's not already charged by mappings we replace. */ +if (uncharged) { + error =security_vm_enough_memory_mm (map->mm, uncharged);if (error)return error; } +/* Our new mapping owns the entire charge now. */ + map->charged = map->pglen; vms->nr_accounted =0 ; map->vm_flags |=VM_ACCOUNT ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 635/686 mm/hugetlb: charge folios to the target mms memcg
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jinmeng Zhou <[email protected]>
[ Upstream commit c2deb1356d82c9d54bd2fcf1241cc97eb66fd81f ]
HugeTLB folios are currently charged to the memcg of the allocating task. This gives the wrong result when a userfaultfd handler populates a HugeTLB VMA that belongs to another process. The UFFDIO_COPY ioctl operates on the userfaultfd context's mm, but get_mem_cgroup_from_current() charges the folio to the handler's memcg instead.
This can be reproduced by placing the faulting process and its userfaultfd handler in different memory cgroups. Have the target process register a HugeTLB mapping with userfaultfd, trigger a missing fault, and let the handler resolve it with UFFDIO_COPY. The hugepage usage is then reported in the handler's memory.current instead of the target's.
The generic userfaultfd population path avoids this problem by charging folios to dst_vma->vm_mm.
Pass the target mm through hugetlb_alloc_folio() and charge the folio by using get_mem_cgroup_from_mm(). This preserves the existing charge timing and error handling while making HugeTLB userfaultfd population consistent with the generic path.
--- include/linux/memcontrol.h | 8 +++++--- mm/hugetlb.c | 2 +- mm/memcontrol.c | 6 ++++-- 3 files changed, 10 insertions(+), 6 deletions(-)
include/linux/memcontrol.h +5 -3
@@ -662,7 +662,8 @@ static inline int mem_cgroup_charge(struct folio *folio, struct mm_struct *mm,return __mem_cgroup_charge (folio, mm, gfp); } -int mem_cgroup_charge_hugetlb (struct folio * folio,gfp_t gfp); +int mem_cgroup_charge_hugetlb (struct folio *folio,struct mm_struct *mm, +gfp_t gfp);int mem_cgroup_swapin_charge_folio (struct folio *folio,struct mm_struct *mm,gfp_t gfp,swp_entry_t entry);
@@ -1175,9 +1176,10 @@ static inline int mem_cgroup_charge(struct folio *folio,return 0 ; } -static inline int mem_cgroup_charge_hugetlb (struct folio * folio,gfp_t gfp) +static inline int mem_cgroup_charge_hugetlb (struct folio *folio, +struct mm_struct *mm,gfp_t gfp) { -return 0 ; +return 0 ; } static inline int mem_cgroup_swapin_charge_folio(struct folio *folio,
mm/hugetlb.c +1 -1
@@ -3125,7 +3125,7 @@ struct folio *alloc_hugetlb_folio(struct vm_area_struct *vma, } } - ret =mem_cgroup_charge_hugetlb (folio, gfp); + ret =mem_cgroup_charge_hugetlb (folio, vma->vm_mm, gfp);/* * Unconditionally increment NR_HUGETLB here. If it turns out that * mem_cgroup_charge_hugetlb failed, then immediately free the page and
mm/memcontrol.c +4 -2
@@ -4824,6 +4824,7 @@ int __mem_cgroup_charge(struct folio *folio, struct mm_struct *mm, gfp_t gfp)/** * mem_cgroup_charge_hugetlb - charge the memcg for a hugetlb folio * @folio: folio being charged +* @mm: mm context of the allocation target * @gfp: reclaim mode * * This function is called when allocating a huge page folio, after the page has
@@ -4833,9 +4834,10 @@ int __mem_cgroup_charge(struct folio *folio, struct mm_struct *mm, gfp_t gfp)* Returns ENOMEM if the memcg is already full. * Returns 0 if either the charge was successful, or if we skip the charging. */ -int mem_cgroup_charge_hugetlb (struct folio *folio,gfp_t gfp) +int mem_cgroup_charge_hugetlb (struct folio *folio,struct mm_struct *mm, +gfp_t gfp) { -struct mem_cgroup *memcg =get_mem_cgroup_from_current (); +struct mem_cgroup *memcg =get_mem_cgroup_from_mm (mm);int ret =0 ;/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 636/686 mm/memfd: fix hugetlb reservation accounting in error paths
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hongfu Li <[email protected]>
[ Upstream commit 50ee565c1e900e247e439e4139839b060c968343 ]
If hugetlb_add_to_page_cache() in memfd_alloc_folio() fails with -EEXIST, a concurrent fault has already instantiated the folio in the page cache, and the reservation now belongs to that folio. Calling hugetlb_unreserve_pages() in that case incorrectly removes the region backing the cached folio and releases one reservation more than it should, leaving that folio in the page cache with no region recording it.
That leaves resv_huge_pages one page short until that folio is removed from the page cache, so available_huge_pages() reports a page that is not actually free and the pool can grant one reservation more than it can back. Applications using hugetlb memfds can then fail to allocate or fault in a page they already reserved. They see -ENOMEM or -ENOSPC from the allocation or fault path even though the reservation and HugePages_Free still look healthy.
So hold the hugetlb fault mutex from hugetlb_reserve_pages() until the error-path unreserve completes to make the reserve, allocate and instantiate steps atomic against concurrent faults. With the mutex held from the start, a concurrent fault can no longer consume the reservation between reserve and allocate/instantiate. If a fault completed before the mutex was taken, it has already added the region for that index, so hugetlb_reserve_pages() returns 0 and the error path leaves the region in place.
--- mm/memfd.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-)
mm/memfd.c +16 -15
@@ -82,22 +82,31 @@ struct folio *memfd_alloc_folio(struct file *memfd, pgoff_t idx)struct hstate *h =hstate_file (memfd);int err = -ENOMEM ;long nr_resv; +u32 hash; gfp_mask =htlb_alloc_mask (h); gfp_mask &= ~(__GFP_HIGHMEM | __GFP_MOVABLE); idx >>=huge_page_order (h); +/* +* Serialize hugepage allocation and instantiation to prevent +* races with concurrent allocations, as required by all other +* callers of hugetlb_add_to_page_cache(). +*/ + hash =hugetlb_fault_mutex_hash (memfd->f_mapping, idx); +mutex_lock (&hugetlb_fault_mutex_table[hash]); + nr_resv =hugetlb_reserve_pages (inode, idx, idx +1 ,NULL ,0 ); -if (nr_resv <0 ) -return ERR_PTR (nr_resv); +if (nr_resv <0 ) { + err = nr_resv; + goto out_unlock; + } folio =alloc_hugetlb_folio_reserve (h,numa_node_id (),NULL , gfp_mask);if (folio) { -u32 hash; -/* * Zero the folio to prevent information leaks to userspace. * Use folio_zero_user() which is optimized for huge/gigantic
@@ -112,20 +121,9 @@ struct folio *memfd_alloc_folio(struct file *memfd, pgoff_t idx)*/ __folio_mark_uptodate (folio); -/* -* Serialize hugepage allocation and instantiation to prevent -* races with concurrent allocations, as required by all other -* callers of hugetlb_add_to_page_cache(). -*/ - hash =hugetlb_fault_mutex_hash (memfd->f_mapping, idx); -mutex_lock (&hugetlb_fault_mutex_table[hash]); - err =hugetlb_add_to_page_cache (folio, memfd->f_mapping, idx); - -mutex_unlock (&hugetlb_fault_mutex_table[hash]); -if (err) {folio_put (folio); goto err_unresv;
@@ -133,11 +131,14 @@ struct folio *memfd_alloc_folio(struct file *memfd, pgoff_t idx)hugetlb_set_folio_subpool (folio,subpool_inode (inode));folio_unlock (folio); +mutex_unlock (&hugetlb_fault_mutex_table[hash]); return folio; } err_unresv:if (nr_resv >0 )hugetlb_unreserve_pages (inode, idx, idx +1 ,0 ); +out_unlock: +mutex_unlock (&hugetlb_fault_mutex_table[hash]);return ERR_PTR (err); }#endif
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 637/686 ASoC: hdac_hda: Allocate the private data at codec driver bind
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Ujfalusi <[email protected]>
[ Upstream commit 7d357eae973a1e1933f81f55aa1b3b4e3064570f ]
The SOF HDA code allocates struct hdac_hda_priv and stores it as drvdata of the codec device before the codec driver is bound. The driver core clears drvdata on unbind, so after unbinding the codec driver via sysfs a subsequent bind dereferences a NULL pointer in hdac_hda_dev_probe().
All information in the private data can be derived from the codec device itself, so allocate and set it up in hdac_hda_dev_probe() as a device managed resource, which is released on unbind.
Remove the allocation from SOF, keeping the check for iDisp codecs without display audio component.
Stable-dep-of: 08a44bde821d ("ASoC: hdac_hda: Restore the codec device type on unbind")
--- sound/soc/codecs/hdac_hda.c | 13 ++++++++++++- sound/soc/sof/intel/hda-codec.c | 23 ++++------------------- 2 files changed, 16 insertions(+), 20 deletions(-)
sound/soc/codecs/hdac_hda.c +12 -1
@@ -638,10 +638,21 @@ static const struct snd_soc_component_driver hdac_hda_hdmi_codec = {static int hdac_hda_dev_probe (struct hdac_device *hdev) { -struct hdac_hda_priv *hda_pvt =dev_get_drvdata (&hdev->dev); +struct hdac_hda_priv *hda_pvt;struct hdac_ext_link *hlink;int ret; + hda_pvt =devm_kzalloc (&hdev->dev,sizeof (*hda_pvt),GFP_KERNEL ); +if (!hda_pvt) +return -ENOMEM ; + + hda_pvt->codec =dev_to_hda_codec (&hdev->dev); + hda_pvt->dev_index = hdev->addr; +/* Intel iDisp (HDMI/DP) codec */ +if (((hdev->vendor_id >>16 ) &0xFFFF ) ==0x8086 ) + hda_pvt->need_display_power = true; +dev_set_drvdata (&hdev->dev, hda_pvt); +/* hold the ref while we probe */ hlink =snd_hdac_ext_bus_get_hlink_by_name (hdev->bus,dev_name (&hdev->dev));if (!hlink) {
sound/soc/sof/intel/hda-codec.c +4 -19
@@ -15,8 +15,6 @@#include "hda.h" #if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC ) -#include "../../codecs/hdac_hda.h" -#define CODEC_PROBE_RETRIES 3#define IDISP_VID_INTEL 0x80860000
@@ -148,7 +146,6 @@ static struct hda_codec *hda_codec_device_init(struct hdac_bus *bus, int addr, i/* probe individual codec */ static int hda_codec_probe (struct snd_sof_dev *sdev,int address) { -struct hdac_hda_priv *hda_priv;struct hda_bus *hbus =sof_to_hbus (sdev);struct hda_codec *codec; u32 hda_cmd = (address << 28) | (AC_NODE_ROOT << 20) |
@@ -168,27 +165,15 @@ static int hda_codec_probe(struct snd_sof_dev *sdev, int address)dev_dbg (sdev->dev,"HDA codec #%d probed OK: response: %x\n" , address, resp); - hda_priv =devm_kzalloc (sdev->dev,sizeof (*hda_priv),GFP_KERNEL ); -if (!hda_priv) -return -ENOMEM ; - codec =hda_codec_device_init (&hbus->core, address,HDA_DEV_LEGACY ); ret =PTR_ERR_OR_ZERO (codec);if (ret <0 )return ret; - hda_priv->codec = codec; - hda_priv->dev_index = address; -dev_set_drvdata (&codec->core.dev, hda_priv); - -if ((resp &0xFFFF0000 ) ==IDISP_VID_INTEL ) { -if (!hbus->core.audio_component) { -dev_dbg (sdev->dev, -"iDisp hw present but no driver\n" ); - ret = -ENOENT ; - goto out; - } - hda_priv->need_display_power = true; +if ((resp &0xFFFF0000 ) ==IDISP_VID_INTEL && !hbus->core.audio_component) { +dev_dbg (sdev->dev,"iDisp hw present but no driver\n" ); + ret = -ENOENT ; + goto out; }if (is_generic_config (hbus))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 638/686 ASoC: hdac_hda: Restore the codec device type on unbind
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Ujfalusi <[email protected]>
[ Upstream commit 08a44bde821d4fe22c0b6e63da04b3c59ac243a8 ]
hdac_hda_codec_probe() changes the type of the codec device to HDA_DEV_ASOC to prevent snd_hda_codec_unregister() from unregistering the device when the card is freed.
The type is never restored, and hda_bus_match() requires the device and driver types to be equal. After unbinding the codec driver via sysfs the HDA_DEV_LEGACY codec drivers no longer match the device and bind fails with -ENODEV.
Restore HDA_DEV_LEGACY with a device managed action registered before the component, so it runs after the component and the card are gone.
--- sound/soc/codecs/hdac_hda.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
sound/soc/codecs/hdac_hda.c +12 -0
@@ -636,6 +636,13 @@ static const struct snd_soc_component_driver hdac_hda_hdmi_codec = { .endianness = 1, }; +static void hdac_hda_restore_dev_type (void *data) +{ +struct hdac_device *hdev = data; + + hdev->type =HDA_DEV_LEGACY ; +} +static int hdac_hda_dev_probe (struct hdac_device *hdev) {struct hdac_hda_priv *hda_pvt;
@@ -653,6 +660,11 @@ static int hdac_hda_dev_probe(struct hdac_device *hdev) hda_pvt->need_display_power = true;dev_set_drvdata (&hdev->dev, hda_pvt); +/* Allow the legacy codec driver to match again after unbind */ + ret =devm_add_action (&hdev->dev, hdac_hda_restore_dev_type, hdev); +if (ret) +return ret; +/* hold the ref while we probe */ hlink =snd_hdac_ext_bus_get_hlink_by_name (hdev->bus,dev_name (&hdev->dev));if (!hlink) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 639/686 fs: dont lose inodes that another LRU walker is isolating
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nikolaos Karaolidis <[email protected]>
[ Upstream commit 8dc4116041e2b377e5e1b62ba98b37636f9f3968 ]
When inode_lru_isolate() finds an unused inode that still has page cache, it sets I_LRU_ISOLATING, drops i_lock and the list_lru lock, invalidates the page cache, clears the flag again and returns LRU_RETRY so that the restarted walk can free the inode.
Another walker of the same list can reach the inode in that window. It sees a non-zero i_state and takes the inode off the LRU, as it would an inode that is in use. Page cache deletion requeues the inode once the mapping is shrinkable, so this is harmless if it happens before the last deletion. If it happens after, nothing puts the inode
back: it stays in memory, unused, clean and without page cache, out of reach of the shrinker and of drop_caches, until it is looked up again or the filesystem is unmounted.
Before commit 2a0629834cd8 ("vfs: Don't evict inode under the inode lru traversing context") the pin was an i_count reference, and the final iput() put the inode back on the LRU.
Skip inodes that are being isolated and leave them to the walker that pinned them, which restarts its walk once it has unpinned them.
The window is reached by any unused inode with page cache on CONFIG_HIGHMEM kernels, and otherwise by inodes whose page cache is a single shadow entry at index 0. On an i386 HIGHMEM guest, eight concurrent "echo 2 > /proc/sys/vm/drop_caches" over 2000 freshly read one-page ext4 files leave roughly 400 of the inodes off the LRU per round; on x86_64, with the files' pages first evicted through memory.reclaim, 3 to 4 per round. With this patch, none in either case.
--- fs/inode.c | 6 ++++++ 1 file changed, 6 insertions(+)
fs/inode.c +6 -0
@@ -924,6 +924,12 @@ static enum lru_status inode_lru_isolate(struct list_head *item,if (!spin_trylock (&inode->i_lock))return LRU_SKIP ; +/* Another walker is dropping its page cache, leave it to that one */ +if (inode->i_state &I_LRU_ISOLATING ) { +spin_unlock (&inode->i_lock); +return LRU_SKIP ; + } +/* * Inodes can get referenced, redirtied, or repopulated while * they're already on the LRU, and this can make them
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 640/686 LoongArch: Fix one-shot limitation for perf hardware breakpoints
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tiezhu Yang <[email protected]>
[ Upstream commit 5e0b00fd000a53a5428fed6c96be74019bd0ad17 ]
In breakpoint_handler() and watchpoint_handler(), the code disables the hardware slot by executing update_bp_registers(regs, 0, ...). This design forces the active hardware breakpoint configuration to be wiped out upon its first hit, turning standard perf hardware breakpoints into "one-shot" events.
Furthermore, while the ptrace single-step path in do_watch() executes a hardware single-step skip mechanism to advance the PC, the standard perf path lacks any mechanism to bypass the original triggering instruction.
To maintain the long-term persistence of hardware breakpoints for perf usage, eliminate the disruptive calls to update_bp_registers() within the handler loops to keep the breakpoint configuration enabled.
Concurrently, execute a single, unified register write outside the loop to atomize the state transition and explicitly enforce the hardware skip mechanism once per exception return, ensuring the processor safely steps forward without lockups.
Meanwhile, in order to prevent status contamination during single-core context switches or cross-core thread migrations, the hardware register skip state of the previous thread is saved first. Then, the skip state is restored and its software skip flag is also cleared only if the next thread has the skip flag; otherwise, 0 is written to clear the FWPS and MWPS registers, which explicitly clears the skip bit according to the architectural specification.
Additionally, explicitly clear hbp_break_skip and hbp_watch_skip inside ptrace_hw_copy_thread() which is called by copy_thread() during the task creation. This guarantees that a newly cloned child task starts with a clean slate.
Here is a user-space reproducer to demonstrate the issue.
(1) Test program (test_perf_continuous.c):
#include <stdio.h>
#include <unistd.h>
#include <sys/syscall.h>
#include <sys/ioctl.h>
#include <linux/perf_event.h>
#include <linux/hw_breakpoint.h>
static int var = 0;
int main(void)
{
size_t count = 0;
struct perf_event_attr attr = {
.type = PERF_TYPE_BREAKPOINT,
.size = sizeof(attr),
.bp_type = HW_BREAKPOINT_W,
.bp_addr = (unsigned long)&var,
.bp_len = HW_BREAKPOINT_LEN_1,
.exclude_kernel = 1,
};
int fd = syscall(__NR_perf_event_open, &attr, 0, -1, -1, 0);
ioctl(fd, PERF_EVENT_IOC_ENABLE, 0);
asm volatile("st.b %1, %0" : "=m"(var) : "r"(11) : "memory");
asm volatile("st.b %1, %0" : "=m"(var) : "r"(22) : "memory");
asm volatile("st.b %1, %0" : "=m"(var) : "r"(33) : "memory");
ioctl(fd, PERF_EVENT_IOC_DISABLE, 0);
read(fd, &count, sizeof(size_t));
printf("Watchpoint counts: expected = 3, actual = %zu\n", count);
close(fd);
return 0;
}(2) Test steps:
$ gcc test_perf_continuous.c -o test_perf_continuous $ ./test_perf_continuous
(3) Test results:
Without this patch:
Watchpoint counts: expected = 3, actual = 1
With this patch:
Watchpoint counts: expected = 3, actual = 3
--- arch/loongarch/include/asm/hw_breakpoint.h | 4 +-- arch/loongarch/include/asm/loongarch.h | 3 ++ arch/loongarch/include/asm/processor.h | 1 + arch/loongarch/include/asm/switch_to.h | 2 +- arch/loongarch/kernel/hw_breakpoint.c | 39 +++++++++++++++++++--- 5 files changed, 41 insertions(+), 8 deletions(-)
arch/loongarch/include/asm/hw_breakpoint.h +2 -2
@@ -121,12 +121,12 @@ bool watchpoint_handler(struct pt_regs *regs);#ifdef CONFIG_HAVE_HW_BREAKPOINT extern void ptrace_hw_copy_thread (struct task_struct *task); -extern void hw_breakpoint_thread_switch (struct task_struct *next); +extern void hw_breakpoint_thread_switch (struct task_struct *prev,struct task_struct *next);#else static inline void ptrace_hw_copy_thread (struct task_struct *task) { } -static inline void hw_breakpoint_thread_switch (struct task_struct *next) +static inline void hw_breakpoint_thread_switch (struct task_struct *prev,struct task_struct *next) { }#endif
arch/loongarch/include/asm/loongarch.h +3 -0
@@ -1093,6 +1093,9 @@#define CSR_FWPS_SKIP_SHIFT 16#define CSR_FWPS_SKIP (_ULCAST_(1) << CSR_FWPS_SKIP_SHIFT) +#define CSR_MWPS_SKIP_SHIFT 16 +#define CSR_MWPS_SKIP (_ULCAST_(1) << CSR_MWPS_SKIP_SHIFT) +/* * CSR_ECFG IM */
arch/loongarch/include/asm/processor.h +1 -0
@@ -138,6 +138,7 @@ struct thread_struct {struct loongarch_lbt lbt;/* Also conditionally copied */ /* Hardware breakpoints pinned to this task. */ +bool hbp_break_skip, hbp_watch_skip;struct perf_event *hbp_break[LOONGARCH_MAX_BRP ];struct perf_event *hbp_watch[LOONGARCH_MAX_WRP ]; };
arch/loongarch/include/asm/switch_to.h +1 -1
@@ -36,7 +36,7 @@ extern asmlinkage struct task_struct *__switch_to(struct task_struct *prev,do { \lose_fpu_inatomic (1 , prev); \lose_lbt_inatomic (1 , prev); \ -hw_breakpoint_thread_switch (next); \ +hw_breakpoint_thread_switch (prev, next); \ (last) =__switch_to (prev, next,task_thread_info (next), \__builtin_return_address (0 ),__builtin_frame_address (0 )); \ }while (0 )
arch/loongarch/kernel/hw_breakpoint.c +34 -5
@@ -156,6 +156,9 @@ static int hw_breakpoint_slot_setup(struct perf_event **slots, int max_slots,void ptrace_hw_copy_thread (struct task_struct *tsk) { + tsk->thread.hbp_break_skip =0 ; + tsk->thread.hbp_watch_skip =0 ; +memset (tsk->thread.hbp_break,0 ,sizeof (tsk->thread.hbp_break));memset (tsk->thread.hbp_watch,0 ,sizeof (tsk->thread.hbp_watch)); }
@@ -485,6 +488,7 @@ NOKPROBE_SYMBOL(update_bp_registers);bool breakpoint_handler (struct pt_regs *regs) {int i; +unsigned int clear_mask =0 ;bool need_sigtrap = false;struct perf_event *bp, **slots;
@@ -500,11 +504,13 @@ bool breakpoint_handler(struct pt_regs *regs)if (bp->attr.sigtrap) need_sigtrap = true; -csr_write32 (0x1 << i,LOONGARCH_CSR_FWPS ); -update_bp_registers (regs,0 ,0 ); + clear_mask |= (0x1 << i); } } +if (clear_mask) +csr_write32 (clear_mask |CSR_FWPS_SKIP ,LOONGARCH_CSR_FWPS ); +return need_sigtrap; }NOKPROBE_SYMBOL (breakpoint_handler);
@@ -512,6 +518,7 @@ NOKPROBE_SYMBOL(breakpoint_handler);bool watchpoint_handler (struct pt_regs *regs) {int i; +unsigned int clear_mask =0 ;bool need_sigtrap = false;struct perf_event *wp, **slots;
@@ -527,11 +534,13 @@ bool watchpoint_handler(struct pt_regs *regs)if (wp->attr.sigtrap) need_sigtrap = true; -csr_write32 (0x1 << i,LOONGARCH_CSR_MWPS ); -update_bp_registers (regs,0 ,1 ); + clear_mask |= (0x1 << i); } } +if (clear_mask) +csr_write32 (clear_mask |CSR_MWPS_SKIP ,LOONGARCH_CSR_MWPS ); +return need_sigtrap; }NOKPROBE_SYMBOL (watchpoint_handler);
@@ -555,7 +564,7 @@ static int __init arch_hw_breakpoint_init(void) }arch_initcall (arch_hw_breakpoint_init); -void hw_breakpoint_thread_switch (struct task_struct *next) +void hw_breakpoint_thread_switch (struct task_struct *prev,struct task_struct *next) {u64 addr, mask;struct pt_regs *regs =task_pt_regs (next);
@@ -567,6 +576,26 @@ void hw_breakpoint_thread_switch(struct task_struct *next)csr_write32 (CSR_FWPS_SKIP ,LOONGARCH_CSR_FWPS ); regs->csr_prmd |=CSR_PRMD_PWE ; }else { +unsigned int fwps =csr_read32 (LOONGARCH_CSR_FWPS ); +unsigned int mwps =csr_read32 (LOONGARCH_CSR_MWPS ); + + prev->thread.hbp_break_skip = !!(fwps &CSR_FWPS_SKIP ); + prev->thread.hbp_watch_skip = !!(mwps &CSR_MWPS_SKIP ); + +if (!next->thread.hbp_break_skip) +csr_write32 (0 ,LOONGARCH_CSR_FWPS ); +else { +csr_write32 (CSR_FWPS_SKIP ,LOONGARCH_CSR_FWPS ); + next->thread.hbp_break_skip =0 ; + } + +if (!next->thread.hbp_watch_skip) +csr_write32 (0 ,LOONGARCH_CSR_MWPS ); +else { +csr_write32 (CSR_MWPS_SKIP ,LOONGARCH_CSR_MWPS ); + next->thread.hbp_watch_skip =0 ; + } +/* Update breakpoints */ update_bp_registers (regs,1 ,0 );/* Update watchpoints */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 641/686 ocfs2: fix oob in __ocfs2_find_path
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Edward Adam Davis <[email protected]>
[ Upstream commit e0b0f2834c9bec51b1068de5cf5e10c7519143eb ]
syzbot constructed a corrupted image, which resulted in el->l_count from the b-tree extent block being 0. Since the length of the l_recs array depends on l_count, reading its member e_blkno triggered the out-of-bounds access reported by syzbot in [1].
The loop terminates when l_count is 0, similar to when next_free is 0.
[1]
UBSAN: array-index-out-of-bounds in fs/ocfs2/alloc.c:1838:11 index 0 is out of range for type 'struct ocfs2_extent_rec[] __counted_by(l_count)' (aka 'struct ocfs2_extent_rec[]') Call Trace: __ocfs2_find_path+0x606/0xa40 fs/ocfs2/alloc.c:1838 ocfs2_find_leaf+0xab/0x1c0 fs/ocfs2/alloc.c:1946 ocfs2_get_clusters_nocache+0x172/0xc60 fs/ocfs2/extent_map.c:418 ocfs2_get_clusters+0x505/0xa70 fs/ocfs2/extent_map.c:631 ocfs2_extent_map_get_blocks+0x202/0x6a0 fs/ocfs2/extent_map.c:678 ocfs2_read_virt_blocks+0x286/0x930 fs/ocfs2/extent_map.c:1001 ocfs2_read_dir_block fs/ocfs2/dir.c:521 [inline] ocfs2_find_entry_el fs/ocfs2/dir.c:728 [inline] ocfs2_find_entry+0x3e4/0x2090 fs/ocfs2/dir.c:1120 ocfs2_find_files_on_disk+0xdf/0x310 fs/ocfs2/dir.c:2023 ocfs2_lookup_ino_from_name+0x52/0x100 fs/ocfs2/dir.c:2045 _ocfs2_get_system_file_inode fs/ocfs2/sysfile.c:136 [inline] ocfs2_get_system_file_inode+0x326/0x770 fs/ocfs2/sysfile.c:112 ocfs2_init_global_system_inodes+0x319/0x660 fs/ocfs2/super.c:461 ocfs2_initialize_super fs/ocfs2/super.c:2196 [inline] ocfs2_fill_super+0x4432/0x65b0 fs/ocfs2/super.c:993 get_tree_bdev_flags+0x40e/0x4d0 fs/super.c:1691 vfs_get_tree+0x92/0x2a0 fs/super.c:1751 fc_mount fs/namespace.c:1199 [inline]
Stable-dep-of: 6193ce7896af ("ocfs2: fix array out of bound access in __ocfs2_find_path()")
--- fs/ocfs2/alloc.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
fs/ocfs2/alloc.c +5 -4
@@ -1811,14 +1811,15 @@ static int __ocfs2_find_path(struct ocfs2_caching_info *ci, ret = -EROFS ; goto out; } -if (le16_to_cpu (el->l_next_free_rec) ==0 ) { +if (!el->l_next_free_rec || !el->l_count) {ocfs2_error (ocfs2_metadata_cache_get_super (ci), -"Owner %llu has empty extent list at depth %u\n" , +"Owner %llu has empty extent list at depth %u\n" +"(next free=%u count=%u)\n" , (unsigned long long )ocfs2_metadata_cache_owner (ci), -le16_to_cpu (el->l_tree_depth)); +le16_to_cpu (el->l_tree_depth), +le16_to_cpu (el->l_next_free_rec),le16_to_cpu (el->l_count)); ret = -EROFS ; goto out; - }for (i =0 ; i <le16_to_cpu (el->l_next_free_rec) -1 ; i++) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 642/686 ocfs2: fix array out of bound access in __ocfs2_find_path()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Giorgi Kobakhia <[email protected]>
[ Upstream commit 6193ce7896afb52a321a0063c8b6a45e477a84e2 ]
__ocfs2_find_path() walks down the extent tree and records path by calling find_path_ins(), which appends entry to path->p_node[]. It only has 5 spots.
A corrupted ocfs2 image whose extent block is pointing to itself causes __ocfs2_find_path() descent endlessly, writing past the end of path->p_node[] array.
UBSAN: array-index-out-of-bounds in fs/ocfs2/alloc.c:677:14 index 5 is out of range for type 'ocfs2_path_item [5]' Call Trace: <TASK> find_path_ins (fs/ocfs2/alloc.c:677 fs/ocfs2/alloc.c:1914) __ocfs2_find_path.constprop.0 (fs/ocfs2/alloc.c:1882) ocfs2_commit_truncate (fs/ocfs2/alloc.c:1924 fs/ocfs2/alloc.c:7286) ocfs2_truncate_file (fs/ocfs2/file.c:515) ocfs2_setattr (fs/ocfs2/file.c:1224) notify_change (fs/attr.c:556) do_truncate (fs/open.c:68) do_ftruncate (fs/open.c:194 (discriminator 1)) ksys_ftruncate (fs/open.c:206) __x64_sys_ftruncate (fs/open.c:211 fs/open.c:209 fs/open.c:209)
Commit a406aff8c051 ("ocfs2: validate l_tree_depth to avoid out-of-bounds access") already restricts el->l_tree_depth to be less than OCFS2_MAX_PATH_DEPTH, which is equal to 5. However, does not handle the infinite descent case.
Check if the el->l_tree_depth decreases on each descent. Maximum descents are restricted to 4 and the path->p_node[] array does not overflow.
--- fs/ocfs2/alloc.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
fs/ocfs2/alloc.c +6 -3
@@ -1796,6 +1796,7 @@ static int __ocfs2_find_path(struct ocfs2_caching_info *ci,int i, ret =0 ;u32 range;u64 blkno; +u32 prev_depth =OCFS2_MAX_PATH_DEPTH ;struct buffer_head *bh =NULL ;struct ocfs2_extent_block *eb;struct ocfs2_extent_list *el;
@@ -1803,14 +1804,16 @@ static int __ocfs2_find_path(struct ocfs2_caching_info *ci, el = root_el;while (el->l_tree_depth) { -if (unlikely (le16_to_cpu (el->l_tree_depth) >=OCFS2_MAX_PATH_DEPTH )) { +if (unlikely (le16_to_cpu (el->l_tree_depth) >= prev_depth)) {ocfs2_error (ocfs2_metadata_cache_get_super (ci), -"Owner %llu has invalid tree depth %u in extent list\n" , +"Owner %llu has invalid tree depth %u in extent list (max %u)\n" , (unsigned long long )ocfs2_metadata_cache_owner (ci), -le16_to_cpu (el->l_tree_depth)); +le16_to_cpu (el->l_tree_depth), prev_depth -1 ); ret = -EROFS ; goto out; } + prev_depth =le16_to_cpu (el->l_tree_depth); +if (!el->l_next_free_rec || !el->l_count) {ocfs2_error (ocfs2_metadata_cache_get_super (ci), "Owner %llu has empty extent list at depth %u\n"
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 643/686 arm64/gcs: release GCS on failed fork
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Iván Ezequiel Rodriguez <[email protected]>
[ Upstream commit 078e122f3bf000dd45965997b66deac10ee580fa ]
copy_thread() can map a CLONE_VM GCS and still return 0. A later copy_process() failure calls exit_thread(), but arm64 did not implement it, so the VMA stayed in the parent's mm. Wire HAVE_EXIT_THREAD to gcs_free().
Kernel threads created with CLONE_VM (io_uring and vhost workers) inherit the parent's gcs_base/gcs_size from arch_dup_task_struct() without allocating their own GCS. When such a thread exits, exit_mm() -> mm_release() -> deactivate_mm() -> gcs_free() unmaps the parent's GCS. With the new exit_thread(), a failed copy_process() for one of these threads would do the same. Clear these fields in copy_thread().
--- arch/arm64/Kconfig | 1 + arch/arm64/kernel/process.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+)
arch/arm64/Kconfig +1 -0
@@ -222,6 +222,7 @@ config ARM64 select HAVE_SAMPLE_FTRACE_DIRECT_MULTI select HAVE_BUILDTIME_MCOUNT_SORT select HAVE_EFFICIENT_UNALIGNED_ACCESS + select HAVE_EXIT_THREAD select HAVE_GUP_FAST select HAVE_FTRACE_GRAPH_FUNC select HAVE_FUNCTION_TRACER
arch/arm64/kernel/process.c +17 -0
@@ -319,9 +319,18 @@ static int copy_thread_gcs(struct task_struct *p, return 0; } +static void gcs_reset_thread (struct task_struct *task) +{ + task->thread.gcs_base =0 ; + task->thread.gcs_size =0 ; + task->thread.gcspr_el0 =0 ; +} +#else static void flush_gcs (void ) { } +static void gcs_reset_thread (struct task_struct *task) { } +static int copy_thread_gcs (struct task_struct *p,const struct kernel_clone_args *args) {
@@ -340,6 +349,12 @@ void flush_thread(void)flush_gcs (); } +void exit_thread (struct task_struct *tsk) +{ +/* Failed fork after copy_thread(); deactivate_mm() does not run. */ +gcs_free (tsk); +} +#ifdef CONFIG_ARM64_ERRATUM_4193714 static void arch_dup_tlbbatch_mask (struct task_struct *dst)
@@ -537,6 +552,8 @@ int copy_thread(struct task_struct *p, const struct kernel_clone_args *args) p->thread.cpu_context.x19 = (unsigned long )args->fn; p->thread.cpu_context.x20 = (unsigned long )args->fn_arg; +/* Kernel threads sharing the parent's mm must not free its GCS. */ +gcs_reset_thread (p);if (system_supports_poe ()) p->thread.por_el0 =POR_EL0_INIT ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 644/686 PCI: cadence: Store the core controller in platform drvdata
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linmao Li <[email protected]>
[ Upstream commit cfe96ce583c51bf6e034d4038c652a1e8227867c ]
cdns_plat_pcie_probe() stores a struct cdns_plat_pcie pointer with platform_set_drvdata(). cdns_plat_pcie_shutdown() and the callbacks in cdns_pcie_pm_ops retrieve the same pointer with dev_get_drvdata() but use it as a struct cdns_pcie pointer. This makes them read phy_count and phy beyond the wrapper.
struct cdns_plat_pcie only contains a pointer to struct cdns_pcie. Drop the redundant wrapper and store the struct cdns_pcie pointer directly.
--- .../controller/cadence/pcie-cadence-plat.c | 33 +++++++------------ 1 file changed, 11 insertions(+), 22 deletions(-)
drivers/pci/controller/cadence/pcie-cadence-plat.c +11 -22
@@ -14,14 +14,6 @@#define CDNS_PLAT_CPU_TO_BUS_ADDR 0x0FFFFFFF -/** -* struct cdns_plat_pcie - private data for this PCIe platform driver -* @pcie: Cadence PCIe controller -*/ -struct cdns_plat_pcie { -struct cdns_pcie *pcie; -}; -struct cdns_plat_pcie_of_data {bool is_rc; };
@@ -40,9 +32,9 @@ static const struct cdns_pcie_ops cdns_plat_ops = {static int cdns_plat_pcie_probe (struct platform_device *pdev) {const struct cdns_plat_pcie_of_data *data; -struct cdns_plat_pcie *cdns_plat_pcie;struct device *dev = &pdev->dev;struct pci_host_bridge *bridge; +struct cdns_pcie *pcie;struct cdns_pcie_ep *ep;struct cdns_pcie_rc *rc;int phy_count;
@@ -56,11 +48,6 @@ static int cdns_plat_pcie_probe(struct platform_device *pdev) is_rc = data->is_rc;pr_debug (" Started %s with is_rc: %d\n" , __func__, is_rc); - cdns_plat_pcie =devm_kzalloc (dev,sizeof (*cdns_plat_pcie),GFP_KERNEL ); -if (!cdns_plat_pcie) -return -ENOMEM ; - -platform_set_drvdata (pdev, cdns_plat_pcie);if (is_rc) {if (!IS_ENABLED (CONFIG_PCIE_CADENCE_PLAT_HOST ))return -ENODEV ;
@@ -72,9 +59,9 @@ static int cdns_plat_pcie_probe(struct platform_device *pdev) rc =pci_host_bridge_priv (bridge); rc->pcie.dev = dev; rc->pcie.ops = &cdns_plat_ops; - cdns_plat_pcie->pcie = &rc->pcie; + pcie = &rc->pcie; - ret =cdns_pcie_init_phy (dev, cdns_plat_pcie->pcie); + ret =cdns_pcie_init_phy (dev, pcie);if (ret) {dev_err (dev,"failed to init phy\n" );return ret;
@@ -99,9 +86,9 @@ static int cdns_plat_pcie_probe(struct platform_device *pdev) ep->pcie.dev = dev; ep->pcie.ops = &cdns_plat_ops; - cdns_plat_pcie->pcie = &ep->pcie; + pcie = &ep->pcie; - ret =cdns_pcie_init_phy (dev, cdns_plat_pcie->pcie); + ret =cdns_pcie_init_phy (dev, pcie);if (ret) {dev_err (dev,"failed to init phy\n" );return ret;
@@ -119,18 +106,20 @@ static int cdns_plat_pcie_probe(struct platform_device *pdev) goto err_init; } +platform_set_drvdata (pdev, pcie); +return 0 ; err_init: err_get_sync:pm_runtime_put_sync (dev);pm_runtime_disable (dev); -cdns_pcie_disable_phy (cdns_plat_pcie->pcie); - phy_count = cdns_plat_pcie->pcie->phy_count; +cdns_pcie_disable_phy (pcie); + phy_count = pcie->phy_count;while (phy_count--) -device_link_del (cdns_plat_pcie->pcie->link[phy_count]); +device_link_del (pcie->link[phy_count]); -return 0 ; +return ret; }static void cdns_plat_pcie_shutdown (struct platform_device *pdev)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 645/686 iomap: dont mark unwritten parts of a folio uptodate
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Brauner <[email protected]>
[ Upstream commit a4193b4af359db84b2cdf3a040752861984c636b ]
For a buffered write into a hole, an unwritten or new extent, or past EOF __iomap_write_begin() zeroes the parts of the blocks outside of the write and then marks the blocks uptodate. That includes the range of the write itself which still holds whatever was in the folio before. It only becomes valid once the copy from userspace has filled it in.
But the copy can come up short and __iomap_write_end() only rejects a short copy if the folio isn't uptodate. If the zeroed blocks were all that was missing the folio is uptodate by then, the short copy is accepted, and the rest of the range is exposed to readers and can end up on disk. A source buffer that ends in an unmapped page is enough:
ftruncate(fd, 4096);
pwrite(fd, p, 3000, 100); /* 16 bytes at p, then PROT_NONE */
pread(fd, buf, 4096, 0);The write returns 16 and the read returns 2984 bytes of whatever was in that page before. If other blocks of the folio aren't uptodate the short copy is rejected but the zeroed blocks keep their uptodate bits and the retry with the copied length leaves the same bytes behind.
Only mark blocks uptodate in __iomap_write_begin() after reading them. __iomap_write_end() marks the zeroed blocks uptodate once the copy has succeeded and rejects a short copy.
Willy reported this back in 2024 (cf. [1]) and Zhang Yi posted the same fix (cf. [2]) but it never got merged.
[1]: https://lore.kernel.org/all/[email protected]
[2]: https://lore.kernel.org/all/[email protected]
--- fs/iomap/buffered-io.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/iomap/buffered-io.c +2 -1
@@ -766,6 +766,7 @@ static int __iomap_write_begin(const struct iomap_iter *iter,if (iomap_block_needs_zeroing (iter, block_start)) {if (WARN_ON_ONCE (iter->flags &IOMAP_UNSHARE ))return -EIO ; +/* uptodate once copied, see __iomap_write_end() */ folio_zero_segments (folio, poff, from, to, poff + plen); }else {int status;
@@ -781,8 +782,8 @@ static int __iomap_write_begin(const struct iomap_iter *iter, folio, block_start, plen);if (status)return status; +iomap_set_range_uptodate (folio, poff, plen); } -iomap_set_range_uptodate (folio, poff, plen); }while ((block_start += plen) < block_end);return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 646/686 mm/shmem: dont release a swapin-error marker as a swap entry
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Carlier <[email protected]>
[ Upstream commit e4b92891aaca0d37b5973362dd14747a65406650 ]
A failed shmem swapin (eg, EIO) frees the swap slot and leaves a PTE_MARKER_POISONED entry in the page cache. On truncate or eviction shmem_free_swap() passes that marker to swap_put_entries_direct(), which warns because it is not a swap entry. There is nothing left to release either way.
Skip the release for non-swap entries, as every other caller already does.
--- mm/shmem.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
mm/shmem.c +4 -2
@@ -948,6 +948,7 @@ static long shmem_free_swap(struct address_space *mapping, pgoff_t index, pgoff_t end, void *radswap) { XA_STATE(xas, &mapping->i_pages, index); +const swp_entry_t swp =radix_to_swp_entry (radswap);unsigned int nr_pages =0 ;pgoff_t base;void *entry;
@@ -964,8 +965,9 @@ static long shmem_free_swap(struct address_space *mapping, }xas_unlock_irq (&xas); -if (nr_pages) -free_swap_and_cache_nr (radix_to_swp_entry (radswap), nr_pages); +/* A swapin-error marker holds no swap slot, so just drop it. */ +if (nr_pages && !non_swap_entry (swp)) +free_swap_and_cache_nr (swp, nr_pages);return nr_pages; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 647/686 f2fs: fix to invalidate curseg if change_curseg() fails
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chao Yu <[email protected]>
[ Upstream commit e74476ad8162c1facc74b74ce2d1372492df872e ]
Our consistency stress test (fsstress + fio + atomic write workers + "f2fs_io shutdown 1") triggers below kernel BUG:
F2FS-fs (vdd): Stopped filesystem due to reason: 0
------------[ cut here ]------------ kernel BUG at fs/f2fs/segment.c:3989! Oops: invalid opcode: 0000 [#1] SMP KASAN PTI Workqueue: writeback wb_workfn (flush-253:48) RIP: 0010:f2fs_allocate_data_block+0x257a/0x38e0 Call Trace: <TASK> do_write_block+0x155/0xc10 f2fs_outplace_write_data+0x192/0x340 f2fs_do_write_data_page+0xc57/0x1880 f2fs_write_single_data_page+0xda9/0x15a0 f2fs_write_cache_pages+0x973/0x1f20 __f2fs_write_data_pages+0x6c4/0x1890 do_writepages+0x21e/0x560 __writeback_single_inode+0x119/0x11b0 writeback_sb_inodes+0x67d/0x17a0 wb_writeback+0x207/0x820 wb_workfn+0x128/0xc30 process_one_work+0x925/0x1600 worker_thread+0x60a/0xff0 kthread+0x35f/0x460 ret_from_fork+0x474/0x7e0 ret_from_fork_asm+0x1a/0x30 </TASK>
The BUG is f2fs_bug_on(sbi, curseg->next_blkoff >= BLKS_PER_SEG(sbi)) in f2fs_allocate_data_block(), next_blkoff was 512.
The root cause is a race in between atomic write commit and shutdown as below:
Thread A (commit atomic write) Thread B (shutdown) Thread C (writeback)
- f2fs_ioc_commit_atomic_write
- f2fs_commit_atomic_write
- __f2fs_commit_atomic_write
- __replace_atomic_write_block
- f2fs_replace_block
- __f2fs_replace_block
- f2fs_ioc_shutdown
- f2fs_do_shutdown
: F2FS_GOING_DOWN_METASYNC
- f2fs_sync_fs
- f2fs_write_single_data_page : pass f2fs_cp_error() check
- f2fs_stop_checkpoint
: set CP_ERROR_FLAG
- change_curseg
- reset_curseg
: curseg->segno = new_segno
: curseg->alloc_type = SSR
: curseg->next_blkoff = __next_free_blkoff()
which is BLKS_PER_SEG if there is no free
slot in new_segno
- f2fs_get_sum_cache
: return -EIO due to f2fs_cp_error()
: return error w/o restoring curseg
: goto out_unlock, skip restoring
old segno, blkoff and alloc_type
- f2fs_do_write_data_page
- f2fs_outplace_write_data
- do_write_block
- f2fs_allocate_data_block : curseg->segno is valid : f2fs_bug_on(next_blkoff >= BLKS_PER_SEG)
Since commit 86f33603f8c5 ("f2fs: handle errors of f2fs_get_meta_page_nofail"), change_curseg() can fail after the curseg has already been switched to the new segment, then the curseg is left in an inconsistent state: it points to a segment which may have no free slot, its summary block is zeroed, and the caller can not restore it. Subsequent block allocation on the curseg will trigger the BUG. Moreover, the writeback thread dies with curseg_lock, curseg_mutex and sentry_lock held, so the commit, shutdown and other I/O threads hang in D state.
Since change_curseg() only fails once CP_ERROR_FLAG is set, no checkpoint will be committed afterward, let's invalidate the curseg via reset_curseg_fields() on failure, as new_curseg() does for -ENOSPC, then f2fs_allocate_data_block() will fail with -ENOSPC on the curseg instead of triggering BUG, and do_write_block() can handle the error since CP_ERROR_FLAG has been set.
--- fs/f2fs/segment.c | 1 + 1 file changed, 1 insertion(+)
fs/f2fs/segment.c +1 -0
@@ -3067,6 +3067,7 @@ static int change_curseg(struct f2fs_sb_info *sbi, int type)if (IS_ERR (sum_folio)) {/* GC won't be able to use stale summary pages by cp_error */ memset (curseg->sum_blk,0 , sbi->sum_entry_size); +reset_curseg_fields (curseg);return PTR_ERR (sum_folio); } sum_node =SUM_BLK_PAGE_ADDR (sbi, sum_folio, new_segno);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 648/686 LoongArch: Dont init & online empty nodes
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Huacai Chen <[email protected]>
[ Upstream commit 87c6d144bc7bbed0c4573848b9c92006edca7848 ]
Don't init & online empty nodes without any CPU cores (and memory), in this way "lscpu" will not display confusing empty nodes.
Modify fake_numa_init() to make sure at least Node-0 isn't empty for the FDT booting case.
--- arch/loongarch/kernel/numa.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
arch/loongarch/kernel/numa.c +6 -2
@@ -216,6 +216,8 @@ static int __init fake_numa_init(void)phys_addr_t start =memblock_start_of_DRAM ();phys_addr_t end =memblock_end_of_DRAM () -1 ; +set_cpuid_to_node (0 ,0 ); +early_numa_add_cpu (0 ,0 );node_set (0 , numa_nodes_parsed);pr_info ("Faking a node at [mem %pap-%pap]\n" , &start, &end);
@@ -245,8 +247,10 @@ int __init init_numa_memory(void)return -EINVAL ;for_each_node_mask (node, node_possible_map) { -node_mem_init (node); -node_set_online (node); +if (!cpumask_empty (&cpus_on_node[node])) { +node_mem_init (node); +node_set_online (node); + } } max_pfn =PFN_DOWN (memblock_end_of_DRAM ()); max_low_pfn =min (PFN_DOWN (HIGHMEM_START ), max_pfn);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 649/686 Documentation/kernel-parameters: Move the kernel build options
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Borislav Petkov (AMD) <[email protected]>
[ Upstream commit f690e07859e67505e7106ef5b4fae5e8b71b2109 ]
Move the kernel build options abbreviations to the .txt file so that they are together instead of one having to go hunt them in the .rst file.
Tweak the formatting so that the inclusion of kernel-parameters.txt still keeps the whole thing somewhat presentable in the html output too.
Message-ID: <[email protected]>
Stable-dep-of: 799203afd298 ("nvme-tcp: validate the TLS handshake timeout")
--- .../admin-guide/kernel-parameters.rst | 97 +----------------- .../admin-guide/kernel-parameters.txt | 98 +++++++++++++++++++ 2 files changed, 99 insertions(+), 96 deletions(-)
Documentation/admin-guide/kernel-parameters.rst +1 -96
@@ -110,102 +110,7 @@ The parameters listed below are only valid if certain kernel build options were enabled and if respective hardware is present. This list should be kept in alphabetical order. The text in square brackets at the beginning of each description states the restrictions within which a parameter -is applicable:: - - ACPI ACPI support is enabled. - AGP AGP (Accelerated Graphics Port) is enabled. - ALSA ALSA sound support is enabled. - APIC APIC support is enabled. - APM Advanced Power Management support is enabled. - APPARMOR AppArmor support is enabled. - ARM ARM architecture is enabled. - ARM64 ARM64 architecture is enabled. - AX25 Appropriate AX.25 support is enabled. - CLK Common clock infrastructure is enabled. - CMA Contiguous Memory Area support is enabled. - DRM Direct Rendering Management support is enabled. - DYNAMIC_DEBUG Build in debug messages and enable them at runtime - EARLY Parameter processed too early to be embedded in initrd. - EDD BIOS Enhanced Disk Drive Services (EDD) is enabled - EFI EFI Partitioning (GPT) is enabled - EVM Extended Verification Module - FB The frame buffer device is enabled. - FTRACE Function tracing enabled. - GCOV GCOV profiling is enabled. - HIBERNATION HIBERNATION is enabled. - HW Appropriate hardware is enabled. - HYPER_V HYPERV support is enabled. - IMA Integrity measurement architecture is enabled. - IP_PNP IP DHCP, BOOTP, or RARP is enabled. - IPV6 IPv6 support is enabled. - ISAPNP ISA PnP code is enabled. - ISDN Appropriate ISDN support is enabled. - ISOL CPU Isolation is enabled. - JOY Appropriate joystick support is enabled. - KGDB Kernel debugger support is enabled. - KVM Kernel Virtual Machine support is enabled. - LIBATA Libata driver is enabled - LOONGARCH LoongArch architecture is enabled. - LOOP Loopback device support is enabled. - LP Printer support is enabled. - M68k M68k architecture is enabled. - These options have more detailed description inside of - Documentation/arch/m68k/kernel-options.rst. - MDA MDA console support is enabled. - MIPS MIPS architecture is enabled. - MOUSE Appropriate mouse support is enabled. - MSI Message Signaled Interrupts (PCI). - MTD MTD (Memory Technology Device) support is enabled. - NET Appropriate network support is enabled. - NFS Appropriate NFS support is enabled. - NUMA NUMA support is enabled. - OF Devicetree is enabled. - PARISC The PA-RISC architecture is enabled. - PCI PCI bus support is enabled. - PCIE PCI Express support is enabled. - PCMCIA The PCMCIA subsystem is enabled. - PNP Plug & Play support is enabled. - PPC PowerPC architecture is enabled. - PPT Parallel port support is enabled. - PS2 Appropriate PS/2 support is enabled. - PV_OPS A paravirtualized kernel is enabled. - RAM RAM disk support is enabled. - RDT Intel Resource Director Technology. - RISCV RISCV architecture is enabled. - S390 S390 architecture is enabled. - SCSI Appropriate SCSI support is enabled. - A lot of drivers have their options described inside - the Documentation/scsi/ sub-directory. - SDW SoundWire support is enabled. - SECURITY Different security models are enabled. - SELINUX SELinux support is enabled. - SERIAL Serial support is enabled. - SH SuperH architecture is enabled. - SMP The kernel is an SMP kernel. - SPARC Sparc architecture is enabled. - SUSPEND System suspend states are enabled. - SWSUSP Software suspend (hibernation) is enabled. - TPM TPM drivers are enabled. - UMS USB Mass Storage support is enabled. - USB USB support is enabled. - USBHID USB Human Interface Device support is enabled. - V4L Video For Linux support is enabled. - VGA The VGA console has been enabled. - VMMIO Driver for memory mapped virtio devices is enabled. - VT Virtual terminal support is enabled. - WDT Watchdog support is enabled. - X86-32 X86-32, aka i386 architecture is enabled. - X86-64 X86-64 architecture is enabled. - X86 Either 32-bit or 64-bit x86 (same as X86-32+X86-64) - X86_UV SGI UV support is enabled. - XEN Xen support is enabled - XTENSA xtensa architecture is enabled. - -In addition, the following text indicates that the option:: - - BOOT Is a boot loader parameter. - BUGS= Relates to possible processor bugs on the said processor. - KNL Is a kernel start-up parameter. +is applicable. Parameters denoted with BOOT are actually interpreted by the boot loader, and have no meaning to the kernel directly.
Documentation/admin-guide/kernel-parameters.txt +98 -0
101 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 650/686 nvmet-tcp: validate the TLS handshake timeout
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yingjie Wang <[email protected]>
[ Upstream commit e3e7a85730a4b17efa1e2ff4088443c4753be683 ]
tls_handshake_timeout is writable but stored as a signed int. Multiplying the value by MSEC_PER_SEC and HZ therefore uses signed arithmetic.
With HZ=1000, setting it to 2147484 overflows both multiplications. If the handshake request is accepted and remains pending, the timer wheel treats the jiffies delay as already expired and queues the timeout work on its next advance, while the handshake agent was given about 24.9 days. Negative values such as -1 cause the same immediate kernel-side timeout.
Store the parameter as an unsigned int and reject values that cannot be represented both by tls_handshake_args::ta_timeout_ms and by a safe jiffies delay. Take one snapshot so a concurrent parameter update cannot give the handshake agent and delayed work different timeouts. Document the accepted range for built-in use.
Negative and oversized values now fail with -EINVAL. Keep zero valid, preserving the existing immediate-timeout behavior.
Backport notes: Route timeout validation through the existing parameter setter, preserving the validation of the other parameters and avoiding a new function. Omit the unrelated dynamic-quirks documentation and retain its blank separator so the host timeout fix merges cleanly.
Stable-dep-of: 799203afd298 ("nvme-tcp: validate the TLS handshake timeout")
--- .../admin-guide/kernel-parameters.txt | 6 +++++ drivers/nvme/target/tcp.c | 26 ++++++++++++++++--- 2 files changed, 28 insertions(+), 4 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +6 -0
@@ -4651,6 +4651,12 @@ Kernel parameters This can be set from sysctl after boot. See Documentation/admin-guide/sysctl/vm.rst for details. + + nvmet_tcp.tls_handshake_timeout= + [NVME] NVMe/TCP target TLS handshake timeout in seconds. + Valid values range from 0 to the smaller of + UINT_MAX / 1000 and MAX_JIFFY_OFFSET / HZ. Default: 10 + ohci1394_dma=early [HW,EARLY] enable debugging via the ohci1394 driver. See Documentation/core-api/debugging-via-ohci1394.rst for more info.
drivers/nvme/target/tcp.c +22 -4
@@ -6,6 +6,7 @@#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt#include <linux/module.h> #include <linux/init.h> +#include <linux/jiffies.h> #include <linux/slab.h> #include <linux/crc32c.h> #include <linux/err.h>
@@ -41,8 +42,18 @@ static int param_store_val(const char *str, int *val, int min, int max)return 0 ; } +#ifdef CONFIG_NVME_TARGET_TCP_TLS +static unsigned int tls_handshake_timeout =10 ; +#endif +static int set_params (const char *str,const struct kernel_param *kp) { +#ifdef CONFIG_NVME_TARGET_TCP_TLS +if (kp->arg == &tls_handshake_timeout) +return param_set_uint_minmax (str, kp,0 , + min_t(unsigned long, UINT_MAX / MSEC_PER_SEC, +MAX_JIFFY_OFFSET /HZ )); +#endif return param_store_val (str, kp->arg,0 ,INT_MAX ); }
@@ -76,8 +87,14 @@ MODULE_PARM_DESC(idle_poll_period_usecs,/* * TLS handshake timeout */ -static int tls_handshake_timeout =10 ; -module_param (tls_handshake_timeout, int,0644 ); +static const struct kernel_param_ops tls_handshake_timeout_ops = { + .set = set_params, + .get = param_get_uint, +}; + +module_param_cb (tls_handshake_timeout, &tls_handshake_timeout_ops, + &tls_handshake_timeout,0644 ); +__MODULE_PARM_TYPE (tls_handshake_timeout,"uint" );MODULE_PARM_DESC (tls_handshake_timeout,"nvme TLS handshake timeout in seconds (default 10)" );#endif
@@ -1926,6 +1943,7 @@ static int nvmet_tcp_tls_handshake(struct nvmet_tcp_queue *queue) {int ret = -EOPNOTSUPP ;struct tls_handshake_args args; +unsigned int timeout =READ_ONCE (tls_handshake_timeout);if (queue->state !=NVMET_TCP_Q_TLS_HANDSHAKE ) {pr_warn ("cannot start TLS in state %d\n" , queue->state);
@@ -1939,7 +1957,7 @@ static int nvmet_tcp_tls_handshake(struct nvmet_tcp_queue *queue) args.ta_done = nvmet_tcp_tls_handshake_done; args.ta_data = queue; args.ta_keyring =key_serial (queue->port->nport->keyring); - args.ta_timeout_ms = tls_handshake_timeout *1000 ; + args.ta_timeout_ms = timeout *MSEC_PER_SEC ; ret =tls_server_hello_psk (&args,GFP_KERNEL );if (ret) {
@@ -1947,7 +1965,7 @@ static int nvmet_tcp_tls_handshake(struct nvmet_tcp_queue *queue)pr_err ("failed to start TLS, err=%d\n" , ret); }else {queue_delayed_work (nvmet_wq, &queue->tls_handshake_tmo_work, - tls_handshake_timeout *HZ ); + (unsigned long )timeout *HZ ); }return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 651/686 nvme-tcp: validate the TLS handshake timeout
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yingjie Wang <[email protected]>
[ Upstream commit 799203afd298b1f8e9ee49815eb38f775f211299 ]
tls_handshake_timeout is writable but stored as a signed int. Multiplying the value by MSEC_PER_SEC and HZ therefore uses signed arithmetic.
With HZ=1000, setting it to 2147484 overflows both multiplications. If the handshake request is accepted and its completion remains pending, schedule_timeout() reports a wrong timeout value with a stack dump and returns zero. The handshake then fails immediately with -ETIMEDOUT, while the handshake agent was given about 24.9 days. Negative values such as -1 have the same kernel-side effect.
Store the parameter as an unsigned int and reject values that cannot be represented both by tls_handshake_args::ta_timeout_ms and by a safe jiffies delay. Take one snapshot so a concurrent parameter update cannot give the handshake agent and completion wait different timeouts. Document the accepted range for built-in use.
wait_for_completion_interruptible_timeout() returns the remaining jiffies as a long after a successful completion. Keep that result in a long because an accepted timeout can exceed INT_MAX jiffies on 64-bit systems.
Negative and oversized values now fail with -EINVAL. Keep zero valid, preserving the existing immediate-timeout behavior.
--- .../admin-guide/kernel-parameters.txt | 5 +++ drivers/nvme/host/tcp.c | 34 ++++++++++++++----- 2 files changed, 31 insertions(+), 8 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +5 -0
@@ -4652,6 +4652,11 @@ Kernel parameters See Documentation/admin-guide/sysctl/vm.rst for details. + nvme_tcp.tls_handshake_timeout= + [NVME] NVMe/TCP host TLS handshake timeout in seconds. + Valid values range from 0 to the smaller of + UINT_MAX / 1000 and MAX_JIFFY_OFFSET / HZ. Default: 10 + nvmet_tcp.tls_handshake_timeout= [NVME] NVMe/TCP target TLS handshake timeout in seconds. Valid values range from 0 to the smaller of
drivers/nvme/host/tcp.c +26 -8
@@ -6,6 +6,7 @@#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt#include <linux/module.h> #include <linux/init.h> +#include <linux/jiffies.h> #include <linux/slab.h> #include <linux/err.h> #include <linux/crc32.h>
@@ -46,9 +47,24 @@ MODULE_PARM_DESC(wq_unbound, "Use unbound workqueue for nvme-tcp IO context (def/* * TLS handshake timeout */ -static int tls_handshake_timeout =10 ; +static unsigned int tls_handshake_timeout =10 ;#ifdef CONFIG_NVME_TCP_TLS -module_param (tls_handshake_timeout, int,0644 ); +static int tls_handshake_timeout_set (const char *val, +const struct kernel_param *kp) +{ +return param_set_uint_minmax (val, kp,0 , + min_t(unsigned long, UINT_MAX / MSEC_PER_SEC, +MAX_JIFFY_OFFSET /HZ )); +} + +static const struct kernel_param_ops tls_handshake_timeout_ops = { + .set = tls_handshake_timeout_set, + .get = param_get_uint, +}; + +module_param_cb (tls_handshake_timeout, &tls_handshake_timeout_ops, + &tls_handshake_timeout,0644 ); +__MODULE_PARM_TYPE (tls_handshake_timeout,"uint" );MODULE_PARM_DESC (tls_handshake_timeout,"nvme TLS handshake timeout in seconds (default 10)" );#endif
@@ -1912,8 +1928,10 @@ static int nvme_tcp_start_tls(struct nvme_ctrl *nctrl, {int qid =nvme_tcp_queue_id (queue);int ret; +long wait_ret;struct tls_handshake_args args; -unsigned long tmo = tls_handshake_timeout *HZ ; +unsigned int timeout =READ_ONCE (tls_handshake_timeout); +unsigned long tmo = (unsigned long )timeout *HZ ;key_serial_t keyring =nvme_keyring_id (); dev_dbg(nctrl->device, "queue %d: start TLS with key %x\n",
@@ -1927,7 +1945,7 @@ static int nvme_tcp_start_tls(struct nvme_ctrl *nctrl,if (nctrl->opts->keyring) keyring =key_serial (nctrl->opts->keyring); args.ta_keyring = keyring; - args.ta_timeout_ms = tls_handshake_timeout *1000 ; + args.ta_timeout_ms = timeout *MSEC_PER_SEC ; queue->tls_err = -EOPNOTSUPP ;init_completion (&queue->tls_complete); ret =tls_client_hello_psk (&args,GFP_KERNEL );
@@ -1936,10 +1954,10 @@ static int nvme_tcp_start_tls(struct nvme_ctrl *nctrl, qid, ret);return ret; } - ret =wait_for_completion_interruptible_timeout (&queue->tls_complete, tmo); -if (ret <=0 ) { -if (ret ==0 ) - ret = -ETIMEDOUT ; + wait_ret =wait_for_completion_interruptible_timeout (&queue->tls_complete, + tmo); +if (wait_ret <=0 ) { + ret = wait_ret <0 ? -ERESTARTSYS : -ETIMEDOUT ; dev_err(nctrl->device, "queue %d: TLS handshake failed, error %d\n",
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 652/686 watchdog/hpwdt: Refine hpwdt message for UV platform
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steve Wahl <[email protected]>
[ Upstream commit d8207d1e9a36b1a8a461581b2d4073ea28335603 ]
The watchdog hardware the hpwdt driver uses was added to the UV platform for UV_5, but the logging mentioned by this driver was not added to the BIOS. When the watchdog fires, the printed message had the administrators and developers looking for non-existent log files, and confused about whether a watchdog actually tripped.
Change the message that prints on UV platforms so it doesn't send the user looking for non-existent logs.
To aid in any future debugging, include all 8 bits of the NMISTAT register in the output, not just the two bits being used to determine this was "mynmi". And provide names to the bits in NMISTAT so the code is easier to understand.
Stable-dep-of: ed9e4c1ff15d ("panic: restore variable arguments to nmi_panic()")
--- drivers/watchdog/hpwdt.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-)
drivers/watchdog/hpwdt.c +15 -7
@@ -22,6 +22,7 @@#include <linux/watchdog.h> #ifdef CONFIG_HPWDT_NMI_DECODING #include <asm/nmi.h> +#include <asm/uv/uv.h> #endif #include <linux/crash_dump.h>
@@ -158,24 +159,31 @@ static int hpwdt_set_pretimeout(struct watchdog_device *wdd, unsigned int req)return 0 ; } -static int hpwdt_my_nmi (void ) -{ -return ioread8 (hpwdt_nmistat) &0x6 ; -} +#define NMISTAT_EASR BIT(0) +#define NMISTAT_EWDOG BIT(1) +#define NMISTAT_RTRAP BIT(2) +#define NMISTAT_DBELL BIT(3) +#define NMISTAT_EMSWDG BIT(4) +#define NMISTAT_GPI BIT(5) +#define NMISTAT_NMIOUT BIT(7)/* * NMI Handler */ static int hpwdt_pretimeout (unsigned int ulReason,struct pt_regs *regs) { -unsigned int mynmi =hpwdt_my_nmi (); -static char panic_msg[] = +u8 nmistat =ioread8 (hpwdt_nmistat); +bool mynmi = (nmistat & (NMISTAT_EWDOG |NMISTAT_RTRAP )) !=0 ; +static char panic_msg_default[] ="00: An NMI occurred. Depending on your system the reason " "for the NMI is logged in any one of the following resources:\n" "1. Integrated Management Log (IML)\n" "2. OA Syslog\n" "3. OA Forward Progress Log\n" "4. iLO Event Log" ; +static char panic_msg_uv[] = +"00: A watchdog NMI occurred." ; +char *panic_msg =is_uv_system () ? panic_msg_uv : panic_msg_default;if (ulReason ==NMI_UNKNOWN && !mynmi)return NMI_DONE ;
@@ -189,7 +197,7 @@ static int hpwdt_pretimeout(unsigned int ulReason, struct pt_regs *regs)hpwdt_ping_ticks (SECS_TO_TICKS (val)); } -hex_byte_pack (panic_msg, mynmi); +hex_byte_pack (panic_msg, nmistat);nmi_panic (regs, panic_msg);return NMI_HANDLED ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 653/686 panic: restore variable arguments to nmi_panic()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bradley Morgan <[email protected]>
[ Upstream commit ed9e4c1ff15d5b935f467811541ca0aa6e49c5d0 ]
nmi_panic() used to accept variable arguments until commit ebc41f20d77f ("panic: change nmi_panic from macro to function") flattened it to a final message string. vpanic() did not exist back then, so the function had to format through panic("%s", msg).
Bring the variable arguments back and format with vpanic() directly. The next patch makes nmi_panic() try the panic_force_cpu= redirect before claiming panic_cpu. panic_try_force_cpu() needs to print the message but it is used also by panic() which accepts variable argument list. The string could be formatted only when a CPU gets assigned to process the redirection. Otherwise, there might be a race when writing to the panic_force_buf.
No current caller passes a string with format specifiers. The closest one is hpwdt_pretimeout(), which builds panic_msg with hex_byte_pack() and has only two variants, both plain strings. But the new __printf() annotation on nmi_panic() would warn with -Wformat-security there because the buffer is passed directly as the format argument, so switch it to nmi_panic(regs, "%s", panic_msg).
--- drivers/watchdog/hpwdt.c | 2 +- include/linux/panic.h | 3 ++- kernel/panic.c | 10 ++++++++-- 3 files changed, 11 insertions(+), 4 deletions(-)
drivers/watchdog/hpwdt.c +1 -1
@@ -198,7 +198,7 @@ static int hpwdt_pretimeout(unsigned int ulReason, struct pt_regs *regs) }hex_byte_pack (panic_msg, nmistat); -nmi_panic (regs, panic_msg); +nmi_panic (regs,"%s" , panic_msg);return NMI_HANDLED ; }
include/linux/panic.h +2 -1
@@ -13,7 +13,8 @@ __printf(1, 2)void panic (const char *fmt, ...)__noreturn __cold ; __printf(1, 0)void vpanic (const char *fmt,va_list args)__noreturn __cold ; -void nmi_panic (struct pt_regs *regs,const char *msg); +__printf(2, 3) +void nmi_panic (struct pt_regs *regs,const char *fmt, ...);void check_panic_on_warn (const char *origin);extern void oops_enter (void );extern void oops_exit (void );
kernel/panic.c +8 -2
@@ -360,13 +360,19 @@ EXPORT_SYMBOL(panic_on_other_cpu);* nmi_panic_self_stop() which can provide architecture dependent code such * as saving register state for crash dump. */ -void nmi_panic (struct pt_regs *regs,const char *msg) +void nmi_panic (struct pt_regs *regs,const char *fmt, ...) { +va_list args; + +va_start (args, fmt); +if (panic_try_start ()) -panic ("%s" , msg); +vpanic (fmt, args);if (panic_on_other_cpu ())nmi_panic_self_stop (regs); + +va_end (args); }EXPORT_SYMBOL (nmi_panic);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 654/686 ALSA: hda/realtek: Enable all four speaker amps on Lenovo ThinkBook X G2 IAH
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Evgeny Akhtimirov <[email protected]>
[ Upstream commit f2293e7b2ddd803b1461e0490f9b2f32089c1dd0 ]
The Lenovo ThinkBook X G2 IAH (MTM 21TU) has an ALC287 codec with four CS35L41 amplifiers on I2C (CSC3551). It reports codec SSID 17aa:3929, which it shares with the ThinkBook 13x Gen 5, and PCI SSID 17aa:3842.
Since PCI SSID 17aa:3842 has no quirk entry, the codec SSID matches ALC287_FIXUP_MG_RTKC_CSAMP_CS35L41_I2C_THINKPAD. That fixup binds only two amps (cs35l41-hda.0 and .1), while the CS35L41 configuration table describes four for 17AA3929. Amps .2 and .3 probe and load firmware, but they are never bound to the codec, so half of the speakers stay silent.
Add a ThinkPad-style fixup chain that binds four I2C amps, and match the laptop by its PCI SSID so the ThinkBook 13x Gen 5 is not affected.
Tested with hda_model=1028:0c4d (alias to ALC287_FIXUP_CS35L41_I2C_4):
all four amps bind, apply their calibration and are runtime-active during playback.
--- sound/hda/codecs/realtek/alc269.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
sound/hda/codecs/realtek/alc269.c +15 -0
@@ -3979,6 +3979,8 @@ enum {ALC245_FIXUP_HP_X360_MUTE_LEDS ,ALC287_FIXUP_THINKPAD_I2S_SPK ,ALC287_FIXUP_MG_RTKC_CSAMP_CS35L41_I2C_THINKPAD , +ALC287_FIXUP_CS35L41_I2C_4_THINKPAD_ACPI , +ALC287_FIXUP_MG_RTKC_CSAMP_CS35L41_I2C_4_THINKPAD ,ALC2XX_FIXUP_HEADSET_MIC ,ALC289_FIXUP_DELL_CS35L41_SPI_2 , ALC294_FIXUP_CS35L41_I2C_2,
@@ -6441,6 +6443,18 @@ static const struct hda_fixup alc269_fixups[] = { .chained = true, .chain_id = ALC287_FIXUP_CS35L41_I2C_2_THINKPAD_ACPI, }, + [ALC287_FIXUP_CS35L41_I2C_4_THINKPAD_ACPI] = { + .type = HDA_FIXUP_FUNC, + .v.func = cs35l41_fixup_i2c_four, + .chained = true, + .chain_id = ALC285_FIXUP_THINKPAD_NO_BASS_SPK_HEADSET_JACK, + }, + [ALC287_FIXUP_MG_RTKC_CSAMP_CS35L41_I2C_4_THINKPAD] = { + .type = HDA_FIXUP_FUNC, + .v.func = alc287_fixup_bind_dacs, + .chained = true, + .chain_id = ALC287_FIXUP_CS35L41_I2C_4_THINKPAD_ACPI, + }, [ALC2XX_FIXUP_HEADSET_MIC] = { .type = HDA_FIXUP_FUNC, .v.func = alc2xx_fixup_headset_mic,
@@ -7579,6 +7593,7 @@ static const struct hda_quirk alc269_fixup_tbl[] = {SND_PCI_QUIRK (0x17aa ,0x3827 ,"Ideapad S740" ,ALC285_FIXUP_IDEAPAD_S740_COEF ),SND_PCI_QUIRK (0x17aa ,0x3834 ,"Lenovo IdeaPad Slim 9i 14ITL5" ,ALC287_FIXUP_YOGA7_14ITL_SPEAKERS ),SND_PCI_QUIRK (0x17aa ,0x383d ,"Legion Y9000X 2019" ,ALC285_FIXUP_LEGION_Y9000X_SPEAKERS ), +SND_PCI_QUIRK (0x17aa ,0x3842 ,"ThinkBook X G2 IAH" ,ALC287_FIXUP_MG_RTKC_CSAMP_CS35L41_I2C_4_THINKPAD ),SND_PCI_QUIRK (0x17aa ,0x3843 ,"Lenovo Yoga 9i / Yoga Book 9i" ,ALC287_FIXUP_LENOVO_YOGA_BOOK_9I ),/* Yoga Pro 7 14IMH9 shares PCI SSID 17aa:3847 with Legion 7 16ACHG6; * use codec SSID to distinguish them
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 655/686 posix-timers: Handle the timer_[re]arm() return value
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Gleixner <[email protected]>
[ Upstream commit cfb7fe3fdd4ca1d37da1ed15a1897d4a27c47a8a ]
The [re]arm callbacks will return true when the timer was queued and false if it was already expired at enqueue time.
In both cases the call sites can trivially queue the signal right there, when the timer was already expired. That avoids a full round trip through the hrtimer interrupt.
Stable-dep-of: 141a27750ec3 ("posix-timers: Report zero remaining time for disarmed SIGEV_NONE timers")
--- kernel/time/posix-timers.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-)
kernel/time/posix-timers.c +17 -5
@@ -306,6 +306,8 @@ static bool common_hrtimer_rearm(struct k_itimer *timr)static bool __posixtimer_deliver_signal (struct kernel_siginfo *info,struct k_itimer *timr) { +bool queued; +guard (spinlock)(&timr->it_lock);/*
@@ -319,12 +321,18 @@ static bool __posixtimer_deliver_signal(struct kernel_siginfo *info, struct k_itif (!timr->it_interval ||WARN_ON_ONCE (timr->it_status !=POSIX_TIMER_REQUEUE_PENDING ))return true; - timr->kclock->timer_rearm (timr); - timr->it_status =POSIX_TIMER_ARMED ; +/* timer_rearm() updates timr::it_overrun */ + queued = timr->kclock->timer_rearm (timr); + timr->it_overrun_last = timr->it_overrun; timr->it_overrun =-1LL ; ++timr->it_signal_seq; info->si_overrun =timer_overrun_to_int (timr); + +if (queued) + timr->it_status =POSIX_TIMER_ARMED ; +else +posix_timer_queue_signal (timr);return true; }
@@ -912,9 +920,13 @@ int common_timer_set(struct k_itimer *timr, int flags, expires =timens_ktime_to_host (timr->it_clock, expires); sigev_none = timr->it_sigev_notify ==SIGEV_NONE ; - kc->timer_arm (timr, expires, flags &TIMER_ABSTIME , sigev_none); -if (!sigev_none) - timr->it_status =POSIX_TIMER_ARMED ; +if (kc->timer_arm (timr, expires, flags &TIMER_ABSTIME , sigev_none)) { +if (!sigev_none) + timr->it_status =POSIX_TIMER_ARMED ; + }else { +/* Timer was already expired, queue the signal */ +posix_timer_queue_signal (timr); + }return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 656/686 posix-timers: Report zero remaining time for disarmed SIGEV_NONE timers
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hung-Jui Lin <[email protected]>
[ Upstream commit 141a27750ec3d91ad9d1ad1764ebb5e51b963478 ]
SIGEV_NONE timers are never queued. common_timer_get() emulates their expiry by computing the remaining time from the stored expiry value. Because an armed SIGEV_NONE oneshot timer is not queued, its it_status stays POSIX_TIMER_DISARMED. So common_timer_get() cannot use it_status to skip a disarmed SIGEV_NONE timer and evaluates the stored expiry value for all SIGEV_NONE timers.
Disarming a timer with timer_settime() and a zero it_value cancels the timer and sets it_status to POSIX_TIMER_DISARMED, but leaves the expiry value unchanged. As a consequence, timer_gettime() on a disarmed SIGEV_NONE timer reports the remaining time of the previous arming until that time has passed, instead of zero as POSIX requires for a disarmed timer. Example with a CLOCK_MONOTONIC timer armed with it_value = 10ms and it_interval = 100ms, then disarmed with an all-zero itimerspec:
armed: it_value = 0.009999000 it_interval = 0.100000000
disarmed: it_value = 0.008700792 it_interval = 0.000000000
SIGEV_SIGNAL timers and SIGEV_NONE CPU timers report zero in the same situation. All clocks which use common_timer_get() are affected, including the alarm timer clocks.
Mark SIGEV_NONE timers as POSIX_TIMER_ARMED when they are armed, so that common_timer_get() returns early for every disarmed timer. Forward SIGEV_NONE interval timers in common_timer_get() regardless of it_status, as they are never queued and therefore never forwarded by the expiry code.
After the change the disarmed timer above reports zero. Armed SIGEV_NONE oneshot and interval timers on CLOCK_MONOTONIC, CLOCK_REALTIME, CLOCK_BOOTTIME and CLOCK_BOOTTIME_ALARM still report their remaining time, and the posix_timers selftest passes.
--- kernel/time/posix-timers.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-)
kernel/time/posix-timers.c +12 -13
@@ -702,16 +702,8 @@ void common_timer_get(struct k_itimer *timr, struct itimerspec64 *cur_setting)if (iv) { cur_setting->it_interval =ktime_to_timespec64 (iv); }else if (timr->it_status ==POSIX_TIMER_DISARMED ) { -/* -* SIGEV_NONE oneshot timers are never queued and therefore -* timr->it_status is always DISARMED. The check below -* vs. remaining time will handle this case. -* -* For all other timers there is nothing to update here, so -* return. -*/ -if (!sig_none) -return ; +/* Nothing to update for a disarmed timer */ +return ; } now = kc->clock_get_ktime (timr->it_clock);
@@ -721,7 +713,7 @@ void common_timer_get(struct k_itimer *timr, struct itimerspec64 *cur_setting)* is a SIGEV_NONE timer move the expiry time forward by intervals, * so expiry is > now. */ -if (iv && timr->it_status !=POSIX_TIMER_ARMED ) +if (iv && (sig_none || timr->it_status !=POSIX_TIMER_ARMED )) timr->it_overrun += kc->timer_forward (timr, now); remaining = kc->timer_remaining (timr, now);
@@ -921,8 +913,15 @@ int common_timer_set(struct k_itimer *timr, int flags, sigev_none = timr->it_sigev_notify ==SIGEV_NONE ;if (kc->timer_arm (timr, expires, flags &TIMER_ABSTIME , sigev_none)) { -if (!sigev_none) - timr->it_status =POSIX_TIMER_ARMED ; +/* +* SIGEV_NONE timers are not queued, but mark them armed +* so that common_timer_get() can tell them apart from +* disarmed timers. An expired SIGEV_NONE timer stays +* armed, which is harmless: common_timer_get() reports +* zero remaining time for it and it never reaches the +* signal delivery code. +*/ + timr->it_status =POSIX_TIMER_ARMED ; }else {/* Timer was already expired, queue the signal */ posix_timer_queue_signal (timr);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 657/686 PCI: imx6: Avoid dereferencing a NULL clock name
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rudi Heitbaum <[email protected]>
[ Upstream commit e60d0d4dfddfac3058753a1c2255251401c92dad ]
of_clk_bulk_get() leaves 'clk_bulk_data->id' as NULL for every clock that has no matching entry in "clock-names", which is legal: a node may list more "clocks" phandles than it names. Both scans of the bulk array dereference that id unconditionally, so such a node oopses during probe.
The loop in imx_pcie_probe() has been wrong since it was written. The loop in imx_setup_phy_mpll() was not: it read a fixed clks[] whose ids came from the driver's own clk_names[] and were never NULL, and only became wrong when the driver moved to the bulk array.
Check 'clk_bulk_data->id' before dereferencing it in both.
--- drivers/pci/controller/dwc/pci-imx6.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/controller/dwc/pci-imx6.c +1 -1
@@ -540,7 +540,7 @@ static int imx_setup_phy_mpll(struct imx_pcie *imx_pcie)return 0 ;for (i =0 ; i < imx_pcie->num_clks; i++) -if (strncmp (clks[i].id,"pcie_phy" ,8 ) ==0 ) +if (clks[i].id &&strncmp (clks[i].id,"pcie_phy" ,8 ) ==0 ) phy_rate =clk_get_rate (clks[i].clk);switch (phy_rate) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 658/686 mm/huge_memory: split huge PUDs when adjusting VMA boundaries
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Hildenbrand (Arm) <[email protected]>
[ Upstream commit 23e570927421d569fdc510d5f3f29542a43eeda5 ]
PFN mappings such as VFIO PCI BAR mappings can use PUD leaves while allowing VMA splits at page granularity. However, vma_adjust_trans_huge() only handles PMDs.
After faulting a writable PUD-sized VFIO BAR mapping, changing its first page to read-only with mprotect() makes the PMD walk treat the PUD leaf as a PMD table. Applying MADV_DONTFORK to the first PMD-sized chunk leaves the PUD spanning two VMAs: the PMD-aligned boundary skips splitting.
Walk the page tables once at each adjusted boundary and split a huge PUD or PMD leaf as needed. Handle PUD leaves even when the boundary is PMD-aligned.
--- mm/huge_memory.c | 70 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 60 insertions(+), 10 deletions(-)
mm/huge_memory.c +60 -10
@@ -3210,16 +3210,66 @@ void split_huge_pmd_address(struct vm_area_struct *vma, unsigned long address,__split_huge_pmd (vma, pmd, address, freeze); } -static inline void split_huge_pmd_if_needed (struct vm_area_struct *vma,unsigned long address) +static bool pud_split_required (const struct vm_area_struct *vma, +unsigned long address) { +if (!IS_ENABLED (CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD )) +return false; +if (IS_ALIGNED (address,HPAGE_PUD_SIZE )) +return false;/* -* If the new address isn't hpage aligned and it could previously -* contain an hugepage: check if we need to split an huge pmd. +* Only selected VMAs support mapping PUDs for now. Lift the +* restriction once this changes. */ -if (!IS_ALIGNED (address,HPAGE_PMD_SIZE ) && -range_in_vma (vma,ALIGN_DOWN (address,HPAGE_PMD_SIZE ), -ALIGN (address,HPAGE_PMD_SIZE ))) -split_huge_pmd_address (vma, address, false); +if (!vma_is_dax (vma) && !(vma->vm_flags & (VM_PFNMAP |VM_MIXEDMAP ))) +return false; +return range_in_vma (vma,ALIGN_DOWN (address,HPAGE_PUD_SIZE ), +ALIGN (address,HPAGE_PUD_SIZE )); +} + +static bool pmd_split_required (const struct vm_area_struct *vma, +unsigned long address) +{ +if (IS_ALIGNED (address,HPAGE_PMD_SIZE )) +return false; + +return range_in_vma (vma,ALIGN_DOWN (address,HPAGE_PMD_SIZE ), +ALIGN (address,HPAGE_PMD_SIZE )); +} + +static void split_huge_leaf (struct vm_area_struct *vma, +unsigned long address) +{ +const bool split_pud =pud_split_required (vma, address); +const bool split_pmd =pmd_split_required (vma, address); +pgd_t *pgd; +p4d_t *p4d; +pud_t *pud; +pmd_t *pmd; + +/* +* mmap, VMA and rmap write locks protect the walk; the split helpers +* take the page table locks. +*/ +if (!split_pud && !split_pmd) +return ; + + pgd =pgd_offset (vma->vm_mm, address); +if (!pgd_present (*pgd)) +return ; + + p4d =p4d_offset (pgd, address); +if (!p4d_present (*p4d)) +return ; + + pud =pud_offset (p4d, address); +if (pud_leaf (*pud)) +__split_huge_pud (vma, pud, address); +if (!split_pmd || !pud_present (*pud)) +return ; + + pmd =pmd_offset (pud, address); +__split_huge_pmd (vma, pmd, address, false); } void vma_adjust_trans_huge(struct vm_area_struct *vma,
@@ -3228,14 +3278,14 @@ void vma_adjust_trans_huge(struct vm_area_struct *vma, struct vm_area_struct *next) {/* Check if we need to split start first. */ -split_huge_pmd_if_needed (vma, start); +split_huge_leaf (vma, start);/* Check if we need to split end next. */ -split_huge_pmd_if_needed (vma, end); +split_huge_leaf (vma, end);/* If we're incrementing next->vm_start, we might need to split it. */ if (next) -split_huge_pmd_if_needed (next, end); +split_huge_leaf (next, end); }static void unmap_folio (struct folio *folio)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 659/686 PCI: dwc: Set DMA_BYPASS bit in outbound IATU CTRL2 register
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sumit Kumar <[email protected]>
[ Upstream commit efadda401c5c8e2390ba66508eba154dbd0db5a9 ]
An outbound iATU region matches any local (AXI/application-side) address that falls within its Base/Limit window and rewrites it to the PCIe-side address programmed in that region's Target Address Registers before the transaction goes out on the link. This matching does not distinguish CPU-initiated transactions from ones issued by the internal DMA engine (eDMA/HDMA).
Example: outbound region 0 is programmed with Base/Limit covering local addresses 0x8000_0000-0x8000_0FFF and Target 0x1_0000_0000, for CPU-initiated accesses. The DMA engine is later given a descriptor whose destination is the host address 0x8000_0080, which happens to fall inside region 0's Base/Limit range. The iATU matches the DMA transaction against region 0 too and rewrites it to 0x1_0000_0080 instead of passing 0x8000_0080 through unchanged. The transaction then lands on the wrong host address, causing data corruption or an IOMMU fault when the rewritten address has no valid mapping.
Set the DMA_BYPASS bit (bit 27) in PCIE_ATU_REGION_CTRL2 when programming outbound iATU regions so only CPU/AXI-initiated transactions are matched against the region; DMA engine transactions bypass the translation and go out on the PCIe link with their original address.
--- drivers/pci/controller/dwc/pcie-designware.c | 2 ++ drivers/pci/controller/dwc/pcie-designware.h | 1 + 2 files changed, 3 insertions(+)
drivers/pci/controller/dwc/pcie-designware.c +2 -0
@@ -568,6 +568,8 @@ int dw_pcie_prog_outbound_atu(struct dw_pcie *pci,/* The data-less messages only for now */ val |=PCIE_ATU_INHIBIT_PAYLOAD | atu->code; } + if (dw_pcie_ver_is_ge(pci, 460A)) + val |=PCIE_ATU_DMA_BYPASS ;dw_pcie_writel_atu_ob (pci, atu->index,PCIE_ATU_REGION_CTRL2 , val);/*
drivers/pci/controller/dwc/pcie-designware.h +1 -0
@@ -173,6 +173,7 @@#define PCIE_ATU_ENABLE BIT(31)#define PCIE_ATU_BAR_MODE_ENABLE BIT(30)#define PCIE_ATU_CFG_SHIFT_MODE_ENABLE BIT(28) +#define PCIE_ATU_DMA_BYPASS BIT(27)#define PCIE_ATU_INHIBIT_PAYLOAD BIT(22)#define PCIE_ATU_FUNC_NUM_MATCH_EN BIT(19)#define PCIE_ATU_LOWER_BASE 0x008
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 660/686 clk: nuvoton: ma35d1: Keep the clock count in the driver
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miquel Raynal <[email protected]>
[ Upstream commit 26ec588063d9b6c70773b8729372e2bf6d3ea95a ]
The number of clocks is not a binding since this is a value that can change. As such, in order to support the missing watchdog clocks and allow the deprecation and removal of CLK_MAX_IDX from the bindings, we need to switch to a local definition first.
Stable-dep-of: 1dc3871ce7ec ("clk: nuvoton: ma35d1: Add missing WDT/WWDT parent clocks")
--- drivers/clk/nuvoton/clk-ma35d1.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/clk/nuvoton/clk-ma35d1.c +3 -2
@@ -17,6 +17,7 @@static DEFINE_SPINLOCK (ma35d1_lock);#define PLL_MAX_NUM 5 +#define MA35D1_CLK_COUNT 236/* Clock Control Registers Offset */ #define REG_CLK_PWRCTL 0x00
@@ -467,12 +468,12 @@ static int ma35d1_clocks_probe(struct platform_device *pdev)int ret; ma35d1_hw_data =devm_kzalloc (dev, -struct_size (ma35d1_hw_data, hws,CLK_MAX_IDX ), +struct_size (ma35d1_hw_data, hws,MA35D1_CLK_COUNT ),GFP_KERNEL );if (!ma35d1_hw_data)return -ENOMEM ; - ma35d1_hw_data->num =CLK_MAX_IDX ; + ma35d1_hw_data->num =MA35D1_CLK_COUNT ; hws = ma35d1_hw_data->hws; clk_base =devm_platform_ioremap_resource (pdev,0 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 661/686 dt-bindings: clock: ma35d1: Drop CLK_MAX_IDX define
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miquel Raynal <[email protected]>
[ Upstream commit 653738db38c7c7f0fb959a7870f9461cf4987825 ]
Drop CLK_MAX_IDX define of MA35D1 include. This is not a binding and should not be placed here. Value is defined in the user driver.
Stable-dep-of: 1dc3871ce7ec ("clk: nuvoton: ma35d1: Add missing WDT/WWDT parent clocks")
--- include/dt-bindings/clock/nuvoton,ma35d1-clk.h | 1 - 1 file changed, 1 deletion(-)
include/dt-bindings/clock/nuvoton,ma35d1-clk.h +0 -1
@@ -248,6 +248,5 @@#define ADC_GATE 233#define EADC_DIV 234#define EADC_GATE 235 -#define CLK_MAX_IDX 236#endif /* __DT_BINDINGS_CLOCK_NUVOTON_MA35D1_CLK_H */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 662/686 dt-bindings: clock: ma35d1: Add missing WDT/WWDT parent clocks
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miquel Raynal <[email protected]>
[ Upstream commit 8c7453cb0b01bee47ec2f902a9ac1872d3b77f3d ]
The WDT and WWDT muxes have PCLK3/4096 and PCLK4/4096 among their possible parents, but these fixed factor clocks are currently not defined, even though they are needed to properly describe the clock tree. Add them to the bindings.
Stable-dep-of: 1dc3871ce7ec ("clk: nuvoton: ma35d1: Add missing WDT/WWDT parent clocks")
--- include/dt-bindings/clock/nuvoton,ma35d1-clk.h | 2 ++ 1 file changed, 2 insertions(+)
include/dt-bindings/clock/nuvoton,ma35d1-clk.h +2 -0
@@ -248,5 +248,7 @@#define ADC_GATE 233#define EADC_DIV 234#define EADC_GATE 235 +#define PCLK3_DIV4096 236 +#define PCLK4_DIV4096 237#endif /* __DT_BINDINGS_CLOCK_NUVOTON_MA35D1_CLK_H */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 663/686 clk: nuvoton: ma35d1: Add missing WDT/WWDT parent clocks
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miquel Raynal <[email protected]>
[ Upstream commit 1dc3871ce7ec819030c22297f8960c61cc42a990 ]
The WDT and WWDT muxes list PCLK3/4096 and PCLK4/4096 among their possible parents, but the driver never registers the corresponding clocks, so these parents could never be used.
Add pclk3_div4096 and pclk4_div4096 as fixed factor children of pclk3 and pclk4 and expose them through the clock provider.
--- drivers/clk/nuvoton/clk-ma35d1.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/clk/nuvoton/clk-ma35d1.c +3 -1
@@ -17,7 +17,7 @@static DEFINE_SPINLOCK (ma35d1_lock);#define PLL_MAX_NUM 5 -#define MA35D1_CLK_COUNT 236 +#define MA35D1_CLK_COUNT 238/* Clock Control Registers Offset */ #define REG_CLK_PWRCTL 0x00
@@ -544,6 +544,8 @@ static int ma35d1_clocks_probe(struct platform_device *pdev) hws[HCLK3 ] =ma35d1_clk_fixed_factor (dev,"hclk3" ,"sysclk1_mux" ,1 ,2 ); hws[PCLK3 ] =ma35d1_clk_fixed_factor (dev,"pclk3" ,"sysclk1_mux" ,1 ,2 ); hws[PCLK4 ] =ma35d1_clk_fixed_factor (dev,"pclk4" ,"sysclk1_mux" ,1 ,2 ); + hws[PCLK3_DIV4096 ] =ma35d1_clk_fixed_factor (dev,"pclk3_div4096" ,"pclk3" ,1 ,4096 ); + hws[PCLK4_DIV4096 ] =ma35d1_clk_fixed_factor (dev,"pclk4_div4096" ,"pclk4" ,1 ,4096 ); hws[USBPHY0 ] =ma35d1_clk_fixed ("usbphy0" ,480000000 ); hws[USBPHY1 ] =ma35d1_clk_fixed ("usbphy1" ,480000000 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 664/686 f2fs: release a removed xattr node in roll-forward recovery
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daeho Jeong <[email protected]>
[ Upstream commit f5924de8867c09206ba631b9faed63862ec00a10 ]
When xattrs shrink enough to fit in the inline xattr area, write_all_xattrs() truncates the xattr node and clears i_xattr_nid. If the file is then fsynced without a checkpoint, only the inode block is written, with i_xattr_nid of 0.
Roll-forward recovery starts from the checkpointed inode, whose i_xattr_nid still points to the old xattr node. f2fs_recover_inline_xattr() copies only the inline xattr area, and f2fs_update_inode() writes the old i_xattr_nid back. So the inode keeps the stale xattr node:
- The node block is never released, and fsck reports "nonzero bytes in xattr space after end of list".
- If the inline xattr list ends exactly at the end of the inline area, its terminator is read from the stale node, and the removed xattrs come back after recovery.
When the fsynced inode has no xattr node but the checkpointed one has, release the old xattr node as truncate_node() does: check its block address, invalidate the block and drop its node cache, which may still be dirty.
--- fs/f2fs/node.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)
fs/f2fs/node.c +39 -0
@@ -2851,6 +2851,45 @@ int f2fs_recover_inline_xattr(struct inode *inode, struct folio *folio)f2fs_folio_wait_writeback (ifolio,NODE , true, true);memcpy (dst_addr, src_addr, inline_size); update_inode: +/* +* The xattr node of the checkpoint was removed before fsync, e.g. the +* xattrs became small enough to fit inline. Release it as well, or +* the inode keeps pointing to the stale xattrs. +*/ +if (!ri->i_xattr_nid &&F2FS_I (inode)->i_xattr_nid) { +struct f2fs_sb_info *sbi =F2FS_I_SB (inode); +struct node_info ni; +int err; + + err =f2fs_get_node_info (sbi,F2FS_I (inode)->i_xattr_nid, + &ni, false); +if (err) { +f2fs_folio_put (ifolio, true); +return err; + } + +if (ni.blk_addr !=NEW_ADDR && + !f2fs_is_valid_blkaddr (sbi, ni.blk_addr, +DATA_GENERIC_ENHANCE )) { +f2fs_err_ratelimited (sbi, +"nat entry is corrupted, run fsck to fix it, ino:%u, nid:%u, blkaddr:%u" , + ni.ino, ni.nid, ni.blk_addr); +set_sbi_flag (sbi,SBI_NEED_FSCK ); +f2fs_handle_error (sbi,ERROR_INCONSISTENT_NAT ); +f2fs_folio_put (ifolio, true); +return -EFSCORRUPTED ; + } + +f2fs_invalidate_blocks (sbi, ni.blk_addr,1 ); +dec_valid_node_count (sbi, inode, false); +set_node_addr (sbi, &ni,NULL_ADDR , false); +/* drop the cached xattr node, which may be dirty */ +truncate_inode_pages_range (NODE_MAPPING (sbi), +F2FS_BLK_TO_BYTES ((loff_t )ni.nid), +F2FS_BLK_END_BYTES ((loff_t )ni.nid)); +f2fs_i_xnid_write (inode,0 ); + } +f2fs_update_inode (inode, ifolio);f2fs_folio_put (ifolio, true);return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 665/686 media: ipu6: Rename pointer to firmware context
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Antti Laakso <[email protected]>
[ Upstream commit ac1a76fdf7e1815445c76d90ef688eff85cbb012 ]
The name fwcom is used to refer firmware communication context and firmware communication configuration. Try to avoid confusion and rename context variable.
Stable-dep-of: d3d9bc694fe0 ("media: ipu6: Fix firmware config leak on stream start")
--- drivers/media/pci/intel/ipu6/ipu6-fw-isys.c | 56 ++++++++++--------- .../media/pci/intel/ipu6/ipu6-isys-video.c | 4 +- drivers/media/pci/intel/ipu6/ipu6-isys.c | 6 +- drivers/media/pci/intel/ipu6/ipu6-isys.h | 5 +- 4 files changed, 36 insertions(+), 35 deletions(-)
drivers/media/pci/intel/ipu6/ipu6-fw-isys.c +29 -27
@@ -32,7 +32,7 @@ static int handle_proxy_response(struct ipu6_isys *isys, unsigned int req_id)struct ipu6_fw_isys_proxy_resp_info_abi *resp;int ret; - resp =ipu6_recv_get_token (isys->fwcom,IPU6_BASE_PROXY_RECV_QUEUES ); + resp =ipu6_recv_get_token (isys->fwctx,IPU6_BASE_PROXY_RECV_QUEUES );if (!resp)return 1 ;
@@ -42,7 +42,7 @@ static int handle_proxy_response(struct ipu6_isys *isys, unsigned int req_id) ret = req_id == resp->request_id ?0 : -EIO ; -ipu6_recv_put_token (isys->fwcom,IPU6_BASE_PROXY_RECV_QUEUES ); +ipu6_recv_put_token (isys->fwctx,IPU6_BASE_PROXY_RECV_QUEUES );return ret; }
@@ -52,7 +52,7 @@ int ipu6_fw_isys_send_proxy_token(struct ipu6_isys *isys,unsigned int index, unsigned int offset, u32 value) { - struct ipu6_fw_com_context *ctx = isys->fwcom; + struct ipu6_fw_com_context *ctx = isys->fwctx;struct device *dev = &isys->adev->auxdev.dev;struct ipu6_fw_proxy_send_queue_token *token;unsigned int timeout =1000 ;
@@ -96,7 +96,7 @@ int ipu6_fw_isys_complex_cmd(struct ipu6_isys *isys,dma_addr_t dma_mapped_buf, size_t size, u16 send_type) { - struct ipu6_fw_com_context *ctx = isys->fwcom; + struct ipu6_fw_com_context *ctx = isys->fwctx;struct device *dev = &isys->adev->auxdev.dev;struct ipu6_fw_send_queue_token *token;
@@ -138,7 +138,7 @@ int ipu6_fw_isys_close(struct ipu6_isys *isys)struct device *dev = &isys->adev->auxdev.dev;int retry =IPU6_ISYS_CLOSE_RETRY ;unsigned long flags; -void *fwcom; +void *fwctx;int ret;/*
@@ -148,9 +148,9 @@ int ipu6_fw_isys_close(struct ipu6_isys *isys)* spinlock to wait the interrupt handler to be finished */ spin_lock_irqsave (&isys->power_lock, flags); - ret =ipu6_fw_com_close (isys->fwcom); - fwcom = isys->fwcom; - isys->fwcom =NULL ; + ret =ipu6_fw_com_close (isys->fwctx); + fwctx = isys->fwctx; + isys->fwctx =NULL ;spin_unlock_irqrestore (&isys->power_lock, flags);if (ret)dev_err (dev,"Device close failure: %d\n" , ret);
@@ -158,14 +158,14 @@ int ipu6_fw_isys_close(struct ipu6_isys *isys)/* release probably fails if the close failed. Let's try still */ do {usleep_range (400 ,500 ); - ret =ipu6_fw_com_release (fwcom,0 ); + ret =ipu6_fw_com_release (fwctx,0 ); retry--; }while (ret && retry);if (ret) {dev_err (dev,"Device release time out %d\n" , ret);spin_lock_irqsave (&isys->power_lock, flags); - isys->fwcom = fwcom; + isys->fwctx = fwctx;spin_unlock_irqrestore (&isys->power_lock, flags); }
@@ -176,11 +176,11 @@ void ipu6_fw_isys_cleanup(struct ipu6_isys *isys) {int ret; - ret =ipu6_fw_com_release (isys->fwcom,1 ); + ret =ipu6_fw_com_release (isys->fwctx,1 );if (ret <0 )dev_warn (&isys->adev->auxdev.dev,"Device busy, fw_com release failed." ); - isys->fwcom =NULL ; + isys->fwctx =NULL ; }static void start_sp (struct ipu6_bus_device *adev)
@@ -212,7 +212,7 @@ static int query_sp(struct ipu6_bus_device *adev) }static int ipu6_isys_fwcom_cfg_init (struct ipu6_isys *isys, -struct ipu6_fw_com_cfg *fwcom, +struct ipu6_fw_com_cfg *fwcom_cfg,unsigned int num_streams) {unsigned int max_send_queues, max_sram_blocks, max_devq_size;
@@ -258,14 +258,16 @@ static int ipu6_isys_fwcom_cfg_init(struct ipu6_isys *isys,if (!output_queue_cfg)return -ENOMEM ; - fwcom->input = input_queue_cfg; - fwcom->output = output_queue_cfg; + fwcom_cfg->input = input_queue_cfg; + fwcom_cfg->output = output_queue_cfg; - fwcom->num_input_queues = isys_fw_cfg->num_send_queues[type_proxy] + + fwcom_cfg->num_input_queues = + isys_fw_cfg->num_send_queues[type_proxy] + isys_fw_cfg->num_send_queues[type_dev] + isys_fw_cfg->num_send_queues[type_msg]; - fwcom->num_output_queues = isys_fw_cfg->num_recv_queues[type_proxy] + + fwcom_cfg->num_output_queues = + isys_fw_cfg->num_recv_queues[type_proxy] + isys_fw_cfg->num_recv_queues[type_dev] + isys_fw_cfg->num_recv_queues[type_msg];
@@ -280,7 +282,7 @@ static int ipu6_isys_fwcom_cfg_init(struct ipu6_isys *isys, isys_fw_cfg->buffer_partition.num_gda_pages[i] =0 ; } -/* FW assumes proxy interface at fwcom queue 0 */ +/* FW assumes proxy interface at fwcom_cfg queue 0 */ for (i =0 ; i < isys_fw_cfg->num_send_queues[type_proxy]; i++) { input_queue_cfg[i].token_size =sizeof (struct ipu6_fw_proxy_send_queue_token );
@@ -314,9 +316,9 @@ static int ipu6_isys_fwcom_cfg_init(struct ipu6_isys *isys,IPU6_ISYS_SIZE_RECV_QUEUE ; } - fwcom->dmem_addr = isys->pdata->ipdata->hw_variant.dmem_offset; - fwcom->specific_addr = isys_fw_cfg; - fwcom->specific_size =sizeof (*isys_fw_cfg); + fwcom_cfg->dmem_addr = isys->pdata->ipdata->hw_variant.dmem_offset; + fwcom_cfg->specific_addr = isys_fw_cfg; + fwcom_cfg->specific_size =sizeof (*isys_fw_cfg);return 0 ; }
@@ -325,23 +327,23 @@ int ipu6_fw_isys_init(struct ipu6_isys *isys, unsigned int num_streams) {struct device *dev = &isys->adev->auxdev.dev;int retry =IPU6_ISYS_OPEN_RETRY ; -struct ipu6_fw_com_cfg fwcom = { +struct ipu6_fw_com_cfg fwcom_cfg = { .cell_start = start_sp, .cell_ready = query_sp, .buttress_boot_offset =SYSCOM_BUTTRESS_FW_PARAMS_ISYS_OFFSET , };int ret; -ipu6_isys_fwcom_cfg_init (isys, &fwcom, num_streams); +ipu6_isys_fwcom_cfg_init (isys, &fwcom_cfg, num_streams); - isys->fwcom =ipu6_fw_com_prepare (&fwcom, isys->adev, + isys->fwctx =ipu6_fw_com_prepare (&fwcom_cfg, isys->adev, isys->pdata->base); -if (!isys->fwcom) { +if (!isys->fwctx) {dev_err (dev,"isys fw com prepare failed\n" );return -EIO ; } - ret =ipu6_fw_com_open (isys->fwcom); + ret =ipu6_fw_com_open (isys->fwctx);if (ret) {dev_err (dev,"isys fw com open failed %d\n" , ret);return ret;
@@ -349,7 +351,7 @@ int ipu6_fw_isys_init(struct ipu6_isys *isys, unsigned int num_streams)do {usleep_range (400 ,500 ); -if (ipu6_fw_com_ready (isys->fwcom)) +if (ipu6_fw_com_ready (isys->fwctx))break ; retry--; }while (retry >0 );
drivers/media/pci/intel/ipu6/ipu6-isys-video.c +2 -2
@@ -1116,7 +1116,7 @@ int ipu6_isys_fw_open(struct ipu6_isys *isys)*/ ipu6_cleanup_fw_msg_bufs (isys); -if (isys->fwcom) { +if (isys->fwctx) {/* * Something went wrong in previous shutdown. As we are now * restarting isys we can safely delete old context.
@@ -1149,7 +1149,7 @@ void ipu6_isys_fw_close(struct ipu6_isys *isys) isys->ref_count--;if (!isys->ref_count) {ipu6_fw_isys_close (isys); -if (isys->fwcom) { +if (isys->fwctx) { isys->need_reset = true;dev_warn (&isys->adev->auxdev.dev,"failed to close fw isys\n" );
drivers/media/pci/intel/ipu6/ipu6-isys.c +3 -3
@@ -1227,10 +1227,10 @@ static int isys_isr_one(struct ipu6_bus_device *adev)u32 index;u64 ts; -if (!isys->fwcom) +if (!isys->fwctx)return 1 ; - resp =ipu6_fw_isys_get_resp (isys->fwcom,IPU6_BASE_MSG_RECV_QUEUES ); + resp =ipu6_fw_isys_get_resp (isys->fwctx,IPU6_BASE_MSG_RECV_QUEUES );if (!resp)return 1 ;
@@ -1339,7 +1339,7 @@ static int isys_isr_one(struct ipu6_bus_device *adev)ipu6_isys_put_stream (stream); leave: -ipu6_fw_isys_put_resp (isys->fwcom,IPU6_BASE_MSG_RECV_QUEUES ); +ipu6_fw_isys_put_resp (isys->fwctx,IPU6_BASE_MSG_RECV_QUEUES );return 0 ; }
drivers/media/pci/intel/ipu6/ipu6-isys.h +2 -3
@@ -114,8 +114,7 @@ struct sensor_async_sd {* @csi2_rx_ctrl_cached: cached shared value between all CSI2 receivers * @streams_lock: serialise access to streams * @streams: streams per firmware stream ID -* @fwcom: fw communication layer private pointer -* or optional external library private pointer +* @fwctx: fw communication layer context pointer * @phy_termcal_val: the termination calibration value, only used for DWC PHY * @need_reset: Isys requires d0i0->i3 transition * @ref_count: total number of callers fw open
@@ -136,7 +135,7 @@ struct ipu6_isys {spinlock_t streams_lock;struct ipu6_isys_stream streams[IPU6_ISYS_MAX_STREAMS ];int streams_ref_count[IPU6_ISYS_MAX_STREAMS ]; -void *fwcom; +void *fwctx;u32 phy_termcal_val;bool need_reset;bool icache_prefetch;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 666/686 media: ipu6: Fix firmware config leak on stream start
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Carlier <[email protected]>
[ Upstream commit d3d9bc694fe087c672c3ad5871984dc45cd9f425 ]
ipu6_isys_fwcom_cfg_init() runs on every first stream start and allocates the firmware config and queue configs with devm, so each STREAMON/STREAMOFF cycle leaks them. They are only needed until ipu6_fw_com_prepare() has copied them, so free them right after. Also check the return value, an allocation failure would otherwise make ipu6_fw_com_prepare() dereference a NULL queue config.
--- drivers/media/pci/intel/ipu6/ipu6-fw-isys.c | 34 +++++++++++++++------ 1 file changed, 24 insertions(+), 10 deletions(-)
drivers/media/pci/intel/ipu6/ipu6-fw-isys.c +24 -10
@@ -218,7 +218,6 @@ static int ipu6_isys_fwcom_cfg_init(struct ipu6_isys *isys,unsigned int max_send_queues, max_sram_blocks, max_devq_size;struct ipu6_fw_syscom_queue_config *input_queue_cfg;struct ipu6_fw_syscom_queue_config *output_queue_cfg; -struct device *dev = &isys->adev->auxdev.dev;int type_proxy =IPU6_FW_ISYS_QUEUE_TYPE_PROXY ;int type_dev =IPU6_FW_ISYS_QUEUE_TYPE_DEV ;int type_msg =IPU6_FW_ISYS_QUEUE_TYPE_MSG ;
@@ -228,7 +227,6 @@ static int ipu6_isys_fwcom_cfg_init(struct ipu6_isys *isys,struct ipu6_fw_isys_fw_config *isys_fw_cfg;u32 num_in_message_queues;unsigned int max_streams; -unsigned int size;unsigned int i; max_streams = isys->pdata->ipdata->max_streams;
@@ -236,7 +234,7 @@ static int ipu6_isys_fwcom_cfg_init(struct ipu6_isys *isys, max_sram_blocks = isys->pdata->ipdata->max_sram_blocks; max_devq_size = isys->pdata->ipdata->max_devq_size; num_in_message_queues =clamp (num_streams,1U , max_streams); - isys_fw_cfg =devm_kzalloc (dev,sizeof (*isys_fw_cfg),GFP_KERNEL ); + isys_fw_cfg =kzalloc_obj (*isys_fw_cfg);if (!isys_fw_cfg)return -ENOMEM ;
@@ -248,15 +246,14 @@ static int ipu6_isys_fwcom_cfg_init(struct ipu6_isys *isys, isys_fw_cfg->num_recv_queues[type_dev] =0 ; isys_fw_cfg->num_recv_queues[type_msg] =1 ; - size =sizeof (*input_queue_cfg) * max_send_queues; - input_queue_cfg =devm_kzalloc (dev, size,GFP_KERNEL ); + input_queue_cfg =kzalloc_objs (*input_queue_cfg, max_send_queues);if (!input_queue_cfg) -return -ENOMEM ; + goto err_free_fw_cfg; - size =sizeof (*output_queue_cfg) *IPU6_N_MAX_RECV_QUEUES ; - output_queue_cfg =devm_kzalloc (dev, size,GFP_KERNEL ); + output_queue_cfg =kzalloc_objs (*output_queue_cfg, +IPU6_N_MAX_RECV_QUEUES );if (!output_queue_cfg) -return -ENOMEM ; + goto err_free_input_queue_cfg; fwcom_cfg->input = input_queue_cfg; fwcom_cfg->output = output_queue_cfg;
@@ -321,6 +318,20 @@ static int ipu6_isys_fwcom_cfg_init(struct ipu6_isys *isys, fwcom_cfg->specific_size =sizeof (*isys_fw_cfg);return 0 ; + +err_free_input_queue_cfg: +kfree (input_queue_cfg); +err_free_fw_cfg: +kfree (isys_fw_cfg); + +return -ENOMEM ; +} + +static void ipu6_isys_fwcom_cfg_free (struct ipu6_fw_com_cfg *fwcom_cfg) +{ +kfree (fwcom_cfg->specific_addr); +kfree (fwcom_cfg->output); +kfree (fwcom_cfg->input); }int ipu6_fw_isys_init (struct ipu6_isys *isys,unsigned int num_streams)
@@ -334,10 +345,13 @@ int ipu6_fw_isys_init(struct ipu6_isys *isys, unsigned int num_streams) };int ret; -ipu6_isys_fwcom_cfg_init (isys, &fwcom_cfg, num_streams); + ret =ipu6_isys_fwcom_cfg_init (isys, &fwcom_cfg, num_streams); +if (ret) +return ret; isys->fwctx =ipu6_fw_com_prepare (&fwcom_cfg, isys->adev, isys->pdata->base); +ipu6_isys_fwcom_cfg_free (&fwcom_cfg);if (!isys->fwctx) {dev_err (dev,"isys fw com prepare failed\n" );return -EIO ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 667/686 mm/vma: avoid broken uffd merge on mremap
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lorenzo Stoakes (ARM) <[email protected]>
[ Upstream commit 68cb098eadda190783f8f8bdf9fe764df59f7d32 ]
Userfaultfd often causes unexpected interactions within mm, and does so at the intersection of uffd, mremap() and VMA merging.
When an mremap of a VMA occurs, copy_vma_and_data() calls mremap_userfaultfd_prep() to notify uffd of this.
However, mremap_userfaultfd_prep() simply drops the UFFD context for the VMA if the user did not register it for remap, i.e. didn't specify the UFFD_FEATURE_EVENT_REMAP flag.
This is OK for the VMA itself, as upon page table move, move_ptes() clears UFFD page table flags, using vma_has_uffd_without_event_remap() to determine whether to do so.
However, this doesn't account for merging with adjacent VMAs, whose page tables won't have received this treatment, and thus latent UFFD markers will be left around.
Worse, it'll break UFFD for any VMAs it is merged with. This is very surprising behaviour for a user, who will then simply not receive UFFD events for VMAs they ought to.
Resolve the issue by explicitly checking for this case via vma_has_uffd_without_event_remap() in vma_merge_copied_range(), the merge function explicitly designated for mremap() operations.
Also update the userland VMA tests accordingly.
--- mm/vma.c | 5 +++++ tools/testing/vma/vma_internal.h | 2 ++ 2 files changed, 7 insertions(+)
mm/vma.c +5 -0
@@ -1145,6 +1145,11 @@ static struct vm_area_struct *vma_merge_copied_range(struct vma_merge_struct *vm vmg->copied_from = vmg->middle; vmg->middle =NULL ; + +/* If not registered for remap, uffd context will be cleared. */ +if (vma_has_uffd_without_event_remap (vmg->copied_from)) +return NULL ; +return vma_merge_new_range (vmg); }
tools/testing/vma/vma_internal.h +2 -0
@@ -802,6 +802,8 @@ static inline bool is_mergeable_vm_userfaultfd_ctx(struct vm_area_struct *vma,return true; } +#define vma_has_uffd_without_event_remap (vma) false +static inline bool anon_vma_name_eq (struct anon_vma_name *anon_name1,struct anon_vma_name *anon_name2) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 668/686 iommufd/iova_bitmap: Ensure that iova_bitmap_set() handles the full IOVA
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrea Parri <[email protected]>
[ Upstream commit e21952d72b4740f08a272d694cca223b6b0099ca ]
Generally userspace is going to step the dirty bitmap through the IOVA space. However if the bitmap ends in the middle of a large PTE this is problematic. The first step will clear the dirty bit and report dirty to the end of its bitmap while the second step will see the clear'd dirty and report clean for the start of the bitmap. If it happens this ends up losing dirties.
Further this function is missing bounds checking so if this does happen ther is a good chance it will write memory beyond what the userspace was expecting.
Return an error code if this illegal condition happens.
--- drivers/iommu/iommufd/io_pagetable.c | 2 +- drivers/iommu/iommufd/iova_bitmap.c | 18 +++++++++++++++++- include/uapi/linux/iommufd.h | 6 ++++++ 3 files changed, 24 insertions(+), 2 deletions(-)
drivers/iommu/iommufd/io_pagetable.c +1 -1
@@ -552,7 +552,7 @@ iommu_read_and_clear_dirty(struct iommu_domain *domain, arg.iopt = iopt; arg.domain = domain; arg.dirty = &dirty; -iova_bitmap_for_each (iter, &arg, __iommu_read_and_clear_dirty); + ret =iova_bitmap_for_each (iter, &arg, __iommu_read_and_clear_dirty);if (!(flags &IOMMU_DIRTY_NO_CLEAR ))iommu_iotlb_sync (domain, &gather);
drivers/iommu/iommufd/iova_bitmap.c +17 -1
@@ -116,6 +116,8 @@ struct iova_bitmap {/* length of the IOVA range for the whole bitmap */ size_t length; + +int err; };/*
@@ -384,7 +386,9 @@ static int iova_bitmap_advance_to(struct iova_bitmap *bitmap,int iova_bitmap_for_each (struct iova_bitmap *bitmap,void *opaque,iova_bitmap_fn_t fn) { -return fn (bitmap, bitmap->iova, bitmap->length, opaque); +int ret =fn (bitmap, bitmap->iova, bitmap->length, opaque); + +return ret ? ret : bitmap->err; }EXPORT_SYMBOL_NS_GPL (iova_bitmap_for_each,"IOMMUFD" );
@@ -404,6 +408,18 @@ void iova_bitmap_set(struct iova_bitmap *bitmap,struct iova_bitmap_map *mapped = &bitmap->mapped;unsigned long cur_bit, last_bit, last_page_idx; +/* +* If the range cannot be recorded then the system call returns failure. +* This is to prevent loosing dirties if userspace is expecting to step +* the bitmap through the IOVA space. +*/ +if (!length || length > bitmap->length || iova < bitmap->iova || + iova - bitmap->iova > bitmap->length - length) { +if (!bitmap->err) + bitmap->err = -EPROTO ; +return ; + } + update_indexes:if (unlikely (!iova_bitmap_mapped_range (mapped, iova, length))) {/*
include/uapi/linux/iommufd.h +6 -0
@@ -775,6 +775,12 @@ enum iommufd_hwpt_get_dirty_bitmap_flags {* Walk the IOMMU pagetables for a given IOVA range to return a bitmap * with the dirty IOVAs. In doing so it will also by default clear any * dirty bit metadata set in the IOPTE. +* +* The IOVA range given must fully enclose any IOPTE. If the range starts or +* ends inside a dirty IOPTE then the ioctl will fail. This avoids partially +* reporting a dirty range. +* +* On failure the dirty state becomes unknown and the userspace must restart. */ struct iommu_hwpt_get_dirty_bitmap {__u32 size;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 669/686 hwmon: (coretemp) Return -ENODATA for invalid temperature readings
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ricardo Neri <[email protected]>
[ Upstream commit f63aaa529cbc73146ff0d52235e5479042285cae ]
IA32_THERM_STATUS and IA32_PACKAGE_THERM_STATUS have a valid bit, bit 31. The Intel SDM documents it only for the former, but the package register implements it too: x86_pkg_temp_thermal has required it since commit f1a18a105660 ("Thermal: CPU Package temperature thermal").
This driver checked the bit for both registers as well, until commit bf6ea084ebb5 ("hwmon: (coretemp) Do not return -EAGAIN for low temperatures") made it ignore the bit because some CPUs clear it while the temperature is too low to be measured. Since then, temp%d_input reports such a reading as a real temperature. Userspace cannot tell it apart from a genuinely low one.
Fail the read with -ENODATA while the CPU reports the reading as invalid. On a CPU that clears the bit, reading temp%d_input now fails where it used to return a low value. sensors(1) shows N/A in its place.
--- Documentation/hwmon/coretemp.rst | 3 +++ drivers/hwmon/coretemp.c | 21 +++++++++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-)
Documentation/hwmon/coretemp.rst +3 -0
@@ -47,6 +47,9 @@ All Sysfs entries are named with their core_id (represented here by 'X'). ================= ======================================================== tempX_input Core temperature (in millidegrees Celsius). + Reading fails with -ENODATA while the CPU reports the + temperature as invalid. Some CPUs do this when the + temperature is too low to be measured. tempX_max All cooling devices should be turned on (on Core2). tempX_crit Maximum junction temperature (in millidegrees Celsius). tempX_crit_alarm Set when Out-of-spec bit is set, never clears.
drivers/hwmon/coretemp.c +15 -6
@@ -61,6 +61,8 @@ enum coretemp_attr_index {/* * Per-Core Temperature Data +* @temp_valid: Whether the CPU reported @temp as valid. @temp is not +* reported when this is false. * @tjmax: The static tjmax value when tjmax cannot be retrieved from * IA32_TEMPERATURE_TARGET MSR. * @last_updated: The time when the current temperature value was updated
@@ -73,6 +75,7 @@ enum coretemp_attr_index {*/ struct temp_data {int temp; +bool temp_valid;int tjmax;unsigned long last_updated;unsigned int cpu;
@@ -391,7 +394,8 @@ static ssize_t show_temp(struct device *dev, {u32 eax, edx; struct temp_data *tdata = container_of(devattr, struct temp_data, sd_attrs[ATTR_TEMP]); -int tjmax; +int tjmax, temp; +bool valid;mutex_lock (&tdata->update_lock);
@@ -400,17 +404,22 @@ static ssize_t show_temp(struct device *dev,if (time_after (jiffies, tdata->last_updated +HZ )) {rdmsr_on_cpu (tdata->cpu, tdata->status_reg, &eax, &edx);/* -* Ignore the valid bit. In all observed cases the register -* value is either low or zero if the valid bit is 0. -* Return it instead of reporting an error which doesn't -* really help at all. +* Bit 31 indicates whether the reading is valid. Some CPUs +* clear it while the temperature is too low to be measured. +* Such a reading is not a temperature. Do not report it. */ + tdata->temp_valid = (eax >>31 ) &1 ; tdata->temp = tjmax - ((eax >>16 ) &0xff ) *1000 ; tdata->last_updated = jiffies; } + valid = tdata->temp_valid; + temp = tdata->temp;mutex_unlock (&tdata->update_lock); -return sprintf (buf,"%d\n" , tdata->temp); + +if (!valid) +return -ENODATA ; +return sprintf (buf,"%d\n" , temp); }static int create_core_attrs (struct temp_data *tdata,struct device *dev)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 670/686 crypto: omap - add omap_sham_unregister_algs helper
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thorsten Blum <[email protected]>
[ Upstream commit c3494e6fbb35579a131de11369b658a59b1323e5 ]
Add a new helper omap_sham_unregister_algs() and replace two for loops in omap_sham_probe() and omap_sham_remove(), which also ensure ->registered is reset to 0.
Stable-dep-of: be51ea091c65 ("crypto: omap-sham - fix crypto engine cleanup")
--- drivers/crypto/omap-sham.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-)
drivers/crypto/omap-sham.c +16 -11
@@ -2041,6 +2041,20 @@ static struct attribute *omap_sham_attrs[] = { };ATTRIBUTE_GROUPS (omap_sham); +static void omap_sham_unregister_algs (const struct omap_sham_pdata *pdata) +{ +struct omap_sham_algs_info *alg_info; +int i; + +for (i = pdata->algs_info_size -1 ; i >=0 ; i--) { + alg_info = &pdata->algs_info[i]; + +crypto_engine_unregister_ahashes (alg_info->algs_list, + alg_info->registered); + alg_info->registered =0 ; + } +} +static int omap_sham_probe (struct platform_device *pdev) {struct omap_sham_dev *dd;
@@ -2158,10 +2172,7 @@ static int omap_sham_probe(struct platform_device *pdev)return 0 ; err_algs: -for (i = dd->pdata->algs_info_size -1 ; i >=0 ; i--) -for (j = dd->pdata->algs_info[i].registered -1 ; j >=0 ; j--) -crypto_engine_unregister_ahash ( - &dd->pdata->algs_info[i].algs_list[j]); +omap_sham_unregister_algs (dd->pdata); err_engine_start:crypto_engine_exit (dd->engine); err_engine:
@@ -2182,19 +2193,13 @@ static int omap_sham_probe(struct platform_device *pdev)static void omap_sham_remove (struct platform_device *pdev) {struct omap_sham_dev *dd; -int i, j; dd =platform_get_drvdata (pdev);spin_lock_bh (&sham.lock);list_del (&dd->list);spin_unlock_bh (&sham.lock); -for (i = dd->pdata->algs_info_size -1 ; i >=0 ; i--) -for (j = dd->pdata->algs_info[i].registered -1 ; j >=0 ; j--) { -crypto_engine_unregister_ahash ( - &dd->pdata->algs_info[i].algs_list[j]); - dd->pdata->algs_info[i].registered--; - } +omap_sham_unregister_algs (dd->pdata);cancel_work_sync (&dd->done_task);pm_runtime_dont_use_autosuspend (&pdev->dev);pm_runtime_disable (&pdev->dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 671/686 crypto: omap-sham - fix crypto engine cleanup
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
[ Upstream commit be51ea091c6563158531e8c74e040552fdb1e28c ]
omap_sham_probe() allocates and starts a crypto engine, but the remove path does not call the matching crypto_engine_exit(). The probe failure path already performs this cleanup.
crypto_engine_alloc_init() creates a kthread worker for processing requests. Without crypto_engine_exit() during driver removal, the worker is left running after the device is removed.
Call crypto_engine_exit() after unregistering the algorithms and before tearing down the remaining request handling resources. This stops the engine and destroys its worker.
This issue was found by manual code inspection.
--- drivers/crypto/omap-sham.c | 1 + 1 file changed, 1 insertion(+)
drivers/crypto/omap-sham.c +1 -0
@@ -2200,6 +2200,7 @@ static void omap_sham_remove(struct platform_device *pdev)list_del (&dd->list);spin_unlock_bh (&sham.lock);omap_sham_unregister_algs (dd->pdata); +crypto_engine_exit (dd->engine);cancel_work_sync (&dd->done_task);pm_runtime_dont_use_autosuspend (&pdev->dev);pm_runtime_disable (&pdev->dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 672/686 irqchip/renesas-rzv2h: Preserve TIEN state in rzv2h_tint_set_type()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Au Dang <[email protected]>
[ Upstream commit 42bedd4af8cd50c32a1560d8744bd22d25be79cc ]
rzv2h_tint_set_type() clears TIEN while switching the TINT source and then unconditionally sets it again, enabling the interrupt even if it was disabled before the call.
Restore the previous TIEN state instead of forcing it on.
--- drivers/irqchip/irq-renesas-rzv2h.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/irqchip/irq-renesas-rzv2h.c +4 -2
@@ -328,9 +328,9 @@ static void rzv2h_clear_tint_int(struct rzv2h_icu_priv *priv, unsigned int hwirqstatic int rzv2h_tint_set_type (struct irq_data *d,unsigned int type) {u32 titsr, titsr_k, titsel_n, tien; +u32 titsr_cur, tssr_cur, tien_cur;struct rzv2h_icu_priv *priv;u32 tssr, tssr_k, tssel_n; -u32 titsr_cur, tssr_cur;unsigned int hwirq;u32 tint, sense;int tint_nr;
@@ -386,6 +386,8 @@ static int rzv2h_tint_set_type(struct irq_data *d, unsigned int type)if (tssr_cur == tint && titsr_cur == sense)return 0 ; + tien_cur = tssr & tien; + tssr &= ~(ICU_TSSR_TSSEL_MASK (tssel_n, priv->info->field_width) | tien); tssr |=ICU_TSSR_TSSEL_PREP (tint, tssel_n, priv->info->field_width);
@@ -398,7 +400,7 @@ static int rzv2h_tint_set_type(struct irq_data *d, unsigned int type)rzv2h_clear_tint_int (priv, hwirq); -writel_relaxed (tssr | tien, priv->base + priv->info->t_offs +ICU_TSSR (tssr_k)); +writel_relaxed (tssr | tien_cur, priv->base + priv->info->t_offs +ICU_TSSR (tssr_k));return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 673/686 power: supply: ltc2941: Fix of_node reference leak in ltc294x_i2c_probe()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit 09a29213bf15630e85a375478832b074b2cfc5c8 ]
ltc294x_i2c_probe() takes a reference on the device node with of_node_get(), but never drops it, so the reference leaks on every return path, including the success path.
The node is only used to read the battery properties and to set info->supply_desc.name, so release it after its last use and also on the lltc,resistor-sense error path.
--- drivers/power/supply/ltc2941-battery-gauge.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/power/supply/ltc2941-battery-gauge.c +5 -1
@@ -464,9 +464,11 @@ static int ltc294x_i2c_probe(struct i2c_client *client)/* r_sense can be negative, when sense+ is connected to the battery * instead of the sense-. This results in reversed measurements. */ ret =of_property_read_u32 (np,"lltc,resistor-sense" , &r_sense); -if (ret <0 ) +if (ret <0 ) { +of_node_put (np);return dev_err_probe (&client->dev, ret,"Could not find lltc,resistor-sense in devicetree\n" ); + } info->r_sense = r_sense; ret = of_property_read_u32(np, "lltc,prescaler-exponent",
@@ -477,6 +479,8 @@ static int ltc294x_i2c_probe(struct i2c_client *client) prescaler_exp =LTC2941_MAX_PRESCALER_EXP ; } +of_node_put (np); +if (info->id ==LTC2943_ID ) {if (prescaler_exp >LTC2943_MAX_PRESCALER_EXP ) prescaler_exp =LTC2943_MAX_PRESCALER_EXP ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 674/686 fbdev: nvidia: Convert to managed PCI and ioremap API
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shixiong Ou <[email protected]>
[ Upstream commit a41961f364bc7aee1611796e7ab5bd687708d770 ]
Fix missing pci_disable_device() in probe and remove.
Use pcim_enable_device(), pcim_request_all_regions(), devm_ioremap() and devm_ioremap_wc() to replace manual resource management. Remove all pci_release_regions() and iounmap() calls.
Stable-dep-of: 8710af6a3520 ("fbdev: nvidia: Release write-combining handle on probe failure")
--- drivers/video/fbdev/nvidia/nvidia.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-)
drivers/video/fbdev/nvidia/nvidia.c +6 -13
@@ -1289,7 +1289,7 @@ static int nvidiafb_probe(struct pci_dev *pd, const struct pci_device_id *ent)NVTRACE_ENTER ();assert (pd !=NULL ); -if (pci_enable_device (pd)) { +if (pcim_enable_device (pd)) { printk(KERN_ERR PFX "cannot enable PCI device\n");return -ENODEV ; }
@@ -1302,7 +1302,7 @@ static int nvidiafb_probe(struct pci_dev *pd, const struct pci_device_id *ent) nvidiafb_fix.mmio_start =pci_resource_start (pd,0 ); nvidiafb_fix.mmio_len =pci_resource_len (pd,0 ); -REGS =ioremap (nvidiafb_fix.mmio_start, nvidiafb_fix.mmio_len); +REGS =devm_ioremap (&pd->dev, nvidiafb_fix.mmio_start, nvidiafb_fix.mmio_len);if (!REGS ) { printk(KERN_ERR PFX "cannot ioremap MMIO base\n");return -ENODEV ;
@@ -1330,7 +1330,7 @@ static int nvidiafb_probe(struct pci_dev *pd, const struct pci_device_id *ent)if (info->pixmap.addr ==NULL ) goto err_out_kfree; -if (pci_request_regions (pd,"nvidiafb" )) { +if (pcim_request_all_regions (pd,"nvidiafb" )) { printk(KERN_ERR PFX "cannot request PCI regions\n"); goto err_out_enable; }
@@ -1355,7 +1355,7 @@ static int nvidiafb_probe(struct pci_dev *pd, const struct pci_device_id *ent)sprintf (nvidiafb_fix.id,"NV%x" , (pd->device &0x0ff0 ) >>4 );if (NVCommonSetup (info)) - goto err_out_free_base0; + goto err_out_enable; par->FbAddress = nvidiafb_fix.smem_start; par->FbMapSize = par->RamAmountKBytes *1024 ;
@@ -1375,8 +1375,8 @@ static int nvidiafb_probe(struct pci_dev *pd, const struct pci_device_id *ent) par->ScratchBufferStart = par->FbUsableSize - par->ScratchBufferSize; par->CursorStart = par->FbUsableSize + (32 *1024 ); - info->screen_base =ioremap_wc (nvidiafb_fix.smem_start, - par->FbMapSize); + info->screen_base =devm_ioremap_wc (&pd->dev, nvidiafb_fix.smem_start, + par->FbMapSize); info->screen_size = par->FbUsableSize; nvidiafb_fix.smem_len = par->RamAmountKBytes *1024 ;
@@ -1420,19 +1420,15 @@ static int nvidiafb_probe(struct pci_dev *pd, const struct pci_device_id *ent)return 0 ; err_out_iounmap_fb: -iounmap (info->screen_base);fb_destroy_modelist (&info->modelist); err_out_free_base1:fb_destroy_modedb (info->monspecs.modedb);nvidia_delete_i2c_busses (par); -err_out_free_base0: -pci_release_regions (pd); err_out_enable:kfree (info->pixmap.addr); err_out_kfree:framebuffer_release (info); err_out: -iounmap (REGS );return -ENODEV ; }
@@ -1447,11 +1443,8 @@ static void nvidiafb_remove(struct pci_dev *pd)unregister_framebuffer (info);arch_phys_wc_del (par->wc_cookie); -iounmap (info->screen_base);fb_destroy_modedb (info->monspecs.modedb);nvidia_delete_i2c_busses (par); -iounmap (par->REGS); -pci_release_regions (pd);kfree (info->pixmap.addr);framebuffer_release (info);NVTRACE_LEAVE ();
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 675/686 fbdev: nvidia: Release write-combining handle on probe failure
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
[ Upstream commit 8710af6a35201a6d01b5af8f7e4bad29cc40467f ]
Failures in nvidia_set_fbinfo() or register_framebuffer() leave the handle from arch_phys_wc_add() allocated. Release it in the shared error path, as nvidiafb_remove() already does on normal removal.
The missing cleanup was already present in the initial Git import, when the driver used mtrr_add() directly.
This issue was identified during our ongoing static-analysis research while reviewing kernel code.
--- drivers/video/fbdev/nvidia/nvidia.c | 1 + 1 file changed, 1 insertion(+)
drivers/video/fbdev/nvidia/nvidia.c +1 -0
@@ -1420,6 +1420,7 @@ static int nvidiafb_probe(struct pci_dev *pd, const struct pci_device_id *ent)return 0 ; err_out_iounmap_fb: +arch_phys_wc_del (par->wc_cookie);fb_destroy_modelist (&info->modelist); err_out_free_base1:fb_destroy_modedb (info->monspecs.modedb);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 676/686 platform/x86/amd/pmf: Add AMDI0112 ACPI ID
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mario Limonciello <[email protected]>
[ Upstream commit 325bcc126cf7a512a0e2da0efddad665f69badac ]
The AMDI0112 ID is used to bind the PMF driver to some platforms. It doesn't have any Linux side code changes relative to the most similar AMDI0105.
--- drivers/platform/x86/amd/pmf/core.c | 1 + 1 file changed, 1 insertion(+)
drivers/platform/x86/amd/pmf/core.c +1 -0
@@ -464,6 +464,7 @@ static const struct acpi_device_id amd_pmf_acpi_ids[] = { {"AMDI0105", 0}, {"AMDI0107", 0}, {"AMDI0108", 0}, + {"AMDI0112", 0}, { } };MODULE_DEVICE_TABLE (acpi, amd_pmf_acpi_ids);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 677/686 fb: Add dev_of_fbinfo() helper for optional sysfs support
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chintan Patel <[email protected]>
[ Upstream commit 39b65316fe9d6d3f730632408ace28d49c5845a4 ]
Add dev_of_fbinfo() to return the framebuffer struct device when CONFIG_FB_DEVICE is enabled, or NULL otherwise.
This allows fbdev drivers to use sysfs interfaces via runtime checks instead of CONFIG_FB_DEVICE ifdefs, keeping the code clean while remaining fully buildable.
Stable-dep-of: 317a8be73091 ("fbdev: sh_mobile_lcdcfb: Restore the per-overlay sysfs attributes")
--- include/linux/fb.h | 9 +++++++++ 1 file changed, 9 insertions(+)
include/linux/fb.h +9 -0
@@ -631,6 +631,15 @@ static inline void unlock_fb_info(struct fb_info *info)mutex_unlock (&info->lock); } +static inline struct device *dev_of_fbinfo (const struct fb_info *info) +{ +#ifdef CONFIG_FB_DEVICE +return info->dev; +#else +return NULL ; +#endif +} +static inline void __fb_pad_aligned_buffer (u8 *dst,u32 d_pitch,u8 *src,u32 s_pitch,u32 height) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 678/686 fbdev: sh_mobile_lcdc: Make FB_DEVICE dependency optional
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chintan Patel <[email protected]>
[ Upstream commit c2925992232fdc4e90f030b77e7867921db071b5 ]
The sh_mobile_lcdc driver exposes overlay configuration via sysfs, but the core driver does not require CONFIG_FB_DEVICE.
Make overlay sysfs optional so that the driver can build and operate even when FB_DEVICE is disabled. The kernel naturally ignores the missing attribute group, preserving buildability and type safety.
Stable-dep-of: 317a8be73091 ("fbdev: sh_mobile_lcdcfb: Restore the per-overlay sysfs attributes")
--- drivers/video/fbdev/sh_mobile_lcdcfb.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/video/fbdev/sh_mobile_lcdcfb.c +4 -1
@@ -1346,14 +1346,17 @@ static DEVICE_ATTR_RW(overlay_mode);static DEVICE_ATTR_RW (overlay_position);static DEVICE_ATTR_RW (overlay_rop3); -static struct attribute *overlay_sysfs_attrs[] = { +static struct attribute *overlay_sysfs_attrs[]__maybe_unused = { &dev_attr_overlay_alpha.attr, &dev_attr_overlay_mode.attr, &dev_attr_overlay_position.attr, &dev_attr_overlay_rop3.attr,NULL , }; + +#ifdef CONFIG_FB_DEVICE ATTRIBUTE_GROUPS (overlay_sysfs); +#endif static const struct fb_fix_screeninfo sh_mobile_lcdc_overlay_fix = { .id ="SH Mobile LCDC" ,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 679/686 fbdev: sh_mobile_lcdcfb: Restore the per-overlay sysfs attributes
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 317a8be730919177956be32422ebe00cf7e46710 ]
The ovl_* files documented in Documentation/ABI/testing/sysfs-devices-platform-sh_mobile_lcdc_fb no longer exist.
Commit a979182a2453 ("fbdev: lcdcfb: Register sysfs groups through driver core") moved the attributes from each overlay's framebuffer device to the platform driver's dev_groups and renamed them overlay_*. There is now only one set of attributes for the whole LCDC. The callbacks still expect dev_get_drvdata() to return a struct fb_info, but the platform device holds struct sh_mobile_lcdc_priv, so they access the wrong structure.
Restore the documented names and register the group on each overlay's framebuffer device with device_add_groups(). Remove it with device_remove_groups() before unregistering the framebuffer. Skip creation when dev_of_fbinfo(info) is NULL, as the old device_create_file() calls did.
Drop the CONFIG_FB_DEVICE guard, since the driver already depends on it.
--- drivers/video/fbdev/sh_mobile_lcdcfb.c | 39 +++++++++++++++++--------- 1 file changed, 25 insertions(+), 14 deletions(-)
drivers/video/fbdev/sh_mobile_lcdcfb.c +25 -14
@@ -1341,22 +1341,24 @@ overlay_rop3_store(struct device *dev, struct device_attribute *attr,return count; } -static DEVICE_ATTR_RW (overlay_alpha); -static DEVICE_ATTR_RW (overlay_mode); -static DEVICE_ATTR_RW (overlay_position); -static DEVICE_ATTR_RW (overlay_rop3); - -static struct attribute *overlay_sysfs_attrs[]__maybe_unused = { - &dev_attr_overlay_alpha.attr, - &dev_attr_overlay_mode.attr, - &dev_attr_overlay_position.attr, - &dev_attr_overlay_rop3.attr, +static struct device_attribute dev_attr_ovl_alpha = +__ATTR (ovl_alpha,0644 , overlay_alpha_show, overlay_alpha_store); +static struct device_attribute dev_attr_ovl_mode = +__ATTR (ovl_mode,0644 , overlay_mode_show, overlay_mode_store); +static struct device_attribute dev_attr_ovl_position = +__ATTR (ovl_position,0644 , overlay_position_show, overlay_position_store); +static struct device_attribute dev_attr_ovl_rop3 = +__ATTR (ovl_rop3,0644 , overlay_rop3_show, overlay_rop3_store); + +static struct attribute *overlay_sysfs_attrs[] = { + &dev_attr_ovl_alpha.attr, + &dev_attr_ovl_mode.attr, + &dev_attr_ovl_position.attr, + &dev_attr_ovl_rop3.attr,NULL , }; -#ifdef CONFIG_FB_DEVICE ATTRIBUTE_GROUPS (overlay_sysfs); -#endif static const struct fb_fix_screeninfo sh_mobile_lcdc_overlay_fix = { .id ="SH Mobile LCDC" ,
@@ -1514,9 +1516,10 @@ sh_mobile_lcdc_overlay_fb_unregister(struct sh_mobile_lcdc_overlay *ovl) {struct fb_info *info = ovl->info; -if (info ==NULL || info->dev ==NULL ) +if (!info || !dev_of_fbinfo (info))return ; +device_remove_groups (dev_of_fbinfo (info), overlay_sysfs_groups);unregister_framebuffer (ovl->info); }
@@ -1534,6 +1537,15 @@ sh_mobile_lcdc_overlay_fb_register(struct sh_mobile_lcdc_overlay *ovl)if (ret <0 )return ret; +/* The framebuffer device is optional, see fb_device_create(). */ +if (dev_of_fbinfo (info)) { + ret =device_add_groups (dev_of_fbinfo (info), overlay_sysfs_groups); +if (ret <0 ) { +unregister_framebuffer (info); +return ret; + } + } +dev_info (lcdc->dev,"registered %s/overlay %u as %dx%d %dbpp.\n" ,dev_name (lcdc->dev), ovl->index, info->var.xres, info->var.yres, info->var.bits_per_pixel);
@@ -2641,7 +2653,6 @@ static int sh_mobile_lcdc_probe(struct platform_device *pdev)static struct platform_driver sh_mobile_lcdc_driver = { .driver = { .name ="sh_mobile_lcdc_fb" , - .dev_groups = overlay_sysfs_groups, .pm = &sh_mobile_lcdc_dev_pm_ops, }, .probe = sh_mobile_lcdc_probe,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 680/686 perf python: Free the parse error entries when parsing fails
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnaldo Carvalho de Melo <[email protected]>
[ Upstream commit 39e0022c89abcdc1a811dfc0aeec2a2b9010b660 ]
pyrf__parse_events() prints the entries parse_events_error__print() receives with the details of a failed parse, but returns without freeing them, leaking whatever parse_events_error__handle() allocated, so call parse_events_error__exit() on both paths, as the other parse_events() callers do.
The perf test attr core PMU probe takes this failure path on machines without a core PMU, where the leak then happens on every test run.
--- tools/perf/util/python.c | 2 ++ 1 file changed, 2 insertions(+)
tools/perf/util/python.c +2 -0
@@ -2075,9 +2075,11 @@ static PyObject *pyrf__parse_events(PyObject *self, PyObject *args)evlist__init (&evlist, cpus, threads);if (parse_events (&evlist, input, &err)) {parse_events_error__print (&err, input); +parse_events_error__exit (&err);PyErr_SetFromErrno (PyExc_OSError);return NULL ; } +parse_events_error__exit (&err); result =pyrf_evlist__from_evlist (&evlist);evlist__exit (&evlist);return result;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 681/686 selftests/landlock: Fix snprintf truncation checks in test files
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wang Yan <[email protected]>
[ Upstream commit 8e4c736cffdd6b133f6498e0d40ba60dc6819d43 ]
Commit b566f7a4f0e4 ("selftests/landlock: Fix snprintf truncation checks in audit helpers") fixed the truncation detection in audit.h by changing the comparison from ">" to ">=" to correctly handle the edge case where snprintf returns a value equal to the buffer size.
However, the same pattern exists in ptrace_test.c, audit_test.c, and net_test.c and was not fixed. snprintf() returns the number of characters that would have been written, excluding the terminating NUL byte. When the output is truncated, this return value equals or exceeds the buffer size. The existing ">" check therefore fails to detect truncation when the return value equals the buffer size.
Fix these remaining instances to use ">=" for truncation detection, matching the fix in audit.h.
--- tools/testing/selftests/landlock/audit_test.c | 2 +- tools/testing/selftests/landlock/net_test.c | 4 ++-- tools/testing/selftests/landlock/ptrace_test.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
tools/testing/selftests/landlock/audit_test.c +1 -1
@@ -31,7 +31,7 @@ static int matches_log_signal(struct __test_metadata *const _metadata, log_match_len =snprintf (log_match,sizeof (log_match), log_template, opid); -if (log_match_len >sizeof (log_match)) +if (log_match_len >=sizeof (log_match))return -E2BIG ; return audit_match_record(audit_fd, AUDIT_LANDLOCK_ACCESS, log_match,
tools/testing/selftests/landlock/net_test.c +2 -2
@@ -2067,7 +2067,7 @@ static int matches_log_tcp(const int audit_fd, const char *const blockers, log_match_len =snprintf (log_match,sizeof (log_match), log_template, blockers, dir_addr, addr, dir_port); -if (log_match_len >sizeof (log_match)) +if (log_match_len >=sizeof (log_match))return -E2BIG ; return audit_match_record(audit_fd, AUDIT_LANDLOCK_ACCESS, log_match,
@@ -2192,7 +2192,7 @@ static int matches_log_tcp_bound(int audit_fd, const char *const addr, log_match_len =snprintf (log_match,sizeof (log_match), log_template, addr, lport, addr, dport); -if (log_match_len >sizeof (log_match)) +if (log_match_len >=sizeof (log_match))return -E2BIG ; return audit_match_record(audit_fd, AUDIT_LANDLOCK_ACCESS, log_match,
tools/testing/selftests/landlock/ptrace_test.c +1 -1
@@ -446,7 +446,7 @@ static int matches_log_ptrace(struct __test_metadata *const _metadata, log_match_len =snprintf (log_match,sizeof (log_match), log_template, opid); -if (log_match_len >sizeof (log_match)) +if (log_match_len >=sizeof (log_match))return -E2BIG ; return audit_match_record(audit_fd, AUDIT_LANDLOCK_ACCESS, log_match,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 682/686 lib/tests: extend cmdline KUnit with next_arg() tests
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shuvam Pandey <[email protected]>
[ Upstream commit dcc8a57815534e3844f342b28ecfb6e626a816a0 ]
The cmdline KUnit suite covers get_option() and get_options(), but it does not exercise next_arg().
Extend the suite with one test for a quoted value containing spaces and one regression test for a bare quote token after a normal parameter.
The regression test covers the bare quote token path fixed by commit 9847f21225c4 ("lib/cmdline: avoid page fault in next_arg").
Stable-dep-of: 5d72266218b1 ("lib/cmdline: fix get_options() count and overflow with large ranges")
--- lib/tests/cmdline_kunit.c | 62 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+)
lib/tests/cmdline_kunit.c +62 -0
@@ -139,11 +139,73 @@ static void cmdline_test_range(struct kunit *test) }while (++i <ARRAY_SIZE (cmdline_test_range_strings)); } +static void cmdline_test_next_arg_quoted_value (struct kunit *test) +{ +char in[] ="foo=\"bar baz\" qux=1" ; +char *next, *param, *val; + + next =next_arg (in, ¶m, &val); +KUNIT_EXPECT_STREQ (test, param,"foo" ); +KUNIT_ASSERT_NOT_NULL (test, val); +KUNIT_EXPECT_STREQ (test, val,"bar baz" ); +KUNIT_EXPECT_STREQ (test, next,"qux=1" ); + + next =next_arg (next, ¶m, &val); +KUNIT_EXPECT_STREQ (test, param,"qux" ); +KUNIT_ASSERT_NOT_NULL (test, val); +KUNIT_EXPECT_STREQ (test, val,"1" ); +KUNIT_EXPECT_STREQ (test, next,"" ); +} + +static void cmdline_test_next_arg_bare_quote_regression (struct kunit *test) +{ +char in[] ="foo=bar \"" ; +char *next, *param, *val; + + next =next_arg (in, ¶m, &val); +KUNIT_EXPECT_STREQ (test, param,"foo" ); +KUNIT_ASSERT_NOT_NULL (test, val); +KUNIT_EXPECT_STREQ (test, val,"bar" ); +KUNIT_EXPECT_STREQ (test, next,"\"" ); + +/* This hits the i == 0 quoted-token case fixed by 9847f21225c4. */ + next =next_arg (next, ¶m, &val); +KUNIT_EXPECT_STREQ (test, param,"" ); +KUNIT_EXPECT_PTR_EQ (test, val,NULL ); +KUNIT_EXPECT_STREQ (test, next,"" ); +} + +static void cmdline_test_next_arg_mixed_tokens (struct kunit *test) +{ +char in[] ="bbb= jjj kkk=\"a=b\"" ; +char *next, *param, *val; + + next =next_arg (in, ¶m, &val); +KUNIT_EXPECT_STREQ (test, param,"bbb" ); +KUNIT_ASSERT_NOT_NULL (test, val); +KUNIT_EXPECT_STREQ (test, val,"" ); +KUNIT_EXPECT_STREQ (test, next,"jjj kkk=\"a=b\"" ); + + next =next_arg (next, ¶m, &val); +KUNIT_EXPECT_STREQ (test, param,"jjj" ); +KUNIT_EXPECT_NULL (test, val); +KUNIT_EXPECT_STREQ (test, next,"kkk=\"a=b\"" ); + + next =next_arg (next, ¶m, &val); +KUNIT_EXPECT_STREQ (test, param,"kkk" ); +KUNIT_ASSERT_NOT_NULL (test, val); +KUNIT_EXPECT_STREQ (test, val,"a=b" ); +KUNIT_EXPECT_STREQ (test, next,"" ); +} +static struct kunit_case cmdline_test_cases[] = {KUNIT_CASE (cmdline_test_noint),KUNIT_CASE (cmdline_test_lead_int),KUNIT_CASE (cmdline_test_tail_int),KUNIT_CASE (cmdline_test_range), +KUNIT_CASE (cmdline_test_next_arg_quoted_value), +KUNIT_CASE (cmdline_test_next_arg_bare_quote_regression), +KUNIT_CASE (cmdline_test_next_arg_mixed_tokens), {} };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 683/686 lib/cmdline: fix get_options() count and overflow with large ranges
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Armaan Sandhu <[email protected]>
[ Upstream commit 5d72266218b1c4dd2917f1df2b86f3b0e0a605c9 ]
get_range() stops writing once the array is full, but get_options() still advances its index by the whole range. So "1-100" parsed into four ints reports 99 numbers, and a range like "0-2147483647" wraps the index negative and writes outside the array.
Stop once a range fills the array, bail out in validation mode before the count overflows, and saturate the range length in get_range(). Add KUnit cases; without the fix "0-2147483647" panics the test kernel.
Only root can supply this input, so this is a robustness fix.
--- lib/cmdline.c | 13 ++++++++++++- lib/tests/cmdline_kunit.c | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-)
lib/cmdline.c +12 -1
@@ -11,6 +11,7 @@#include <linux/export.h> #include <linux/kernel.h> +#include <linux/overflow.h> #include <linux/string.h> #include <linux/ctype.h>
@@ -26,7 +27,9 @@ static int get_range(char **str, int *pint, int n) (*str)++; upper_range =simple_strtol ((*str),NULL ,0 ); - inc_counter = upper_range - *pint; +/* Keep the sign of the result when the difference doesn't fit */ +if (check_sub_overflow (upper_range, *pint, &inc_counter)) + inc_counter = upper_range < *pint ?-1 :INT_MAX ;for (x = *pint; n && x < upper_range; x++, n--) *pint++ = x;return inc_counter;
@@ -122,6 +125,14 @@ char *get_options(const char *str, int nints, int *ints) range_nums =get_range ((char **)&str, pint, n);if (range_nums <0 )break ; +/* The range didn't fit, so the array is full */ +if (!validate && range_nums > n) { + i = nints; +break ; + } +/* Leave room for the upper number of the range */ +if (range_nums >=INT_MAX - i) +break ;/* * Decrement the result by one to leave out the * last number in the range. The next iteration
lib/tests/cmdline_kunit.c +39 -0
@@ -139,6 +139,44 @@ static void cmdline_test_range(struct kunit *test) }while (++i <ARRAY_SIZE (cmdline_test_range_strings)); } +static const struct { +const char *in; +int parsed[4 ]; +int validated; +} cmdline_test_range_overflow_cases[] = { + {"1-100" , {3 ,1 ,2 ,3 , },100 , }, + {"1,5-100,7" , {3 ,1 ,5 ,6 , },98 , }, + {"1-2147483646" , {3 ,1 ,2 ,3 , },2147483646 , }, + {"0-2147483647" , {3 ,0 ,1 ,2 , },0 , }, + {"-5-2147483647" , {3 ,-5 ,-4 ,-3 , },0 , }, + {"2147483647--5" , {0 ,2147483647 , },0 , }, + {"1,0-2147483647" , {3 ,1 ,0 ,1 , },1 , }, +}; + +static void cmdline_test_range_overflow (struct kunit *test) +{ +unsigned int i, j; + +for (i =0 ; i <ARRAY_SIZE (cmdline_test_range_overflow_cases); i++) { +const char *in = cmdline_test_range_overflow_cases[i].in; +const int *e = cmdline_test_range_overflow_cases[i].parsed; +/* Two guard elements past the array handed to get_options() */ +int r[ARRAY_SIZE (cmdline_test_range_overflow_cases[0 ].parsed) +2 ]; +int n; + +memset (r,0 ,sizeof (r)); +get_options (in,ARRAY_SIZE (r) -2 , r); +for (j =0 ; j <ARRAY_SIZE (r) -2 ; j++) +KUNIT_EXPECT_EQ_MSG (test, r[j], e[j],"Pattern: %s at %u" , in, j); +for (; j <ARRAY_SIZE (r); j++) +KUNIT_EXPECT_EQ_MSG (test, r[j],0 ,"Pattern: %s out of bound at %u" , in, j); + +get_options (in,0 , &n); +KUNIT_EXPECT_EQ_MSG (test, n, cmdline_test_range_overflow_cases[i].validated, +"Pattern: %s (validated)" , in); + } +} +static void cmdline_test_next_arg_quoted_value (struct kunit *test) {char in[] ="foo=\"bar baz\" qux=1" ;
@@ -203,6 +241,7 @@ static struct kunit_case cmdline_test_cases[] = {KUNIT_CASE (cmdline_test_lead_int),KUNIT_CASE (cmdline_test_tail_int),KUNIT_CASE (cmdline_test_range), +KUNIT_CASE (cmdline_test_range_overflow),KUNIT_CASE (cmdline_test_next_arg_quoted_value),KUNIT_CASE (cmdline_test_next_arg_bare_quote_regression), KUNIT_CASE(cmdline_test_next_arg_mixed_tokens),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 684/686 ASoC: amd: yc: Add DMI quirk for HP OmniBook 3 Laptop 16-by0xxx
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gianluca Balboni <[email protected]>
[ Upstream commit 1e73257dff33ff851af60d5bb00d73893a8b6dc8 ]
The HP OmniBook 3 Laptop 16-by0xxx (board ID 8EE3) has an internal DMIC connected to the AMD ACP6x audio coprocessor. The BIOS does not set the AcpDmicConnected _DSD property or the _WOV method, and the board is missing from yc_acp_quirk_table[], so acp6x_probe() returns -ENODEV and no DMIC capture device is registered.
Add a DMI quirk entry for this model to enable ACP DMIC support.
--- sound/soc/amd/yc/acp6x-mach.c | 7 +++++++ 1 file changed, 7 insertions(+)
sound/soc/amd/yc/acp6x-mach.c +7 -0
@@ -682,6 +682,13 @@ static const struct dmi_system_id yc_acp_quirk_table[] = { DMI_MATCH(DMI_BOARD_NAME, "8BD6"), } }, + { + .driver_data = &acp6x_card, + .matches = { +DMI_MATCH (DMI_BOARD_VENDOR ,"HP" ), + DMI_MATCH(DMI_BOARD_NAME, "8EE3"), + } + }, { .driver_data = &acp6x_card, .matches = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 685/686 ALSA: hda/realtek: Enable mute LEDs on HP OmniBook 7 17-dc0xxx
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jaeho Cho <[email protected]>
[ Upstream commit 1c4f6202876a74e752a8cfd3696955f761671c7a ]
The HP OmniBook 7 Laptop 17-dc0xxx (SSID 103c:8d9c) has mute and mic-mute LEDs on its F6 and F9 keys, but neither lights up. Its quirk entry only sets up the two CS35L41 amplifiers, so no LED control is registered for either key.
Writing to the ALC245 by hand with hda-verb, the mute LED responds to COEF 0x0b bits 2-3 and the mic-mute LED to GPIO 0x04, lit when the pin is low. That appears to match what ALC245_FIXUP_HP_X360_MUTE_LEDS already does, so add a fixup that chains the two-amp I2C setup to it and use it for this model.
Tested on 7.2.4 with the patched module: hda::mute and hda::micmute are registered, and both LEDs follow the speaker and microphone mute state, including from the F6 and F9 keys.
Stable-dep-of: c80286aaa4ac ("ALSA: hda/realtek: Enable mute LEDs on HP OmniBook X Flip 14-fm0xxx")
--- sound/hda/codecs/realtek/alc269.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
sound/hda/codecs/realtek/alc269.c +8 -1
@@ -3952,6 +3952,7 @@ enum {ALC287_FIXUP_LEGION_16ACHG6 ,ALC287_FIXUP_CS35L41_I2C_2 ,ALC287_FIXUP_CS35L41_I2C_2_HP_GPIO_LED , +ALC287_FIXUP_CS35L41_I2C_2_HP_MUTE_LEDS ,ALC287_FIXUP_CS35L41_I2C_4 ,ALC245_FIXUP_CS35L41_SPI_1 , ALC245_FIXUP_CS35L41_SPI_2,
@@ -6234,6 +6235,12 @@ static const struct hda_fixup alc269_fixups[] = { .chained = true, .chain_id = ALC285_FIXUP_HP_MUTE_LED, }, + [ALC287_FIXUP_CS35L41_I2C_2_HP_MUTE_LEDS] = { + .type = HDA_FIXUP_FUNC, + .v.func = cs35l41_fixup_i2c_two, + .chained = true, + .chain_id = ALC245_FIXUP_HP_X360_MUTE_LEDS, + }, [ALC287_FIXUP_CS35L41_I2C_4] = { .type = HDA_FIXUP_FUNC, .v.func = cs35l41_fixup_i2c_four,
@@ -7143,7 +7150,7 @@ static const struct hda_quirk alc269_fixup_tbl[] = {SND_PCI_QUIRK (0x103c ,0x8d92 ,"HP ZBook Firefly 16 G12" ,ALC285_FIXUP_HP_GPIO_LED ),SND_PCI_QUIRK (0x103c ,0x8dcd ,"HP Victus 15-fa2xxx" ,ALC245_FIXUP_HP_MUTE_LED_COEFBIT ),SND_PCI_QUIRK (0x103c ,0x8d9b ,"HP 17 Turbine OmniBook 7 UMA" ,ALC287_FIXUP_CS35L41_I2C_2 ), -SND_PCI_QUIRK (0x103c ,0x8d9c ,"HP 17 Turbine OmniBook 7 DIS" ,ALC287_FIXUP_CS35L41_I2C_2 ), +SND_PCI_QUIRK (0x103c ,0x8d9c ,"HP 17 Turbine OmniBook 7 DIS" ,ALC287_FIXUP_CS35L41_I2C_2_HP_MUTE_LEDS ),SND_PCI_QUIRK (0x103c ,0x8d9d ,"HP 17 Turbine OmniBook X UMA" ,ALC287_FIXUP_CS35L41_I2C_2 ),SND_PCI_QUIRK (0x103c ,0x8d9e ,"HP 17 Turbine OmniBook X DIS" ,ALC287_FIXUP_CS35L41_I2C_2 ), SND_PCI_QUIRK(0x103c, 0x8d9f, "HP 14 Cadet (x360)", ALC287_FIXUP_CS35L41_I2C_2),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 686/686 ALSA: hda/realtek: Enable mute LEDs on HP OmniBook X Flip 14-fm0xxx
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: José Miguel Castellanos Valladolid <[email protected]>
[ Upstream commit c80286aaa4acd52f9bd0b0d4914d2069fe6ba3a8 ]
The HP OmniBook X Flip Laptop 14-fm0xxx (subsystem ID 0x103c8d9f, ALC245 with two CS35L41 amplifiers over I2C) is currently handled by ALC287_FIXUP_CS35L41_I2C_2. That binds the amplifiers but does not set up the mute LEDs, so neither the speaker mute key LED nor the microphone mute key LED lights up under Linux. With that fixup the codec GPIOs stay disabled (IO[0..2] enable=0).
Switch the entry to ALC287_FIXUP_CS35L41_I2C_2_HP_MUTE_LEDS, which chains cs35l41_fixup_i2c_two with ALC245_FIXUP_HP_X360_MUTE_LEDS. This keeps the amplifier setup and adds the speaker mute LED through the ALC245 COEF register and the mic mute LED through codec GPIO2. It is the same fixup already used for the 17 Turbine OmniBook 7 DIS (0x103c8d9c).
Tested on the affected laptop with v7.2.11 using the equivalent ALC245_FIXUP_HP_ENVY_X360_15_FH0XXX fixup, which has the identical cs35l41_fixup_i2c_two + ALC245_FIXUP_HP_X360_MUTE_LEDS chain: hda::mute and hda::micmute LED class devices appear and both key LEDs light up when muting.
--- sound/hda/codecs/realtek/alc269.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/hda/codecs/realtek/alc269.c +1 -1
@@ -7153,7 +7153,7 @@ static const struct hda_quirk alc269_fixup_tbl[] = {SND_PCI_QUIRK (0x103c ,0x8d9c ,"HP 17 Turbine OmniBook 7 DIS" ,ALC287_FIXUP_CS35L41_I2C_2_HP_MUTE_LEDS ),SND_PCI_QUIRK (0x103c ,0x8d9d ,"HP 17 Turbine OmniBook X UMA" ,ALC287_FIXUP_CS35L41_I2C_2 ),SND_PCI_QUIRK (0x103c ,0x8d9e ,"HP 17 Turbine OmniBook X DIS" ,ALC287_FIXUP_CS35L41_I2C_2 ), -SND_PCI_QUIRK (0x103c ,0x8d9f ,"HP 14 Cadet (x360)" ,ALC287_FIXUP_CS35L41_I2C_2 ), +SND_PCI_QUIRK (0x103c ,0x8d9f ,"HP 14 Cadet (x360)" ,ALC287_FIXUP_CS35L41_I2C_2_HP_MUTE_LEDS ),SND_PCI_QUIRK (0x103c ,0x8da0 ,"HP 16 Clipper OmniBook 7(X360)" ,ALC287_FIXUP_CS35L41_I2C_2 ),SND_PCI_QUIRK (0x103c ,0x8da1 ,"HP 16 Clipper OmniBook X" ,ALC287_FIXUP_CS35L41_I2C_2 ), SND_PCI_QUIRK(0x103c, 0x8da7, "HP 14 Enstrom OmniBook X", ALC287_FIXUP_CS35L41_I2C_2),
Signature · 1 line
2.53.0
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.18.64 release. There are 686 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Sun, 15 Nov 2026 15:36:17 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.18.64-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.18.y
and the diffstat can be found below.thanks,
greg k-h
On ARCH_BRCMSTB using 32-bit and 64-bit ARM kernels, build tested on BMIPS_GENERIC:
Signature · 1 line
Florian
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.18.64 release. There are 686 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Sun, 15 Nov 2026 15:36:17 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 9 lines
https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.18.64-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.18.y
and the diffstat can be found below.thanks,
greg k-h
Compiled and booted on my test system. No dmesg regressions.
thanks,
-- Shuah
Quoted 7 lines · On Fri, 13 Nov 2026 10:42:13 -0500 Greg Kroah-Hartman…
This is the start of the stable review cycle for the 6.18.64 release. There are 686 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Sun, 15 Nov 2026 15:36:17 +0000. Anything received after that time might be too late.
This rc kernel passes DAMON functionality test [1] on my test machine.
[1] https://github.com/damonitor/damon-tests/tree/next/corr
Thanks,
SJ
[...]
# Librecast Test Results
044/044 [ OK ] liblcrq
010/010 [ OK ] libmld
120/120 [ OK ] liblibrecast
CPU/kernel: Linux auntie 6.18.64-rc1-g910b5c0af479 #1 SMP PREEMPT_DYNAMIC Sat Nov 14 07:25:26 -00 2026 x86_64 AMD Ryzen 9 9950X 16-Core Processor AuthenticAMD GNU/Linux
Quoted 8 lines · On Fri, 13 Nov 2026 10:42:13 -0500 Greg Kroah-Hartman…
This is the start of the stable review cycle for the 6.18.64 release. There are 686 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Sun, 15 Nov 2026 15:36:17 +0000. Anything received after that time might be too late.
Boot-tested under QEMU for Rust x86_64, arm64 and riscv64; built-tested for loongarch64 and arm32:
I noticed in UML the following, though:
https://lore.kernel.org/stable/[email protected]/
Thanks!
Cheers,
Miguel
Am 13.11.2026 um 16:42 schrieb Greg Kroah-Hartman:
Quoted 4 lines
This is the start of the stable review cycle for the 6.18.64 release. There are 686 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Builds, boots and works on my 2-socket Ivy Bridge Xeon E5-2697v2 server. No dmesg oddities or regressions found.
Beste Grüße,
Peter Schneider
Signature · 8 lines
Climb the mountain not to plant your flag, but to embrace the challenge, enjoy the air and behold the view. Climb it so you can see the world, not so the world can see you. -- David McCullough Jr. OpenPGP: 0xA3828BD796CCE11A8CADE8866E3A92C92C3FF244 Download: https://www.peters-netzplatz.de/download/pschneider1968_pub.asc https://keys.mailvelope.com/pks/lookup?op=get&[email protected] https://keys.mailvelope.com/pks/lookup?op=get&[email protected]
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.18.64 release. There are 686 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Sun, 15 Nov 2026 15:36:17 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.18.64-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.18.y
and the diffstat can be found below.thanks,
greg k-h
Tested on my Lenovo ThinkPad T14 Gen 1 and an arm64 virtual machine. Working well, no regressions observed.
Signature · 1 line
-Barry K. Nathan <[email protected]>
Quoted 4 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.18.64 release. There are 686 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Built, booted, and tested on hardware for x86_64:
- AMD Ryzen 9 5900X, Nvidia RTX 3080 (nouveau)
- Intel N100
No regressions found.
Thanks!
Sean
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.18.64 release. There are 686 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Sun, 15 Nov 2026 15:36:17 +0000. Anything received after that time might be too late.
Hi, Greg:
6.18.64-rc1 successfully built and booted in my system without any notable regressions.
Distribution: Gentoo Linux
Architecture: x86_64 (ASUS Zenbook UM3504DA)
CPU: AMD Ryzen 7 7735U
iGPU: AMD Radeon 680M
[ 0.000000] Linux version 6.18.64-rc1-900-myllvm+
(user1@gentoo-zenbook) (clang version 23.1.5, LLD 23.1.5) #3 SMP PREEMPT_DYNAMIC Sun Nov 15 12:36:52 KST 2026
Best,
Joungmin
Build tested in our x86,arm64,loongarch,riscv config successfully without error.
Best Regards
Wentao Guan
Log:
Linux version 6.18.64-rc1-g910b5c0af479 (guanwentao@uos-PC) (aarch64-linux-gnu-gcc-12 (Deepin 12.3.0-17deepin8) 12.3.0, GNU ld (GNU Binutils for Deepin) 2.41) #2 SMP PREEMPT_DYNAMIC Sun Nov 15 18:18:39 CST 2026 Linux version 6.18.64-rc1-g910b5c0af479 (guanwentao@uos-PC) (loongarch64-linux-gnu-gcc-12 (Deepin 12.3.0-17deepin8) 12.3.0, GNU ld (GNU Binutils for Deepin) 2.41) #3 SMP PREEMPT_DYNAMIC Sun Nov 15 18:36:37 CST 2026 Linux version 6.18.64-rc1+ (guanwentao@uos-PC) (riscv64-linux-gnu-gcc-12 (Deepin 12.3.0-17deepin8) 12.3.0, GNU ld (GNU Binutils for Deepin) 2.41) #4 SMP PREEMPT Sun Nov 15 18:56:07 CST 2026 Linux version 6.18.64-rc1-g910b5c0af479 (guanwentao@uos-PC) (gcc (Deepin 12.3.0-17deepin18) 12.3.0, GNU ld (GNU Binutils for Deepin) 2.41) #1 SMP PREEMPT_DYNAMIC Sun Nov 15 17:54:57 CST 2026
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.18.64 release. There are 686 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Sun, 15 Nov 2026 15:36:17 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.18.64-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.18.y
and the diffstat can be found below.thanks,
greg k-h
Built and booted successfully on RISC-V RV64 (HiFive Unmatched).
Hi!
Quoted 4 lines
This is the start of the stable review cycle for the 6.18.64 release. There are 686 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
CIP testing did not find any problems here:
https://gitlab.com/cip-project/cip-testing/linux-stable-rc-ci/-/tree/linux-6.18.y
Best regards,
Pavel
Quoted 4 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.18.64 release. There are 686 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.