From nobody Sun Feb 8 02:21:17 2026 Received: from out-174.mta1.migadu.com (out-174.mta1.migadu.com [95.215.58.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4C3837260A for ; Fri, 16 Jan 2026 13:18:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768569517; cv=none; b=ZoUUmwvUxVqMMt8uOiLsF9NCrzGTeO1YOz191Dd/xdYejnjbH0cektycYLc96RHxyXIgS344ftjTP6i/TYzR5h5EMDsPNwTCq3N+bmKRzPf882KfCXSAasSKhY1mgNTkCzATxAQooncSm2tx8eyz+ZH+68M2zoJTVIGTsg5Az1c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768569517; c=relaxed/simple; bh=4GLLgomd1MIULtiqCsTwoRwJXghnulUDpEJRxt40xxQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=XPViUCVk4hCWmxFxzgi2Ygea3hG5YibE7yk9m+whvq4fzp50+zUXk4D8B0nmXzyCsXLPVbLA4OLW5vplMaZhThZ8Ao6/vEunJhu74h4ete/UN6/VJs4Qc2HnmZ7vdfO6YfueW/F1m9lkbbDhoTXbq+z9KfAk+iw/XezaQ7G7t08= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=g8Tdcgcx; arc=none smtp.client-ip=95.215.58.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="g8Tdcgcx" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1768569513; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vRVA1pT9ccZ1QlSIsSYNaFWDgIEvpEMO66rX8NvLUH0=; b=g8TdcgcxlX7SpHJLVysCLs3RIxnRVWuHO069lGyVKK3Skc7gfimB7pF+Z6dO1pXk6CuYgX /iWLG+ADG+hiquPDWWUiHOxv5ewpRYrGyLW0raGJlatfaWIe893UZYiHIVF9OkPX2La2E/ wO+6Ycqm8YNoCi//gOmNToLdEi+SEzI= From: Fushuai Wang To: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, vschneid@redhat.com, dave.hansen@linux.intel.com, luto@kernel.org, tglx@kernel.org, bp@alien8.de, hpa@zytor.com Cc: linux-kernel@vger.kernel.org, x86@kernel.org, wangfushuai@baidu.com, aliceryhl@google.com, ynorov@nvidia.com Subject: [PATCH 1/2] sched/debug: Convert copy_from_user() + kstrtouint() to kstrtouint_from_user() Date: Fri, 16 Jan 2026 21:17:50 +0800 Message-Id: <20260116131751.45768-2-fushuai.wang@linux.dev> In-Reply-To: <20260116131751.45768-1-fushuai.wang@linux.dev> References: <20260116131751.45768-1-fushuai.wang@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" From: Fushuai Wang Using kstrtouint_from_user() instead of copy_from_user() + kstrtouint() makes the code simpler and less error-prone. Signed-off-by: Fushuai Wang Reviewed-by: Yury Norov Suggested-by: Yury Norov --- kernel/sched/debug.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c index 41caa22e0680..1091f9046260 100644 --- a/kernel/sched/debug.c +++ b/kernel/sched/debug.c @@ -172,18 +172,12 @@ static const struct file_operations sched_feat_fops = =3D { static ssize_t sched_scaling_write(struct file *filp, const char __user *u= buf, size_t cnt, loff_t *ppos) { - char buf[16]; unsigned int scaling; + int ret; =20 - if (cnt > 15) - cnt =3D 15; - - if (copy_from_user(&buf, ubuf, cnt)) - return -EFAULT; - buf[cnt] =3D '\0'; - - if (kstrtouint(buf, 10, &scaling)) - return -EINVAL; + ret =3D kstrtouint_from_user(ubuf, cnt, 10, &scaling); + if (ret < 0) + return ret; =20 if (scaling >=3D SCHED_TUNABLESCALING_END) return -EINVAL; --=20 2.36.1 From nobody Sun Feb 8 02:21:17 2026 Received: from out-179.mta1.migadu.com (out-179.mta1.migadu.com [95.215.58.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1790A1F4C8C for ; Fri, 16 Jan 2026 13:18:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768569524; cv=none; b=fHpJp3LviJ6GwtpUkOvIYTO/lZYcqGVnfEjhrfKJzHMYQG1MMWqloHBV2oTnX5COnBirZz2U3hCpmv/nD16UsHwYGP5J7cy3JgZMvegD56LNLr6ZUTT4B0LwsMq5WQ7QLlef7kj//3i0ubKScn2KfnSNsTwFmygzNnAHKwWGsko= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768569524; c=relaxed/simple; bh=W030Cngi27ARnrs0hcx3i9eS3lrlMPJjDqdTJ1xmuEY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ALrpi2aHMNSZCiUBMsj2wa++GZI/ZQR3xeUNrRYkkACtqFz5xXnjY4ZnZyWu4yxwjaCUGERedR54V/oIGVgeSFvN3YLRbb6yWNNW6TfKGAJ9azLYwke5KhGj4rO/J8ZHsYh/skeiHWzZi7LWO+ldPbP+yRlkM44FPBFm9Q9JP/o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=EBVcf6M9; arc=none smtp.client-ip=95.215.58.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="EBVcf6M9" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1768569520; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uYSo00XVoIwr6sPFP0Qd1bj+mn6dCWN0CoUSmiLU1ls=; b=EBVcf6M9SKL87Zar2Q7qRonnSwYitvu6V7xu55IBZXJMH/iJsGsHlqMYW+OK9tdH54gAca rpjzs6aHOBWq8HSXqhF/LXP+9PAOr98hsH+gB+75mVl/nJAiHSyH299TPJX14fcwFwpnrC dPuJb1KgWSz/7pFFoLGt+XHE9LMbJdQ= From: Fushuai Wang To: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, vschneid@redhat.com, dave.hansen@linux.intel.com, luto@kernel.org, tglx@kernel.org, bp@alien8.de, hpa@zytor.com Cc: linux-kernel@vger.kernel.org, x86@kernel.org, wangfushuai@baidu.com, aliceryhl@google.com, ynorov@nvidia.com Subject: [PATCH 2/2] x86/tlb: Convert copy_from_user() + kstrtouint() to kstrtouint_from_user() Date: Fri, 16 Jan 2026 21:17:51 +0800 Message-Id: <20260116131751.45768-3-fushuai.wang@linux.dev> In-Reply-To: <20260116131751.45768-1-fushuai.wang@linux.dev> References: <20260116131751.45768-1-fushuai.wang@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" From: Fushuai Wang Using kstrtouint_from_user() instead of copy_from_user() + kstrtouint() makes the code simpler and less error-prone. Signed-off-by: Fushuai Wang --- arch/x86/mm/tlb.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c index f5b93e01e347..5e6a07306214 100644 --- a/arch/x86/mm/tlb.c +++ b/arch/x86/mm/tlb.c @@ -1802,17 +1802,12 @@ static ssize_t tlbflush_read_file(struct file *file= , char __user *user_buf, static ssize_t tlbflush_write_file(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) { - char buf[32]; - ssize_t len; int ceiling; + int err; =20 - len =3D min(count, sizeof(buf) - 1); - if (copy_from_user(buf, user_buf, len)) - return -EFAULT; - - buf[len] =3D '\0'; - if (kstrtoint(buf, 0, &ceiling)) - return -EINVAL; + err =3D kstrtoint_from_user(user_buf, count, 0, &ceiling); + if (err) + return err; =20 if (ceiling < 0) return -EINVAL; --=20 2.36.1