RDMA/siw: Fix potential NULL pointer dereference in header processing
Subsystems (235)
PATCH 275/385 crypto: ccp - Send PSP_CMD_TEE_RING_DESTROY when PSP_CMD_TEE_RING_INIT fails
In reply to Sasha LevinFrom: "Mario Limonciello (AMD)" <[email protected]>
[ Upstream commit 7b85137caf110a09a4a18f00f730de4709f9afc8 ]
The hibernate resume sequence involves loading a resume kernel that is just used for loading the hibernate image before shifting back to the existing kernel.
During that hibernate resume sequence the resume kernel may have loaded the ccp driver. If this happens the resume kernel will also have called PSP_CMD_TEE_RING_INIT but it will never have called PSP_CMD_TEE_RING_DESTROY.
This is problematic because the existing kernel needs to re-initialize the ring. One could argue that the existing kernel should call destroy as part of restore() but there is no guarantee that the resume kernel did or didn't load the ccp driver. There is also no callback opportunity for the resume kernel to destroy before handing back control to the existing kernel.
Similar problems could potentially exist with the use of kdump and crash handling. I actually reproduced this issue like this:
1) rmmod ccp
2) hibernate the system
3) resume the system
4) modprobe ccp
The resume kernel will have loaded ccp but never destroyed and then when I try to modprobe it fails.
Because of these possible cases add a flow that checks the error code from the PSP_CMD_TEE_RING_INIT call and tries to call PSP_CMD_TEE_RING_DESTROY if it failed. If this succeeds then call PSP_CMD_TEE_RING_INIT again.
--- drivers/crypto/ccp/tee-dev.c | 14 ++++++++++++++ include/linux/psp.h | 1 + 2 files changed, 15 insertions(+)
drivers/crypto/ccp/tee-dev.c +14 -0
@@ -113,6 +113,7 @@ static int tee_init_ring(struct psp_tee_device *tee) {int ring_size =MAX_RING_BUFFER_ENTRIES *sizeof (struct tee_ring_cmd );struct tee_init_ring_cmd *cmd; +bool retry = false;unsigned int reg;int ret;
@@ -135,6 +136,7 @@ static int tee_init_ring(struct psp_tee_device *tee)/* Send command buffer details to Trusted OS by writing to * CPU-PSP message registers */ +retry_init: ret =psp_mailbox_command (tee->psp,PSP_CMD_TEE_RING_INIT , cmd,TEE_DEFAULT_CMD_TIMEOUT , ®);if (ret) {
@@ -145,6 +147,18 @@ static int tee_init_ring(struct psp_tee_device *tee) }if (FIELD_GET (PSP_CMDRESP_STS , reg)) { +/* +* During the hibernate resume sequence driver may have gotten loaded +* but the ring not properly destroyed. If the ring doesn't work, try +* to destroy and re-init once. +*/ +if (!retry &&FIELD_GET (PSP_CMDRESP_STS , reg) ==PSP_TEE_STS_RING_BUSY ) { +dev_info (tee->dev,"tee: ring init command failed with busy status, retrying\n" ); +if (tee_send_destroy_cmd (tee)) { + retry = true; + goto retry_init; + } + }dev_err (tee->dev,"tee: ring init command failed (%#010lx)\n" ,FIELD_GET (PSP_CMDRESP_STS , reg));tee_free_ring (tee);
include/linux/psp.h +1 -0
@@ -18,6 +18,7 @@* and should include an appropriate local definition in their source file. */ #define PSP_CMDRESP_STS GENMASK(15, 0) +#define PSP_TEE_STS_RING_BUSY 0x0000000d/* Ring already initialized */ #define PSP_CMDRESP_CMD GENMASK(23, 16)#define PSP_CMDRESP_RESERVED GENMASK(29, 24)#define PSP_CMDRESP_RECOVERY BIT(30)
Signature · 1 line
2.51.0
PATCH 276/385 mtd: parsers: Fix memory leak in mtd_parser_tplink_safeloader_parse()
In reply to Sasha LevinFrom: Zilin Guan <[email protected]>
[ Upstream commit 980ce2b02dd06a4fdf5fee38b2e14becf9cf7b8b ]
The function mtd_parser_tplink_safeloader_parse() allocates buf via mtd_parser_tplink_safeloader_read_table(). If the allocation for parts[idx].name fails inside the loop, the code jumps to the err_free label without freeing buf, leading to a memory leak.
Fix this by freeing the temporary buffer buf in the err_free label.
Compile tested only. Issue found using a prototype static analysis tool and code review.
--- drivers/mtd/parsers/tplink_safeloader.c | 1 + 1 file changed, 1 insertion(+)
drivers/mtd/parsers/tplink_safeloader.c +1 -0
@@ -116,6 +116,7 @@ static int mtd_parser_tplink_safeloader_parse(struct mtd_info *mtd,return idx; err_free: +kfree (buf);for (idx -=1 ; idx >=0 ; idx--)kfree (parts[idx].name); err_free_parts:
Signature · 1 line
2.51.0
PATCH 277/385 nfs/localio: eliminate unnecessary kref in nfs_local_fsync_ctx
In reply to Sasha LevinFrom: Mike Snitzer <[email protected]>
[ Upstream commit 894f5c5593cdb57841318597a800ad1d3cb45a52 ]
nfs_local_commit() doesn't need async cleanup of nfs_local_fsync_ctx, so there is no need to use a kref.
Stable-dep-of: 9bb0060f7860 ("NFS/localio: use GFP_NOIO and non-memreclaim workqueue in nfs_local_commit")
--- fs/nfs/localio.c | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-)
fs/nfs/localio.c +3 -17
@@ -43,7 +43,6 @@ struct nfs_local_fsync_ctx {struct nfsd_file *localio;struct nfs_commit_data *data;struct work_struct work; -struct kref kref;struct completion *done; };static void nfs_local_fsync_work (struct work_struct *work);
@@ -775,30 +774,17 @@ nfs_local_fsync_ctx_alloc(struct nfs_commit_data *data, ctx->localio = localio; ctx->data = data;INIT_WORK (&ctx->work, nfs_local_fsync_work); -kref_init (&ctx->kref); ctx->done =NULL ; }return ctx; } -static void -nfs_local_fsync_ctx_kref_free (struct kref *kref) -{ -kfree (container_of(kref ,struct nfs_local_fsync_ctx ,kref )); -} - -static void -nfs_local_fsync_ctx_put (struct nfs_local_fsync_ctx *ctx) -{ -kref_put (&ctx->kref, nfs_local_fsync_ctx_kref_free); -} -static void nfs_local_fsync_ctx_free (struct nfs_local_fsync_ctx *ctx) {nfs_local_release_commit_data (ctx->localio, ctx->data, ctx->data->task.tk_ops); -nfs_local_fsync_ctx_put (ctx); +kfree (ctx); } static void
@@ -831,7 +817,7 @@ int nfs_local_commit(struct nfsd_file *localio, }nfs_local_init_commit (data, call_ops); -kref_get (&ctx->kref); +if (how &FLUSH_SYNC ) {DECLARE_COMPLETION_ONSTACK (done); ctx->done = &done;
@@ -839,6 +825,6 @@ int nfs_local_commit(struct nfsd_file *localio,wait_for_completion (&done); }else queue_work (nfsiod_workqueue, &ctx->work); -nfs_local_fsync_ctx_put (ctx); +return 0 ; }
Signature · 1 line
2.51.0
PATCH 278/385 NFS/localio: use GFP_NOIO and non-memreclaim workqueue in nfs_local_commit
In reply to Sasha LevinFrom: Mike Snitzer <[email protected]>
[ Upstream commit 9bb0060f7860aa4561c5b21163dd45ceb66946a9 ]
nfslocaliod_workqueue is a non-memreclaim workqueue (it isn't initialized with WQ_MEM_RECLAIM), see commit b9f5dd57f4a5 ("nfs/localio: use dedicated workqueues for filesystem read and write").
Use nfslocaliod_workqueue for LOCALIO's SYNC work.
Also, set PF_LOCAL_THROTTLE | PF_MEMALLOC_NOIO innfs_local_fsync_work.
--- fs/nfs/localio.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
fs/nfs/localio.c +8 -3
@@ -790,17 +790,22 @@ nfs_local_fsync_ctx_free(struct nfs_local_fsync_ctx *ctx)static void nfs_local_fsync_work (struct work_struct *work) { +unsigned long old_flags = current->flags;struct nfs_local_fsync_ctx *ctx;int status; ctx = container_of(work, struct nfs_local_fsync_ctx, work); + current->flags |=PF_LOCAL_THROTTLE |PF_MEMALLOC_NOIO ; + status =nfs_local_run_commit (nfs_to->nfsd_file_file (ctx->localio), ctx->data);nfs_local_commit_done (ctx->data, status);if (ctx->done !=NULL )complete (ctx->done);nfs_local_fsync_ctx_free (ctx); + + current->flags = old_flags; } int nfs_local_commit(struct nfsd_file *localio,
@@ -809,7 +814,7 @@ int nfs_local_commit(struct nfsd_file *localio, {struct nfs_local_fsync_ctx *ctx; - ctx =nfs_local_fsync_ctx_alloc (data, localio,GFP_KERNEL ); + ctx =nfs_local_fsync_ctx_alloc (data, localio,GFP_NOIO );if (!ctx) {nfs_local_commit_done (data, -ENOMEM );nfs_local_release_commit_data (localio, data, call_ops);
@@ -821,10 +826,10 @@ int nfs_local_commit(struct nfsd_file *localio,if (how &FLUSH_SYNC ) {DECLARE_COMPLETION_ONSTACK (done); ctx->done = &done; -queue_work (nfsiod_workqueue, &ctx->work); +queue_work (nfslocaliod_workqueue, &ctx->work);wait_for_completion (&done); }else -queue_work (nfsiod_workqueue, &ctx->work); +queue_work (nfslocaliod_workqueue, &ctx->work);return 0 ; }
Signature · 1 line
2.51.0
PATCH 279/385 RDMA/uverbs: Validate wqe_size before using it in ib_uverbs_post_send
In reply to Sasha LevinFrom: Yi Liu <[email protected]>
[ Upstream commit 1956f0a74ccf5dc9c3ef717f2985c3ed3400aab0 ]
ib_uverbs_post_send() uses cmd.wqe_size from userspace without any validation before passing it to kmalloc() and using the allocated buffer as struct ib_uverbs_send_wr.
If a user provides a small wqe_size value (e.g., 1), kmalloc() will succeed, but subsequent accesses to user_wr->opcode, user_wr->num_sge, and other fields will read beyond the allocated buffer, resulting in an out-of-bounds read from kernel heap memory. This could potentially leak sensitive kernel information to userspace.
Additionally, providing an excessively large wqe_size can trigger a WARNING in the memory allocation path, as reported by syzkaller.
This is inconsistent with ib_uverbs_unmarshall_recv() which properly validates that wqe_size >= sizeof(struct ib_uverbs_recv_wr) before proceeding.
Add the same validation for ib_uverbs_post_send() to ensure wqe_size is at least sizeof(struct ib_uverbs_send_wr).
--- drivers/infiniband/core/uverbs_cmd.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/infiniband/core/uverbs_cmd.c +4 -1
@@ -2031,7 +2031,10 @@ static int ib_uverbs_post_send(struct uverbs_attr_bundle *attrs)if (ret)return ret; - user_wr =kmalloc (cmd.wqe_size,GFP_KERNEL ); +if (cmd.wqe_size <sizeof (struct ib_uverbs_send_wr )) +return -EINVAL ; + + user_wr =kmalloc (cmd.wqe_size,GFP_KERNEL | __GFP_NOWARN);if (!user_wr)return -ENOMEM ;
Signature · 1 line
2.51.0
PATCH 280/385 RDMA/mlx5: Fix memory leak in GET_DATA_DIRECT_SYSFS_PATH handler
In reply to Sasha LevinFrom: Zilin Guan <[email protected]>
[ Upstream commit 9b9d253908478f504297ac283c514e5953ddafa6 ]
The UVERBS_HANDLER(MLX5_IB_METHOD_GET_DATA_DIRECT_SYSFS_PATH) function allocates memory for the device path using kobject_get_path(). If the length of the device path exceeds the output buffer length, the function returns -ENOSPC but does not free the allocated memory, resulting in a memory leak.
Add a kfree() call to the error path to ensure the allocated memory is properly freed.
Compile tested only. Issue found using a prototype static analysis tool and code review.
--- drivers/infiniband/hw/mlx5/std_types.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/infiniband/hw/mlx5/std_types.c +2 -2
@@ -214,7 +214,7 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_GET_DATA_DIRECT_SYSFS_PATH)(int out_len =uverbs_attr_get_len (attrs,MLX5_IB_ATTR_GET_DATA_DIRECT_SYSFS_PATH );u32 dev_path_len; -char *dev_path; +char *dev_path =NULL ;int ret; c =to_mucontext (ib_uverbs_get_ucontext (attrs));
@@ -242,9 +242,9 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_GET_DATA_DIRECT_SYSFS_PATH)( ret =uverbs_copy_to (attrs,MLX5_IB_ATTR_GET_DATA_DIRECT_SYSFS_PATH , dev_path, dev_path_len); -kfree (dev_path); end: +kfree (dev_path);mutex_unlock (&dev->data_direct_lock);return ret; }
Signature · 1 line
2.51.0
PATCH 281/385 RDMA/rxe: Fix race condition in QP timer handlers
In reply to Sasha LevinFrom: Li Zhijian <[email protected]>
[ Upstream commit 87bf646921430e303176edc4eb07c30160361b73 ]
I encontered the following warning:
WARNING: drivers/infiniband/sw/rxe/rxe_task.c:249 at rxe_sched_task+0x1c8/0x238 [rdma_rxe], CPU#0: swapper/0/0 ... libsha1 [last unloaded: ip6_udp_tunnel] CPU: 0 UID: 0 PID: 0 Comm: swapper/0 Tainted: G C 6.19.0-rc5-64k-v8+ #37 PREEMPT Tainted: [C]=CRAP Hardware name: Raspberry Pi 4 Model B Rev 1.2 Call trace: rxe_sched_task+0x1c8/0x238 [rdma_rxe] (P) retransmit_timer+0x130/0x188 [rdma_rxe] call_timer_fn+0x68/0x4d0 __run_timers+0x630/0x888 ... WARNING: drivers/infiniband/sw/rxe/rxe_task.c:38 at rxe_sched_task+0x1c0/0x238 [rdma_rxe], CPU#0: swapper/0/0 ... WARNING: drivers/infiniband/sw/rxe/rxe_task.c:111 at do_work+0x488/0x5c8 [rdma_rxe], CPU#3: kworker/u17:4/93400 ... refcount_t: underflow; use-after-free. WARNING: lib/refcount.c:28 at refcount_warn_saturate+0x138/0x1a0, CPU#3: kworker/u17:4/93400
The issue is caused by a race condition between retransmit_timer() and rxe_destroy_qp, leading to the Queue Pair's (QP) reference count dropping to zero during timer handler execution.
It seems this warning is harmless because rxe_qp_do_cleanup() will flush all pending timers and requests.
Example of flow causing the issue:
CPU0 CPU1
retransmit_timer() {
spin_lock_irqsave
rxe_destroy_qp()
__rxe_cleanup()
__rxe_put() // qp->ref_count decrease to 0
rxe_qp_do_cleanup() {
if (qp->valid) {
rxe_sched_task() {
WARN_ON(rxe_read(task->qp) <= 0);
}
}
spin_unlock_irqrestore
}
spin_lock_irqsave
qp->valid = 0
spin_unlock_irqrestore
}Ensure the QP's reference count is maintained and its validity is checked within the timer callbacks by adding calls to rxe_get(qp) and corresponding rxe_put(qp) after use.
--- drivers/infiniband/sw/rxe/rxe_comp.c | 3 +++ drivers/infiniband/sw/rxe/rxe_req.c | 3 +++ 2 files changed, 6 insertions(+)
drivers/infiniband/sw/rxe/rxe_comp.c +3 -0
@@ -119,12 +119,15 @@ void retransmit_timer(struct timer_list *t)rxe_dbg_qp (qp,"retransmit timer fired\n" ); +if (!rxe_get (qp)) +return ;spin_lock_irqsave (&qp->state_lock, flags);if (qp->valid) { qp->comp.timeout =1 ;rxe_sched_task (&qp->send_task); }spin_unlock_irqrestore (&qp->state_lock, flags); +rxe_put (qp); }void rxe_comp_queue_pkt (struct rxe_qp *qp,struct sk_buff *skb)
drivers/infiniband/sw/rxe/rxe_req.c +3 -0
@@ -103,6 +103,8 @@ void rnr_nak_timer(struct timer_list *t)rxe_dbg_qp (qp,"nak timer fired\n" ); +if (!rxe_get (qp)) +return ;spin_lock_irqsave (&qp->state_lock, flags);if (qp->valid) {/* request a send queue retry */
@@ -111,6 +113,7 @@ void rnr_nak_timer(struct timer_list *t)rxe_sched_task (&qp->send_task); }spin_unlock_irqrestore (&qp->state_lock, flags); +rxe_put (qp); }static void req_check_sq_drain_done (struct rxe_qp *qp)
Signature · 1 line
2.51.0
PATCH 282/385 RDMA/core: add rdma_rw_max_sge() helper for SQ sizing
In reply to Sasha LevinFrom: Chuck Lever <[email protected]>
[ Upstream commit afcae7d7b8a278a6c29e064f99e5bafd4ac1fb37 ]
svc_rdma_accept() computes sc_sq_depth as the sum of rq_depth and the number of rdma_rw contexts (ctxts). This value is used to allocate the Send CQ and to initialize the sc_sq_avail credit pool.
However, when the device uses memory registration for RDMA operations, rdma_rw_init_qp() inflates the QP's max_send_wr by a factor of three per context to account for REG and INV work requests. The Send CQ and credit pool remain sized for only one work request per context, causing Send Queue exhaustion under heavy NFS WRITE workloads.
Introduce rdma_rw_max_sge() to compute the actual number of Send Queue entries required for a given number of rdma_rw contexts. Upper layer protocols call this helper before creating a Queue Pair so that their Send CQs and credit accounting match the QP's true capacity.
Update svc_rdma_accept() to use rdma_rw_max_sge() when computing sc_sq_depth, ensuring the credit pool reflects the work requests that rdma_rw_init_qp() will reserve.
--- drivers/infiniband/core/rw.c | 53 +++++++++++++++++------- include/rdma/rw.h | 2 + net/sunrpc/xprtrdma/svc_rdma_transport.c | 8 +++- 3 files changed, 46 insertions(+), 17 deletions(-)
drivers/infiniband/core/rw.c +38 -15
@@ -651,34 +651,57 @@ unsigned int rdma_rw_mr_factor(struct ib_device *device, u32 port_num, }EXPORT_SYMBOL (rdma_rw_mr_factor); +/** +* rdma_rw_max_send_wr - compute max Send WRs needed for RDMA R/W contexts +* @dev: RDMA device +* @port_num: port number +* @max_rdma_ctxs: number of rdma_rw_ctx structures +* @create_flags: QP create flags (pass IB_QP_CREATE_INTEGRITY_EN if +* data integrity will be enabled on the QP) +* +* Returns the total number of Send Queue entries needed for +* @max_rdma_ctxs. The result accounts for memory registration and +* invalidation work requests when the device requires them. +* +* ULPs use this to size Send Queues and Send CQs before creating a +* Queue Pair. +*/ +unsigned int rdma_rw_max_send_wr (struct ib_device *dev,u32 port_num, +unsigned int max_rdma_ctxs,u32 create_flags) +{ +unsigned int factor =1 ; +unsigned int result; + +if (create_flags &IB_QP_CREATE_INTEGRITY_EN || +rdma_rw_can_use_mr (dev, port_num)) + factor +=2 ;/* reg + inv */ + +if (check_mul_overflow (factor, max_rdma_ctxs, &result)) +return UINT_MAX ; +return result; +} +EXPORT_SYMBOL (rdma_rw_max_send_wr); +void rdma_rw_init_qp (struct ib_device *dev,struct ib_qp_init_attr *attr) { -u32 factor; +unsigned int factor =1 ;WARN_ON_ONCE (attr->port_num ==0 );/* -* Each context needs at least one RDMA READ or WRITE WR. -* -* For some hardware we might need more, eventually we should ask the -* HCA driver for a multiplier here. -*/ - factor =1 ; - -/* -* If the device needs MRs to perform RDMA READ or WRITE operations, -* we'll need two additional MRs for the registrations and the -* invalidation. +* If the device uses MRs to perform RDMA READ or WRITE operations, +* or if data integrity is enabled, account for registration and +* invalidation work requests. */ if (attr->create_flags &IB_QP_CREATE_INTEGRITY_EN ||rdma_rw_can_use_mr (dev, attr->port_num)) - factor +=2 ;/* inv + reg */ + factor +=2 ;/* reg + inv */ attr->cap.max_send_wr += factor * attr->cap.max_rdma_ctxs;/* -* But maybe we were just too high in the sky and the device doesn't -* even support all we need, and we'll have to live with what we get.. +* The device might not support all we need, and we'll have to +* live with what we get. */ attr->cap.max_send_wr =min_t (u32, attr->cap.max_send_wr, dev->attrs.max_qp_wr);
include/rdma/rw.h +2 -0
@@ -66,6 +66,8 @@ int rdma_rw_ctx_post(struct rdma_rw_ctx *ctx, struct ib_qp *qp, u32 port_num,unsigned int rdma_rw_mr_factor (struct ib_device *device,u32 port_num,unsigned int maxpages); +unsigned int rdma_rw_max_send_wr (struct ib_device *dev,u32 port_num, +unsigned int max_rdma_ctxs,u32 create_flags);void rdma_rw_init_qp (struct ib_device *dev,struct ib_qp_init_attr *attr);int rdma_rw_init_mrs (struct ib_qp *qp,struct ib_qp_init_attr *attr);void rdma_rw_cleanup_mrs (struct ib_qp *qp);
net/sunrpc/xprtrdma/svc_rdma_transport.c +6 -2
@@ -462,7 +462,10 @@ static struct svc_xprt *svc_rdma_accept(struct svc_xprt *xprt) newxprt->sc_max_bc_requests =2 ; } -/* Arbitrary estimate of the needed number of rdma_rw contexts. +/* Estimate the needed number of rdma_rw contexts. The maximum +* Read and Write chunks have one segment each. Each request +* can involve one Read chunk and either a Write chunk or Reply +* chunk; thus a factor of three. */ maxpayload =min (xprt->xpt_server->sv_max_payload,RPCSVC_MAXPAYLOAD_RDMA );
@@ -470,7 +473,8 @@ static struct svc_xprt *svc_rdma_accept(struct svc_xprt *xprt)rdma_rw_mr_factor (dev, newxprt->sc_port_num, maxpayload >>PAGE_SHIFT ); - newxprt->sc_sq_depth = rq_depth + ctxts; + newxprt->sc_sq_depth = rq_depth + +rdma_rw_max_send_wr (dev, newxprt->sc_port_num, ctxts,0 );if (newxprt->sc_sq_depth > dev->attrs.max_qp_wr) newxprt->sc_sq_depth = dev->attrs.max_qp_wr;atomic_set (&newxprt->sc_sq_avail, newxprt->sc_sq_depth);
Signature · 1 line
2.51.0
PATCH 283/385 cxl: Fix premature commit_end increment on decoder commit failure
In reply to Sasha LevinFrom: Yuxiong Wang <[email protected]>
[ Upstream commit 7b6f9d9b1ea05c9c22570126547c780e8c6c3f62 ]
In cxl_decoder_commit(), commit_end is incremented before verifying whether the commit succeeded, and the CXL_DECODER_F_ENABLE bit in cxld->flags is only set after a successful commit. As a result, if the commit fails, commit_end has been incremented and cxld->reset() has no effect since the flag is not set, so commit_end remains incorrectly incremented. The inconsistency between commit_end and CXL_DECODER_F_ENABLE causes failure during subsequent either commit or reset operations.
Fix this by incrementing commit_end only after confirming the commit succeeded. Also, remove the ineffective cxld->reset() call. According to CXL Spec r4.0 8.2.4.20.12 Committing Decoder Programming, since cxld_await_commit() has cleared the decoder commit bit on failure, no additional reset is required.
[dj: Fixed commit log 80 char wrapping. ]
[dj: Fix "Fixes" tag to correct hash length. ]
[dj: Change spec to r4.0. ]
--- drivers/cxl/core/hdm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/cxl/core/hdm.c +1 -2
@@ -699,14 +699,13 @@ static int cxl_decoder_commit(struct cxl_decoder *cxld)writel (ctrl, hdm +CXL_HDM_DECODER0_CTRL_OFFSET (id));up_read (&cxl_dpa_rwsem); - port->commit_end++; rc =cxld_await_commit (hdm, cxld->id);if (rc) {dev_dbg (&port->dev,"%s: error %d committing decoder\n" ,dev_name (&cxld->dev), rc); - cxld->reset (cxld);return rc; } + port->commit_end++; cxld->flags |=CXL_DECODER_F_ENABLE ;return 0 ;
Signature · 1 line
2.51.0
PATCH 284/385 mtd: parsers: ofpart: fix OF node refcount leak in parse_fixed_partitions()
In reply to Sasha LevinFrom: Weigang He <[email protected]>
[ Upstream commit 7cce81df7d26d44123bd7620715c8349d96793d7 ]
of_get_child_by_name() returns a node pointer with refcount incremented, which must be released with of_node_put() when done. However, in parse_fixed_partitions(), when dedicated is true (i.e., a "partitions" subnode was found), the ofpart_node obtained from of_get_child_by_name() is never released on any code path.
Add of_node_put(ofpart_node) calls on all exit paths when dedicated is true to fix the reference count leak.
This bug was detected by our static analysis tool.
--- drivers/mtd/parsers/ofpart_core.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
drivers/mtd/parsers/ofpart_core.c +14 -2
@@ -77,6 +77,7 @@ static int parse_fixed_partitions(struct mtd_info *master, of_id =of_match_node (parse_ofpart_match_table, ofpart_node);if (dedicated && !of_id) {/* The 'partitions' subnode might be used by another parser */ +of_node_put (ofpart_node);return 0 ; }
@@ -91,12 +92,18 @@ static int parse_fixed_partitions(struct mtd_info *master, nr_parts++; } -if (nr_parts ==0 ) +if (nr_parts ==0 ) { +if (dedicated) +of_node_put (ofpart_node);return 0 ; + } parts =kcalloc (nr_parts,sizeof (*parts),GFP_KERNEL ); -if (!parts) +if (!parts) { +if (dedicated) +of_node_put (ofpart_node);return -ENOMEM ; + } i =0 ;for_each_child_of_node (ofpart_node, pp) {
@@ -175,6 +182,9 @@ static int parse_fixed_partitions(struct mtd_info *master,if (quirks && quirks->post_parse) quirks->post_parse (master, parts, nr_parts); +if (dedicated) +of_node_put (ofpart_node); + *pparts = parts;return nr_parts;
@@ -183,6 +193,8 @@ static int parse_fixed_partitions(struct mtd_info *master, master->name, pp, mtd_node); ret = -EINVAL ; ofpart_none: +if (dedicated) +of_node_put (ofpart_node);of_node_put (pp);kfree (parts);return ret;
Signature · 1 line
2.51.0
PATCH 285/385 mtd: spinand: Fix kernel doc
In reply to Sasha LevinFrom: Miquel Raynal <[email protected]>
[ Upstream commit a57b1f07d2d35843a7ada30c8cf9a215c0931868 ]
The @data buffer is 5 bytes, not 4, it has been extended for the need of devices with an extra ID bytes.
--- include/linux/mtd/spinand.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/mtd/spinand.h +1 -1
@@ -195,7 +195,7 @@ struct spinand_device;/** * struct spinand_id - SPI NAND id structure -* @data: buffer containing the id bytes. Currently 4 bytes large, but can +* @data: buffer containing the id bytes. Currently 5 bytes large, but can * be extended if required * @len: ID length */
Signature · 1 line
2.51.0
PATCH 286/385 power: supply: pm8916_lbc: Fix use-after-free for extcon in IRQ handler
In reply to Sasha LevinFrom: Waqar Hameed <[email protected]>
[ Upstream commit 23067259919663580c6f81801847cfc7bd54fd1f ]
Using the devm_ variant for requesting IRQ _before_ the devm_ variant for allocating/registering the extcon handle, means that the extcon handle will be deallocated/unregistered _before_ the interrupt handler (since devm_ naturally deallocates in reverse allocation order). This means that during removal, there is a race condition where an interrupt can fire just _after_ the extcon handle has been freed, *but* just _before_ the corresponding unregistration of the IRQ handler has run.
This will lead to the IRQ handler calling extcon_set_state_sync() with a freed extcon handle. Which usually crashes the system or otherwise silently corrupts the memory...
Fix this racy use-after-free by making sure the IRQ is requested _after_ the registration of the extcon handle.
--- drivers/power/supply/pm8916_lbc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/power/supply/pm8916_lbc.c +5 -5
@@ -327,11 +327,6 @@ static int pm8916_lbc_charger_probe(struct platform_device *pdev)if (irq <0 )return irq; - ret =devm_request_threaded_irq (dev, irq,NULL , pm8916_lbc_charger_state_changed_irq, -IRQF_ONESHOT ,"pm8916_lbc" , chg); -if (ret) -return ret; - chg->edev =devm_extcon_dev_allocate (dev, pm8916_lbc_charger_cable);if (IS_ERR (chg->edev))return PTR_ERR (chg->edev);
@@ -340,6 +335,11 @@ static int pm8916_lbc_charger_probe(struct platform_device *pdev)if (ret <0 )return dev_err_probe (dev, ret,"failed to register extcon device\n" ); + ret =devm_request_threaded_irq (dev, irq,NULL , pm8916_lbc_charger_state_changed_irq, +IRQF_ONESHOT ,"pm8916_lbc" , chg); +if (ret) +return ret; + ret =regmap_read (chg->regmap, chg->reg[LBC_USB ] +PM8916_INT_RT_STS , &tmp);if (ret) goto comm_error;
Signature · 1 line
2.51.0
PATCH 287/385 power: supply: qcom_battmgr: Recognize "LiP" as lithium-polymer
In reply to Sasha LevinFrom: Val Packett <[email protected]>
[ Upstream commit c655f45480637aee326b5bd96488d35ab90db2b0 ]
On the Dell Latitude 7455, the firmware uses "LiP" with a lowercase 'i' for the battery chemistry type, but only all-uppercase "LIP" was being recognized. Add the CamelCase variant to the check to fix the "Unknown battery technology" warning.
--- drivers/power/supply/qcom_battmgr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/power/supply/qcom_battmgr.c +2 -1
@@ -984,7 +984,8 @@ static unsigned int qcom_battmgr_sc8280xp_parse_technology(const char *chemistryif ((!strncmp (chemistry,"LIO" ,BATTMGR_CHEMISTRY_LEN )) || (!strncmp (chemistry,"OOI" ,BATTMGR_CHEMISTRY_LEN )))return POWER_SUPPLY_TECHNOLOGY_LION ; -if (!strncmp (chemistry,"LIP" ,BATTMGR_CHEMISTRY_LEN )) +if (!strncmp (chemistry,"LIP" ,BATTMGR_CHEMISTRY_LEN ) || + !strncmp (chemistry,"LiP" ,BATTMGR_CHEMISTRY_LEN ))return POWER_SUPPLY_TECHNOLOGY_LIPO ;pr_err ("Unknown battery technology '%s'\n" , chemistry);
Signature · 1 line
2.51.0
PATCH 288/385 RDMA/uverbs: Add __GFP_NOWARN to ib_uverbs_unmarshall_recv() kmalloc
In reply to Sasha LevinFrom: Yi Liu <[email protected]>
[ Upstream commit 58b604dfc7bb753f91bc0ccd3fa705e14e6edfb4 ]
Since wqe_size in ib_uverbs_unmarshall_recv() is user-provided and already validated, but can still be large, add __GFP_NOWARN to suppress memory allocation warnings for large sizes, consistent with the similar fix in ib_uverbs_post_send().
--- drivers/infiniband/core/uverbs_cmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/core/uverbs_cmd.c +1 -1
@@ -2224,7 +2224,7 @@ ib_uverbs_unmarshall_recv(struct uverbs_req_iter *iter, u32 wr_count,if (ret)return ERR_PTR (ret); - user_wr =kmalloc (wqe_size,GFP_KERNEL ); + user_wr =kmalloc (wqe_size,GFP_KERNEL | __GFP_NOWARN);if (!user_wr)return ERR_PTR (-ENOMEM );
Signature · 1 line
2.51.0
PATCH 289/385 pNFS: fix a missing wake up while waiting on NFS_LAYOUT_DRAIN
In reply to Sasha LevinFrom: Olga Kornievskaia <[email protected]>
[ Upstream commit 5248d8474e594d156bee1ed10339cc16e207a28b ]
It is possible to have a task get stuck on waiting on the NFS_LAYOUT_DRAIN in the following scenario
1. cpu a: waiter test NFS_LAYOUT_DRAIN (1) and plh_outstanding (1)
2. cpu b: atomic_dec_and_test() -> clear bit -> wake up
3. cpu c: sets NFS_LAYOUT_DRAIN again
4. cpu a: calls wait_on_bit() sleeps forever.
To expand on this we have say 2 outstanding pnfs write IO that get ESTALE which causes both to call pnfs_destroy_layout() and set the NFS_LAYOUT_DRAIN bit but the 1st one doesn't call the pnfs_put_layout_hdr() yet (as that would prevent the 2nd ESTALE write from trying to call pnfs_destroy_layout()). If the 1st ESTALE write is the one that initially sets the NFS_LAYOUT_DRAIN so that new IO on this file initiates new LAYOUTGET. Another new write would find NFS_LAYOUT_DRAIN set and phl_outstanding>0 (step 1) and would wait_on_bit(). LAYOUTGET completes doing step 2. Now, the 2nd of ESTALE writes is calling pnfs_destory_layout() and set the NFS_LAYOUT_DRAIN bit (step 3). Finally, the waiting write wakes up to check the bit and goes back to sleep.
The problem revolves around the fact that if NFS_LAYOUT_INVALID_STID was already set, it should not do the work of pnfs_mark_layout_stateid_invalid(), thus NFS_LAYOUT_DRAIN will not be set more than once for an invalid layout.
--- fs/nfs/pnfs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/nfs/pnfs.c +2 -1
@@ -465,7 +465,8 @@ pnfs_mark_layout_stateid_invalid(struct pnfs_layout_hdr *lo, };struct pnfs_layout_segment *lseg, *next; -set_bit (NFS_LAYOUT_INVALID_STID , &lo->plh_flags); +if (test_and_set_bit (NFS_LAYOUT_INVALID_STID , &lo->plh_flags)) +return !list_empty (&lo->plh_segs);clear_bit (NFS_INO_LAYOUTCOMMIT , &NFS_I (lo->plh_inode)->flags);list_for_each_entry_safe (lseg, next, &lo->plh_segs, pls_list)pnfs_clear_lseg_state (lseg, lseg_list);
Signature · 1 line
2.51.0
PATCH 290/385 scsi: smartpqi: Fix memory leak in pqi_report_phys_luns()
In reply to Sasha LevinFrom: Zilin Guan <[email protected]>
[ Upstream commit 41b37312bd9722af77ec7817ccf22d7a4880c289 ]
pqi_report_phys_luns() fails to release the rpl_list buffer when encountering an unsupported data format or when the allocation for rpl_16byte_wwid_list fails. These early returns bypass the cleanup logic, leading to memory leaks.
Consolidate the error handling by adding an out_free_rpl_list label and use goto statements to ensure rpl_list is consistently freed on failure.
Compile tested only. Issue found using a prototype static analysis tool and code review.
--- drivers/scsi/smartpqi/smartpqi_init.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/scsi/smartpqi/smartpqi_init.c +10 -3
@@ -1239,7 +1239,8 @@ static inline int pqi_report_phys_luns(struct pqi_ctrl_info *ctrl_info, void **bdev_err (&ctrl_info->pci_dev->dev,"RPL returned unsupported data format %u\n" , rpl_response_format); -return -EINVAL ; + rc = -EINVAL ; + goto out_free_rpl_list; }else {dev_warn (&ctrl_info->pci_dev->dev,"RPL returned extended format 2 instead of 4\n" );
@@ -1251,8 +1252,10 @@ static inline int pqi_report_phys_luns(struct pqi_ctrl_info *ctrl_info, void **b rpl_16byte_wwid_list =kmalloc (struct_size (rpl_16byte_wwid_list, lun_entries, num_physicals),GFP_KERNEL ); -if (!rpl_16byte_wwid_list) -return -ENOMEM ; +if (!rpl_16byte_wwid_list) { + rc = -ENOMEM ; + goto out_free_rpl_list; + }put_unaligned_be32 (num_physicals *sizeof (struct report_phys_lun_16byte_wwid ), &rpl_16byte_wwid_list->header.list_length);
@@ -1273,6 +1276,10 @@ static inline int pqi_report_phys_luns(struct pqi_ctrl_info *ctrl_info, void **b *buffer = rpl_16byte_wwid_list;return 0 ; + +out_free_rpl_list: +kfree (rpl_list); +return rc; }static inline int pqi_report_logical_luns (struct pqi_ctrl_info *ctrl_info,void **buffer)
Signature · 1 line
2.51.0
PATCH 291/385 scsi: ufs: host: mediatek: Require CONFIG_PM
In reply to Sasha LevinFrom: Arnd Bergmann <[email protected]>
[ Upstream commit bbb8d98fb4536594cb104fd630ea0f7dce3771d6 ]
The added print statement from a recent fix causes the driver to fail building when CONFIG_PM is disabled:
drivers/ufs/host/ufs-mediatek.c: In function 'ufs_mtk_resume':drivers/ufs/host/ufs-mediatek.c:1890:40: error: 'struct dev_pm_info' has no member named 'request'
1890 | hba->dev->power.request,
It seems unlikely that the driver can work at all without CONFIG_PM, so just add a dependency and remove the existing ifdef checks, rather than adding another ifdef.
--- drivers/ufs/host/Kconfig | 1 + drivers/ufs/host/ufs-mediatek.c | 12 +++--------- include/ufs/ufshcd.h | 4 ---- 3 files changed, 4 insertions(+), 13 deletions(-)
drivers/ufs/host/Kconfig +1 -0
@@ -72,6 +72,7 @@ config SCSI_UFS_QCOM config SCSI_UFS_MEDIATEK tristate "Mediatek specific hooks to UFS controller platform driver" depends on SCSI_UFSHCD_PLATFORM && ARCH_MEDIATEK + depends on PM depends on RESET_CONTROLLER select PHY_MTK_UFS select RESET_TI_SYSCON
drivers/ufs/host/ufs-mediatek.c +3 -9
@@ -1987,7 +1987,6 @@ static void ufs_mtk_remove(struct platform_device *pdev)ufshcd_pltfrm_remove (pdev); } -#ifdef CONFIG_PM_SLEEP static int ufs_mtk_system_suspend (struct device *dev) {struct ufs_hba *hba =dev_get_drvdata (dev);
@@ -2034,9 +2033,7 @@ static int ufs_mtk_system_resume(struct device *dev)return ret; } -#endif -#ifdef CONFIG_PM static int ufs_mtk_runtime_suspend (struct device *dev) {struct ufs_hba *hba =dev_get_drvdata (dev);
@@ -2067,13 +2064,10 @@ static int ufs_mtk_runtime_resume(struct device *dev)return ufshcd_runtime_resume (dev); } -#endif static const struct dev_pm_ops ufs_mtk_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(ufs_mtk_system_suspend, - ufs_mtk_system_resume) -SET_RUNTIME_PM_OPS (ufs_mtk_runtime_suspend, - ufs_mtk_runtime_resume,NULL ) + SYSTEM_SLEEP_PM_OPS(ufs_mtk_system_suspend, ufs_mtk_system_resume) +RUNTIME_PM_OPS (ufs_mtk_runtime_suspend, ufs_mtk_runtime_resume,NULL ) .prepare = ufshcd_suspend_prepare, .complete = ufshcd_resume_complete, };
@@ -2083,7 +2077,7 @@ static struct platform_driver ufs_mtk_pltform = { .remove_new = ufs_mtk_remove, .driver = { .name = "ufshcd-mtk", - .pm = &ufs_mtk_pm_ops, + .pm = pm_ptr(&ufs_mtk_pm_ops), .of_match_table = ufs_mtk_of_match, }, };
include/ufs/ufshcd.h +0 -4
@@ -1356,17 +1356,13 @@ static inline void *ufshcd_get_variant(struct ufs_hba *hba)return hba->priv; } -#ifdef CONFIG_PM extern int ufshcd_runtime_suspend (struct device *dev);extern int ufshcd_runtime_resume (struct device *dev); -#endif -#ifdef CONFIG_PM_SLEEP extern int ufshcd_system_suspend (struct device *dev);extern int ufshcd_system_resume (struct device *dev);extern int ufshcd_system_freeze (struct device *dev);extern int ufshcd_system_thaw (struct device *dev);extern int ufshcd_system_restore (struct device *dev); -#endif extern int ufshcd_dme_configure_adapt(struct ufs_hba *hba, int agreed_gear,
Signature · 1 line
2.51.0
PATCH 292/385 scsi: csiostor: Fix dereference of null pointer rn
In reply to Sasha LevinFrom: Colin Ian King <[email protected]>
[ Upstream commit 1982257570b84dc33753d536dd969fd357a014e9 ]
The error exit path when rn is NULL ends up deferencing the null pointer rn via the use of the macro CSIO_INC_STATS. Fix this by adding a new error return path label after the use of the macro to avoid the deference.
--- drivers/scsi/csiostor/csio_scsi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/scsi/csiostor/csio_scsi.c +2 -1
@@ -2074,7 +2074,7 @@ csio_eh_lun_reset_handler(struct scsi_cmnd *cmnd)struct csio_scsi_level_data sld;if (!rn) - goto fail; + goto fail_ret;csio_dbg (hw,"Request to reset LUN:%llu (ssni:0x%x tgtid:%d)\n" , cmnd->device->lun, rn->flowid, rn->scsi_id);
@@ -2220,6 +2220,7 @@ csio_eh_lun_reset_handler(struct scsi_cmnd *cmnd)csio_put_scsi_ioreq_lock (hw, scsim, ioreq); fail:CSIO_INC_STATS (rn, n_lun_rst_fail); +fail_ret:return FAILED ; }
Signature · 1 line
2.51.0
PATCH 293/385 nvdimm: virtio_pmem: serialize flush requests
In reply to Sasha LevinFrom: Li Chen <[email protected]>
[ Upstream commit a9ba6733c7f1096c4506bf4e34a546e07242df74 ]
Under heavy concurrent flush traffic, virtio-pmem can overflow its request virtqueue (req_vq): virtqueue_add_sgs() starts returning -ENOSPC and the driver logs "no free slots in the virtqueue". Shortly after that the device enters VIRTIO_CONFIG_S_NEEDS_RESET and flush requests fail with "virtio pmem device needs a reset".
Serialize virtio_pmem_flush() with a per-device mutex so only one flush request is in-flight at a time. This prevents req_vq descriptor overflow under high concurrency.
Reproducer (guest with virtio-pmem):
- mkfs.ext4 -F /dev/pmem0
- mount -t ext4 -o dax,noatime /dev/pmem0 /mnt/bench
- fio: ioengine=io_uring rw=randwrite bs=4k iodepth=64 numjobs=64 direct=1 fsync=1 runtime=30s time_based=1
- dmesg: "no free slots in the virtqueue"
"virtio pmem device needs a reset"
--- drivers/nvdimm/nd_virtio.c | 3 ++- drivers/nvdimm/virtio_pmem.c | 1 + drivers/nvdimm/virtio_pmem.h | 4 ++++ 3 files changed, 7 insertions(+), 1 deletion(-)
drivers/nvdimm/nd_virtio.c +2 -1
@@ -44,6 +44,8 @@ static int virtio_pmem_flush(struct nd_region *nd_region)unsigned long flags;int err, err1; +guard (mutex)(&vpmem->flush_lock); +/* * Don't bother to submit the request to the device if the device is * not activated.
@@ -53,7 +55,6 @@ static int virtio_pmem_flush(struct nd_region *nd_region)return -EIO ; } -might_sleep (); req_data =kmalloc (sizeof (*req_data),GFP_KERNEL );if (!req_data)return -ENOMEM ;
drivers/nvdimm/virtio_pmem.c +1 -0
@@ -64,6 +64,7 @@ static int virtio_pmem_probe(struct virtio_device *vdev) goto out_err; } +mutex_init (&vpmem->flush_lock); vpmem->vdev = vdev; vdev->priv = vpmem; err =init_vq (vpmem);
drivers/nvdimm/virtio_pmem.h +4 -0
@@ -13,6 +13,7 @@#include <linux/module.h> #include <uapi/linux/virtio_pmem.h> #include <linux/libnvdimm.h> +#include <linux/mutex.h> #include <linux/spinlock.h> struct virtio_pmem_request {
@@ -35,6 +36,9 @@ struct virtio_pmem {/* Virtio pmem request queue */ struct virtqueue *req_vq; +/* Serialize flush requests to the device. */ +struct mutex flush_lock; +/* nvdimm bus registers virtio pmem device */ struct nvdimm_bus *nvdimm_bus;struct nvdimm_bus_descriptor nd_desc;
Signature · 1 line
2.51.0
PATCH 294/385 fs/nfs: Fix readdir slow-start regression
In reply to Sasha LevinFrom: Sagi Grimberg <[email protected]>
[ Upstream commit 42e7c876b182da65723700f6bc507a8aecb10d3b ]
Commit 580f236737d1 ("NFS: Adjust the amount of readahead performed by NFS readdir") reduces the amount of readahead names caching done by the client.
The downside of this approach is READDIR now may suffer from a slow-start issue, where initially it will fetch names that fit in a single page, then in 2, 4, 8 until the maximum supported transfer size (usually 1M).
This patch tries to take a balanced approach between mitigating the slow-start issue still maintaining some efficiency gains.
--- fs/nfs/dir.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/nfs/dir.c +2 -2
@@ -72,7 +72,7 @@ const struct address_space_operations nfs_dir_aops = { .free_folio = nfs_readdir_clear_array, }; -#define NFS_INIT_DTSIZE PAGE_SIZE +#define NFS_INIT_DTSIZE SZ_64Kstatic struct nfs_open_dir_context *alloc_nfs_open_dir_context (struct inode *dir)
@@ -83,7 +83,7 @@ alloc_nfs_open_dir_context(struct inode *dir) ctx =kzalloc (sizeof (*ctx),GFP_KERNEL_ACCOUNT );if (ctx !=NULL ) { ctx->attr_gencount = nfsi->attr_gencount; - ctx->dtsize =NFS_INIT_DTSIZE ; + ctx->dtsize =min (NFS_SERVER (dir)->dtsize,NFS_INIT_DTSIZE );spin_lock (&dir->i_lock);if (list_empty (&nfsi->open_files) && (nfsi->cache_validity &NFS_INO_DATA_INVAL_DEFER ))
Signature · 1 line
2.51.0
PATCH 295/385 tracing: Properly process error handling in event_hist_trigger_parse()
In reply to Sasha LevinFrom: Miaoqian Lin <[email protected]>
[ Upstream commit 0550069cc25f513ce1f109c88f7c1f01d63297db ]
Memory allocated with trigger_data_alloc() requires trigger_data_free() for proper cleanup.
Replace kfree() with trigger_data_free() to fix this.
Found via static analysis and code review.
This isn't a real bug due to the current code basically being an open coded version of trigger_data_free() without the synchronization. The synchronization isn't needed as this is the error path of creation and there's nothing to synchronize against yet. Replace the kfree() to be consistent with the allocation.
--- kernel/trace/trace_events_hist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace_events_hist.c +1 -1
@@ -6881,7 +6881,7 @@ static int event_hist_trigger_parse(struct event_command *cmd_ops,remove_hist_vars (hist_data); -kfree (trigger_data); +trigger_data_free (trigger_data);destroy_hist_data (hist_data); goto out;
Signature · 1 line
2.51.0
PATCH 296/385 tracing: Remove duplicate ENABLE_EVENT_STR and DISABLE_EVENT_STR macros
In reply to Sasha LevinFrom: Steven Rostedt <[email protected]>
[ Upstream commit 9df0e49c5b9b8d051529be9994e4f92f2d20be6f ]
The macros ENABLE_EVENT_STR and DISABLE_EVENT_STR were added to trace.h so that more than one file can have access to them, but was never removed from their original location. Remove the duplicates.
--- kernel/trace/trace_events.c | 5 ----- 1 file changed, 5 deletions(-)
kernel/trace/trace_events.c +0 -5
@@ -3609,11 +3609,6 @@ void trace_put_event_file(struct trace_event_file *file)EXPORT_SYMBOL_GPL (trace_put_event_file); #ifdef CONFIG_DYNAMIC_FTRACE - -/* Avoid typos */ -#define ENABLE_EVENT_STR "enable_event" -#define DISABLE_EVENT_STR "disable_event" - struct event_probe_data { struct trace_event_file *file; unsigned long count;
Signature · 1 line
2.51.0
PATCH 297/385 fbdev: of_display_timing: Fix device node reference leak in of_get_display_timings()
In reply to Sasha LevinFrom: Felix Gu <[email protected]>
[ Upstream commit c39ee2d264f98efa14aa46c9942114cb03c7baa6 ]
Use for_each_child_of_node_scoped instead of for_each_child_of_node to ensure automatic of_node_put on early exit paths, preventing device node reference leak.
--- drivers/video/of_display_timing.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/video/of_display_timing.c +3 -3
@@ -195,7 +195,7 @@ struct display_timings *of_get_display_timings(const struct device_node *np) disp->num_timings =0 ; disp->native_mode =0 ; -for_each_child_of_node (timings_np, entry) { +for_each_child_of_node_scoped (timings_np, child) {struct display_timing *dt;int r;
@@ -206,7 +206,7 @@ struct display_timings *of_get_display_timings(const struct device_node *np) goto timingfail; } - r =of_parse_display_timing (entry, dt); + r =of_parse_display_timing (child, dt);if (r) {/* * to not encourage wrong devicetrees, fail in case of
@@ -218,7 +218,7 @@ struct display_timings *of_get_display_timings(const struct device_node *np) goto timingfail; } -if (native_mode == entry) +if (native_mode == child) disp->native_mode = disp->num_timings; disp->timings[disp->num_timings] = dt;
Signature · 1 line
2.51.0
PATCH 298/385 fbdev: au1200fb: Fix a memory leak in au1200fb_drv_probe()
In reply to Sasha LevinFrom: Felix Gu <[email protected]>
[ Upstream commit ce4e25198a6aaaaf36248edf8daf3d744ec8e309 ]
In au1200fb_drv_probe(), when platform_get_irq fails(), it directly returns from the function with an error code, which causes a memory leak.
Replace it with a goto label to ensure proper cleanup.
--- drivers/video/fbdev/au1200fb.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/video/fbdev/au1200fb.c +4 -2
@@ -1724,8 +1724,10 @@ static int au1200fb_drv_probe(struct platform_device *dev)/* Now hook interrupt too */ irq =platform_get_irq (dev,0 ); -if (irq <0 ) -return irq; +if (irq <0 ) { + ret = irq; + goto failed; + } ret =request_irq (irq, au1200fb_handle_irq,IRQF_SHARED ,"lcd" , (void *)dev);
Signature · 1 line
2.51.0
PATCH 299/385 clk: qcom: gcc-sm8550: Use floor ops for SDCC RCGs
In reply to Sasha LevinFrom: Vladimir Zapolskiy <[email protected]>
[ Upstream commit 1c06e3956054fb5a0930f07b02726b1774b6c700 ]
In line with commit a27ac3806b0a ("clk: qcom: gcc-sm8450: Use floor ops for SDCC RCGs") done to fix issues with overclocked SD cards on SM8450 powered boards set floor clock operations for SDCC RCGs on SM8550.
This change fixes initialization of some SD cards, where the problem is manifested by the SDHC driver:
mmc0: Card appears overclocked; req 50000000 Hz, actual 100000000 Hz
mmc0: error -110 whilst initialising SD card
--- drivers/clk/qcom/gcc-sm8550.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/clk/qcom/gcc-sm8550.c +2 -2
@@ -1025,7 +1025,7 @@ static struct clk_rcg2 gcc_sdcc2_apps_clk_src = { .parent_data = gcc_parent_data_9, .num_parents = ARRAY_SIZE(gcc_parent_data_9), .flags = CLK_SET_RATE_PARENT, - .ops = &clk_rcg2_shared_ops, + .ops = &clk_rcg2_shared_floor_ops, }, };
@@ -1048,7 +1048,7 @@ static struct clk_rcg2 gcc_sdcc4_apps_clk_src = { .parent_data = gcc_parent_data_0, .num_parents = ARRAY_SIZE(gcc_parent_data_0), .flags = CLK_SET_RATE_PARENT, - .ops = &clk_rcg2_shared_ops, + .ops = &clk_rcg2_shared_floor_ops, }, };
Signature · 1 line
2.51.0
PATCH 300/385 clk: qcom: gcc-sm8650: Use floor ops for SDCC RCGs
In reply to Sasha LevinFrom: Vladimir Zapolskiy <[email protected]>
[ Upstream commit 8c4415fd17cd5979c31a4bf303acc702e9726033 ]
In line with commit a27ac3806b0a ("clk: qcom: gcc-sm8450: Use floor ops for SDCC RCGs") done to fix issues with overclocked SD cards on SM8450 powered boards set floor clock operations for SDCC RCGs on SM8650.
This change fixes initialization of some SD cards, where the problem is manifested by the SDHC driver:
mmc0: Card appears overclocked; req 50000000 Hz, actual 100000000 Hz
mmc0: error -110 whilst initialising SD card
--- drivers/clk/qcom/gcc-sm8650.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/clk/qcom/gcc-sm8650.c +2 -2
@@ -1257,7 +1257,7 @@ static struct clk_rcg2 gcc_sdcc2_apps_clk_src = { .parent_data = gcc_parent_data_11, .num_parents = ARRAY_SIZE(gcc_parent_data_11), .flags = CLK_SET_RATE_PARENT, - .ops = &clk_rcg2_shared_ops, + .ops = &clk_rcg2_shared_floor_ops, }, };
@@ -1279,7 +1279,7 @@ static struct clk_rcg2 gcc_sdcc4_apps_clk_src = { .parent_data = gcc_parent_data_0, .num_parents = ARRAY_SIZE(gcc_parent_data_0), .flags = CLK_SET_RATE_PARENT, - .ops = &clk_rcg2_shared_ops, + .ops = &clk_rcg2_shared_floor_ops, }, };
Signature · 1 line
2.51.0
PATCH 301/385 clk: qcom: rcg2: compute 2d using duty fraction directly
In reply to Sasha LevinFrom: Taniya Das <[email protected]>
[ Upstream commit d6205a1878dd4cc9664c4b4829b68a29c0426efc ]
The duty-cycle calculation in clk_rcg2_set_duty_cycle() currently derives an intermediate percentage duty_per = (num * 100) / den and then computes:
d = DIV_ROUND_CLOSEST(n * duty_per * 2, 100);
This introduces integer truncation at the percentage step (division by den) and a redundant scaling by 100, which can reduce precision for large den and skew the final rounding.
Compute 2d directly from the duty fraction to preserve precision and avoid the unnecessary scaling:
d = DIV_ROUND_CLOSEST(n * duty->num * 2, duty->den);
This keeps the intended formula d ≈ n * 2 * (num/den) while performing a single, final rounded division, improving accuracy especially for small duty cycles or large denominators. It also removes the unused duty_per variable, simplifying the code.
There is no functional changes beyond improved numerical accuracy.
--- drivers/clk/qcom/clk-rcg2.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/clk/qcom/clk-rcg2.c +2 -4
@@ -587,7 +587,7 @@ static int clk_rcg2_get_duty_cycle(struct clk_hw *hw, struct clk_duty *duty)static int clk_rcg2_set_duty_cycle (struct clk_hw *hw,struct clk_duty *duty) {struct clk_rcg2 *rcg =to_clk_rcg2 (hw); -u32 notn_m, n, m, d, not2d, mask, duty_per, cfg; +u32 notn_m, n, m, d, not2d, mask, cfg;int ret;/* Duty-cycle cannot be modified for non-MND RCGs */
@@ -606,10 +606,8 @@ static int clk_rcg2_set_duty_cycle(struct clk_hw *hw, struct clk_duty *duty) n = (~(notn_m) + m) & mask; - duty_per = (duty->num *100 ) / duty->den; -/* Calculate 2d value */ - d =DIV_ROUND_CLOSEST (n * duty_per *2 ,100 ); + d =DIV_ROUND_CLOSEST (n * duty->num *2 , duty->den);/* * Check bit widths of 2d. If D is too big reduce duty cycle.
Signature · 1 line
2.51.0
PATCH 302/385 clk: meson: gxbb: Limit the HDMI PLL OD to /4 on GXL/GXM SoCs
In reply to Sasha LevinFrom: Martin Blumenstingl <[email protected]>
[ Upstream commit 5b1a43950fd3162af0ce52b13c14a2d29b179d4f ]
GXBB has the HDMI PLL OD in the HHI_HDMI_PLL_CNTL2 register while for GXL/GXM the OD has moved to HHI_HDMI_PLL_CNTL3. At first glance the rest of the OD setup seems identical.
However, looking at the downstream kernel sources as well as testing shows that GXL only supports three OD values:
- register value 0 means: divide by 1
- register value 1 means: divide by 2
- register value 2 means: divide by 4
Using register value 3 (which on GXBB means: divide by 8) still divides by 4 as verified using meson-clk-measure. Downstream sources are also only using OD register values 0, 1 and 2 for GXL (while for GXBB the downstream kernel sources are also using value 3).
Add clk_div_table and have it replace the CLK_DIVIDER_POWER_OF_TWO flag to make the kernel's view of this register match with how the hardware actually works.
--- drivers/clk/meson/gxbb.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
drivers/clk/meson/gxbb.c +14 -3
@@ -318,12 +318,23 @@ static struct clk_regmap gxbb_hdmi_pll = { }, }; +/* +* GXL hdmi OD dividers are POWER_OF_TWO dividers but limited to /4. +* A divider value of 3 should map to /8 but instead map /4 so ignore it. +*/ +static const struct clk_div_table gxl_hdmi_pll_od_div_table[] = { + { .val =0 , .div =1 }, + { .val =1 , .div =2 }, + { .val =2 , .div =4 }, + {/* sentinel */ } +}; +static struct clk_regmap gxl_hdmi_pll_od = { .data = &(struct clk_regmap_div_data ){ .offset =HHI_HDMI_PLL_CNTL +8 , .shift =21 , .width =2 , - .flags =CLK_DIVIDER_POWER_OF_TWO , + .table = gxl_hdmi_pll_od_div_table, }, .hw.init = &(struct clk_init_data ){ .name ="hdmi_pll_od" ,
@@ -341,7 +352,7 @@ static struct clk_regmap gxl_hdmi_pll_od2 = { .offset = HHI_HDMI_PLL_CNTL + 8, .shift = 23, .width = 2, - .flags = CLK_DIVIDER_POWER_OF_TWO, + .table = gxl_hdmi_pll_od_div_table, }, .hw.init = &(struct clk_init_data ){ .name ="hdmi_pll_od2" ,
@@ -359,7 +370,7 @@ static struct clk_regmap gxl_hdmi_pll = { .offset = HHI_HDMI_PLL_CNTL + 8, .shift = 19, .width = 2, - .flags = CLK_DIVIDER_POWER_OF_TWO, + .table = gxl_hdmi_pll_od_div_table, }, .hw.init = &(struct clk_init_data ){ .name ="hdmi_pll" ,
Signature · 1 line
2.51.0
PATCH 303/385 clk: qcom: gcc-sm8450: Update the SDCC RCGs to use shared_floor_ops
In reply to Sasha LevinFrom: Jagadeesh Kona <[email protected]>
[ Upstream commit 89428516f99572a9c37ebbb7859595881e7025a0 ]
Use shared_floor_ops for the SDCC RCGs so the RCG is safely parked during disable and the new parent configuration is programmed in hardware only when the new parent is enabled, avoiding cases where the RCG configuration fails to update.
--- drivers/clk/qcom/gcc-sm8450.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/clk/qcom/gcc-sm8450.c +2 -2
@@ -936,7 +936,7 @@ static struct clk_rcg2 gcc_sdcc2_apps_clk_src = { .parent_data = gcc_parent_data_7, .num_parents = ARRAY_SIZE(gcc_parent_data_7), .flags = CLK_SET_RATE_PARENT, - .ops = &clk_rcg2_floor_ops, + .ops = &clk_rcg2_shared_floor_ops, }, };
@@ -959,7 +959,7 @@ static struct clk_rcg2 gcc_sdcc4_apps_clk_src = { .parent_data = gcc_parent_data_0, .num_parents = ARRAY_SIZE(gcc_parent_data_0), .flags = CLK_SET_RATE_PARENT, - .ops = &clk_rcg2_floor_ops, + .ops = &clk_rcg2_shared_floor_ops, }, };
Signature · 1 line
2.51.0
PATCH 304/385 clk: qcom: gcc-sm4450: Update the SDCC RCGs to use shared_floor_ops
In reply to Sasha LevinFrom: Jagadeesh Kona <[email protected]>
[ Upstream commit 458e8a082186335380a9ab83003a385aec9bb254 ]
Use shared_floor_ops for the SDCC RCGs so the RCG is safely parked during disable and the new parent configuration is programmed in hardware only when the new parent is enabled, avoiding cases where the RCG configuration fails to update.
--- drivers/clk/qcom/gcc-sm4450.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/clk/qcom/gcc-sm4450.c +3 -3
@@ -769,7 +769,7 @@ static struct clk_rcg2 gcc_sdcc1_apps_clk_src = { .parent_data = gcc_parent_data_4, .num_parents = ARRAY_SIZE(gcc_parent_data_4), .flags = CLK_SET_RATE_PARENT, - .ops = &clk_rcg2_floor_ops, + .ops = &clk_rcg2_shared_floor_ops, }, };
@@ -791,7 +791,7 @@ static struct clk_rcg2 gcc_sdcc1_ice_core_clk_src = { .parent_data = gcc_parent_data_4, .num_parents = ARRAY_SIZE(gcc_parent_data_4), .flags = CLK_SET_RATE_PARENT, - .ops = &clk_rcg2_floor_ops, + .ops = &clk_rcg2_shared_floor_ops, }, };
@@ -815,7 +815,7 @@ static struct clk_rcg2 gcc_sdcc2_apps_clk_src = { .parent_data = gcc_parent_data_6, .num_parents = ARRAY_SIZE(gcc_parent_data_6), .flags = CLK_SET_RATE_PARENT, - .ops = &clk_rcg2_floor_ops, + .ops = &clk_rcg2_shared_floor_ops, }, };
Signature · 1 line
2.51.0
PATCH 305/385 clk: qcom: gcc-sdx75: Update the SDCC RCGs to use shared_floor_ops
In reply to Sasha LevinFrom: Jagadeesh Kona <[email protected]>
[ Upstream commit 4b057462bb61a6571608ba393e6e018c9da9c9c3 ]
Use shared_floor_ops for the SDCC RCGs so the RCG is safely parked during disable and the new parent configuration is programmed in hardware only when the new parent is enabled, avoiding cases where the RCG configuration fails to update.
--- drivers/clk/qcom/gcc-sdx75.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/clk/qcom/gcc-sdx75.c +2 -2
@@ -1033,7 +1033,7 @@ static struct clk_rcg2 gcc_sdcc1_apps_clk_src = { .name = "gcc_sdcc1_apps_clk_src", .parent_data = gcc_parent_data_17, .num_parents = ARRAY_SIZE(gcc_parent_data_17), - .ops = &clk_rcg2_floor_ops, + .ops = &clk_rcg2_shared_floor_ops, }, };
@@ -1057,7 +1057,7 @@ static struct clk_rcg2 gcc_sdcc2_apps_clk_src = { .name = "gcc_sdcc2_apps_clk_src", .parent_data = gcc_parent_data_18, .num_parents = ARRAY_SIZE(gcc_parent_data_18), - .ops = &clk_rcg2_floor_ops, + .ops = &clk_rcg2_shared_floor_ops, }, };
Signature · 1 line
2.51.0
PATCH 306/385 clk: qcom: gcc-x1e80100: Update the SDCC RCGs to use shared_floor_ops
In reply to Sasha LevinFrom: Jagadeesh Kona <[email protected]>
[ Upstream commit a468047c4e1c56783204a3ac551b843b4277c8fc ]
Use shared_floor_ops for the SDCC RCGs so the RCG is safely parked during disable and the new parent configuration is programmed in hardware only when the new parent is enabled, avoiding cases where the RCG configuration fails to update.
--- drivers/clk/qcom/gcc-x1e80100.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/clk/qcom/gcc-x1e80100.c +2 -2
@@ -1516,7 +1516,7 @@ static struct clk_rcg2 gcc_sdcc2_apps_clk_src = { .parent_data = gcc_parent_data_9, .num_parents = ARRAY_SIZE(gcc_parent_data_9), .flags = CLK_SET_RATE_PARENT, - .ops = &clk_rcg2_floor_ops, + .ops = &clk_rcg2_shared_floor_ops, }, };
@@ -1538,7 +1538,7 @@ static struct clk_rcg2 gcc_sdcc4_apps_clk_src = { .parent_data = gcc_parent_data_0, .num_parents = ARRAY_SIZE(gcc_parent_data_0), .flags = CLK_SET_RATE_PARENT, - .ops = &clk_rcg2_floor_ops, + .ops = &clk_rcg2_shared_floor_ops, }, };
Signature · 1 line
2.51.0
PATCH 307/385 clk: qcom: gcc-qdu1000: Update the SDCC RCGs to use shared_floor_ops
In reply to Sasha LevinFrom: Jagadeesh Kona <[email protected]>
[ Upstream commit 947c4b326c1f4dc64aed42170b39c2cf551ba8ca ]
Use shared_floor_ops for the SDCC RCGs so the RCG is safely parked during disable and the new parent configuration is programmed in hardware only when the new parent is enabled, avoiding cases where the RCG configuration fails to update.
--- drivers/clk/qcom/gcc-qdu1000.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/clk/qcom/gcc-qdu1000.c +2 -2
@@ -904,7 +904,7 @@ static struct clk_rcg2 gcc_sdcc5_apps_clk_src = { .name = "gcc_sdcc5_apps_clk_src", .parent_data = gcc_parent_data_8, .num_parents = ARRAY_SIZE(gcc_parent_data_8), - .ops = &clk_rcg2_floor_ops, + .ops = &clk_rcg2_shared_floor_ops, }, };
@@ -923,7 +923,7 @@ static struct clk_rcg2 gcc_sdcc5_ice_core_clk_src = { .name = "gcc_sdcc5_ice_core_clk_src", .parent_data = gcc_parent_data_2, .num_parents = ARRAY_SIZE(gcc_parent_data_2), - .ops = &clk_rcg2_floor_ops, + .ops = &clk_rcg2_shared_floor_ops, }, };
Signature · 1 line
2.51.0
PATCH 308/385 clk: qcom: gcc-msm8953: Remove ALWAYS_ON flag from cpp_gdsc
In reply to Sasha LevinFrom: Barnabás Czémán <[email protected]>
[ Upstream commit 5f613e7034187179a9d088ff5fd02b1089d0cf20 ]
cpp_gdsc should not be always on, ALWAYS_ON flag was set accidentally.
--- drivers/clk/qcom/gcc-msm8953.c | 1 - 1 file changed, 1 deletion(-)
drivers/clk/qcom/gcc-msm8953.c +0 -1
@@ -3946,7 +3946,6 @@ static struct gdsc cpp_gdsc = { .pd = { .name = "cpp_gdsc", }, - .flags = ALWAYS_ON, .pwrsts = PWRSTS_OFF_ON, };
Signature · 1 line
2.51.0
PATCH 309/385 clk: qcom: gcc-msm8917: Remove ALWAYS_ON flag from cpp_gdsc
In reply to Sasha LevinFrom: Barnabás Czémán <[email protected]>
[ Upstream commit e4eb42f290aecac0ba355b1f8d7243be6de11f32 ]
cpp_gdsc should not be always on, ALWAYS_ON flag was set accidentally.
--- drivers/clk/qcom/gcc-msm8917.c | 1 - 1 file changed, 1 deletion(-)
drivers/clk/qcom/gcc-msm8917.c +0 -1
@@ -3034,7 +3034,6 @@ static struct gdsc cpp_gdsc = { .pd = { .name = "cpp_gdsc", }, - .flags = ALWAYS_ON, .pwrsts = PWRSTS_OFF_ON, };
Signature · 1 line
2.51.0
PATCH 310/385 clk: qcom: gcc-ipq5018: flag sleep clock as critical
In reply to Sasha LevinFrom: George Moussalem <[email protected]>
[ Upstream commit 04c4dc1f541135708d90a9b4632af51136f93ac3 ]
The sleep clock never be disabled. To avoid the kernel trying to disable it and keep it always on, flag it as critical.
--- drivers/clk/qcom/gcc-ipq5018.c | 1 + 1 file changed, 1 insertion(+)
drivers/clk/qcom/gcc-ipq5018.c +1 -0
@@ -1340,6 +1340,7 @@ static struct clk_branch gcc_sleep_clk_src = { .name = "gcc_sleep_clk_src", .parent_data = gcc_sleep_clk_data, .num_parents = ARRAY_SIZE(gcc_sleep_clk_data), + .flags = CLK_IS_CRITICAL, .ops = &clk_branch2_ops, }, },
Signature · 1 line
2.51.0
PATCH 311/385 clk: Move clk_{save,restore}_context() to COMMON_CLK section
In reply to Sasha LevinFrom: Geert Uytterhoeven <[email protected]>
[ Upstream commit f47c1b77d0a2a9c0d49ec14302e74f933398d1a3 ]
The clk_save_context() and clk_restore_context() helpers are only implemented by the Common Clock Framework. They are not available when using legacy clock frameworks. Dummy implementations are provided, but only if no clock support is available at all.
Hence when CONFIG_HAVE_CLK=y, but CONFIG_COMMON_CLK is not enabled:
m68k-linux-gnu-ld: drivers/net/phy/air_en8811h.o: in function `en8811h_resume':
air_en8811h.c:(.text+0x83e): undefined reference to `clk_restore_context'
m68k-linux-gnu-ld: drivers/net/phy/air_en8811h.o: in function `en8811h_suspend':
air_en8811h.c:(.text+0x856): undefined reference to `clk_save_context'Fix this by moving forward declarations and dummy implementions from the HAVE_CLK to the COMMON_CLK section.
--- include/linux/clk.h | 48 ++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 24 deletions(-)
include/linux/clk.h +24 -24
@@ -228,6 +228,23 @@ int devm_clk_rate_exclusive_get(struct device *dev, struct clk *clk);*/ void clk_rate_exclusive_put (struct clk *clk); +/** +* clk_save_context - save clock context for poweroff +* +* Saves the context of the clock register for powerstates in which the +* contents of the registers will be lost. Occurs deep within the suspend +* code so locking is not necessary. +*/ +int clk_save_context (void ); + +/** +* clk_restore_context - restore clock context after poweroff +* +* This occurs with all clocks enabled. Occurs deep within the resume code +* so locking is not necessary. +*/ +void clk_restore_context (void ); +#else static inline int clk_notifier_register(struct clk *clk,
@@ -293,6 +310,13 @@ static inline int devm_clk_rate_exclusive_get(struct device *dev, struct clk *clstatic inline void clk_rate_exclusive_put (struct clk *clk) {} +static inline int clk_save_context (void ) +{ +return 0 ; +} + +static inline void clk_restore_context (void ) {} +#endif #ifdef CONFIG_HAVE_CLK_PREPARE
@@ -931,23 +955,6 @@ struct clk *clk_get_parent(struct clk *clk);*/ struct clk *clk_get_sys (const char *dev_id,const char *con_id); -/** -* clk_save_context - save clock context for poweroff -* -* Saves the context of the clock register for powerstates in which the -* contents of the registers will be lost. Occurs deep within the suspend -* code so locking is not necessary. -*/ -int clk_save_context (void ); - -/** -* clk_restore_context - restore clock context after poweroff -* -* This occurs with all clocks enabled. Occurs deep within the resume code -* so locking is not necessary. -*/ -void clk_restore_context (void ); -#else /* !CONFIG_HAVE_CLK */ static inline struct clk *clk_get (struct device *dev,const char *id)
@@ -1127,13 +1134,6 @@ static inline struct clk *clk_get_sys(const char *dev_id, const char *con_id) return NULL; } -static inline int clk_save_context (void ) -{ -return 0 ; -} - -static inline void clk_restore_context (void ) {} -#endif /* clk_prepare_enable helps cases using clk_enable in non-atomic context. */
Signature · 1 line
2.51.0
PATCH 312/385 clk: qcom: dispcc-sdm845: Enable parents for pixel clocks
In reply to Sasha LevinFrom: Petr Hodina <[email protected]>
[ Upstream commit a1d63493634e98360140027fef49d82b1ff0a267 ]
Add CLK_OPS_PARENT_ENABLE to MDSS pixel clock sources to ensure parent clocks are enabled during clock operations, preventing potential stability issues during display configuration.
--- drivers/clk/qcom/dispcc-sdm845.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/clk/qcom/dispcc-sdm845.c +2 -2
@@ -280,7 +280,7 @@ static struct clk_rcg2 disp_cc_mdss_pclk0_clk_src = { .name = "disp_cc_mdss_pclk0_clk_src", .parent_data = disp_cc_parent_data_4, .num_parents = ARRAY_SIZE(disp_cc_parent_data_4), - .flags = CLK_SET_RATE_PARENT, + .flags = CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE, .ops = &clk_pixel_ops, }, };
@@ -295,7 +295,7 @@ static struct clk_rcg2 disp_cc_mdss_pclk1_clk_src = { .name = "disp_cc_mdss_pclk1_clk_src", .parent_data = disp_cc_parent_data_4, .num_parents = ARRAY_SIZE(disp_cc_parent_data_4), - .flags = CLK_SET_RATE_PARENT, + .flags = CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE, .ops = &clk_pixel_ops, }, };
Signature · 1 line
2.51.0
PATCH 313/385 clk: qcom: dispcc-sm7150: Fix dispcc_mdss_pclk1_clk_src
In reply to Sasha LevinFrom: David Heidelberg <[email protected]>
[ Upstream commit fab13d738c9bd645965464b881335f580d38a54e ]
Set CLK_OPS_PARENT_ENABLE to ensure the parent gets prepared and enabled when switching to it.
--- drivers/clk/qcom/dispcc-sm7150.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/qcom/dispcc-sm7150.c +1 -1
@@ -371,7 +371,7 @@ static struct clk_rcg2 dispcc_mdss_pclk1_clk_src = { .name = "dispcc_mdss_pclk1_clk_src", .parent_data = dispcc_parent_data_4, .num_parents = ARRAY_SIZE(dispcc_parent_data_4), - .flags = CLK_SET_RATE_PARENT, + .flags = CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE, .ops = &clk_pixel_ops, }, };
Signature · 1 line
2.51.0
PATCH 314/385 clk: qcom: gfx3d: add parent to parent request map
In reply to Sasha LevinFrom: Dmitry Baryshkov <[email protected]>
[ Upstream commit 2583cb925ca1ce450aa5d74a05a67448db970193 ]
After commit d228ece36345 ("clk: divider: remove round_rate() in favor of determine_rate()") determining GFX3D clock rate crashes, because the passed parent map doesn't provide the expected best_parent_hw clock (with the roundd_rate path before the offending commit the best_parent_hw was ignored).
Set the field in parent_req in addition to setting it in the req, fixing the crash.
clk_hw_round_rate (drivers/clk/clk.c:1764) (P) clk_divider_bestdiv (drivers/clk/clk-divider.c:336) divider_determine_rate (drivers/clk/clk-divider.c:358) clk_alpha_pll_postdiv_determine_rate (drivers/clk/qcom/clk-alpha-pll.c:1275) clk_core_determine_round_nolock (drivers/clk/clk.c:1606) clk_core_round_rate_nolock (drivers/clk/clk.c:1701) __clk_determine_rate (drivers/clk/clk.c:1741) clk_gfx3d_determine_rate (drivers/clk/qcom/clk-rcg2.c:1268) clk_core_determine_round_nolock (drivers/clk/clk.c:1606) clk_core_round_rate_nolock (drivers/clk/clk.c:1701) clk_core_round_rate_nolock (drivers/clk/clk.c:1710) clk_round_rate (drivers/clk/clk.c:1804)
dev_pm_opp_set_rate (drivers/opp/core.c:1440 (discriminator 1)) msm_devfreq_target (drivers/gpu/drm/msm/msm_gpu_devfreq.c:51) devfreq_set_target (drivers/devfreq/devfreq.c:360) devfreq_update_target (drivers/devfreq/devfreq.c:426) devfreq_monitor (drivers/devfreq/devfreq.c:458) process_one_work (arch/arm64/include/asm/jump_label.h:36 include/trace/events/workqueue.h:110 kernel/workqueue.c:3284) worker_thread (kernel/workqueue.c:3356 (discriminator 2) kernel/workqueue.c:3443 (discriminator 2)) kthread (kernel/kthread.c:467) ret_from_fork (arch/arm64/kernel/entry.S:861)
--- drivers/clk/qcom/clk-rcg2.c | 1 + 1 file changed, 1 insertion(+)
drivers/clk/qcom/clk-rcg2.c +1 -0
@@ -1084,6 +1084,7 @@ static int clk_gfx3d_determine_rate(struct clk_hw *hw,if (req->max_rate < parent_req.max_rate) parent_req.max_rate = req->max_rate; + parent_req.best_parent_hw = req->best_parent_hw; ret =__clk_determine_rate (req->best_parent_hw, &parent_req);if (ret)return ret;
Signature · 1 line
2.51.0
PATCH 315/385 clk: mediatek: Fix error handling in runtime PM setup
In reply to Sasha LevinFrom: Haotian Zhang <[email protected]>
[ Upstream commit aa2ad19210a6a444111bce55e8b69579f29318fb ]
devm_pm_runtime_enable() can fail due to memory allocation. The current code ignores its return value, and when pm_runtime_resume_and_get() fails, it returns directly without unmapping the shared_io region.
Add error handling for devm_pm_runtime_enable(). Reorder cleanup labels to properly unmap shared_io on pm_runtime_resume_and_get() failure.
--- drivers/clk/mediatek/clk-mtk.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/clk/mediatek/clk-mtk.c +7 -5
@@ -497,14 +497,16 @@ static int __mtk_clk_simple_probe(struct platform_device *pdev,if (mcd->need_runtime_pm) { -devm_pm_runtime_enable (&pdev->dev); + r =devm_pm_runtime_enable (&pdev->dev); +if (r) + goto unmap_io;/* * Do a pm_runtime_resume_and_get() to workaround a possible * deadlock between clk_register() and the genpd framework. */ r =pm_runtime_resume_and_get (&pdev->dev);if (r) -return r; + goto unmap_io; }/* Calculate how many clk_hw_onecell_data entries to allocate */
@@ -618,11 +620,11 @@ static int __mtk_clk_simple_probe(struct platform_device *pdev, free_data:mtk_free_clk_data (clk_data); free_base: -if (mcd->shared_io && base) -iounmap (base); -if (mcd->need_runtime_pm)pm_runtime_put (&pdev->dev); +unmap_io: +if (mcd->shared_io && base) +iounmap (base);return r; }
Signature · 1 line
2.51.0
PATCH 316/385 interconnect: mediatek: Don't hijack parent device
In reply to Sasha LevinFrom: Nicolas Frattaroli <[email protected]>
[ Upstream commit 510f8214440c553e81774c5822437ccf154e9e38 ]
If the intention is that users of the interconnect declare their relationship to the child icc_emi node of the dvfsrc controller, then this code never worked. That's because it uses the parent dvfsrc device as the device it passes to the interconnect core framework, which means all the OF parsing is broken.
Use the actual device instead, and pass the dvfsrc parent into the dvfsrc calls.
--- drivers/interconnect/mediatek/icc-emi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/interconnect/mediatek/icc-emi.c +2 -2
@@ -40,7 +40,7 @@ static int mtk_emi_icc_set(struct icc_node *src, struct icc_node *dst)if (unlikely (!src->provider))return -EINVAL ; - dev = src->provider->dev; + dev = src->provider->dev->parent;switch (node->ep) {case 0 :
@@ -97,7 +97,7 @@ int mtk_emi_icc_probe(struct platform_device *pdev)if (!data)return -ENOMEM ; - provider->dev = pdev->dev.parent; + provider->dev = dev; provider->set = mtk_emi_icc_set; provider->aggregate = mtk_emi_icc_aggregate; provider->xlate = of_icc_xlate_onecell;
Signature · 1 line
2.51.0
PATCH 317/385 interconnect: mediatek: Aggregate bandwidth with saturating add
In reply to Sasha LevinFrom: Nicolas Frattaroli <[email protected]>
[ Upstream commit 6ffd02b82243d9907b5f5d2c7a2fc6a62669eece ]
By using a regular non-overflow-checking add, the MediaTek icc-emi driver will happy wrap at U32_MAX + 1 to 0. As it's common for the interconnect core to fill in INT_MAX values, this is not a hypothetical situation, but something that actually happens in regular use. This would be pretty disasterous if anything used this driver.
Replace the addition with an overflow-checked addition from overflow.h, and saturate to U32_MAX if an overflow is detected.
--- drivers/interconnect/mediatek/icc-emi.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/interconnect/mediatek/icc-emi.c +4 -1
@@ -12,6 +12,7 @@#include <linux/module.h> #include <linux/of.h> #include <linux/of_platform.h> +#include <linux/overflow.h> #include <linux/platform_device.h> #include <linux/soc/mediatek/dvfsrc.h>
@@ -22,7 +23,9 @@ static int mtk_emi_icc_aggregate(struct icc_node *node, u32 tag, u32 avg_bw, {struct mtk_icc_node *in = node->data; - *agg_avg += avg_bw; +if (check_add_overflow (*agg_avg, avg_bw, agg_avg)) + *agg_avg =U32_MAX ; + *agg_peak =max_t (u32, *agg_peak, peak_bw); in->sum_avg = *agg_avg;
Signature · 1 line
2.51.0
PATCH 318/385 dmaengine: mediatek: uart-apdma: Fix above 4G addressing TX/RX
In reply to Sasha LevinFrom: AngeloGioacchino Del Regno <[email protected]>
[ Upstream commit 58ab9d7b6651d21e1cff1777529f2d3dd0b4e851 ]
The VFF_4G_SUPPORT register is named differently in datasheets, and its name is "VFF_ADDR2"; was this named correctly from the beginning it would've been clearer that there was a mistake in the programming sequence.
This register is supposed to hold the high bits to support the DMA addressing above 4G (so, more than 32 bits) and not a bit to "enable" the support for VFF 4G.
Fix the name of this register, and also fix its usage by writing the upper 32 bits of the dma_addr_t on it when the SoC supports such feature.
--- drivers/dma/mediatek/mtk-uart-apdma.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/dma/mediatek/mtk-uart-apdma.c +5 -5
@@ -41,7 +41,7 @@#define VFF_STOP_CLR_B 0#define VFF_EN_CLR_B 0#define VFF_INT_EN_CLR_B 0 -#define VFF_4G_SUPPORT_CLR_B 0 +#define VFF_ADDR2_CLR_B 0/* * interrupt trigger level for tx
@@ -72,7 +72,7 @@/* TX: the buffer size SW can write. RX: the buffer size HW can write. */ #define VFF_LEFT_SIZE 0x40#define VFF_DEBUG_STATUS 0x50 -#define VFF_4G_SUPPORT 0x54 +#define VFF_ADDR2 0x54struct mtk_uart_apdmadev {struct dma_device ddev;
@@ -149,7 +149,7 @@ static void mtk_uart_apdma_start_tx(struct mtk_chan *c)mtk_uart_apdma_write (c,VFF_INT_FLAG ,VFF_TX_INT_CLR_B );if (mtkd->support_33bits) -mtk_uart_apdma_write (c,VFF_4G_SUPPORT ,VFF_4G_EN_B ); +mtk_uart_apdma_write (c,VFF_ADDR2 ,upper_32_bits (d->addr)); }mtk_uart_apdma_write (c,VFF_EN ,VFF_EN_B );
@@ -192,7 +192,7 @@ static void mtk_uart_apdma_start_rx(struct mtk_chan *c)mtk_uart_apdma_write (c,VFF_INT_FLAG ,VFF_RX_INT_CLR_B );if (mtkd->support_33bits) -mtk_uart_apdma_write (c,VFF_4G_SUPPORT ,VFF_4G_EN_B ); +mtk_uart_apdma_write (c,VFF_ADDR2 ,upper_32_bits (d->addr)); }mtk_uart_apdma_write (c,VFF_INT_EN ,VFF_RX_INT_EN_B );
@@ -298,7 +298,7 @@ static int mtk_uart_apdma_alloc_chan_resources(struct dma_chan *chan) }if (mtkd->support_33bits) -mtk_uart_apdma_write (c,VFF_4G_SUPPORT ,VFF_4G_SUPPORT_CLR_B ); +mtk_uart_apdma_write (c,VFF_ADDR2 ,VFF_ADDR2_CLR_B ); err_pm:pm_runtime_put_noidle (mtkd->ddev.dev);
Signature · 1 line
2.51.0
PATCH 319/385 dma: dma-axi-dmac: fix SW cyclic transfers
In reply to Sasha LevinFrom: Nuno Sá <[email protected]>
[ Upstream commit 9bd257181fd5c996d922e9991500ad27987cfbf4 ]
If 'hw_cyclic' is false we should still be able to do cyclic transfers in "software". That was not working for the case where 'desc->num_sgs' is 1 because 'chan->next_desc' is never set with the current desc which means that the cyclic transfer only runs once and in the next SOT interrupt we do nothing since vchan_next_desc() will return NULL.
Fix it by setting 'chan->next_desc' as soon as we get a new desc via vchan_next_desc().
base-commit: 398035178503bf662281bbffb4bebce1460a4bc5
--- drivers/dma/dma-axi-dmac.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/dma/dma-axi-dmac.c +1 -2
@@ -247,6 +247,7 @@ static void axi_dmac_start_transfer(struct axi_dmac_chan *chan)return ;list_move_tail (&vdesc->node, &chan->active_descs); desc =to_axi_dmac_desc (vdesc); + chan->next_desc = desc; } sg = &desc->sg[desc->num_submitted];
@@ -265,8 +266,6 @@ static void axi_dmac_start_transfer(struct axi_dmac_chan *chan)else chan->next_desc =NULL ; flags |=AXI_DMAC_FLAG_LAST ; - }else { - chan->next_desc = desc; } sg->hw->id =axi_dmac_read (dmac,AXI_DMAC_REG_TRANSFER_ID );
Signature · 1 line
2.51.0
PATCH 320/385 dma: dma-axi-dmac: fix HW scatter-gather not looking at the queue
In reply to Sasha LevinFrom: Nuno Sá <[email protected]>
[ Upstream commit bbcbafb99df41a1d81403eb4f5bb443b38228b57 ]
For HW scatter gather transfers we still need to look for the queue. The HW is capable of queueing 3 concurrent transfers and if we try more than that we'll get the submit queue full and should return. Otherwise, if we go ahead and program the new transfer, we end up discarding it.
base-commit: 398035178503bf662281bbffb4bebce1460a4bc5
--- drivers/dma/dma-axi-dmac.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/dma/dma-axi-dmac.c +3 -5
@@ -233,11 +233,9 @@ static void axi_dmac_start_transfer(struct axi_dmac_chan *chan)unsigned int flags =0 ;unsigned int val; -if (!chan->hw_sg) { - val =axi_dmac_read (dmac,AXI_DMAC_REG_START_TRANSFER ); -if (val)/* Queue is full, wait for the next SOT IRQ */ -return ; - } + val =axi_dmac_read (dmac,AXI_DMAC_REG_START_TRANSFER ); +if (val)/* Queue is full, wait for the next SOT IRQ */ +return ; desc = chan->next_desc;
Signature · 1 line
2.51.0
PATCH 321/385 soundwire: intel_ace2x: add SND_HDA_CORE dependency
In reply to Sasha LevinFrom: Arnd Bergmann <[email protected]>
[ Upstream commit dc3a6a942e9ee3f18560bfcb16c06bb94f37fabf ]
The ace2x driver can optionally use the HDA infrastructure, but can still build without that. However, with SND_HDA_CORE=m and SND_HDA_ALIGNED_MMIO=y, it fails to link as built-in:
aarch64-linux-ld: drivers/soundwire/intel_ace2x.o: in function `intel_shim_wake':
intel_ace2x.c:(.text+0x2518): undefined reference to `snd_hdac_aligned_read'
aarch64-linux-ld: intel_ace2x.c:(.text+0x25d4): undefined reference to `snd_hdac_aligned_read'
aarch64-linux-ld: intel_ace2x.c:(.text+0x268c): undefined reference to `snd_hdac_aligned_write'
Add a Kconfig dependency that forces the soundwire driver to be a loadable module if necessary.
--- drivers/soundwire/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/soundwire/Kconfig +1 -0
@@ -38,6 +38,7 @@ config SOUNDWIRE_INTEL select AUXILIARY_BUS depends on ACPI && SND_SOC depends on SND_SOC_SOF_HDA_MLINK || !SND_SOC_SOF_HDA_MLINK + depends on SND_HDA_CORE || !SND_HDA_ALIGNED_MMIO help SoundWire Intel Master driver. If you have an Intel platform which has a SoundWire Master then
Signature · 1 line
2.51.0
PATCH 322/385 iio: test: drop dangling symbol in gain-time-scale helpers
In reply to Sasha LevinFrom: Randy Dunlap <[email protected]>
[ Upstream commit d63d868b312478523670b76007dcc5eaedc3ee07 ]
The code for this never went upstream. It was replaced by other code, so this should be dropped.
--- drivers/iio/test/Kconfig | 1 - 1 file changed, 1 deletion(-)
drivers/iio/test/Kconfig +0 -1
@@ -8,7 +8,6 @@ config IIO_GTS_KUNIT_TEST tristate "Test IIO formatting functions" if !KUNIT_ALL_TESTS depends on KUNIT select IIO_GTS_HELPER - select TEST_KUNIT_DEVICE_HELPERS default KUNIT_ALL_TESTS help build unit tests for the IIO light sensor gain-time-scale helpers.
Signature · 1 line
2.51.0
PATCH 323/385 staging: greybus: lights: avoid NULL deref
In reply to Sasha LevinFrom: Chaitanya Mishra <[email protected]>
[ Upstream commit efcffd9a6ad8d190651498d5eda53bfc7cf683a7 ]
gb_lights_light_config() stores channel_count before allocating the channels array. If kcalloc() fails, gb_lights_release() iterates the non-zero count and dereferences light->channels, which is NULL.
Allocate channels first and only then publish channels_count so the cleanup path can't walk a NULL pointer.
--- drivers/staging/greybus/light.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/staging/greybus/light.c +6 -2
@@ -1008,14 +1008,18 @@ static int gb_lights_light_config(struct gb_lights *glights, u8 id)if (!strlen (conf.name))return -EINVAL ; - light->channels_count = conf.channel_count; light->name =kstrndup (conf.name,NAMES_MAX ,GFP_KERNEL );if (!light->name)return -ENOMEM ; - light->channels =kcalloc (light->channels_count, + light->channels =kcalloc (conf.channel_count,sizeof (struct gb_channel ),GFP_KERNEL );if (!light->channels)return -ENOMEM ; +/* +* Publish channels_count only after channels allocation so cleanup +* doesn't walk a NULL channels pointer on allocation failure. +*/ + light->channels_count = conf.channel_count;/* First we collect all the configurations for all channels */ for (i =0 ; i < light->channels_count; i++) {
Signature · 1 line
2.51.0
PATCH 324/385 serial: imx: change SERIAL_IMX_CONSOLE to bool
In reply to Sasha LevinFrom: Randy Dunlap <[email protected]>
[ Upstream commit 79527d86ba91c2d9354832d19fd12b3baa66bd10 ]
SERIAL_IMX_CONSOLE is a build option for the imx driver (SERIAL_IMX). It does not build a separate console driver file, so it can't be built as a module since it isn't built at all.
Change the Kconfig symbol from tristate to bool and update the help text accordingly.
--- drivers/tty/serial/Kconfig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/tty/serial/Kconfig +3 -3
@@ -482,14 +482,14 @@ config SERIAL_IMX can enable its onboard serial port by enabling this option. config SERIAL_IMX_CONSOLE - tristate "Console on IMX serial port" + bool "Console on IMX serial port" depends on SERIAL_IMX select SERIAL_CORE_CONSOLE help If you have enabled the serial port on the Freescale IMX - CPU you can make it the console by answering Y/M to this option. + CPU you can make it the console by answering Y to this option. - Even if you say Y/M here, the currently visible virtual console + Even if you say Y here, the currently visible virtual console (/dev/tty0) will still be used as the system console by default, but you can alter that using a kernel command line option such as "console=ttymxc0". (Try "man bootparam" or see the documentation of
Signature · 1 line
2.51.0
PATCH 325/385 serial: SH_SCI: improve "DMA support" prompt
In reply to Sasha LevinFrom: Randy Dunlap <[email protected]>
[ Upstream commit 93bb95a11238d66a4c9aa6eabf9774b073a5895c ]
Having a prompt of "DMA support" suddenly appear during a "make oldconfig" can be confusing. Add a little helpful text to the prompt message.
--- drivers/tty/serial/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/Kconfig +1 -1
@@ -667,7 +667,7 @@ config SERIAL_SH_SCI_EARLYCON default ARCH_RENESAS config SERIAL_SH_SCI_DMA - bool "DMA support" if EXPERT + bool "Support for DMA on SuperH SCI(F)" if EXPERT depends on SERIAL_SH_SCI && DMA_ENGINE default ARCH_RENESAS
Signature · 1 line
2.51.0
PATCH 326/385 mmc: rtsx_pci_sdmmc: increase power-on settling delay to 5ms
In reply to Sasha LevinFrom: Matthew Schwartz <[email protected]>
[ Upstream commit aced969e9bf3701dc75cfca57c78c031b7875b9d ]
The existing 1ms delay in sd_power_on is insufficient and causes resume errors around 4% of the time.
Increasing the delay to 5ms resolves this issue after testing 300 s2idle cycles.
--- drivers/mmc/host/rtsx_pci_sdmmc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/host/rtsx_pci_sdmmc.c +1 -1
@@ -939,7 +939,7 @@ static int sd_power_on(struct realtek_pci_sdmmc *host, unsigned char power_mode)if (err <0 )return err; -mdelay (1 ); +mdelay (5 ); err =rtsx_pci_write_register (pcr,CARD_OE ,SD_OUTPUT_EN ,SD_OUTPUT_EN );if (err <0 )
Signature · 1 line
2.51.0
PATCH 327/385 iio: pressure: mprls0025pa: fix spi_transfer struct initialisation
In reply to Sasha LevinFrom: Petre Rodan <[email protected]>
[ Upstream commit 1e0ac56c92e26115cbc8cfc639843725cb3a7d6a ]
Make sure that the spi_transfer struct is zeroed out before use.
--- drivers/iio/pressure/mprls0025pa_spi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/pressure/mprls0025pa_spi.c +1 -1
@@ -40,7 +40,7 @@ static int mpr_spi_xfer(struct mpr_data *data, const u8 cmd, const u8 pkt_len) {struct spi_device *spi =to_spi_device (data->dev);struct mpr_spi_buf *buf =spi_get_drvdata (spi); -struct spi_transfer xfer; +struct spi_transfer xfer = { };if (pkt_len >MPR_MEASUREMENT_RD_SIZE )return -EOVERFLOW ;
Signature · 1 line
2.51.0
PATCH 328/385 iio: pressure: mprls0025pa: fix SPI CS delay violation
In reply to Sasha LevinFrom: Petre Rodan <[email protected]>
[ Upstream commit 583fa86ca581595b1f534a8de6d49ba8b3bf7196 ]
Based on the sensor datasheet in chapter 7.6 SPI timing, Table 20, during the SPI transfer there is a minimum time interval requirement between the CS being asserted and the first clock edge (tHDSS). This minimum interval of 2.5us is being violated if two consecutive SPI transfers are queued up.
--- drivers/iio/pressure/mprls0025pa_spi.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-)
drivers/iio/pressure/mprls0025pa_spi.c +14 -5
@@ -8,6 +8,7 @@* https://prod-edam.honeywell.com/content/dam/honeywell-edam/sps/siot/en-us/products/sensors/pressure-sensors/board-mount-pressure-sensors/micropressure-mpr-series/documents/sps-siot-mpr-series-datasheet-32332628-ciid-172626.pdf */ +#include <linux/array_size.h> #include <linux/device.h> #include <linux/errno.h> #include <linux/mod_devicetable.h>
@@ -40,17 +41,25 @@ static int mpr_spi_xfer(struct mpr_data *data, const u8 cmd, const u8 pkt_len) {struct spi_device *spi =to_spi_device (data->dev);struct mpr_spi_buf *buf =spi_get_drvdata (spi); -struct spi_transfer xfer = { }; +struct spi_transfer xfers[2 ] = { };if (pkt_len >MPR_MEASUREMENT_RD_SIZE )return -EOVERFLOW ; buf->tx[0 ] = cmd; - xfer.tx_buf = buf->tx; - xfer.rx_buf = data->buffer; - xfer.len = pkt_len; -return spi_sync_transfer (spi, &xfer,1 ); +/* +* Dummy transfer with no data, just cause a 2.5us+ delay between the CS assert +* and the first clock edge as per the datasheet tHDSS timing requirement. +*/ + xfers[0 ].delay.value =2500 ; + xfers[0 ].delay.unit =SPI_DELAY_UNIT_NSECS ; + + xfers[1 ].tx_buf = buf->tx; + xfers[1 ].rx_buf = data->buffer; + xfers[1 ].len = pkt_len; + +return spi_sync_transfer (spi, xfers,ARRAY_SIZE (xfers)); }static const struct mpr_ops mpr_spi_ops = {
Signature · 1 line
2.51.0
PATCH 329/385 iio: pressure: mprls0025pa: fix interrupt flag
In reply to Sasha LevinFrom: Petre Rodan <[email protected]>
[ Upstream commit fff3f1a7d805684e4701a70bfaeba39622b59dbc ]
Interrupt falling/rising flags should only be defined in the device tree.
--- drivers/iio/pressure/mprls0025pa.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/iio/pressure/mprls0025pa.c +2 -4
@@ -418,10 +418,8 @@ int mpr_common_probe(struct device *dev, const struct mpr_ops *ops, int irq) data->offset =div_s64_rem (offset,NANO , &data->offset2);if (data->irq >0 ) { - ret =devm_request_irq (dev, data->irq, mpr_eoc_handler, -IRQF_TRIGGER_RISING , -dev_name (dev), - data); + ret =devm_request_irq (dev, data->irq, mpr_eoc_handler,0 , +dev_name (dev), data);if (ret)return dev_err_probe (dev, ret,"request irq %d failed\n" , data->irq);
Signature · 1 line
2.51.0
PATCH 330/385 iio: pressure: mprls0025pa: fix scan_type struct
In reply to Sasha LevinFrom: Petre Rodan <[email protected]>
[ Upstream commit 8a228e036926f7e57421d750c3724e63f11b808a ]
Fix the scan_type sign and realbits assignment.
The pressure is a 24bit unsigned int between output_min and output_max.
transfer function A: 10% to 90% of 2^24
transfer function B: 2.5% to 22.5% of 2^24
transfer function C: 20% to 80% of 2^24
[MPR_FUNCTION_A] = { .output_min = 1677722, .output_max = 15099494 } [MPR_FUNCTION_B] = { .output_min = 419430, .output_max = 3774874 } [MPR_FUNCTION_C] = { .output_min = 3355443, .output_max = 13421773 }
--- drivers/iio/pressure/mprls0025pa.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/pressure/mprls0025pa.c +2 -2
@@ -160,8 +160,8 @@ static const struct iio_chan_spec mpr_channels[] = {BIT (IIO_CHAN_INFO_OFFSET ), .scan_index = 0, .scan_type = { - .sign ='s' , - .realbits =32 , + .sign ='u' , + .realbits =24 , .storagebits =32 , .endianness =IIO_CPU , },
Signature · 1 line
2.51.0
PATCH 331/385 iio: pressure: mprls0025pa: fix pressure calculation
In reply to Sasha LevinFrom: Petre Rodan <[email protected]>
[ Upstream commit d63403d4e31ae537fefc5c0ee9d90f29b4fc532b ]
A sign change is needed for proper calculation of the pressure.
This is a minor fix since it only affects users that might have custom silicon from Honeywell that has honeywell,pmin-pascal != 0.
Also due to the fact that raw pressure values can not be lower than output_min (400k-3.3M) there is no need to calculate a decimal for the offset.
--- drivers/iio/pressure/mprls0025pa.c | 26 +++++++++++--------------- drivers/iio/pressure/mprls0025pa.h | 2 -- 2 files changed, 11 insertions(+), 17 deletions(-)
drivers/iio/pressure/mprls0025pa.c +11 -15
@@ -59,7 +59,7 @@* * Values given to the userspace in sysfs interface: * * raw - press_cnt -* * offset - (-1 * outputmin) - pmin / scale +* * offset - (-1 * outputmin) + pmin / scale * note: With all sensors from the datasheet pmin = 0 * which reduces the offset to (-1 * outputmin) */
@@ -313,8 +313,7 @@ static int mpr_read_raw(struct iio_dev *indio_dev,return IIO_VAL_INT_PLUS_NANO ;case IIO_CHAN_INFO_OFFSET : *val = data->offset; - *val2 = data->offset2; -return IIO_VAL_INT_PLUS_NANO ; +return IIO_VAL_INT ;default :return -EINVAL ; }
@@ -330,8 +329,9 @@ int mpr_common_probe(struct device *dev, const struct mpr_ops *ops, int irq)struct mpr_data *data;struct iio_dev *indio_dev;const char *triplet; -s64 scale, offset; +s64 odelta, pdelta;u32 func; +s32 tmp; indio_dev =devm_iio_device_alloc (dev,sizeof (*data));if (!indio_dev)
@@ -405,17 +405,13 @@ int mpr_common_probe(struct device *dev, const struct mpr_ops *ops, int irq) data->outmin = mpr_func_spec[data->function].output_min; data->outmax = mpr_func_spec[data->function].output_max; -/* use 64 bit calculation for preserving a reasonable precision */ - scale =div_s64 (((s64)(data->pmax - data->pmin)) *NANO , - data->outmax - data->outmin); - data->scale =div_s64_rem (scale,NANO , &data->scale2); -/* -* multiply with NANO before dividing by scale and later divide by NANO -* again. -*/ - offset = ((-1LL ) * (s64 )data->outmin) *NANO - -div_s64 (div_s64 ((s64 )data->pmin *NANO , scale),NANO ); - data->offset =div_s64_rem (offset,NANO , &data->offset2); + odelta = data->outmax - data->outmin; + pdelta = data->pmax - data->pmin; + + data->scale =div_s64_rem (div_s64 (pdelta *NANO , odelta),NANO , &tmp); + data->scale2 = tmp; + + data->offset =div_s64 (odelta * data->pmin, pdelta) - data->outmin;if (data->irq >0 ) { ret = devm_request_irq(dev, data->irq, mpr_eoc_handler, 0,
drivers/iio/pressure/mprls0025pa.h +0 -2
@@ -53,7 +53,6 @@ enum mpr_func_id {* @scale: pressure scale * @scale2: pressure scale, decimal number * @offset: pressure offset -* @offset2: pressure offset, decimal number * @gpiod_reset: reset * @irq: end of conversion irq. used to distinguish between irq mode and * reading in a loop until data is ready
@@ -75,7 +74,6 @@ struct mpr_data {int scale;int scale2;int offset; -int offset2;struct gpio_desc *gpiod_reset;int irq;struct completion completion;
Signature · 1 line
2.51.0
PATCH 332/385 watchdog: starfive-wdt: Fix PM reference leak in probe error path
In reply to Sasha LevinFrom: Kery Qi <[email protected]>
[ Upstream commit 3f2d8d79cceb05a8b8dd200fa81c0dffc59ec46f ]
The PM reference count is not expected to be incremented on return in functions starfive_wdt_probe.
However, pm_runtime_get_sync will increment pm usage counter even failed. Forgetting to putting operation will result in a reference leak here.
Replace it with pm_runtime_resume_and_get to keep usage counter balanced.
--- drivers/watchdog/starfive-wdt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/watchdog/starfive-wdt.c +1 -1
@@ -446,7 +446,7 @@ static int starfive_wdt_probe(struct platform_device *pdev)platform_set_drvdata (pdev, wdt);pm_runtime_enable (&pdev->dev);if (pm_runtime_enabled (&pdev->dev)) { - ret =pm_runtime_get_sync (&pdev->dev); + ret =pm_runtime_resume_and_get (&pdev->dev);if (ret <0 )return ret; }else {
Signature · 1 line
2.51.0
PATCH 333/385 coresight: etm3x: Fix cpulocked warning on cpuhp
In reply to Sasha LevinFrom: Antonio Borneo <[email protected]>
[ Upstream commit 1feb0377b9b816f89a04fc381eb19fc6bac9f4a4 ]
When changes [1] and [2] have been applied to the driver etm4x, the same modifications have been also collapsed in [3] and applied in one shot to the driver etm3x.
While doing this, the driver etm3x has not been aligned to etm4x on the use of non cpuslocked version of cpuhp callback setup APIs.
The current code triggers two run-time warnings when the kernel is compiled with CONFIG_PROVE_LOCKING=y.
Use non cpuslocked version of cpuhp callback setup APIs in driver etm3x, aligning it to the driver etm4x.
[1] commit 2d1a8bfb61ec ("coresight: etm4x: Fix etm4_count race by moving cpuhp callbacks to init")
[2] commit 22a550a306ad ("coresight: etm4x: Allow etm4x to be built as a module")
[3] commit 97fe626ce64c ("coresight: etm3x: Allow etm3x to be built as a module")
--- drivers/hwtracing/coresight/coresight-etm3x-core.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/hwtracing/coresight/coresight-etm3x-core.c +6 -6
@@ -812,16 +812,16 @@ static int __init etm_hp_setup(void) {int ret; - ret =cpuhp_setup_state_nocalls_cpuslocked (CPUHP_AP_ARM_CORESIGHT_STARTING , -"arm/coresight:starting" , - etm_starting_cpu, etm_dying_cpu); + ret =cpuhp_setup_state_nocalls (CPUHP_AP_ARM_CORESIGHT_STARTING , +"arm/coresight:starting" , + etm_starting_cpu, etm_dying_cpu);if (ret)return ret; - ret =cpuhp_setup_state_nocalls_cpuslocked (CPUHP_AP_ONLINE_DYN , -"arm/coresight:online" , - etm_online_cpu,NULL ); + ret =cpuhp_setup_state_nocalls (CPUHP_AP_ONLINE_DYN , +"arm/coresight:online" , + etm_online_cpu,NULL );/* HP dyn state ID returned in ret on success */ if (ret >0 ) {
Signature · 1 line
2.51.0
PATCH 334/385 phy: freescale: imx8qm-hsio: fix NULL pointer dereference
In reply to Sasha LevinFrom: Thomas Richard <[email protected]>
[ Upstream commit 4dd5d4c0361af0a3fd24f45c815996abf4429770 ]
During the probe the refclk_pad pointer is set to NULL if the 'fsl,refclk-pad-mode' property is not defined in the devicetree node. But in imx_hsio_configure_clk_pad() this pointer is unconditionally used which could result in a NULL pointer dereference. So check the pointer before to use it.
--- drivers/phy/freescale/phy-fsl-imx8qm-hsio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/phy/freescale/phy-fsl-imx8qm-hsio.c +1 -1
@@ -251,7 +251,7 @@ static void imx_hsio_configure_clk_pad(struct phy *phy)struct imx_hsio_lane *lane =phy_get_drvdata (phy);struct imx_hsio_priv *priv = lane->priv; -if (strncmp (priv->refclk_pad,"output" ,6 ) ==0 ) { +if (priv->refclk_pad &&strncmp (priv->refclk_pad,"output" ,6 ) ==0 ) { pll = true; regmap_update_bits(priv->misc, HSIO_CTRL0, HSIO_IOB_A_0_TXOE | HSIO_IOB_A_0_M1M0_MASK,
Signature · 1 line
2.51.0
PATCH 335/385 Revert "mmc: rtsx_pci_sdmmc: increase power-on settling delay to 5ms"
In reply to Sasha LevinFrom: Greg Kroah-Hartman <[email protected]>
[ Upstream commit ff112f1ecd10b72004eac05bae395e1c65f0c63c ]
This reverts commit aced969e9bf3701dc75cfca57c78c031b7875b9d.
It was determined that this was not the correct "fix", so should be reverted.
--- drivers/mmc/host/rtsx_pci_sdmmc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/host/rtsx_pci_sdmmc.c +1 -1
@@ -939,7 +939,7 @@ static int sd_power_on(struct realtek_pci_sdmmc *host, unsigned char power_mode)if (err <0 )return err; -mdelay (5 ); +mdelay (1 ); err =rtsx_pci_write_register (pcr,CARD_OE ,SD_OUTPUT_EN ,SD_OUTPUT_EN );if (err <0 )
Signature · 1 line
2.51.0
PATCH 336/385 mfd: arizona: Fix regulator resource leak on wm5102_clear_write_sequencer() failure
In reply to Sasha LevinFrom: Haotian Zhang <[email protected]>
[ Upstream commit 4feb753ba6e5e5bbaba868b841a2db41c21e56fa ]
The wm5102_clear_write_sequencer() helper may return an error and just return, bypassing the cleanup sequence and causing regulators to remain enabled, leading to a resource leak.
Change the direct return to jump to the err_reset label to properly free the resources.
--- drivers/mfd/arizona-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mfd/arizona-core.c +1 -1
@@ -1100,7 +1100,7 @@ int arizona_dev_init(struct arizona *arizona) }else if (val &0x01 ) { ret =wm5102_clear_write_sequencer (arizona);if (ret) -return ret; + goto err_reset; }break ;default :
Signature · 1 line
2.51.0
PATCH 337/385 mfd: simple-mfd-i2c: Add MAX77705 support
In reply to Sasha LevinFrom: Dzmitry Sankouski <[email protected]>
[ Upstream commit 7b591ef98b3fc1ce20c3ccb86715429b72e2e6f0 ]
Add MAX77705 support - fuel gauge and hwmon devices. Hwmon provides charger input and system bus measurements.
Stable-dep-of: 8f34c1a64c53 ("mfd: simple-mfd-i2c: Add Delta TN48M CPLD support")
--- drivers/mfd/simple-mfd-i2c.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/mfd/simple-mfd-i2c.c +11 -0
@@ -83,11 +83,22 @@ static const struct simple_mfd_data maxim_max5970 = { .mfd_cell_size = ARRAY_SIZE(max5970_cells), }; +static const struct mfd_cell max77705_sensor_cells[] = { + { .name ="max77705-battery" }, + { .name ="max77705-hwmon" , }, +}; + +static const struct simple_mfd_data maxim_mon_max77705 = { + .mfd_cell = max77705_sensor_cells, + .mfd_cell_size =ARRAY_SIZE (max77705_sensor_cells), +}; +static const struct of_device_id simple_mfd_i2c_of_match[] = { { .compatible ="kontron,sl28cpld" }, { .compatible ="silergy,sy7636a" , .data = &silergy_sy7636a}, { .compatible ="maxim,max5970" , .data = &maxim_max5970}, { .compatible ="maxim,max5978" , .data = &maxim_max5970}, + { .compatible ="maxim,max77705-battery" , .data = &maxim_mon_max77705}, {} };MODULE_DEVICE_TABLE (of, simple_mfd_i2c_of_match);
Signature · 1 line
2.51.0
PATCH 338/385 mfd: simple-mfd-i2c: Add compatible strings for Layerscape QIXIS FPGA
In reply to Sasha LevinFrom: Ioana Ciornei <[email protected]>
[ Upstream commit 81a2c31257411296862487aaade98b7d9e25dc72 ]
The QIXIS FPGA found on Layerscape boards such as LX2160AQDS, LS1028AQDS etc deals with power-on-reset timing, muxing etc. Use the simple-mfd-i2c as its core driver by adding its compatible string (already found in some dt files). By using the simple-mfd-i2c driver, any child device will have access to the i2c regmap created by it.
Stable-dep-of: 8f34c1a64c53 ("mfd: simple-mfd-i2c: Add Delta TN48M CPLD support")
--- drivers/mfd/simple-mfd-i2c.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/mfd/simple-mfd-i2c.c +2 -0
@@ -99,6 +99,8 @@ static const struct of_device_id simple_mfd_i2c_of_match[] = { { .compatible = "maxim,max5970", .data = &maxim_max5970}, { .compatible = "maxim,max5978", .data = &maxim_max5970}, { .compatible = "maxim,max77705-battery", .data = &maxim_mon_max77705}, + { .compatible = "fsl,lx2160aqds-fpga" }, + { .compatible = "fsl,ls1028aqds-fpga" }, {} };MODULE_DEVICE_TABLE (of, simple_mfd_i2c_of_match);
Signature · 1 line
2.51.0
PATCH 339/385 mfd: simple-mfd-i2c: Add SpacemiT P1 support
In reply to Sasha LevinFrom: Alex Elder <[email protected]>
[ Upstream commit 6fc5d415c10e98ac1b31dd1d5653443e691cdcff ]
Enable support for the RTC and regulators found in the SpacemiT P1 PMIC. Support is implemented by the simple I2C MFD driver.
The P1 PMIC is normally implemented with the SpacemiT K1 SoC. This PMIC provides 6 buck converters and 12 LDO regulators. It also implements a switch, watchdog timer, real-time clock, and more. Initially its RTC and regulators are supported.
Stable-dep-of: 8f34c1a64c53 ("mfd: simple-mfd-i2c: Add Delta TN48M CPLD support")
--- drivers/mfd/Kconfig | 13 +++++++++++++ drivers/mfd/simple-mfd-i2c.c | 17 +++++++++++++++++ 2 files changed, 30 insertions(+)
drivers/mfd/Kconfig +13 -0
@@ -1161,6 +1161,19 @@ config MFD_QCOM_RPM Say M here if you want to include support for the Qualcomm RPM as a module. This will build a module called "qcom_rpm". +config MFD_SPACEMIT_P1 + tristate "SpacemiT P1 PMIC" + depends on ARCH_SPACEMIT || COMPILE_TEST + depends on I2C + select I2C_K1 + select MFD_SIMPLE_MFD_I2C + help + This option supports the I2C-based SpacemiT P1 PMIC, which + contains regulators, a power switch, GPIOs, an RTC, and more. + This option is selected when any of the supported sub-devices + is configured. The basic functionality is implemented by the + simple MFD I2C driver. + config MFD_SPMI_PMIC tristate "Qualcomm SPMI PMICs" depends on ARCH_QCOM || COMPILE_TEST
drivers/mfd/simple-mfd-i2c.c +17 -0
@@ -93,6 +93,22 @@ static const struct simple_mfd_data maxim_mon_max77705 = { .mfd_cell_size = ARRAY_SIZE(max77705_sensor_cells), }; +static const struct regmap_config spacemit_p1_regmap_config = { + .reg_bits =8 , + .val_bits =8 , +}; + +static const struct mfd_cell spacemit_p1_cells[] = { + { .name ="spacemit-p1-regulator" , }, + { .name ="spacemit-p1-rtc" , }, +}; + +static const struct simple_mfd_data spacemit_p1 = { + .regmap_config = &spacemit_p1_regmap_config, + .mfd_cell = spacemit_p1_cells, + .mfd_cell_size =ARRAY_SIZE (spacemit_p1_cells), +}; +static const struct of_device_id simple_mfd_i2c_of_match[] = { { .compatible ="kontron,sl28cpld" }, { .compatible ="silergy,sy7636a" , .data = &silergy_sy7636a},
@@ -101,6 +117,7 @@ static const struct of_device_id simple_mfd_i2c_of_match[] = { { .compatible = "maxim,max77705-battery", .data = &maxim_mon_max77705}, { .compatible = "fsl,lx2160aqds-fpga" }, { .compatible = "fsl,ls1028aqds-fpga" }, + { .compatible = "spacemit,p1", .data = &spacemit_p1, }, {} };MODULE_DEVICE_TABLE (of, simple_mfd_i2c_of_match);
Signature · 1 line
2.51.0
PATCH 340/385 mfd: simple-mfd-i2c: Keep compatible strings in alphabetical order
In reply to Sasha LevinFrom: Ioana Ciornei <[email protected]>
[ Upstream commit 3ed50d77924ff2e35918739df145dd429cee0ce4 ]
Reorder the of_device_id structures so that they are in alphabetical order.
Stable-dep-of: 8f34c1a64c53 ("mfd: simple-mfd-i2c: Add Delta TN48M CPLD support")
--- drivers/mfd/simple-mfd-i2c.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/mfd/simple-mfd-i2c.c +3 -3
@@ -110,13 +110,13 @@ static const struct simple_mfd_data spacemit_p1 = { };static const struct of_device_id simple_mfd_i2c_of_match[] = { + { .compatible ="fsl,ls1028aqds-fpga" }, + { .compatible ="fsl,lx2160aqds-fpga" }, { .compatible ="kontron,sl28cpld" }, - { .compatible ="silergy,sy7636a" , .data = &silergy_sy7636a}, { .compatible ="maxim,max5970" , .data = &maxim_max5970}, { .compatible ="maxim,max5978" , .data = &maxim_max5970}, { .compatible ="maxim,max77705-battery" , .data = &maxim_mon_max77705}, - { .compatible ="fsl,lx2160aqds-fpga" }, - { .compatible ="fsl,ls1028aqds-fpga" }, + { .compatible ="silergy,sy7636a" , .data = &silergy_sy7636a}, { .compatible ="spacemit,p1" , .data = &spacemit_p1, }, {} };
Signature · 1 line
2.51.0
PATCH 341/385 mfd: simple-mfd-i2c: Add Delta TN48M CPLD support
In reply to Sasha LevinFrom: Robert Marko <[email protected]>
[ Upstream commit 8f34c1a64c5394d2b51d3fba197947dc4b0b48a0 ]
Delta TN48M switches have a Lattice CPLD that serves multiple purposes including being a GPIO expander.
So, lets use the simple I2C MFD driver to provide the MFD core.
Also add a virtual symbol which pulls in the simple-mfd-i2c driver and provide a common symbol on which the subdevice drivers can depend on.
--- drivers/mfd/Kconfig | 11 +++++++++++ drivers/mfd/simple-mfd-i2c.c | 1 + 2 files changed, 12 insertions(+)
drivers/mfd/Kconfig +11 -0
@@ -347,6 +347,17 @@ config MFD_CS47L92 help Support for Cirrus Logic CS42L92, CS47L92 and CS47L93 Smart Codecs +config MFD_TN48M_CPLD + tristate "Delta Networks TN48M switch CPLD driver" + depends on I2C + depends on ARCH_MVEBU || COMPILE_TEST + select MFD_SIMPLE_MFD_I2C + help + Select this option to enable support for Delta Networks TN48M switch + CPLD. It consists of reset and GPIO drivers. CPLD provides GPIOS-s + for the SFP slots as well as power supply related information. + SFP support depends on the GPIO driver being selected. + config PMIC_DA903X bool "Dialog Semiconductor DA9030/DA9034 PMIC Support" depends on I2C=y
drivers/mfd/simple-mfd-i2c.c +1 -0
@@ -110,6 +110,7 @@ static const struct simple_mfd_data spacemit_p1 = { };static const struct of_device_id simple_mfd_i2c_of_match[] = { + { .compatible ="delta,tn48m-cpld" }, { .compatible ="fsl,ls1028aqds-fpga" }, { .compatible ="fsl,lx2160aqds-fpga" }, { .compatible ="kontron,sl28cpld" },
Signature · 1 line
2.51.0
PATCH 342/385 drivers: iio: mpu3050: use dev_err_probe for regulator request
In reply to Sasha LevinFrom: Svyatoslav Ryhel <[email protected]>
[ Upstream commit b010880b9936da14f8035585ab57577aa05be23a ]
Regulator requesting may result in deferred probing error which will abort driver probing. To avoid this just use dev_err_probe which handles deferred probing.
--- drivers/iio/gyro/mpu3050-core.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/iio/gyro/mpu3050-core.c +2 -4
@@ -1165,10 +1165,8 @@ int mpu3050_common_probe(struct device *dev, mpu3050->regs[1 ].supply = mpu3050_reg_vlogic; ret =devm_regulator_bulk_get (dev,ARRAY_SIZE (mpu3050->regs), mpu3050->regs); -if (ret) { -dev_err (dev,"Cannot get regulators\n" ); -return ret; - } +if (ret) +return dev_err_probe (dev, ret,"Cannot get regulators\n" ); ret =mpu3050_power_up (mpu3050);if (ret)
Signature · 1 line
2.51.0
PATCH 343/385 usb: bdc: fix sleep during atomic
In reply to Sasha LevinFrom: Justin Chen <[email protected]>
[ Upstream commit f1195ca3b4bbd001d3f1264dce91f83dec7777f5 ]
bdc_run() can be ran during atomic context leading to a sleep during atomic warning. Fix this by replacing read_poll_timeout() with read_poll_timeout_atomic().
--- drivers/usb/gadget/udc/bdc/bdc_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/gadget/udc/bdc/bdc_core.c +2 -2
@@ -35,8 +35,8 @@ static int poll_oip(struct bdc *bdc, u32 usec)u32 status;int ret; - ret =readl_poll_timeout (bdc->regs +BDC_BDCSC , status, - (BDC_CSTS (status) !=BDC_OIP ),10 , usec); + ret =readl_poll_timeout_atomic (bdc->regs +BDC_BDCSC , status, + (BDC_CSTS (status) !=BDC_OIP ),10 , usec);if (ret)dev_err (bdc->dev,"operation timedout BDCSC: 0x%08x\n" , status);else
Signature · 1 line
2.51.0
PATCH 344/385 pinctrl: equilibrium: Fix device node reference leak in pinbank_init()
In reply to Sasha LevinFrom: Felix Gu <[email protected]>
[ Upstream commit c0b4a4feeb43305a754893d8d9c6b2b5a52d45ac ]
When calling of_parse_phandle_with_fixed_args(), the caller is responsible to call of_node_put() to release the reference of device node.
In pinbank_init(), the reference of the node obtained from the "gpio-ranges" property is never released, resulting in a reference count leak.
Add the missing of_node_put() call to fix the leak.
--- drivers/pinctrl/pinctrl-equilibrium.c | 1 + 1 file changed, 1 insertion(+)
drivers/pinctrl/pinctrl-equilibrium.c +1 -0
@@ -841,6 +841,7 @@ static int pinbank_init(struct device_node *np, bank->pin_base = spec.args[1 ]; bank->nr_pins = spec.args[2 ]; +of_node_put (spec.np); bank->aval_pinmap =readl (bank->membase +REG_AVAIL ); bank->id = id;
Signature · 1 line
2.51.0
PATCH 345/385 ovl: Fix uninit-value in ovl_fill_real
In reply to Sasha LevinFrom: Qing Wang <[email protected]>
[ Upstream commit 1992330d90dd766fcf1730fd7bf2d6af65370ac4 ]
Syzbot reported a KMSAN uninit-value issue in ovl_fill_real.
This iusse's call chain is:__do_sys_getdents64()
-> iterate_dir()
...
-> ext4_readdir()
-> fscrypt_fname_alloc_buffer() // alloc
-> fscrypt_fname_disk_to_usr // write without tail '\0'
-> dir_emit()
-> ovl_fill_real() // read by strcmp()The string is used to store the decrypted directory entry name for an encrypted inode. As shown in the call chain, fscrypt_fname_disk_to_usr() write it without null-terminate. However, ovl_fill_real() uses strcmp() to compare the name against "..", which assumes a null-terminated string and may trigger a KMSAN uninit-value warning when the buffer tail contains uninit data.
--- fs/overlayfs/readdir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/overlayfs/readdir.c +1 -1
@@ -673,7 +673,7 @@ static bool ovl_fill_real(struct dir_context *ctx, const char *name, container_of(ctx, struct ovl_readdir_translate, ctx);struct dir_context *orig_ctx = rdt->orig_ctx; -if (rdt->parent_ino &&strcmp (name,".." ) ==0 ) { +if (rdt->parent_ino && namelen ==2 && !strncmp (name,".." ,2 )) { ino = rdt->parent_ino; }else if (rdt->cache) {struct ovl_cache_entry *p;
Signature · 1 line
2.51.0
PATCH 346/385 iio: sca3000: Fix a resource leak in sca3000_probe()
In reply to Sasha LevinFrom: Harshit Mogalapalli <[email protected]>
[ Upstream commit 62b44ebc1f2c71db3ca2d4737c52e433f6f03038 ]
spi->irq from request_threaded_irq() not released when iio_device_register() fails. Add an return value check and jump to a common error handler when iio_device_register() fails.
--- drivers/iio/accel/sca3000.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/iio/accel/sca3000.c +5 -1
@@ -1496,7 +1496,11 @@ static int sca3000_probe(struct spi_device *spi)if (ret) goto error_free_irq; -return iio_device_register (indio_dev); + ret =iio_device_register (indio_dev); +if (ret) + goto error_free_irq; + +return 0 ; error_free_irq:if (spi->irq)
Signature · 1 line
2.51.0
PATCH 347/385 pinctrl: qcom: sm8250-lpass-lpi: Fix i2s2_data_groups definition
In reply to Sasha LevinFrom: Luca Weiss <[email protected]>
[ Upstream commit eabf273c8466af3f033473c2d2267a6ea7946d57 ]
The i2s2_data function is available on both gpio12 and gpio13. Fix the groups definition.
--- drivers/pinctrl/qcom/pinctrl-sm8250-lpass-lpi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/qcom/pinctrl-sm8250-lpass-lpi.c +1 -1
@@ -73,7 +73,7 @@ static const char * const i2s1_ws_groups[] = { "gpio7" };static const char *const i2s1_data_groups[] = {"gpio8" ,"gpio9" };static const char *const wsa_swr_clk_groups[] = {"gpio10" };static const char *const wsa_swr_data_groups[] = {"gpio11" }; -static const char *const i2s2_data_groups[] = {"gpio12" ,"gpio12" }; +static const char *const i2s2_data_groups[] = {"gpio12" ,"gpio13" };static const struct lpi_pingroup sm8250_groups[] = {LPI_PINGROUP (0 ,0 , swr_tx_clk, qua_mi2s_sclk, _, _),
Signature · 1 line
2.51.0
PATCH 348/385 pinctrl: single: fix refcount leak in pcs_add_gpio_func()
In reply to Sasha LevinFrom: Wei Li <[email protected]>
[ Upstream commit 353353309b0f7afa407df29e455f9d15b5acc296 ]
of_parse_phandle_with_args() returns a device_node pointer with refcount incremented in gpiospec.np. The loop iterates through all phandles but never releases the reference, causing a refcount leak on each iteration.
Add of_node_put() calls to release the reference after extracting the needed arguments and on the error path when devm_kzalloc() fails.
This bug was detected by our static analysis tool and verified by my code review.
--- drivers/pinctrl/pinctrl-single.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/pinctrl/pinctrl-single.c +2 -0
@@ -1359,6 +1359,7 @@ static int pcs_add_gpio_func(struct device_node *node, struct pcs_device *pcs) } range =devm_kzalloc (pcs->dev,sizeof (*range),GFP_KERNEL );if (!range) { +of_node_put (gpiospec.np); ret = -ENOMEM ;break ; }
@@ -1368,6 +1369,7 @@ static int pcs_add_gpio_func(struct device_node *node, struct pcs_device *pcs)mutex_lock (&pcs->mutex);list_add_tail (&range->node, &pcs->gpiofuncs);mutex_unlock (&pcs->mutex); +of_node_put (gpiospec.np); }return ret; }
Signature · 1 line
2.51.0
PATCH 349/385 leds: qcom-lpg: Check the return value of regmap_bulk_write()
In reply to Sasha LevinFrom: Haotian Zhang <[email protected]>
[ Upstream commit f42033b5ce8c79c5db645916c9a72ee3e10cecfa ]
The lpg_lut_store() function currently ignores the return value of regmap_bulk_write() and always returns 0. This can cause hardware write failures to go undetected, leading the caller to believe LUT programming succeeded when it may have failed.
Check the return value of regmap_bulk_write() in lpg_lut_store and return the error to the caller on failure.
--- drivers/leds/rgb/leds-qcom-lpg.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/leds/rgb/leds-qcom-lpg.c +5 -3
@@ -368,7 +368,7 @@ static int lpg_lut_store(struct lpg *lpg, struct led_pattern *pattern, {unsigned int idx;u16 val; -int i; +int i, ret; idx =bitmap_find_next_zero_area (lpg->lut_bitmap, lpg->lut_size,0 , len,0 );
@@ -378,8 +378,10 @@ static int lpg_lut_store(struct lpg *lpg, struct led_pattern *pattern,for (i =0 ; i < len; i++) { val = pattern[i].brightness; -regmap_bulk_write (lpg->map, lpg->lut_base +LPG_LUT_REG (idx + i), - &val,sizeof (val)); + ret =regmap_bulk_write (lpg->map, lpg->lut_base +LPG_LUT_REG (idx + i), + &val,sizeof (val)); +if (ret) +return ret; }bitmap_set (lpg->lut_bitmap, idx, len);
Signature · 1 line
2.51.0
PATCH 350/385 backlight: qcom-wled: Support ovp values for PMI8994
In reply to Sasha LevinFrom: Barnabás Czémán <[email protected]>
[ Upstream commit f29f972a6e7e3f187ea4d89b98a76c1981ca4d53 ]
WLED4 found in PMI8994 supports different ovp values.
--- drivers/video/backlight/qcom-wled.c | 41 +++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-)
drivers/video/backlight/qcom-wled.c +39 -2
@@ -1244,6 +1244,15 @@ static const struct wled_var_cfg wled4_ovp_cfg = { .size = ARRAY_SIZE(wled4_ovp_values), }; +static const u32 pmi8994_wled_ovp_values[] = { +31000 ,29500 ,19400 ,17800 , +}; + +static const struct wled_var_cfg pmi8994_wled_ovp_cfg = { + .values = pmi8994_wled_ovp_values, + .size =ARRAY_SIZE (pmi8994_wled_ovp_values), +}; +static inline u32 wled5_ovp_values_fn (u32 idx) {/*
@@ -1357,6 +1366,29 @@ static int wled_configure(struct wled *wled) }, }; +const struct wled_u32_opts pmi8994_wled_opts[] = { + { + .name ="qcom,current-boost-limit" , + .val_ptr = &cfg->boost_i_limit, + .cfg = &wled4_boost_i_limit_cfg, + }, + { + .name ="qcom,current-limit-microamp" , + .val_ptr = &cfg->string_i_limit, + .cfg = &wled4_string_i_limit_cfg, + }, + { + .name ="qcom,ovp-millivolt" , + .val_ptr = &cfg->ovp, + .cfg = &pmi8994_wled_ovp_cfg, + }, + { + .name ="qcom,switching-freq" , + .val_ptr = &cfg->switch_freq, + .cfg = &wled3_switch_freq_cfg, + }, + }; +const struct wled_u32_opts wled5_opts[] = { { .name ="qcom,current-boost-limit" ,
@@ -1423,8 +1455,13 @@ static int wled_configure(struct wled *wled)break ;case 4 : - u32_opts = wled4_opts; - size =ARRAY_SIZE (wled4_opts); +if (of_device_is_compatible (dev->of_node,"qcom,pmi8994-wled" )) { + u32_opts = pmi8994_wled_opts; + size =ARRAY_SIZE (pmi8994_wled_opts); + }else { + u32_opts = wled4_opts; + size =ARRAY_SIZE (wled4_opts); + } *cfg = wled4_config_defaults; wled->wled_set_brightness = wled4_set_brightness; wled->wled_sync_toggle = wled3_sync_toggle;
Signature · 1 line
2.51.0
PATCH 351/385 backlight: qcom-wled: Change PM8950 WLED configurations
In reply to Sasha LevinFrom: Barnabás Czémán <[email protected]>
[ Upstream commit 83333aa97441ba7ce32b91e8a007c72d316a1c67 ]
PMI8950 WLED needs same configurations as PMI8994 WLED.
--- drivers/video/backlight/qcom-wled.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/video/backlight/qcom-wled.c +2 -1
@@ -1455,7 +1455,8 @@ static int wled_configure(struct wled *wled)break ;case 4 : -if (of_device_is_compatible (dev->of_node,"qcom,pmi8994-wled" )) { +if (of_device_is_compatible (dev->of_node,"qcom,pmi8950-wled" ) || +of_device_is_compatible (dev->of_node,"qcom,pmi8994-wled" )) { u32_opts = pmi8994_wled_opts; size =ARRAY_SIZE (pmi8994_wled_opts); }else {
Signature · 1 line
2.51.0
PATCH 352/385 dmaengine: fsl-edma: don't explicitly disable clocks in .remove()
In reply to Sasha LevinFrom: Jared Kangas <[email protected]>
[ Upstream commit 666c53e94c1d0bf0bdf14c49505ece9ddbe725bc ]
The clocks in fsl_edma_engine::muxclk are allocated and enabled with devm_clk_get_enabled(), which automatically cleans these resources up, but these clocks are also manually disabled in fsl_edma_remove(). This causes warnings on driver removal for each clock:
edma_module already disabled
WARNING: CPU: 0 PID: 418 at drivers/clk/clk.c:1200 clk_core_disable+0x198/0x1c8
[...]
Call trace:
clk_core_disable+0x198/0x1c8 (P)
clk_disable+0x34/0x58
fsl_edma_remove+0x74/0xe8 [fsl_edma]
[...]
---[ end trace 0000000000000000 ]---
edma_module already unprepared
WARNING: CPU: 0 PID: 418 at drivers/clk/clk.c:1059 clk_core_unprepare+0x1f8/0x220
[...]
Call trace:
clk_core_unprepare+0x1f8/0x220 (P)
clk_unprepare+0x34/0x58
fsl_edma_remove+0x7c/0xe8 [fsl_edma]
[...]
---[ end trace 0000000000000000 ]---Fix these warnings by removing the unnecessary fsl_disable_clocks() call in fsl_edma_remove().
--- drivers/dma/fsl-edma-main.c | 1 - 1 file changed, 1 deletion(-)
drivers/dma/fsl-edma-main.c +0 -1
@@ -708,7 +708,6 @@ static void fsl_edma_remove(struct platform_device *pdev)of_dma_controller_free (np);dma_async_device_unregister (&fsl_edma->dma_dev);fsl_edma_cleanup_vchan (&fsl_edma->dma_dev); -fsl_disable_clocks (fsl_edma, fsl_edma->drvdata->dmamuxs); }static int fsl_edma_suspend_late (struct device *dev)
Signature · 1 line
2.51.0
PATCH 353/385 drbd: always set BLK_FEAT_STABLE_WRITES
In reply to Sasha LevinFrom: Christoph Böhmwalder <[email protected]>
[ Upstream commit 2ebc8d600fb907fa6b1e7095c0b6d84fc47e91ea ]
DRBD requires stable pages because it may read the same bio data multiple times for local disk I/O and network transmission, and in some cases for calculating checksums.
The BLK_FEAT_STABLE_WRITES flag is set when the device is first created, but blk_set_stacking_limits() clears it whenever a backing device is attached. In some cases the flag may be inherited from the backing device, but we want it to be enabled at all times.
Unconditionally re-enable BLK_FEAT_STABLE_WRITES in drbd_reconsider_queue_parameters() after the queue parameter negotiations.
Also, document why we want this flag enabled in the first place.
--- drivers/block/drbd/drbd_main.c | 3 --- drivers/block/drbd/drbd_nl.c | 20 +++++++++++++++++++- 2 files changed, 19 insertions(+), 4 deletions(-)
drivers/block/drbd/drbd_main.c +0 -3
@@ -2683,9 +2683,6 @@ enum drbd_ret_code drbd_create_device(struct drbd_config_context *adm_ctx, unsig* connect. */ .max_hw_sectors = DRBD_MAX_BIO_SIZE_SAFE >> 8, - .features =BLK_FEAT_WRITE_CACHE |BLK_FEAT_FUA | -BLK_FEAT_ROTATIONAL | - BLK_FEAT_STABLE_WRITES, }; device =minor_to_device (minor);
drivers/block/drbd/drbd_nl.c +19 -1
@@ -1296,6 +1296,8 @@ void drbd_reconsider_queue_parameters(struct drbd_device *device, lim.max_segments =drbd_backing_dev_max_segments (device); }else { lim.max_segments =BLK_MAX_SEGMENTS ; + lim.features =BLK_FEAT_WRITE_CACHE |BLK_FEAT_FUA | +BLK_FEAT_ROTATIONAL |BLK_FEAT_STABLE_WRITES ; } lim.max_hw_sectors = new >>SECTOR_SHIFT ;
@@ -1318,8 +1320,24 @@ void drbd_reconsider_queue_parameters(struct drbd_device *device, lim.max_hw_discard_sectors =0 ; } -if (bdev) +if (bdev) {blk_stack_limits (&lim, &b->limits,0 ); +/* +* blk_set_stacking_limits() cleared the features, and +* blk_stack_limits() may or may not have inherited +* BLK_FEAT_STABLE_WRITES from the backing device. +* +* DRBD always requires stable writes because: +* 1. The same bio data is read for both local disk I/O and +* network transmission. If the page changes mid-flight, +* the local and remote copies could diverge. +* 2. When data integrity is enabled, DRBD calculates a +* checksum before sending the data. If the page changes +* between checksum calculation and transmission, the +* receiver will detect a checksum mismatch. +*/ + lim.features |=BLK_FEAT_STABLE_WRITES ; + }/* * If we can handle "zeroes" efficiently on the protocol, we want to do
Signature · 1 line
2.51.0
PATCH 354/385 io_uring/cancel: de-unionize file and user_data in struct io_cancel_data
In reply to Sasha LevinFrom: Jens Axboe <[email protected]>
[ Upstream commit 22dbb0987bd1e0ec3b1e4ad20756a98f99aa4a08 ]
By having them share the same space in struct io_cancel_data, it ends up disallowing IORING_ASYNC_CANCEL_FD|IORING_ASYNC_CANCEL_USERDATA from working. Eg you cannot match on both a file and user_data for cancelation purposes. This obviously isn't a common use case as nobody has reported this, but it does result in -ENOENT potentially being returned when trying to match on both, rather than actually doing what the API says it would.
--- io_uring/cancel.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
io_uring/cancel.h +2 -4
@@ -6,10 +6,8 @@struct io_cancel_data {struct io_ring_ctx *ctx; -union { -u64 data; -struct file *file; - }; +u64 data; +struct file *file;u8 opcode;u32 flags;int seq;
Signature · 1 line
2.51.0
PATCH 355/385 fs/ntfs3: Initialize new folios before use
In reply to Sasha LevinFrom: Bartlomiej Kubik <[email protected]>
[ Upstream commit f223ebffa185cc8da934333c5a31ff2d4f992dc9 ]
KMSAN reports an uninitialized value in longest_match_std(), invoked from ntfs_compress_write(). When new folios are allocated without being marked uptodate and ni_read_frame() is skipped because the caller expects the frame to be completely overwritten, some reserved folios may remain only partially filled, leaving the rest memory uninitialized.
--- fs/ntfs3/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ntfs3/file.c +1 -1
@@ -964,7 +964,7 @@ static int ntfs_get_frame_pages(struct address_space *mapping, pgoff_t index, folio =__filemap_get_folio (mapping, index,FGP_LOCK |FGP_ACCESSED |FGP_CREAT , - gfp_mask); + gfp_mask | __GFP_ZERO);if (IS_ERR (folio)) {while (npages--) { folio =page_folio (pages[npages]);
Signature · 1 line
2.51.0
PATCH 356/385 fs/ntfs3: prevent infinite loops caused by the next valid being the same
In reply to Sasha LevinFrom: Edward Adam Davis <[email protected]>
[ Upstream commit 27b75ca4e51e3e4554dc85dbf1a0246c66106fd3 ]
When processing valid within the range [valid : pos), if valid cannot be retrieved correctly, for example, if the retrieved valid value is always the same, this can trigger a potential infinite loop, similar to the hung problem reported by syzbot [1].
Adding a check for the valid value within the loop body, and terminating the loop and returning -EINVAL if the value is the same as the current value, can prevent this.
[1]
INFO: task syz.4.21:6056 blocked for more than 143 seconds. Call Trace: rwbase_write_lock+0x14f/0x750 kernel/locking/rwbase_rt.c:244 inode_lock include/linux/fs.h:1027 [inline] ntfs_file_write_iter+0xe6/0x870 fs/ntfs3/file.c:1284
--- fs/ntfs3/file.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
fs/ntfs3/file.c +6 -2
@@ -1045,8 +1045,12 @@ static ssize_t ntfs_compress_write(struct kiocb *iocb, struct iov_iter *from) goto out;if (lcn ==SPARSE_LCN ) { - ni->i_valid = valid = - frame_vbo + ((u64 )clen << sbi->cluster_bits); + valid = frame_vbo + ((u64 )clen << sbi->cluster_bits); +if (ni->i_valid == valid) { + err = -EINVAL ; + goto out; + } + ni->i_valid = valid;continue ; }
Signature · 1 line
2.51.0
PATCH 357/385 fs/ntfs3: Fix slab-out-of-bounds read in DeleteIndexEntryRoot
In reply to Sasha LevinFrom: Jiasheng Jiang <[email protected]>
[ Upstream commit b2bc7c44ed1779fc9eaab9a186db0f0d01439622 ]
In the 'DeleteIndexEntryRoot' case of the 'do_action' function, the entry size ('esize') is retrieved from the log record without adequate bounds checking.
Specifically, the code calculates the end of the entry ('e2') using:
e2 = Add2Ptr(e1, esize);
It then calculates the size for memmove using 'PtrOffset(e2, ...)', which subtracts the end pointer from the buffer limit. If 'esize' is maliciously large, 'e2' exceeds the used buffer size. This results in a negative offset which, when cast to size_t for memmove, interprets as a massive unsigned integer, leading to a heap buffer overflow.
This commit adds a check to ensure that the entry size ('esize') strictly fits within the remaining used space of the index header before performing memory operations.
--- fs/ntfs3/fslog.c | 3 +++ 1 file changed, 3 insertions(+)
fs/ntfs3/fslog.c +3 -0
@@ -3431,6 +3431,9 @@ static int do_action(struct ntfs_log *log, struct OPEN_ATTR_ENRTY *oe, e1 =Add2Ptr (attr,le16_to_cpu (lrh->attr_off)); esize =le16_to_cpu (e1->size); +if (PtrOffset (e1,Add2Ptr (hdr, used)) < esize) + goto dirty_vol; + e2 =Add2Ptr (e1, esize);memmove (e1, e2,PtrOffset (e2,Add2Ptr (hdr, used)));
Signature · 1 line
2.51.0
PATCH 358/385 ACPI: CPPC: Fix remaining for_each_possible_cpu() to use online CPUs
In reply to Sasha LevinFrom: Sean V Kelley <[email protected]>
[ Upstream commit 56eb0c0ed345da7815274aa821a8546a073d7e97 ]
per_cpu(cpc_desc_ptr, cpu) object is initialized for only the online CPUs via acpi_soft_cpu_online() --> __acpi_processor_start() --> acpi_cppc_processor_probe().
However, send_pcc_cmd() and acpi_get_psd_map() still iterate over all possible CPUs. In acpi_get_psd_map(), encountering an offline CPU returns -EFAULT, causing cppc_cpufreq initialization to fail.
This breaks systems booted with "nosmt" or "nosmt=force".
Fix by using for_each_online_cpu() in both functions.
--- drivers/acpi/cppc_acpi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/acpi/cppc_acpi.c +2 -2
@@ -349,7 +349,7 @@ static int send_pcc_cmd(int pcc_ss_id, u16 cmd) end:if (cmd ==CMD_WRITE ) {if (unlikely (ret)) { -for_each_possible_cpu (i) { +for_each_online_cpu (i) {struct cpc_desc *desc =per_cpu (cpc_desc_ptr, i);if (!desc)
@@ -511,7 +511,7 @@ int acpi_get_psd_map(unsigned int cpu, struct cppc_cpudata *cpu_data)else if (pdomain->coord_type ==DOMAIN_COORD_TYPE_SW_ANY ) cpu_data->shared_type =CPUFREQ_SHARED_TYPE_ANY ; -for_each_possible_cpu (i) { +for_each_online_cpu (i) {if (i == cpu)continue ;
Signature · 1 line
2.51.0
PATCH 359/385 powercap: intel_rapl_tpmi: Remove FW_BUG from invalid version check
In reply to Sasha LevinFrom: Kuppuswamy Sathyanarayanan <[email protected]>
[ Upstream commit c7d54dafa042cf379859dba265fe5afef6fa8770 ]
On partitioned systems, multiple TPMI instances may exist per package, but RAPL registers are only valid on one instance since RAPL has package-scope control. Other instances return invalid versions during domain parsing, which is expected behavior on such systems.
Currently this generates a firmware bug warning:
intel_rapl_tpmi: [Firmware Bug]: Invalid version
Remove the FW_BUG tag, downgrade to pr_debug(), and update the message to clarify that invalid versions are expected on partitioned systems where only one instance can be valid.
--- drivers/powercap/intel_rapl_tpmi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/powercap/intel_rapl_tpmi.c +1 -1
@@ -156,7 +156,7 @@ static int parse_one_domain(struct tpmi_rapl_package *trp, u32 offset) tpmi_domain_flags = tpmi_domain_header >>32 &0xffff ;if (tpmi_domain_version ==TPMI_VERSION_INVALID ) { -pr_warn (FW_BUG "Invalid version\n" ); +pr_debug ("Invalid version, other instances may be valid\n" );return -ENODEV ; }
Signature · 1 line
2.51.0
PATCH 360/385 kbuild: Add objtool to top-level clean target
In reply to Sasha LevinFrom: Josh Poimboeuf <[email protected]>
[ Upstream commit 68b4fe32d73789dea23e356f468de67c8367ef8f ]
Objtool is an integral part of the build, make sure it gets cleaned by "make clean" and "make mrproper".
--- Makefile | 11 ++++++++++- tools/objtool/Makefile | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-)
Makefile +10 -1
@@ -1370,6 +1370,15 @@ ifneq ($(wildcard $(resolve_btfids_O)),) $(Q)$(MAKE) -sC $(srctree)/tools/bpf/resolve_btfids O=$(resolve_btfids_O) clean endif +PHONY += objtool_clean + +objtool_O = $(abspath $(objtree))/tools/objtool + +objtool_clean: +ifneq ($(wildcard $(objtool_O)),) + $(Q)$(MAKE) -sC $(abs_srctree)/tools/objtool O=$(objtool_O) srctree=$(abs_srctree) clean +endif + tools/: FORCE $(Q)mkdir -p $(objtree)/tools $(Q)$(MAKE) O=$(abspath $(objtree)) subdir=tools -C $(srctree)/tools/
@@ -1527,7 +1536,7 @@ vmlinuxclean: $(Q)$(CONFIG_SHELL) $(srctree)/scripts/link-vmlinux.sh clean $(Q)$(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) clean) -clean: archclean vmlinuxclean resolve_btfids_clean +clean: archclean vmlinuxclean resolve_btfids_clean objtool_clean # mrproper - Delete all generated files, including .config #
tools/objtool/Makefile +2 -0
@@ -7,6 +7,8 @@ srctree := $(patsubst %/,%,$(dir $(CURDIR))) srctree := $(patsubst %/,%,$(dir $(srctree))) endif +RM ?= rm -f + LIBSUBCMD_DIR = $(srctree)/tools/lib/subcmd/ ifneq ($(OUTPUT),) LIBSUBCMD_OUTPUT = $(abspath $(OUTPUT))/libsubcmd
Signature · 1 line
2.51.0
PATCH 361/385 selftests/memfd: use IPC semaphore instead of SIGSTOP/SIGCONT
In reply to Sasha LevinFrom: Aristeu Rozanski <[email protected]>
[ Upstream commit b24335521de92fd2ee22460072b75367ca8860b0 ]
selftests/memfd: use IPC semaphore instead of SIGSTOP/SIGCONT
In order to synchronize new processes to test inheritance of memfd_noexec sysctl, memfd_test sets up the sysctl with a value before creating the new process. The new process then sends itself a SIGSTOP in order to wait for the parent to flip the sysctl value and send a SIGCONT signal.
This would work as intended if it wasn't the fact that the new process is being created with CLONE_NEWPID, which creates a new PID namespace and the new process has PID 1 in this namespace. There're restrictions on sending signals to PID 1 and, although it's relaxed for other than root PID namespace, it's biting us here. In this specific case the SIGSTOP sent by the new process is ignored (no error to kill() is returned) and it never stops its execution. This is usually not noticiable as the parent usually manages to set the new sysctl value before the child has a chance to run and the test succeeds. But if you run the test in a loop, it eventually reproduces:
while [ 1 ]; do ./memfd_test >log 2>&1 || break; done; cat log
So this patch replaces the SIGSTOP/SIGCONT synchronization with IPC semaphore.
--- tools/testing/selftests/memfd/memfd_test.c | 113 +++++++++++++++++++-- 1 file changed, 105 insertions(+), 8 deletions(-)
tools/testing/selftests/memfd/memfd_test.c +105 -8
@@ -18,6 +18,9 @@#include <sys/stat.h> #include <sys/syscall.h> #include <sys/wait.h> +#include <sys/types.h> +#include <sys/ipc.h> +#include <sys/sem.h> #include <unistd.h> #include <ctype.h>
@@ -39,6 +42,20 @@ F_SEAL_EXEC)#define MFD_NOEXEC_SEAL 0x0008U +union semun { +int val; +struct semid_ds *buf; +unsigned short int *array; +struct seminfo *__buf; +}; + +/* +* we use semaphores on nested wait tasks due the use of CLONE_NEWPID: the +* child will be PID 1 and can't send SIGSTOP to themselves due special +* treatment of the init task, so the SIGSTOP/SIGCONT synchronization +* approach can't be used here. +*/ +#define SEM_KEY 0xdeadbeef/* * Default is not to test hugetlbfs
@@ -1291,8 +1308,22 @@ static int sysctl_nested(void *arg)static int sysctl_nested_wait (void *arg) { -/* Wait for a SIGCONT. */ -kill (getpid (),SIGSTOP ); +int sem =semget (SEM_KEY ,1 ,0600 ); +struct sembuf sembuf; + +if (sem <0 ) { +perror ("semget:" ); +abort (); + } + sembuf.sem_num =0 ; + sembuf.sem_flg =0 ; + sembuf.sem_op =0 ; + +if (semop (sem, &sembuf,1 ) <0 ) { +perror ("semop:" ); +abort (); + } +return sysctl_nested (arg); }
@@ -1313,7 +1344,9 @@ static void test_sysctl_sysctl2_failset(void)static int sysctl_nested_child (void *arg) { -int pid; +int pid, sem; +union semun semun; +struct sembuf sembuf;printf ("%s nested sysctl 0\n" , memfd_str);sysctl_assert_write ("0" );
@@ -1347,23 +1380,53 @@ static int sysctl_nested_child(void *arg) test_sysctl_sysctl2_failset);join_thread (pid); + sem =semget (SEM_KEY ,1 ,IPC_CREAT |0600 ); +if (sem <0 ) { +perror ("semget:" ); +return 1 ; + } + semun.val =1 ; + sembuf.sem_op =-1 ; + sembuf.sem_flg =0 ; + sembuf.sem_num =0 ; +/* Verify that the rules are actually inherited after fork. */ printf ("%s nested sysctl 0 -> 1 after fork\n" , memfd_str);sysctl_assert_write ("0" ); +if (semctl (sem,0 ,SETVAL , semun) <0 ) { +perror ("semctl:" ); +return 1 ; + } + pid =spawn_thread (CLONE_NEWPID , sysctl_nested_wait, test_sysctl_sysctl1_failset);sysctl_assert_write ("1" ); -kill (pid,SIGCONT ); + +/* Allow child to continue */ +if (semop (sem, &sembuf,1 ) <0 ) { +perror ("semop:" ); +return 1 ; + }join_thread (pid);printf ("%s nested sysctl 0 -> 2 after fork\n" , memfd_str);sysctl_assert_write ("0" ); +if (semctl (sem,0 ,SETVAL , semun) <0 ) { +perror ("semctl:" ); +return 1 ; + } + pid =spawn_thread (CLONE_NEWPID , sysctl_nested_wait, test_sysctl_sysctl2_failset);sysctl_assert_write ("2" ); -kill (pid,SIGCONT ); + +/* Allow child to continue */ +if (semop (sem, &sembuf,1 ) <0 ) { +perror ("semop:" ); +return 1 ; + }join_thread (pid);/*
@@ -1373,28 +1436,62 @@ static int sysctl_nested_child(void *arg)*/ printf ("%s nested sysctl 2 -> 1 after fork\n" , memfd_str);sysctl_assert_write ("2" ); + +if (semctl (sem,0 ,SETVAL , semun) <0 ) { +perror ("semctl:" ); +return 1 ; + } + pid =spawn_thread (CLONE_NEWPID , sysctl_nested_wait, test_sysctl_sysctl2);sysctl_assert_write ("1" ); -kill (pid,SIGCONT ); + +/* Allow child to continue */ +if (semop (sem, &sembuf,1 ) <0 ) { +perror ("semop:" ); +return 1 ; + }join_thread (pid);printf ("%s nested sysctl 2 -> 0 after fork\n" , memfd_str);sysctl_assert_write ("2" ); + +if (semctl (sem,0 ,SETVAL , semun) <0 ) { +perror ("semctl:" ); +return 1 ; + } + pid =spawn_thread (CLONE_NEWPID , sysctl_nested_wait, test_sysctl_sysctl2);sysctl_assert_write ("0" ); -kill (pid,SIGCONT ); + +/* Allow child to continue */ +if (semop (sem, &sembuf,1 ) <0 ) { +perror ("semop:" ); +return 1 ; + }join_thread (pid);printf ("%s nested sysctl 1 -> 0 after fork\n" , memfd_str);sysctl_assert_write ("1" ); + +if (semctl (sem,0 ,SETVAL , semun) <0 ) { +perror ("semctl:" ); +return 1 ; + } + pid =spawn_thread (CLONE_NEWPID , sysctl_nested_wait, test_sysctl_sysctl1);sysctl_assert_write ("0" ); -kill (pid,SIGCONT ); +/* Allow child to continue */ +if (semop (sem, &sembuf,1 ) <0 ) { +perror ("semop:" ); +return 1 ; + }join_thread (pid); +semctl (sem,0 ,IPC_RMID ); +return 0 ; }
Signature · 1 line
2.51.0
PATCH 362/385 objpool: fix the overestimation of object pooling metadata size
In reply to Sasha LevinFrom: zhouwenhao <[email protected]>
[ Upstream commit 5ed4b6b37c647d168ae31035b3f61b705997e043 ]
objpool uses struct objpool_head to store metadata information, and its cpu_slots member points to an array of pointers that store the addresses of the percpu ring arrays. However, the memory size allocated during the initialization of cpu_slots is nr_cpu_ids * sizeof(struct objpool_slot). On a 64-bit machine, the size of struct objpool_slot is 16 bytes, which is twice the size of the actual pointer required, and the extra memory is never be used, resulting in a waste of memory. Therefore, the memory size required for cpu_slots needs to be corrected.
--- lib/objpool.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/objpool.c +1 -1
@@ -142,7 +142,7 @@ int objpool_init(struct objpool_head *pool, int nr_objs, int object_size, pool->gfp = gfp & ~__GFP_ZERO; pool->context = context; pool->release = release; - slot_size = nr_cpu_ids *sizeof (struct objpool_slot ); + slot_size = nr_cpu_ids *sizeof (struct objpool_slot *); pool->cpu_slots =kzalloc (slot_size, pool->gfp);if (!pool->cpu_slots)return -ENOMEM ;
Signature · 1 line
2.51.0
PATCH 363/385 ACPI: PM: Add unused power resource quirk for THUNDEROBOT ZERO
In reply to Sasha LevinFrom: Zhai Can <[email protected]>
[ Upstream commit cd7ef20ba8c6e936dba133b4136537a8ada22976 ]
On the THUNDEROBOT ZERO laptop, the second NVMe slot and the discrete NVIDIA GPU are both controlled by power-resource PXP. Due to the SSDT table bug (lack of reference), PXP will be shut dow as an "unused" power resource during initialization, making the NVMe slot #2 + NVIDIA both inaccessible.
This issue was introduced by commit a1224f34d72a ("ACPI: PM: Check states of power resources during initialization"). Here are test results on the three consecutive commits:
(bad again!) a1224f34d72a ACPI: PM: Check states of power resources during initialization (good) bc2836859643 ACPI: PM: Do not turn off power resources in unknown state (bad) 519d81956ee2 Linux 5.15-rc6
On commit bc2836859643 ("ACPI: PM: Do not turn off power resources in unknown state") this was not an issue because the power resource state left UNKNOWN thus being ignored.
See also commit 9b04d99788cf ("ACPI: PM: Do not turn of unused power resources on the Toshiba Click Mini") which is another almost identical case to this one.
--- drivers/acpi/power.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/acpi/power.c +13 -0
@@ -1035,6 +1035,19 @@ static const struct dmi_system_id dmi_leave_unused_power_resources_on[] = { DMI_MATCH(DMI_PRODUCT_NAME, "SATELLITE Click Mini L9W-B"), }, }, + { + /* + * THUNDEROBOT ZERO laptop: Due to its SSDT table bug, power + * resource 'PXP' will be shut down on initialization, making + * the NVMe #2 and the NVIDIA dGPU both unavailable (they're + * both controlled by 'PXP'). + */ + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "THUNDEROBOT"), + DMI_MATCH(DMI_PRODUCT_NAME, "ZERO"), + } + + }, {} };
Signature · 1 line
2.51.0
PATCH 364/385 cpuidle: Skip governor when only one idle state is available
In reply to Sasha LevinFrom: Aboorva Devarajan <[email protected]>
[ Upstream commit e5c9ffc6ae1bcdb1062527d611043681ac301aca ]
On certain platforms (PowerNV systems without a power-mgt DT node), cpuidle may register only a single idle state. In cases where that single state is a polling state (state 0), the ladder governor may incorrectly treat state 1 as the first usable state and pass an out-of-bounds index. This can lead to a NULL enter callback being invoked, ultimately resulting in a system crash.
[ 13.342636] cpuidle-powernv : Only Snooze is available [ 13.351854] Faulting instruction address: 0x00000000 [ 13.376489] NIP [0000000000000000] 0x0 [ 13.378351] LR [c000000001e01974] cpuidle_enter_state+0x2c4/0x668
Fix this by adding a bail-out in cpuidle_select() that returns state 0 directly when state_count <= 1, bypassing the governor and keeping the tick running.
--- drivers/cpuidle/cpuidle.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/cpuidle/cpuidle.c +10 -0
@@ -353,6 +353,16 @@ noinstr int cpuidle_enter_state(struct cpuidle_device *dev,int cpuidle_select (struct cpuidle_driver *drv,struct cpuidle_device *dev,bool *stop_tick) { +/* +* If there is only a single idle state (or none), there is nothing +* meaningful for the governor to choose. Skip the governor and +* always use state 0 with the tick running. +*/ +if (drv->state_count <=1 ) { + *stop_tick = false; +return 0 ; + } +return cpuidle_curr_governor->select (drv, dev, stop_tick); }
Signature · 1 line
2.51.0
PATCH 365/385 selftests: mlxsw: tc_restrictions: Fix test failure with new iproute2
In reply to Sasha LevinFrom: Ido Schimmel <[email protected]>
[ Upstream commit a2646773a005b59fd1dc7ff3ba15df84889ca5d2 ]
As explained in [1], iproute2 started rejecting tc-police burst sizes that result in an overflow. This can happen when the burst size is high enough and the rate is low enough.
A couple of test cases specify such configurations, resulting in iproute2 errors and test failure.
Fix by reducing the burst size so that the test will pass with both new and old iproute2 versions.
[1] https://lore.kernel.org/netdev/[email protected]/
--- tools/testing/selftests/drivers/net/mlxsw/tc_restrictions.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/drivers/net/mlxsw/tc_restrictions.sh +2 -2
@@ -317,7 +317,7 @@ police_limits_test() tc filter add dev $swp1 ingress pref 1 proto ip handle 101 \ flower skip_sw \ - action police rate 0.5kbit burst 1m conform-exceed drop/ok + action police rate 0.5kbit burst 2k conform-exceed drop/ok check_fail $? "Incorrect success to add police action with too low rate" tc filter add dev $swp1 ingress pref 1 proto ip handle 101 \
@@ -327,7 +327,7 @@ police_limits_test() tc filter add dev $swp1 ingress pref 1 proto ip handle 101 \ flower skip_sw \ - action police rate 1.5kbit burst 1m conform-exceed drop/ok + action police rate 1.5kbit burst 2k conform-exceed drop/ok check_err $? "Failed to add police action with low rate" tc filter del dev $swp1 ingress protocol ip pref 1 handle 101 flower
Signature · 1 line
2.51.0
PATCH 366/385 net: sparx5/lan969x: fix DWRR cost max to match hardware register width
In reply to Sasha LevinFrom: Daniel Machon <[email protected]>
[ Upstream commit 6c28aa8dfdf24f554d4c5d4ff7d723a95360d94a ]
DWRR (Deficit Weighted Round Robin) scheduling distributes bandwidth across traffic classes based on per-queue cost values, where lower cost means higher bandwidth share.
The SPX5_DWRR_COST_MAX constant is 63 (6 bits) but the hardware register field HSCH_DWRR_ENTRY_DWRR_COST is GENMASK(24, 20), only 5 bits wide (max 31). This causes sparx5_weight_to_hw_cost() to compute cost values that silently overflow via FIELD_PREP, resulting in incorrect scheduling weights.
Set SPX5_DWRR_COST_MAX to 31 to match the hardware register width.
--- drivers/net/ethernet/microchip/sparx5/sparx5_qos.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/microchip/sparx5/sparx5_qos.h +1 -1
@@ -35,7 +35,7 @@#define SPX5_SE_BURST_UNIT 4096/* Dwrr */ -#define SPX5_DWRR_COST_MAX 63 +#define SPX5_DWRR_COST_MAX 31struct sparx5_shaper {u32 mode;
Signature · 1 line
2.51.0
PATCH 367/385 net: mscc: ocelot: extract ocelot_xmit_timestamp() helper
In reply to Sasha LevinFrom: Ziyi Guo <[email protected]>
[ Upstream commit 29372f07f7969a2f0490793226ecf6c8c6bde0fa ]
Extract the PTP timestamp handling logic from ocelot_port_xmit() into a separate ocelot_xmit_timestamp() helper function. This is a pure refactor with no behavioral change.
The helper returns false if the skb was consumed (freed) due to a timestamp request failure, and true if the caller should continue with frame injection. The rew_op value is returned via pointer.
This prepares for splitting ocelot_port_xmit() into separate FDMA and register injection paths in a subsequent patch.
Stable-dep-of: 026f6513c588 ("net: mscc: ocelot: add missing lock protection in ocelot_port_xmit_inj()")
--- drivers/net/ethernet/mscc/ocelot_net.c | 36 ++++++++++++++++---------- 1 file changed, 22 insertions(+), 14 deletions(-)
drivers/net/ethernet/mscc/ocelot_net.c +22 -14
@@ -551,33 +551,41 @@ static int ocelot_port_stop(struct net_device *dev)return 0 ; } -static netdev_tx_t ocelot_port_xmit (struct sk_buff *skb,struct net_device *dev) +static bool ocelot_xmit_timestamp (struct ocelot *ocelot,int port, +struct sk_buff *skb,u32 *rew_op) { -struct ocelot_port_private *priv =netdev_priv (dev); -struct ocelot_port *ocelot_port = &priv->port; -struct ocelot *ocelot = ocelot_port->ocelot; -int port = priv->port.index; -u32 rew_op =0 ; - -if (!static_branch_unlikely (&ocelot_fdma_enabled) && - !ocelot_can_inject (ocelot,0 )) -return NETDEV_TX_BUSY ; - -/* Check if timestamping is needed */ if (ocelot->ptp && (skb_shinfo (skb)->tx_flags &SKBTX_HW_TSTAMP )) {struct sk_buff *clone =NULL ;if (ocelot_port_txtstamp_request (ocelot, port, skb, &clone)) {kfree_skb (skb); -return NETDEV_TX_OK ; +return false; }if (clone)OCELOT_SKB_CB (skb)->clone = clone; - rew_op =ocelot_ptp_rew_op (skb); + *rew_op =ocelot_ptp_rew_op (skb); } +return true; +} + +static netdev_tx_t ocelot_port_xmit (struct sk_buff *skb,struct net_device *dev) +{ +struct ocelot_port_private *priv =netdev_priv (dev); +struct ocelot_port *ocelot_port = &priv->port; +struct ocelot *ocelot = ocelot_port->ocelot; +int port = priv->port.index; +u32 rew_op =0 ; + +if (!static_branch_unlikely (&ocelot_fdma_enabled) && + !ocelot_can_inject (ocelot,0 )) +return NETDEV_TX_BUSY ; + +if (!ocelot_xmit_timestamp (ocelot, port, skb, &rew_op)) +return NETDEV_TX_OK ; +if (static_branch_unlikely (&ocelot_fdma_enabled)) {ocelot_fdma_inject_frame (ocelot, port, rew_op, skb, dev); }else {
Signature · 1 line
2.51.0
PATCH 368/385 net: mscc: ocelot: split xmit into FDMA and register injection paths
In reply to Sasha LevinFrom: Ziyi Guo <[email protected]>
[ Upstream commit 47f79b20e7fb885aa1623b759a68e8e27401ec4d ]
Split ocelot_port_xmit() into two separate functions:
- ocelot_port_xmit_fdma(): handles the FDMA injection path
- ocelot_port_xmit_inj(): handles the register-based injection path
The top-level ocelot_port_xmit() now dispatches to the appropriate function based on the ocelot_fdma_enabled static key.
This is a pure refactor with no behavioral change. Separating the two code paths makes each one simpler and prepares for adding proper locking to the register injection path without affecting the FDMA path.
Stable-dep-of: 026f6513c588 ("net: mscc: ocelot: add missing lock protection in ocelot_port_xmit_inj()")
--- drivers/net/ethernet/mscc/ocelot_net.c | 39 ++++++++++++++++++++------ 1 file changed, 30 insertions(+), 9 deletions(-)
drivers/net/ethernet/mscc/ocelot_net.c +30 -9
@@ -571,7 +571,25 @@ static bool ocelot_xmit_timestamp(struct ocelot *ocelot, int port,return true; } -static netdev_tx_t ocelot_port_xmit (struct sk_buff *skb,struct net_device *dev) +static netdev_tx_t ocelot_port_xmit_fdma (struct sk_buff *skb, +struct net_device *dev) +{ +struct ocelot_port_private *priv =netdev_priv (dev); +struct ocelot_port *ocelot_port = &priv->port; +struct ocelot *ocelot = ocelot_port->ocelot; +int port = priv->port.index; +u32 rew_op =0 ; + +if (!ocelot_xmit_timestamp (ocelot, port, skb, &rew_op)) +return NETDEV_TX_OK ; + +ocelot_fdma_inject_frame (ocelot, port, rew_op, skb, dev); + +return NETDEV_TX_OK ; +} + +static netdev_tx_t ocelot_port_xmit_inj (struct sk_buff *skb, +struct net_device *dev) {struct ocelot_port_private *priv =netdev_priv (dev);struct ocelot_port *ocelot_port = &priv->port;
@@ -579,24 +597,27 @@ static netdev_tx_t ocelot_port_xmit(struct sk_buff *skb, struct net_device *dev)int port = priv->port.index;u32 rew_op =0 ; -if (!static_branch_unlikely (&ocelot_fdma_enabled) && - !ocelot_can_inject (ocelot,0 )) +if (!ocelot_can_inject (ocelot,0 ))return NETDEV_TX_BUSY ;if (!ocelot_xmit_timestamp (ocelot, port, skb, &rew_op))return NETDEV_TX_OK ; -if (static_branch_unlikely (&ocelot_fdma_enabled)) { -ocelot_fdma_inject_frame (ocelot, port, rew_op, skb, dev); - }else { -ocelot_port_inject_frame (ocelot, port,0 , rew_op, skb); +ocelot_port_inject_frame (ocelot, port,0 , rew_op, skb); -consume_skb (skb); - } +consume_skb (skb);return NETDEV_TX_OK ; } +static netdev_tx_t ocelot_port_xmit (struct sk_buff *skb,struct net_device *dev) +{ +if (static_branch_unlikely (&ocelot_fdma_enabled)) +return ocelot_port_xmit_fdma (skb, dev); + +return ocelot_port_xmit_inj (skb, dev); +} +enum ocelot_action_type {OCELOT_MACT_LEARN ,OCELOT_MACT_FORGET ,
Signature · 1 line
2.51.0
PATCH 369/385 net: mscc: ocelot: add missing lock protection in ocelot_port_xmit_inj()
In reply to Sasha LevinFrom: Ziyi Guo <[email protected]>
[ Upstream commit 026f6513c5880c2c89e38ad66bbec2868f978605 ]
ocelot_port_xmit_inj() calls ocelot_can_inject() and ocelot_port_inject_frame() without holding the injection group lock. Both functions contain lockdep_assert_held() for the injection lock, and the correct caller felix_port_deferred_xmit() properly acquires the lock using ocelot_lock_inj_grp() before calling these functions.
Add ocelot_lock_inj_grp()/ocelot_unlock_inj_grp() around the register injection path to fix the missing lock protection. The FDMA path is not affected as it uses its own locking mechanism.
--- drivers/net/ethernet/mscc/ocelot_net.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/net/ethernet/mscc/ocelot_net.c +10 -2
@@ -597,14 +597,22 @@ static netdev_tx_t ocelot_port_xmit_inj(struct sk_buff *skb,int port = priv->port.index;u32 rew_op =0 ; -if (!ocelot_can_inject (ocelot,0 )) +ocelot_lock_inj_grp (ocelot,0 ); + +if (!ocelot_can_inject (ocelot,0 )) { +ocelot_unlock_inj_grp (ocelot,0 );return NETDEV_TX_BUSY ; + } -if (!ocelot_xmit_timestamp (ocelot, port, skb, &rew_op)) +if (!ocelot_xmit_timestamp (ocelot, port, skb, &rew_op)) { +ocelot_unlock_inj_grp (ocelot,0 );return NETDEV_TX_OK ; + }ocelot_port_inject_frame (ocelot, port,0 , rew_op, skb); +ocelot_unlock_inj_grp (ocelot,0 ); +consume_skb (skb);return NETDEV_TX_OK ;
Signature · 1 line
2.51.0
PATCH 370/385 ipv6: Fix out-of-bound access in fib6_add_rt2node().
In reply to Sasha LevinFrom: Kuniyuki Iwashima <[email protected]>
[ Upstream commit 8244f959e2c125c849e569f5b23ed49804cce695 ]
syzbot reported out-of-bound read in fib6_add_rt2node(). [0]
When IPv6 route is created with RTA_NH_ID, struct fib6_info does not have the trailing struct fib6_nh.
The cited commit started to check !iter->fib6_nh->fib_nh_gw_family to ensure that rt6_qualify_for_ecmp() will return false for iter.
If iter->nh is not NULL, rt6_qualify_for_ecmp() returns false anyway.
Let's check iter->nh before reading iter->fib6_nh and avoid OOB read.
[0]:
BUG: KASAN: slab-out-of-bounds in fib6_add_rt2node+0x349c/0x3500 net/ipv6/ip6_fib.c:1142 Read of size 1 at addr ffff8880384ba6de by task syz.0.18/5500 CPU: 0 UID: 0 PID: 5500 Comm: syz.0.18 Not tainted syzkaller #0 PREEMPT(full) Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014 Call Trace: <TASK> dump_stack_lvl+0xe8/0x150 lib/dump_stack.c:120 print_address_description mm/kasan/report.c:378 [inline] print_report+0xba/0x230 mm/kasan/report.c:482 kasan_report+0x117/0x150 mm/kasan/report.c:595 fib6_add_rt2node+0x349c/0x3500 net/ipv6/ip6_fib.c:1142 fib6_add_rt2node_nh net/ipv6/ip6_fib.c:1363 [inline] fib6_add+0x910/0x18c0 net/ipv6/ip6_fib.c:1531 __ip6_ins_rt net/ipv6/route.c:1351 [inline] ip6_route_add+0xde/0x1b0 net/ipv6/route.c:3957 inet6_rtm_newroute+0x268/0x19e0 net/ipv6/route.c:5660 rtnetlink_rcv_msg+0x7d5/0xbe0 net/core/rtnetlink.c:6958 netlink_rcv_skb+0x232/0x4b0 net/netlink/af_netlink.c:2550 netlink_unicast_kernel net/netlink/af_netlink.c:1318 [inline] netlink_unicast+0x80f/0x9b0 net/netlink/af_netlink.c:1344 netlink_sendmsg+0x813/0xb40 net/netlink/af_netlink.c:1894 sock_sendmsg_nosec net/socket.c:727 [inline] __sock_sendmsg net/socket.c:742 [inline] ____sys_sendmsg+0xa68/0xad0 net/socket.c:2592 ___sys_sendmsg+0x2a5/0x360 net/socket.c:2646 __sys_sendmsg net/socket.c:2678 [inline] __do_sys_sendmsg net/socket.c:2683 [inline] __se_sys_sendmsg net/socket.c:2681 [inline] __x64_sys_sendmsg+0x1bd/0x2a0 net/socket.c:2681 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xe2/0xf80 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7f9316b9aeb9 Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 e8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007ffd8809b678 EFLAGS: 00000246 ORIG_RAX: 000000000000002e RAX: ffffffffffffffda RBX: 00007f9316e15fa0 RCX: 00007f9316b9aeb9 RDX: 0000000000000000 RSI: 0000200000004380 RDI: 0000000000000003 RBP: 00007f9316c08c1f R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007f9316e15fac R14: 00007f9316e15fa0 R15: 00007f9316e15fa0 </TASK> Allocated by task 5499: kasan_save_stack mm/kasan/common.c:57 [inline] kasan_save_track+0x3e/0x80 mm/kasan/common.c:78 poison_kmalloc_redzone mm/kasan/common.c:398 [inline] __kasan_kmalloc+0x93/0xb0 mm/kasan/common.c:415 kasan_kmalloc include/linux/kasan.h:263 [inline] __do_kmalloc_node mm/slub.c:5657 [inline] __kmalloc_noprof+0x40c/0x7e0 mm/slub.c:5669 kmalloc_noprof include/linux/slab.h:961 [inline] kzalloc_noprof include/linux/slab.h:1094 [inline] fib6_info_alloc+0x30/0xf0 net/ipv6/ip6_fib.c:155 ip6_route_info_create+0x142/0x860 net/ipv6/route.c:3820 ip6_route_add+0x49/0x1b0 net/ipv6/route.c:3949 inet6_rtm_newroute+0x268/0x19e0 net/ipv6/route.c:5660 rtnetlink_rcv_msg+0x7d5/0xbe0 net/core/rtnetlink.c:6958 netlink_rcv_skb+0x232/0x4b0 net/netlink/af_netlink.c:2550 netlink_unicast_kernel net/netlink/af_netlink.c:1318 [inline] netlink_unicast+0x80f/0x9b0 net/netlink/af_netlink.c:1344 netlink_sendmsg+0x813/0xb40 net/netlink/af_netlink.c:1894 sock_sendmsg_nosec net/socket.c:727 [inline] __sock_sendmsg net/socket.c:742 [inline] ____sys_sendmsg+0xa68/0xad0 net/socket.c:2592 ___sys_sendmsg+0x2a5/0x360 net/socket.c:2646 __sys_sendmsg net/socket.c:2678 [inline] __do_sys_sendmsg net/socket.c:2683 [inline] __se_sys_sendmsg net/socket.c:2681 [inline] __x64_sys_sendmsg+0x1bd/0x2a0 net/socket.c:2681 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xe2/0xf80 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f
--- net/ipv6/ip6_fib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv6/ip6_fib.c +1 -1
@@ -1139,7 +1139,7 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct fib6_info *rt,fib6_add_gc_list (iter); }if (!(rt->fib6_flags & (RTF_ADDRCONF |RTF_PREFIX_RT )) && - !iter->fib6_nh->fib_nh_gw_family) { + (iter->nh || !iter->fib6_nh->fib_nh_gw_family)) { iter->fib6_flags &= ~RTF_ADDRCONF ; iter->fib6_flags &= ~RTF_PREFIX_RT ; }
Signature · 1 line
2.51.0
PATCH 371/385 net: sparx5/lan969x: fix PTP clock max_adj value
In reply to Sasha LevinFrom: Daniel Machon <[email protected]>
[ Upstream commit a49d2a2c37a6252c41cbdd505f9d1c58d5a3817a ]
The max_adj field in ptp_clock_info tells userspace how much the PHC clock frequency can be adjusted. ptp4l reads this and will never request a correction larger than max_adj.
On both sparx5 and lan969x the clock offset may never converge because the servo needs a frequency correction larger than the current max_adj of 200000 (200 ppm) allows. The servo rails at the max and the offset stays in the tens of microseconds.
The hardware has no inherent max adjustment limit; frequency correction is done by writing a 64-bit clock period increment to CLK_PER_CFG, and the register has plenty of range. The 200000 value was just an overly conservative software limit. The max_adj is shared between sparx5 and lan969x, and the increased value is safe for both.
Fix this by increasing max_adj to 10000000 (10000 ppm), giving the servo sufficient headroom.
--- drivers/net/ethernet/microchip/sparx5/sparx5_ptp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/microchip/sparx5/sparx5_ptp.c +1 -1
@@ -562,7 +562,7 @@ static int sparx5_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)static struct ptp_clock_info sparx5_ptp_clock_info = { .owner =THIS_MODULE , .name ="sparx5 ptp" , - .max_adj =200000 , + .max_adj =10000000 , .gettime64 = sparx5_ptp_gettime64, .settime64 = sparx5_ptp_settime64, .adjtime = sparx5_ptp_adjtime,
Signature · 1 line
2.51.0
PATCH 372/385 net: usb: catc: enable basic endpoint checking
In reply to Sasha LevinFrom: Ziyi Guo <[email protected]>
[ Upstream commit 9e7021d2aeae57c323a6f722ed7915686cdcc123 ]
catc_probe() fills three URBs with hardcoded endpoint pipes without verifying the endpoint descriptors:
- usb_sndbulkpipe(usbdev, 1) and usb_rcvbulkpipe(usbdev, 1) for TX/RX
- usb_rcvintpipe(usbdev, 2) for interrupt status
A malformed USB device can present these endpoints with transfer types that differ from what the driver assumes.
Add a catc_usb_ep enum for endpoint numbers, replacing magic constants throughout. Add usb_check_bulk_endpoints() and usb_check_int_endpoints() calls after usb_set_interface() to verify endpoint types before use, rejecting devices with mismatched descriptors at probe time.
Similar to
- commit 90b7f2961798 ("net: usb: rtl8150: enable basic endpoint checking") which fixed the issue in rtl8150.
--- drivers/net/usb/catc.c | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-)
drivers/net/usb/catc.c +31 -6
@@ -64,6 +64,16 @@ static const char driver_name[] = "catc";#define CTRL_QUEUE 16/* Max control requests in flight (power of two) */ #define RX_PKT_SZ 1600/* Max size of receive packet for F5U011 */ +/* +* USB endpoints. +*/ + +enum catc_usb_ep { +CATC_USB_EP_CONTROL =0 , +CATC_USB_EP_BULK =1 , +CATC_USB_EP_INT_IN =2 , +}; +/* * Control requests. */
@@ -772,6 +782,13 @@ static int catc_probe(struct usb_interface *intf, const struct usb_device_id *idu8 broadcast[ETH_ALEN ];u8 *macbuf;int pktsz, ret = -ENOMEM ; +static const u8 bulk_ep_addr[] = { +CATC_USB_EP_BULK |USB_DIR_OUT , +CATC_USB_EP_BULK |USB_DIR_IN , +0 }; +static const u8 int_ep_addr[] = { +CATC_USB_EP_INT_IN |USB_DIR_IN , +0 }; macbuf =kmalloc (ETH_ALEN ,GFP_KERNEL );if (!macbuf)
@@ -784,6 +801,14 @@ static int catc_probe(struct usb_interface *intf, const struct usb_device_id *id goto fail_mem; } +/* Verify that all required endpoints are present */ +if (!usb_check_bulk_endpoints (intf, bulk_ep_addr) || + !usb_check_int_endpoints (intf, int_ep_addr)) { +dev_err (dev,"Missing or invalid endpoints\n" ); + ret = -ENODEV ; + goto fail_mem; + } + netdev =alloc_etherdev (sizeof (struct catc ));if (!netdev) goto fail_mem;
@@ -828,14 +853,14 @@ static int catc_probe(struct usb_interface *intf, const struct usb_device_id *idusb_fill_control_urb (catc->ctrl_urb, usbdev,usb_sndctrlpipe (usbdev,0 ),NULL ,NULL ,0 , catc_ctrl_done, catc); -usb_fill_bulk_urb (catc->tx_urb, usbdev,usb_sndbulkpipe (usbdev,1 ), -NULL ,0 , catc_tx_done, catc); +usb_fill_bulk_urb (catc->tx_urb, usbdev,usb_sndbulkpipe (usbdev,CATC_USB_EP_BULK ), +NULL ,0 , catc_tx_done, catc); -usb_fill_bulk_urb (catc->rx_urb, usbdev,usb_rcvbulkpipe (usbdev,1 ), - catc->rx_buf, pktsz, catc_rx_done, catc); +usb_fill_bulk_urb (catc->rx_urb, usbdev,usb_rcvbulkpipe (usbdev,CATC_USB_EP_BULK ), + catc->rx_buf, pktsz, catc_rx_done, catc); -usb_fill_int_urb (catc->irq_urb, usbdev,usb_rcvintpipe (usbdev,2 ), - catc->irq_buf,2 , catc_irq_done, catc,1 ); +usb_fill_int_urb (catc->irq_urb, usbdev,usb_rcvintpipe (usbdev,CATC_USB_EP_INT_IN ), + catc->irq_buf,2 , catc_irq_done, catc,1 );if (!catc->is_f5u011) {u32 *buf;
Signature · 1 line
2.51.0
PATCH 373/385 xen-netback: reject zero-queue configuration from guest
In reply to Sasha LevinFrom: Ziyi Guo <[email protected]>
[ Upstream commit 6d1dc8014334c7fb25719999bca84d811e60a559 ]
A malicious or buggy Xen guest can write "0" to the xenbus key "multi-queue-num-queues". The connect() function in the backend only validates the upper bound (requested_num_queues > xenvif_max_queues) but not zero, allowing requested_num_queues=0 to reach vzalloc(array_size(0, sizeof(struct xenvif_queue))), which triggers WARN_ON_ONCE(!size) in __vmalloc_node_range().
On systems with panic_on_warn=1, this allows a guest-to-host denial of service.
The Xen network interface specification requires
the queue count to be "greater than zero".
Add a zero check to match the validation already present in xen-blkback, which has included this
guard since its multi-queue support was added.
--- drivers/net/xen-netback/xenbus.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/xen-netback/xenbus.c +3 -2
@@ -735,10 +735,11 @@ static void connect(struct backend_info *be)*/ requested_num_queues =xenbus_read_unsigned (dev->otherend,"multi-queue-num-queues" ,1 ); -if (requested_num_queues > xenvif_max_queues) { +if (requested_num_queues > xenvif_max_queues || + requested_num_queues ==0 ) {/* buggy or malicious guest */ xenbus_dev_fatal (dev, -EINVAL , -"guest requested %u queues, exceeding the maximum of %u." , +"guest requested %u queues, but valid range is 1 - %u." , requested_num_queues, xenvif_max_queues);return ; }
Signature · 1 line
2.51.0
PATCH 374/385 net/rds: rds_sendmsg should not discard payload_len
In reply to Sasha LevinFrom: Allison Henderson <[email protected]>
[ Upstream commit da29e453dcb3aa7cabead7915f5f945d0add3a52 ]
Commit 3db6e0d172c9 ("rds: use RCU to synchronize work-enqueue with connection teardown") modifies rds_sendmsg to avoid enqueueing work while a tear down is in progress. However, it also changed the return value of rds_sendmsg to that of rds_send_xmit instead of the payload_len. This means the user may incorrectly receive errno values when it should have simply received a payload of 0 while the peer attempts a reconnections. So this patch corrects the teardown handling code to only use the out error path in that case, thus restoring the original payload_len return value.
--- net/rds/send.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
net/rds/send.c +4 -2
@@ -1382,9 +1382,11 @@ int rds_sendmsg(struct socket *sock, struct msghdr *msg, size_t payload_len)else queue_delayed_work (rds_wq, &cpath->cp_send_w,1 );rcu_read_unlock (); + +if (ret) + goto out; } -if (ret) - goto out; +rds_message_put (rm);for (ind =0 ; ind < vct.indx; ind++)
Signature · 1 line
2.51.0
PATCH 375/385 net: bridge: mcast: always update mdb_n_entries for vlan contexts
In reply to Sasha LevinFrom: Nikolay Aleksandrov <[email protected]>
[ Upstream commit 8b769e311a86bb9d15c5658ad283b86fc8f080a2 ]
syzbot triggered a warning[1] about the number of mdb entries in a context. It turned out that there are multiple ways to trigger that warning today (some got added during the years), the root cause of the problem is that the increase is done conditionally, and over the years these different conditions increased so there were new ways to trigger the warning, that is to do a decrease which wasn't paired with a previous increase.
For example one way to trigger it is with flush:
$ ip l add br0 up type bridge vlan_filtering 1 mcast_snooping 1
$ ip l add dumdum up master br0 type dummy
$ bridge mdb add dev br0 port dumdum grp 239.0.0.1 permanent vid 1
$ ip link set dev br0 down
$ ip link set dev br0 type bridge mcast_vlan_snooping 1
^^^^ this will enable snooping, but will not update mdb_n_entries
because in __br_multicast_enable_port_ctx() we check !netif_running
$ bridge mdb flush dev br0
^^^ this will trigger the warning because it will delete the pg which
we added above, which will try to decrease mdb_n_entriesFix the problem by removing the conditional increase and always keep the count up-to-date while the vlan exists. In order to do that we have to first initialize it on port-vlan context creation, and then always increase or decrease the value regardless of mcast options. To keep the current behaviour we have to enforce the mdb limit only if the context is port's or if the port-vlan's mcast snooping is enabled.
[1]
------------[ cut here ]------------ n == 0 WARNING: net/bridge/br_multicast.c:718 at br_multicast_port_ngroups_dec_one net/bridge/br_multicast.c:718 [inline], CPU#0: syz.4.4607/22043 WARNING: net/bridge/br_multicast.c:718 at br_multicast_port_ngroups_dec net/bridge/br_multicast.c:771 [inline], CPU#0: syz.4.4607/22043 WARNING: net/bridge/br_multicast.c:718 at br_multicast_del_pg+0x1bbe/0x1e20 net/bridge/br_multicast.c:825, CPU#0: syz.4.4607/22043 Modules linked in: CPU: 0 UID: 0 PID: 22043 Comm: syz.4.4607 Not tainted syzkaller #0 PREEMPT(full) Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/24/2026 RIP: 0010:br_multicast_port_ngroups_dec_one net/bridge/br_multicast.c:718 [inline] RIP: 0010:br_multicast_port_ngroups_dec net/bridge/br_multicast.c:771 [inline] RIP: 0010:br_multicast_del_pg+0x1bbe/0x1e20 net/bridge/br_multicast.c:825 Code: 41 5f 5d e9 04 7a 48 f7 e8 3f 73 5c f7 90 0f 0b 90 e9 cf fd ff ff e8 31 73 5c f7 90 0f 0b 90 e9 16 fd ff ff e8 23 73 5c f7 90 <0f> 0b 90 e9 60 fd ff ff e8 15 73 5c f7 eb 05 e8 0e 73 5c f7 48 8b RSP: 0018:ffffc9000c207220 EFLAGS: 00010293 RAX: ffffffff8a68042d RBX: ffff88807c6f1800 RCX: ffff888066e90000 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000 RBP: 0000000000000000 R08: ffff888066e90000 R09: 000000000000000c R10: 000000000000000c R11: 0000000000000000 R12: ffff8880303ef800 R13: dffffc0000000000 R14: ffff888050eb11c4 R15: 1ffff1100a1d6238 FS: 00007fa45921b6c0(0000) GS:ffff8881256f5000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007fa4591f9ff8 CR3: 0000000081df2000 CR4: 00000000003526f0 Call Trace: <TASK> br_mdb_flush_pgs net/bridge/br_mdb.c:1525 [inline] br_mdb_flush net/bridge/br_mdb.c:1544 [inline] br_mdb_del_bulk+0x5e2/0xb20 net/bridge/br_mdb.c:1561 rtnl_mdb_del+0x48a/0x640 net/core/rtnetlink.c:-1 rtnetlink_rcv_msg+0x77e/0xbe0 net/core/rtnetlink.c:6967 netlink_rcv_skb+0x232/0x4b0 net/netlink/af_netlink.c:2550 netlink_unicast_kernel net/netlink/af_netlink.c:1318 [inline] netlink_unicast+0x80f/0x9b0 net/netlink/af_netlink.c:1344 netlink_sendmsg+0x813/0xb40 net/netlink/af_netlink.c:1894 sock_sendmsg_nosec net/socket.c:727 [inline] __sock_sendmsg net/socket.c:742 [inline] ____sys_sendmsg+0xa68/0xad0 net/socket.c:2592 ___sys_sendmsg+0x2a5/0x360 net/socket.c:2646 __sys_sendmsg net/socket.c:2678 [inline] __do_sys_sendmsg net/socket.c:2683 [inline] __se_sys_sendmsg net/socket.c:2681 [inline] __x64_sys_sendmsg+0x1bd/0x2a0 net/socket.c:2681 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xe2/0xf80 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7fa45839aeb9 Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 e8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007fa45921b028 EFLAGS: 00000246 ORIG_RAX: 000000000000002e RAX: ffffffffffffffda RBX: 00007fa458615fa0 RCX: 00007fa45839aeb9 RDX: 0000000000000000 RSI: 00002000000000c0 RDI: 0000000000000004 RBP: 00007fa458408c1f R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007fa458616038 R14: 00007fa458615fa0 R15: 00007fff0b59fae8 </TASK>
--- net/bridge/br_multicast.c | 45 ++++++++++++++++----------------------- 1 file changed, 18 insertions(+), 27 deletions(-)
net/bridge/br_multicast.c +18 -27
@@ -244,14 +244,11 @@ br_multicast_port_vid_to_port_ctx(struct net_bridge_port *port, u16 vid)lockdep_assert_held_once (&port->br->multicast_lock); -if (!br_opt_get (port->br,BROPT_MCAST_VLAN_SNOOPING_ENABLED )) -return NULL ; -/* Take RCU to access the vlan. */ rcu_read_lock (); vlan =br_vlan_find (nbp_vlan_group_rcu (port), vid); -if (vlan && !br_multicast_port_ctx_vlan_disabled (&vlan->port_mcast_ctx)) +if (vlan) pmctx = &vlan->port_mcast_ctx;rcu_read_unlock ();
@@ -701,7 +698,10 @@ br_multicast_port_ngroups_inc_one(struct net_bridge_mcast_port *pmctx,u32 max =READ_ONCE (pmctx->mdb_max_entries);u32 n =READ_ONCE (pmctx->mdb_n_entries); -if (max && n >= max) { +/* enforce the max limit when it's a port pmctx or a port-vlan pmctx +* with snooping enabled +*/ +if (!br_multicast_port_ctx_vlan_disabled (pmctx) && max && n >= max) {NL_SET_ERR_MSG_FMT_MOD (extack,"%s is already in %u groups, and mcast_max_groups=%u" , what, n, max);return -E2BIG ;
@@ -736,9 +736,7 @@ static int br_multicast_port_ngroups_inc(struct net_bridge_port *port,return err; } -/* Only count on the VLAN context if VID is given, and if snooping on -* that VLAN is enabled. -*/ +/* Only count on the VLAN context if VID is given */ if (!group->vid)return 0 ;
@@ -2010,6 +2008,18 @@ void br_multicast_port_ctx_init(struct net_bridge_port *port,timer_setup (&pmctx->ip6_own_query.timer, br_ip6_multicast_port_query_expired,0 );#endif +/* initialize mdb_n_entries if a new port vlan is being created */ +if (vlan) { +struct net_bridge_port_group *pg; +u32 n =0 ; + +spin_lock_bh (&port->br->multicast_lock); +hlist_for_each_entry (pg, &port->mglist, mglist) +if (pg->key.addr.vid == vlan->vid) + n++; +WRITE_ONCE (pmctx->mdb_n_entries, n); +spin_unlock_bh (&port->br->multicast_lock); + } }void br_multicast_port_ctx_deinit (struct net_bridge_mcast_port *pmctx)
@@ -2093,25 +2103,6 @@ static void __br_multicast_enable_port_ctx(struct net_bridge_mcast_port *pmctx)br_ip4_multicast_add_router (brmctx, pmctx);br_ip6_multicast_add_router (brmctx, pmctx); } - -if (br_multicast_port_ctx_is_vlan (pmctx)) { -struct net_bridge_port_group *pg; -u32 n =0 ; - -/* The mcast_n_groups counter might be wrong. First, -* BR_VLFLAG_MCAST_ENABLED is toggled before temporary entries -* are flushed, thus mcast_n_groups after the toggle does not -* reflect the true values. And second, permanent entries added -* while BR_VLFLAG_MCAST_ENABLED was disabled, are not reflected -* either. Thus we have to refresh the counter. -*/ - -hlist_for_each_entry (pg, &pmctx->port->mglist, mglist) { -if (pg->key.addr.vid == pmctx->vlan->vid) - n++; - } -WRITE_ONCE (pmctx->mdb_n_entries, n); - } }static void br_multicast_enable_port_ctx (struct net_bridge_mcast_port *pmctx)
Signature · 1 line
2.51.0
PATCH 376/385 selftests: forwarding: vxlan_bridge_1d: fix test failure with br_netfilter enabled
In reply to Sasha LevinFrom: Aleksei Oladko <[email protected]>
[ Upstream commit 02cb2e6bacbb08ebf6acb61be816efd11e1f4a21 ]
The test generates VXLAN traffic using mausezahn, where the encapsulated inner IPv4 packet contains a zero IP header checksum. After VXLAN decapsulation, such packets do not pass sanity checks in br_netfilter and are dropped, which causes the test to fail.
Fix this by calculating and setting a valid IPv4 header checksum for the encapsulated packet generated by mausezahn, so that the packet is accepted by br_netfilter. Fixed by using the payload_template_calc_checksum() / payload_template_expand_checksum() helpers that are only available in v6.3 and newer kernels.
--- .../net/forwarding/vxlan_bridge_1d.sh | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-)
tools/testing/selftests/net/forwarding/vxlan_bridge_1d.sh +16 -10
@@ -559,6 +559,21 @@ vxlan_encapped_ping_do() local inner_tos=$1; shift local outer_tos=$1; shift + local ipv4hdr=$(: + )"45:"$( : IP version + IHL + )"$inner_tos:"$( : IP TOS + )"00:54:"$( : IP total length + )"99:83:"$( : IP identification + )"40:00:"$( : IP flags + frag off + )"40:"$( : IP TTL + )"01:"$( : IP proto + )"CHECKSUM:"$( : IP header csum + )"c0:00:02:03:"$( : IP saddr: 192.0.2.3 + )"c0:00:02:01"$( : IP daddr: 192.0.2.1 + ) + local checksum=$(payload_template_calc_checksum "$ipv4hdr") + ipv4hdr=$(payload_template_expand_checksum "$ipv4hdr" $checksum) + $MZ $dev -c $count -d 100msec -q \ -b $next_hop_mac -B $dest_ip \ -t udp tos=$outer_tos,sp=23456,dp=$VXPORT,p=$(:
@@ -569,16 +584,7 @@ vxlan_encapped_ping_do() )"$dest_mac:"$( : ETH daddr )"$(mac_get w2):"$( : ETH saddr )"08:00:"$( : ETH type - )"45:"$( : IP version + IHL - )"$inner_tos:"$( : IP TOS - )"00:54:"$( : IP total length - )"99:83:"$( : IP identification - )"40:00:"$( : IP flags + frag off - )"40:"$( : IP TTL - )"01:"$( : IP proto - )"00:00:"$( : IP header csum - )"c0:00:02:03:"$( : IP saddr: 192.0.2.3 - )"c0:00:02:01:"$( : IP daddr: 192.0.2.1 + )"$ipv4hdr:"$( : IPv4 header )"08:"$( : ICMP type )"00:"$( : ICMP code )"8b:f2:"$( : ICMP csum
Signature · 1 line
2.51.0
PATCH 377/385 selftests: forwarding: vxlan_bridge_1d_ipv6: fix test failure with br_netfilter enabled
In reply to Sasha LevinFrom: Aleksei Oladko <[email protected]>
[ Upstream commit ce9f6aec0fb780dafc1dfc5f47c688422aff464a ]
The test generates VXLAN traffic using mausezahn, where the encapsulated inner IPv6 packet has an incorrect payload length set in the IPv6 header. After VXLAN decapsulation, such packets do not pass sanity checks in br_netfilter and are dropped, which causes the test to fail.
Fix this by setting the correct IPv6 payload length for the encapsulated packet generated by mausezahn, so that the packet is accepted by br_netfilter.
tools/testing/selftests/net/forwarding/vxlan_bridge_1d_ipv6.sh lines 698-706
)"00:03:"$( : Payload length
)"3a:"$( : Next header
)"04:"$( : Hop limit
)"$saddr:"$( : IP saddr
)"$daddr:"$( : IP daddr
)"80:"$( : ICMPv6.type
)"00:"$( : ICMPv6.code
)"00:"$( : ICMPv6.checksum
)Data after IPv6 header:
• 80: — 1 byte (ICMPv6 type)
• 00: — 1 byte (ICMPv6 code)
• 00: — 1 byte (ICMPv6 checksum, truncated)
Total: 3 bytes → 00:03 is correct. The old value 00:08 did not match the actual payload size.
--- tools/testing/selftests/net/forwarding/vxlan_bridge_1d_ipv6.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/net/forwarding/vxlan_bridge_1d_ipv6.sh +1 -1
@@ -695,7 +695,7 @@ vxlan_encapped_ping_do() )"6"$( : IP version )"$inner_tos"$( : Traffic class )"0:00:00:"$( : Flow label - )"00:08:"$( : Payload length + )"00:03:"$( : Payload length )"3a:"$( : Next header )"04:"$( : Hop limit )"$saddr:"$( : IP saddr
Signature · 1 line
2.51.0
PATCH 378/385 netfilter: nf_conntrack_h323: don't pass uninitialised l3num value
In reply to Sasha LevinFrom: Florian Westphal <[email protected]>
[ Upstream commit a6d28eb8efe96b3e35c92efdf1bfacb0cccf541f ]
Mihail Milev reports: Error: UNINIT (CWE-457):
net/netfilter/nf_conntrack_h323_main.c:1189:2: var_decl:
Declaring variable "tuple" without initializer.
net/netfilter/nf_conntrack_h323_main.c:1197:2:
uninit_use_in_call: Using uninitialized value "tuple.src.l3num" when calling "__nf_ct_expect_find".
net/netfilter/nf_conntrack_expect.c:142:2:
read_value: Reading value "tuple->src.l3num" when calling "nf_ct_expect_dst_hash".
1195| tuple.dst.protonum = IPPROTO_TCP; 1196| 1197|-> exp = __nf_ct_expect_find(net, nf_ct_zone(ct), &tuple); 1198| if (exp && exp->master == ct) 1199| return exp;
Switch this to a C99 initialiser and set the l3num value.
--- net/netfilter/nf_conntrack_h323_main.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
net/netfilter/nf_conntrack_h323_main.c +5 -5
@@ -1186,13 +1186,13 @@ static struct nf_conntrack_expect *find_expect(struct nf_conn *ct, {struct net *net =nf_ct_net (ct);struct nf_conntrack_expect *exp; -struct nf_conntrack_tuple tuple; +struct nf_conntrack_tuple tuple = { + .src.l3num =nf_ct_l3num (ct), + .dst.protonum =IPPROTO_TCP , + .dst.u.tcp.port = port, + }; -memset (&tuple.src.u3,0 ,sizeof (tuple.src.u3)); - tuple.src.u.tcp.port =0 ;memcpy (&tuple.dst.u3, addr,sizeof (tuple.dst.u3)); - tuple.dst.u.tcp.port = port; - tuple.dst.protonum =IPPROTO_TCP ; exp =__nf_ct_expect_find (net,nf_ct_zone (ct), &tuple);if (exp && exp->master == ct)
Signature · 1 line
2.51.0
PATCH 379/385 ipvs: do not keep dest_dst if dev is going down
In reply to Sasha LevinFrom: Julian Anastasov <[email protected]>
[ Upstream commit 8fde939b0206afc1d5846217a01a16b9bc8c7896 ]
There is race between the netdev notifier ip_vs_dst_event() and the code that caches dst with dev that is going down. As the FIB can be notified for the closed device after our handler finishes, it is possible valid route to be returned and cached resuling in a leaked dev reference until the dest is not removed.
To prevent new dest_dst to be attached to dest just after the handler dropped the old one, add a netif_running() check to make sure the notifier handler is not currently running for device that is closing.
--- net/netfilter/ipvs/ip_vs_xmit.c | 46 ++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 10 deletions(-)
net/netfilter/ipvs/ip_vs_xmit.c +36 -10
@@ -295,6 +295,12 @@ static inline bool decrement_ttl(struct netns_ipvs *ipvs,return true; } +/* rt has device that is down */ +static bool rt_dev_is_down (const struct net_device *dev) +{ +return dev && !netif_running (dev); +} +/* Get route to destination or remote server */ static int __ip_vs_get_out_rt(struct netns_ipvs *ipvs, int skb_af, struct sk_buff *skb,
@@ -310,9 +316,11 @@ __ip_vs_get_out_rt(struct netns_ipvs *ipvs, int skb_af, struct sk_buff *skb,if (dest) { dest_dst =__ip_vs_dst_check (dest); -if (likely (dest_dst)) +if (likely (dest_dst)) { rt =dst_rtable (dest_dst->dst_cache); -else { +if (ret_saddr) + *ret_saddr = dest_dst->dst_saddr.ip; + }else { dest_dst =ip_vs_dest_dst_alloc ();spin_lock_bh (&dest->dst_lock);if (!dest_dst) {
@@ -328,14 +336,22 @@ __ip_vs_get_out_rt(struct netns_ipvs *ipvs, int skb_af, struct sk_buff *skb,ip_vs_dest_dst_free (dest_dst); goto err_unreach; } -__ip_vs_dst_set (dest, dest_dst, &rt->dst,0 ); +/* It is forbidden to attach dest->dest_dst if +* device is going down. +*/ +if (!rt_dev_is_down (dst_dev_rcu (&rt->dst))) +__ip_vs_dst_set (dest, dest_dst, &rt->dst,0 ); +else + noref =0 ;spin_unlock_bh (&dest->dst_lock);IP_VS_DBG (10 ,"new dst %pI4, src %pI4, refcnt=%d\n" , &dest->addr.ip, &dest_dst->dst_saddr.ip,rcuref_read (&rt->dst.__rcuref)); +if (ret_saddr) + *ret_saddr = dest_dst->dst_saddr.ip; +if (!noref) +ip_vs_dest_dst_free (dest_dst); } -if (ret_saddr) - *ret_saddr = dest_dst->dst_saddr.ip; }else { noref =0 ;
@@ -472,9 +488,11 @@ __ip_vs_get_out_rt_v6(struct netns_ipvs *ipvs, int skb_af, struct sk_buff *skb,if (dest) { dest_dst =__ip_vs_dst_check (dest); -if (likely (dest_dst)) +if (likely (dest_dst)) { rt =dst_rt6_info (dest_dst->dst_cache); -else { +if (ret_saddr) + *ret_saddr = dest_dst->dst_saddr.in6; + }else {u32 cookie; dest_dst =ip_vs_dest_dst_alloc ();
@@ -495,14 +513,22 @@ __ip_vs_get_out_rt_v6(struct netns_ipvs *ipvs, int skb_af, struct sk_buff *skb, } rt =dst_rt6_info (dst); cookie =rt6_get_cookie (rt); -__ip_vs_dst_set (dest, dest_dst, &rt->dst, cookie); +/* It is forbidden to attach dest->dest_dst if +* device is going down. +*/ +if (!rt_dev_is_down (dst_dev_rcu (&rt->dst))) +__ip_vs_dst_set (dest, dest_dst, &rt->dst, cookie); +else + noref =0 ;spin_unlock_bh (&dest->dst_lock);IP_VS_DBG (10 ,"new dst %pI6, src %pI6, refcnt=%d\n" , &dest->addr.in6, &dest_dst->dst_saddr.in6,rcuref_read (&rt->dst.__rcuref)); +if (ret_saddr) + *ret_saddr = dest_dst->dst_saddr.in6; +if (!noref) +ip_vs_dest_dst_free (dest_dst); } -if (ret_saddr) - *ret_saddr = dest_dst->dst_saddr.in6; }else { noref =0 ; dst = __ip_vs_route_output_v6(net, daddr, ret_saddr, do_xfrm,
Signature · 1 line
2.51.0
PATCH 380/385 net: remove WARN_ON_ONCE when accessing forward path array
In reply to Sasha LevinFrom: Pablo Neira Ayuso <[email protected]>
[ Upstream commit 008e7a7c293b30bc43e4368dac6ea3808b75a572 ]
Although unlikely, recent support for IPIP tunnels increases chances of reaching this WARN_ON_ONCE if userspace manages to build a sufficiently long forward path.
Remove it.
--- net/core/dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/dev.c +1 -1
@@ -720,7 +720,7 @@ static struct net_device_path *dev_fwd_path(struct net_device_path_stack *stack) {int k = stack->num_paths++; -if (WARN_ON_ONCE (k >=NET_DEVICE_PATH_STACK_MAX )) +if (k >=NET_DEVICE_PATH_STACK_MAX )return NULL ;return &stack->path[k];
Signature · 1 line
2.51.0
PATCH 381/385 netfilter: nf_tables: fix use-after-free in nf_tables_addchain()
In reply to Sasha LevinFrom: Inseo An <[email protected]>
[ Upstream commit 71e99ee20fc3f662555118cf1159443250647533 ]
nf_tables_addchain() publishes the chain to table->chains via list_add_tail_rcu() (in nft_chain_add()) before registering hooks. If nf_tables_register_hook() then fails, the error path calls nft_chain_del() (list_del_rcu()) followed by nf_tables_chain_destroy() with no RCU grace period in between.
This creates two use-after-free conditions:
1) Control-plane: nf_tables_dump_chains() traverses table->chains under rcu_read_lock(). A concurrent dump can still be walking the chain when the error path frees it.
2) Packet path: for NFPROTO_INET, nf_register_net_hook() briefly installs the IPv4 hook before IPv6 registration fails. Packets entering nft_do_chain() via the transient IPv4 hook can still be dereferencing chain->blob_gen_X when the error path frees the chain.
Add synchronize_rcu() between nft_chain_del() and the chain destroy so that all RCU readers -- both dump threads and in-flight packet evaluation -- have finished before the chain is freed.
--- net/netfilter/nf_tables_api.c | 1 + 1 file changed, 1 insertion(+)
net/netfilter/nf_tables_api.c +1 -0
@@ -2645,6 +2645,7 @@ static int nf_tables_addchain(struct nft_ctx *ctx, u8 family, u8 genmask, err_register_hook:nft_chain_del (chain); +synchronize_rcu (); err_chain_add:nft_trans_destroy (trans); err_trans:
Signature · 1 line
2.51.0
PATCH 382/385 ipv6: fix a race in ip6_sock_set_v6only()
In reply to Sasha LevinFrom: Eric Dumazet <[email protected]>
[ Upstream commit 452a3eee22c57a5786ae6db5c97f3b0ec13bb3b7 ]
It is unlikely that this function will be ever called with isk->inet_num being not zero.
Perform the check on isk->inet_num inside the locked section for complete safety.
--- include/net/ipv6.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
include/net/ipv6.h +7 -4
@@ -1275,12 +1275,15 @@ int ipv6_sock_mc_drop(struct sock *sk, int ifindex,static inline int ip6_sock_set_v6only (struct sock *sk) { -if (inet_sk (sk)->inet_num) -return -EINVAL ; +int ret =0 ; +lock_sock (sk); - sk->sk_ipv6only = true; +if (inet_sk (sk)->inet_num) + ret = -EINVAL ; +else + sk->sk_ipv6only = true;release_sock (sk); -return 0 ; +return ret; }static inline void ip6_sock_set_recverr (struct sock *sk)
Signature · 1 line
2.51.0
PATCH 383/385 bpftool: Fix truncated netlink dumps
In reply to Sasha LevinFrom: Jakub Kicinski <[email protected]>
[ Upstream commit 3b39d73cc3379360a33eb583b17f21fe55e1288e ]
Netlink requires that the recv buffer used during dumps is at least min(PAGE_SIZE, 8k) (see the man page). Otherwise the messages will get truncated. Make sure bpftool follows this requirement, avoid missing information on systems with large pages.
--- tools/bpf/bpftool/net.c | 5 ++++- tools/lib/bpf/netlink.c | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-)
tools/bpf/bpftool/net.c +4 -1
@@ -156,7 +156,7 @@ static int netlink_recv(int sock, __u32 nl_pid, __u32 seq,bool multipart = true;struct nlmsgerr *err;struct nlmsghdr *nh; -char buf[4096 ]; +char buf[8192 ];int len, ret;while (multipart) {
@@ -201,6 +201,9 @@ static int netlink_recv(int sock, __u32 nl_pid, __u32 seq,return ret; } } + +if (len) +p_err ("Invalid message or trailing data in Netlink response: %d bytes left" , len); } ret =0 ; done:
tools/lib/bpf/netlink.c +3 -1
@@ -143,7 +143,7 @@ static int libbpf_netlink_recv(int sock, __u32 nl_pid, int seq,struct nlmsghdr *nh;int len, ret; - ret =alloc_iov (&iov,4096 ); + ret =alloc_iov (&iov,8192 );if (ret) goto done;
@@ -212,6 +212,8 @@ static int libbpf_netlink_recv(int sock, __u32 nl_pid, int seq, } } } +if (len) +pr_warn ("Invalid message or trailing data in Netlink response: %d bytes left\n" , len); } ret =0 ; done:
Signature · 1 line
2.51.0
PATCH 384/385 ping: annotate data-races in ping_lookup()
In reply to Sasha LevinFrom: Eric Dumazet <[email protected]>
[ Upstream commit ad5dfde2a5733aaf652ea3e40c8c5e071e935901 ]
isk->inet_num, isk->inet_rcv_saddr and sk->sk_bound_dev_if are read locklessly in ping_lookup().
Add READ_ONCE()/WRITE_ONCE() annotations.
The race on isk->inet_rcv_saddr is probably coming from IPv6 support, but does not deserve a specific backport.
--- net/ipv4/ping.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-)
net/ipv4/ping.c +19 -12
@@ -159,7 +159,7 @@ void ping_unhash(struct sock *sk)pr_debug ("ping_unhash(isk=%p,isk->num=%u)\n" , isk, isk->inet_num);spin_lock (&ping_table.lock);if (sk_del_node_init_rcu (sk)) { - isk->inet_num =0 ; +WRITE_ONCE (isk->inet_num,0 ); isk->inet_sport =0 ;sock_prot_inuse_add (sock_net (sk), sk->sk_prot,-1 ); }
@@ -192,31 +192,35 @@ static struct sock *ping_lookup(struct net *net, struct sk_buff *skb, u16 ident) } sk_for_each_rcu(sk, hslot) { + int bound_dev_if; + if (!net_eq(sock_net(sk), net)) continue; isk = inet_sk(sk); pr_debug("iterate\n"); - if (isk->inet_num != ident) + if (READ_ONCE(isk->inet_num) != ident) continue; + bound_dev_if = READ_ONCE(sk->sk_bound_dev_if); if (skb->protocol == htons(ETH_P_IP) && sk->sk_family == AF_INET) { + __be32 rcv_saddr = READ_ONCE(isk->inet_rcv_saddr); + pr_debug("found: %p: num=%d, daddr=%pI4, dif=%d\n", sk, - (int) isk->inet_num, &isk->inet_rcv_saddr, - sk->sk_bound_dev_if); + ident, &rcv_saddr, + bound_dev_if); - if (isk->inet_rcv_saddr && - isk->inet_rcv_saddr != ip_hdr(skb)->daddr) + if (rcv_saddr && rcv_saddr != ip_hdr(skb)->daddr) continue; #if IS_ENABLED(CONFIG_IPV6) } else if (skb->protocol == htons(ETH_P_IPV6) && sk->sk_family == AF_INET6) { pr_debug("found: %p: num=%d, daddr=%pI6c, dif=%d\n", sk, - (int) isk->inet_num, + ident, &sk->sk_v6_rcv_saddr, - sk->sk_bound_dev_if); + bound_dev_if); if (!ipv6_addr_any(&sk->sk_v6_rcv_saddr) && !ipv6_addr_equal(&sk->sk_v6_rcv_saddr,
@@ -227,8 +231,8 @@ static struct sock *ping_lookup(struct net *net, struct sk_buff *skb, u16 ident)continue ; } -if (sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif && - sk->sk_bound_dev_if != sdif) +if (bound_dev_if && bound_dev_if != dif && + bound_dev_if != sdif)continue ; goto exit;
@@ -403,7 +407,9 @@ static void ping_set_saddr(struct sock *sk, struct sockaddr *saddr)if (saddr->sa_family ==AF_INET ) {struct inet_sock *isk =inet_sk (sk);struct sockaddr_in *addr = (struct sockaddr_in *) saddr; - isk->inet_rcv_saddr = isk->inet_saddr = addr->sin_addr.s_addr; + + isk->inet_saddr = addr->sin_addr.s_addr; +WRITE_ONCE (isk->inet_rcv_saddr, addr->sin_addr.s_addr);#if IS_ENABLED (CONFIG_IPV6 ) } else if (saddr->sa_family == AF_INET6) {struct sockaddr_in6 *addr = (struct sockaddr_in6 *) saddr;
@@ -860,7 +866,8 @@ int ping_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int flags,struct sk_buff *skb;int copied, err; -pr_debug ("ping_recvmsg(sk=%p,sk->num=%u)\n" , isk, isk->inet_num); +pr_debug ("ping_recvmsg(sk=%p,sk->num=%u)\n" , isk, +READ_ONCE (isk->inet_num)); err = -EOPNOTSUPP ;if (flags &MSG_OOB )
Signature · 1 line
2.51.0
PATCH 385/385 Linux 6.12.75-rc1
In reply to Sasha Levin--- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Makefile +2 -2
@@ -1,8 +1,8 @@ # SPDX-License-Identifier: GPL-2.0 VERSION = 6 PATCHLEVEL = 12 -SUBLEVEL = 74 -EXTRAVERSION = +SUBLEVEL = 75 +EXTRAVERSION = -rc1 NAME = Baby Opossum Posse # *DOCUMENTATION*
Signature · 1 line
2.51.0