Skip to contentSkip to conversation

v6.13-rc1: Module signing stopped working for external modules

PATCH Superseded Torsten Hilbrich 2 participants 7 messages Jan 9, 2025 – Jan 14, 2025 Kbuild

lore
Share & tools
lore
#0 lore raw

Hello,

after testing v6.13-rc1 after successfully using v6.12 I noticed that our external modules are no longer building correctly.

- Module source: /build/client/devel/addmodules/vtx/work/vtx
- Kernel source: /build/client/devel/kernel/work/linux-2.6 Symlinked by build-source

We run the module_install step:

----------------
make -C build-source M=/build/client/devel/addmodules/vtx/work/vtx modules_install INSTALL_MOD_PATH=/build/client/devel/addmodules/vtx/_ INSTALL_MOD_DIR=extra make[5]: Entering directory '/build/client/devel/kernel/work/linux-2.6'
make[6]: Entering directory '/build/client/devel/addmodules/vtx/work/vtx'
INSTALL /build/client/devel/addmodules/vtx/_/lib/modules/6.13.0-devel+/extra/vtx.ko
SIGN /build/client/devel/addmodules/vtx/_/lib/modules/6.13.0-devel+/extra/vtx.ko
/bin/sh: 1: scripts/sign-file: not found
DEPMOD /build/client/devel/addmodules/vtx/_/lib/modules/6.13.0-devel+
make[6]: Leaving directory '/build/client/devel/addmodules/vtx/work/vtx'
make[5]: Leaving directory '/build/client/devel/kernel/work/linux-2.6'
----------------

The problem here is that before calling cmd_sign (scripts/sign-file) the build system now changes to the module source.

In v6.12 the build system was still in the kernel source tree when running this command so "scripts/sign-file" was found.

Here from a build log with a 6.8.12 kernel (/build/client/daily/kernel/work/linux-2.6 being the kernel source here):

----------------
make[4]: Entering directory '/build/client/daily/addmodules/vtx/work/vtx'
make -C build-source M=/build/client/daily/addmodules/vtx/work/vtx modules_install INSTALL_MOD_PATH=/build/client/daily/addmodules/vtx/_ INSTALL_MOD_DIR=extra make[5]: Entering directory '/build/client/daily/kernel/work/linux-2.6'
INSTALL /build/client/daily/addmodules/vtx/_/lib/modules/6.8.12-grsec+/extra/vtx.ko
SIGN /build/client/daily/addmodules/vtx/_/lib/modules/6.8.12-grsec+/extra/vtx.ko
DEPMOD /build/client/daily/addmodules/vtx/_/lib/modules/6.8.12-grsec+
make[5]: Leaving directory '/build/client/daily/kernel/work/linux-2.6'
----------------

Here the sign-file call is made with cwd being the kernel source.

I also tried the new method in v6.13 by invoking "make -f /build/client/devel/kernel/work/linux-2.6/Makefile" with the same result.

Here is the relevant part of our Makefile for building the module:

----------------
TARGETS = vtx

obj-m := vtx.o

vtx-objs := main.o intel.o amd.o
subdir = extra

KERNEL_SOURCE ?= build-source
BUILD = $(MAKE) -C $(KERNEL_SOURCE) M=$(CURDIR)

.PHONY: all install clean

all:

    ln -sf $(KERNEL_SOURCE) build-source
    $(BUILD)

clean:

    $(BUILD) $@

install:

    $(BUILD) modules_install INSTALL_MOD_PATH=$(DESTDIR) INSTALL_MOD_DIR=$(subdir)

----------------

KERNEL_SOURCE is suppliced when running the all target. DESTDIR is supplied when running install.

The module_sign target fails as well.

I already consulted the updated documentation but couldn't find any problem in that invocation (which still works in v6.12).

Thanks,

Torsten

#1 lore raw
Quoted 10 lines · Torsten Hilbrich

Hello,

after testing v6.13-rc1 after successfully using v6.12 I noticed that our external modules are no longer building correctly.

