[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aWS9nOj4MAa7pYmS@google.com>
Date: Mon, 12 Jan 2026 09:23:40 +0000
From: Alice Ryhl <aliceryhl@...gle.com>
To: Fushuai Wang <fushuai.wang@...ux.dev>
Cc: tglx@...nel.org, peterz@...radead.org, mathieu.desnoyers@...icios.com,
akpm@...ux-foundation.org, yury.norov@...il.com, vmalik@...hat.com,
kees@...nel.org, dave.hansen@...ux.intel.com, luto@...nel.org,
mingo@...hat.com, bp@...en8.de, hpa@...or.com, rostedt@...dmis.org,
mhiramat@...nel.org, brauner@...nel.org, jack@...e.cz, cyphar@...har.com,
linux-kernel@...r.kernel.org, x86@...nel.org,
linux-trace-kernel@...r.kernel.org, wangfushuai@...du.com
Subject: Re: [PATCH v2 1/6] uaccess: Add copy_from_user_nul helper
On Mon, Jan 12, 2026 at 03:30:34PM +0800, Fushuai Wang wrote:
> From: Fushuai Wang <wangfushuai@...du.com>
>
> Many places call copy_from_user() to copy a buffer from user space,
> and then manually add a NULL terminator to the destination buffer,
> e.g.:
>
> if (copy_from_user(dest, src, len))
> return -EFAULT;
> dest[len] = '\0';
>
> This is repetitive and error-prone. Add a copy_from_user_nul() helper to
> simplify such patterns. It copied n bytes from user space to kernel space,
> and NUL-terminates the destination buffer.
>
> Signed-off-by: Fushuai Wang <wangfushuai@...du.com>
Hmm, this function is very very similar to strncpy_from_user(). Should
they be using that instead?
Alice
Powered by blists - more mailing lists