Re: [PATCH v2 2/2] hardening: Enable i386 FORTIFY_SOURCE on Clang 16+

2025-03-08 Thread Nathan Chancellor
es Cook Reviewed-by: Nathan Chancellor > --- > arch/x86/Makefile | 2 +- > security/Kconfig.hardening | 2 +- > 2 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/arch/x86/Makefile b/arch/x86/Makefile > index d25ed25fb7d9..917459d1ad40 100644 > ---

Re: [PATCH v2 1/2] x86/build: Remove -ffreestanding on i386 with GCC

2025-03-08 Thread Nathan Chancellor
also adjust the comment but it is probably not that big of a deal since the "temporary" is already pretty stale. Reviewed-by: Nathan Chancellor > --- > Cc: Nathan Chancellor > Cc: Nick Desaulniers > Cc: Thomas Gleixner > Cc: Ingo Molnar > Cc: Borislav Petkov > C

Re: [PATCH] hardening: Enable i386 FORTIFY_SOURCE on Clang 16+

2025-03-07 Thread Nathan Chancellor
On Fri, Mar 07, 2025 at 02:57:06PM -0800, Kees Cook wrote: > > > On March 7, 2025 1:47:34 PM PST, Nathan Chancellor wrote: > >On Tue, Mar 04, 2025 at 09:50:44AM -0800, Kees Cook wrote: > >> On Mon, 03 Mar 2025 13:49:37 -0800, Kees Cook wrote: > >> &g

Re: [PATCH] hardening: Enable i386 FORTIFY_SOURCE on Clang 16+

2025-03-07 Thread Nathan Chancellor
On Tue, Mar 04, 2025 at 09:50:44AM -0800, Kees Cook wrote: > On Mon, 03 Mar 2025 13:49:37 -0800, Kees Cook wrote: > > The i386 regparm bug exposed with FORTIFY_SOURCE with Clang was fixed > > in Clang 16[1]. > > > > > > Applied to for-next/hardening, thanks! > > [1/1] hardening: Enable i386 FOR

Re: [PATCH] kunit/stackinit: Use fill byte different from Clang i386 pattern

2025-03-05 Thread Nathan Chancellor
-rc3. Hopefully they do not change the init pattern :) Tested-by: Nathan Chancellor > --- > Cc: Nathan Chancellor > Cc: Bill Wendling > Cc: Justin Stitt > Cc: l...@lists.linux.dev > --- > lib/tests/stackinit_kunit.c | 30 -- > 1 file chang

Re: [PATCH] kbuild: clang: Support building UM with SUBARCH=i386

2025-03-05 Thread Nathan Chancellor
On Tue, Mar 04, 2025 at 09:07:57AM -0800, Kees Cook wrote: > On Tue, Mar 04, 2025 at 03:51:19PM +0100, Thomas Weißschuh wrote: > > No, it doesn't. > > > > Running tests with: > > $ .kunit/linux kunit.filter_glob=overflow.DEFINE_FLEX_test kunit.enable=1 > > mem=1G console=tty kunit_shutdown=halt >

Re: [PATCH v2] kbuild: clang: Support building UM with SUBARCH=i386

2025-03-04 Thread Nathan Chancellor
nit tests with Clang: > > $ ./tools/testing/kunit/kunit.py run \ > --make_options LLVM=1 \ > --make_options SUBARCH=i386 > ... > > Fixes: c7500c1b53bf ("um: Allow builds with Clang") > Signed-off-by: Kees Cook Reviewed-by: Nathan Chancellor >

Re: [PATCH] kbuild: clang: Support building UM with SUBARCH=i386

2025-03-04 Thread Nathan Chancellor
gt; This is also what exists in tools/testing/selftests/lib.mk. > Minus the missing CONFIG_FORTIFY_SOURCE on clang x86_32 > and a failure of overflow.DEFINE_FLEX_test (clang 19.1.7). Does Kees's other patch resolve the second issue? It'll obviously fix the first :P https

Re: [PATCH] hardening: Enable i386 FORTIFY_SOURCE on Clang 16+