- Module source: /build/client/devel/addmodules/vtx/work/vtx
- Kernel source: /build/client/devel/kernel/work/linux-2.6 Symlinked by build-source

We run the module_install step:

Quoted 14 lines

----------------
make -C build-source M=/build/client/devel/addmodules/vtx/work/vtx modules_install INSTALL_MOD_PATH=/build/client/devel/addmodules/vtx/_ INSTALL_MOD_DIR=extra make[5]: Entering directory '/build/client/devel/kernel/work/linux-2.6'
make[6]: Entering directory '/build/client/devel/addmodules/vtx/work/vtx'
  INSTALL
/build/client/devel/addmodules/vtx/_/lib/modules/6.13.0-devel+/extra/vtx.ko
  SIGN
/build/client/devel/addmodules/vtx/_/lib/modules/6.13.0-devel+/extra/vtx.ko
/bin/sh: 1: scripts/sign-file: not found
  DEPMOD  /build/client/devel/addmodules/vtx/_/lib/modules/6.13.0-devel+
make[6]: Leaving directory '/build/client/devel/addmodules/vtx/work/vtx'
make[5]: Leaving directory '/build/client/devel/kernel/work/linux-2.6'
---------------->
The problem here is that before calling cmd_sign (scripts/sign-file) the build system now changes to the module source.

As workaround I used the following modification:

scripts/Makefile.modinst +1 -1
index 6fa9af4a25b4..67f081a68364 100644
@@ -105,7 +105,7 @@ else
 sig-key := $(CONFIG_MODULE_SIG_KEY)
 endif
 quiet_cmd_sign = SIGN    $@
-      cmd_sign = scripts/sign-file $(CONFIG_MODULE_SIG_HASH) "$(sig-key)" certs/signing_key.x509 $@ \
+      cmd_sign = $(srctree)/scripts/sign-file $(CONFIG_MODULE_SIG_HASH) "$(sig-key)" $(srctree)/certs/signing_key.x509 $@ \
                  $(if $(KBUILD_EXTMOD),|| true)
 
 ifeq ($(sign-only),)

I first fixed the sign-file invocation, then I got errors like the following:

SIGN /build/client/devel/addmodules/vtx/_/lib/modules/6.13.0-devel+/extra/vtx.ko
At main.c:189:
- SSL error:FFFFFFFF80000002:system library::No such file or directory: crypto/bio/bss_file.c:67
- SSL error:10000080:BIO routines::no such file: crypto/bio/bss_file.c:75
sign-file: certs/signing_key.x509
DEPMOD /build/client/devel/addmodules/vtx/_/lib/modules/6.13.0-devel+

Adding $(srctree) for both the program and the signing key fixed the issue.

I assume the root issue is a different beast but I was not able to find it.

Thanks,

Torsten

#2 lore raw
Quoted 38 lines · Torsten Hilbrich
Quoted 20 lines · Torsten Hilbrich

Hello,

after testing v6.13-rc1 after successfully using v6.12 I noticed that our external modules are no longer building correctly.

- Module source: /build/client/devel/addmodules/vtx/work/vtx
- Kernel source: /build/client/devel/kernel/work/linux-2.6 Symlinked by build-source

We run the module_install step:

----------------
make -C build-source M=/build/client/devel/addmodules/vtx/work/vtx modules_install INSTALL_MOD_PATH=/build/client/devel/addmodules/vtx/_ INSTALL_MOD_DIR=extra
make[5]: Entering directory '/build/client/devel/kernel/work/linux-2.6' make[6]: Entering directory '/build/client/devel/addmodules/vtx/work/vtx'
INSTALL
/build/client/devel/addmodules/vtx/_/lib/modules/6.13.0-devel+/extra/vtx.ko
SIGN

Quoted 8 lines

