From nobody Sun Feb 8 20:52:09 2026 Received: from out-173.mta0.migadu.com (out-173.mta0.migadu.com [91.218.175.173]) (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 8A002331A5D for ; Mon, 12 Jan 2026 07:32:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768203135; cv=none; b=Gk3gn1mndGfC33sgLAdWz4ufdlvtj2JccxMeEPRxKQaH/c5PO5Svlju8M6gCB3bca5tBqf/rcKfxihmpqdBxfQu5JIm7Ir+CE7csJ3p3Vq+U70VR33KtxmgFuBYrpcGXXI4q71ySnolB4s+VE9hAmNHBLN6/FYtNgQiQvZ5WULA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768203135; c=relaxed/simple; bh=OnqAbUWVy7D0WXGNVBkrLwkuw9vg94fN5udfoCsYN8g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=XV0p3USB/VH/Vwj15yzMN2DmtMWk/ymtnS+VErnVo3s3mMzJHGoed69G1MTYToMlNCWJ15rqDplYtnERVxx2qKxRfQUZXcZWdgULqhr09vzoqih8l9RbDrRX6vLrSdbnHhsCJF4eO0LjDuhyh0l72FGo0qaWmNnJ2sVTG/eDkic= 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=QQzgX29E; arc=none smtp.client-ip=91.218.175.173 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="QQzgX29E" 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=1768203126; 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=AwRqj4wTYeIgUDX0xZiGWFeCRQeFcAPC39VTqib2tBs=; b=QQzgX29EQmy4am2md5KjS0HuRT47z1dVNL4CH+BM0JYJb/YmzU4y/+lWkgxufMtBChEJ9G VcJND5bpCED/8yd1po0iwV4o93eczOgcIUlhgDMVZOGrhCqSQwJn8BqLoguJloK/x6VmCU bWhz9AVqeugOgV5pVfu2xggICKU01BI= From: Fushuai Wang To: tglx@kernel.org, peterz@infradead.org, mathieu.desnoyers@efficios.com, akpm@linux-foundation.org, aliceryhl@google.com, yury.norov@gmail.com, vmalik@redhat.com, kees@kernel.org, dave.hansen@linux.intel.com, luto@kernel.org, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, rostedt@goodmis.org, mhiramat@kernel.org, brauner@kernel.org, jack@suse.cz, cyphar@cyphar.com Cc: linux-kernel@vger.kernel.org, x86@kernel.org, linux-trace-kernel@vger.kernel.org, wangfushuai@baidu.com Subject: [PATCH v2 4/6] userns: Use copy_from_user_nul() instead of copy_from_user() Date: Mon, 12 Jan 2026 15:30:37 +0800 Message-Id: <20260112073039.1185-5-fushuai.wang@linux.dev> In-Reply-To: <20260112073039.1185-1-fushuai.wang@linux.dev> References: <20260112073039.1185-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 Use copy_from_user_nul() instead of copy_from_user() to simplify the code. No functional change. Signed-off-by: Fushuai Wang --- kernel/user_namespace.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c index 03cb63883d04..881a05a3502c 100644 --- a/kernel/user_namespace.c +++ b/kernel/user_namespace.c @@ -1239,9 +1239,8 @@ ssize_t proc_setgroups_write(struct file *file, const= char __user *buf, =20 /* What was written? */ ret =3D -EFAULT; - if (copy_from_user(kbuf, buf, count)) + if (copy_from_user_nul(kbuf, buf, count)) goto out; - kbuf[count] =3D '\0'; pos =3D kbuf; =20 /* What is being requested? */ --=20 2.36.1