|
Message-ID: <20190219215345.GB16094@eros.localdomain> Date: Wed, 20 Feb 2019 08:53:45 +1100 From: "Tobin C. Harding" <me@...in.cc> To: Jann Horn <jannh@...gle.com> Cc: "Tobin C. Harding" <tobin@...nel.org>, Kees Cook <keescook@...omium.org>, Shuah Khan <shuah@...nel.org>, Alexander Shishkin <alexander.shishkin@...ux.intel.com>, Greg Kroah-Hartman <gregkh@...uxfoundation.org>, Andy Shevchenko <andriy.shevchenko@...ux.intel.com>, Kernel Hardening <kernel-hardening@...ts.openwall.com>, kernel list <linux-kernel@...r.kernel.org> Subject: Re: [PATCH 6/6] lib: Add function strscpy_from_user() On Tue, Feb 19, 2019 at 03:12:33AM +0100, Jann Horn wrote: > On Tue, Feb 19, 2019 at 12:25 AM Tobin C. Harding <tobin@...nel.org> 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 <tobin@...nel.org> > > --- > > 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. thanks! Dropping *_from_user() stuff from set. Tobin
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.