From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796384411; b=beVHACTPJu8PB1GvW0QMEf4eNgTh4llVvS7gIIE/QStmZUJhFsmOdWmGGfYbZdJOEmm/ bthhAzcVj2+ex2Vnc3GQk9bQKsvkln9I6jJKjQ6QKo4tJRpM/i1VMPilv0NRqGmm6Nwlu 2pYj0c2z0SMwf7uMYn7nmQyTWu6b9PyNu9u9qYjPXG7bukjj8iuvn7bPo8AnmAqiZjg9O KZpQRhKq9yDH6cuegetHuGMVnYtAr6Vh0U33K9Rv09iBIvKXhkPHH2RChdWPvH3OU/2SM iMWw1IGm8YLO1gL5ja4EWIxZz/nm6vDq/Imltez7SR9+qxLqnLT3DJdpgCZLRdoVIfg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796384411; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=bYv1xykUqN+w1pzePWu1NfBR1fEl8q2fqlabWGfL2U4=; b=FbV21Xi3HnZT4aPtCAe/A/2dGuIhiT6NB8uNh1O+1nvNwFHW6fdwqq8gaxJN3LQytHOH xMPBrsOZ9KK8mZ68J+EfUbH0/rVb9EC3E7QWLMkmWQO9kuT9Ue7UErQDQT2527CMltCWx 1fQ4Gb1ACj1YDArg5te42ztUmmIsKuq8jCyUn6u5hJsc9MnuYJ+1hKWxLpRP9FGIU6c+F bSzOkv3gMc4VYkLmIv8g/vXtbdcEMazNtxGYiKk3234ok4eBiK25kXhrPgLFH5kCmj1/5 yQbvWUtdaYIQ9CUXrFgwoAQ0LOK3ufpwFw13vbd+I2lkjqH6RxZ9ogr0V4t9QHrBboQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=w+Pqi2u6; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2F559606A32C; Fri, 4 Dec 2026 11:40:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=w+Pqi2u6 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9B7EC1F000C2; Fri, 4 Dec 2026 11:40:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796384411; bh=bYv1xykUqN+w1pzePWu1NfBR1fEl8q2fqlabWGfL2U4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=w+Pqi2u6yzBeoTpdBFA0EGCaCCsG9ak5M0vsv3Qoz4qMYBg5OXNWsRcgd9iSBu7YM 4Ve4zWOSkbj248cWtjjf6PJ/d1f1YlNOfxp5wChnbdP6mcBQufYsguj5LQlnthNiJs 5YciFtGUjU1Hss5E+3cKg8cocdZFz4rlB2mmn73c= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Zizhi Wo , Christoph Hellwig , Jens Axboe , Sasha Levin Subject: [PATCH 6.6 0137/1167] block: partitions: reject GPT entries with starting_lba > ending_lba Date: Fri, 4 Dec 2026 18:52:44 +0900 Message-ID: <20261204100705.658466463@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Zizhi Wo [ Upstream commit 7e3801d12ebabaa3db6e2685ccc80b6e6f6d1ff7 ] A GPT entry whose starting_lba is greater than its ending_lba is accepted, and the kernel creates a partition with a bogus size. The bogus sector count defeats the end-of-device check, so I/O through that partition is not confined to it and can access sectors outside the partition on the same disk. is_pte_valid() only rejects an entry when its type is NULL or when starting_lba or ending_lba is greater than lastlba; it never checks that starting_lba <= ending_lba. For a reversed entry both field checks still pass, but efi_partition() computes size = ending_lba - starting_lba + 1 in u64, which underflows to a huge value. That value also wraps in the end-of-device check in blk_add_partition() (from + size) and does not fit the signed i_size, which turns negative. Reject entries with starting_lba > ending_lba in is_pte_valid(), matching the head-level check against last_usable_lba < first_usable_lba. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Zizhi Wo Reviewed-by: Christoph Hellwig Link: https://patch.msgid.link/20261102080442.3775061-1-wozizhi@huaweicloud.com Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- block/partitions/efi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/block/partitions/efi.c b/block/partitions/efi.c index 7acba66eed481..d88321f6400ab 100644 --- a/block/partitions/efi.c +++ b/block/partitions/efi.c @@ -461,6 +461,7 @@ static inline int is_pte_valid(const gpt_entry *pte, const u64 lastlba) { if ((!efi_guidcmp(pte->partition_type_guid, NULL_GUID)) || + le64_to_cpu(pte->starting_lba) > le64_to_cpu(pte->ending_lba) || le64_to_cpu(pte->starting_lba) > lastlba || le64_to_cpu(pte->ending_lba) > lastlba) return 0; -- 2.53.0