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
diff --git a/debian/changelog b/debian/changelog
index 4da09c8..8cfe069 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,17 @@
1util-linux (2.34-0.1ubuntu9.4) focal; urgency=medium
2
3 * Fix false atari partition detection (LP: #2015355):
4 - Backport upstream patches to fix atari partition detection in libblkid:
5 + debian/patches/libblkid-fix-Atari-prober-logic.patch
6 + debian/patches/libblkid-make-Atari-more-robust.patch
7 - Backport upstream patches to fix atari tests:
8 + debian/patches/tests-update-atari-partx-tests.patch
9 + debian/patches/tests-update-atari-blkid-tests.patch
10 + debian/source/include-binaries: Track changes that are not
11 representable in quilt patch.
12
13 -- Nick Rosbrook <nick.rosbrook@canonical.com> Tue, 30 May 2023 11:42:35 -0400
14
1util-linux (2.34-0.1ubuntu9.3) focal-security; urgency=medium15util-linux (2.34-0.1ubuntu9.3) focal-security; urgency=medium
216
3 * SECURITY UPDATE: Unauthorized unmount of FUSE filesystems belonging to17 * SECURITY UPDATE: Unauthorized unmount of FUSE filesystems belonging to
diff --git a/debian/patches/libblkid-fix-Atari-prober-logic.patch b/debian/patches/libblkid-fix-Atari-prober-logic.patch
4new file mode 10064418new file mode 100644
index 0000000..1c60685
--- /dev/null
+++ b/debian/patches/libblkid-fix-Atari-prober-logic.patch
@@ -0,0 +1,47 @@
1From: Karel Zak <kzak@redhat.com>
2Date: Fri, 9 Oct 2020 13:06:08 +0200
3Subject: libblkid: fix Atari prober logic
4
5Addresses: https://github.com/karelzak/util-linux/issues/1159
6Addresses: https://github.com/karelzak/util-linux/issues/1116
7Signed-off-by: Karel Zak <kzak@redhat.com>
8
9Origin: upstream, https://github.com/util-linux/util-linux/commit/2cc76d50d7a14bef8e7b07fab11b26c9e49d36a2
10Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/util-linux/+bug/2015355
11---
12 libblkid/src/partitions/atari.c | 12 +++++++-----
13 1 file changed, 7 insertions(+), 5 deletions(-)
14
15diff --git a/libblkid/src/partitions/atari.c b/libblkid/src/partitions/atari.c
16index 48c322670..03ec6084c 100644
17--- a/libblkid/src/partitions/atari.c
18+++ b/libblkid/src/partitions/atari.c
19@@ -199,11 +199,10 @@ static int probe_atari_pt(blkid_probe pr,
20
21 hdsize = blkid_probe_get_size(pr) / 512;
22
23- /* Look for validly looking primary partition */
24- for (i = 0; ; i++) {
25- if (i >= ARRAY_SIZE(rs->part))
26- goto nothing;
27-
28+ /*
29+ * At least one valid partition required
30+ */
31+ for (i = 0; i < 4; i++) {
32 if (IS_PARTDEF_VALID(rs->part[i], hdsize)) {
33 if (blkid_probe_set_magic(pr,
34 offsetof(struct atari_rootsector, part[i]),
35@@ -214,6 +213,9 @@ static int probe_atari_pt(blkid_probe pr,
36 }
37 }
38
39+ if (i == 4)
40+ goto nothing;
41+
42 if (blkid_partitions_need_typeonly(pr))
43 /* caller does not ask for details about partitions */
44 return BLKID_PROBE_OK;
45--
462.39.2
47
diff --git a/debian/patches/libblkid-make-Atari-more-robust.patch b/debian/patches/libblkid-make-Atari-more-robust.patch
0new file mode 10064448new file mode 100644
index 0000000..9e1b94c
--- /dev/null
+++ b/debian/patches/libblkid-make-Atari-more-robust.patch
@@ -0,0 +1,120 @@
1From: Karel Zak <kzak@redhat.com>
2Date: Tue, 13 Oct 2020 16:19:20 +0200
3Subject: libblkid: make Atari more robust
4
5* ignore large disks
6* check in-table stored device size
7* check bad sectors list
8* check partition dimensions against in-table device size
9
10Addresses: https://github.com/karelzak/util-linux/issues/1159
11Signed-off-by: Karel Zak <kzak@redhat.com>
12
13Origin: upstream, https://github.com/util-linux/util-linux/commit/282ceadc3a72fc07dd0388b8880fd751490bb87f
14Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/util-linux/+bug/2015355
15---
16 libblkid/src/partitions/atari.c | 57 +++++++++++++++++++++++++--------
17 1 file changed, 43 insertions(+), 14 deletions(-)
18
19diff --git a/libblkid/src/partitions/atari.c b/libblkid/src/partitions/atari.c
20index 03ec6084c..c3f77117a 100644
21--- a/libblkid/src/partitions/atari.c
22+++ b/libblkid/src/partitions/atari.c
23@@ -74,16 +74,27 @@ static int linux_isalnum(unsigned char c) {
24
25 #define IS_ACTIVE(partdef) ((partdef).flags & 1)
26
27-#define IS_PARTDEF_VALID(partdef, hdsize) \
28- ( \
29- (partdef).flags & 1 && \
30- isalnum((partdef).id[0]) && \
31- isalnum((partdef).id[1]) && \
32- isalnum((partdef).id[2]) && \
33- be32_to_cpu((partdef).start) <= (hdsize) && \
34- be32_to_cpu((partdef).start) + \
35- be32_to_cpu((partdef).size) <= (hdsize) \
36- )
37+static int is_valid_dimension(uint32_t start, uint32_t size, uint32_t maxoff)
38+{
39+ uint64_t end = start + size;
40+
41+ return end >= start
42+ && 0 < start && start <= maxoff
43+ && 0 < size && size <= maxoff
44+ && 0 < end && end <= maxoff;
45+}
46+
47+static int is_valid_partition(struct atari_part_def *part, uint32_t maxoff)
48+{
49+ uint32_t start = be32_to_cpu(part->start),
50+ size = be32_to_cpu(part->size);
51+
52+ return (part->flags & 1)
53+ && isalnum(part->id[0])
54+ && isalnum(part->id[1])
55+ && isalnum(part->id[2])
56+ && is_valid_dimension(start, size, maxoff);
57+}
58
59 static int is_id_common(char *id)
60 {
61@@ -184,12 +195,20 @@ static int probe_atari_pt(blkid_probe pr,
62 unsigned i;
63 int has_xgm = 0;
64 int rc = 0;
65- off_t hdsize;
66+ uint32_t rssize; /* size in sectors from root sector */
67+ uint64_t size; /* size in sectors from system */
68
69 /* Atari partition is not defined for other sector sizes */
70 if (blkid_probe_get_sectorsize(pr) != 512)
71 goto nothing;
72
73+ size = blkid_probe_get_size(pr) / 512;
74+
75+ /* Atari is not well defined to support large disks */
76+ if (size > INT32_MAX)
77+ goto nothing;
78+
79+ /* read root sector */
80 rs = (struct atari_rootsector *) blkid_probe_get_sector(pr, 0);
81 if (!rs) {
82 if (errno)
83@@ -197,13 +216,24 @@ static int probe_atari_pt(blkid_probe pr,
84 goto nothing;
85 }
86
87- hdsize = blkid_probe_get_size(pr) / 512;
88+ rssize = be32_to_cpu(rs->hd_size);
89+
90+ /* check number of sectors stored in the root sector */
91+ if (rssize < 2 || rssize > size)
92+ goto nothing;
93+
94+ /* check list of bad blocks */
95+ if ((rs->bsl_start || rs->bsl_len)
96+ && !is_valid_dimension(be32_to_cpu(rs->bsl_start),
97+ be32_to_cpu(rs->bsl_len),
98+ rssize))
99+ goto nothing;
100
101 /*
102 * At least one valid partition required
103 */
104 for (i = 0; i < 4; i++) {
105- if (IS_PARTDEF_VALID(rs->part[i], hdsize)) {
106+ if (is_valid_partition(&rs->part[i], rssize)) {
107 if (blkid_probe_set_magic(pr,
108 offsetof(struct atari_rootsector, part[i]),
109 sizeof(rs->part[i].flags) + sizeof(rs->part[i].id),
110@@ -235,7 +265,6 @@ static int probe_atari_pt(blkid_probe pr,
111 blkid_partlist_increment_partno(ls);
112 continue;
113 }
114-
115 if (!memcmp(p->id, "XGM", 3)) {
116 has_xgm = 1;
117 rc = parse_extended(pr, ls, tab, p);
118--
1192.39.2
120
diff --git a/debian/patches/series b/debian/patches/series
index df2692e..32316aa 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -11,3 +11,7 @@ CVE-2021-3995-1.patch
11CVE-2021-3995-2.patch11CVE-2021-3995-2.patch
12CVE-2021-3996-1.patch12CVE-2021-3996-1.patch
13CVE-2021-3996-2.patch13CVE-2021-3996-2.patch
14libblkid-fix-Atari-prober-logic.patch
15libblkid-make-Atari-more-robust.patch
16tests-update-atari-partx-tests.patch
17tests-update-atari-blkid-tests.patch
diff --git a/debian/patches/tests-update-atari-blkid-tests.patch b/debian/patches/tests-update-atari-blkid-tests.patch
14new file mode 10064418new file mode 100644
index 0000000..8e375c9
--- /dev/null
+++ b/debian/patches/tests-update-atari-blkid-tests.patch
@@ -0,0 +1,83 @@
1From 0d061b6e68bc74ce7d61524097b5d0f3becee437 Mon Sep 17 00:00:00 2001
2From: Karel Zak <kzak@redhat.com>
3Date: Tue, 13 Oct 2020 16:29:19 +0200
4Subject: [PATCH] tests: update atari blkid tests
5
6Origin: upstream, https://github.com/util-linux/util-linux/commit/0d061b6e68bc74ce7d61524097b5d0f3becee437
7Bug-Ubuntu: https://launchpad.net/bugs/2015355
8
9Note for Ubuntu: The original binary diff in the upstream commit cannot be
10represented in this patch. For the complete removal of atari-icd.img.xz,
11instead patch the test script to skip the test using that data. For the changes
12in atari-primary.img.xz and atari-xgm.img.xz, the changes are made in the
13tarball using debian/source/include-binaries.
14
15The old images of the atari label are truncated and in-table stored
16sizes do not match with real images sizes -- libblkid checks it now.
17
18I have no idea how to generate ICD format, let's ignore it in tests
19for now.
20
21Signed-off-by: Karel Zak <kzak@redhat.com>
22---
23 tests/expected/blkid/lowprobe-pt-atari-icd | 8 --------
24 tests/expected/blkid/lowprobe-pt-atari-primary | 3 +++
25 tests/expected/blkid/lowprobe-pt-atari-xgm | 10 +++-------
26
27--- a/tests/expected/blkid/lowprobe-pt-atari-icd
28+++ /dev/null
29@@ -1,8 +0,0 @@
30-size: 8388608, sector size: 512, PT: atari, offset: 0, id=(null)
31----
32-#1: 65 4032 0x0 type='FAT'
33-#2: 4097 904 0x0 type='FOO'
34-#4: 12289 4096 0x0 type='BAR'
35-#5: 5002 1999 0x0 type='GEM'
36-#6: 7003 3238 0x0 type='RAW'
37-#7: 10241 2048 0x0 type='RAW'
38--- /dev/null
39+++ b/tests/expected/blkid/lowprobe-pt-atari-primary
40@@ -0,0 +1,3 @@
41+size: 5242880, sector size: 512, PT: atari, offset: 0, id=(null)
42+---
43+#1: 2 10238 0x0 type='RAW'
44--- a/tests/expected/blkid/lowprobe-pt-atari-xgm
45+++ b/tests/expected/blkid/lowprobe-pt-atari-xgm
46@@ -1,8 +1,4 @@
47-size: 8388608, sector size: 512, PT: atari, offset: 0, id=(null)
48+size: 5242880, sector size: 512, PT: atari, offset: 0, id=(null)
49 ---
50-#1: 65 4032 0x0 type='FAT'
51-#2: 4097 904 0x0 type='FOO'
52-#3: 5002 1999 0x0 type='GEM'
53-#4: 7003 3238 0x0 type='RAW'
54-#5: 10241 2048 0x0 type='RAW'
55-#6: 12289 4096 0x0 type='BAR'
56+#1: 2 9 0x0 type='RAW'
57+#2: 14 10226 0x0 type='RAW'
58--- a/tests/ts/blkid/lowprobe-pt
59+++ b/tests/ts/blkid/lowprobe-pt
60@@ -30,6 +30,10 @@
61
62 for img in $(ls $TS_SELF/images-pt/*.img.xz | sort); do
63 name=$(basename $img .img.xz)
64+ if [[ "$name" == "atari-icd" ]]; then
65+ continue
66+ fi
67+
68 outimg=$TS_OUTDIR/images-pt/${name}.img
69
70 ts_init_subtest $name
71--- a/tests/ts/partx/partx-image
72+++ b/tests/ts/partx/partx-image
73@@ -29,6 +29,10 @@
74 mkdir -p $TS_OUTDIR/images-pt
75 for img in $TS_IMGDIR/*.img.xz; do
76 name=$(basename $img .img.xz)
77+ if [[ "$name" == "atari-icd" ]]; then
78+ continue
79+ fi
80+
81 outimg=$TS_OUTDIR/images-pt/${name}.img
82
83 ts_init_subtest $name
diff --git a/debian/patches/tests-update-atari-partx-tests.patch b/debian/patches/tests-update-atari-partx-tests.patch
0new file mode 10064484new file mode 100644
index 0000000..9790f44
--- /dev/null
+++ b/debian/patches/tests-update-atari-partx-tests.patch
@@ -0,0 +1,53 @@
1From 017c0308c7d3b0d84bfc11e5863220bc32d640ba Mon Sep 17 00:00:00 2001
2From: Karel Zak <kzak@redhat.com>
3Date: Tue, 13 Oct 2020 18:34:39 +0200
4Subject: [PATCH] tests: update atari partx tests
5
6Origin: upstream, https://github.com/util-linux/util-linux/commit/017c0308c7d3b0d84bfc11e5863220bc32d640ba
7Bug-Ubuntu: https://launchpad.net/bugs/2015355
8
9Signed-off-by: Karel Zak <kzak@redhat.com>
10---
11 tests/expected/partx/partx-image-atari-icd | 7 -------
12 tests/expected/partx/partx-image-atari-primary | 2 ++
13 tests/expected/partx/partx-image-atari-xgm | 10 +++-------
14 3 files changed, 5 insertions(+), 14 deletions(-)
15 delete mode 100644 tests/expected/partx/partx-image-atari-icd
16 create mode 100644 tests/expected/partx/partx-image-atari-primary
17
18diff --git a/tests/expected/partx/partx-image-atari-icd b/tests/expected/partx/partx-image-atari-icd
19deleted file mode 100644
20index 8677dff03f..0000000000
21--- a/tests/expected/partx/partx-image-atari-icd
22+++ /dev/null
23@@ -1,7 +0,0 @@
24-NR START END SECTORS SIZE NAME UUID
25- 1 65 4096 4032 2M
26- 2 4097 5000 904 452K
27- 4 12289 16384 4096 2M
28- 5 5002 7000 1999 999.5K
29- 6 7003 10240 3238 1.6M
30- 7 10241 12288 2048 1M
31diff --git a/tests/expected/partx/partx-image-atari-primary b/tests/expected/partx/partx-image-atari-primary
32new file mode 100644
33index 0000000000..044d319be8
34--- /dev/null
35+++ b/tests/expected/partx/partx-image-atari-primary
36@@ -0,0 +1,2 @@
37+NR START END SECTORS SIZE NAME UUID
38+ 1 2 10239 10238 5M
39diff --git a/tests/expected/partx/partx-image-atari-xgm b/tests/expected/partx/partx-image-atari-xgm
40index 248d6a56a0..557327c04e 100644
41--- a/tests/expected/partx/partx-image-atari-xgm
42+++ b/tests/expected/partx/partx-image-atari-xgm
43@@ -1,7 +1,3 @@
44-NR START END SECTORS SIZE NAME UUID
45- 1 65 4096 4032 2M
46- 2 4097 5000 904 452K
47- 3 5002 7000 1999 999.5K
48- 4 7003 10240 3238 1.6M
49- 5 10241 12288 2048 1M
50- 6 12289 16384 4096 2M
51+NR START END SECTORS SIZE NAME UUID
52+ 1 2 10 9 4.5K
53+ 2 14 10239 10226 5M
diff --git a/debian/source/include-binaries b/debian/source/include-binaries
0new file mode 10064454new file mode 100644
index 0000000..e41f987
--- /dev/null
+++ b/debian/source/include-binaries
@@ -0,0 +1,2 @@
1tests/ts/blkid/images-pt/atari-primary.img.xz
2tests/ts/blkid/images-pt/atari-xgm.img.xz
diff --git a/tests/ts/blkid/images-pt/atari-primary.img.xz b/tests/ts/blkid/images-pt/atari-primary.img.xz
0new file mode 1006443new file mode 100644
index 0000000..6f915fa
1Binary files /dev/null and b/tests/ts/blkid/images-pt/atari-primary.img.xz differ4Binary files /dev/null and b/tests/ts/blkid/images-pt/atari-primary.img.xz differ
diff --git a/tests/ts/blkid/images-pt/atari-xgm.img.xz b/tests/ts/blkid/images-pt/atari-xgm.img.xz
index bc2b8f9..a98c02d 100644
2Binary files a/tests/ts/blkid/images-pt/atari-xgm.img.xz and b/tests/ts/blkid/images-pt/atari-xgm.img.xz differ5Binary 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