/build/client/devel/addmodules/vtx/_/lib/modules/6.13.0-devel+/extra/vtx.ko /bin/sh: 1: scripts/sign-file: not found
DEPMOD /build/client/devel/addmodules/vtx/_/lib/modules/6.13.0-devel+
make[6]: Leaving directory '/build/client/devel/addmodules/vtx/work/vtx' make[5]: Leaving directory '/build/client/devel/kernel/work/linux-2.6' ---------------->
The problem here is that before calling cmd_sign (scripts/sign-file) the build system now changes to the module source.

As workaround I used the following modification:

scripts/Makefile.modinst +0 -0
index 6fa9af4a25b4..67f081a68364 100644

scripts/Makefile.modinst else · line 110

Quoted 7 lines
scripts/Makefile.modinst +1 -1
@@ -105,7 +105,7 @@ else
  sig-key := $(CONFIG_MODULE_SIG_KEY)
  endif
  quiet_cmd_sign = SIGN    $@
-      cmd_sign = scripts/sign-file $(CONFIG_MODULE_SIG_HASH) "$(sig-key)" certs/signing_key.x509 $@ \
+      cmd_sign = $(srctree)/scripts/sign-file $(CONFIG_MODULE_SIG_HASH) "$(sig-key)" $(srctree)/certs/signing_key.x509 $@ \
                   $(if $(KBUILD_EXTMOD),|| true)
 

Please add $(objtree)/ instead of $(srctree)/
in case the kernel was O= option.

Please submit a patch with this tag.

