From nobody Sat Feb 7 22:21:02 2026 Received: from out-180.mta0.migadu.com (out-180.mta0.migadu.com [91.218.175.180]) (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 87D1F135A53 for ; Sat, 17 Jan 2026 14:57:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768661831; cv=none; b=DaHlYkbBpc0mGUcDX5agGR8fFH/Cs8MqdyFuXf5mumLPAlIZqZPeqSalaHxwC+rGK4lST39HxMgJ9i1MJHq6s/tlxKj3mdtMx7FGRqXMqKSg1npss6FQyuUjjnZkgSy8yvbzneXsHWqFPn3Rq9LfjnIQUN8lfCeViURJd+sktV8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768661831; c=relaxed/simple; bh=KfjyWfJ0OcxZD1rdo2Qfd8W/AdVx4uWEYPHWpHI/Nmo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rK7thlPoGB3grznsaD8CiCU5IhXiHYOhAHvu4ui4lRiVDIUuIakuCskHOIKf1/lyU/nx2E9mwUcEEZ7FzluIwT+7Vr328jxpAUKeR5FLcIKPdvYWCqHD0W1ADTfMtZ9MQmIf7ZIfiLCX4YDLdMriHQ8CS9ChIl4NEulZn5XS2LI= 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=EA3e1lrn; arc=none smtp.client-ip=91.218.175.180 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="EA3e1lrn" 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=1768661826; 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=z+Aee/W8dwsk9W07lPrpMvK4GVzq11zqDx26pB61fJw=; b=EA3e1lrnb/itYtrdTJxjpyIteUYN+m1USoF/flLl3GxPSpazgqCNLhwEPeN7e3pvPirS24 hQK2QrzN8W5NoeIcX5pDc0BvxewxnQ3YrBKN3K+H9i3JhZyfQn+oOifp4KWXmrSnlwBsEF U6aOINRDA7yLKxt8xG/wAlMlPOussi4= 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 v2 1/2] sched/debug: Convert copy_from_user() + kstrtouint() to kstrtouint_from_user() Date: Sat, 17 Jan 2026 22:56:14 +0800 Message-Id: <20260117145615.53455-2-fushuai.wang@linux.dev> In-Reply-To: <20260117145615.53455-1-fushuai.wang@linux.dev> References: <20260117145615.53455-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. Suggested-by: Yury Norov Signed-off-by: Fushuai Wang Reviewed-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..b27229a1922b 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) + return ret; =20 if (scaling >=3D SCHED_TUNABLESCALING_END) return -EINVAL; --=20 2.36.1 From nobody Sat Feb 7 22:21:02 2026 Received: from out-172.mta0.migadu.com (out-172.mta0.migadu.com [91.218.175.172]) (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 CBE9B1C8604 for ; Sat, 17 Jan 2026 14:57:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768661839; cv=none; b=HKf2OMBatgMqfNoIHVQ7+BUX9g6EOg2KquawIOM59Q4wSkgCY/DxCgGCHhPn/mmu983AEkQAV91wdOcz1FMfWdx+ERMr+uJ0CeUDOaHUXQLgvU5AhCY/2Ou/Lm/TC77xvpO8hsbJ3TOAlbhpfLrh3wxdgvujHQZmWaoTWz0Cl4g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768661839; c=relaxed/simple; bh=GMdqRmdHj0p2UuxCKy6TNTi0E50JaVmab4hXuuplK3Y=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=SdgnOMCwG95DMkpckjis05kYp6OAIytYdKWSv58j2ILKTMdkb6F985o5nYGr1Eo8gEg6l1fIbuYPB5EhJOsdKqxzCxGd2F9xJDtlBy5/3br+fiwJ5S6nZOtNGuegRpgfmm14z8j7y2btMl28wtec2XP6uoReMGRemFs2Mz4LnhE= 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=sfNrbshI; arc=none smtp.client-ip=91.218.175.172 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="sfNrbshI" 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=1768661835; 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=tTdGbvRuFnvWK23R+yyXNvABdeDAFjAONBjd3JinxkE=; b=sfNrbshI7lvhXaLC3JjkZvdTt3j4Dca8K9XgWJXmI6ltzLfRbctQVSJU00QwVD9rO1d8V+ kqxL9es2A8FMc7jdgimCAAELGb9ubqFEqqHC1L2J2iZDbm/C/fnLEMRDHp6tUY4MGe+YRN J7idpYQdXqm0lmwUVA0oSWu/WUhcE2M= 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 v2 2/2] x86/tlb: Convert copy_from_user() + kstrtouint() to kstrtouint_from_user() Date: Sat, 17 Jan 2026 22:56:15 +0800 Message-Id: <20260117145615.53455-3-fushuai.wang@linux.dev> In-Reply-To: <20260117145615.53455-1-fushuai.wang@linux.dev> References: <20260117145615.53455-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. Suggested-by: Yury Norov Signed-off-by: Fushuai Wang Reviewed-by: Yury Norov --- 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