Skip to contentSkip to conversation

Patch "configs/hardening: Fix disabling UBSAN configurations" has been added to the 6.8-stable tree

DISCUSSION Nathan Chancellor 2 participants 3 messages Apr 22, 2024 – Apr 23, 2024 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive
Quoted 16 lines · Sasha Levin

This is a note to let you know that I've just added the patch titled

configs/hardening: Fix disabling UBSAN configurations

to the 6.8-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
configs-hardening-fix-disabling-ubsan-configurations.patch
and it can be found in the queue-6.8 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 7 lines

commit a54fba0bb1f52707b423c908e153d6429d08db58

Author: Nathan Chancellor <[email protected]>
Date:   Thu Apr 11 11:11:06 2024 -0700

configs/hardening: Fix disabling UBSAN configurations

[ Upstream commit e048d668f2969cf2b76e0fa21882a1b3bb323eca ]

While I think backporting this makes sense, I don't know that backporting 918327e9b7ff ("ubsan: Remove CONFIG_UBSAN_SANITIZE_ALL") to resolve the conflict with 6.8 is entirely necessary (or beneficial, I don't know how Kees feels about it though). I've attached a version that applies cleanly to 6.8, in case it is desirable.

Cheers,
Nathan

From 8990975f1a5b3042a51253d1be0a360fba38b43e Mon Sep 17 00:00:00 2001
From: Nathan Chancellor <[email protected]>
Date: Thu, 11 Apr 2024 11:11:06 -0700
Subject: [PATCH 6.8] configs/hardening: Fix disabling UBSAN configurations

commit e048d668f2969cf2b76e0fa21882a1b3bb323eca upstream.

The initial change that added kernel/configs/hardening.config attempted to disable all UBSAN sanitizers except for the array bounds one while turning on UBSAN_TRAP. Unfortunately, it only got the syntax for CONFIG_UBSAN_SHIFT correct, so configurations that are on by default with CONFIG_UBSAN=y such as CONFIG_UBSAN_{BOOL,ENUM} do not get disabled properly.

CONFIG_ARCH_HAS_UBSAN=y
CONFIG_UBSAN=y
CONFIG_UBSAN_TRAP=y
CONFIG_CC_HAS_UBSAN_BOUNDS_STRICT=y
CONFIG_UBSAN_BOUNDS=y
CONFIG_UBSAN_BOUNDS_STRICT=y
# CONFIG_UBSAN_SHIFT is not set
# CONFIG_UBSAN_DIV_ZERO is not set
# CONFIG_UBSAN_UNREACHABLE is not set
CONFIG_UBSAN_SIGNED_WRAP=y
CONFIG_UBSAN_BOOL=y
CONFIG_UBSAN_ENUM=y
# CONFIG_TEST_UBSAN is not set

Add the missing 'is not set' to each configuration that needs it so that they get disabled as intended.

CONFIG_ARCH_HAS_UBSAN=y
CONFIG_UBSAN=y
CONFIG_UBSAN_TRAP=y
CONFIG_CC_HAS_UBSAN_BOUNDS_STRICT=y
CONFIG_UBSAN_BOUNDS=y
CONFIG_UBSAN_BOUNDS_STRICT=y
# CONFIG_UBSAN_SHIFT is not set
# CONFIG_UBSAN_DIV_ZERO is not set
# CONFIG_UBSAN_UNREACHABLE is not set
CONFIG_UBSAN_SIGNED_WRAP=y
# CONFIG_UBSAN_BOOL is not set
# CONFIG_UBSAN_ENUM is not set
# CONFIG_TEST_UBSAN is not set

[nathan: Resolve conflicts due to lack of 006eac3fe20f and de2683e7fdac
in earlier releases]

---
 kernel/configs/hardening.config | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
kernel/configs/hardening.config +5 -5
index 95a400f042b1..cac20e001c5b 100644
@@ -39,11 +39,11 @@ CONFIG_UBSAN=y
 CONFIG_UBSAN_TRAP=y
 CONFIG_UBSAN_BOUNDS=y
 # CONFIG_UBSAN_SHIFT is not set
