Skip to contentSkip to conversation

vDSO, kbuild: Provide vDSO debug variants at runtime

PATCH In review Thomas Weißschuh 5 participants 17 messages Jul 8 – Nov 2

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vDSO, kbuild: Provide vDSO debug variants at runtime

Finding the debug version of the vDSO is not trivial as there is no common scheme where it is placed. That's especially problematic for CI testing.

The vDSO futex unlock mechanism requires for testing to have access to the inner labels of the unlock assembly, which are only accessible via the debug so.

Also for general debugging purposes it's convenient to have access to the debug vDSO at a well defined place.

The files are placed in /sys/kernel/vdso_debug.tar.xz. They use the regular 'make vdso_install' layout, including build-id symlinks to find the correct file for each process.

The design is kept close to the ones of the similar IKCONFIG and IKHEADERS.

On x86 the x32 vDSO is derived from the x86_64 one, necessitating an explicit dependency to avoid errors due to concurrent builds.

---
 Makefile            | 33 ++++++++++++++++++++++++++++++++-
 arch/x86/Makefile   |  3 +++
 init/Kconfig        | 10 ++++++++++
 kernel/Makefile     |  1 +
 kernel/vdso_debug.c | 43 +++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 89 insertions(+), 1 deletion(-)
Makefile +32 -1
index b9c5792c79e0..8049f10c27b2 100644
@@ -298,7 +298,7 @@ no-dot-config-targets := $(clean-targets) \
 			 %asm-generic kernelversion %src-pkg dt_binding_check \
 			 dt_style_selftest \
 			 outputmakefile rustavailable rustfmt rustfmtcheck \
-			 run-command
+			 run-command have-vdso-debug
 no-sync-config-targets := $(no-dot-config-targets) %install modules_sign kernelrelease \
 			  image_name
 single-targets := %.a %.i %.ko %.lds %.ll %.lst %.mod %.o %.rsi %.s %/
@@ -1539,6 +1539,37 @@ vdso_install: export INSTALL_FILES = $(vdso-install-y)
 vdso_install:
 	$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.vdsoinst
 
+# ---------------------------------------------------------------------------
+# vDSO embedded debug symbols
+
+PHONY += vdso_prepare
+
+# Build the targets in $(vdso-install-y)
+# Some architectures may do this already through vdso_prepare,
+# so add a dependency to avoid race conditions
+$(vdso-install-y): vdso_prepare prepare0 FORCE
+	@$(MAKE) $(build)=$(patsubst %/,%,$(dir $@)) $@
+
+tar-opts := --mtime='1970-01-01 00:00:00' --owner=0 --group=0 --sort=name --numeric-owner --mode=u=rw,go=r,a+X
+
+quiet_cmd_vdso_debug_tar_xz = VDSODBG $@
+      cmd_vdso_debug_tar_xz = \
+		rm -rf $(tmp-target); mkdir -p $(tmp-target)/vdso/; \
+		$(MAKE) quiet=@ MODLIB=$(tmp-target) vdso_install; \
+		$(TAR) $(tar-opts) -a -c -f $@ -C $(tmp-target)/vdso/ .
+
+targets += vdso_debug.tar.xz
+vdso_debug.tar.xz: $(vdso-install-y) FORCE
+	$(call if_changed,vdso_debug_tar_xz)
+
+ifdef CONFIG_IVDSODEBUG
+prepare: vdso_debug.tar.xz
+endif
+
+PHONY += have-vdso-debug
+have-vdso-debug:
+	@echo $(if $(vdso-install-y)$(vdso-install-),y,n)
+
 # ---------------------------------------------------------------------------
 # Tools
 
arch/x86/Makefile +3 -0
index 598f178102ee..b762fddb620e 100644
@@ -316,6 +316,9 @@ vdso-install-$(CONFIG_X86_64)	   += arch/x86/entry/vdso/vdso64/vdso64.so.dbg
 vdso-install-$(CONFIG_X86_X32_ABI) += arch/x86/entry/vdso/vdso64/vdsox32.so.dbg
 vdso-install-$(CONFIG_COMPAT_32)   += arch/x86/entry/vdso/vdso32/vdso32.so.dbg
 
+# vdsox32.so.dbg is derived from vdso64.so.dbg. Avoid races with CONFIG_IVDSODEBUG
+arch/x86/entry/vdso/vdso64/vdsox32.so.dbg: arch/x86/entry/vdso/vdso64/vdso64.so.dbg
+
 archprepare: checkbin
 checkbin:
 ifdef CONFIG_MITIGATION_RETPOLINE
init/Kconfig +10 -0
index 5230d4879b1c..f09132a44264 100644
@@ -801,6 +801,16 @@ config IKHEADERS
 	  or similar programs.  If you build the headers as a module, a module called
 	  kheaders.ko is built which can be loaded on-demand to get access to headers.
 
+config IVDSODEBUG
+	tristate "Enable vDSO debug information through /sys/kernel/vdso_debug.tar.xz"
+	depends on SYSFS
+	depends on "$(shell,make have-vdso-debug)"
+	help
+	  This option enables access to the vDSO debug information. That can be
+	  used to debug applications and test the vDSO implementation.
+
+	  If configured as M the module will be called vdso_debug.ko.
+
 config LOG_BUF_SHIFT
 	int "Kernel log buffer size (16 => 64KB, 17 => 128KB)"
 	range 12 25
kernel/Makefile +1 -0
index 1e1a31673577..8adcc26ef859 100644
@@ -93,6 +93,7 @@ obj-$(CONFIG_USER_NS) += user_namespace.o
 obj-$(CONFIG_PID_NS) += pid_namespace.o
 obj-$(CONFIG_IKCONFIG) += configs.o
 obj-$(CONFIG_IKHEADERS) += kheaders.o
+obj-$(CONFIG_IVDSODEBUG) += vdso_debug.o
 obj-$(CONFIG_SMP) += stop_machine.o
 obj-$(CONFIG_AUDIT) += audit.o auditfilter.o
 obj-$(CONFIG_AUDITSYSCALL) += auditsc.o audit_watch.o audit_fsnotify.o audit_tree.o
