[PATCH] aarch64, libgcc: Fix unwinding from pac-ret to normal frames [PR94514]

Christophe Lyon christophe.lyon@linaro.org
Wed Apr 22 13:22:36 GMT 2020


Hi,


On Tue, 21 Apr 2020 at 18:52, Szabolcs Nagy <Szabolcs.Nagy@arm.com> wrote:
>
> The 04/17/2020 11:05, Kyrylo Tkachov wrote:
> > Hi Szabolcs,
> >
> > > -----Original Message-----
> > > From: Szabolcs Nagy <Szabolcs.Nagy@arm.com>
> > > Sent: 09 April 2020 15:20
> > > To: gcc-patches@gcc.gnu.org
> > > Cc: Richard Earnshaw <Richard.Earnshaw@arm.com>; Richard Sandiford
> > > <Richard.Sandiford@arm.com>; Kyrylo Tkachov <Kyrylo.Tkachov@arm.com>
> > > Subject: [PATCH] aarch64, libgcc: Fix unwinding from pac-ret to normal
> > > frames [PR94514]
> > >
> > > With -mbranch-protection=pac-ret the debug info toggles the
> > > signedness state of the return address so the unwinder knows when
> > > the return address needs pointer authentication.
> > >
> > > The unwind context flags were not updated according to the dwarf
> > > frame info.
> > >
> > > This causes unwinding across frames that were built without pac-ret
> > > to incorrectly authenticate the return address wich corrupts the
> > > return address on a system where PAuth is enabled.
> > >
> > > Note: This even affects systems where all code use pac-ret because
> > > unwinding across a signal frame the return address is not signed.
> > >
> >
> > Ok, I'm guessing this needs backporting?
>
> committed now,
>
> yes i think it has to go back to gcc-9 and gcc-8,
> i will do that later. thanks.

The new test fails with ilp32, not sure if that's supposed to work?

FAIL: gcc.target/aarch64/pr94514.c (test for excess errors)
Excess errors:
/gcc/testsuite/gcc.target/aarch64/pr94514.c:27:4: warning: cast to
pointer from integer of different size [-Wint-to-pointer-cast]

spawn /aci-gcc-fsf/builds/gcc-fsf-gccsrc/tools/aarch64-none-elf/invoke-foundation-v8-bare-metal.sh
./pr94514.exe
force_unwind_stop: CFA: 0xefffff80 PC: 0x80001304 actions: 10
force_unwind_stop: CFA: 0xefffff90 PC: 0x8000133c actions: 10
Terminated by exception.

*** EXIT code 126
gcc.target/aarch64/pr94514.c execution test (reason: TCL LOOKUP CHANNEL exp7)
FAIL: gcc.target/aarch64/pr94514.c execution test

(executed using the Foundation Model)


The C++ test compiles without warnings, but fails at execution too
(without the force_unwind_stop traces):
PASS: g++.target/aarch64/pr94514.C (test for excess errors)
spawn /aci-gcc-fsf/builds/gcc-fsf-gccsrc/tools/aarch64-none-elf/invoke-foundation-v8-bare-metal.sh
./pr94514.exe
Terminated by exception.

*** EXIT code 126
g++.target/aarch64/pr94514.C execution test (reason: TCL LOOKUP CHANNEL exp7)
FAIL: g++.target/aarch64/pr94514.C execution test

Maybe you just want to skip the test for ilp32?

Thanks,

Christophe


More information about the Gcc-patches mailing list