2025-03-04 Thread Nathan Chancellor
Cook Yes, thank you for catching this! Reviewed-by: Nathan Chancellor I assume you'll take this? > --- > Cc: Nathan Chancellor > Cc: Nick Desaulniers > Cc: Bill Wendling > Cc: Justin Stitt > Cc: "Gustavo A. R. Silva" > Cc: l...@lists.linux.de

Re: [PATCH] kbuild: Use -fzero-init-padding-bits=all

2025-01-21 Thread Nathan Chancellor
t --arch=x86_64 \ > --make_option CC=gcc-15 > > Suggested-by: Jakub Jelinek > Link: https://lore.kernel.org/linux-toolchains/Z0hRrrNU3Q+ro2T7@tucnak/ [1] > Signed-off-by: Kees Cook Reviewed-by: Nathan Chancellor As far as I understand it, clang

Re: UBSAN array-index-out-of-bounds: cfg80211_scan_6ghz

2024-12-29 Thread Nathan Chancellor
Hi John, On Sat, Dec 28, 2024 at 11:21:27AM +, John Rowley wrote: > Hi, I'm experiencing UBSAN array-index-out-of-bounds errors while using > my Framework 13" AMD laptop with its Mediatek MT7922 wifi adapter > (mt7921e). > > It seems to happen only once on boot, and occurs with both kernel >

Re: korg-clang-19-lkftconfig-hardening: TI x15 board - PC is at edma_probe (drivers/dma/ti/edma.c

2024-11-25 Thread Nathan Chancellor
Hi Naresh, + Kees and linux-hardening, since this is a hardening configuration. On Mon, Nov 25, 2024 at 07:34:22PM +0530, Naresh Kamboju wrote: > The arm TI x15 board boot has failed with the Linux next, mainline > and the Linux stable. Please find boot log and build links. > > The boot failed w

Re: [weiny2:dcd-v4-2024-10-29 9/28] drivers/cxl/cxlmem.h:755:35: error: use of undeclared identifier 'regions_retunred'

2024-10-30 Thread Nathan Chancellor
On Wed, Oct 30, 2024 at 09:50:42AM -0500, Ira Weiny wrote: > [snip] > > > >> drivers/cxl/cxlmem.h:755:35: error: use of undeclared identifier > > >> 'regions_retunred' > > 755 | } __packed region[] __counted_by(regions_retunred); > > |

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

2024-10-15 Thread Nathan Chancellor
ree_initmem+0x95/0x98 ]--- I can confirm that this patch resolves that issue for me and LKDTM's REPORT_STACK_CANARY test passes with that configuration. Reviewed-by: Nathan Chancellor Tested-by: Nathan Chancellor I presume the '#ifndef CONFIG_X86_64' in arch/x86/entry/entry.S is

Re: [PATCH] acl: Annotate struct posix_acl with __counted_by()