kernel/vdso_debug.c new file +43 -0

43 lines not on this page · raw message

---
base-commit: dc59e4fea9d83f03bad6bddf3fa2e52491777482
change-id: 20260624-vdso-sysfs-abfd14fde5a7

Best regards,

Signature · 1 line
Thomas Weißschuh <[email protected]>
Tested-by on v1 1/1
#1 lore raw

Em 08/07/2026 10:56, Thomas Weißschuh escreveu:

Quoted 16 lines

Finding the debug version of the vDSO is not trivial as there is no common scheme where it is placed. That's especially problematic for CI testing.

The vDSO futex unlock mechanism requires for testing to have access to the inner labels of the unlock assembly, which are only accessible via the debug so.

Also for general debugging purposes it's convenient to have access to the debug vDSO at a well defined place.

The files are placed in /sys/kernel/vdso_debug.tar.xz. They use the regular 'make vdso_install' layout, including build-id symlinks to find the correct file for each process.

The design is kept close to the ones of the similar IKCONFIG and IKHEADERS.

Quoted 7 lines

On x86 the x32 vDSO is derived from the x86_64 one, necessitating an explicit dependency to avoid errors due to concurrent builds.

---

Thanks for your patch! Tested in arm64 (qemu) and it worked fine. I was just expecting that the file would be called "vdso.so.dbg", not "vdso.so".

#2 lore raw

Em 08/07/2026 12:28, André Almeida escreveu:

Quoted 20 lines

Em 08/07/2026 10:56, Thomas Weißschuh escreveu:

Quoted 19 lines

Finding the debug version of the vDSO is not trivial as there is no common scheme where it is placed. That's especially problematic for CI testing.

The vDSO futex unlock mechanism requires for testing to have access to the inner labels of the unlock assembly, which are only accessible via the debug so.

Also for general debugging purposes it's convenient to have access to the debug vDSO at a well defined place.

The files are placed in /sys/kernel/vdso_debug.tar.xz. They use the regular 'make vdso_install' layout, including build-id symlinks to find the correct file for each process.

The design is kept close to the ones of the similar IKCONFIG and IKHEADERS.

On x86 the x32 vDSO is derived from the x86_64 one, necessitating an explicit dependency to avoid errors due to concurrent builds.

Quoted 8 lines
Quoted 4 lines

---

Thanks for your patch! Tested in arm64 (qemu) and it worked fine. I was just expecting that the file would be called "vdso.so.dbg", not "vdso.so".

Also, how do you suggest to integrate this with kselftests? Maybe adding an untar command to futex/functional/run.sh?

#3 lore raw
Quoted 32 lines · André Almeida

Em 08/07/2026 12:28, André Almeida escreveu:

Quoted 31 lines

Em 08/07/2026 10:56, Thomas Weißschuh escreveu:

Quoted 19 lines

Finding the debug version of the vDSO is not trivial as there is no common
scheme where it is placed. That's especially problematic for CI testing.

The vDSO futex unlock mechanism requires for testing to have access to the
inner labels of the unlock assembly, which are only accessible via the debug so.

Also for general debugging purposes it's convenient to have access to the debug vDSO at a well defined place.

The files are placed in /sys/kernel/vdso_debug.tar.xz. They use the regular 'make vdso_install' layout, including build-id symlinks to find the correct file for each process.

The design is kept close to the ones of the similar IKCONFIG and IKHEADERS.

Quoted 7 lines

On x86 the x32 vDSO is derived from the x86_64 one, necessitating an explicit dependency to avoid errors due to concurrent builds.

---

Thanks for your patch! Tested in arm64 (qemu) and it worked fine. I was just expecting that the file would be called "vdso.so.dbg", not "vdso.so".

That is due to scripts/Makefile.vdsoinst:

dest := $(install-dir)/$$(patsubst %.dbg,%,$$(notdir $(1)))

Quoted 1 line
Quoted 1 line

Thanks!

Quoted 2 lines

Also, how do you suggest to integrate this with kselftests? Maybe adding an untar command to futex/functional/run.sh?

In the current implementation, yes. But it would also be possible to have a proper virtual directory tree, albeit with higher implementation consts.

Thomas

Reviewed-by on v1 1/1
#4 lore raw
In reply to Thomas Weißschuh
Quoted 14 lines · Thomas Weißschuh

Finding the debug version of the vDSO is not trivial as there is no common scheme where it is placed. That's especially problematic for CI testing.

The vDSO futex unlock mechanism requires for testing to have access to the inner labels of the unlock assembly, which are only accessible via the debug so.

Also for general debugging purposes it's convenient to have access to the debug vDSO at a well defined place.

The files are placed in /sys/kernel/vdso_debug.tar.xz. They use the regular 'make vdso_install' layout, including build-id symlinks to find the correct file for each process.

Quoted 8 lines

The design is kept close to the ones of the similar IKCONFIG and IKHEADERS.

On x86 the x32 vDSO is derived from the x86_64 one, necessitating an explicit dependency to avoid errors due to concurrent builds.

This is a really good idea. Thanks!

Quoted 164 lines
---
 Makefile            | 33 ++++++++++++++++++++++++++++++++-
 arch/x86/Makefile   |  3 +++
 init/Kconfig        | 10 ++++++++++
 kernel/Makefile     |  1 +
 kernel/vdso_debug.c | 43 +++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 89 insertions(+), 1 deletion(-)
Makefile +32 -1
index b9c5792c79e0..8049f10c27b2 100644
@@ -298,7 +298,7 @@ no-dot-config-targets := $(clean-targets) \
 			 %asm-generic kernelversion %src-pkg dt_binding_check \
 			 dt_style_selftest \
 			 outputmakefile rustavailable rustfmt rustfmtcheck \