Fixes 13b25489b6f8 ("kbuild: change working directory to external

module directory with M=")

Then, I will pick it up.
Thanks.

Signature · 2 lines
Best Regards
Masahiro Yamada
#3 lore raw

PATCH 1/1 kbuild: Fix signing issue for external modules

When running the sign script the kernel is within the source directory of external modules. This caused issues when the kernel uses relative paths, like:

make[5]: Entering directory '/build/client/devel/kernel/work/linux-2.6' make[6]: Entering directory '/build/client/devel/addmodules/vtx/work/vtx'
INSTALL /build/client/devel/addmodules/vtx/_/lib/modules/6.13.0-devel+/extra/vtx.ko
SIGN /build/client/devel/addmodules/vtx/_/lib/modules/6.13.0-devel+/extra/vtx.ko
/bin/sh: 1: scripts/sign-file: not found
DEPMOD /build/client/devel/addmodules/vtx/_/lib/modules/6.13.0-devel+

Working around it by using absolute pathes here.

Fixes 13b25489b6f8 ("kbuild: change working directory to external module directory with M=")

Issue: CLIENT-32662

---
 scripts/Makefile.modinst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/Makefile.modinst +1 -1
index f97c9926ed31..1628198f3e83 100644
@@ -105,7 +105,7 @@ else
 sig-key := $(CONFIG_MODULE_SIG_KEY)
 endif
 quiet_cmd_sign = SIGN    $@
-      cmd_sign = scripts/sign-file $(CONFIG_MODULE_SIG_HASH) "$(sig-key)" certs/signing_key.x509 $@ \
+      cmd_sign = $(objtree)/scripts/sign-file $(CONFIG_MODULE_SIG_HASH) "$(sig-key)" $(objtree)/certs/signing_key.x509 $@ \
                  $(if $(KBUILD_EXTMOD),|| true)
 
 ifeq ($(sign-only),)
Signature · 1 line
2.39.5
#4 lore raw

Re: [PATCH] kbuild: Fix signing issue for external modules

Quoted 12 lines · Torsten Hilbrich

When running the sign script the kernel is within the source directory of external modules. This caused issues when the kernel uses relative paths, like:

make[5]: Entering directory '/build/client/devel/kernel/work/linux-2.6' make[6]: Entering directory '/build/client/devel/addmodules/vtx/work/vtx'
INSTALL /build/client/devel/addmodules/vtx/_/lib/modules/6.13.0-devel+/extra/vtx.ko
SIGN /build/client/devel/addmodules/vtx/_/lib/modules/6.13.0-devel+/extra/vtx.ko
/bin/sh: 1: scripts/sign-file: not found
DEPMOD /build/client/devel/addmodules/vtx/_/lib/modules/6.13.0-devel+

Quoted 5 lines

Working around it by using absolute pathes here.

Fixes 13b25489b6f8 ("kbuild: change working directory to external module directory with M=")

Issue: CLIENT-32662

Please drop this tag.

Instead, your Signed-off-by tag is mandatory.

Quoted 22 lines
---
  scripts/Makefile.modinst | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
scripts/Makefile.modinst +1 -2
index f97c9926ed31..1628198f3e83 100644
@@ -105,7 +105,7 @@ else
  sig-key := $(CONFIG_MODULE_SIG_KEY)
  endif
  quiet_cmd_sign = SIGN    $@
-      cmd_sign = scripts/sign-file $(CONFIG_MODULE_SIG_HASH) "$(sig-key)" certs/signing_key.x509 $@ \
+      cmd_sign = $(objtree)/scripts/sign-file $(CONFIG_MODULE_SIG_HASH) "$(sig-key)" $(objtree)/certs/signing_key.x509 $@ \
                   $(if $(KBUILD_EXTMOD),|| true)
 
  ifeq ($(sign-only),)
--

2.39.5

Signature · 2 lines
Best Regards
Masahiro Yamada
#5 lore raw

PATCH v2 1/1 kbuild: Fix signing issue for external modules

When running the sign script the kernel is within the source directory of external modules. This caused issues when the kernel uses relative paths, like:

make[5]: Entering directory '/build/client/devel/kernel/work/linux-2.6' make[6]: Entering directory '/build/client/devel/addmodules/vtx/work/vtx'
INSTALL /build/client/devel/addmodules/vtx/_/lib/modules/6.13.0-devel+/extra/vtx.ko
SIGN /build/client/devel/addmodules/vtx/_/lib/modules/6.13.0-devel+/extra/vtx.ko
/bin/sh: 1: scripts/sign-file: not found
DEPMOD /build/client/devel/addmodules/vtx/_/lib/modules/6.13.0-devel+

Working around it by using absolute pathes here.

Fixes 13b25489b6f8 ("kbuild: change working directory to external module directory with M=")
---
 scripts/Makefile.modinst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/Makefile.modinst +1 -1
index f97c9926ed31..1628198f3e83 100644
@@ -105,7 +105,7 @@ else
 sig-key := $(CONFIG_MODULE_SIG_KEY)
 endif
 quiet_cmd_sign = SIGN    $@
-      cmd_sign = scripts/sign-file $(CONFIG_MODULE_SIG_HASH) "$(sig-key)" certs/signing_key.x509 $@ \
+      cmd_sign = $(objtree)/scripts/sign-file $(CONFIG_MODULE_SIG_HASH) "$(sig-key)" $(objtree)/certs/signing_key.x509 $@ \
                  $(if $(KBUILD_EXTMOD),|| true)
 
 ifeq ($(sign-only),)
Signature · 1 line
2.39.5
#6 lore raw

Re: [PATCH v2] kbuild: Fix signing issue for external modules

Quoted 12 lines · Torsten Hilbrich

When running the sign script the kernel is within the source directory of external modules. This caused issues when the kernel uses relative paths, like:

make[5]: Entering directory '/build/client/devel/kernel/work/linux-2.6' make[6]: Entering directory '/build/client/devel/addmodules/vtx/work/vtx'
INSTALL /build/client/devel/addmodules/vtx/_/lib/modules/6.13.0-devel+/extra/vtx.ko
SIGN /build/client/devel/addmodules/vtx/_/lib/modules/6.13.0-devel+/extra/vtx.ko
/bin/sh: 1: scripts/sign-file: not found
DEPMOD /build/client/devel/addmodules/vtx/_/lib/modules/6.13.0-devel+

Quoted 6 lines

Working around it by using absolute pathes here.

Fixes 13b25489b6f8 ("kbuild: change working directory to external module directory with M=")

---

Applied to linux-kbuild.
Thanks!

Signature · 2 lines
Best Regards
Masahiro Yamada