2024-10-01 Thread Nathan Chancellor
On Thu, Sep 26, 2024 at 02:21:42PM +0200, Thorsten Blum wrote: > On 26. Sep 2024, at 03:46, kernel test robot wrote: > > > > Hello, > > > > kernel test robot noticed > > "WARNING:at_lib/string_helpers.c:#__fortify_report" on: > > > > commit: 3d2d832826325210abb9849ee96634bf5a197517 ("[PATCH] a

Re: [PATCH] hardening: Adjust dependencies in selection of MODVERSIONS

2024-09-29 Thread Nathan Chancellor
On Sun, Sep 29, 2024 at 08:35:44AM -0700, Linus Torvalds wrote: > On Sat, 28 Sept 2024 at 11:13, Nathan Chancellor wrote: > > > > MODVERSIONS recently grew a dependency on !COMPILE_TEST so that Rust > > could be more easily tested. However, this introduces a Kconfig warn

Re: [PATCH] MAINTAINERS: Add security/Kconfig.hardening to hardening section

2024-09-29 Thread Nathan Chancellor
On Sun, Sep 29, 2024 at 10:20:59PM +0200, Paul Moore wrote: > On September 28, 2024 8:26:28 PM Nathan Chancellor wrote: > > When running get_maintainer.pl on security/Kconfig.hardening, only the > > security subsystem folks show up, even though they have never taken > >

[PATCH] MAINTAINERS: Add security/Kconfig.hardening to hardening section

2024-09-28 Thread Nathan Chancellor
q -c 3 Andrew Morton 1 Greg Kroah-Hartman 18 Kees Cook 2 Linus Torvald Add it to the hardening section so that the KSPP folks are also shown, which matches reality over who should comment on and take said patches if necessary. Signed-off-by: Nathan Chancellor --

[PATCH] hardening: Adjust dependencies in selection of MODVERSIONS

2024-09-28 Thread Nathan Chancellor
; MODULES [=y] Add the !COMPILE_TEST dependency to the selections to clear up the warning. Fixes: 1f9c4a996756 ("Kbuild: make MODVERSIONS support depend on not being a compile test build") Signed-off-by: Nathan Chancellor --- security/Kconfig.hardening | 4 ++-- 1 file changed, 2 i

Re: [djiang:cxl/fwctl 13/25] drivers/cxl/cxlmem.h:798:44: error: 'counted_by' argument must be a simple declaration reference

2024-09-27 Thread Nathan Chancellor
On Fri, Sep 27, 2024 at 09:39:54AM +0800, kernel test robot wrote: > tree: https://git.kernel.org/pub/scm/linux/kernel/git/djiang/linux.git > cxl/fwctl > head: b4f2900f53c72de8fc639b62e44763c6a9695d3b > commit: 5a0496c19151d83cd0d926f8a1488eeaab27509b [13/25] cxl: Add Get > Supported Features

Re: [RESEND PATCH v2] params: Annotate struct module_param_attrs with __counted_by()

2024-09-13 Thread Nathan Chancellor
On Sat, Sep 14, 2024 at 01:32:19AM +0200, Thorsten Blum wrote: > Thanks for reporting this. > > Changing > > memset(&mk->mp->attrs[mk->mp->num - 1], 0, sizeof(mk->mp->attrs[0])); > > to > > memset(mk->mp->attrs + mk->mp->num - 1, 0, sizeof(mk->mp->attrs[0])); > > fixes the false-positive war

Re: [RESEND PATCH v2] params: Annotate struct module_param_attrs with __counted_by()

2024-09-13 Thread Nathan Chancellor
Hi Thorsten, On Mon, Sep 09, 2024 at 06:27:26PM +0200, Thorsten Blum wrote: > Add the __counted_by compiler attribute to the flexible array member > attrs to improve access bounds-checking via CONFIG_UBSAN_BOUNDS and > CONFIG_FORTIFY_SOURCE. > > Increment num before adding a new param_attribute t

Re: [PATCH] nvmet-fc: Remove __counted_by from nvmet_fc_tgt_queue.fod[]

2024-06-26 Thread Nathan Chancellor
On Wed, Jun 26, 2024 at 11:19:24AM -0600, Keith Busch wrote: > On Wed, Jun 26, 2024 at 10:06:05AM -0700, Nathan Chancellor wrote: > > Ping? This is still relevant and I don't think this is a compiler bug > > that would justify withholding this change. > > Sorry, I misun

Re: [PATCH] nvmet-fc: Remove __counted_by from nvmet_fc_tgt_queue.fod[]

2024-06-26 Thread Nathan Chancellor
Ping? This is still relevant and I don't think this is a compiler bug that would justify withholding this change. On Wed, May 29, 2024 at 02:42:40PM -0700, Nathan Chancellor wrote: > Work for __counted_by on generic pointers in structures (not just > flexible array members) has started

Re: [PATCH] USB: serial: garmin_gps: annotate struct garmin_packet with __counted_by

2024-06-19 Thread Nathan Chancellor
t reference to the flexible array > (see pkt_add()), which allows for a straightforward annotation without > further modifications. Agreed, this seems like a reasonable patch in and of itself that should work: Reviewed-by: Nathan Chancellor It might also make sense to change the pkt alloc

Re: [PATCH] kunit/overflow: Adjust for __counted_by with DEFINE_RAW_FLEX()

2024-06-10 Thread Nathan Chancellor
truct. Adjust the tests to check for the condition and for compiler > support. > > Reported-by: Christian Schrefl > Closes: > https://lore.kernel.org/all/0bfc6b38-8bc5-4971-b6fb-dc642a73f...@gmail.com/ > Suggested-by: Nathan Chancellor > Signed-off-by: Kees Cook Seems

Re: [PATCH] tty: mxser: Remove __counted_by from mxser_board.ports[]

2024-05-30 Thread Nathan Chancellor
On Thu, May 30, 2024 at 09:40:13AM +0200, Greg Kroah-Hartman wrote: > On Thu, May 30, 2024 at 08:22:03AM +0200, Jiri Slaby wrote: > > > This will be an error in a future compiler version > > > [-Werror,-Wbounds-safety-counted-by-elt-type-unknown-size] > > > 291 | struct mxser_port po

Re: [PATCH] nvmet-fc: Remove __counted_by from nvmet_fc_tgt_queue.fod[]

2024-05-30 Thread Nathan Chancellor
Hi Jiri, On Thu, May 30, 2024 at 08:41:18AM +0200, Jiri Slaby wrote: > On 29. 05. 24, 23:42, Nathan Chancellor wrote: > >drivers/nvme/target/fc.c:151:2: error: 'counted_by' should not be > > applied to an array with element of unknown size because 'struct >

[PATCH] nvmet-fc: Remove __counted_by from nvmet_fc_tgt_queue.fod[]

2024-05-29 Thread Nathan Chancellor
Cc: sta...@vger.kernel.org Closes: https://github.com/ClangBuiltLinux/linux/issues/2027 Fixes: ccd3129aca28 ("nvmet-fc: Annotate struct nvmet_fc_tgt_queue with __counted_by") Signed-off-by: Nathan Chancellor --- drivers/nvme/target/fc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletio

[PATCH] tty: mxser: Remove __counted_by from mxser_board.ports[]

2024-05-29 Thread Nathan Chancellor
://github.com/ClangBuiltLinux/linux/issues/2026 Fixes: f34907ecca71 ("mxser: Annotate struct mxser_board with __counted_by") Signed-off-by: Nathan Chancellor --- drivers/tty/mxser.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c

Re: [PATCH] wifi: nl80211: Avoid address calculations via out of bounds array indexing

2024-05-07 Thread Nathan Chancellor
On Tue, May 07, 2024 at 12:46:46PM +0200, Johannes Berg wrote: > On Thu, 2024-04-25 at 11:13 -0700, Nathan Chancellor wrote: > > On Wed, Apr 24, 2024 at 03:01:01PM -0700, Kees Cook wrote: > > > Before request->channels[] can be used, request->n_channels must be set. >

Re: [PATCH] x86/alternatives: Make FineIBT mode Kconfig selectable

2024-05-01 Thread Nathan Chancellor
whatever choice was made at compile time. This patch was a perfect excuse to put my new CET enabled test machine to work. Reviewed-by: Nathan Chancellor Tested-by: Nathan Chancellor CFI_DEFAULT_AUTO reads a little bit better to me personally but I am not looking to get into painting today :)

