diff options
author | Narpat Mali <narpat.mali@windriver.com> | 2022-11-23 14:21:38 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-11-27 23:54:50 +0000 |
commit | c867f67bdb146b42cc2816314954096143124e49 (patch) | |
tree | 0bf777ab0d400d88620c651b0b2e097a856c0924 /meta/recipes-multimedia/ffmpeg | |
parent | 2a642aa2b1b96bd84e650a7c3ebade4d2d7c3863 (diff) | |
download | poky-c867f67bdb146b42cc2816314954096143124e49.tar.gz |
ffmpeg: fix for CVE-2022-3965
A vulnerability classified as problematic was found in ffmpeg. This vulnerability affects the function
smc_encode_stream of the file libavcodec/smcenc.c of the component QuickTime Graphics Video Encoder. The
manipulation of the argument y_size leads to out-of-bounds read. The attack can be initiated remotely.
The name of the patch is 13c13109759090b7f7182480d075e13b36ed8edd. It is recommended to apply a patch to
fix this issue. The identifier of this vulnerability is VDB-213544.
Reference:
https://nvd.nist.gov/vuln/detail/CVE-2022-3965
Upstream Fix:
https://github.com/FFmpeg/FFmpeg/commit/13c13109759090b7f7182480d075e13b36ed8edd
(From OE-Core rev: b88c96fe8964614978aa25a65dd34fc3c05c664c)
Signed-off-by: Narpat Mali <narpat.mali@windriver.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-multimedia/ffmpeg')
-rw-r--r-- | meta/recipes-multimedia/ffmpeg/ffmpeg/0001-avcodec-smcenc-stop-accessing-out-of-bounds-frame.patch | 108 | ||||
-rw-r--r-- | meta/recipes-multimedia/ffmpeg/ffmpeg_5.1.2.bb | 4 |
2 files changed, 111 insertions, 1 deletions
diff --git a/meta/recipes-multimedia/ffmpeg/ffmpeg/0001-avcodec-smcenc-stop-accessing-out-of-bounds-frame.patch b/meta/recipes-multimedia/ffmpeg/ffmpeg/0001-avcodec-smcenc-stop-accessing-out-of-bounds-frame.patch new file mode 100644 index 0000000000..923fc6a9c1 --- /dev/null +++ b/meta/recipes-multimedia/ffmpeg/ffmpeg/0001-avcodec-smcenc-stop-accessing-out-of-bounds-frame.patch | |||
@@ -0,0 +1,108 @@ | |||
1 | From 13c13109759090b7f7182480d075e13b36ed8edd Mon Sep 17 00:00:00 2001 | ||
2 | From: Paul B Mahol <onemda@gmail.com> | ||
3 | Date: Sat, 12 Nov 2022 15:19:21 +0100 | ||
4 | Subject: [PATCH] avcodec/smcenc: stop accessing out of bounds frame | ||
5 | |||
6 | Upstream-Status: Backport [https://github.com/FFmpeg/FFmpeg/commit/13c13109759090b7f7182480d075e13b36ed8edd] | ||
7 | |||
8 | Signed-off-by: <narpat.mali@windriver.com> | ||
9 | |||
10 | --- | ||
11 | libavcodec/smcenc.c | 18 ++++++++++++++---- | ||
12 | 1 file changed, 14 insertions(+), 4 deletions(-) | ||
13 | |||
14 | diff --git a/libavcodec/smcenc.c b/libavcodec/smcenc.c | ||
15 | index f3d26a4e8d..33549b8ab4 100644 | ||
16 | --- a/libavcodec/smcenc.c | ||
17 | +++ b/libavcodec/smcenc.c | ||
18 | @@ -61,6 +61,7 @@ typedef struct SMCContext { | ||
19 | { \ | ||
20 | row_ptr += stride * 4; \ | ||
21 | pixel_ptr = row_ptr; \ | ||
22 | + cur_y += 4; \ | ||
23 | } \ | ||
24 | } \ | ||
25 | } | ||
26 | @@ -117,6 +118,7 @@ static void smc_encode_stream(SMCContext *s, const AVFrame *frame, | ||
27 | const uint8_t *prev_pixels = (const uint8_t *)s->prev_frame->data[0]; | ||
28 | uint8_t *distinct_values = s->distinct_values; | ||
29 | const uint8_t *pixel_ptr, *row_ptr; | ||
30 | + const int height = frame->height; | ||
31 | const int width = frame->width; | ||
32 | uint8_t block_values[16]; | ||
33 | int block_counter = 0; | ||
34 | @@ -125,13 +127,14 @@ static void smc_encode_stream(SMCContext *s, const AVFrame *frame, | ||
35 | int color_octet_index = 0; | ||
36 | int color_table_index; /* indexes to color pair, quad, or octet tables */ | ||
37 | int total_blocks; | ||
38 | + int cur_y = 0; | ||
39 | |||
40 | memset(s->color_pairs, 0, sizeof(s->color_pairs)); | ||
41 | memset(s->color_quads, 0, sizeof(s->color_quads)); | ||
42 | memset(s->color_octets, 0, sizeof(s->color_octets)); | ||
43 | |||
44 | /* Number of 4x4 blocks in frame. */ | ||
45 | - total_blocks = ((frame->width + 3) / 4) * ((frame->height + 3) / 4); | ||
46 | + total_blocks = ((width + 3) / 4) * ((height + 3) / 4); | ||
47 | |||
48 | pixel_ptr = row_ptr = src_pixels; | ||
49 | |||
50 | @@ -145,11 +148,13 @@ static void smc_encode_stream(SMCContext *s, const AVFrame *frame, | ||
51 | int cache_index; | ||
52 | int distinct = 0; | ||
53 | int blocks = 0; | ||
54 | + int frame_y = cur_y; | ||
55 | |||
56 | while (prev_pixels && s->key_frame == 0 && block_counter + inter_skip_blocks < total_blocks) { | ||
57 | + const int y_size = FFMIN(4, height - cur_y); | ||
58 | int compare = 0; | ||
59 | |||
60 | - for (int y = 0; y < 4; y++) { | ||
61 | + for (int y = 0; y < y_size; y++) { | ||
62 | const ptrdiff_t offset = pixel_ptr - src_pixels; | ||
63 | const uint8_t *prev_pixel_ptr = prev_pixels + offset; | ||
64 | |||
65 | @@ -170,8 +175,10 @@ static void smc_encode_stream(SMCContext *s, const AVFrame *frame, | ||
66 | |||
67 | pixel_ptr = xpixel_ptr; | ||
68 | row_ptr = xrow_ptr; | ||
69 | + cur_y = frame_y; | ||
70 | |||
71 | while (block_counter > 0 && block_counter + intra_skip_blocks < total_blocks) { | ||
72 | + const int y_size = FFMIN(4, height - cur_y); | ||
73 | const ptrdiff_t offset = pixel_ptr - src_pixels; | ||
74 | const int sy = offset / stride; | ||
75 | const int sx = offset % stride; | ||
76 | @@ -180,7 +187,7 @@ static void smc_encode_stream(SMCContext *s, const AVFrame *frame, | ||
77 | const uint8_t *old_pixel_ptr = src_pixels + nx + ny * stride; | ||
78 | int compare = 0; | ||
79 | |||
80 | - for (int y = 0; y < 4; y++) { | ||
81 | + for (int y = 0; y < y_size; y++) { | ||
82 | compare |= memcmp(old_pixel_ptr + y * stride, pixel_ptr + y * stride, 4); | ||
83 | if (compare) | ||
84 | break; | ||
85 | @@ -197,9 +204,11 @@ static void smc_encode_stream(SMCContext *s, const AVFrame *frame, | ||
86 | |||
87 | pixel_ptr = xpixel_ptr; | ||
88 | row_ptr = xrow_ptr; | ||
89 | + cur_y = frame_y; | ||
90 | |||
91 | while (block_counter + coded_blocks < total_blocks && coded_blocks < 256) { | ||
92 | - for (int y = 0; y < 4; y++) | ||
93 | + const int y_size = FFMIN(4, height - cur_y); | ||
94 | + for (int y = 0; y < y_size; y++) | ||
95 | memcpy(block_values + y * 4, pixel_ptr + y * stride, 4); | ||
96 | |||
97 | qsort(block_values, 16, sizeof(block_values[0]), smc_cmp_values); | ||
98 | @@ -224,6 +233,7 @@ static void smc_encode_stream(SMCContext *s, const AVFrame *frame, | ||
99 | |||
100 | pixel_ptr = xpixel_ptr; | ||
101 | row_ptr = xrow_ptr; | ||
102 | + cur_y = frame_y; | ||
103 | |||
104 | blocks = coded_blocks; | ||
105 | distinct = coded_distinct; | ||
106 | -- | ||
107 | 2.34.1 | ||
108 | |||
diff --git a/meta/recipes-multimedia/ffmpeg/ffmpeg_5.1.2.bb b/meta/recipes-multimedia/ffmpeg/ffmpeg_5.1.2.bb index 43b858984b..06eca4fefe 100644 --- a/meta/recipes-multimedia/ffmpeg/ffmpeg_5.1.2.bb +++ b/meta/recipes-multimedia/ffmpeg/ffmpeg_5.1.2.bb | |||
@@ -23,7 +23,9 @@ LIC_FILES_CHKSUM = "file://COPYING.GPLv2;md5=b234ee4d69f5fce4486a80fdaf4a4263 \ | |||
23 | file://COPYING.LGPLv3;md5=e6a600fd5e1d9cbde2d983680233ad02" | 23 | file://COPYING.LGPLv3;md5=e6a600fd5e1d9cbde2d983680233ad02" |
24 | 24 | ||
25 | SRC_URI = "https://www.ffmpeg.org/releases/${BP}.tar.xz \ | 25 | SRC_URI = "https://www.ffmpeg.org/releases/${BP}.tar.xz \ |
26 | file://0001-avcodec-rpzaenc-stop-accessing-out-of-bounds-frame.patch" | 26 | file://0001-avcodec-rpzaenc-stop-accessing-out-of-bounds-frame.patch \ |
27 | file://0001-avcodec-smcenc-stop-accessing-out-of-bounds-frame.patch \ | ||
28 | " | ||
27 | 29 | ||
28 | SRC_URI[sha256sum] = "619e706d662c8420859832ddc259cd4d4096a48a2ce1eefd052db9e440eef3dc" | 30 | SRC_URI[sha256sum] = "619e706d662c8420859832ddc259cd4d4096a48a2ce1eefd052db9e440eef3dc" |
29 | 31 | ||