From nobody Wed Feb 11 06:30:16 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 909C01DE89A for ; Thu, 9 Oct 2025 15:24:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760023460; cv=none; b=BTVDHZGxqdaGfn5k0hWHD5MsLBgcU78ijcVpSg3gxloGNeZDFPbRhDiAFA5XimJq6Tlr7XHF8O3ZTSWOjsYRHHXcUVviM5PUnQB0Wn5xRYQH27hh3kbxNbLDM3vqpG12nq32Mx/57hCzwJVsAhMHEziMc7o9BjI9mLiUxuONfWg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760023460; c=relaxed/simple; bh=CEtGqqcITVTrUmu5n1Px/b8IT2fO/W9sS2iAC9PxAX4=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=aN2DSYH+Deo74Yqs1wtddbjC3rfFyeDURc8Z2gtXXfR69KY+ZNx1ryHBqC0e3hHuN7VAcFcojpMVepyORBBOAwddTH2au0EYmc4QITTvZ8OrK14xfVh6xgFUW3Nj6N/d+p9aqGQIeKKmTE2qDeV+5qQYTitEE+4L8nYjKJFV7Xc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Nr25ctU9; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Nr25ctU9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2D2C9C4CEE7; Thu, 9 Oct 2025 15:24:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1760023460; bh=CEtGqqcITVTrUmu5n1Px/b8IT2fO/W9sS2iAC9PxAX4=; h=Date:From:To:Cc:Subject:References:From; b=Nr25ctU9Wxd8Z9qTVYFelUJo2Hkw/fNmWZnfIw9jokhnD3bFYHQg/zgC5NBHXMu3J 7Y5hRxFQFM04ndSWj86W03eETYEQoWJCRIVNUSClh+jB+OpZGDtErHEa+QtVgnAOnF ovWcGNBDXO2DChjYRAC/uMD5eeRFs/iCCCivbXbMLHA87bocdwqF+dPiwRIwf3ePYQ qLVM5ZCL0kskZDfMu1DfTthw3XEzoSJqUrQCczyp0Xs0asEQeGCDlY50Sf9sjdWDeL sagb06OLue4jRXxaf2bwnobtm6iLDKRC0j0DxDLWjTZQckeWk4xDMKmHywyfheOhU0 YyKH9Ct+DQ8mQ== Received: from rostedt by gandalf with local (Exim 4.98.2) (envelope-from ) id 1v6sVA-00000000BcV-34Cn; Thu, 09 Oct 2025 11:24:20 -0400 Message-ID: <20251009152420.583914074@kernel.org> User-Agent: quilt/0.68 Date: Thu, 09 Oct 2025 11:24:00 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Thorsten Blum Subject: [for-linus][PATCH 1/5] tracing/osnoise: Replace kmalloc + copy_from_user with memdup_user_nul References: <20251009152359.604267051@kernel.org> 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 Content-Type: text/plain; charset="utf-8" From: Thorsten Blum Replace kmalloc() followed by copy_from_user() with memdup_user_nul() to simplify and improve osnoise_cpus_write(). Remove the manual NUL-termination. No functional changes intended. Cc: Masami Hiramatsu Cc: Mathieu Desnoyers Link: https://lore.kernel.org/20251001130907.364673-2-thorsten.blum@linux.d= ev Signed-off-by: Thorsten Blum Signed-off-by: Steven Rostedt (Google) --- kernel/trace/trace_osnoise.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/kernel/trace/trace_osnoise.c b/kernel/trace/trace_osnoise.c index dc734867f0fc..26d0c99125f5 100644 --- a/kernel/trace/trace_osnoise.c +++ b/kernel/trace/trace_osnoise.c @@ -24,6 +24,7 @@ #include #include #include +#include #include "trace.h" =20 #ifdef CONFIG_X86_LOCAL_APIC @@ -2325,13 +2326,9 @@ osnoise_cpus_write(struct file *filp, const char __u= ser *ubuf, size_t count, if (count < 1) return 0; =20 - buf =3D kmalloc(count + 1, GFP_KERNEL); - if (!buf) - return -ENOMEM; - - if (copy_from_user(buf, ubuf, count)) - return -EFAULT; - buf[count] =3D '\0'; + buf =3D memdup_user_nul(ubuf, count); + if (IS_ERR(buf)) + return PTR_ERR(buf); =20 if (!zalloc_cpumask_var(&osnoise_cpumask_new, GFP_KERNEL)) return -ENOMEM; --=20 2.51.0