From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from cstnet.cn (smtp21.cstnet.cn [159.226.251.21]) (using TLSv1.2 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6A7C32264A3 for ; Sun, 5 Apr 2026 02:15:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.226.251.21 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775355318; cv=none; b=RML9aaNXSwt6ygBNtTe1fQk1LHJ28DnXGzGzGO9j5eBExvq44o2GGt6YZtL66c7GvJcOurq16S7yIWMRhoMvFkcZ3t+vYwns4qOn1abcDO/cc1gZF4B1AkxZ4aOE1ImQEVapYr9AlH/o9Fe1ID9gvCDGath2vIGk3jo+2fNtjmo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775355318; c=relaxed/simple; bh=pNjwf3exX9YiDwm8TEmSP4mbjvcq2fQfI6/+Dp7hvuw=; h=From:Date:Message-ID:To:Cc:In-Reply-To:References:Subject: MIME-Version:Content-Type; b=NwIJZe4nPWppJKCm8WVezI/0EQb0gpZqmu5eQJhInKmr2VsFuzlHhr6xju1qMngR0qdLWNlBMqvVrdA8/QGqAPo1UEV2pVgp9sPhvc4PyrvY9xiG4umirMdEVzpmw02t7X6NTP/N5LgfRt96HtfuDYs/mdFTUsokmKhjsMygJZs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=iscas.ac.cn; spf=pass smtp.mailfrom=iscas.ac.cn; arc=none smtp.client-ip=159.226.251.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=iscas.ac.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=iscas.ac.cn Received: from 0002-x86-setup-data-reply.eml (unknown [111.196.245.197]) by APP-01 (Coremail) with SMTP id qwCowAD3oGyhxdFpQQU5DA--.18550S2; Sun, 05 Apr 2026 10:14:57 +0800 (CST) From: Pengpeng Hou Date: Sun, 5 Apr 2026 09:40:00 +0800 Message-ID: <20260405094002.2-reply-x86-setup-data-pengpeng@iscas.ac.cn> To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org Cc: "H. Peter Anvin" , Andy Lutomirski , Peter Zijlstra , linux-kernel@vger.kernel.org, pengpeng@iscas.ac.cn In-Reply-To: <20260404190001.1-x86-setup-data-pengpeng@iscas.ac.cn> References: <20260404190001.1-x86-setup-data-pengpeng@iscas.ac.cn> Subject: Re: [PATCH 1/2] x86/setup_data: validate indirect entry sizes before dereferencing them Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-CM-TRANSID:qwCowAD3oGyhxdFpQQU5DA--.18550S2 X-Coremail-Antispam: 1UD129KBjvJXoW7Zr4kAry5urW5Zr1xWw4kJFb_yoW8Gr1Upa y3Kr1Yyr1kJrWxtw1kZa17Cay3Xr13JayYgF4vka40yrn0gr10kF17Kw1I93WjkrZ5G34Y qw4jga4rZ3WDtaUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvE14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26r4j6ryUM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4j 6F4UM28EF7xvwVC2z280aVAFwI0_Cr1j6rxdM28EF7xvwVC2z280aVCY1x0267AKxVWxJr 0_GcWle2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E 2Ix0cI8IcVAFwI0_JrI_JrylYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJV W8JwACjcxG0xvEwIxGrwACjI8F5VA0II8E6IAqYI8I648v4I1lFIxGxcIEc7CjxVA2Y2ka 0xkIwI1lc7CjxVAaw2AFwI0_Jw0_GFyl42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7 v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF 1VAY17CE14v26r1q6r43MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIx AIcVC0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI 42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWI evJa73UjIFyTuYvjfUFg4SDUUUU X-CM-SenderInfo: pshqw1xhqjqxpvfd2hldfou0/ Hi Boris, Because the failure mode here is not just “the bootloader passed nonsense” in a semantic sense; the current code can dereference past the mapped payload of a malformed `SETUP_INDIRECT` entry. The affected paths first read the outer `struct setup_data` header, and then some of them treat `data->len` as though it always covers a full `struct setup_indirect`. If `data->len` is short, or wraps when `sizeof(struct setup_data) + data->len` is computed, the kernel can remap or reserve less than a full indirect header and still read `indirect->type`, `addr`, or `len` beyond that range. So the thing I was trying to harden is not “make every bad setup_data entry boot successfully”; it is “do not turn malformed boot metadata into a kernel OOB read while walking setup_data”. I think that is worth handling because `setup_data` is still external boot input to the kernel. It can come not only from a normal bootloader path, but also from kexec-style handoff and virtualized boot flows. The intended fallback here is narrow and local: if an indirect entry is malformed, keep treating the outer `setup_data` payload as opaque instead of walking the embedded header. That way we avoid the out-of-bounds read without trying to make malformed metadata otherwise “work”. Thanks, Pengpeng