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=1795059297; b=n5MTqihqJQdShvwl0l2c0VW0A+rP2AX9HbvCumYxg2Qd1R0MkxHablzC3qW9xrygW67c 22YRHPXhpJIi/f7fPfzBQi4efXUqHjH2QTrp8jOpvEE8FuSrFhH9PiUcsNwQ1I0cbhzbQ FlJL43RgE1XGbBre22k2fu1+3Digivnvyh8BZrIj424roJHlf54qT+SGG0oWmUrWWOo0E YM6a63BIXLOE1RDwxdLS894Gc3lpiTKWNIqgrhgiJzj+N0Cn7HOK/eiyujYWGOfP8c1yY V/GTyqiujN4LX7nN3z/MiFw8t6ERAi1YgSTyCrNkwxyduvYBcJxmg23cC9a5G1jOHdQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795059297; 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=paU7D3y/4NUa5H+fSpo9OvygzThpuXpL5MfTHKcf2gA=; b=3DnNNYL6qLBoKHLNXTwHVYwxr5L4jJGLndg85tBrFoL4v9iMl73XBuBwjx6t3vWfjFUx L7+8qmEZnAuJMvxbdsU6cNxTdWpEuH/sdy+9WTWhT7fk/ldTQ34beSAvx+ARck/L/fC8H Gupfv5H/l9cA3GUM13srP7M6oJkFqZ80Z9k4S3WDML4O9bXOBewI4N77wD2q+ZhjdgJ7q 2OAXS8wZfRgrHulnQ7RKSI2rVfiQa+MYxYJanIfly5jPAQPRU4IpkD1kURsnMx499RMYD vTKGCZ0rwZRwant0G7xAC979xGNqPRw8Hlju868/FtPukfzUYJMxbjQp6S97YX/1CVg== 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=gH5X474L; 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 A73D4606A31C; Thu, 19 Nov 2026 03:34:57 +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=gH5X474L Received: by smtp.kernel.org (Postfix) with ESMTPSA id D23411F000C5; Thu, 19 Nov 2026 03:34:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795059297; bh=paU7D3y/4NUa5H+fSpo9OvygzThpuXpL5MfTHKcf2gA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=gH5X474Ld1FOc7ISSVyGnpJALfLphvhhCjgXP3dZIHTl9Et5Li/5SNcKr9HYbgijW oT2xX4qCnyYn4NaZ2Xfh+ZPVZDgde4o5/PIMULTv6vfcc3B6nn/plZklRsuuIYFhg9 sWWigTZiIQq8sRcUDyAzqZhYXm/aWtKTp/MPJXvU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Robert Morris , Jan Kara , Sasha Levin Subject: [PATCH 5.10 0790/1848] udf: Avoid invalid LVID used on mount Date: Wed, 18 Nov 2026 15:47:08 +0100 Message-ID: <20261118145949.502166765@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261118145911.150052362@linuxfoundation.org> References: <20261118145911.150052362@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jan Kara [ Upstream commit c8f1140cb82dc843e72697dc6f8c7ee1acce5d28 ] udf_load_logicalvolint() loads logical volume integrity descriptors. Since there can be multiple blocks with LVIDs, we verify the contents of only the last (prevailing) LVID found. However if we fail to load the last LVID (either due to IO error or because it's checksum fails to match), we never perform the verification of validity of the LVID we are going to use. If such LVID contains invalid data, we can hit out-of-bounds access or similar issues. Fix the problem by verifying each LVID we are potentially going to accept. Reported-by: Robert Morris Signed-off-by: Jan Kara Stable-dep-of: a61fb39759d7 ("udf: Make sure there's enough space for LVID implementation use field") Signed-off-by: Sasha Levin --- fs/udf/super.c | 42 +++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/fs/udf/super.c b/fs/udf/super.c index 467e760863486..58bc19b82afa4 100644 --- a/fs/udf/super.c +++ b/fs/udf/super.c @@ -1574,6 +1574,20 @@ static int udf_load_logicalvol(struct super_block *sb, sector_t block, return ret; } +static bool udf_lvid_valid(struct super_block *sb, + struct logicalVolIntegrityDesc *lvid) +{ + u32 parts, impuselen; + + parts = le32_to_cpu(lvid->numOfPartitions); + impuselen = le32_to_cpu(lvid->lengthOfImpUse); + if (parts >= sb->s_blocksize || impuselen >= sb->s_blocksize || + sizeof(struct logicalVolIntegrityDesc) + impuselen + + 2 * parts * sizeof(u32) > sb->s_blocksize) + return false; + return true; +} + /* * Find the prevailing Logical Volume Integrity Descriptor. */ @@ -1584,7 +1598,6 @@ static void udf_load_logicalvolint(struct super_block *sb, struct kernel_extent_ struct udf_sb_info *sbi = UDF_SB(sb); struct logicalVolIntegrityDesc *lvid; int indirections = 0; - u32 parts, impuselen; while (++indirections <= UDF_MAX_LVID_NESTING) { final_bh = NULL; @@ -1606,32 +1619,27 @@ static void udf_load_logicalvolint(struct super_block *sb, struct kernel_extent_ if (!final_bh) return; - brelse(sbi->s_lvid_bh); - sbi->s_lvid_bh = final_bh; - lvid = (struct logicalVolIntegrityDesc *)final_bh->b_data; + if (udf_lvid_valid(sb, lvid)) { + brelse(sbi->s_lvid_bh); + sbi->s_lvid_bh = final_bh; + } else { + udf_warn(sb, "Corrupted LVID (parts=%u, impuselen=%u), " + "ignoring.\n", + le32_to_cpu(lvid->numOfPartitions), + le32_to_cpu(lvid->lengthOfImpUse)); + } + if (lvid->nextIntegrityExt.extLength == 0) - goto check; + return; loc = leea_to_cpu(lvid->nextIntegrityExt); } udf_warn(sb, "Too many LVID indirections (max %u), ignoring.\n", UDF_MAX_LVID_NESTING); -out_err: brelse(sbi->s_lvid_bh); sbi->s_lvid_bh = NULL; - return; -check: - parts = le32_to_cpu(lvid->numOfPartitions); - impuselen = le32_to_cpu(lvid->lengthOfImpUse); - if (parts >= sb->s_blocksize || impuselen >= sb->s_blocksize || - sizeof(struct logicalVolIntegrityDesc) + impuselen + - 2 * parts * sizeof(u32) > sb->s_blocksize) { - udf_warn(sb, "Corrupted LVID (parts=%u, impuselen=%u), " - "ignoring.\n", parts, impuselen); - goto out_err; - } } /* -- 2.53.0