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: <bibraqfzt22adfii3emorei7lobdhjnmfrfv3n4cd7f22k73s4@jbxclgfc6fgi>
Date: Wed, 4 Jun 2025 21:00:58 -0700
From: Josh Poimboeuf <jpoimboe@...nel.org>
To: Peter Zijlstra <peterz@...radead.org>
Cc: x86@...nel.org, linux-kernel@...r.kernel.org, 
	Petr Mladek <pmladek@...e.com>, Miroslav Benes <mbenes@...e.cz>, 
	Joe Lawrence <joe.lawrence@...hat.com>, live-patching@...r.kernel.org, Song Liu <song@...nel.org>, 
	laokz <laokz@...mail.com>, Jiri Kosina <jikos@...nel.org>, 
	Marcos Paulo de Souza <mpdesouza@...e.com>, Weinan Liu <wnliu@...gle.com>, 
	Fazla Mehrab <a.mehrab@...edance.com>, Chen Zhongjin <chenzhongjin@...wei.com>, 
	Puranjay Mohan <puranjay@...nel.org>, Masahiro Yamada <masahiroy@...nel.org>
Subject: Re: [PATCH v2 42/62] kbuild,x86: Fix module permissions for
 __jump_table and __bug_table

On Wed, Jun 04, 2025 at 05:22:15PM -0700, Josh Poimboeuf wrote:
> On Mon, May 26, 2025 at 01:06:34PM +0200, Peter Zijlstra wrote:
> > On Fri, May 09, 2025 at 01:17:06PM -0700, Josh Poimboeuf wrote:
> > > An upcoming patch will add the SHF_MERGE flag to x86 __jump_table and
> > > __bug_table so their entry sizes can be defined in inline asm.
> > > 
> > > However, those sections have SHF_WRITE, which the Clang linker (lld)
> > > explicitly forbids combining with SHF_MERGE.
> > > 
> > > Those sections are modified at runtime and must remain writable.  While
> > > SHF_WRITE is ignored by vmlinux, it's still needed for modules.
> > > 
> > > To work around the linker interference, remove SHF_WRITE during
> > > compilation and restore it after linking the module.
> > 
> > *groan*
> > 
> > This and the following patches marking a whole bunch of sections M,
> > seems to suggest you're going to rely on sh_entsize actually working.
> > 
> > There was an ld.lld bug, and IIRC you need to enforce llvm-20 or later
> > if you want this to be so.
> 
> Hm, ISTR this working with clang 18, I'll go test that again.

You're right, looks like sh_entsize is getting cleared by the linker
with my Clang 18.  I guess I tested with newer Clang.

"objtool klp diff" fails with:

  vmlinux.o: error: objtool: .discard.annotate_insn: unknown entry size

So yeah, non-buggy linker is already being enforced, though I should
probably make the error more human friendly.

-- 
Josh

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