From: Pengpeng Hou <pengpeng@iscas.ac.cn>
To: Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,
Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
x86@kernel.org
Cc: "H. Peter Anvin" <hpa@zytor.com>,
Andy Lutomirski <luto@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
linux-kernel@vger.kernel.org, pengpeng@iscas.ac.cn
Subject: [PATCH 2/2] x86/boot/compressed/kaslr: validate indirect setup_data payloads
Date: Sat, 4 Apr 2026 17:32:04 +0800 [thread overview]
Message-ID: <20260404190002.2-x86-kaslr-pengpeng@iscas.ac.cn> (raw)
In-Reply-To: <20260404190001.1-x86-setup-data-pengpeng@iscas.ac.cn>
mem_avoid_overlap() checks SETUP_INDIRECT entries in the boot-time
setup_data chain and reads an embedded struct setup_indirect directly from
ptr->data.
If ptr->len is smaller than sizeof(struct setup_indirect), that access can
run past the setup_data payload before compressed x86 boot has finished
walking the list.
Require the indirect payload to be large enough before dereferencing it.
Short entries are still covered by the outer setup_data avoidance range, so
this only drops the unsafe embedded-header walk.
Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
---
arch/x86/boot/compressed/kaslr.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c
index 3b0948ad449f..1205ea588431 100644
--- a/arch/x86/boot/compressed/kaslr.c
+++ b/arch/x86/boot/compressed/kaslr.c
@@ -432,6 +432,7 @@ static bool mem_avoid_overlap(struct mem_vector *img,
}
if (ptr->type == SETUP_INDIRECT &&
+ ptr->len >= sizeof(struct setup_indirect) &&
((struct setup_indirect *)ptr->data)->type != SETUP_INDIRECT) {
avoid.start = ((struct setup_indirect *)ptr->data)->addr;
avoid.size = ((struct setup_indirect *)ptr->data)->len;
--
2.50.1 (Apple Git-155)
next prev parent reply other threads:[~2026-04-04 13:55 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-04 13:48 [PATCH 1/2] x86/setup_data: validate indirect entry sizes before dereferencing them Pengpeng Hou
2026-04-04 9:32 ` Pengpeng Hou [this message]
2026-04-04 21:53 ` Borislav Petkov
2026-04-05 1:40 ` Pengpeng Hou
2026-04-05 11:06 ` Borislav Petkov
2026-04-06 20:54 ` H. Peter Anvin
2026-04-05 3:20 ` Pengpeng Hou
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260404190002.2-x86-kaslr-pengpeng@iscas.ac.cn \
--to=pengpeng@iscas.ac.cn \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=tglx@kernel.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®