From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gabriel Paubert Subject: Re: [PATCH v12 01/12] lib: introduce copy_struct_{to, from}_user helpers Date: Thu, 5 Sep 2019 12:13:15 +0200 Message-ID: <20190905101315.GA25637@lt-gp.iram.es> References: <20190904201933.10736-1-cyphar@cyphar.com> <20190904201933.10736-2-cyphar@cyphar.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=m.gmane.org@lists.infradead.org To: Andreas Schwab Cc: linux-ia64@vger.kernel.org, linux-sh@vger.kernel.org, Peter Zijlstra , Rasmus Villemoes , Alexei Starovoitov , linux-mips@vger.kernel.org, David Howells , linux-kselftest@vger.kernel.org, sparclinux@vger.kernel.org, Jiri Olsa , linux-arch@vger.kernel.org, linux-s390@vger.kernel.org, Tycho Andersen , Aleksa Sarai , Shuah Khan , Alexander Shishkin , Ingo Molnar , Christian Brauner , linux-xtensa@linux-xtensa.org, Kees Cook , Arnd Bergmann , Jann Horn , Oleg Nesterov , Aleksa Sarai , Al Viro , Andy Lutomirski Shua List-Id: linux-arch.vger.kernel.org On Thu, Sep 05, 2019 at 11:09:35AM +0200, Andreas Schwab wrote: > On Sep 05 2019, Aleksa Sarai wrote: > > > diff --git a/lib/struct_user.c b/lib/struct_user.c > > new file mode 100644 > > index 000000000000..7301ab1bbe98 > > --- /dev/null > > +++ b/lib/struct_user.c > > @@ -0,0 +1,182 @@ > > +// SPDX-License-Identifier: GPL-2.0-or-later > > +/* > > + * Copyright (C) 2019 SUSE LLC > > + * Copyright (C) 2019 Aleksa Sarai > > + */ > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > +#define BUFFER_SIZE 64 > > + > > +/* > > + * "memset(p, 0, size)" but for user space buffers. Caller must have already > > + * checked access_ok(p, size). > > + */ > > +static int __memzero_user(void __user *p, size_t s) > > +{ > > + const char zeros[BUFFER_SIZE] = {}; > > Perhaps make that static? On SMP? It should at least be per cpu, and I'm not even sure with preemption. Gabriel > > Andreas. > > -- > Andreas Schwab, schwab@linux-m68k.org > GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 > "And now for something completely different." From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from outbound4mad.lav.puc.rediris.es ([130.206.19.146]:47950 "EHLO mx01.puc.rediris.es" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730864AbfIEK0C (ORCPT ); Thu, 5 Sep 2019 06:26:02 -0400 Date: Thu, 5 Sep 2019 12:13:15 +0200 From: Gabriel Paubert Subject: Re: [PATCH v12 01/12] lib: introduce copy_struct_{to, from}_user helpers Message-ID: <20190905101315.GA25637@lt-gp.iram.es> References: <20190904201933.10736-1-cyphar@cyphar.com> <20190904201933.10736-2-cyphar@cyphar.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-arch-owner@vger.kernel.org List-ID: To: Andreas Schwab Cc: Aleksa Sarai , linux-ia64@vger.kernel.org, linux-sh@vger.kernel.org, Peter Zijlstra , Rasmus Villemoes , Alexei Starovoitov , linux-kernel@vger.kernel.org, David Howells , linux-kselftest@vger.kernel.org, sparclinux@vger.kernel.org, Shuah Khan , linux-arch@vger.kernel.org, linux-s390@vger.kernel.org, Tycho Andersen , Aleksa Sarai , Jiri Olsa , Alexander Shishkin , Ingo Molnar , linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-xtensa@linux-xtensa.org, Kees Cook , Arnd Bergmann , Jann Horn , linuxppc-dev@lists.ozlabs.org, linux-m68k@lists.linux-m68k.org, Al Viro , Andy Lutomirski , Shuah Khan , Namhyung Kim , David Drysdale , Christian Brauner , "J. Bruce Fields" , linux-parisc@vger.kernel.org, linux-api@vger.kernel.org, Chanho Min , Jeff Layton , Oleg Nesterov , Eric Biederman , linux-alpha@vger.kernel.org, linux-fsdevel@vger.kernel.org, Andrew Morton , Linus Torvalds , containers@lists.linux-foundation.org Message-ID: <20190905101315.5WejuCN-mzyPQeijvcpn2OKF6dQ-jya6R3EZjUdFIDQ@z> On Thu, Sep 05, 2019 at 11:09:35AM +0200, Andreas Schwab wrote: > On Sep 05 2019, Aleksa Sarai wrote: > > > diff --git a/lib/struct_user.c b/lib/struct_user.c > > new file mode 100644 > > index 000000000000..7301ab1bbe98 > > --- /dev/null > > +++ b/lib/struct_user.c > > @@ -0,0 +1,182 @@ > > +// SPDX-License-Identifier: GPL-2.0-or-later > > +/* > > + * Copyright (C) 2019 SUSE LLC > > + * Copyright (C) 2019 Aleksa Sarai > > + */ > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > +#define BUFFER_SIZE 64 > > + > > +/* > > + * "memset(p, 0, size)" but for user space buffers. Caller must have already > > + * checked access_ok(p, size). > > + */ > > +static int __memzero_user(void __user *p, size_t s) > > +{ > > + const char zeros[BUFFER_SIZE] = {}; > > Perhaps make that static? On SMP? It should at least be per cpu, and I'm not even sure with preemption. Gabriel > > Andreas. > > -- > Andreas Schwab, schwab@linux-m68k.org > GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 > "And now for something completely different."