-# CONFIG_UBSAN_DIV_ZERO
-# CONFIG_UBSAN_UNREACHABLE
-# CONFIG_UBSAN_BOOL
-# CONFIG_UBSAN_ENUM
-# CONFIG_UBSAN_ALIGNMENT
+# CONFIG_UBSAN_DIV_ZERO is not set
+# CONFIG_UBSAN_UNREACHABLE is not set
+# CONFIG_UBSAN_BOOL is not set
+# CONFIG_UBSAN_ENUM is not set
+# CONFIG_UBSAN_ALIGNMENT is not set
 CONFIG_UBSAN_SANITIZE_ALL=y
 
 # Linked list integrity checking.

base-commit: 12dadc409c2bd8538c6ee0e56e191efde6d92007

Signature · 1 line
2.44.0
maintainer
#2 lore raw
Quoted 23 lines · Nathan Chancellor
Quoted 22 lines · Sasha Levin

This is a note to let you know that I've just added the patch titled

configs/hardening: Fix disabling UBSAN configurations

to the 6.8-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
configs-hardening-fix-disabling-ubsan-configurations.patch
and it can be found in the queue-6.8 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

commit a54fba0bb1f52707b423c908e153d6429d08db58

Author: Nathan Chancellor <[email protected]>
Date:   Thu Apr 11 11:11:06 2024 -0700

configs/hardening: Fix disabling UBSAN configurations

Quoted 7 lines
Quoted 1 line
    [ Upstream commit e048d668f2969cf2b76e0fa21882a1b3bb323eca ]

While I think backporting this makes sense, I don't know that backporting 918327e9b7ff ("ubsan: Remove CONFIG_UBSAN_SANITIZE_ALL") to resolve the conflict with 6.8 is entirely necessary (or beneficial, I don't know how Kees feels about it though). I've attached a version that applies cleanly to 6.8, in case it is desirable.

I usually wouldn't do it, but 918327e9b7ff ("ubsan: Remove CONFIG_UBSAN_SANITIZE_ALL") indicated that it's mostly a noop rather than a change in behavior for existing config files.

Signature · 2 lines
Thanks,
Sasha
#3 lore raw
Quoted 32 lines · Sasha Levin
Quoted 23 lines · Nathan Chancellor
Quoted 22 lines · Sasha Levin

This is a note to let you know that I've just added the patch titled

configs/hardening: Fix disabling UBSAN configurations

to the 6.8-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
configs-hardening-fix-disabling-ubsan-configurations.patch
and it can be found in the queue-6.8 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

commit a54fba0bb1f52707b423c908e153d6429d08db58

Author: Nathan Chancellor <[email protected]>
Date:   Thu Apr 11 11:11:06 2024 -0700

configs/hardening: Fix disabling UBSAN configurations

Quoted 7 lines
Quoted 1 line
    [ Upstream commit e048d668f2969cf2b76e0fa21882a1b3bb323eca ]

While I think backporting this makes sense, I don't know that backporting 918327e9b7ff ("ubsan: Remove CONFIG_UBSAN_SANITIZE_ALL") to resolve the conflict with 6.8 is entirely necessary (or beneficial, I don't know how Kees feels about it though). I've attached a version that applies cleanly to 6.8, in case it is desirable.

Quoted 3 lines

I usually wouldn't do it, but 918327e9b7ff ("ubsan: Remove CONFIG_UBSAN_SANITIZE_ALL") indicated that it's mostly a noop rather than a change in behavior for existing config files.

It is a change in behavior for architectures that did not select CONFIG_ARCH_HAS_UBSAN_SANITIZE_ALL because CONFIG_UBSAN_SANITIZE_ALL depends on that (for example, LoongArch). That change actually helped expose an issue in LoongArch's LLVM backend because UBSAN was now getting enabled on files in allmodconfig, which is good, but that shows the change is not risk free. However, given that it makes CONFIG_UBSAN perhaps work more expectedly (which could be considered a fix on its own), we can probably keep this as is and just back out of it if it is too disruptive to people.

Cheers,
Nathan