Re: [PATCH 14/14] uaccess: drop set_fs leftovers

2022-02-14 Thread Helge Deller
On 2/15/22 04:03, Al Viro wrote: > On Mon, Feb 14, 2022 at 05:34:52PM +0100, Arnd Bergmann wrote: >> diff --git a/arch/parisc/include/asm/futex.h >> b/arch/parisc/include/asm/futex.h >> index b5835325d44b..2f4a1b1ef387 100644 >> --- a/arch/parisc/include/asm/futex.h >> +++ b/arch/parisc/include/as

Re: [PATCH 09/14] m68k: drop custom __access_ok()

2022-02-14 Thread Al Viro
On Tue, Feb 15, 2022 at 07:29:42AM +0100, Christoph Hellwig wrote: > On Tue, Feb 15, 2022 at 12:37:41AM +, Al Viro wrote: > > Perhaps simply wrap that sucker into #ifdef CONFIG_CPU_HAS_ADDRESS_SPACES > > (and trim the comment down to "coldfire and 68000 will pick generic > > variant")? > > I w

Re: [PATCH 09/14] m68k: drop custom __access_ok()

2022-02-14 Thread Christoph Hellwig
On Tue, Feb 15, 2022 at 12:37:41AM +, Al Viro wrote: > Perhaps simply wrap that sucker into #ifdef CONFIG_CPU_HAS_ADDRESS_SPACES > (and trim the comment down to "coldfire and 68000 will pick generic > variant")? I wonder if we should invert CONFIG_ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE, select

Re: [PATCH 14/14] uaccess: drop set_fs leftovers

2022-02-14 Thread Al Viro
On Mon, Feb 14, 2022 at 05:34:52PM +0100, Arnd Bergmann wrote: > diff --git a/arch/parisc/include/asm/futex.h b/arch/parisc/include/asm/futex.h > index b5835325d44b..2f4a1b1ef387 100644 > --- a/arch/parisc/include/asm/futex.h > +++ b/arch/parisc/include/asm/futex.h > @@ -99,7 +99,7 @@ futex_atomic_

Re: [PATCH 04/14] x86: use more conventional access_ok() definition

2022-02-14 Thread Al Viro
On Mon, Feb 14, 2022 at 08:17:07PM +, Al Viro wrote: > On Mon, Feb 14, 2022 at 12:01:05PM -0800, Linus Torvalds wrote: > > On Mon, Feb 14, 2022 at 11:46 AM Arnd Bergmann wrote: > > > > > > As Al pointed out, they turned out to be necessary on sparc64, but the > > > only > > > definitions are

Re: [PATCH 11/14] sparc64: remove CONFIG_SET_FS support

