From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1793132533; b=OhSTz0gWNlCpTrcHsLoNAfbYkZ1l4QZm9NbVmjjQqYisQ8nKQcl188KG2q1VSQiQlqkj pRQdLRbFr/cD380FK+lAbm7SivoRmK9YdVv5YEk9bOrD3F+whcbiQkr4T4rRrSCmzwAMW pIm1jU4TpANjMBq44J6uPMj8F4HDy8ayCoGQUVNoHzVhf1qqotdzXKJj/EG4j+hqz70yI w+ZCdEbfubOmIcSkcU6OwMojntBodu5F2DGOKI3hyeAFImneSnz+uR3vBr6RlgkCurqan 6mjX0GeSLSW2YLEE61lufNRu/hAuF1bnGH9b69x2aBI6GZtS7lgDwddrFiGwDwbA7SQ== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793132533; h=Received:DKIM-Signature:Received:From:Date:Subject:MIME-Version: Content-Type:Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=WvoryfsLReniPM210uyHjxW2mBlmgQb/I7woegPoekg=; b=CFUD2Y1H6FSbBuJQ7XHsACT6SF7Kzw0SoUJr71gudg3xxx5JrIvY8i4JQivrjdsDPOEb JpK+ezOvj/4tytfzmh2PVaeuGf+RrlgGc/LtjwK3fYne553Ny5NIK8L7Dh/4V1FbURcnE DARtiu1za1viaxxXv32s37d4gozrHBCo6Q5k4FjRHVXDY6o1mdD1JISbZYFXg/NDj/MwW C4h+il2sJzYXGn5s5WE/74s68NfG7JH7zXvLIgEWvRgyBZW590CphWE1GP1QP6KkYo7G6 1FiMHgvKbtai3gj29RoZRanGjtdyQAxnU5pdmyCZXGKoSf0MM757jlm0LqFvTJN6Z8A== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=DXoGvWNj; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2EA97606A326; Tue, 27 Oct 2026 20:22:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=DXoGvWNj Authentication-Results: smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 ARC-Seal: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; cv=none; t=1793132532; b=oWP42g2dobMeEH/gm6JpdC4Rxpni/jubNMFHbjdvSCs65wCBsX/nNzVICNp0bTU0sia5 JqV2er5sp/L94DVQR01p0e7tAV/NLuFmwepeJ6OKymRM7xZVoJUWdiT+0e/eWQTAxcMNs FPfZGm9q5nGSld/GA8ZjIl9C65O1hy/cJDUUVHkk0C363347tR5GVRnMNgca3OPW4Q3Yz F56JeBjTumf4933iVw7bfOaDfrSgwZpWIxntafFJ47sKEJveFMo0GHTIPrWNzIrfDFXKT t/AJ5zSiajOlu0JurzgGrxNEUiSZF4B2ZitNX+4Di66T8KfJlcujHZ72Mv1/dYmBBwA== ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; c=relaxed/relaxed; t=1793132532; h=DKIM-Signature:Received:From:Date:Subject:MIME-Version:Content-Type: Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=WvoryfsLReniPM210uyHjxW2mBlmgQb/I7woegPoekg=; b=U9ljXzlvePSTrbe/33RPq389+MFaWLj8nylVTWA2rKVZr1V9SHytidGFfRLhxh9SqLok CB2HSbgU5ImICZ5ObGgooJSI7lbWVf+ZoBb8LTlZANiVGEIjDpnsSSQ72oum9/VlC6t5a u/p5tZurnjjlqolPQx5K1MBcfR9eVyrDa/7m+/Tu+c8sUs9n63FemGQ/S2p4s9AKwbpEB oPqNJprowjHOPPzBeHYcq2ig/v2c7CmwFD6haBRL7lZ/hLXqsmiP8hfwi1Ir66ARtwKiu 7aqjk18yQy4UzTA3pWyseboG6fuckrModhTBNp2VuJ1JJWIN2pzkzwof6/T+haMKVow== ARC-Authentication-Results: i=1; smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 Received: from lkml.kernel.org (nexus.subspace.kernel.org [100.80.115.77]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.kernel.org (Postfix) with ESMTPS id 3C67E1F031E1; Tue, 27 Oct 2026 20:22:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1793132532; bh=WvoryfsLReniPM210uyHjxW2mBlmgQb/I7woegPoekg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To; b=DXoGvWNjAjGbL0tXLJt0y1cNtAF7hU/X1TjsfvSIiWHEBk54BI5sraO0DtXG4Po2B ICxOwZBLLl8XEVoZPfjwdyc78m7D6ksb+H3UlsGPWpOLPq5OssSVtkb/38QvpWW8O4 pGSzeixvLtUuIhbdBtfhYcUx750aNOPro++wNqvau2Vh9ljs0on62ZHFvfiol5Kax0 K+1Pq2lq73ZBW6yFSDZSRXzsm/OFRyWjwN76Xf0r2zxfgwcQpnuNnpAq/gkM+T0Srx TiDY9q2gdJyON54u6obYT/TMjrvRWjS2ooXagUK3LmW22VBE0nRf/tAom2UqVIxcBA B/uYXd2LTxf0g== Received: from nexus.subspace.kernel.org (localhost [IPv6:::1]) by lkml.kernel.org (Postfix) with ESMTP id BA26445201; Tue, 27 Oct 2026 20:22:09 +0000 (UTC) From: Jim Cromie via B4 Relay Date: Tue, 27 Oct 2026 14:22:04 -0600 Subject: [PATCH v13 04/39] vmlinux.lds.h: Fix ALIGN(8) omission causing NULL ptr on i386 X-Mailing-List: linux-doc@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Message-Id: <20261027-dd-cmap-part2-clean-v13-4-9267923be612@gmail.com> References: <20261027-dd-cmap-part2-clean-v13-0-9267923be612@gmail.com> In-Reply-To: <20261027-dd-cmap-part2-clean-v13-0-9267923be612@gmail.com> To: Jason Baron , Shuah Khan , Andrew Morton , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Arnd Bergmann , Luis Chamberlain , Petr Pavlu , Daniel Gomez , Sami Tolvanen , Aaron Tomlin , Jonathan Corbet , Greg Kroah-Hartman , Nathan Chancellor , Nicolas Schier , Shuah Khan , Randy Dunlap , "Rafael J. Wysocki" , Pavel Machek , Len Brown , Jonathan Corbet , Petr Mladek , Steven Rostedt , John Ogness , Sergey Senozhatsky , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , "Jason A. Donenfeld" Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arch@vger.kernel.org, linux-modules@vger.kernel.org, linux-doc@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-pm@vger.kernel.org, Jason Baron , Jim Cromie , Louis Chauvet X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1793132527; l=6221; i=jim.cromie@gmail.com; s=20260203; h=from:subject:message-id; bh=f8FtvoZfeQ6c/NMIwKnCyVl6/fclxMKMtCi8B+MVaA8=; b=S8gr3t+aoV5lZFitKsEWUd456dNN3CGchlSPh9Tjz61CfB1xxisTgzxr7wmtQO7I4LO2Q1UE4 T3+3gwN7aq9DLuzSSwWq003osius6r9tkEwnlnN7dwyoyWuXLcXtfyr X-Developer-Key: i=jim.cromie@gmail.com; a=ed25519; pk=C6E5ODlPQo7ZBynATXH9wg7K6HxP0pIXyf4s38Qw0XE= X-Endpoint-Received: by B4 Relay for jim.cromie@gmail.com/20260203 with auth_id=958 X-Original-From: Jim Cromie Reply-To: jim.cromie@gmail.com Content-Transfer-Encoding: 7bit From: Jim Cromie Almost all uses of the BOUNDED_SECTION macros are ALIGN(8), either explicitly, or by being below an aligned section containing x*8 byte objects. The noteworthy exception is BOUNDED_SECTION(__dyndbg), which immediately follows BOUNDED_SECTION(__dyndbg_classes). On i386, struct _ddebug_classmap is 28 bytes, so without an explicit ALIGN(8) in the macro, the following __dyndbg section gets misaligned, causing a NULL ptr deref in dynamic_debug_init(). So fix this with an explicit ALIGN(8) in the existing BOUNDED_SECTION macros, and introduce _ALIGNED variants to handle the cases with an explicit . = ALIGN(x) Also add explicit alignments for: EXCEPTION_TABLE, ORC_UNWIND_TABLE, TRACEDATA, INIT_SETUP, and NOTES. update BOUNDED_SECTION uses inside . = ALIGN(x) stanzas to use _ALIGNED variants, but keep the outer ALIGNs so the symbols between them are not "re-aligned". In particular, scripts/sorttable.c does not tolerate sloppy padding. At the top of ORC_UNWIND_TABLE, add . = ALIGN(4) to match the struct orc_header __align() call in the code: commit b9f174c811e3 ("x86/unwind/orc: Add ELF section with ORC version identifier") Suggested-by: Louis Chauvet # _ALIGNED variants. Link: https://lore.kernel.org/lkml/177402491426.6181.12855763650074831089.b4-review@b4/ Signed-off-by: Jim Cromie --- v3: sashiko complained about NOTES and .BTF_ids. gemini asserts that NOTES are natively 4-byte aligned, add comment repeating it. .BTF_ids doesnt use BOUNDED_BY, since start/end isnt needed; sashiko evidently got confused by immediately preceding usage. v2: sashiko picked up 2 cases, added to the explicit list above https://sashiko.dev/#/patchset/20260515-asm-generic-1-v3-0-680b273666d4%40gmail.com --- include/asm-generic/bounded_sections.lds.h | 17 ++++++++++++++--- include/asm-generic/vmlinux.lds.h | 18 ++++++++++-------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/include/asm-generic/bounded_sections.lds.h b/include/asm-generic/bounded_sections.lds.h index 268cdc34389b..8ff3e3420f60 100644 --- a/include/asm-generic/bounded_sections.lds.h +++ b/include/asm-generic/bounded_sections.lds.h @@ -3,19 +3,30 @@ #ifndef _ASM_GENERIC_BOUNDED_SECTIONS_H #define _ASM_GENERIC_BOUNDED_SECTIONS_H -#define BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_) \ +#define BOUNDED_SECTION_PRE_LABEL_ALIGNED(_sec_, _label_, _BEGIN_, _END_, _ALIGNED_) \ + . = ALIGN(_ALIGNED_); \ _BEGIN_##_label_ = .; \ KEEP(*(_sec_)) \ _END_##_label_ = .; -#define BOUNDED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_) \ +#define BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_) \ + BOUNDED_SECTION_PRE_LABEL_ALIGNED(_sec_, _label_, _BEGIN_, _END_, 8) + +#define BOUNDED_SECTION_POST_LABEL_ALIGNED(_sec_, _label_, _BEGIN_, _END_, _ALIGNED_) \ + . = ALIGN(_ALIGNED_); \ _label_##_BEGIN_ = .; \ KEEP(*(_sec_)) \ _label_##_END_ = .; +#define BOUNDED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_) \ + BOUNDED_SECTION_POST_LABEL_ALIGNED(_sec_, _label_, _BEGIN_, _END_, 8) + #define BOUNDED_SECTION_BY(_sec_, _label_) \ BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, __start, __stop) -#define BOUNDED_SECTION(_sec) BOUNDED_SECTION_BY(_sec, _sec) +#define BOUNDED_SECTION_BY_ALIGNED(_sec_, _label_, _ALIGNED_) \ + BOUNDED_SECTION_PRE_LABEL_ALIGNED(_sec_, _label_, __start, __stop, _ALIGNED_) + +#define BOUNDED_SECTION(_sec) BOUNDED_SECTION_BY(_sec, _sec) #endif /* _ASM_GENERIC_BOUNDED_SECTIONS_H */ diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index b4ece391f7b1..b1a69f8af6d2 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -640,7 +640,7 @@ #define EXCEPTION_TABLE(align) \ . = ALIGN(align); \ __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) { \ - BOUNDED_SECTION_BY(__ex_table, ___ex_table) \ + BOUNDED_SECTION_BY_ALIGNED(__ex_table, ___ex_table, align) \ } /* @@ -650,7 +650,7 @@ #define BTF \ . = ALIGN(PAGE_SIZE); \ .BTF : AT(ADDR(.BTF) - LOAD_OFFSET) { \ - BOUNDED_SECTION_BY(.BTF, _BTF) \ + BOUNDED_SECTION_BY_ALIGNED(.BTF, _BTF, PAGE_SIZE) \ } \ . = ALIGN(PAGE_SIZE); \ .BTF_ids : AT(ADDR(.BTF_ids) - LOAD_OFFSET) { \ @@ -840,16 +840,17 @@ #ifdef CONFIG_UNWINDER_ORC #define ORC_UNWIND_TABLE \ + . = ALIGN(4); \ .orc_header : AT(ADDR(.orc_header) - LOAD_OFFSET) { \ - BOUNDED_SECTION_BY(.orc_header, _orc_header) \ + BOUNDED_SECTION_BY_ALIGNED(.orc_header, _orc_header, 4) \ } \ . = ALIGN(4); \ .orc_unwind_ip : AT(ADDR(.orc_unwind_ip) - LOAD_OFFSET) { \ - BOUNDED_SECTION_BY(.orc_unwind_ip, _orc_unwind_ip) \ + BOUNDED_SECTION_BY_ALIGNED(.orc_unwind_ip, _orc_unwind_ip, 4)\ } \ . = ALIGN(2); \ .orc_unwind : AT(ADDR(.orc_unwind) - LOAD_OFFSET) { \ - BOUNDED_SECTION_BY(.orc_unwind, _orc_unwind) \ + BOUNDED_SECTION_BY_ALIGNED(.orc_unwind, _orc_unwind, 2) \ } \ text_size = _etext - _stext; \ . = ALIGN(4); \ @@ -877,7 +878,7 @@ #define TRACEDATA \ . = ALIGN(4); \ .tracedata : AT(ADDR(.tracedata) - LOAD_OFFSET) { \ - BOUNDED_SECTION_POST_LABEL(.tracedata, __tracedata, _start, _end) \ + BOUNDED_SECTION_POST_LABEL_ALIGNED(.tracedata, __tracedata, _start, _end, 4) \ } #else #define TRACEDATA @@ -906,13 +907,14 @@ *(.note.gnu.property) \ } \ .notes : AT(ADDR(.notes) - LOAD_OFFSET) { \ - BOUNDED_SECTION_BY(.note.*, _notes) \ + /* *(.note.*) are natively 4-byte aligned */ \ + BOUNDED_SECTION_BY_ALIGNED(.note.*, _notes, 4) \ } NOTES_HEADERS \ NOTES_HEADERS_RESTORE #define INIT_SETUP(initsetup_align) \ . = ALIGN(initsetup_align); \ - BOUNDED_SECTION_POST_LABEL(.init.setup, __setup, _start, _end) + BOUNDED_SECTION_POST_LABEL_ALIGNED(.init.setup, __setup, _start, _end, initsetup_align) #define INIT_CALLS_LEVEL(level) \ __initcall##level##_start = .; \ -- 2.56.0