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 1B1C91974EA; Tue, 10 Sep 2024 10:08:51 +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=1725962931; cv=none; b=IA3akZRb/ddq/T1zA3VDrGAGf4xE0ibuyUlCeyK3K/aISPADlrYs+1uLw3tYnTb6y8jV4fTcqCeMQXEw7S6wRBJXnNSnCZHcBgY6TgKHiO54UacciQq4tzI1zxLnVTYDm0ed/otawPtQ29C02cN9LNy3pnjaBxzOFFw8c9jebqo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725962931; c=relaxed/simple; bh=4XHbwMNb+hk/6TF7mV8+0taj7XSzvjSsv06NObfcdbE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=G8Z8Ya3LSSc9YVJ07iVUAbHdG/Fep5rZB1Mqm5Tv9fBuWUYQ2AxG/uArxUmWMBsdXaQUiJHybhwmjxuvxj7meO4yZCD3JM6tZdC45ohej6HNidpqxTVvmtHt1CWA06Fznv3oXOJ3UBxhn6xM5AFMM4cSmilsGQKaVVzKQbqYM0U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=1ryJU2D4; 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="1ryJU2D4" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8993AC4CEC3; Tue, 10 Sep 2024 10:08:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1725962930; bh=4XHbwMNb+hk/6TF7mV8+0taj7XSzvjSsv06NObfcdbE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1ryJU2D4yUWWvZ9lk/8jUIOkPQ+umdIt5QyP4caL3HBzy3ckrt3xpey7aAubGlEjF gtGY/cUo3XpvHFxFjHoCHuqp5Spq8bgYy0ygB97j9bOsAM6lTRSIWljzA+dqYedFu0 MALzvkdnJFfhtmQKWMstKFHLvLbIjSy5IMylv8ao= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jan Kara , Sasha Levin Subject: [PATCH 6.1 051/192] udf: Avoid excessive partition lengths Date: Tue, 10 Sep 2024 11:31:15 +0200 Message-ID: <20240910092600.085741752@linuxfoundation.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240910092557.876094467@linuxfoundation.org> References: <20240910092557.876094467@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jan Kara [ Upstream commit ebbe26fd54a9621994bc16b14f2ba8f84c089693 ] Avoid mounting filesystems where the partition would overflow the 32-bits used for block number. Also refuse to mount filesystems where the partition length is so large we cannot safely index bits in a block bitmap. Link: https://patch.msgid.link/20240620130403.14731-1-jack@suse.cz Signed-off-by: Jan Kara Signed-off-by: Sasha Levin --- fs/udf/super.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/fs/udf/super.c b/fs/udf/super.c index 3b6419f29a4c..fa790be4f19f 100644 --- a/fs/udf/super.c +++ b/fs/udf/super.c @@ -1084,12 +1084,19 @@ static int udf_fill_partdesc_info(struct super_block *sb, struct udf_part_map *map; struct udf_sb_info *sbi = UDF_SB(sb); struct partitionHeaderDesc *phd; + u32 sum; int err; map = &sbi->s_partmaps[p_index]; map->s_partition_len = le32_to_cpu(p->partitionLength); /* blocks */ map->s_partition_root = le32_to_cpu(p->partitionStartingLocation); + if (check_add_overflow(map->s_partition_root, map->s_partition_len, + &sum)) { + udf_err(sb, "Partition %d has invalid location %u + %u\n", + p_index, map->s_partition_root, map->s_partition_len); + return -EFSCORRUPTED; + } if (p->accessType == cpu_to_le32(PD_ACCESS_TYPE_READ_ONLY)) map->s_partition_flags |= UDF_PART_FLAG_READ_ONLY; @@ -1145,6 +1152,14 @@ static int udf_fill_partdesc_info(struct super_block *sb, bitmap->s_extPosition = le32_to_cpu( phd->unallocSpaceBitmap.extPosition); map->s_partition_flags |= UDF_PART_FLAG_UNALLOC_BITMAP; + /* Check whether math over bitmap won't overflow. */ + if (check_add_overflow(map->s_partition_len, + sizeof(struct spaceBitmapDesc) << 3, + &sum)) { + udf_err(sb, "Partition %d is too long (%u)\n", p_index, + map->s_partition_len); + return -EFSCORRUPTED; + } udf_debug("unallocSpaceBitmap (part %d) @ %u\n", p_index, bitmap->s_extPosition); } -- 2.43.0