Merge ~enr0n/ubuntu/+source/util-linux:lp2015355 into ubuntu/+source/util-linux:ubuntu/focal-updates

Proposed by Nick Rosbrook
Status: Superseded
Proposed branch: ~enr0n/ubuntu/+source/util-linux:lp2015355
Merge into: ubuntu/+source/util-linux:ubuntu/focal-updates
Diff against target: 376 lines (+323/-0)
7 files modified
debian/changelog (+14/-0)
debian/patches/libblkid-fix-Atari-prober-logic.patch (+47/-0)
debian/patches/libblkid-make-Atari-more-robust.patch (+120/-0)
debian/patches/series (+4/-0)
debian/patches/tests-update-atari-blkid-tests.patch (+83/-0)
debian/patches/tests-update-atari-partx-tests.patch (+53/-0)
debian/source/include-binaries (+2/-0)
Reviewer Review Type Date Requested Status
Steve Langasek (community) Approve
Review via email: mp+443888@code.launchpad.net

This proposal has been superseded by a proposal from 2023-05-31.

Description of the change

Backport upstream patches to fix false detection of atari partitions. I have built this in my PPA: https://launchpad.net/~enr0n/+archive/ubuntu/proposed-migration/+packages?field.name_filter=util-linux&field.status_filter=published&field.series_filter=.

autopkgtest passed locally on amd64.

To post a comment you must log in.
Revision history for this message
Steve Langasek (vorlon) :
review: Approve

Unmerged commits

171ef76... by Nick Rosbrook

changelog

0dab1f4... by Nick Rosbrook

debian/patches/tests-update-atari-blkid-tests.patch

Cherry-pick upstream patch (partially). The upstream commit makes
changes to binary data in the tests directory, and this cannot be
represented in a quilt diff. Modify the binaries directly and list them
in debian/source/include-binaries, except for atari-icd.img.xz, which is
a total removal. For this, add a workaround in the test scripts to
explicitly ignore this test data.

f929f74... by Nick Rosbrook

debian/patches/tests-update-atari-partx-tests.patch

Cherry-pick upstream patch.

d0fd7d7... by Nick Rosbrook

debian/patches/libblkid-make-Atari-more-robust.patch

Cherry-pick upstream patch.

998da78... by Nick Rosbrook

debian/patches/libblkid-fix-Atari-prober-logic.patch