2022-02-14 Thread Al Viro
On Mon, Feb 14, 2022 at 05:34:49PM +0100, Arnd Bergmann wrote: > -/* > - * Sparc64 is segmented, though more like the M68K than the I386. > - * We use the secondary ASI to address user memory, which references a > - * completely different VM map, thus there is zero chance of the user > - * doing s

Re: [PATCH 09/14] m68k: drop custom __access_ok()

2022-02-14 Thread Al Viro
On Mon, Feb 14, 2022 at 05:34:47PM +0100, Arnd Bergmann wrote: > From: Arnd Bergmann > > While most m68k platforms use separate address spaces for user > and kernel space, at least coldfire does not, and the other > ones have a TASK_SIZE that is less than the entire 4GB address > range. > > Usin

Re: [PATCH 05/14] uaccess: add generic __{get,put}_kernel_nofault

2022-02-14 Thread Al Viro
On Mon, Feb 14, 2022 at 05:34:43PM +0100, Arnd Bergmann wrote: > From: Arnd Bergmann > > All architectures that don't provide __{get,put}_kernel_nofault() yet > can implement this on top of __{get,put}_user. > > Add a generic version that lets everything use the normal > copy_{from,to}_kernel_no

RE: [PATCH 04/14] x86: use more conventional access_ok() definition

2022-02-14 Thread David Laight
From: Linus Torvalds > Sent: 14 February 2022 20:24 > > > > x86-64 has always(*) used TASK_SIZE_MAX for access_ok(), and the > > get_user() assembler implementation does the same. > > Side note: we could just check the sign bit instead, and avoid big > constants that way. The cheap test for most

Re: [PATCH 08/14] arm64: simplify access_ok()

2022-02-14 Thread Robin Murphy
On 2022-02-14 16:34, Arnd Bergmann wrote: From: Arnd Bergmann arm64 has an inline asm implementation of access_ok() that is derived from the 32-bit arm version and optimized for the case that both the limit and the size are variable. With set_fs() gone, the limit is always constant, and the siz

Re: [PATCH 04/14] x86: use more conventional access_ok() definition

2022-02-14 Thread Linus Torvalds
On Mon, Feb 14, 2022 at 12:01 PM Linus Torvalds wrote: > > x86-64 has always(*) used TASK_SIZE_MAX for access_ok(), and the > get_user() assembler implementation does the same. Side note: we could just check the sign bit instead, and avoid big constants that way. Right now we actually have this

Re: [PATCH 04/14] x86: use more conventional access_ok() definition

2022-02-14 Thread Al Viro
On Mon, Feb 14, 2022 at 12:01:05PM -0800, Linus Torvalds wrote: > On Mon, Feb 14, 2022 at 11:46 AM Arnd Bergmann wrote: > > > > As Al pointed out, they turned out to be necessary on sparc64, but the only > > definitions are on sparc64 and x86, so it's possible that they serve a > > similar > > pu

Re: [PATCH 04/14] x86: use more conventional access_ok() definition

2022-02-14 Thread Linus Torvalds
On Mon, Feb 14, 2022 at 11:46 AM Arnd Bergmann wrote: > > As Al pointed out, they turned out to be necessary on sparc64, but the only > definitions are on sparc64 and x86, so it's possible that they serve a similar > purpose here, in which case changing the limit from TASK_SIZE to > TASK_SIZE_MAX

Re: [PATCH 04/14] x86: use more conventional access_ok() definition

2022-02-14 Thread Christoph Hellwig
On Mon, Feb 14, 2022 at 08:45:52PM +0100, Arnd Bergmann wrote: > As Al pointed out, they turned out to be necessary on sparc64, but the only > definitions are on sparc64 and x86, so it's possible that they serve a similar > purpose here, in which case changing the limit from TASK_SIZE to > TASK_SIZ

Re: [PATCH 04/14] x86: use more conventional access_ok() definition

2022-02-14 Thread Arnd Bergmann
On Mon, Feb 14, 2022 at 6:02 PM Christoph Hellwig wrote: > > On Mon, Feb 14, 2022 at 05:34:42PM +0100, Arnd Bergmann wrote: > > +#define __range_not_ok(addr, size, limit)(!__access_ok(addr, size)) > > +#define __chk_range_not_ok(addr, size, limit)(!__access_ok((void > > __user *)addr,

Re: [PATCH 10/14] uaccess: remove most CONFIG_SET_FS users

2022-02-14 Thread Arnd Bergmann
On Mon, Feb 14, 2022 at 6:06 PM Christoph Hellwig wrote: > > On Mon, Feb 14, 2022 at 05:34:48PM +0100, Arnd Bergmann wrote: > > From: Arnd Bergmann > > > > On almost all architectures, there are no remaining callers > > of set_fs(), so CONFIG_SET_FS can be disabled, along with > > removing the th

Re: [PATCH 07/14] uaccess: generalize access_ok()

2022-02-14 Thread Arnd Bergmann
On Mon, Feb 14, 2022 at 6:15 PM Al Viro wrote: > > On Mon, Feb 14, 2022 at 05:34:45PM +0100, Arnd Bergmann wrote: > > > diff --git a/arch/csky/kernel/signal.c b/arch/csky/kernel/signal.c > > index c7b763d2f526..8867ddf3e6c7 100644 > > --- a/arch/csky/kernel/signal.c > > +++ b/arch/csky/kernel/sign

Re: [PATCH 00/14] clean up asm/uaccess.h, kill set_fs for good

2022-02-14 Thread Linus Torvalds
On Mon, Feb 14, 2022 at 8:35 AM Arnd Bergmann wrote: > > I did a patch for microblaze at some point, which turned out to be fairly > generic, and now ported it to most other architectures, using new generic > implementations of access_ok() and __{get,put}_kernel_nocheck(). Thanks for doing this.

Re: [PATCH 07/14] uaccess: generalize access_ok()

2022-02-14 Thread Al Viro
On Mon, Feb 14, 2022 at 05:34:45PM +0100, Arnd Bergmann wrote: > diff --git a/arch/csky/kernel/signal.c b/arch/csky/kernel/signal.c > index c7b763d2f526..8867ddf3e6c7 100644 > --- a/arch/csky/kernel/signal.c > +++ b/arch/csky/kernel/signal.c > @@ -136,7 +136,7 @@ static inline void __user *get_sig

RE: [PATCH 03/14] nds32: fix access_ok() checks in get/put_user

2022-02-14 Thread David Laight
From: Christoph Hellwig > Sent: 14 February 2022 17:01 > > On Mon, Feb 14, 2022 at 05:34:41PM +0100, Arnd Bergmann wrote: > > From: Arnd Bergmann > > > > The get_user()/put_user() functions are meant to check for > > access_ok(), while the __get_user()/__put_user() functions > > don't. > > > > Th

Re: [PATCH 11/14] sparc64: remove CONFIG_SET_FS support

2022-02-14 Thread Christoph Hellwig
> void prom_world(int enter) > { > - if (!enter) > - set_fs(get_fs()); > - > __asm__ __volatile__("flushw"); > } The enter argument is now unused. ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.i

Re: [PATCH 10/14] uaccess: remove most CONFIG_SET_FS users

2022-02-14 Thread Christoph Hellwig
On Mon, Feb 14, 2022 at 05:34:48PM +0100, Arnd Bergmann wrote: > From: Arnd Bergmann > > On almost all architectures, there are no remaining callers > of set_fs(), so CONFIG_SET_FS can be disabled, along with > removing the thread_info field and any references to it. > > This turns access_ok() i

Re: [PATCH 07/14] uaccess: generalize access_ok()

2022-02-14 Thread Christoph Hellwig
Looks good, Reviewed-by: Christoph Hellwig ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc

Re: [PATCH 05/14] uaccess: add generic __{get,put}_kernel_nofault

2022-02-14 Thread Christoph Hellwig
Looks good, Reviewed-by: Christoph Hellwig ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc

Re: [PATCH 04/14] x86: use more conventional access_ok() definition

2022-02-14 Thread Christoph Hellwig
On Mon, Feb 14, 2022 at 05:34:42PM +0100, Arnd Bergmann wrote: > +#define __range_not_ok(addr, size, limit)(!__access_ok(addr, size)) > +#define __chk_range_not_ok(addr, size, limit)(!__access_ok((void > __user *)addr, size)) Can we just kill these off insted of letting themm obsfucat

Re: [PATCH 03/14] nds32: fix access_ok() checks in get/put_user

2022-02-14 Thread Christoph Hellwig
On Mon, Feb 14, 2022 at 05:34:41PM +0100, Arnd Bergmann wrote: > From: Arnd Bergmann > > The get_user()/put_user() functions are meant to check for > access_ok(), while the __get_user()/__put_user() functions > don't. > > This broke in 4.19 for nds32, when it gained an extraneous > check in __ge

Re: [PATCH 01/14] uaccess: fix integer overflow on access_ok()

2022-02-14 Thread Christoph Hellwig
Looks good, Reviewed-by: Christoph Hellwig ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc

[PATCH 14/14] uaccess: drop set_fs leftovers

2022-02-14 Thread Arnd Bergmann
From: Arnd Bergmann There are no more users of CONFIG_SET_FS left, so drop all remaining references to set_fs()/get_fs(), mm_segment_t and uaccess_kernel(). Signed-off-by: Arnd Bergmann --- arch/Kconfig | 3 --- arch/arm/lib/uaccess_with_memcpy.c | 10 - arch/nds

[PATCH 13/14] ia64: remove CONFIG_SET_FS support

2022-02-14 Thread Arnd Bergmann
From: Arnd Bergmann ia64 only uses set_fs() in one file to handle unaligned access for both user space and kernel instructions. Rewrite this to explicitly pass around a flag about which one it is and drop the feature from the architecture. Signed-off-by: Arnd Bergmann --- arch/ia64/Kconfig

[PATCH 12/14] sh: remove CONFIG_SET_FS support

2022-02-14 Thread Arnd Bergmann
From: Arnd Bergmann sh uses set_fs/get_fs only in one file, to handle address errors in both user and kernel memory. It already has an abstraction to differentiate between I/O and memory, so adding a third class for kernel memory fits into the same scheme and lets us kill off CONFIG_SET_FS. Sig

[PATCH 11/14] sparc64: remove CONFIG_SET_FS support

2022-02-14 Thread Arnd Bergmann
From: Arnd Bergmann sparc64 uses address space identifiers to differentiate between kernel and user space, using ASI_P for kernel threads but ASI_AIUS for normal user space, with the option of changing between them. As nothing really changes the ASI any more, just hardcode ASI_AIUS everywhere. K

[PATCH 10/14] uaccess: remove most CONFIG_SET_FS users

2022-02-14 Thread Arnd Bergmann
From: Arnd Bergmann On almost all architectures, there are no remaining callers of set_fs(), so CONFIG_SET_FS can be disabled, along with removing the thread_info field and any references to it. This turns access_ok() into a cheaper check against TASK_SIZE_MAX. Signed-off-by: Arnd Bergmann ---

[PATCH 09/14] m68k: drop custom __access_ok()

2022-02-14 Thread Arnd Bergmann
From: Arnd Bergmann While most m68k platforms use separate address spaces for user and kernel space, at least coldfire does not, and the other ones have a TASK_SIZE that is less than the entire 4GB address range. Using the generic implementation of __access_ok() stops coldfire user space from tr

[PATCH 08/14] arm64: simplify access_ok()

2022-02-14 Thread Arnd Bergmann
From: Arnd Bergmann arm64 has an inline asm implementation of access_ok() that is derived from the 32-bit arm version and optimized for the case that both the limit and the size are variable. With set_fs() gone, the limit is always constant, and the size usually is as well, so just using the defa

[PATCH 07/14] uaccess: generalize access_ok()

2022-02-14 Thread Arnd Bergmann
From: Arnd Bergmann There are many different ways that access_ok() is defined across architectures, but in the end, they all just compare against the user_addr_max() value or they accept anything. Provide one definition that works for most architectures, checking against TASK_SIZE_MAX for user p

[PATCH 06/14] mips: use simpler access_ok()

2022-02-14 Thread Arnd Bergmann
From: Arnd Bergmann Before unifying the mips version of __access_ok() with the generic code, this converts it to the same algorithm. This is a change in behavior on mips64, as now address in the user segment, the lower 2^62 bytes, is taken to be valid, relying on a page fault for addresses that a

[PATCH 05/14] uaccess: add generic __{get,put}_kernel_nofault

2022-02-14 Thread Arnd Bergmann
From: Arnd Bergmann All architectures that don't provide __{get,put}_kernel_nofault() yet can implement this on top of __{get,put}_user. Add a generic version that lets everything use the normal copy_{from,to}_kernel_nofault() code based on these, removing the last use of get_fs()/set_fs() from

[PATCH 04/14] x86: use more conventional access_ok() definition

2022-02-14 Thread Arnd Bergmann
From: Arnd Bergmann The way that access_ok() is defined on x86 is slightly different from most other architectures, and a bit more complex. The generic version tends to result in the best output on all architectures, as it results in single comparison against a constant limit for calls with a kn

[PATCH 03/14] nds32: fix access_ok() checks in get/put_user

2022-02-14 Thread Arnd Bergmann
From: Arnd Bergmann The get_user()/put_user() functions are meant to check for access_ok(), while the __get_user()/__put_user() functions don't. This broke in 4.19 for nds32, when it gained an extraneous check in __get_user(), but lost the check it needs in __put_user(). Fixes: 487913ab18c2 ("n

[PATCH 02/14] sparc64: add __{get,put}_kernel_nocheck()

2022-02-14 Thread Arnd Bergmann
From: Arnd Bergmann sparc64 is one of the architectures that uses separate address spaces for kernel and user addresses, so __get_kernel_nofault() can not just call into the normal __get_user() without the access_ok() check. Instead duplicate __get_user() and __put_user() into their in-kernel ve

[PATCH 01/14] uaccess: fix integer overflow on access_ok()

2022-02-14 Thread Arnd Bergmann
From: Arnd Bergmann Three architectures check the end of a user access against the address limit without taking a possible overflow into account. Passing a negative length or another overflow in here returns success when it should not. Use the most common correct implementation here, which optim

[PATCH 00/14] clean up asm/uaccess.h, kill set_fs for good

2022-02-14 Thread Arnd Bergmann
From: Arnd Bergmann Christoph Hellwig and a few others spent a huge effort on removing set_fs() from most of the important architectures, but about half the other architectures were never completed even though most of them don't actually use set_fs() at all. I did a patch for microblaze at some