-			 run-command
+			 run-command have-vdso-debug
 no-sync-config-targets := $(no-dot-config-targets) %install modules_sign kernelrelease \
 			  image_name
 single-targets := %.a %.i %.ko %.lds %.ll %.lst %.mod %.o %.rsi %.s %/
@@ -1539,6 +1539,37 @@ vdso_install: export INSTALL_FILES = $(vdso-install-y)
 vdso_install:
 	$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.vdsoinst
 
+# ---------------------------------------------------------------------------
+# vDSO embedded debug symbols
+
+PHONY += vdso_prepare
+
+# Build the targets in $(vdso-install-y)
+# Some architectures may do this already through vdso_prepare,
+# so add a dependency to avoid race conditions
+$(vdso-install-y): vdso_prepare prepare0 FORCE
+	@$(MAKE) $(build)=$(patsubst %/,%,$(dir $@)) $@
+
+tar-opts := --mtime='1970-01-01 00:00:00' --owner=0 --group=0 --sort=name --numeric-owner --mode=u=rw,go=r,a+X
+
+quiet_cmd_vdso_debug_tar_xz = VDSODBG $@
+      cmd_vdso_debug_tar_xz = \
+		rm -rf $(tmp-target); mkdir -p $(tmp-target)/vdso/; \
+		$(MAKE) quiet=@ MODLIB=$(tmp-target) vdso_install; \
+		$(TAR) $(tar-opts) -a -c -f $@ -C $(tmp-target)/vdso/ .
+
+targets += vdso_debug.tar.xz
+vdso_debug.tar.xz: $(vdso-install-y) FORCE
+	$(call if_changed,vdso_debug_tar_xz)
+
+ifdef CONFIG_IVDSODEBUG
+prepare: vdso_debug.tar.xz
+endif
+
+PHONY += have-vdso-debug
+have-vdso-debug:
+	@echo $(if $(vdso-install-y)$(vdso-install-),y,n)
+
 # ---------------------------------------------------------------------------
 # Tools
 
arch/x86/Makefile +3 -0
index 598f178102ee..b762fddb620e 100644
@@ -316,6 +316,9 @@ vdso-install-$(CONFIG_X86_64)	   += arch/x86/entry/vdso/vdso64/vdso64.so.dbg
 vdso-install-$(CONFIG_X86_X32_ABI) += arch/x86/entry/vdso/vdso64/vdsox32.so.dbg
 vdso-install-$(CONFIG_COMPAT_32)   += arch/x86/entry/vdso/vdso32/vdso32.so.dbg
 
+# vdsox32.so.dbg is derived from vdso64.so.dbg. Avoid races with CONFIG_IVDSODEBUG
+arch/x86/entry/vdso/vdso64/vdsox32.so.dbg: arch/x86/entry/vdso/vdso64/vdso64.so.dbg
+
 archprepare: checkbin
 checkbin:
 ifdef CONFIG_MITIGATION_RETPOLINE
init/Kconfig +10 -0
index 5230d4879b1c..f09132a44264 100644
@@ -801,6 +801,16 @@ config IKHEADERS
 	  or similar programs.  If you build the headers as a module, a module called
 	  kheaders.ko is built which can be loaded on-demand to get access to headers.
 
+config IVDSODEBUG
+	tristate "Enable vDSO debug information through /sys/kernel/vdso_debug.tar.xz"
+	depends on SYSFS
+	depends on "$(shell,make have-vdso-debug)"
+	help
+	  This option enables access to the vDSO debug information. That can be
+	  used to debug applications and test the vDSO implementation.
+
+	  If configured as M the module will be called vdso_debug.ko.
+
 config LOG_BUF_SHIFT
 	int "Kernel log buffer size (16 => 64KB, 17 => 128KB)"
 	range 12 25
kernel/Makefile +1 -0
index 1e1a31673577..8adcc26ef859 100644
@@ -93,6 +93,7 @@ obj-$(CONFIG_USER_NS) += user_namespace.o
 obj-$(CONFIG_PID_NS) += pid_namespace.o
 obj-$(CONFIG_IKCONFIG) += configs.o
 obj-$(CONFIG_IKHEADERS) += kheaders.o
+obj-$(CONFIG_IVDSODEBUG) += vdso_debug.o
 obj-$(CONFIG_SMP) += stop_machine.o
 obj-$(CONFIG_AUDIT) += audit.o auditfilter.o
 obj-$(CONFIG_AUDITSYSCALL) += auditsc.o audit_watch.o audit_fsnotify.o audit_tree.o
