* + tools-bootconfig-fix-integer-overflow-in-size-check.patch added to mm-hotfixes-unstable branch
@ 2026-09-10 4:29 Andrew Morton
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Morton @ 2026-09-10 4:29 UTC (permalink / raw)
To: mm-commits, stable, sashiko-bot, ekffu200098, mhiramat, akpm
The patch titled
Subject: tools/bootconfig: Fix integer overflow in size check
has been added to the -mm mm-hotfixes-unstable branch. Its filename is
tools-bootconfig-fix-integer-overflow-in-size-check.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/tools-bootconfig-fix-integer-overflow-in-size-check.patch
This patch will later appear in the mm-hotfixes-unstable branch at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next via various
branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there most days
------------------------------------------------------
From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Subject: tools/bootconfig: Fix integer overflow in size check
Date: Thu, 10 Sep 2026 09:30:46 +0900
Sashiko reported that on 32-bit systems, if the size in the bootconfig
footer is corrupted such that adding BOOTCONFIG_FOOTER_SIZE wraps around
(for instance, if size is 0xFFFFFFFF), the size check in
load_xbc_from_initrd() can be bypassed:
if (stat.st_size < size + BOOTCONFIG_FOOTER_SIZE) {
pr_err("bootconfig size is too big\n");
return -E2BIG;
}
This would lead to load_xbc_fd() being called with a negative size,
resulting in an undersized allocation, heap overflow on read, and
out-of-bounds write on the terminating null byte.
Avoid the integer overflow by checking whether size is greater than
stat.st_size - BOOTCONFIG_FOOTER_SIZE. Since stat.st_size is already
verified to be at least BOOTCONFIG_FOOTER_SIZE earlier in the function,
this subtraction will never underflow.
Link: https://lore.kernel.org/178900024679.183840.10345859264677533824.stgit@devnote2
Fixes: 950313ebf79c ("tools: bootconfig: Add bootconfig command")
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://lore.kernel.org/all/20260909161113.16C691F00A3A@smtp.kernel.org/
Assisted-by: Antigravity:gemini-3.8-flash
Cc: Sang-Heon Jeon <ekffu200098@gmail.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
tools/bootconfig/main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/tools/bootconfig/main.c~tools-bootconfig-fix-integer-overflow-in-size-check
+++ a/tools/bootconfig/main.c
@@ -218,7 +218,7 @@ static int load_xbc_from_initrd(int fd,
csum = le32toh(csum);
/* Wrong size error */
- if (stat.st_size < size + BOOTCONFIG_FOOTER_SIZE) {
+ if (size > stat.st_size - BOOTCONFIG_FOOTER_SIZE) {
pr_err("bootconfig size is too big\n");
return -E2BIG;
}
_
Patches currently in -mm which might be from mhiramat@kernel.org are
tools-bootconfig-fix-integer-overflow-in-size-check.patch
bootconfig-reject-unexpected-data-after-null-character.patch
tools-bootconfig-consolidate-xbc_init-to-error-message-wrapper.patch
bootconfig-skip-internal-tree-sanity-checks-in-kernel.patch
^ permalink raw reply [flat|nested] 2+ messages in thread
* + tools-bootconfig-fix-integer-overflow-in-size-check.patch added to mm-hotfixes-unstable branch
@ 2026-09-10 4:31 Andrew Morton
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Morton @ 2026-09-10 4:31 UTC (permalink / raw)
To: mm-commits, stable, sashiko-bot, ekffu200098, mhiramat, akpm
The patch titled
Subject: tools/bootconfig: fix integer overflow in size check
has been added to the -mm mm-hotfixes-unstable branch. Its filename is
tools-bootconfig-fix-integer-overflow-in-size-check.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/tools-bootconfig-fix-integer-overflow-in-size-check.patch
This patch will later appear in the mm-hotfixes-unstable branch at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next via various
branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there most days
------------------------------------------------------
From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Subject: tools/bootconfig: fix integer overflow in size check
Date: Thu, 10 Sep 2026 09:45:45 +0900
Sashiko reported that on 32-bit systems, if an attacker crafts size in the
bootconfig footer such that adding BOOTCONFIG_FOOTER_SIZE wraps around
(for instance, if size is 0xFFFFFFFF), the size check in
load_xbc_from_initrd() can be bypassed:
if (stat.st_size < size + BOOTCONFIG_FOOTER_SIZE) {
pr_err("bootconfig size is too big\n");
return -E2BIG;
}
This would lead to load_xbc_fd() being called with a negative size,
resulting in an undersized allocation, heap overflow on read, and
out-of-bounds write on the terminating null byte.
Avoid the integer overflow by checking whether size is greater than
stat.st_size - BOOTCONFIG_FOOTER_SIZE. Since stat.st_size is already
verified to be at least BOOTCONFIG_FOOTER_SIZE earlier in the function,
this subtraction will never underflow.
Also reject size > XBC_DATA_MAX upfront in load_xbc_from_initrd() to avoid
allocating and reading oversized configurations into memory before
xbc_init() validation.
Link: https://lore.kernel.org/178900114498.187028.9558747732041210116.stgit@devnote2
Fixes: 950313ebf79c ("tools: bootconfig: Add bootconfig command")
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://lore.kernel.org/all/20260909161113.16C691F00A3A@smtp.kernel.org/
Assisted-by: Antigravity:gemini-3.8-flash
Cc: Sang-Heon Jeon <ekffu200098@gmail.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
tools/bootconfig/main.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
--- a/tools/bootconfig/main.c~tools-bootconfig-fix-integer-overflow-in-size-check
+++ a/tools/bootconfig/main.c
@@ -218,7 +218,8 @@ static int load_xbc_from_initrd(int fd,
csum = le32toh(csum);
/* Wrong size error */
- if (stat.st_size < size + BOOTCONFIG_FOOTER_SIZE) {
+ if (size > XBC_DATA_MAX ||
+ size > stat.st_size - BOOTCONFIG_FOOTER_SIZE) {
pr_err("bootconfig size is too big\n");
return -E2BIG;
}
_
Patches currently in -mm which might be from mhiramat@kernel.org are
tools-bootconfig-fix-integer-overflow-in-size-check.patch
bootconfig-reject-unexpected-data-after-null-character.patch
tools-bootconfig-consolidate-xbc_init-to-error-message-wrapper.patch
bootconfig-skip-internal-tree-sanity-checks-in-kernel.patch
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-10 4:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-10 4:31 + tools-bootconfig-fix-integer-overflow-in-size-check.patch added to mm-hotfixes-unstable branch Andrew Morton
-- strict thread matches above, loose matches on Subject: below --
2026-09-10 4:29 Andrew Morton
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.