]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
s390/bug: Always emit format word in __BUG_ENTRY
authorJan Polensky <japo@linux.ibm.com>
Thu, 21 May 2026 12:01:32 +0000 (14:01 +0200)
committerAlexander Gordeev <agordeev@linux.ibm.com>
Thu, 28 May 2026 10:08:27 +0000 (12:08 +0200)
When CONFIG_DEBUG_BUGVERBOSE is disabled, the s390 __BUG_ENTRY() macro
omits the format string pointer, so the generated __bug_table entry no
longer matches struct bug_entry.

With HAVE_ARCH_BUG_FORMAT enabled, the generic BUG infrastructure reads
bug_entry::format via bug_get_format(). If the format word is missing,
subsequent fields are read from the wrong offset, which may:
- Misinterpret flags (BUG vs WARN classification errors)
- Fault when dereferencing a misread format pointer

The root cause is that __BUG_ENTRY() delegates format word emission to
__BUG_ENTRY_VERBOSE(), which is conditional on CONFIG_DEBUG_BUGVERBOSE.

Fix this by moving the format field emission directly into __BUG_ENTRY()
so it is always emitted unconditionally. Remove the format parameter from
__BUG_ENTRY_VERBOSE() and keep only file/line emission conditional on
CONFIG_DEBUG_BUGVERBOSE.

Fixes: 2b71b8ab9718 ("s390/bug: Use BUG_FORMAT for DEBUG_BUGVERBOSE_DETAILED")
Signed-off-by: Jan Polensky <japo@linux.ibm.com>
Reviewed-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
arch/s390/include/asm/bug.h

index 59017fd3d9358d495fc06ec9775b12cbb4c27f37..50a270edb020350065beefa5de2964435b710d6b 100644 (file)
 #if defined(CONFIG_BUG) && defined(CONFIG_CC_HAS_ASM_IMMEDIATE_STRINGS)
 
 #ifdef CONFIG_DEBUG_BUGVERBOSE
-#define __BUG_ENTRY_VERBOSE(format, file, line)                                \
-       "       .long   " format " - .  # bug_entry::format\n"          \
+#define __BUG_ENTRY_VERBOSE(file, line)                                        \
        "       .long   " file " - .    # bug_entry::file\n"            \
        "       .short  " line "        # bug_entry::line\n"
 #else
-#define __BUG_ENTRY_VERBOSE(format, file, line)
+#define __BUG_ENTRY_VERBOSE(file, line)
 #endif
 
 #ifdef CONFIG_DEBUG_BUGVERBOSE_DETAILED
 
 #define __BUG_ENTRY(format, file, line, flags, size)                   \
                "       .section __bug_table,\"aw\"\n"                  \
-               "1:     .long   0b - .  # bug_entry::bug_addr\n"        \
-               __BUG_ENTRY_VERBOSE(format, file, line)                 \
-               "       .short  "flags" # bug_entry::flags\n"           \
+               "1:     .long   0b - .          # bug_entry::bug_addr\n"\
+               "       .long   " format " - .  # bug_entry::format\n"  \
+               __BUG_ENTRY_VERBOSE(file, line)                         \
+               "       .short  "flags"         # bug_entry::flags\n"   \
                "       .org    1b+"size"\n"                            \
                "       .previous"