From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ACE6C27B355; Mon, 18 Aug 2025 12:55:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755521755; cv=none; b=rDxy0qXQRVdQAf9KxQRj4IKGLCLOGgLyFVOimmmNowQIUifYqw/WZE/snL92KPIxNdtl9u3pXquesjuR83NuRR85iPm9A9gx4ONoStJZk8mY69UXEJ7ei5rV6E+IkW+zdP8oF7FhiidnHXl+J8GPqHbLjVrwT6Hq0mOlCH+NqDg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755521755; c=relaxed/simple; bh=HYINa91+3YHMXM1NgjK155e45iCBjcSmCLai9NYBDoE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Dy98PnyA+F7+z5Nke2tV0IZVPPACPRr5L15AifumVRx1I0NBkcZg8IGSqxUYO9okiCkTrRM2VmLQx/a0pEXv0vsbHiUxMYbzEFvF+upVqcSv8J4V2EgA0Cm262F8Caj/LyTTfaUehWdkeEhwpRscsUHUk5Nh94lX7AvNaVc413Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=JzfNlEKB; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="JzfNlEKB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A9F84C4CEEB; Mon, 18 Aug 2025 12:55:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1755521755; bh=HYINa91+3YHMXM1NgjK155e45iCBjcSmCLai9NYBDoE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JzfNlEKBoTPxzTKiSD8RbHOzOnAb9dhigkku8klKbQlY46B0Y2nbjSn35s16+NpLB 9CUEBRcMd/nES68TCkX7cCJOa9PqGrvUwWv97+epaMyGV0GqsXi8umprVtAEEwZX+U YIWlfe/bO/UUO2HmtOLJcgnC/OEMNhpyQcE6ecb4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, syzbot+478f2c1a6f0f447a46bb@syzkaller.appspotmail.com, Jan Kara , Sasha Levin Subject: [PATCH 6.12 080/444] udf: Verify partition map count Date: Mon, 18 Aug 2025 14:41:46 +0200 Message-ID: <20250818124451.955349171@linuxfoundation.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250818124448.879659024@linuxfoundation.org> References: <20250818124448.879659024@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jan Kara [ Upstream commit 1a11201668e8635602577dcf06f2e96c591d8819 ] Verify that number of partition maps isn't insanely high which can lead to large allocation in udf_sb_alloc_partition_maps(). All partition maps have to fit in the LVD which is in a single block. Reported-by: syzbot+478f2c1a6f0f447a46bb@syzkaller.appspotmail.com Signed-off-by: Jan Kara Signed-off-by: Sasha Levin --- fs/udf/super.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/fs/udf/super.c b/fs/udf/super.c index 1c8a736b3309..b2f168b0a0d1 100644 --- a/fs/udf/super.c +++ b/fs/udf/super.c @@ -1440,7 +1440,7 @@ static int udf_load_logicalvol(struct super_block *sb, sector_t block, struct genericPartitionMap *gpm; uint16_t ident; struct buffer_head *bh; - unsigned int table_len; + unsigned int table_len, part_map_count; int ret; bh = udf_read_tagged(sb, block, block, &ident); @@ -1461,7 +1461,16 @@ static int udf_load_logicalvol(struct super_block *sb, sector_t block, "logical volume"); if (ret) goto out_bh; - ret = udf_sb_alloc_partition_maps(sb, le32_to_cpu(lvd->numPartitionMaps)); + + part_map_count = le32_to_cpu(lvd->numPartitionMaps); + if (part_map_count > table_len / sizeof(struct genericPartitionMap1)) { + udf_err(sb, "error loading logical volume descriptor: " + "Too many partition maps (%u > %u)\n", part_map_count, + table_len / (unsigned)sizeof(struct genericPartitionMap1)); + ret = -EIO; + goto out_bh; + } + ret = udf_sb_alloc_partition_maps(sb, part_map_count); if (ret) goto out_bh; -- 2.39.5