linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: "Sean Christopherson" <sean.j.christopherson@intel.com>,
	"Daniel Díaz" <daniel.diaz@linaro.org>,
	"Naresh Kamboju" <naresh.kamboju@linaro.org>,
	"Stephen Rothwell" <sfr@canb.auug.org.au>,
	"Matthew Wilcox (Oracle)" <willy@infradead.org>,
	zenglg.jy@cn.fujitsu.com,
	"Peter Zijlstra (Intel)" <peterz@infradead.org>,
	"Viresh Kumar" <viresh.kumar@linaro.org>,
	"X86 ML" <x86@kernel.org>,
	"open list" <linux-kernel@vger.kernel.org>,
	lkft-triage@lists.linaro.org,
	"Eric W. Biederman" <ebiederm@xmission.com>,
	linux-mm <linux-mm@kvack.org>,
	linux-m68k <linux-m68k@lists.linux-m68k.org>,
	"Linux-Next Mailing List" <linux-next@vger.kernel.org>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	kasan-dev <kasan-dev@googlegroups.com>,
	"Dmitry Vyukov" <dvyukov@google.com>,
	"Geert Uytterhoeven" <geert@linux-m68k.org>,
	"Christian Brauner" <christian.brauner@ubuntu.com>,
	"Ingo Molnar" <mingo@redhat.com>, "LTP List" <ltp@lists.linux.it>,
	"Al Viro" <viro@zeniv.linux.org.uk>
Subject: Re: [LTP] mmstress[1309]: segfault at 7f3d71a36ee8 ip 00007f3d77132bdf sp 00007f3d71a36ee8 error 4 in libc-2.27.so[7f3d77058000+1aa000]
Date: Fri, 23 Oct 2020 09:32:54 -0700	[thread overview]
Message-ID: <CAHk-=whGbM1E0BbSVvxGRj5nBaNRXXD-oKcgrM40s4gvYV_C+w@mail.gmail.com> (raw)
In-Reply-To: <CAHk-=whFb3wk0ff8jb3BCyoNvNJ1TSZxoYRKaAoW=Y43iQFNkw@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1486 bytes --]

On Fri, Oct 23, 2020 at 8:54 AM Linus Torvalds
<torvalds@linux-foundation.org> wrote:
>
> On Fri, Oct 23, 2020 at 12:14 AM Rasmus Villemoes
> <linux@rasmusvillemoes.dk> wrote:
> >
> > That's certainly garbage. Now, I don't know if it's a sufficient fix (or
> > could break something else), but the obvious first step of rearranging
> > so that the ptr argument is evaluated before the assignment to __val_pu
>
> Ack. We could do that.
>
> I'm more inclined to just bite the bullet and go back to the ugly
> conditional on the size that I had hoped to avoid, but if that turns
> out too ugly, mind signing off on your patch and I'll have that as a
> fallback?

Actually, looking at that code, and the fact that we've used the
"register asm()" format forever for the get_user() side, I think your
approach is the right one.

I'd rename the internal ptr variable to "__ptr_pu", and make sure the
assignments happen just before the asm call (with the __val_pu
assignment being the final thing).

lso, it needs to be

        void __user *__ptr_pu;

instead of

        __typeof__(ptr) __ptr = (ptr);

because "ptr" may actually be an array, and we need to have the usual
C "array to pointer" conversions happen, rather than try to make
__ptr_pu be an array too.

So the patch would become something like the appended instead, but I'd
still like your sign-off (and I'd put you as author of the fix).

Narest, can you confirm that this patch fixes the issue for you?

                  Linus

[-- Attachment #2: patch --]
[-- Type: application/octet-stream, Size: 862 bytes --]

 arch/x86/include/asm/uaccess.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
index f13659523108..d006af915d4a 100644
--- a/arch/x86/include/asm/uaccess.h
+++ b/arch/x86/include/asm/uaccess.h
@@ -211,13 +211,15 @@ extern void __put_user_nocheck_8(void);
 #define do_put_user_call(fn,x,ptr)					\
 ({									\
 	int __ret_pu;							\
+	void __user *__ptr_pu;						\
 	register __typeof__(*(ptr)) __val_pu asm("%"_ASM_AX);		\
 	__chk_user_ptr(ptr);						\
+	__ptr_pu = (ptr);						\
 	__val_pu = (x);							\
 	asm volatile("call __" #fn "_%P[size]"				\
 		     : "=c" (__ret_pu),					\
 			ASM_CALL_CONSTRAINT				\
-		     : "0" (ptr),					\
+		     : "0" (__ptr_pu),					\
 		       "r" (__val_pu),					\
 		       [size] "i" (sizeof(*(ptr)))			\
 		     :"ebx");						\

  reply	other threads:[~2020-10-23 16:41 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-21 16:58 mmstress[1309]: segfault at 7f3d71a36ee8 ip 00007f3d77132bdf sp 00007f3d71a36ee8 error 4 in libc-2.27.so[7f3d77058000+1aa000] Naresh Kamboju
2020-10-21 17:05 ` Linus Torvalds
2020-10-21 17:22   ` Naresh Kamboju
2020-10-22 20:55     ` Naresh Kamboju
2020-10-22 23:43       ` Linus Torvalds
2020-10-23  0:11         ` Linus Torvalds
2020-10-23  0:22           ` Linus Torvalds
2020-10-23  1:36           ` [LTP] " Daniel Díaz
2020-10-23  3:05             ` Linus Torvalds
2020-10-23  5:02               ` Sean Christopherson
2020-10-23  7:14                 ` Rasmus Villemoes
2020-10-23 15:54                   ` Linus Torvalds
2020-10-23 16:32                     ` Linus Torvalds [this message]
2020-10-23 17:50                       ` Naresh Kamboju
2020-10-23 15:52                 ` Linus Torvalds
2020-10-23 17:00               ` Naresh Kamboju
2020-10-23 17:50                 ` Linus Torvalds
2020-10-23 21:15                   ` Song Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAHk-=whGbM1E0BbSVvxGRj5nBaNRXXD-oKcgrM40s4gvYV_C+w@mail.gmail.com' \
    --to=torvalds@linux-foundation.org \
    --cc=christian.brauner@ubuntu.com \
    --cc=daniel.diaz@linaro.org \
    --cc=dvyukov@google.com \
    --cc=ebiederm@xmission.com \
    --cc=geert@linux-m68k.org \
    --cc=kasan-dev@googlegroups.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-m68k@lists.linux-m68k.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-next@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=lkft-triage@lists.linaro.org \
    --cc=ltp@lists.linux.it \
    --cc=mingo@redhat.com \
    --cc=naresh.kamboju@linaro.org \
    --cc=peterz@infradead.org \
    --cc=sean.j.christopherson@intel.com \
    --cc=sfr@canb.auug.org.au \
    --cc=tglx@linutronix.de \
    --cc=viresh.kumar@linaro.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=willy@infradead.org \
    --cc=x86@kernel.org \
    --cc=zenglg.jy@cn.fujitsu.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).