[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <Z9WgvgHYr1A6S3K6@slm.duckdns.org>
Date: Sat, 15 Mar 2025 05:46:06 -1000
From: Tejun Heo <tj@...nel.org>
To: xie.ludan@....com.cn
Cc: jiangshanlai@...il.com, linux-kernel@...r.kernel.org
Subject: Re: [PATCH linux-next] workqueue: use sysfs_emit() instead of
scnprintf().
On Sat, Mar 15, 2025 at 02:17:58PM +0800, xie.ludan@....com.cn wrote:
> From: XieLudan <xie.ludan@....com.cn>
>
> Follow the advice in Documentation/filesystems/sysfs.rst:
> show() should only use sysfs_emit() or sysfs_emit_at() when formatting
> the value to be returned to user space.
>
> Signed-off-by: XieLudan <xie.ludan@....com.cn>
> ---
> kernel/workqueue.c | 22 +++++++++++-----------
> 1 file changed, 11 insertions(+), 11 deletions(-)
>
> diff --git a/kernel/workqueue.c b/kernel/workqueue.c
> index bfe030b443e2..648e89dd3ef1 100644
> --- a/kernel/workqueue.c
> +++ b/kernel/workqueue.c
> @@ -6463,10 +6463,10 @@ void wq_worker_comm(char *buf, size_t size, struct task_struct *task)
> */
> if (worker->desc[0] != '\0') {
> if (worker->current_work)
> - scnprintf(buf + off, size - off, "+%s",
> + sysfs_emit(buf + off, "+%s",
> worker->desc);
> else
> - scnprintf(buf + off, size - off, "-%s",
> + sysfs_emit(buf + off, "-%s",
> worker->desc);
> }
> raw_spin_unlock_irq(&pool->lock);
How did you verify your changes? wq_worker_comm() is used from procfs not
sysfs. @buf is on-stack 64byte buffer from proc_task_name() which is not
page aligned and will most likely trigger WARN() path in sysfs_emit().
Thanks.
--
tejun
Powered by blists - more mailing lists