This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: i386: Lazy binding trampoline and vector register usage
- From: Szabolcs Nagy <Szabolcs dot Nagy at arm dot com>
- To: Florian Weimer <fweimer at redhat dot com>, "H.J. Lu" <hjl dot tools at gmail dot com>
- Cc: nd <nd at arm dot com>, "libc-alpha at sourceware dot org" <libc-alpha at sourceware dot org>
- Date: Thu, 9 Jan 2020 10:49:26 +0000
- Subject: Re: i386: Lazy binding trampoline and vector register usage
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=k946EJVtRiQX4Mo9BK6WpMAZ3gfZK86uppmJ+5mrgkg=; b=dSuyL1BdnDqateoIaIP8TK8uj/3mS4eQd8ChZPytFFQICMufTL5EOvDZnZHB4GnnD4fSe5SI4hwnS1T/TMOU+jy2m64W/o8rhRj1PF8M0aO0BayC/jRENixjtmRDTOHOSaA4gp32+Z8DhMcDg+1oSZgZLlCg6oPchlUaDxyz1hQGziwT2b42AzX/FG5QJu+8P3+OLCgjR8fxx4PHbunCyk/qxjLVI8tGeOma7T4SvIiRf00GFOU4T2I+TT2ha08mPju1d+FtkvyCSYL+WasVwznd5OIuVZk/635u/bIBO4CwAqZhHums/z9vF4/hRuTRh6b89cXCFsEG2SVwyqwPjQ==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SSg1yBOdNz0WdTLWbUU9dom6eoBYiCGT35j6mceB3jQmPkUhwl94MbKKfeSCKqC9cyQPtEG4bDSG0ldmn5iwRW3H7dwM9ddT2lDyedZ3f14lG4x26XvNzntMfBBWra2n9RIcXhzucXR/okYKbfF+6xFWgGr7d+x9YvGaZt5xla0043AoQ374/BqWDaFmh2kX4g/FC2eo3J5wbmY+YZugBdBhiNzJGleVMLt73Kaqv+8DsY6DKu4Dl/o+LUqw9bhWxs8up+QgRNaTmDqvhXRlz2AXo4rlEtfTsWN32CQ9UFFTuVjlHjcRJ3eUmvwTWM1duKNa0PSHFqNZ7vMvART5ZQ==
- Original-authentication-results: spf=none (sender IP is ) smtp.mailfrom=Szabolcs dot Nagy at arm dot com;
- References: <87lfra2as7.fsf@oldenburg2.str.redhat.com>
On 18/12/2019 10:22, Florian Weimer wrote:
> We have this in sysdeps/i386/Makefile:
>
> # Make sure no code in ld.so uses mm/xmm/ymm/zmm registers on i386 since
> # the first 3 mm/xmm/ymm/zmm registers are used to pass vector parameters
> # which must be preserved.
> # With SSE disabled, ensure -fpmath is not set to use sse either.
> rtld-CFLAGS += -mno-sse -mno-mmx -mfpmath=387
> ifeq ($(subdir),elf)
> CFLAGS-.os += $(if $(filter $(@F),$(patsubst %,%.os,$(all-rtld-routines))),\
> $(rtld-CFLAGS))
>
> tests-special += $(objpfx)tst-ld-sse-use.out
> $(objpfx)tst-ld-sse-use.out: ../sysdeps/i386/tst-ld-sse-use.sh $(objpfx)ld.so
> @echo "Checking ld.so for SSE register use. This will take a few seconds..."
> $(BASH) $< $(objpfx) '$(NM)' '$(OBJDUMP)' '$(READELF)' > $@; \
> $(evaluate-test)
> else
> CFLAGS-.os += $(if $(filter rtld-%.os,$(@F)), $(rtld-CFLAGS))
> endif
>
> The idea is that we do not need to save and restore vector registers in
> the trampoline (or align the stack) if we compile ld.so in such a way
> that only general registers are used. But that does not actually work
> in all cases because lazy binding can call malloc, which lives in
> libc.so or might even be interposed, and is thus free to use vector
> registers.
>
> What should we do about this? Calling malloc from _dl_fixup is unsafe
> for other reasons because lazy binding can happen in signal handlers, so
> maybe this would be fixed if we switched to a non-interposable
> async-signal-safe allocator?
note that ifunc resolvers can also run during lazy binding
and those can execute arbitrary user code (even if the
allocator issue is fixed).