lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240910094459.352572-1-masahiroy@kernel.org>
Date: Tue, 10 Sep 2024 18:44:52 +0900
From: Masahiro Yamada <masahiroy@...nel.org>
To: linux-kbuild@...r.kernel.org
Cc: devicetree@...r.kernel.org,
	Rob Herring <robh+dt@...nel.org>,
	linux-arch@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	Masahiro Yamada <masahiroy@...nel.org>
Subject: [PATCH v2 1/3] modpost: check section mismatch in reference to .dtb.init.rodata

Built-in DTB files are discarded because KERNEL_DTB() is a part of
INIT_DATA, as defined in include/asm-generic/vmlinux.lds.h.

Currently, modpost warns about mismatched section references to init
data only when the destination section is prefixed with ".init.".
However, ".dtb.init.rodata" is also discarded.

This commit has revealed some missing annotations.

overlays[] references builtin DTBs, which become dangling pointers
after early boot.

testdrv_probe() is not an __init function, yet it holds a reference to
overlays[]. The assumption is that this function is executed only at
the boot time even though it remains in memory. I annotated it as __ref
because otherwise I do not know how to suppress the modpost warning.

I marked the dtb_start as __initdata in the Xtensa boot code, although
modpost does not warn about it because __dtb_start is not yet defined
at the time of modpost.

Signed-off-by: Masahiro Yamada <masahiroy@...nel.org>
---

Changes in v2:
  - New patch

 arch/xtensa/kernel/setup.c | 2 +-
 drivers/of/unittest.c      | 5 +++--
 scripts/mod/modpost.c      | 2 +-
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/arch/xtensa/kernel/setup.c b/arch/xtensa/kernel/setup.c
index bdec4a773af0..d9f290cf726e 100644
--- a/arch/xtensa/kernel/setup.c
+++ b/arch/xtensa/kernel/setup.c
@@ -55,7 +55,7 @@ extern int initrd_below_start_ok;
 #endif
 
 #ifdef CONFIG_USE_OF
-void *dtb_start = __dtb_start;
+static __initdata void *dtb_start = __dtb_start;
 #endif
 
 extern unsigned long loops_per_jiffy;
diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
index fd8cb931b1cc..56516bf4171d 100644
--- a/drivers/of/unittest.c
+++ b/drivers/of/unittest.c
@@ -3585,7 +3585,7 @@ OVERLAY_INFO_EXTERN(overlay_bad_symbol);
 OVERLAY_INFO_EXTERN(overlay_bad_unresolved);
 
 /* entries found by name */
-static struct overlay_info overlays[] = {
+static __initdata struct overlay_info overlays[] = {
 	OVERLAY_INFO(overlay_base, -9999, 0),
 	OVERLAY_INFO(overlay, 0, 0),
 	OVERLAY_INFO(overlay_0, 0, 0),
@@ -4054,7 +4054,8 @@ static const struct pci_device_id testdrv_pci_ids[] = {
 	{ 0, }
 };
 
-static int testdrv_probe(struct pci_dev *pdev, const struct pci_device_id *id)
+/* testdrv_probe() references overlays[], which is discarded data  */
+static int __ref testdrv_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 {
 	struct overlay_info *info;
 	struct device_node *dn;
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 107393a8c48a..2e4b0816fdc1 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -776,7 +776,7 @@ static void check_section(const char *modname, struct elf_info *elf,
 	".pci_fixup_enable", ".pci_fixup_resume", \
 	".pci_fixup_resume_early", ".pci_fixup_suspend"
 
-#define ALL_INIT_SECTIONS ".init.*"
+#define ALL_INIT_SECTIONS ".init.*", ".dtb.init.rodata"
 #define ALL_EXIT_SECTIONS ".exit.*"
 
 #define DATA_SECTIONS ".data", ".data.rel"
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