diff mbox series

[SRU,O,2/2] UBUNTU: [Packaging] Add list of used source files to buildinfo package

Message ID 8e08dcfccbaa3440edd066db33ad122e2fd361cc.1730725509.git.juerg.haefliger@canonical.com
State New
Headers show
Series Add list of source files to linux-buildinfo (LP: #2086606) | expand

Commit Message

Juerg Haefliger Nov. 5, 2024, 7:15 a.m. UTC
BugLink: https://bugs.launchpad.net/bugs/2086606

For CVE triaging, it's helpful to have a list of all the kernel source
files used for a particular build. Generate the list and add it to
the buildinfo package.

Signed-off-by: Juerg Haefliger <juerg.haefliger@canonical.com>
---
 debian.master/control.stub.in   |  1 +
 debian/rules.d/2-binary-arch.mk | 10 ++++++++++
 2 files changed, 11 insertions(+)
diff mbox series

Patch

diff --git a/debian.master/control.stub.in b/debian.master/control.stub.in
index 81730f7a22a4..744dce7bb70e 100644
--- a/debian.master/control.stub.in
+++ b/debian.master/control.stub.in
@@ -16,6 +16,7 @@  Build-Depends:
  debhelper-compat (= 10),
  default-jdk-headless <!stage1>,
  dkms <!stage1>,
+ dwarfdump <!stage1>,
  flex <!stage1>,
  gawk <!stage1>,
  java-common <!stage1>,
diff --git a/debian/rules.d/2-binary-arch.mk b/debian/rules.d/2-binary-arch.mk
index 137d975f0424..7864f764d76a 100644
--- a/debian/rules.d/2-binary-arch.mk
+++ b/debian/rules.d/2-binary-arch.mk
@@ -43,6 +43,14 @@  ifeq ($(do_dbgsym_package),true)
 		$(kmake) O=$(builddir)/build-$* $(conc_level) scripts_gdb ; \
 	fi
 endif
+
+	# Collect the list of kernel source files used for this build. Need to do this early
+	# before modules are stripped. Fail if the resulting file is empty.
+	find $(builddir)/build-$* -name vmlinux -o -name \*.ko -exec dwarfdump -i {} \; | \
+		grep -E 'DW_AT_(call|decl)_file' | sed -n 's|.*\s/|/|p' | sort -u > \
+		$(builddir)/build-$*/sources.list
+	test -s $(builddir)/build-$*/sources.list
+
 	$(stamp)
 
 define build_dkms_sign =
@@ -479,6 +487,8 @@  endif
 	fi
 	install -m644 $(DROOT)/canonical-certs.pem $(pkgdir_bldinfo)/usr/lib/linux/$(abi_release)-$*/canonical-certs.pem
 	install -m644 $(DROOT)/canonical-revoked-certs.pem $(pkgdir_bldinfo)/usr/lib/linux/$(abi_release)-$*/canonical-revoked-certs.pem
+	# List of source files used for this build
+	install -m644 $(builddir)/build-$*/sources.list $(pkgdir_bldinfo)/usr/lib/linux/$(abi_release)-$*/sources
 
 	# Get rid of .o and .cmd artifacts in headers
 	find $(hdrdir) -name \*.o -or -name \*.cmd -exec rm -f {} \;