From: Johannes Berg <johannes@sipsolutions.net>
To: David Gow <davidgow@google.com>,
Benjamin Berg <benjamin@sipsolutions.net>
Cc: linux-um@lists.infradead.org,
Benjamin Berg <benjamin.berg@intel.com>,
KUnit Development <kunit-dev@googlegroups.com>,
Kees Cook <kees@kernel.org>
Subject: Re: [PATCH v9 02/10] um: use execveat to create userspace MMs
Date: Thu, 17 Oct 2024 10:18:27 +0200 [thread overview]
Message-ID: <49ef8267b4c2cbce11698a377330d92327b332d3.camel@sipsolutions.net> (raw)
In-Reply-To: <CABVgOS=boUoG6=LHFFhxEd8H8jDP1zOaPKFEjH+iy2n2Q5S2aQ@mail.gmail.com>
On Thu, 2024-10-17 at 15:17 +0800, David Gow wrote:
> It turns out that this breaks the KUnit user alloc helpers on x86_64,
> at least on my machine.
Yay, second bug from this ;-)
> This can be reproduced with:
> ./tools/testing/kunit/kunit.py run usercopy
>
> Though the 32-bit version works:
> ./tools/testing/kunit/kunit.py run usercopy --kconfig_add CONFIG_64BIT=n
>
> The error we're getting is:
> start_userspace : expected SIGSTOP, got status = 139
> Could not create userspace mm
>
> This basically is the result of the stub_exe segfaulting very early on
> in its execution.
>
> It seems that this is due to the stack being misaligned, and so the
> generated SSE instructions are faulting. The workarounds I've tested
> here include:
> a) Build the stub with -mno-sse
> b) Decorate real_init() with __attribute__((force_align_arg_pointer))
> c) Decorate __start() with __attribute__((naked))
>
> The last one seems to validate my theory as to why this is occurring:
> __start's prologue is misaligning the stack, as __start is not
> actually _called_ from anything, so there's no 8-byte misalignment to
> hold the return address.
>
> If this makes sense, I'll send a patch out with whichever the
> preferred fix(es) are. My guess is that (c) is the "proper" fix,
> though I'd not _miss_ SSE if we chose to disable it for the handful of
> instructions here anyway.
Interesting. Actually somewhere here while reviewing this, though I
don't remember precisely if it was _start, I thought we might need
__attribute__((naked)) to ensure we don't get extra things, but I let
that thought go since it seemed to work and I didn't wrap my head around
it too much...
I wonder now if the SSE instructions generated are memset() and that
goes away with the patches that Nathan just sent to not have the memset
(which was due to -ftrivial-auto-var-init) in the first place?
But anyway all of these pretty much sound reasonable. We don't need much
to happen in the stub here, simpler is better.
johannes
next prev parent reply other threads:[~2024-10-17 8:18 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-19 12:45 [PATCH v9 00/10] Increased address space for 64 bit Benjamin Berg
2024-09-19 12:45 ` [PATCH v9 01/10] um: Add generic stub_syscall1 function Benjamin Berg
2024-09-19 12:45 ` [PATCH v9 02/10] um: use execveat to create userspace MMs Benjamin Berg
2024-10-16 2:34 ` Nathan Chancellor
2024-10-16 8:19 ` Berg, Benjamin
2024-10-17 7:17 ` David Gow
2024-10-17 8:18 ` Johannes Berg [this message]
2024-10-17 12:05 ` Benjamin Berg
2024-10-17 23:17 ` David Gow
2024-10-17 9:01 ` Benjamin Berg
2024-09-19 12:45 ` [PATCH v9 03/10] um: Set parent death signal for userspace process Benjamin Berg
2024-09-19 12:45 ` [PATCH v9 04/10] um: Set parent death signal for winch thread/process Benjamin Berg
2024-09-19 12:45 ` [PATCH v9 05/10] um: Add compile time assert that stub fits on a page Benjamin Berg
2024-09-19 12:45 ` [PATCH v9 06/10] um: Calculate stub data address relative to stub code Benjamin Berg
2024-09-19 12:45 ` [PATCH v9 07/10] um: Limit TASK_SIZE to the addressable range Benjamin Berg
2024-09-19 12:45 ` [PATCH v9 08/10] um: Discover host_task_size from envp Benjamin Berg
2024-09-19 12:45 ` [PATCH v9 09/10] um: clear all memory in new userspace processes Benjamin Berg
2024-09-19 12:45 ` [PATCH v9 10/10] um: Switch to 4 level page tables on 64 bit Benjamin Berg
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=49ef8267b4c2cbce11698a377330d92327b332d3.camel@sipsolutions.net \
--to=johannes@sipsolutions.net \
--cc=benjamin.berg@intel.com \
--cc=benjamin@sipsolutions.net \
--cc=davidgow@google.com \
--cc=kees@kernel.org \
--cc=kunit-dev@googlegroups.com \
--cc=linux-um@lists.infradead.org \
/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