Re: [PATCH] ARC: uaccess: get_user to zero out dest in cause of fault

2016-08-22 Thread Al Viro
On Mon, Aug 22, 2016 at 04:48:00PM -0700, Linus Torvalds wrote: > On Mon, Aug 22, 2016 at 4:12 PM, H. Peter Anvin wrote: > > > > How about the gcc native __builtin_setjmp stuff which is supposedly better? > > How new is it? The whole point was that we'd not have to worry and > wait for gcc featur

Re: [PATCH] ARC: uaccess: get_user to zero out dest in cause of fault

2016-08-22 Thread H. Peter Anvin
On August 22, 2016 4:57:10 PM PDT, David Miller wrote: >From: Linus Torvalds >Date: Mon, 22 Aug 2016 16:48:00 -0700 > >> How new is it? The whole point was that we'd not have to worry and >> wait for gcc features.. > >It's been around for a long time. > >I'd say at least gcc-3.0 and later support

Re: [PATCH] ARC: uaccess: get_user to zero out dest in cause of fault

2016-08-22 Thread David Miller
From: Linus Torvalds Date: Mon, 22 Aug 2016 16:48:00 -0700 > How new is it? The whole point was that we'd not have to worry and > wait for gcc features.. It's been around for a long time. I'd say at least gcc-3.0 and later support it.

Re: [PATCH] ARC: uaccess: get_user to zero out dest in cause of fault

2016-08-22 Thread H. Peter Anvin
On August 22, 2016 4:48:00 PM PDT, Linus Torvalds wrote: >On Mon, Aug 22, 2016 at 4:12 PM, H. Peter Anvin wrote: >> >> How about the gcc native __builtin_setjmp stuff which is supposedly >better? > >How new is it? The whole point was that we'd not have to worry and >wait for gcc features.. > >gl

Re: [PATCH] ARC: uaccess: get_user to zero out dest in cause of fault

2016-08-22 Thread Linus Torvalds
On Mon, Aug 22, 2016 at 4:12 PM, H. Peter Anvin wrote: > > How about the gcc native __builtin_setjmp stuff which is supposedly better? How new is it? The whole point was that we'd not have to worry and wait for gcc features.. glibc doesn't use it, which worries me a bit. Has it ever gotten any u

Re: [PATCH] ARC: uaccess: get_user to zero out dest in cause of fault

2016-08-22 Thread H. Peter Anvin
On August 22, 2016 3:23:06 PM PDT, Linus Torvalds wrote: >On Sun, Aug 21, 2016 at 10:52 AM, Linus Torvalds > wrote: >> On Sat, Aug 20, 2016 at 11:42 PM, Al Viro >wrote: >>> >>> It's not exactly setjmp/longjmp; what I had in mind was along the >lines of >> >> That ends up having all the exact sam

Re: [PATCH] ARC: uaccess: get_user to zero out dest in cause of fault

2016-08-22 Thread H. Peter Anvin
On August 22, 2016 3:23:06 PM PDT, Linus Torvalds wrote: >On Sun, Aug 21, 2016 at 10:52 AM, Linus Torvalds > wrote: >> On Sat, Aug 20, 2016 at 11:42 PM, Al Viro >wrote: >>> >>> It's not exactly setjmp/longjmp; what I had in mind was along the >lines of >> >> That ends up having all the exact sam

Re: [PATCH] ARC: uaccess: get_user to zero out dest in cause of fault

2016-08-22 Thread Linus Torvalds
On Sun, Aug 21, 2016 at 10:52 AM, Linus Torvalds wrote: > On Sat, Aug 20, 2016 at 11:42 PM, Al Viro wrote: >> >> It's not exactly setjmp/longjmp; what I had in mind was along the lines of > > That ends up having all the exact same issues as setjmp, and generally > you *do* want the compiler to kn

Re: [PATCH] ARC: uaccess: get_user to zero out dest in cause of fault

2016-08-21 Thread Linus Torvalds
On Sat, Aug 20, 2016 at 11:42 PM, Al Viro wrote: > > It's not exactly setjmp/longjmp; what I had in mind was along the lines of That ends up having all the exact same issues as setjmp, and generally you *do* want the compiler to know about it. For example, let's say that you have something like

Re: [PATCH] ARC: uaccess: get_user to zero out dest in cause of fault

2016-08-20 Thread Al Viro
On Sun, Aug 21, 2016 at 06:54:02AM +0200, Jakub Jelinek wrote: > On Sat, Aug 20, 2016 at 05:45:00PM -0700, Linus Torvalds wrote: > If you plan to use setjmp/longjmp a lot, then it is certainly a major > performance and compile time/memory problem. > Older versions don't model it properly, and newe

Re: [PATCH] ARC: uaccess: get_user to zero out dest in cause of fault

