freebsd-src/libexec
R. Christian McDonald 98fd69f009 rtld/arm: fix initial-exec (IE) thread-local storage relocation
net/frr[89] revealed an interesting edge-case on arm when dynamically
linking a shared library that declares more than one static TLS variable
with at least one  using the "initial-exec" TLS model. In the case
of frr[89], this library was libfrr.so which essentially does the
following:

	#include <stdio.h>

	#include "lib.h"

	static __thread int *a
		__attribute__((tls_model("initial-exec")));

	void lib_test()
	{
		static __thread int b = -1;

		printf("&a = %p\n", &a);
		printf(" a = %p\n", a);

		printf("\n");

		printf("&b = %p\n", &b);
		printf(" b = %d\n", b);
	}

Allocates a file scoped `static __thread` pointer with
tls_model("initial-exec") and later a block scoped TLS int. Notice in
the above minimal reproducer, `b == -1`. The relocation process does
the wrong thing and ends up pointing both `a` and `b` at the same place
in memory.

The output of the above in the broken state is:

	&a = 0x4009c018
	 a = 0xffffffff

	&b = 0x4009c018
	 b = -1

With the patch applied, the output becomes:

	&a = 0x4009c01c
	 a = 0x0

	&b = 0x4009c018
	 b = -1

Reviewed by:	kib
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D42415/
2023-11-03 22:43:40 +01:00
..
atf Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
atrun Purge more stray embedded $FreeBSD$ strings 2023-09-25 07:54:56 -07:00
blacklistd-helper Track upstream project rename in contrib/blocklistd 2023-11-03 16:53:04 -04:00
bootpd Fix partially removed comment by removing the rest 2023-08-16 14:17:33 -06:00
comsat Purge more stray embedded $FreeBSD$ strings 2023-09-25 07:54:56 -07:00
dma Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
fingerd Track upstream project rename in contrib/blocklistd 2023-11-03 16:53:04 -04:00
flua flua: add fbsd module 2023-09-27 16:00:00 +02:00
ftpd Track upstream project rename in contrib/blocklistd 2023-11-03 16:53:04 -04:00
getty ttys: bump date 2023-10-26 12:38:22 -06:00
hyperv Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
mail.local Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
makewhatis.local Remove $FreeBSD$: two-line nroff pattern 2023-08-16 11:55:10 -06:00
mknetid Purge more stray embedded $FreeBSD$ strings 2023-09-25 07:54:56 -07:00
phttpget Remove $FreeBSD$: two-line nroff pattern 2023-08-16 11:55:10 -06:00
pppoed Remove $FreeBSD$: two-line nroff pattern 2023-08-16 11:55:10 -06:00
rbootd Purge more stray embedded $FreeBSD$ strings 2023-09-25 07:54:56 -07:00
rc jail: avoid a clash with /etc/jail.conf.d between rc and jail(8) 2023-09-24 17:03:09 -07:00
revnetgroup Purge more stray embedded $FreeBSD$ strings 2023-09-25 07:54:56 -07:00
rpc.rquotad Remove $FreeBSD$: two-line nroff pattern 2023-08-16 11:55:10 -06:00
rpc.rstatd Purge more stray embedded $FreeBSD$ strings 2023-09-25 07:54:56 -07:00
rpc.rusersd Purge more stray embedded $FreeBSD$ strings 2023-09-25 07:54:56 -07:00
rpc.rwalld Remove $FreeBSD$: two-line nroff pattern 2023-08-16 11:55:10 -06:00
rpc.sprayd Purge more stray embedded $FreeBSD$ strings 2023-09-25 07:54:56 -07:00
rtld-elf rtld/arm: fix initial-exec (IE) thread-local storage relocation 2023-11-03 22:43:40 +01:00
rtld-elf32 Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
save-entropy save-entropy: Add manual page 2023-09-18 13:33:59 +02:00
smrsh Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
talkd Purge more stray embedded $FreeBSD$ strings 2023-09-25 07:54:56 -07:00
tcpd Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
tests Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
tftp-proxy Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
tftpd Remove $FreeBSD$: one-line nroff pattern 2023-08-16 11:55:15 -06:00
ulog-helper Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
ypxfr Remove $FreeBSD$: two-line nroff pattern 2023-08-16 11:55:10 -06:00
Makefile Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
Makefile.inc Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00