Re: [PATCH] hardening: Refresh KCFI options, add some more

2024-04-30 Thread Nathan Chancellor
On Mon, Apr 29, 2024 at 10:35:03PM -0700, Kees Cook wrote: > On Mon, Apr 29, 2024 at 03:16:50PM -0700, Nathan Chancellor wrote: > > On Fri, Apr 26, 2024 at 03:29:44PM -0700, Kees Cook wrote: > > [...] > > > +# Enable Kernel Control Flow Integrity (currently Clang only). &

Re: [PATCH] hardening: Refresh KCFI options, add some more

2024-04-29 Thread Nathan Chancellor
LANG=y for x86 and arm64. (And disable FINEIBT since > it isn't as secure as straight KCFI.) > > - CONFIG_PAGE_TABLE_CHECK=y for userspace mapping sanity. > > Signed-off-by: Kees Cook Seems reasonable to me. Reviewed-by: Nathan Chancellor One comment below. > --- >

Re: [PATCH v2] ubsan: Avoid i386 UBSAN handler crashes with Clang

2024-04-26 Thread Nathan Chancellor
for earlier Clang versions today. Force the > calling convention to use non-register arguments. > > Reported-by: Erhard Furtner > Closes: https://github.com/KSPP/linux/issues/350 > Signed-off-by: Kees Cook Acked-by: Nathan Chancellor > --- > Cc: Marco Elver > Cc: Andr

Re: [PATCH] wifi: nl80211: Avoid address calculations via out of bounds array indexing

2024-04-25 Thread Nathan Chancellor
") rather than > via the first "out of bounds" index of "channels", otherwise run-time > bounds checking will throw a warning. > > Reported-by: Nathan Chancellor > Fixes: e3eac9f32ec0 ("wifi: cfg80211: Annotate struct cfg80211_scan_request >

[PATCH 2/2] clk: bcm: rpi: Assign ->num before accessing ->hws

2024-04-25 Thread Nathan Chancellor
zation to before the first access of ->hws, which clears up the warning. Cc: sta...@vger.kernel.org Fixes: f316cdff8d67 ("clk: Annotate struct clk_hw_onecell_data with __counted_by") Signed-off-by: Nathan Chancellor --- drivers/clk/bcm/clk-raspberrypi.c | 2 +- 1 file changed, 1

[PATCH 1/2] clk: bcm: dvp: Assign ->num before accessing ->hws

2024-04-25 Thread Nathan Chancellor
re the first access of ->hws, which clears up the warning. Cc: sta...@vger.kernel.org Fixes: f316cdff8d67 ("clk: Annotate struct clk_hw_onecell_data with __counted_by") Signed-off-by: Nathan Chancellor --- drivers/clk/bcm/clk-bcm2711-dvp.c | 3 ++- 1 file changed, 2 insertions(+), 1

[PATCH 0/2] clk: bcm: Move a couple of __counted_by initializations

2024-04-25 Thread Nathan Chancellor
/c/79a2207963b8fea452acfc5dea13ed54bd36c7e1 --- Nathan Chancellor (2): clk: bcm: dvp: Assign ->num before accessing ->hws clk: bcm: rpi: Assign ->num before accessing ->hws drivers/clk/bcm/clk-bcm2711-dvp.c | 3 ++- drivers/clk/bcm/clk-raspberrypi.c | 2 +- 2 file

Re: [PATCH] ubsan: Avoid i386 UBSAN handler crashes with Clang

2024-04-24 Thread Nathan Chancellor
https://github.com/KSPP/linux/issues/350 > Signed-off-by: Kees Cook > --- > Cc: Marco Elver > Cc: Andrey Konovalov > Cc: Andrey Ryabinin > Cc: Nathan Chancellor > Cc: Nick Desaulniers > Cc: Bill Wendling > Cc: Justin Stitt > Cc: l...@lists.linux.dev > Cc: ka

Re: [PATCH] ubsan: Add awareness of signed integer overflow traps

2024-04-15 Thread Nathan Chancellor
ed failure code: f2005515 [#1] > PREEMPT SMP > > Reported-by: Nathan Chancellor > Closes: > https://lore.kernel.org/lkml/20240411-fix-ubsan-in-hardening-config-v1-0-e0177c80f...@kernel.org > Fixes: 557f8c582a9b ("ubsan: Reintroduce signed overflow sanitizer")

Re: [PATCH 0/2] configs/hardening: Some fixes for UBSAN

2024-04-15 Thread Nathan Chancellor
On Mon, Apr 15, 2024 at 11:15:05AM -0700, Kees Cook wrote: > On Thu, Apr 11, 2024 at 11:11:05AM -0700, Nathan Chancellor wrote: > > [0.189542] Internal error: UBSAN: unrecognized failure code: > > f2005515 [#1] PREEMPT SMP > > Oops! Yes, I didn't update t

[PATCH 2/2] configs/hardening: Disable CONFIG_UBSAN_SIGNED_WRAP

2024-04-11 Thread Nathan Chancellor
. Disable CONFIG_UBSAN_SIGNED_WRAP in hardening.config to avoid this situation. Fixes: 557f8c582a9b ("ubsan: Reintroduce signed overflow sanitizer") Signed-off-by: Nathan Chancellor --- kernel/configs/hardening.config | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/configs/hardenin

[PATCH 1/2] configs/hardening: Fix disabling UBSAN configurations

2024-04-11 Thread Nathan Chancellor
AN_ENUM is not set # CONFIG_TEST_UBSAN is not set Fixes: 215199e3d9f3 ("hardening: Provide Kconfig fragments for basic options") Signed-off-by: Nathan Chancellor --- kernel/configs/hardening.config | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --

[PATCH 0/2] configs/hardening: Some fixes for UBSAN

2024-04-11 Thread Nathan Chancellor
nel_init+0x28/0x1b8 [0.200123] ret_from_fork+0x10/0x20 [0.200547] Code: 5460 37f80080 39400268 371001c8 (d42aa2a0) [0.200996] ---[ end trace 0000 ]--- --- Nathan Chancellor (2): configs/hardening: Fix disabling UBSAN configurations configs/hardenin

[PATCH] lkdtm/bugs: Improve warning message for compilers without counted_by support

2024-03-21 Thread Nathan Chancellor
The current message for telling the user that their compiler does not support the counted_by attribute in the FAM_BOUNDS test does not make much sense either grammatically or semantically. Fix it to make it correct in both aspects. Signed-off-by: Nathan Chancellor --- drivers/misc/lkdtm/bugs.c

Re: [PATCH] thermal: core: Move initial num_trips assignment before memcpy()

2024-02-28 Thread Nathan Chancellor
On Wed, Feb 28, 2024 at 08:41:07AM +, Lukasz Luba wrote: > Hi Nathan and Kees, > > On 2/27/24 17:00, Kees Cook wrote: > > On Tue, Feb 27, 2024 at 05:47:44PM +0100, Daniel Lezcano wrote: > > > Ok my misunderstanding was I thought sizeof() was calling _bdos under the > > > hood, so when calling

Re: [PATCH] thermal: core: Move initial num_trips assignment before memcpy()

2024-02-27 Thread Nathan Chancellor
Hi Daniel and Lukasz, On Tue, Feb 27, 2024 at 04:37:36PM +0100, Daniel Lezcano wrote: > On 27/02/2024 12:09, Rafael J. Wysocki wrote: > > On Tue, Feb 27, 2024 at 11:14 AM Daniel Lezcano > > wrote: > > > > > > On 27/02/2024 01:54, Nathan Chancel

[PATCH] thermal: core: Move initial num_trips assignment before memcpy()

2024-02-26 Thread Nathan Chancellor
core: Store zone trips table in struct thermal_zone_device") Signed-off-by: Nathan Chancellor --- drivers/thermal/thermal_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index bb21f78b4bfa..1eabc8ebe27d 10

[PATCH 09/11] fortify: Drop Clang version check for 12.0.1 or newer

2024-01-25 Thread Nathan Chancellor
Now that the minimum supported version of LLVM for building the kernel has been bumped to 13.0.1, this condition is always true, as the build will fail during the configuration stage for older LLVM versions. Remove it. Signed-off-by: Nathan Chancellor --- Cc: keesc...@chromium.org Cc: linux

[PATCH 00/11] Bump the minimum supported version of LLVM to 13.0.1

2024-01-25 Thread Nathan Chancellor
kernel.org/20240109-update-llvm-links-v1-0-eb09b59db...@kernel.org/ --- Nathan Chancellor (11): kbuild: Raise the minimum supported version of LLVM to 13.0.1 Makefile: Drop warn-stack-size plugin opt x86: Drop stack-alignment plugin opt ARM: Remove Thumb2 __builtin_thread_pointer