Skip to content

Commit 2d41226

Browse files
committed
Merge tag 'hardening-v6.9-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux
Pull hardening fixes from Kees Cook: - Correctly disable UBSAN configs in configs/hardening (Nathan Chancellor) - Add missing signed integer overflow trap types to arm64 handler * tag 'hardening-v6.9-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux: ubsan: Add awareness of signed integer overflow traps configs/hardening: Disable CONFIG_UBSAN_SIGNED_WRAP configs/hardening: Fix disabling UBSAN configurations
2 parents 50a1317 + f4626c1 commit 2d41226

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

kernel/configs/hardening.config

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,12 @@ CONFIG_UBSAN=y
3939
CONFIG_UBSAN_TRAP=y
4040
CONFIG_UBSAN_BOUNDS=y
4141
# CONFIG_UBSAN_SHIFT is not set
42-
# CONFIG_UBSAN_DIV_ZERO
43-
# CONFIG_UBSAN_UNREACHABLE
44-
# CONFIG_UBSAN_BOOL
45-
# CONFIG_UBSAN_ENUM
46-
# CONFIG_UBSAN_ALIGNMENT
42+
# CONFIG_UBSAN_DIV_ZERO is not set
43+
# CONFIG_UBSAN_UNREACHABLE is not set
44+
# CONFIG_UBSAN_SIGNED_WRAP is not set
45+
# CONFIG_UBSAN_BOOL is not set
46+
# CONFIG_UBSAN_ENUM is not set
47+
# CONFIG_UBSAN_ALIGNMENT is not set
4748

4849
# Sampling-based heap out-of-bounds and use-after-free detection.
4950
CONFIG_KFENCE=y

lib/ubsan.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,10 @@ const char *report_ubsan_failure(struct pt_regs *regs, u32 check_type)
4444
case ubsan_shift_out_of_bounds:
4545
return "UBSAN: shift out of bounds";
4646
#endif
47-
#ifdef CONFIG_UBSAN_DIV_ZERO
47+
#if defined(CONFIG_UBSAN_DIV_ZERO) || defined(CONFIG_UBSAN_SIGNED_WRAP)
4848
/*
49-
* SanitizerKind::IntegerDivideByZero emits
49+
* SanitizerKind::IntegerDivideByZero and
50+
* SanitizerKind::SignedIntegerOverflow emit
5051
* SanitizerHandler::DivremOverflow.
5152
*/
5253
case ubsan_divrem_overflow:
@@ -77,6 +78,19 @@ const char *report_ubsan_failure(struct pt_regs *regs, u32 check_type)
7778
return "UBSAN: alignment assumption";
7879
case ubsan_type_mismatch:
7980
return "UBSAN: type mismatch";
81+
#endif
82+
#ifdef CONFIG_UBSAN_SIGNED_WRAP
83+
/*
84+
* SanitizerKind::SignedIntegerOverflow emits
85+
* SanitizerHandler::AddOverflow, SanitizerHandler::SubOverflow,
86+
* or SanitizerHandler::MulOverflow.
87+
*/
88+
case ubsan_add_overflow:
89+
return "UBSAN: integer addition overflow";
90+
case ubsan_sub_overflow:
91+
return "UBSAN: integer subtraction overflow";
92+
case ubsan_mul_overflow:
93+
return "UBSAN: integer multiplication overflow";
8094
#endif
8195
default:
8296
return "UBSAN: unrecognized failure code";

0 commit comments

Comments
 (0)