]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
x86/fpu: Fix FPU state core dump truncation on CPUs with no extended xfeatures
authorYongxin Liu <yongxin.liu@windriver.com>
Wed, 10 Dec 2025 00:02:20 +0000 (08:02 +0800)
committerIngo Molnar <mingo@kernel.org>
Wed, 10 Dec 2025 07:44:34 +0000 (08:44 +0100)
Zero can be a valid value of num_records. For example, on Intel Atom x6425RE,
only x87 and SSE are supported (features 0, 1), and fpu_user_cfg.max_features
is 3. The for_each_extended_xfeature() loop only iterates feature 2, which is
not enabled, so num_records = 0. This is valid and should not cause core dump
failure.

The issue is that dump_xsave_layout_desc() returns 0 for both genuine errors
(dump_emit() failure) and valid cases (no extended features). Use negative
return values for errors and only abort on genuine failures.

Fixes: ba386777a30b ("x86/elf: Add a new FPU buffer layout info to x86 core files")
Signed-off-by: Yongxin Liu <yongxin.liu@windriver.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://patch.msgid.link/20251210000219.4094353-2-yongxin.liu@windriver.com
arch/x86/kernel/fpu/xstate.c

index 48113c5193aa3c446a869a1f2aceec7c1b831e56..76153dfb58c9d03c86883ad0998ee3ccb8b78056 100644 (file)
@@ -1946,7 +1946,7 @@ static int dump_xsave_layout_desc(struct coredump_params *cprm)
                };
 
                if (!dump_emit(cprm, &xc, sizeof(xc)))
-                       return 0;
+                       return -1;
 
                num_records++;
        }
@@ -1984,7 +1984,7 @@ int elf_coredump_extra_notes_write(struct coredump_params *cprm)
                return 1;
 
        num_records = dump_xsave_layout_desc(cprm);
-       if (!num_records)
+       if (num_records < 0)
                return 1;
 
        /* Total size should be equal to the number of records */