Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 19 Feb 2019 03:12:33 +0100
From: Jann Horn <>
To: "Tobin C. Harding" <>
Cc: Kees Cook <>, Shuah Khan <>, 
	Alexander Shishkin <>, 
	Greg Kroah-Hartman <>, 
	Andy Shevchenko <>, 
	Kernel Hardening <>, 
	kernel list <>
Subject: Re: [PATCH 6/6] lib: Add function strscpy_from_user()

On Tue, Feb 19, 2019 at 12:25 AM Tobin C. Harding <> wrote:
> Currently we have strncpy_from_userspace().  If the user string is
> longer than the destination kernel buffer we get an error code -EFAULT.
> We are unable to recover from here because this is the same error
> returned if the access to userspace fails totally.
> There is no reason we cannot continue execution with the user string
> truncated.
> Add a function strscpy_from_user() that guarantees the string written is
> null-terminated.  If user string is longer than destination buffer
> truncates the string.  Returns the number of characters written
> excluding the null-terminator.
> Signed-off-by: Tobin C. Harding <>
> ---
>  lib/strncpy_from_user.c | 43 +++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 43 insertions(+)
> diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c
> index 11fe9a4a00fd..6bd603ccec7a 100644
> --- a/lib/strncpy_from_user.c
> +++ b/lib/strncpy_from_user.c

This file is only built when CONFIG_GENERIC_STRNCPY_FROM_USER is set.
Some architectures have their own versions of strncpy_from_user() and
don't set that, so on those architectures, your code wouldn't be built
into the kernel.

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.