panic: Fix TAINT_FLAGS_MAX overflow on i686

This commit is contained in:
eabdullin 2026-01-22 11:43:26 +03:00
parent af79e504bb
commit 57d1452fdb
2 changed files with 42 additions and 0 deletions

View File

@ -0,0 +1,35 @@
From 44fe6b26d992d1e432f62c6f817814a77bb803fb Mon Sep 17 00:00:00 2001
From: eabdullin <eabdullin@almalinux.org>
Date: Thu, 22 Jan 2026 11:41:17 +0300
Subject: [PATCH] panic: Fix TAINT_FLAGS_MAX overflow on i686
Red Hat specific taint flags extend TAINT_FLAGS_COUNT to 32.
On 32-bit architectures this makes (1UL << TAINT_FLAGS_COUNT)
an invalid shift (shift by the width of unsigned long), resulting
in undefined behaviour and build failures with -Wshift-count-overflow.
Fix this by avoiding the shift when TAINT_FLAGS_COUNT >= BITS_PER_LONG
and using an all-bits-set mask instead.
---
include/linux/panic.h | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/include/linux/panic.h b/include/linux/panic.h
index 0ac2aa0c0..ccef37b4b 100644
--- a/include/linux/panic.h
+++ b/include/linux/panic.h
@@ -92,7 +92,12 @@ static inline void set_arch_panic_timeout(int timeout, int arch_default_timeout)
#define TAINT_UNPRIVILEGED_BPF 31
/* End of Red Hat-specific taint flags */
#define TAINT_FLAGS_COUNT 32
+
+#if TAINT_FLAGS_COUNT >= BITS_PER_LONG
+#define TAINT_FLAGS_MAX (~0UL)
+#else
#define TAINT_FLAGS_MAX ((1UL << TAINT_FLAGS_COUNT) - 1)
+#endif
struct taint_flag {
char c_true; /* character printed when tainted */
--
2.51.0

View File

@ -1160,6 +1160,9 @@ Patch2007: 0007-Bring-back-deprecated-pci-ids-to-be2iscsi-driver.patch
Patch2008: 0008-Bring-back-deprecated-pci-ids-to-megaraid_sas-driver.patch
Patch2009: 0009-Bring-back-deprecated-pci-ids-to-mpt3sas-driver.patch
# i686 specific patches
Patch2010: 0001-panic-Fix-TAINT_FLAGS_MAX-overflow-on-i686.patch
# END OF PATCH DEFINITIONS
%description
@ -2019,6 +2022,10 @@ ApplyPatch 0007-Bring-back-deprecated-pci-ids-to-be2iscsi-driver.patch
ApplyPatch 0008-Bring-back-deprecated-pci-ids-to-megaraid_sas-driver.patch
ApplyPatch 0009-Bring-back-deprecated-pci-ids-to-mpt3sas-driver.patch
%ifarch i686
ApplyPatch 0001-panic-Fix-TAINT_FLAGS_MAX-overflow-on-i686.patch
%endif
%{log_msg "End of patch applications"}
# END OF PATCH APPLICATIONS