[PATCH 04/16] elf, uapi: Add definitions for VER_FLG_BASE and VER_FLG_WEAK

Thomas Weißschuh posted 16 patches 1 year ago
There is a newer version of this series
[PATCH 04/16] elf, uapi: Add definitions for VER_FLG_BASE and VER_FLG_WEAK
Posted by Thomas Weißschuh 1 year ago
The definitions are used by tools/testing/selftests/vDSO/parse_vdso.c.
To be able to build the vDSO selftests without a libc dependency,
add the definitions to the kernels own UAPI headers.

Link: https://docs.oracle.com/cd/E19683-01/816-1386/chapter6-80869/index.html
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
 include/uapi/linux/elf.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h
index c5383cc7bb13c931fea083de5243c4006f795006..d040f12ff1c0ae3dde5c371c81d6089118fbe8ed 100644
--- a/include/uapi/linux/elf.h
+++ b/include/uapi/linux/elf.h
@@ -136,6 +136,9 @@ typedef __s64	Elf64_Sxword;
 #define STT_COMMON  5
 #define STT_TLS     6
 
+#define VER_FLG_BASE 0x1
+#define VER_FLG_WEAK 0x2
+
 #define ELF_ST_BIND(x)		((x) >> 4)
 #define ELF_ST_TYPE(x)		((x) & 0xf)
 #define ELF32_ST_BIND(x)	ELF_ST_BIND(x)

-- 
2.48.1

Re: [PATCH 04/16] elf, uapi: Add definitions for VER_FLG_BASE and VER_FLG_WEAK
Posted by Kees Cook 1 year ago
On Mon, Feb 03, 2025 at 10:05:05AM +0100, Thomas Weißschuh wrote:
> The definitions are used by tools/testing/selftests/vDSO/parse_vdso.c.
> To be able to build the vDSO selftests without a libc dependency,
> add the definitions to the kernels own UAPI headers.
> 
> Link: https://docs.oracle.com/cd/E19683-01/816-1386/chapter6-80869/index.html
> Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>

Reviewed-by: Kees Cook <kees@kernel.org>

-- 
Kees Cook
Re: [PATCH 04/16] elf, uapi: Add definitions for VER_FLG_BASE and VER_FLG_WEAK
Posted by Kees Cook 1 year ago
On Mon, Feb 03, 2025 at 10:05:05AM +0100, Thomas Weißschuh wrote:
> The definitions are used by tools/testing/selftests/vDSO/parse_vdso.c.
> To be able to build the vDSO selftests without a libc dependency,
> add the definitions to the kernels own UAPI headers.

For all the UAPI changes, where are the defines "normally" found? i.e.
how does adding these to UAPI not break something that already has them?
Or have these never been defined before? I'm confused about how removing
the libc dependency exposes the lack of these defines. Are they defined
in a non-exported libc header somewhere?

-Kees

-- 
Kees Cook
Re: [PATCH 04/16] elf, uapi: Add definitions for VER_FLG_BASE and VER_FLG_WEAK
Posted by Thomas Weißschuh 1 year ago
On Tue, Feb 04, 2025 at 07:10:00AM -0800, Kees Cook wrote:
> On Mon, Feb 03, 2025 at 10:05:05AM +0100, Thomas Weißschuh wrote:
> > The definitions are used by tools/testing/selftests/vDSO/parse_vdso.c.
> > To be able to build the vDSO selftests without a libc dependency,
> > add the definitions to the kernels own UAPI headers.
> 
> For all the UAPI changes, where are the defines "normally" found? i.e.
> how does adding these to UAPI not break something that already has them?
> Or have these never been defined before? I'm confused about how removing
> the libc dependency exposes the lack of these defines. Are they defined
> in a non-exported libc header somewhere?

They are normally defined directly in libc <elf.h>, which does not use
UAPI headers. Libc elf.h and Linux UAPI elf.h can not be used at the
same time because they define the same symbols.
In theory some user of UAPI elf.h could have defined these new symbols
on their own without ifdef guards. However UAPI elf.h is regularly
updated with new symbols.
Re: [PATCH 04/16] elf, uapi: Add definitions for VER_FLG_BASE and VER_FLG_WEAK
Posted by Kees Cook 1 year ago
On Tue, Feb 04, 2025 at 04:17:03PM +0100, Thomas Weißschuh wrote:
> On Tue, Feb 04, 2025 at 07:10:00AM -0800, Kees Cook wrote:
> > On Mon, Feb 03, 2025 at 10:05:05AM +0100, Thomas Weißschuh wrote:
> > > The definitions are used by tools/testing/selftests/vDSO/parse_vdso.c.
> > > To be able to build the vDSO selftests without a libc dependency,
> > > add the definitions to the kernels own UAPI headers.
> > 
> > For all the UAPI changes, where are the defines "normally" found? i.e.
> > how does adding these to UAPI not break something that already has them?
> > Or have these never been defined before? I'm confused about how removing
> > the libc dependency exposes the lack of these defines. Are they defined
> > in a non-exported libc header somewhere?
> 
> They are normally defined directly in libc <elf.h>, which does not use
> UAPI headers. Libc elf.h and Linux UAPI elf.h can not be used at the
> same time because they define the same symbols.
> In theory some user of UAPI elf.h could have defined these new symbols
> on their own without ifdef guards. However UAPI elf.h is regularly
> updated with new symbols.

Okay, great. As long as the collision risk is low, I'm fine with all the
UAPI additions. Thanks for doing this!

-- 
Kees Cook