Re: [PATCH] md/bcache: Mark __nonstring look-up table

2025-04-18 Thread Ard Biesheuvel
On Thu, 17 Apr 2025 at 15:12, Coly Li wrote: > > > > > 2025年4月17日 15:10,Kees Cook 写道: > > > > > > > > On April 16, 2025 11:16:45 PM PDT, Ard Biesheuvel wrote: > >> On Thu, 17 Apr 2025 at 00:01, Kees Cook wrote: > >>> > >>&g

Re: [PATCH] md/bcache: Mark __nonstring look-up table

2025-04-16 Thread Ard Biesheuvel
On Thu, 17 Apr 2025 at 00:01, Kees Cook wrote: > > GCC 15's new -Wunterminated-string-initialization notices that the 16 > character lookup table "zero_uuid" (which is not used as a C-String) > needs to be marked as "nonstring": > > drivers/md/bcache/super.c: In function 'uuid_find_empty': > drive

Re: [PATCH] gcc-plugins: Remove ARM_SSP_PER_TASK plugin

2025-04-09 Thread Ard Biesheuvel
t; Suggested-by: Arnd Bergmann > Link: > https://lore.kernel.org/all/08393aa3-05a3-4e3f-8004-f374a3ec4...@app.fastmail.com/ > [1] > Signed-off-by: Kees Cook > --- > Cc: Ard Biesheuvel > Cc: Chris Packham > Cc: Douglas Anderson > Cc: Russell King > Cc: Masahiro Ya

Re: [RFC PATCH] arm64/mm: Remove randomization of the linear map

2025-04-05 Thread Ard Biesheuvel
On Tue, 18 Mar 2025 at 14:50, Ard Biesheuvel wrote: > > From: Ard Biesheuvel > > Since commit > > 97d6786e0669 ("arm64: mm: account for hotplug memory when randomizing the > linear region") > > the decision whether or not to randomize the placement of the

[RFC PATCH] arm64/mm: Remove randomization of the linear map

2025-03-18 Thread Ard Biesheuvel
From: Ard Biesheuvel Since commit 97d6786e0669 ("arm64: mm: account for hotplug memory when randomizing the linear region") the decision whether or not to randomize the placement of the system's DRAM inside the linear map is based on the capabilities of the CPU rather than

Re: Re: [PATCH v2] treewide: const qualify ctl_tables where applicable

2025-01-22 Thread Ard Biesheuvel
On Wed, 22 Jan 2025 at 13:25, Joel Granados wrote: > > On Tue, Jan 21, 2025 at 02:40:16PM +0100, Alexander Gordeev wrote: > > On Fri, Jan 10, 2025 at 03:16:08PM +0100, Joel Granados wrote: > > > > Hi Joel, > > > > > Add the const qualifier to all the ctl_tables in the tree except for > > > watchdo

Re: [PATCH v2] x86/stackprotector: Work around strict Clang TLS symbol requirements

2024-10-15 Thread Ard Biesheuvel
On Wed, 16 Oct 2024 at 04:10, Nathan Chancellor wrote: > > On Tue, Oct 15, 2024 at 12:56:57PM +0200, Ard Biesheuvel wrote: > > On Mon, 14 Oct 2024 at 22:59, Kees Cook wrote: > > > > > > On Wed, Oct 09, 2024 at 02:43:53PM +0200, Ard Biesheuvel wrote: > > >

Re: [PATCH v2] x86/stackprotector: Work around strict Clang TLS symbol requirements