kernel/vdso_debug.c new file +43 -1
new file mode 100644
index 000000000000..72d4f11327fc
@@ -0,0 +1,43 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#include <linux/cache.h>
+#include <linux/init.h>
+#include <linux/kobject.h>
+#include <linux/module.h>
+#include <linux/sysfs.h>
+
+asm (
+"	.pushsection .rodata, \"a\"	\n"
+"	.global vdso_debug_data		\n"
+"vdso_debug_data:			\n"
+"	.incbin \"vdso_debug.tar.xz\"	\n"
+"	.global vdso_debug_data_end	\n"
+"vdso_debug_data_end:			\n"
+"	.popsection			\n"
+);
+
+extern char vdso_debug_data[];
+extern char vdso_debug_data_end[];
+
+static struct bin_attribute vdso_debug_attr __ro_after_init =
+	__BIN_ATTR_SIMPLE_RO(vdso_debug.tar.xz, 0444);
+
+static int __init vdso_debug_init(void)
+{
+	vdso_debug_attr.private = vdso_debug_data;
+	vdso_debug_attr.size = vdso_debug_data_end - vdso_debug_data;
+
+	return sysfs_create_bin_file(kernel_kobj, &vdso_debug_attr);
+}
+
+static void __exit vdso_debug_exit(void)
+{
+	sysfs_remove_bin_file(kernel_kobj, &vdso_debug_attr);
+}
+
+module_init(vdso_debug_init);
+module_exit(vdso_debug_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Thomas Weißschuh <[email protected]>");
+MODULE_DESCRIPTION("Provide vDSO debug information at runtime");
 
---

base-commit: dc59e4fea9d83f03bad6bddf3fa2e52491777482
change-id: 20260624-vdso-sysfs-abfd14fde5a7

Best regards,

Signature · 1 line
Thomas Weißschuh <[email protected]>
Signature · 2 lines
Regards,
Vincenzo
#5 lore raw
Quoted 186 lines · Vincenzo Frascino
Quoted 14 lines · Thomas Weißschuh

Finding the debug version of the vDSO is not trivial as there is no common scheme where it is placed. That's especially problematic for CI testing.

The vDSO futex unlock mechanism requires for testing to have access to the inner labels of the unlock assembly, which are only accessible via the debug so.

Also for general debugging purposes it's convenient to have access to the debug vDSO at a well defined place.

The files are placed in /sys/kernel/vdso_debug.tar.xz. They use the regular 'make vdso_install' layout, including build-id symlinks to find the correct file for each process.

Quoted 8 lines

The design is kept close to the ones of the similar IKCONFIG and IKHEADERS.

On x86 the x32 vDSO is derived from the x86_64 one, necessitating an explicit dependency to avoid errors due to concurrent builds.

This is a really good idea. Thanks!

Quoted 156 lines
---
 Makefile            | 33 ++++++++++++++++++++++++++++++++-
 arch/x86/Makefile   |  3 +++
 init/Kconfig        | 10 ++++++++++
 kernel/Makefile     |  1 +
 kernel/vdso_debug.c | 43 +++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 89 insertions(+), 1 deletion(-)
Makefile +32 -1
index b9c5792c79e0..8049f10c27b2 100644
@@ -298,7 +298,7 @@ no-dot-config-targets := $(clean-targets) \
 			 %asm-generic kernelversion %src-pkg dt_binding_check \
 			 dt_style_selftest \
 			 outputmakefile rustavailable rustfmt rustfmtcheck \
-			 run-command
+			 run-command have-vdso-debug
 no-sync-config-targets := $(no-dot-config-targets) %install modules_sign kernelrelease \
 			  image_name
 single-targets := %.a %.i %.ko %.lds %.ll %.lst %.mod %.o %.rsi %.s %/
@@ -1539,6 +1539,37 @@ vdso_install: export INSTALL_FILES = $(vdso-install-y)
 vdso_install:
 	$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.vdsoinst
 
+# ---------------------------------------------------------------------------
+# vDSO embedded debug symbols
+
+PHONY += vdso_prepare
+
+# Build the targets in $(vdso-install-y)
+# Some architectures may do this already through vdso_prepare,
+# so add a dependency to avoid race conditions
+$(vdso-install-y): vdso_prepare prepare0 FORCE
+	@$(MAKE) $(build)=$(patsubst %/,%,$(dir $@)) $@
+
+tar-opts := --mtime='1970-01-01 00:00:00' --owner=0 --group=0 --sort=name --numeric-owner --mode=u=rw,go=r,a+X
+
+quiet_cmd_vdso_debug_tar_xz = VDSODBG $@
+      cmd_vdso_debug_tar_xz = \
+		rm -rf $(tmp-target); mkdir -p $(tmp-target)/vdso/; \
+		$(MAKE) quiet=@ MODLIB=$(tmp-target) vdso_install; \
+		$(TAR) $(tar-opts) -a -c -f $@ -C $(tmp-target)/vdso/ .
+
+targets += vdso_debug.tar.xz
+vdso_debug.tar.xz: $(vdso-install-y) FORCE
+	$(call if_changed,vdso_debug_tar_xz)
+
+ifdef CONFIG_IVDSODEBUG
+prepare: vdso_debug.tar.xz
+endif
+
+PHONY += have-vdso-debug
+have-vdso-debug:
+	@echo $(if $(vdso-install-y)$(vdso-install-),y,n)
+
 # ---------------------------------------------------------------------------
 # Tools
 
arch/x86/Makefile +3 -0
index 598f178102ee..b762fddb620e 100644
@@ -316,6 +316,9 @@ vdso-install-$(CONFIG_X86_64)	   += arch/x86/entry/vdso/vdso64/vdso64.so.dbg
 vdso-install-$(CONFIG_X86_X32_ABI) += arch/x86/entry/vdso/vdso64/vdsox32.so.dbg
 vdso-install-$(CONFIG_COMPAT_32)   += arch/x86/entry/vdso/vdso32/vdso32.so.dbg
 
+# vdsox32.so.dbg is derived from vdso64.so.dbg. Avoid races with CONFIG_IVDSODEBUG
+arch/x86/entry/vdso/vdso64/vdsox32.so.dbg: arch/x86/entry/vdso/vdso64/vdso64.so.dbg
+
 archprepare: checkbin
 checkbin:
 ifdef CONFIG_MITIGATION_RETPOLINE
init/Kconfig +10 -0
index 5230d4879b1c..f09132a44264 100644
@@ -801,6 +801,16 @@ config IKHEADERS
 	  or similar programs.  If you build the headers as a module, a module called
 	  kheaders.ko is built which can be loaded on-demand to get access to headers.
 
+config IVDSODEBUG
+	tristate "Enable vDSO debug information through /sys/kernel/vdso_debug.tar.xz"
+	depends on SYSFS
+	depends on "$(shell,make have-vdso-debug)"
+	help
+	  This option enables access to the vDSO debug information. That can be
+	  used to debug applications and test the vDSO implementation.
+
+	  If configured as M the module will be called vdso_debug.ko.
+
 config LOG_BUF_SHIFT
 	int "Kernel log buffer size (16 => 64KB, 17 => 128KB)"
 	range 12 25
kernel/Makefile +1 -0
index 1e1a31673577..8adcc26ef859 100644
@@ -93,6 +93,7 @@ obj-$(CONFIG_USER_NS) += user_namespace.o
 obj-$(CONFIG_PID_NS) += pid_namespace.o
 obj-$(CONFIG_IKCONFIG) += configs.o
 obj-$(CONFIG_IKHEADERS) += kheaders.o
+obj-$(CONFIG_IVDSODEBUG) += vdso_debug.o
 obj-$(CONFIG_SMP) += stop_machine.o
 obj-$(CONFIG_AUDIT) += audit.o auditfilter.o
 obj-$(CONFIG_AUDITSYSCALL) += auditsc.o audit_watch.o audit_fsnotify.o audit_tree.o
kernel/vdso_debug.c new file +43 -0
new file mode 100644
index 000000000000..72d4f11327fc
@@ -0,0 +1,43 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#include <linux/cache.h>
+#include <linux/init.h>
+#include <linux/kobject.h>
+#include <linux/module.h>
+#include <linux/sysfs.h>
+
+asm (
+"	.pushsection .rodata, \"a\"	\n"
+"	.global vdso_debug_data		\n"
+"vdso_debug_data:			\n"
+"	.incbin \"vdso_debug.tar.xz\"	\n"
+"	.global vdso_debug_data_end	\n"
+"vdso_debug_data_end:			\n"
+"	.popsection			\n"
+);
+
+extern char vdso_debug_data[];
+extern char vdso_debug_data_end[];
+
+static struct bin_attribute vdso_debug_attr __ro_after_init =
+	__BIN_ATTR_SIMPLE_RO(vdso_debug.tar.xz, 0444);
+
+static int __init vdso_debug_init(void)
+{
+	vdso_debug_attr.private = vdso_debug_data;
+	vdso_debug_attr.size = vdso_debug_data_end - vdso_debug_data;
+
+	return sysfs_create_bin_file(kernel_kobj, &vdso_debug_attr);
+}
+
+static void __exit vdso_debug_exit(void)
+{
+	sysfs_remove_bin_file(kernel_kobj, &vdso_debug_attr);
+}
+
+module_init(vdso_debug_init);
+module_exit(vdso_debug_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Thomas Weißschuh <[email protected]>");
+MODULE_DESCRIPTION("Provide vDSO debug information at runtime");
Quoted 9 lines
Quoted 8 lines

---
base-commit: dc59e4fea9d83f03bad6bddf3fa2e52491777482
change-id: 20260624-vdso-sysfs-abfd14fde5a7

Best regards,

Signature · 1 line
Thomas Weißschuh <[email protected]>

Why stuff them into a tarball?

#6 lore raw
Quoted 24 lines · H. Peter Anvin
Quoted 23 lines · Vincenzo Frascino
Quoted 22 lines · Thomas Weißschuh

Finding the debug version of the vDSO is not trivial as there is no common scheme where it is placed. That's especially problematic for CI testing.

The vDSO futex unlock mechanism requires for testing to have access to the inner labels of the unlock assembly, which are only accessible via the debug so.

Also for general debugging purposes it's convenient to have access to the debug vDSO at a well defined place.

The files are placed in /sys/kernel/vdso_debug.tar.xz. They use the regular 'make vdso_install' layout, including build-id symlinks to find the correct file for each process.

The design is kept close to the ones of the similar IKCONFIG and IKHEADERS.

On x86 the x32 vDSO is derived from the x86_64 one, necessitating an explicit dependency to avoid errors due to concurrent builds.

(...)

Quoted 1 line

Why stuff them into a tarball?

Because it was the easiest solution to implement and has been sufficient for IKHEADERS so far. I don't see a clearly winning solution among the possibilities to expose a directory:

* Use plain sysfs:
Requires a new code generator and potentially changes to sysfs

* Use a read-only filesystem like cramfs/erofs:
Introduces new build-time and runtime dependencies

* Add a new filesystem backed by a tarball or cpio archive:
Lot's of complexity and work to implement

But I am open to discussions and other ideas.

Thomas

#7 lore raw
Quoted 40 lines · Thomas Weißschuh
Quoted 24 lines · H. Peter Anvin
Quoted 23 lines · Vincenzo Frascino
Quoted 22 lines · Thomas Weißschuh

Finding the debug version of the vDSO is not trivial as there is no common scheme where it is placed. That's especially problematic for CI testing.

The vDSO futex unlock mechanism requires for testing to have access to the inner labels of the unlock assembly, which are only accessible via the debug so.

Also for general debugging purposes it's convenient to have access to the debug vDSO at a well defined place.

The files are placed in /sys/kernel/vdso_debug.tar.xz. They use the regular 'make vdso_install' layout, including build-id symlinks to find the correct file for each process.

The design is kept close to the ones of the similar IKCONFIG and IKHEADERS.

On x86 the x32 vDSO is derived from the x86_64 one, necessitating an explicit dependency to avoid errors due to concurrent builds.

(...)

Quoted 1 line

Why stuff them into a tarball?

Because it was the easiest solution to implement and has been sufficient for IKHEADERS so far. I don't see a clearly winning solution among the possibilities to expose a directory:

* Use plain sysfs:
Requires a new code generator and potentially changes to sysfs

* Use a read-only filesystem like cramfs/erofs:
Introduces new build-time and runtime dependencies

Quoted 7 lines

* Add a new filesystem backed by a tarball or cpio archive:
Lot's of complexity and work to implement

But I am open to discussions and other ideas.

Thomas

I discussed this with GregKH a while ago, in the context of eventually making the vdso an actual mapping of a virtual file. According to him it should be quite simple in sysfs; I got a bit stumped on the necessary hooks (the kernel needs to keep track of where the vdso lives in the address space.)

#8 lore raw
Quoted 44 lines · H. Peter Anvin
Quoted 43 lines · Thomas Weißschuh
Quoted 24 lines · H. Peter Anvin
Quoted 23 lines · Vincenzo Frascino
Quoted 22 lines · Thomas Weißschuh

Finding the debug version of the vDSO is not trivial as there is no common scheme where it is placed. That's especially problematic for CI testing.

The vDSO futex unlock mechanism requires for testing to have access to the inner labels of the unlock assembly, which are only accessible via the debug so.

Also for general debugging purposes it's convenient to have access to the debug vDSO at a well defined place.

The files are placed in /sys/kernel/vdso_debug.tar.xz. They use the regular 'make vdso_install' layout, including build-id symlinks to find the correct file for each process.

The design is kept close to the ones of the similar IKCONFIG and IKHEADERS.

On x86 the x32 vDSO is derived from the x86_64 one, necessitating an explicit dependency to avoid errors due to concurrent builds.

(...)

Quoted 1 line

Why stuff them into a tarball?

Because it was the easiest solution to implement and has been sufficient for IKHEADERS so far. I don't see a clearly winning solution among the possibilities to expose a directory:

* Use plain sysfs:
Requires a new code generator and potentially changes to sysfs

* Use a read-only filesystem like cramfs/erofs:
Introduces new build-time and runtime dependencies

* Add a new filesystem backed by a tarball or cpio archive:
Lot's of complexity and work to implement

Quoted 6 lines
Quoted 1 line

But I am open to discussions and other ideas.

I discussed this with GregKH a while ago, in the context of eventually making the vdso an actual mapping of a virtual file. According to him it should be quite simple in sysfs; I got a bit stumped on the necessary hooks (the kernel needs to keep track of where the vdso lives in the address space.)

Interesting idea, I will take a look at it.

Today the vDSO mapped into userspace is a stripped version. For the debugging usecase however we want the unstripped one. Also it won't help with debugging a coredump.

Thomas

#9 lore raw
Quoted 52 lines · Thomas Weißschuh
Quoted 44 lines · H. Peter Anvin
Quoted 43 lines · Thomas Weißschuh
Quoted 24 lines · H. Peter Anvin
Quoted 23 lines · Vincenzo Frascino
Quoted 22 lines · Thomas Weißschuh

Finding the debug version of the vDSO is not trivial as there is no common scheme where it is placed. That's especially problematic for CI testing.

The vDSO futex unlock mechanism requires for testing to have access to the inner labels of the unlock assembly, which are only accessible via the debug so.

Also for general debugging purposes it's convenient to have access to the debug vDSO at a well defined place.

The files are placed in /sys/kernel/vdso_debug.tar.xz. They use the regular 'make vdso_install' layout, including build-id symlinks to find the correct file for each process.

The design is kept close to the ones of the similar IKCONFIG and IKHEADERS.

On x86 the x32 vDSO is derived from the x86_64 one, necessitating an explicit dependency to avoid errors due to concurrent builds.

(...)

Quoted 1 line

Why stuff them into a tarball?

Because it was the easiest solution to implement and has been sufficient for IKHEADERS so far. I don't see a clearly winning solution among the possibilities to expose a directory:

* Use plain sysfs:
Requires a new code generator and potentially changes to sysfs

* Use a read-only filesystem like cramfs/erofs:
Introduces new build-time and runtime dependencies

* Add a new filesystem backed by a tarball or cpio archive:
Lot's of complexity and work to implement

Quoted 6 lines
Quoted 1 line

But I am open to discussions and other ideas.

I discussed this with GregKH a while ago, in the context of eventually making the vdso an actual mapping of a virtual file. According to him it should be quite simple in sysfs; I got a bit stumped on the necessary hooks (the kernel needs to keep track of where the vdso lives in the address space.)

Quoted 8 lines

Interesting idea, I will take a look at it.

Today the vDSO mapped into userspace is a stripped version. For the debugging usecase however we want the unstripped one. Also it won't help with debugging a coredump.

Thomas

Why wouldn't it??

#10 lore raw
Quoted 46 lines · H. Peter Anvin
Quoted 45 lines · Thomas Weißschuh
Quoted 44 lines · H. Peter Anvin
Quoted 43 lines · Thomas Weißschuh
Quoted 24 lines · H. Peter Anvin
Quoted 23 lines · Vincenzo Frascino
Quoted 22 lines · Thomas Weißschuh

Finding the debug version of the vDSO is not trivial as there is no common scheme where it is placed. That's especially problematic for CI testing.

The vDSO futex unlock mechanism requires for testing to have access to the inner labels of the unlock assembly, which are only accessible via the debug so.

Also for general debugging purposes it's convenient to have access to the debug vDSO at a well defined place.

The files are placed in /sys/kernel/vdso_debug.tar.xz. They use the regular 'make vdso_install' layout, including build-id symlinks to find the correct file for each process.

The design is kept close to the ones of the similar IKCONFIG and IKHEADERS.

On x86 the x32 vDSO is derived from the x86_64 one, necessitating an explicit dependency to avoid errors due to concurrent builds.

(...)

Quoted 1 line

Why stuff them into a tarball?

Because it was the easiest solution to implement and has been sufficient for IKHEADERS so far. I don't see a clearly winning solution among the possibilities to expose a directory:

* Use plain sysfs:
Requires a new code generator and potentially changes to sysfs

* Use a read-only filesystem like cramfs/erofs:
Introduces new build-time and runtime dependencies

* Add a new filesystem backed by a tarball or cpio archive:
Lot's of complexity and work to implement

Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
Quoted 1 line

But I am open to discussions and other ideas.

I discussed this with GregKH a while ago, in the context of eventually making the vdso an actual mapping of a virtual file. According to him it should be quite simple in sysfs; I got a bit stumped on the necessary hooks (the kernel needs to keep track of where the vdso lives in the address space.)

Interesting idea, I will take a look at it.

What would be the advantages?

How would this handle the fact that the data page mapping needs to be fixed next to the code one? Should the data page mapping also be a virtual file?

Quoted 5 lines
Quoted 4 lines

Today the vDSO mapped into userspace is a stripped version. For the debugging usecase however we want the unstripped one.

Also it won't help with debugging a coredump.

Why wouldn't it??

I can't reconstruct what I was thinking here. Sorry for the noise.

Thomas

maintainer
#11 lore raw
In reply to Thomas Weißschuh
Quoted 22 lines · Thomas Weißschuh

Finding the debug version of the vDSO is not trivial as there is no common scheme where it is placed. That's especially problematic for CI testing.

The vDSO futex unlock mechanism requires for testing to have access to the inner labels of the unlock assembly, which are only accessible via the debug so.

Also for general debugging purposes it's convenient to have access to the debug vDSO at a well defined place.

The files are placed in /sys/kernel/vdso_debug.tar.xz. They use the regular 'make vdso_install' layout, including build-id symlinks to find the correct file for each process.

The design is kept close to the ones of the similar IKCONFIG and IKHEADERS.

On x86 the x32 vDSO is derived from the x86_64 one, necessitating an explicit dependency to avoid errors due to concurrent builds.

Quoted 8 lines
---
 Makefile            | 33 ++++++++++++++++++++++++++++++++-
 arch/x86/Makefile   |  3 +++
 init/Kconfig        | 10 ++++++++++
 kernel/Makefile     |  1 +
 kernel/vdso_debug.c | 43 +++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 89 insertions(+), 1 deletion(-)

This seems to have fallen through the cracks; shall it be considered for kbuild-7.5?

Signature · 1 line
Nicolas
#12 lore raw
Quoted 32 lines · Nicolas Schier
Quoted 22 lines · Thomas Weißschuh

Finding the debug version of the vDSO is not trivial as there is no common scheme where it is placed. That's especially problematic for CI testing.

The vDSO futex unlock mechanism requires for testing to have access to the inner labels of the unlock assembly, which are only accessible via the debug so.

Also for general debugging purposes it's convenient to have access to the debug vDSO at a well defined place.

The files are placed in /sys/kernel/vdso_debug.tar.xz. They use the regular 'make vdso_install' layout, including build-id symlinks to find the correct file for each process.

The design is kept close to the ones of the similar IKCONFIG and IKHEADERS.

On x86 the x32 vDSO is derived from the x86_64 one, necessitating an explicit dependency to avoid errors due to concurrent builds.

Quoted 8 lines
---
 Makefile            | 33 ++++++++++++++++++++++++++++++++-
 arch/x86/Makefile   |  3 +++
 init/Kconfig        | 10 ++++++++++
 kernel/Makefile     |  1 +
 kernel/vdso_debug.c | 43 +++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 89 insertions(+), 1 deletion(-)
Quoted 3 lines

This seems to have fallen through the cracks; shall it be considered for kbuild-7.5?

A thought: most tools support compressed separate debug information. Would it make more sense to have the vdso images with separate, compressed debug data in a subdirectory?

#13 lore raw
Quoted 33 lines · H. Peter Anvin
Quoted 32 lines · Nicolas Schier
Quoted 30 lines · Thomas Weißschuh

Finding the debug version of the vDSO is not trivial as there is no common scheme where it is placed. That's especially problematic for CI testing.

The vDSO futex unlock mechanism requires for testing to have access to the inner labels of the unlock assembly, which are only accessible via the debug so.

Also for general debugging purposes it's convenient to have access to the debug vDSO at a well defined place.

The files are placed in /sys/kernel/vdso_debug.tar.xz. They use the regular 'make vdso_install' layout, including build-id symlinks to find the correct file for each process.

The design is kept close to the ones of the similar IKCONFIG and IKHEADERS.

On x86 the x32 vDSO is derived from the x86_64 one, necessitating an explicit dependency to avoid errors due to concurrent builds.

---
 Makefile            | 33 ++++++++++++++++++++++++++++++++-
 arch/x86/Makefile   |  3 +++
 init/Kconfig        | 10 ++++++++++
 kernel/Makefile     |  1 +
 kernel/vdso_debug.c | 43 +++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 89 insertions(+), 1 deletion(-)
Quoted 2 lines
Quoted 2 lines

This seems to have fallen through the cracks; shall it be considered for kbuild-7.5?

Please don't pick this up just yet. I have a prototype which exposes the directory through sysfs directly without forcing users to unpack the archive. If you could take a look at the kbuild bits however, that would be great.

Quoted 3 lines

A thought: most tools support compressed separate debug information. Would it make more sense to have the vdso images with separate, compressed debug data in a subdirectory?

I want to stick to the 'make vdso_install' layout. Maybe that should be changed to your proposal, too? But what are the specific advantages? The files are compressed on disk anyways through the module compression.

Thomas

#14 lore raw
Quoted 45 lines · Thomas Weißschuh
Quoted 33 lines · H. Peter Anvin
Quoted 32 lines · Nicolas Schier
Quoted 30 lines · Thomas Weißschuh

Finding the debug version of the vDSO is not trivial as there is no common scheme where it is placed. That's especially problematic for CI testing.

The vDSO futex unlock mechanism requires for testing to have access to the inner labels of the unlock assembly, which are only accessible via the debug so.

Also for general debugging purposes it's convenient to have access to the debug vDSO at a well defined place.

The files are placed in /sys/kernel/vdso_debug.tar.xz. They use the regular 'make vdso_install' layout, including build-id symlinks to find the correct file for each process.

The design is kept close to the ones of the similar IKCONFIG and IKHEADERS.

On x86 the x32 vDSO is derived from the x86_64 one, necessitating an explicit dependency to avoid errors due to concurrent builds.

---
 Makefile            | 33 ++++++++++++++++++++++++++++++++-
 arch/x86/Makefile   |  3 +++
 init/Kconfig        | 10 ++++++++++
 kernel/Makefile     |  1 +
 kernel/vdso_debug.c | 43 +++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 89 insertions(+), 1 deletion(-)
Quoted 2 lines
Quoted 2 lines

This seems to have fallen through the cracks; shall it be considered for kbuild-7.5?

Please don't pick this up just yet. I have a prototype which exposes the directory through sysfs directly without forcing users to unpack the archive. If you could take a look at the kbuild bits however, that would be great.

Quoted 3 lines

A thought: most tools support compressed separate debug information. Would it make more sense to have the vdso images with separate, compressed debug data in a subdirectory?

Quoted 6 lines

I want to stick to the 'make vdso_install' layout. Maybe that should be changed to your proposal, too? But what are the specific advantages? The files are compressed on disk anyways through the module compression.

Thomas

The nice thing would be that it would let debug tools use them as-is, and after all we need to make the vdso itself available anyway. As a possible side benefit the user would be able to see the post-patch vdso.

#15 lore raw
Quoted 46 lines · H. Peter Anvin
Quoted 45 lines · Thomas Weißschuh
Quoted 33 lines · H. Peter Anvin
Quoted 32 lines · Nicolas Schier
Quoted 30 lines · Thomas Weißschuh

Finding the debug version of the vDSO is not trivial as there is no common scheme where it is placed. That's especially problematic for CI testing.

The vDSO futex unlock mechanism requires for testing to have access to the inner labels of the unlock assembly, which are only accessible via the debug so.

Also for general debugging purposes it's convenient to have access to the debug vDSO at a well defined place.

The files are placed in /sys/kernel/vdso_debug.tar.xz. They use the regular 'make vdso_install' layout, including build-id symlinks to find the correct file for each process.

The design is kept close to the ones of the similar IKCONFIG and IKHEADERS.

On x86 the x32 vDSO is derived from the x86_64 one, necessitating an explicit dependency to avoid errors due to concurrent builds.

---
 Makefile            | 33 ++++++++++++++++++++++++++++++++-
 arch/x86/Makefile   |  3 +++
 init/Kconfig        | 10 ++++++++++
 kernel/Makefile     |  1 +
 kernel/vdso_debug.c | 43 +++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 89 insertions(+), 1 deletion(-)
Quoted 2 lines
Quoted 2 lines

This seems to have fallen through the cracks; shall it be considered for kbuild-7.5?

Please don't pick this up just yet. I have a prototype which exposes the directory through sysfs directly without forcing users to unpack the archive. If you could take a look at the kbuild bits however, that would be great.

Quoted 3 lines

A thought: most tools support compressed separate debug information. Would it make more sense to have the vdso images with separate, compressed debug data in a subdirectory?

Quoted 6 lines
Quoted 3 lines

I want to stick to the 'make vdso_install' layout. Maybe that should be changed to your proposal, too? But what are the specific advantages? The files are compressed on disk anyways through the module compression.

The nice thing would be that it would let debug tools use them as-is, and after all we need to make the vdso itself available anyway.

To make sure we are on the same page:
You propose to make the vDSO mapping a file-based one pointing to sysfs?

This would change the userspace ABI and I can imagine some tools breaking. Also it will require a bunch of additional per-architecture logic.

Tools should be able to handle the debug-id symlinks as implemented by my current scheme. For regular (real) file backed mappings there is no guarantee that the file on disk is still the same version that is mapped by the process.

Quoted 1 line

As a possible side benefit the user would be able to see the post-patch vdso.

Nice idea.

We could go with a combined aproach. First we go with my proposal which works with minimal per-architecture logic and already works for most of them as is. That can later be extended with per-architecture logic to provide the alternative-patched "live" view, file-backed mappings and detached debug symbols.

Thomas

#16 lore raw
Quoted 69 lines · Thomas Weißschuh
Quoted 46 lines · H. Peter Anvin
Quoted 45 lines · Thomas Weißschuh
Quoted 33 lines · H. Peter Anvin
Quoted 32 lines · Nicolas Schier
Quoted 30 lines · Thomas Weißschuh

Finding the debug version of the vDSO is not trivial as there is no common scheme where it is placed. That's especially problematic for CI testing.

The vDSO futex unlock mechanism requires for testing to have access to the inner labels of the unlock assembly, which are only accessible via the debug so.

Also for general debugging purposes it's convenient to have access to the debug vDSO at a well defined place.

The files are placed in /sys/kernel/vdso_debug.tar.xz. They use the regular 'make vdso_install' layout, including build-id symlinks to find the correct file for each process.

The design is kept close to the ones of the similar IKCONFIG and IKHEADERS.

On x86 the x32 vDSO is derived from the x86_64 one, necessitating an explicit dependency to avoid errors due to concurrent builds.

---
 Makefile            | 33 ++++++++++++++++++++++++++++++++-
 arch/x86/Makefile   |  3 +++
 init/Kconfig        | 10 ++++++++++
 kernel/Makefile     |  1 +
 kernel/vdso_debug.c | 43 +++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 89 insertions(+), 1 deletion(-)
Quoted 2 lines
Quoted 2 lines

This seems to have fallen through the cracks; shall it be considered for kbuild-7.5?

Please don't pick this up just yet. I have a prototype which exposes the directory through sysfs directly without forcing users to unpack the archive. If you could take a look at the kbuild bits however, that would be great.

Quoted 3 lines

A thought: most tools support compressed separate debug information. Would it make more sense to have the vdso images with separate, compressed debug data in a subdirectory?

Quoted 6 lines
Quoted 3 lines

I want to stick to the 'make vdso_install' layout. Maybe that should be changed to your proposal, too? But what are the specific advantages? The files are compressed on disk anyways through the module compression.

The nice thing would be that it would let debug tools use them as-is, and after all we need to make the vdso itself available anyway.

To make sure we are on the same page:
You propose to make the vDSO mapping a file-based one pointing to sysfs?

This would change the userspace ABI and I can imagine some tools breaking. Also it will require a bunch of additional per-architecture logic.

Tools should be able to handle the debug-id symlinks as implemented by my current scheme. For regular (real) file backed mappings there is no guarantee that the file on disk is still the same version that is mapped by the process.

Quoted 1 line

As a possible side benefit the user would be able to see the post-patch vdso.

Nice idea.

Quoted 7 lines

We could go with a combined aproach. First we go with my proposal which works with minimal per-architecture logic and already works for most of them as is. That can later be extended with per-architecture logic to provide the alternative-patched "live" view, file-backed mappings and detached debug symbols.

Thomas

I'm not necessarily saying the vma has to work that way, but the contents can be exported as a file regardless.

It might be nice to do that in the long run, but that's a separate project.