[PATCH v2] um: Fix stack pointer alignment

YiFei Zhu zhuyifei1999 at gmail.com
Tue Apr 20 06:47:27 BST 2021


On Mon, Apr 19, 2021 at 3:36 PM YiFei Zhu <zhuyifei1999 at gmail.com> wrote:
> > > To reproduce this bug, enable CONFIG_UML_RTC. uml_rtc will call
> > > add_sigio_fd which will then cause write_sigio_thread to go
> > > into segfault loop.
> >
> > It must also depend on the glibc version, because I've definitely been
> > testing UML_RTC on 64-bit, on Fedora 32 at the time.
> >
>
> Hmm. Interesting. I can't seem to find anything suggesting Fedora has
> a patch that would align the stack within clone() [3][4]. I also got a
> Fedora 32 docker image and could not see the aligning from disassembly
> of clone, and the gcc version installed by yum is 10.2.1-9.fc32, which
> is supposed to be affected by this issue... weird. I would expect this
> to fail outright. I'm considering compiling uml inside this container
> to see what is going on.

It seems config related. I tested with my original config and it
segfault loops, but then I tested with a fresh defconfig, then enabled
RTC_CLASS and UML_RTC and it boots successfully, with the assembly as:

  movaps (%rdx),%xmm0
  movaps %xmm0,(%r12)

The move from xmm0 to stack is omitted.

After a bit of trial and error I found changing from
CC_OPTIMIZE_FOR_SIZE to CC_OPTIMIZE_FOR_PERFORMANCE alone makes the
difference. What's also interesting is that instead of
segfault-looping (as in, segfault recovery did not do anything to fix
the fault, so after sigreturn it segfaults again), it panics with
"Segfault with no mm" which seems more like the expected behavior.

I'll send a v3 to clarify CC_OPTIMIZE_FOR_PERFORMANCE.

YiFei Zhu



More information about the linux-um mailing list