2024-10-15 Thread Ard Biesheuvel
On Mon, 14 Oct 2024 at 22:59, Kees Cook wrote: > > On Wed, Oct 09, 2024 at 02:43:53PM +0200, Ard Biesheuvel wrote: > > However, if a non-TLS definition of the symbol in question is visible in > > the same compilation unit (which amounts to the whole of vmlinux if LTO > > i

Re: [PATCH v3 6/8] crypto: x86/crc32c - Use idiomatic relative jump table

2024-10-14 Thread Ard Biesheuvel
On Mon, 14 Oct 2024 at 06:28, Eric Biggers wrote: > > On Fri, Oct 11, 2024 at 07:08:54PM +0200, Ard Biesheuvel wrote: > > diff --git a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S > > b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S > > index bbcff1fb78cb..45b005935194 100644 &

[PATCH v3 8/8] crypto: x86/crc32c-intel - Tweaks to make objtool's life harder

2024-10-11 Thread Ard Biesheuvel
From: Ard Biesheuvel Tweak the asm crc32c asm code so that the jump table is more difficult to decipher for objtool: - load the address in the prologue - move the jump table to the middle of .rodata, so that the section offset and the symbol offset differ - emit an entry following the jump

[PATCH v3 7/8] crypto: x86/crc32c - Add jump table annotation

2024-10-11 Thread Ard Biesheuvel
From: Ard Biesheuvel Annotate the indirect jump with a relocation that correlates it with the jump table emitted into .rodata. This helps objtool identify the jump table, allowing it to infer the places in the code that are reachable from the jump. Signed-off-by: Ard Biesheuvel --- arch/x86

[PATCH v3 6/8] crypto: x86/crc32c - Use idiomatic relative jump table

2024-10-11 Thread Ard Biesheuvel
From: Ard Biesheuvel The original crc32c code used a place-relative jump table but with a slightly awkward use of two separate symbols. To help objtool, this was replaced with a bog-standard position dependent jump table call, which was subsequently tweaked to use a RIP-relative reference to the

[PATCH v3 5/8] objtool: Add generic support for jump table annotations

2024-10-11 Thread Ard Biesheuvel
From: Ard Biesheuvel Refactor the jump table handling code so that a generic code path is provided that can identify jump tables attached to indirect jumps based only on compiler provided annotations. This will be used by non-x86 architectures which do not support jump tables at all at this

[PATCH v3 4/8] objtool: Move jump table heuristics to a x86 specific source file

2024-10-11 Thread Ard Biesheuvel
From: Ard Biesheuvel In preparation for implementing support for the use of compiler emitted jump table annotations, move the existing code out of the generic sources. This will permit a clean separation between the two approaches, where the old one will not be wired up for architectures other

[PATCH v3 3/8] objtool: Make some helper functions globally accessible

2024-10-11 Thread Ard Biesheuvel
From: Ard Biesheuvel Move some helpers around so they can be used from arch specific jump table code that is getting refactored in the next patch. Signed-off-by: Ard Biesheuvel --- tools/objtool/check.c | 22 tools/objtool/include/objtool/check.h | 16

[PATCH v3 2/8] objtool: Allow arch code to discover jump table size

2024-10-11 Thread Ard Biesheuvel
From: Ard Biesheuvel In preparation for adding support for annotated jump tables, where ELF relocations and symbols are used to describe the locations of jump tables in the executable, refactor the jump table discovery logic so the table size can be returned from arch_find_switch_table

[PATCH v3 1/8] objtool: Deal with relative jump tables correctly

2024-10-11 Thread Ard Biesheuvel
From: Ard Biesheuvel Relative jump tables contain entries that carry the offset between the target of the jump and the start of the jump table. This permits the use of the PIC idiom of leaqjump_table(%rip), %tbl movslq (%tbl,%idx,4), %offset addq%offset, %tbl jmp

[PATCH v3 0/8] Improve objtool jump table handling

2024-10-11 Thread Ard Biesheuvel
From: Ard Biesheuvel Jump table handling has faded into the background a little due to the fact that jump tables are [currently] disabled when enabling retpoline mitigations and/or IBT on x86. However, this is likely to come back and bite us later, so it still needs to be addressed. Given the

Re: [PATCH v2 2/5] objtool: Allow arch code to discover jump table size

2024-10-11 Thread Ard Biesheuvel
On Thu, 10 Oct 2024 at 21:52, Josh Poimboeuf wrote: > > On Thu, Oct 10, 2024 at 02:28:04PM +0200, Ard Biesheuvel wrote: > > @@ -,7 +2234,6 @@ static void mark_func_jump_tables(struct objtool_file > > *file, > > struct symbol *func)

Re: [PATCH v2 5/5] crypto: x86/crc32c - Tweak jump table to validate objtool logic

2024-10-11 Thread Ard Biesheuvel
On Fri, 11 Oct 2024 at 18:05, Josh Poimboeuf wrote: > > On Fri, Oct 11, 2024 at 08:32:33AM +0200, Ard Biesheuvel wrote: > > On Thu, 10 Oct 2024 at 22:34, Josh Poimboeuf wrote: > > > > > > On Thu, Oct 10, 2024 at 02:28:07PM +0200, Ard Biesheuvel wrote

Re: [PATCH v2 5/5] crypto: x86/crc32c - Tweak jump table to validate objtool logic

2024-10-10 Thread Ard Biesheuvel
On Thu, 10 Oct 2024 at 22:34, Josh Poimboeuf wrote: > > On Thu, Oct 10, 2024 at 02:28:07PM +0200, Ard Biesheuvel wrote: > > From: Ard Biesheuvel > > > > Tweak the jump table so > > - the address is taken far way from its use > > - its offset from the start of

Re: [PATCH v2 3/5] objtool: Add support for annotated jump tables

2024-10-10 Thread Ard Biesheuvel
On Thu, 10 Oct 2024 at 22:15, Josh Poimboeuf wrote: > > On Thu, Oct 10, 2024 at 02:28:05PM +0200, Ard Biesheuvel wrote: > > +++ b/tools/objtool/arch/x86/special.c > > @@ -115,30 +115,51 @@ struct reloc *arch_find_switch_table(struct > > objtool_file *file, > >

Re: [PATCH v2 0/5] Improve objtool jump table handling

2024-10-10 Thread Ard Biesheuvel
On Thu, 10 Oct 2024 at 14:28, Ard Biesheuvel wrote: > > From: Ard Biesheuvel > > Jump table handling has faded into the background a little due to the > fact that jump tables are [currently] disabled when enabling retpoline > mitigations and/or IBT on x86. > > However

Re: [PATCH v2 1/5] objtool: Deal with relative jump tables correctly

2024-10-10 Thread Ard Biesheuvel
On Thu, 10 Oct 2024 at 15:26, Peter Zijlstra wrote: > > On Thu, Oct 10, 2024 at 02:28:03PM +0200, Ard Biesheuvel wrote: > > diff --git a/tools/objtool/check.c b/tools/objtool/check.c > > index 3cb3e9b5ad0b..7f7981a93535 100644 > > --- a/tools/objtool/check.c > &g

[PATCH v2 5/5] crypto: x86/crc32c - Tweak jump table to validate objtool logic

2024-10-10 Thread Ard Biesheuvel
From: Ard Biesheuvel Tweak the jump table so - the address is taken far way from its use - its offset from the start of .rodata is != 0x0 - its type is STT_OBJECT and its size is set to the size of the actual table - the indirect jump is annotated with a R_X86_64_NONE relocation pointing to

[PATCH v2 4/5] crypto: x86/crc32c - Use idiomatic relative jump table

2024-10-10 Thread Ard Biesheuvel
From: Ard Biesheuvel The original crc32c code used a place-relative jump table but with a slightly awkward use of two separate symbols. To help objtool, this was replaced with a bog-standard position dependent jump table call, which was subsequently tweaked to use a RIP-relative reference to the

[PATCH v2 3/5] objtool: Add support for annotated jump tables

2024-10-10 Thread Ard Biesheuvel
From: Ard Biesheuvel Add logic to follow R_X86_64_NONE relocations attached to indirect jumps, which are emitted to annotate jump tables, which are otherwise difficult to spot reliably. If an ELF symbol is associated with the jump table, its size is taken as the size of the jump table, and

[PATCH v2 2/5] objtool: Allow arch code to discover jump table size

2024-10-10 Thread Ard Biesheuvel
From: Ard Biesheuvel In preparation for adding support for annotated jump tables, where ELF relocations and symbols are used to describe the locations of jump tables in the executable, refactor the jump table discovery logic so the table size can be returned from arch_find_switch_table

[PATCH v2 1/5] objtool: Deal with relative jump tables correctly

2024-10-10 Thread Ard Biesheuvel
From: Ard Biesheuvel Relative jump tables contain entries that carry the offset between the target of the jump and the start of the jump table. This permits the use of the PIC idiom of leaqjump_table(%rip), %tbl movslq (%tbl,%idx,4), %offset addq%offset, %tbl jmp

[PATCH v2 0/5] Improve objtool jump table handling

2024-10-10 Thread Ard Biesheuvel
From: Ard Biesheuvel Jump table handling has faded into the background a little due to the fact that jump tables are [currently] disabled when enabling retpoline mitigations and/or IBT on x86. However, this is likely to come back and bite us later, so it still needs to be addressed. Given the

Re: [PATCH] objtool: Deal with relative jump tables correctly

2024-10-09 Thread Ard Biesheuvel
On Tue, 8 Oct 2024 at 19:42, Josh Poimboeuf wrote: > > On Tue, Oct 08, 2024 at 12:47:48AM +0200, Ard Biesheuvel wrote: > > - /* > > - * Use of RIP-relative switch jumps is quite rare, and > > - * indicates a rare GCC quirk/bug which can leave dead

[PATCH v2] x86/stackprotector: Work around strict Clang TLS symbol requirements

2024-10-09 Thread Ard Biesheuvel
From: Ard Biesheuvel GCC and Clang both implement stack protector support based on Thread Local Storage (TLS) variables, and this is used in the kernel to implement per-task stack cookies, by copying a task's stack cookie into a per-CPU variable every time it is scheduled in. Both now

Re: [PATCH][next] wifi: iwlwifi: mvm: Use __counted_by() and avoid -Wfamnae warnings

2024-09-16 Thread Ard Biesheuvel
On Fri, 9 Aug 2024 at 21:17, Gustavo A. R. Silva wrote: > > -Wflex-array-member-not-at-end was introduced in GCC-14, and we are > getting ready to enable it, globally. > > So, use the `DEFINE_FLEX()` helper for multiple on-stack definitions > of flexible structures where the size of their flexible

Re: [PATCH v3] proc: add config & param to block forcing mem writes

2024-07-26 Thread Ard Biesheuvel
On Fri, 26 Jul 2024 at 11:11, Adrian Ratiu wrote: > > This adds a Kconfig option and boot param to allow removing > the FOLL_FORCE flag from /proc/pid/mem write calls because > it can be abused. > > The traditional forcing behavior is kept as default because > it can break GDB and some other use c

Re: [PATCH v3 2/2] pstore/ramoops: Add ramoops.mem_name= command line option

2024-06-13 Thread Ard Biesheuvel
On Thu, 13 Jun 2024 at 15:26, Steven Rostedt wrote: > > On Thu, 13 Jun 2024 08:11:48 +0200 > Ard Biesheuvel wrote: > > > > > > I've added one more comment to v5, with that fixed I can take this. > > > > > > > So how is this supposed to work wr

Re: [PATCH v3 2/2] pstore/ramoops: Add ramoops.mem_name= command line option

2024-06-12 Thread Ard Biesheuvel
On Thu, 13 Jun 2024 at 08:04, Mike Rapoport wrote: > > On Wed, Jun 12, 2024 at 02:52:28PM -0400, Steven Rostedt wrote: > > On Wed, 12 Jun 2024 11:45:57 -0700 > > Kees Cook wrote: > > > > > On Tue, Jun 11, 2024 at 10:49:13AM -0400, Steven Rostedt wrote: > > > > From: "Steven Rostedt (Google)" > >

Re: [PATCH 1/2] mm/memblock: Add "reserve_mem" to reserved named memory at boot up

2024-06-03 Thread Ard Biesheuvel
On Tue, 4 Jun 2024 at 01:35, Steven Rostedt wrote: > > From: "Steven Rostedt (Google)" > > In order to allow for requesting a memory region that can be used for > things like pstore on multiple machines where the memory layout is not the > same, add a new option to the kernel command line called

Re: [POC][RFC][PATCH 1/2] mm/x86: Add wildcard * option as memmap=nn*align:name

2024-05-06 Thread Ard Biesheuvel
On Wed, 1 May 2024 at 16:59, Mike Rapoport wrote: > > On Mon, Apr 15, 2024 at 10:22:53AM -0700, Kees Cook wrote: > > On Fri, Apr 12, 2024 at 06:19:40PM -0400, Steven Rostedt wrote: > > > On Fri, 12 Apr 2024 23:59:07 +0300 > > > Mike Rapoport wrote: > > > > > > > On Tue, Apr 09, 2024 at 04:41:24PM

[PATCH] gcc-plugins/stackleak: Avoid .head.text section

2024-03-27 Thread Ard Biesheuvel
From: Ard Biesheuvel The .head.text section carries the startup code that runs with the MMU off or with a translation of memory that deviates from the ordinary one. So avoid instrumentation with the stackleak plugin, which already avoids .init.text and .noinstr.text entirely. Fixes

Re: [PATCH v2] ARM: unwind: improve unwinders for noreturn case

2024-03-21 Thread Ard Biesheuvel
On Thu, 21 Mar 2024 at 12:24, Russell King (Oracle) wrote: > > On Thu, Mar 21, 2024 at 10:22:30AM +, David Laight wrote: > > How aggressively does the compiler optimise 'noreturn' functions? > > I've seen cases where the compiler emits a BL instruction as the very > last thing in the function,

Re: [PATCH] smb: Work around Clang __bdos() type confusion

2024-01-25 Thread Ard Biesheuvel
On Thu, 25 Jan 2024 at 19:00, Kees Cook wrote: > > On Thu, Jan 25, 2024 at 01:19:19PM +0100, Ard Biesheuvel wrote: > > On Wed, 24 Jan 2024 at 00:47, Kees Cook wrote: > > > > > > Recent versions of Clang gets confused about the possible size of th

Re: [PATCH] smb: Work around Clang __bdos() type confusion

2024-01-25 Thread Ard Biesheuvel
On Wed, 24 Jan 2024 at 00:47, Kees Cook wrote: > > Recent versions of Clang gets confused about the possible size of the > "user" allocation, and CONFIG_FORTIFY_SOURCE ends up emitting a > warning[1]: > > repro.c:126:4: warning: call to '__write_overflow_field' declared with > 'warning' attribute

Re: [PATCH] ARM: fault: Add "cut here" line for prefetch aborts

2024-01-23 Thread Ard Biesheuvel
On Tue, 23 Jan 2024 at 02:12, Kees Cook wrote: > > The common pattern in arm is to emit a "8<--- cut here ---" line for > faults, but it was missing for do_PrefetchAbort(). Add it. > > Cc: "Russell King (Oracle)" > Cc: Ard Biesheuvel > Cc: Wang Kefe

Re: [PATCH] ARM: fault: Implement copy_from_kernel_nofault_allowed()

2024-01-23 Thread Ard Biesheuvel
ress. Make sure copy_from_kernel_nofault() does not attempt this > any more. > > Reported-by: Mark Brown > Link: https://lore.kernel.org/all/202401181125.D48DCB4C@keescook/ [1] > Suggested-by: "Russell King (Oracle)" > Cc: Russell King > Cc: Ard Biesheuvel > Cc: Wang Kefeng >

Re: Limited/Broken functionality of ASLR for Libs >= 2MB

2024-01-16 Thread Ard Biesheuvel
(cc Kees, LAKML) https://lkml.kernel.org/r/69fa6015256613ed10aee996e181ebd4%40horotw.com On Mon, 15 Jan 2024 at 21:46, Matthew Wilcox wrote: > ... > Yeah, I don't know either. Outside my scope of expertise. > > I received a suggestion off-list that we only do the PMD alignment on > 64-bit, whic