Cherry-pick upstream patch.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index 4da09c8..8cfe069 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,17 @@
6+util-linux (2.34-0.1ubuntu9.4) focal; urgency=medium
7+
8+ * Fix false atari partition detection (LP: #2015355):
9+ - Backport upstream patches to fix atari partition detection in libblkid:
10+ + debian/patches/libblkid-fix-Atari-prober-logic.patch
11+ + debian/patches/libblkid-make-Atari-more-robust.patch
12+ - Backport upstream patches to fix atari tests:
13+ + debian/patches/tests-update-atari-partx-tests.patch
14+ + debian/patches/tests-update-atari-blkid-tests.patch
15+ + debian/source/include-binaries: Track changes that are not
16+ representable in quilt patch.
17+
18+ -- Nick Rosbrook <nick.rosbrook@canonical.com> Tue, 30 May 2023 11:42:35 -0400
19+
20 util-linux (2.34-0.1ubuntu9.3) focal-security; urgency=medium
21
22 * SECURITY UPDATE: Unauthorized unmount of FUSE filesystems belonging to
23diff --git a/debian/patches/libblkid-fix-Atari-prober-logic.patch b/debian/patches/libblkid-fix-Atari-prober-logic.patch
24new file mode 100644
25index 0000000..1c60685
26--- /dev/null
27+++ b/debian/patches/libblkid-fix-Atari-prober-logic.patch
28@@ -0,0 +1,47 @@
29+From: Karel Zak <kzak@redhat.com>
30+Date: Fri, 9 Oct 2020 13:06:08 +0200
31+Subject: libblkid: fix Atari prober logic
32+
33+Addresses: https://github.com/karelzak/util-linux/issues/1159
34+Addresses: https://github.com/karelzak/util-linux/issues/1116
35+Signed-off-by: Karel Zak <kzak@redhat.com>
36+
37+Origin: upstream, https://github.com/util-linux/util-linux/commit/2cc76d50d7a14bef8e7b07fab11b26c9e49d36a2
38+Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/util-linux/+bug/2015355
39+---
40+ libblkid/src/partitions/atari.c | 12 +++++++-----
41+ 1 file changed, 7 insertions(+), 5 deletions(-)
42+
43+diff --git a/libblkid/src/partitions/atari.c b/libblkid/src/partitions/atari.c
44+index 48c322670..03ec6084c 100644
45+--- a/libblkid/src/partitions/atari.c
46++++ b/libblkid/src/partitions/atari.c
47+@@ -199,11 +199,10 @@ static int probe_atari_pt(blkid_probe pr,
48+
49+ hdsize = blkid_probe_get_size(pr) / 512;
50+
51+- /* Look for validly looking primary partition */
52+- for (i = 0; ; i++) {
53+- if (i >= ARRAY_SIZE(rs->part))
54+- goto nothing;
55+-
56++ /*
57++ * At least one valid partition required
58++ */
59++ for (i = 0; i < 4; i++) {
60+ if (IS_PARTDEF_VALID(rs->part[i], hdsize)) {
61+ if (blkid_probe_set_magic(pr,
62+ offsetof(struct atari_rootsector, part[i]),
63+@@ -214,6 +213,9 @@ static int probe_atari_pt(blkid_probe pr,
64+ }
65+ }
66+
67++ if (i == 4)
68++ goto nothing;
69++
70+ if (blkid_partitions_need_typeonly(pr))
71+ /* caller does not ask for details about partitions */
72+ return BLKID_PROBE_OK;
73+--
74+2.39.2
75+
76diff --git a/debian/patches/libblkid-make-Atari-more-robust.patch b/debian/patches/libblkid-make-Atari-more-robust.patch
77new file mode 100644
78index 0000000..9e1b94c
79--- /dev/null
80+++ b/debian/patches/libblkid-make-Atari-more-robust.patch
81@@ -0,0 +1,120 @@
82+From: Karel Zak <kzak@redhat.com>
83+Date: Tue, 13 Oct 2020 16:19:20 +0200
84+Subject: libblkid: make Atari more robust
85+
86+* ignore large disks
87+* check in-table stored device size
88+* check bad sectors list
89+* check partition dimensions against in-table device size
90+
91+Addresses: https://github.com/karelzak/util-linux/issues/1159
92+Signed-off-by: Karel Zak <kzak@redhat.com>
93+
94+Origin: upstream, https://github.com/util-linux/util-linux/commit/282ceadc3a72fc07dd0388b8880fd751490bb87f
95+Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/util-linux/+bug/2015355
96+---
97+ libblkid/src/partitions/atari.c | 57 +++++++++++++++++++++++++--------
98+ 1 file changed, 43 insertions(+), 14 deletions(-)
99+
100+diff --git a/libblkid/src/partitions/atari.c b/libblkid/src/partitions/atari.c
101+index 03ec6084c..c3f77117a 100644
102+--- a/libblkid/src/partitions/atari.c
103++++ b/libblkid/src/partitions/atari.c
104+@@ -74,16 +74,27 @@ static int linux_isalnum(unsigned char c) {
105+
106+ #define IS_ACTIVE(partdef) ((partdef).flags & 1)
107+
108+-#define IS_PARTDEF_VALID(partdef, hdsize) \
109+- ( \
110+- (partdef).flags & 1 && \
111+- isalnum((partdef).id[0]) && \
112+- isalnum((partdef).id[1]) && \
113+- isalnum((partdef).id[2]) && \
114+- be32_to_cpu((partdef).start) <= (hdsize) && \
115+- be32_to_cpu((partdef).start) + \
116+- be32_to_cpu((partdef).size) <= (hdsize) \
117+- )
118++static int is_valid_dimension(uint32_t start, uint32_t size, uint32_t maxoff)
119++{
120++ uint64_t end = start + size;
121++
122++ return end >= start
123++ && 0 < start && start <= maxoff
124++ && 0 < size && size <= maxoff
125++ && 0 < end && end <= maxoff;
126++}
127++
128++static int is_valid_partition(struct atari_part_def *part, uint32_t maxoff)
129++{
130++ uint32_t start = be32_to_cpu(part->start),
131++ size = be32_to_cpu(part->size);
132++
133++ return (part->flags & 1)
134++ && isalnum(part->id[0])
135++ && isalnum(part->id[1])
136++ && isalnum(part->id[2])
137++ && is_valid_dimension(start, size, maxoff);
138++}
139+
140+ static int is_id_common(char *id)
141+ {
142+@@ -184,12 +195,20 @@ static int probe_atari_pt(blkid_probe pr,
143+ unsigned i;
144+ int has_xgm = 0;
145+ int rc = 0;
146+- off_t hdsize;
147++ uint32_t rssize; /* size in sectors from root sector */
148++ uint64_t size; /* size in sectors from system */
149+
150+ /* Atari partition is not defined for other sector sizes */
151+ if (blkid_probe_get_sectorsize(pr) != 512)
152+ goto nothing;
153+
154++ size = blkid_probe_get_size(pr) / 512;
155++
156++ /* Atari is not well defined to support large disks */
157++ if (size > INT32_MAX)
158++ goto nothing;
159++
160++ /* read root sector */
161+ rs = (struct atari_rootsector *) blkid_probe_get_sector(pr, 0);
162+ if (!rs) {
163+ if (errno)
164+@@ -197,13 +216,24 @@ static int probe_atari_pt(blkid_probe pr,
165+ goto nothing;
166+ }
167+
168+- hdsize = blkid_probe_get_size(pr) / 512;
169++ rssize = be32_to_cpu(rs->hd_size);
170++
171++ /* check number of sectors stored in the root sector */
172++ if (rssize < 2 || rssize > size)
173++ goto nothing;
174++
175++ /* check list of bad blocks */
176++ if ((rs->bsl_start || rs->bsl_len)
177++ && !is_valid_dimension(be32_to_cpu(rs->bsl_start),
178++ be32_to_cpu(rs->bsl_len),
179++ rssize))
180++ goto nothing;
181+
182+ /*
183+ * At least one valid partition required
184+ */
185+ for (i = 0; i < 4; i++) {
186+- if (IS_PARTDEF_VALID(rs->part[i], hdsize)) {
187++ if (is_valid_partition(&rs->part[i], rssize)) {
188+ if (blkid_probe_set_magic(pr,
189+ offsetof(struct atari_rootsector, part[i]),
190+ sizeof(rs->part[i].flags) + sizeof(rs->part[i].id),
191+@@ -235,7 +265,6 @@ static int probe_atari_pt(blkid_probe pr,
192+ blkid_partlist_increment_partno(ls);
193+ continue;
194+ }
195+-
196+ if (!memcmp(p->id, "XGM", 3)) {
197+ has_xgm = 1;
198+ rc = parse_extended(pr, ls, tab, p);
199+--
200+2.39.2
201+
202diff --git a/debian/patches/series b/debian/patches/series
203index df2692e..32316aa 100644
204--- a/debian/patches/series
205+++ b/debian/patches/series
206@@ -11,3 +11,7 @@ CVE-2021-3995-1.patch
207 CVE-2021-3995-2.patch
208 CVE-2021-3996-1.patch
209 CVE-2021-3996-2.patch
210+libblkid-fix-Atari-prober-logic.patch
211+libblkid-make-Atari-more-robust.patch
212+tests-update-atari-partx-tests.patch
213+tests-update-atari-blkid-tests.patch
214diff --git a/debian/patches/tests-update-atari-blkid-tests.patch b/debian/patches/tests-update-atari-blkid-tests.patch
215new file mode 100644
216index 0000000..8e375c9
217--- /dev/null
218+++ b/debian/patches/tests-update-atari-blkid-tests.patch
219@@ -0,0 +1,83 @@
220+From 0d061b6e68bc74ce7d61524097b5d0f3becee437 Mon Sep 17 00:00:00 2001
221+From: Karel Zak <kzak@redhat.com>
222+Date: Tue, 13 Oct 2020 16:29:19 +0200
223+Subject: [PATCH] tests: update atari blkid tests
224+
225+Origin: upstream, https://github.com/util-linux/util-linux/commit/0d061b6e68bc74ce7d61524097b5d0f3becee437
226+Bug-Ubuntu: https://launchpad.net/bugs/2015355
227+
228+Note for Ubuntu: The original binary diff in the upstream commit cannot be
229+represented in this patch. For the complete removal of atari-icd.img.xz,
230+instead patch the test script to skip the test using that data. For the changes
231+in atari-primary.img.xz and atari-xgm.img.xz, the changes are made in the
232+tarball using debian/source/include-binaries.
233+
234+The old images of the atari label are truncated and in-table stored
235+sizes do not match with real images sizes -- libblkid checks it now.
236+
237+I have no idea how to generate ICD format, let's ignore it in tests
238+for now.
239+
240+Signed-off-by: Karel Zak <kzak@redhat.com>
241+---
242+ tests/expected/blkid/lowprobe-pt-atari-icd | 8 --------
243+ tests/expected/blkid/lowprobe-pt-atari-primary | 3 +++
244+ tests/expected/blkid/lowprobe-pt-atari-xgm | 10 +++-------
245+
246+--- a/tests/expected/blkid/lowprobe-pt-atari-icd
247++++ /dev/null
248+@@ -1,8 +0,0 @@
249+-size: 8388608, sector size: 512, PT: atari, offset: 0, id=(null)
250+----
251+-#1: 65 4032 0x0 type='FAT'
252+-#2: 4097 904 0x0 type='FOO'
253+-#4: 12289 4096 0x0 type='BAR'
254+-#5: 5002 1999 0x0 type='GEM'
255+-#6: 7003 3238 0x0 type='RAW'
256+-#7: 10241 2048 0x0 type='RAW'
257+--- /dev/null
258++++ b/tests/expected/blkid/lowprobe-pt-atari-primary
259+@@ -0,0 +1,3 @@
260++size: 5242880, sector size: 512, PT: atari, offset: 0, id=(null)
261++---
262++#1: 2 10238 0x0 type='RAW'
263+--- a/tests/expected/blkid/lowprobe-pt-atari-xgm
264++++ b/tests/expected/blkid/lowprobe-pt-atari-xgm
265+@@ -1,8 +1,4 @@
266+-size: 8388608, sector size: 512, PT: atari, offset: 0, id=(null)
267++size: 5242880, sector size: 512, PT: atari, offset: 0, id=(null)
268+ ---
269+-#1: 65 4032 0x0 type='FAT'
270+-#2: 4097 904 0x0 type='FOO'
271+-#3: 5002 1999 0x0 type='GEM'
272+-#4: 7003 3238 0x0 type='RAW'
273+-#5: 10241 2048 0x0 type='RAW'
274+-#6: 12289 4096 0x0 type='BAR'
275++#1: 2 9 0x0 type='RAW'
276++#2: 14 10226 0x0 type='RAW'
277+--- a/tests/ts/blkid/lowprobe-pt
278++++ b/tests/ts/blkid/lowprobe-pt
279+@@ -30,6 +30,10 @@
280+
281+ for img in $(ls $TS_SELF/images-pt/*.img.xz | sort); do
282+ name=$(basename $img .img.xz)
283++ if [[ "$name" == "atari-icd" ]]; then
284++ continue
285++ fi
286++
287+ outimg=$TS_OUTDIR/images-pt/${name}.img
288+
289+ ts_init_subtest $name
290+--- a/tests/ts/partx/partx-image
291++++ b/tests/ts/partx/partx-image
292+@@ -29,6 +29,10 @@
293+ mkdir -p $TS_OUTDIR/images-pt
294+ for img in $TS_IMGDIR/*.img.xz; do
295+ name=$(basename $img .img.xz)
296++ if [[ "$name" == "atari-icd" ]]; then
297++ continue
298++ fi
299++
300+ outimg=$TS_OUTDIR/images-pt/${name}.img
301+
302+ ts_init_subtest $name
303diff --git a/debian/patches/tests-update-atari-partx-tests.patch b/debian/patches/tests-update-atari-partx-tests.patch
304new file mode 100644
305index 0000000..9790f44
306--- /dev/null
307+++ b/debian/patches/tests-update-atari-partx-tests.patch
308@@ -0,0 +1,53 @@
309+From 017c0308c7d3b0d84bfc11e5863220bc32d640ba Mon Sep 17 00:00:00 2001
310+From: Karel Zak <kzak@redhat.com>
311+Date: Tue, 13 Oct 2020 18:34:39 +0200
312+Subject: [PATCH] tests: update atari partx tests
313+
314+Origin: upstream, https://github.com/util-linux/util-linux/commit/017c0308c7d3b0d84bfc11e5863220bc32d640ba
315+Bug-Ubuntu: https://launchpad.net/bugs/2015355
316+
317+Signed-off-by: Karel Zak <kzak@redhat.com>
318+---
319+ tests/expected/partx/partx-image-atari-icd | 7 -------
320+ tests/expected/partx/partx-image-atari-primary | 2 ++
321+ tests/expected/partx/partx-image-atari-xgm | 10 +++-------
322+ 3 files changed, 5 insertions(+), 14 deletions(-)
323+ delete mode 100644 tests/expected/partx/partx-image-atari-icd
324+ create mode 100644 tests/expected/partx/partx-image-atari-primary
325+
326+diff --git a/tests/expected/partx/partx-image-atari-icd b/tests/expected/partx/partx-image-atari-icd
327+deleted file mode 100644
328+index 8677dff03f..0000000000
329+--- a/tests/expected/partx/partx-image-atari-icd
330++++ /dev/null
331+@@ -1,7 +0,0 @@
332+-NR START END SECTORS SIZE NAME UUID
333+- 1 65 4096 4032 2M
334+- 2 4097 5000 904 452K
335+- 4 12289 16384 4096 2M
336+- 5 5002 7000 1999 999.5K
337+- 6 7003 10240 3238 1.6M
338+- 7 10241 12288 2048 1M
339+diff --git a/tests/expected/partx/partx-image-atari-primary b/tests/expected/partx/partx-image-atari-primary
340+new file mode 100644
341+index 0000000000..044d319be8
342+--- /dev/null
343++++ b/tests/expected/partx/partx-image-atari-primary
344+@@ -0,0 +1,2 @@
345++NR START END SECTORS SIZE NAME UUID
346++ 1 2 10239 10238 5M
347+diff --git a/tests/expected/partx/partx-image-atari-xgm b/tests/expected/partx/partx-image-atari-xgm
348+index 248d6a56a0..557327c04e 100644
349+--- a/tests/expected/partx/partx-image-atari-xgm
350++++ b/tests/expected/partx/partx-image-atari-xgm
351+@@ -1,7 +1,3 @@
352+-NR START END SECTORS SIZE NAME UUID
353+- 1 65 4096 4032 2M
354+- 2 4097 5000 904 452K
355+- 3 5002 7000 1999 999.5K
356+- 4 7003 10240 3238 1.6M
357+- 5 10241 12288 2048 1M
358+- 6 12289 16384 4096 2M
359++NR START END SECTORS SIZE NAME UUID
360++ 1 2 10 9 4.5K
361++ 2 14 10239 10226 5M
362diff --git a/debian/source/include-binaries b/debian/source/include-binaries
363new file mode 100644
364index 0000000..e41f987
365--- /dev/null
366+++ b/debian/source/include-binaries
367@@ -0,0 +1,2 @@
368+tests/ts/blkid/images-pt/atari-primary.img.xz
369+tests/ts/blkid/images-pt/atari-xgm.img.xz
370diff --git a/tests/ts/blkid/images-pt/atari-primary.img.xz b/tests/ts/blkid/images-pt/atari-primary.img.xz
371new file mode 100644
372index 0000000..6f915fa
373Binary files /dev/null and b/tests/ts/blkid/images-pt/atari-primary.img.xz differ
374diff --git a/tests/ts/blkid/images-pt/atari-xgm.img.xz b/tests/ts/blkid/images-pt/atari-xgm.img.xz
375index bc2b8f9..a98c02d 100644
376Binary files a/tests/ts/blkid/images-pt/atari-xgm.img.xz and b/tests/ts/blkid/images-pt/atari-xgm.img.xz differ

Subscribers

People subscribed via source and target branches