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-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240129192644.3359978-3-mcgrof@kernel.org>
Date: Mon, 29 Jan 2024 11:26:41 -0800
From: Luis Chamberlain <mcgrof@...nel.org>
To: masahiroy@...nel.org,
	deller@....de
Cc: mcgrof@...nel.org,
	arnd@...db.de,
	linux-arch@...r.kernel.org,
	linux-modules@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: [PATCH v2 2/4] modules: Ensure 64-bit alignment on __ksymtab_* sections

From: Helge Deller <deller@....de>

On 64-bit architectures without CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
(e.g. ppc64, ppc64le, parisc, s390x,...) the __KSYM_REF() macro stores
64-bit pointers into the __ksymtab* sections.
Make sure that those sections will be correctly aligned at module link time,
otherwise unaligned memory accesses may happen at runtime.

The __kcrctab* sections store 32-bit entities, so use ALIGN(4) for those.

Testing with the kallsyms selftest on x86_64 we see a savings of about
1,958,153 ns in the worst case which may or not be within noise. Testing
on parisc would be useful and welcomed.

On x86_64 before:

 Performance counter stats for '/sbin/modprobe test_kallsyms_b':

        86,430,119 ns   duration_time
        84,407,000 ns   system_time
               213      page-faults

       0.086430119 seconds time elapsed

       0.000000000 seconds user
       0.084407000 seconds sys

 Performance counter stats for '/sbin/modprobe test_kallsyms_b':

        85,777,474 ns   duration_time
        82,581,000 ns   system_time
               212      page-faults

       0.085777474 seconds time elapsed

       0.000000000 seconds user
       0.082581000 seconds sys

 Performance counter stats for '/sbin/modprobe test_kallsyms_b':

        87,906,053 ns   duration_time
        87,939,000 ns   system_time
               212      page-faults

       0.087906053 seconds time elapsed

       0.000000000 seconds user
       0.087939000 seconds sys

After:

 Performance counter stats for '/sbin/modprobe test_kallsyms_b':

        82,925,631 ns   duration_time
        83,000,000 ns   system_time
               212      page-faults

       0.082925631 seconds time elapsed

       0.000000000 seconds user
       0.083000000 seconds sys

 Performance counter stats for '/sbin/modprobe test_kallsyms_b':

        87,776,380 ns   duration_time
        86,678,000 ns   system_time
               213      page-faults

       0.087776380 seconds time elapsed

       0.000000000 seconds user
       0.086678000 seconds sys

 Performance counter stats for '/sbin/modprobe test_kallsyms_b':

        85,947,900 ns   duration_time
        82,006,000 ns   system_time
               212      page-faults

       0.085947900 seconds time elapsed

       0.000000000 seconds user
       0.082006000 seconds sys

Signed-off-by: Helge Deller <deller@....de>
[mcgrof: ran kallsyms selftests on x86_64]
Signed-off-by: Luis Chamberlain <mcgrof@...nel.org>
---
 scripts/module.lds.S | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/scripts/module.lds.S b/scripts/module.lds.S
index bf5bcf2836d8..b00415a9ff27 100644
--- a/scripts/module.lds.S
+++ b/scripts/module.lds.S
@@ -15,10 +15,10 @@ SECTIONS {
 		*(.discard.*)
 	}
 
-	__ksymtab		0 : { *(SORT(___ksymtab+*)) }
-	__ksymtab_gpl		0 : { *(SORT(___ksymtab_gpl+*)) }
-	__kcrctab		0 : { *(SORT(___kcrctab+*)) }
-	__kcrctab_gpl		0 : { *(SORT(___kcrctab_gpl+*)) }
+	__ksymtab		0 : ALIGN(8) { *(SORT(___ksymtab+*)) }
+	__ksymtab_gpl		0 : ALIGN(8) { *(SORT(___ksymtab_gpl+*)) }
+	__kcrctab		0 : ALIGN(4) { *(SORT(___kcrctab+*)) }
+	__kcrctab_gpl		0 : ALIGN(4) { *(SORT(___kcrctab_gpl+*)) }
 
 	.ctors			0 : ALIGN(8) { *(SORT(.ctors.*)) *(.ctors) }
 	.init_array		0 : ALIGN(8) { *(SORT(.init_array.*)) *(.init_array) }
-- 
2.42.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