2016-08-20 Thread Jakub Jelinek
On Sat, Aug 20, 2016 at 05:45:00PM -0700, Linus Torvalds wrote: > You have to save the stack pointer at the setjmp point too. And there > might be other architecture-specific ABI rules for that. But you're > right, it might be worth it. > > I *would* be a bit worried about code generation issues.

Re: [PATCH] ARC: uaccess: get_user to zero out dest in cause of fault

2016-08-20 Thread Al Viro
On Sat, Aug 20, 2016 at 06:09:15PM -0700, H. Peter Anvin wrote: > >Sorry for the bogus noise. I don't know why I was so convinced setjmp > >needed special gcc semantics. > > > > Linus > > I think the specific name setjmp() is magic in gcc. It is; attribute equivalent is returns_twice

Re: [PATCH] ARC: uaccess: get_user to zero out dest in cause of fault

2016-08-20 Thread H. Peter Anvin
On August 20, 2016 6:00:17 PM PDT, Linus Torvalds wrote: >On Sat, Aug 20, 2016 at 5:45 PM, Linus Torvalds > wrote: >> >> So I slightly considered it, because gcc actually has support for >that >> kind of behavior thanks to setjmp/longjmp (and yes, the compiler >> actually needs to know about the

Re: [PATCH] ARC: uaccess: get_user to zero out dest in cause of fault

2016-08-20 Thread Linus Torvalds
On Sat, Aug 20, 2016 at 5:45 PM, Linus Torvalds wrote: > > So I slightly considered it, because gcc actually has support for that > kind of behavior thanks to setjmp/longjmp (and yes, the compiler > actually needs to know about the magic "this code can be entered a > second time from elsewhere" -

Re: [PATCH] ARC: uaccess: get_user to zero out dest in cause of fault

2016-08-20 Thread Linus Torvalds
On Sat, Aug 20, 2016 at 5:11 PM, Al Viro wrote: > > Interesting... BTW, how's this in the "really vile tricks" department? > > if (!uaccess_begin()) > goto fail; So I slightly considered it, because gcc actually has support for that kind of behavior thanks to setjmp/longj

Re: [PATCH] ARC: uaccess: get_user to zero out dest in cause of fault

2016-08-20 Thread Al Viro
On Sat, Aug 20, 2016 at 04:32:57PM -0700, Linus Torvalds wrote: > Anyway, the asm coming out of gcc looks nasty, because it has all the > ugly section stuiff and fixups for SMAP not existing on some CPU's > etc. So the resulting fs/readdir.s file is hard to read. But if you > look at the disassemb

Re: [PATCH] ARC: uaccess: get_user to zero out dest in cause of fault

2016-08-20 Thread Linus Torvalds
On Fri, Aug 19, 2016 at 3:11 PM, Linus Torvalds wrote: >> >> (I have some experimental patches that actually use "asm goto" in >> "unsafe_put_user()" to get that nice code generation, but they only >> work if your gcc version supports "asm goto", which some older >> versions of gcc does not) > > S

Re: [PATCH] ARC: uaccess: get_user to zero out dest in cause of fault

2016-08-19 Thread Linus Torvalds
On Fri, Aug 19, 2016 at 3:00 PM, Linus Torvalds wrote: > > (I have some experimental patches that actually use "asm goto" in > "unsafe_put_user()" to get that nice code generation, but they only > work if your gcc version supports "asm goto", which some older > versions of gcc does not) Since you

Re: [PATCH] ARC: uaccess: get_user to zero out dest in cause of fault

2016-08-19 Thread Linus Torvalds
On Fri, Aug 19, 2016 at 2:24 PM, Al Viro wrote: > * x86-only get_user_ex(). Does *not* return anything, uses > per-process > flag to indicate errors, the entire sequence is bracketed by uaccess_try() > and uaccess_catch(err), the latter dumps the flag into err. I really don't want peopl

Re: [PATCH] ARC: uaccess: get_user to zero out dest in cause of fault

2016-08-19 Thread Al Viro
On Fri, Aug 19, 2016 at 12:10:02PM -0700, Vineet Gupta wrote: > Al reported potential issue with ARC get_user() as it wasn't clearing > out destination pointer in case of fault due to bad address etc. Applied to my branch with other similar fixes. FWIW, there's another interesting question in the

[PATCH] ARC: uaccess: get_user to zero out dest in cause of fault

2016-08-19 Thread Vineet Gupta
Al reported potential issue with ARC get_user() as it wasn't clearing out destination pointer in case of fault due to bad address etc. Verified using following | { | u32 bogus1 = 0xdeadbeef; | u64 bogus2 = 0xdead; | int rc1, rc2; | | pr_info("Orig values %x %llx\n", bogus1