memcpy is leaking secret data through ZMM vector registers
H.J. Lu
hjl.tools@gmail.com
Fri Apr 19 14:37:19 GMT 2024
On Fri, Apr 19, 2024 at 7:24 AM Mikulas Patocka <mpatocka@redhat.com> wrote:
>
>
>
> On Fri, 19 Apr 2024, H.J. Lu wrote:
>
> > On Fri, Apr 19, 2024 at 7:08 AM Mikulas Patocka <mpatocka@redhat.com> wrote:
> > >
> > > I'd like to ask what to do with it? We could use LD_BIND_NOW=1 (or
> > > -Wl,-z,now) - it mostly works, but not entirely - the key may still be
> > > present on the stack even if we use LD_BIND_NOW=1.
> >
> > Since vector registers are saved on stack only during symbol lookup,
> > shouldn't disabling lazy binding solve this issue?
>
> It should, but it doesn't fix this problem entirely.
>
> If I set "GLIBC_TUNABLES=glibc.cpu.hwcaps=-AVX512F,-AVX2" "LD_BIND_NOW=1",
> I still get a failure (I don't get the failure if I don't set
> GLIBC_TUNABLES and set only LD_BIND_NOW).
>
> So, even if we use plain SSE, the data somehow end up on the stack.
>
You should write your own memory copy function and compile it with
-fzero-call-used-regs if possible.
--
H.J.
More information about the Libc-alpha
mailing list