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=1795301378; b=CdVSB7/x+QyK1OWejXdivav6zQ2t5jfCqtR+A//2oM7Yb0DR5C7YyeoLCBXv3LL85HLW IyASZCdfp0vvuELt/X6GYl2zaXtrVxTWfukrO7OnuHHSWsl/DXQUkfRpIDIGjjS7ocbHZ E372BKP7EdHw5M5PD4KEH2dRQpcA9lwCEP/e+74GGfKjf4hPsqVk5GLTJ6sH/8GBIx+lO F9WgMhL8HVZGa10M5oCJkenZde5KeetfldgleWfyFNd0hvshXlTHwkarIAm94CFKzBhdI tXHsYR6Z6Gsae3WETwB5n9+ThpyKnDXmwPsnjENDrK2f+trdXabSxNTCtrIG/hczfhw== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795301378; 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=H9hLFYdDcHGIG6tOFa8fYz6Aka6RgRcp8ANYo2cnmEs=; b=ndQkiGwarSnCWwTdYTPBGhotfmT80l0xKePUjUuae2tny45roGnFuAwZIpAMroW4srfN yt2yt5ws1Mp7pP9SAhgHJTDQO3+oQ2ChF+vkTNAPYxiuahstvPcSfmGujQ0jNGouhfg19 2BucUtPg+uccIuZuhWOvv5TMPpfIi8LCaxgBpfVM+LanfyJS/afVaUAT2A4ubO2Scn7QG dEfmNPOxp13QVun69Gqbb+wkUPx4dVxCUnKiZHMJtftpVSDu6xjAGnJ1SOQK9UvSsFM4K eCnJd/i0e1gTe/YNsItVVzsDaCYZVKbShjqX+UTP5R13mLOH5PnRKMtJR2VCeWgz97A== 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=JiKob9da; 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 CC1DA606A33C; Sat, 21 Nov 2026 22:49:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=JiKob9da 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=1795301378; b=rvaczIG6lujNJPZyAop5E62iC12wZEgvo0JR2J0qHxj3CqqG4z3XfGqwN1CEwk9p/lXx /rQmZ+6ULQrIWblZA92ZkXvItI26p8REIuemTB4jeIxYldLDrFGsXFHEe+HFcLtenQhfJ yp8st8lVt5EbOz7S6IsxEZ07xRE1Sghub0OF1JHUOYFdvBxk/7dop/GP4VLX79wfzpp4V Vlom3umfQgDnSmgnEzZo/o2XobrvqLYVVwB7slQjTh9AQCN9ym6vwRAfSObMEuY04Ew4n 1zlEjbxo0WCANveTTFbso8FLXRQuCNiOKwCkM6cSir5uZTPvm/cPG3eI4/jPjpaTKvg== ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; c=relaxed/relaxed; t=1795301378; 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=H9hLFYdDcHGIG6tOFa8fYz6Aka6RgRcp8ANYo2cnmEs=; b=iB6hVor2hLkVC7O1xzMluiPhi8VD59L+LBx/S8zsdzrmid0Qf0pRTp9uOWBMKqac6jJH JR6uZc3YZ5Yzq3GddriGQK9+5FF4sc2z+V6B4N4imFmbtb8vf57/W1YTPNtLbImaWUTvM la0K8LSxuNq7sMP7GiGQYJGKd/iDtFaSJiok/qmVTK3V9knM6cB/ee82HqSVaxhujGbV+ AHAuL5iiMWN45tJNcOoXrHE3SyAVdyEoZcP29x0hZCu/KjNFDfdbvkDpru7gsgJ4+eObe 4G8gALpbIZsICmJYDI1T1pOqd/Nf4LsX41DtA8HASqvA7ZSJCpqkoW+UZWwzD8m2Guw== 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 3B2E11F000CF; Sat, 21 Nov 2026 22:49:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795301378; bh=H9hLFYdDcHGIG6tOFa8fYz6Aka6RgRcp8ANYo2cnmEs=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To; b=JiKob9dazLAXBPGogjWSWKjjtlHDQU5eT73H2SWPpbh8AXyvMr7ypIPsBWWgLz/rU SrBg1riOmsSVSOokawQnzEwYKPH9LAZJEpauIvvw1Crn2WhbR+jHBvS2pos+vz/g+M KJWEu/LdQuSWEWlvLJeLxcoj7yR/hcJA6pXIxDy0t6qNHc4XH6nZwxibbSAxEVXaxI f/Np3Fw+pvtb7iAyWONqoATR5iadPyrjsaTNpQkDoFGllO3RdQIHI4JSffECEFLwCt f0+TYY0R7YL2sFsw6jpotDnliwfFpx3XE8l1hLF19E2U8Nwuc+vVtgWt+119fl2ZyT u/PahogTv/hfQ== Received: from nexus.subspace.kernel.org (localhost [IPv6:::1]) by lkml.kernel.org (Postfix) with ESMTP id BDA4C4BE5B; Sat, 21 Nov 2026 22:49:36 +0000 (UTC) From: Jim Cromie via B4 Relay Date: Sat, 21 Nov 2026 15:49:21 -0700 Subject: [PATCH 3/6] vmlinux.lds.h: Fix ALIGN(8) omission causing NULL ptr on i386 X-Mailing-List: linux-kernel@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: <20261121-vmlinux-lds-v1-3-49818f3f5cc0@gmail.com> References: <20261121-vmlinux-lds-v1-0-49818f3f5cc0@gmail.com> In-Reply-To: <20261121-vmlinux-lds-v1-0-49818f3f5cc0@gmail.com> To: Arnd Bergmann , Jason Baron , Luis Chamberlain , Petr Pavlu , Daniel Gomez , Sami Tolvanen , Aaron Tomlin , Andrew Morton Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-modules@vger.kernel.org, Jim Cromie , Louis Chauvet X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1795301375; l=6184; i=jim.cromie@gmail.com; s=20260203; h=from:subject:message-id; bh=/qgoDW7c7nR89lr2OZBZD5s7J3bChFTFpiNOOO/Q4r0=; b=Ix3MvBnzBnm8PcnchzNV855JArmYPkwAamXK4+x+C+3yYNwE7aH5o0wFx6OL9KFVdl0T4EV01 ZYvIfBSJv9nBqt9h/qS6xIyqmLhEchuIfaJcOaEwuLgv0F1PcTGxbkk 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 5fed4194983c..c570495d8de5 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) \ } /* @@ -679,7 +679,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) \ } \ BTF_INLINE \ BTF_INLINE_LINK \ @@ -871,16 +871,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); \ @@ -908,7 +909,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 @@ -937,13 +938,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.1