diff options
author | Marta Rybczynska <rybczynska@gmail.com> | 2022-02-18 11:05:31 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-03-02 00:21:37 +0000 |
commit | f4c3f4508a6353bb5359d334c58a3ded85573ec4 (patch) | |
tree | 36aecafb53d7530380af7d9e5d47ed41fb1c2592 /meta/recipes-bsp/grub | |
parent | 0dd3f436f474e37b01a77d31de407cea5689b62c (diff) | |
download | poky-f4c3f4508a6353bb5359d334c58a3ded85573ec4.tar.gz |
grub: add a fix for possible integer overflows
This patch adds a fix for a possible integer overflows in grub's zfs.
It is a part of a security series [1].
[1] https://lists.gnu.org/archive/html/grub-devel/2021-03/msg00007.html
(From OE-Core rev: a21a1f225090b2f9d4c76e323fa7cc2051587924)
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
Signed-off-by: Steve Sakoman <steve@sakoman.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-bsp/grub')
-rw-r--r-- | meta/recipes-bsp/grub/files/0023-zfs-Fix-possible-integer-overflows.patch | 56 | ||||
-rw-r--r-- | meta/recipes-bsp/grub/grub2.inc | 1 |
2 files changed, 57 insertions, 0 deletions
diff --git a/meta/recipes-bsp/grub/files/0023-zfs-Fix-possible-integer-overflows.patch b/meta/recipes-bsp/grub/files/0023-zfs-Fix-possible-integer-overflows.patch new file mode 100644 index 0000000000..8df758b41f --- /dev/null +++ b/meta/recipes-bsp/grub/files/0023-zfs-Fix-possible-integer-overflows.patch | |||
@@ -0,0 +1,56 @@ | |||
1 | From ec35d862f3567671048aa0d0d8ad1ded1fd25336 Mon Sep 17 00:00:00 2001 | ||
2 | From: Darren Kenny <darren.kenny@oracle.com> | ||
3 | Date: Tue, 8 Dec 2020 22:17:04 +0000 | ||
4 | Subject: [PATCH] zfs: Fix possible integer overflows | ||
5 | |||
6 | In all cases the problem is that the value being acted upon by | ||
7 | a left-shift is a 32-bit number which is then being used in the | ||
8 | context of a 64-bit number. | ||
9 | |||
10 | To avoid overflow we ensure that the number being shifted is 64-bit | ||
11 | before the shift is done. | ||
12 | |||
13 | Fixes: CID 73684, CID 73695, CID 73764 | ||
14 | |||
15 | Signed-off-by: Darren Kenny <darren.kenny@oracle.com> | ||
16 | Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com> | ||
17 | |||
18 | Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=302c12ff5714bc455949117c1c9548ccb324d55b] | ||
19 | Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com> | ||
20 | --- | ||
21 | grub-core/fs/zfs/zfs.c | 8 ++++---- | ||
22 | 1 file changed, 4 insertions(+), 4 deletions(-) | ||
23 | |||
24 | diff --git a/grub-core/fs/zfs/zfs.c b/grub-core/fs/zfs/zfs.c | ||
25 | index 9087a72..b078ccc 100644 | ||
26 | --- a/grub-core/fs/zfs/zfs.c | ||
27 | +++ b/grub-core/fs/zfs/zfs.c | ||
28 | @@ -564,7 +564,7 @@ find_bestub (uberblock_phys_t * ub_array, | ||
29 | ubptr = (uberblock_phys_t *) ((grub_properly_aligned_t *) ub_array | ||
30 | + ((i << ub_shift) | ||
31 | / sizeof (grub_properly_aligned_t))); | ||
32 | - err = uberblock_verify (ubptr, offset, 1 << ub_shift); | ||
33 | + err = uberblock_verify (ubptr, offset, (grub_size_t) 1 << ub_shift); | ||
34 | if (err) | ||
35 | { | ||
36 | grub_errno = GRUB_ERR_NONE; | ||
37 | @@ -1543,7 +1543,7 @@ read_device (grub_uint64_t offset, struct grub_zfs_device_desc *desc, | ||
38 | |||
39 | high = grub_divmod64 ((offset >> desc->ashift) + c, | ||
40 | desc->n_children, &devn); | ||
41 | - csize = bsize << desc->ashift; | ||
42 | + csize = (grub_size_t) bsize << desc->ashift; | ||
43 | if (csize > len) | ||
44 | csize = len; | ||
45 | |||
46 | @@ -1635,8 +1635,8 @@ read_device (grub_uint64_t offset, struct grub_zfs_device_desc *desc, | ||
47 | |||
48 | while (len > 0) | ||
49 | { | ||
50 | - grub_size_t csize; | ||
51 | - csize = ((s / (desc->n_children - desc->nparity)) | ||
52 | + grub_size_t csize = s; | ||
53 | + csize = ((csize / (desc->n_children - desc->nparity)) | ||
54 | << desc->ashift); | ||
55 | if (csize > len) | ||
56 | csize = len; | ||
diff --git a/meta/recipes-bsp/grub/grub2.inc b/meta/recipes-bsp/grub/grub2.inc index 1630235edd..9158fc7f50 100644 --- a/meta/recipes-bsp/grub/grub2.inc +++ b/meta/recipes-bsp/grub/grub2.inc | |||
@@ -69,6 +69,7 @@ SRC_URI = "${GNU_MIRROR}/grub/grub-${PV}.tar.gz \ | |||
69 | file://0020-hfsplus-Check-that-the-volume-name-length-is-valid.patch \ | 69 | file://0020-hfsplus-Check-that-the-volume-name-length-is-valid.patch \ |
70 | file://0021-zfs-Fix-possible-negative-shift-operation.patch \ | 70 | file://0021-zfs-Fix-possible-negative-shift-operation.patch \ |
71 | file://0022-zfs-Fix-resource-leaks-while-constructing-path.patch \ | 71 | file://0022-zfs-Fix-resource-leaks-while-constructing-path.patch \ |
72 | file://0023-zfs-Fix-possible-integer-overflows.patch \ | ||
72 | " | 73 | " |
73 | SRC_URI[md5sum] = "5ce674ca6b2612d8939b9e6abed32934" | 74 | SRC_URI[md5sum] = "5ce674ca6b2612d8939b9e6abed32934" |
74 | SRC_URI[sha256sum] = "f10c85ae3e204dbaec39ae22fa3c5e99f0665417e91c2cb49b7e5031658ba6ea" | 75 | SRC_URI[sha256sum] = "f10c85ae3e204dbaec39ae22fa3c5e99f0665417e91c2cb49b7e5031658ba6ea" |