From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 018783D668F; Tue, 16 Jun 2026 19:00:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781636447; cv=none; b=dZVBEHYYIu2M7hwG/iM8RzHi8tQ1n2nLegnkrqqBc9fDcL4WBRr0EiQbkpWumcCu+QXLQWhG4xrdbPssp04Dhhurk4PYlqq65x66IlRTnYHBtBGwIaoedc2nVhExosUA5v2BPMnrT6j8sbHJl6jJ3TkxDun9jCVk6TlOy89t4Ys= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781636447; c=relaxed/simple; bh=2352pqhxa5X3qEbWtsMNp9B3SZyOI/Op3YCm8oSvfis=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cOOmLhHwKpOMcNSIpNhQcG3FDr/MggQ48aKFwMV94LUXNrNb/3jDzTU2LsUs7QmJKQ/V9YZFvut5t26UF+YV28EH5oPvZAYLG7SufoettQbFh56JXIe0+CY2ZLfI+93XkpZ6BvqNXTdSHwU5/06CobX22m7z2Hlr00AFrId9vSw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=mafPeLIV; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="mafPeLIV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 01E551F000E9; Tue, 16 Jun 2026 19:00:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1781636445; bh=IZ/Flk8vesj+PYym3q3j1feBthE1sgM2Li5hDFgsP8c=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=mafPeLIVrefTSXA3gNnvebA5ndI5wndLhznUdOKX4sWBuxDEEKj4LNdqfYUysPHtw acKa15nW4YsJ4IOQkofVajoYw897+sNNY8/V9w4offZRddVG5LneY+PP+W+mFA45If pKdLL/pRh3R9Jnw0wd/RmRet2AOBbBXOqzEL7Mus= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Seohyeon Maeng , Jan Kara , Sasha Levin Subject: [PATCH 5.10 240/342] udf: fix partition descriptor append bookkeeping Date: Tue, 16 Jun 2026 20:28:56 +0530 Message-ID: <20260616145059.388135002@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260616145048.348037099@linuxfoundation.org> References: <20260616145048.348037099@linuxfoundation.org> User-Agent: quilt/0.69 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 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Seohyeon Maeng [ Upstream commit 08841b06fa64d8edbd1a21ca6e613420c90cc4b8 ] Mounting a crafted UDF image with repeated partition descriptors can trigger a heap out-of-bounds write in part_descs_loc[]. handle_partition_descriptor() deduplicates entries by partition number, but appended slots never record partnum. As a result duplicate Partition Descriptors are appended repeatedly and num_part_descs keeps growing. Once the table is full, the growth path still sizes the allocation from partnum even though inserts are indexed by num_part_descs. If partnum is already aligned to PART_DESC_ALLOC_STEP, ALIGN(partnum, step) can keep the old capacity and the next append writes past the end of the table. Store partnum in the appended slot and size growth from the next append count so deduplication and capacity tracking follow the same model. Fixes: ee4af50ca94f ("udf: Fix mounting of Win7 created UDF filesystems") Cc: stable@vger.kernel.org Signed-off-by: Seohyeon Maeng Link: https://patch.msgid.link/20260310081652.21220-1-bioloidgp@gmail.com Signed-off-by: Jan Kara [ replaced kzalloc_objs() helper with equivalent kcalloc() ] Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- fs/udf/super.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/fs/udf/super.c +++ b/fs/udf/super.c @@ -1657,8 +1657,9 @@ static struct udf_vds_record *handle_par return &(data->part_descs_loc[i].rec); if (data->num_part_descs >= data->size_part_descs) { struct part_desc_seq_scan_data *new_loc; - unsigned int new_size = ALIGN(partnum, PART_DESC_ALLOC_STEP); + unsigned int new_size; + new_size = data->num_part_descs + PART_DESC_ALLOC_STEP; new_loc = kcalloc(new_size, sizeof(*new_loc), GFP_KERNEL); if (!new_loc) return ERR_PTR(-ENOMEM); @@ -1668,6 +1669,7 @@ static struct udf_vds_record *handle_par data->part_descs_loc = new_loc; data->size_part_descs = new_size; } + data->part_descs_loc[data->num_part_descs].partnum = partnum; return &(data->part_descs_loc[data->num_part_descs++].rec); }