From nobody Thu Apr 9 07:05:14 2026 Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 26B7534EEEF for ; Tue, 10 Mar 2026 08:17:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773130655; cv=none; b=s9cHLSwiRcEhf7PSnT1ogJuiKPomhu/T+ugEsDVphmjuO3eWfXmK1BOes/4Kdd0VrCC0geRmQGSqsyYfKRqq3CQCypsbH0E+l9PF28Jf+JTdQXkWHbocyV7CM/w0yfbADM33zwXTPxiegBE9O6+6uKTH0NUfv8ZCt3+BrijvL74= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773130655; c=relaxed/simple; bh=/D/qOvBY8V7Pb4JsqtZ+y2EJY5cGHgmFaYtqSaQeLIU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=lZEZGAKKTK3AV2pEc6q1zH9DcI7QHLnm8X0AfTLStKOI1vIW7/QdEgteqcA5rptzm9K7B9xn/6jpfOV6Y6xkvGGazKihR1mcICOGc14brKpK3AnlSWts7psGg1hnxDd4LUjePPbtpwsacbs2bODzFg8zLlkjr1R1megfWTr2GGk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=X7UJfx4B; arc=none smtp.client-ip=209.85.210.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="X7UJfx4B" Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-829865a8471so5213009b3a.3 for ; Tue, 10 Mar 2026 01:17:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773130653; x=1773735453; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=NSX2/KunvfJmTIm/YDzKXoDaJ8O0AYEhpCELONSClG8=; b=X7UJfx4BfRH9Vq2IkCNHxIZHgRJnGALnkDkhr0bKj3Rm0IpPAWJZP7xY8880pC27Es ErUFFSEGyeIus+OaV6vNaShM95fUJfRmkRMg86+VkAusw3HqtwEtzNOuuAnSl+P1vkm1 ldCO0+j2gBRubDnxsJCdZBMxqL3x8vlQOjRpe08Z/OiVQstba6BQLhWuyObZ2//SoKMr Src281gMoA1tQwxTiPovPPRiYCpg8SnbKAIS6VKq7tzf6y/P1ZtAwTtIZVuKwkT8PycY ax4f1bE+095aJ/vzjPjboQ5gjvX3lzFzly+UuLytWhB1QJnviWEgJVjAh+dQDyAKRql0 cfzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773130653; x=1773735453; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=NSX2/KunvfJmTIm/YDzKXoDaJ8O0AYEhpCELONSClG8=; b=ChiceiGQuAwNv9fprL0mikefcuFTrXlg4JePOpwnBDWVOJhn+i6GaJ3lVbdlilh1i9 tNkZ3lJP4MC3jygJ8c84LqDvcAbE9CwicQXfGN1QZLAkEhdzK7HwNG61jd9xQ4ZyiPhX Id4Gsbxh93tiz7uqsiUjil2uFyzM53G+Q5NXf2R/b7pjhgunnMnlrebnaX+IpIfVaRR4 R6kSRAeTBWoze1IiSVx+Nt64LGob/4GLoL6hrK5dsNecTcw9iGOOdoKdlW7wWfrPFnZ5 dbnRjgu9IcPzyPN/ACc6g0jGjZuUXKFmh3G0V0W9et1+kTkOq+vFf7KRwQ+J31jaQU0r V+rw== X-Gm-Message-State: AOJu0YxZtCzmrbIYbl3WwiQatUl9GsNze+E67D8uL5ucBMEKhkb3O/dS RDoe/VNJ3irmcnu+xuM2jcLKMfkEPE3QV4/xyQ+gwyIOm/74lB1yNA3K X-Gm-Gg: ATEYQzxbkFaCoWgLshIfd2+tIEIvE/8/Cm35LKIs8pKrXtR21EljI0Of9Cr4UR4iCli KYTWmgsJ2REZtsYRPLL0TYhJQm+JV7rvGMs/ni9Abroiq3b+x/IlMF8VGeyOJqkq2s0mBvDEVG7 JPjN5DmfBMj4WlUv031DhpOekWpPaCWUDxz3PLmchuJSKQw43+tfhwJjoP9HJ45jJL/UK7BCMod rDUEtdtd03eezDNraC4xxVbB0iokD+IxhJ3yVOsabkUr8KpiXUO9DAaamfXWjl7DABrOgeuGGbv lFQ/cXWW2/THaSamiIePF2AZWMaKap7MQtREW3xGtdAA+u1aepu6zB0s7Nh0ZRotIau5CPitPyH o8ixKcgqO0FYPjMZmhrMoqgb2q66nzpAplN+1HdtNcM0RoG5EtIlLy83v5jTS1BT39Aqj4VT8n4 QFXwVPyOjG3zwWdsPycm5h9J1s7/GcHjg2Wjlpzx5e X-Received: by 2002:a05:6a00:1a8c:b0:829:810e:8af8 with SMTP id d2e1a72fcca58-829a2dc4f99mr13412167b3a.22.1773130653357; Tue, 10 Mar 2026 01:17:33 -0700 (PDT) Received: from DESKTOP-SF55S0Q.localdomain ([110.76.74.67]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-829a465b6f7sm15455650b3a.23.2026.03.10.01.17.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Mar 2026 01:17:32 -0700 (PDT) From: Seohyeon Maeng To: Jan Kara Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH] udf: fix partition descriptor append bookkeeping Date: Tue, 10 Mar 2026 17:16:52 +0900 Message-ID: <20260310081652.21220-1-bioloidgp@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 --- fs/udf/super.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/udf/super.c b/fs/udf/super.c index 27f463fd1d89..3c3c645de0bc 100644 --- a/fs/udf/super.c +++ b/fs/udf/super.c @@ -1694,7 +1694,8 @@ static struct udf_vds_record *handle_partition_descri= ptor( return &(data->part_descs_loc[i].rec); if (data->num_part_descs >=3D data->size_part_descs) { struct part_desc_seq_scan_data *new_loc; - unsigned int new_size =3D ALIGN(partnum, PART_DESC_ALLOC_STEP); + unsigned int need =3D data->num_part_descs + 1; + unsigned int new_size =3D ALIGN(need, PART_DESC_ALLOC_STEP); =20 new_loc =3D kzalloc_objs(*new_loc, new_size); if (!new_loc) @@ -1705,6 +1706,7 @@ static struct udf_vds_record *handle_partition_descri= ptor( data->part_descs_loc =3D new_loc; data->size_part_descs =3D new_size; } + data->part_descs_loc[data->num_part_descs].partnum =3D partnum; return &(data->part_descs_loc[data->num_part_descs++].rec); } =20 base-commit: 1f318b96cc84d7c2ab792fcc0bfd42a7ca890681 --=20 2.43.0