diff options
| author | Archana Polampalli <archana.polampalli@windriver.com> | 2025-07-02 21:16:15 +0530 |
|---|---|---|
| committer | Steve Sakoman <steve@sakoman.com> | 2025-07-09 08:43:32 -0700 |
| commit | 0d8b19752ddd401065c873beff61d2c738e37460 (patch) | |
| tree | d523e7144f8b13c2f37122e21708c13fc058619b | |
| parent | a1db9c900f419fe3b0a09f37071a897f1b59dbdd (diff) | |
| download | poky-0d8b19752ddd401065c873beff61d2c738e37460.tar.gz | |
xwayland: fix CVE-2025-49176
A flaw was found in the Big Requests extension. The request length is multiplied
by 4 before checking against the maximum allowed size, potentially causing an
integer overflow and bypassing the size check.
(From OE-Core rev: 0a2c5179e1f08ccd0fcaccb6f95c892ebafac8a8)
Signed-off-by: Archana Polampalli <archana.polampalli@windriver.com>
Signed-off-by: Steve Sakoman <steve@sakoman.com>
3 files changed, 133 insertions, 0 deletions
diff --git a/meta/recipes-graphics/xwayland/xwayland/CVE-2025-49176-0001.patch b/meta/recipes-graphics/xwayland/xwayland/CVE-2025-49176-0001.patch new file mode 100644 index 0000000000..fd3b1d936b --- /dev/null +++ b/meta/recipes-graphics/xwayland/xwayland/CVE-2025-49176-0001.patch | |||
| @@ -0,0 +1,93 @@ | |||
| 1 | From 03731b326a80b582e48d939fe62cb1e2b10400d9 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Olivier Fourdan <ofourdan@redhat.com> | ||
| 3 | Date: Mon, 7 Apr 2025 16:13:34 +0200 | ||
| 4 | Subject: [PATCH] os: Do not overflow the integer size with BigRequest | ||
| 5 | MIME-Version: 1.0 | ||
| 6 | Content-Type: text/plain; charset=UTF-8 | ||
| 7 | Content-Transfer-Encoding: 8bit | ||
| 8 | |||
| 9 | The BigRequest extension allows requests larger than the 16-bit length | ||
| 10 | limit. | ||
| 11 | |||
| 12 | It uses integers for the request length and checks for the size not to | ||
| 13 | exceed the maxBigRequestSize limit, but does so after translating the | ||
| 14 | length to integer by multiplying the given size in bytes by 4. | ||
| 15 | |||
| 16 | In doing so, it might overflow the integer size limit before actually | ||
| 17 | checking for the overflow, defeating the purpose of the test. | ||
| 18 | |||
| 19 | To avoid the issue, make sure to check that the request size does not | ||
| 20 | overflow the maxBigRequestSize limit prior to any conversion. | ||
| 21 | |||
| 22 | The caller Dispatch() function however expects the return value to be in | ||
| 23 | bytes, so we cannot just return the converted value in case of error, as | ||
| 24 | that would also overflow the integer size. | ||
| 25 | |||
| 26 | To preserve the existing API, we use a negative value for the X11 error | ||
| 27 | code BadLength as the function only return positive values, 0 or -1 and | ||
| 28 | update the caller Dispatch() function to take that case into account to | ||
| 29 | return the error code to the offending client. | ||
| 30 | |||
| 31 | CVE-2025-49176 | ||
| 32 | |||
| 33 | This issue was discovered by Nils Emmerich <nemmerich@ernw.de> and | ||
| 34 | reported by Julian Suleder via ERNW Vulnerability Disclosure. | ||
| 35 | |||
| 36 | Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> | ||
| 37 | Reviewed-by: Michel Dänzer <mdaenzer@redhat.com> | ||
| 38 | Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2024> | ||
| 39 | |||
| 40 | CVE: CVE-2025-49176 | ||
| 41 | |||
| 42 | Upstream-Status: Backport [https://gitlab.freedesktop.org/xorg/xserver/-/commit/03731b326a80b582e48d939fe62cb1e2b10400d9] | ||
| 43 | |||
| 44 | Signed-off-by: Archana Polampalli <archana.polampalli@windriver.com> | ||
| 45 | --- | ||
| 46 | dix/dispatch.c | 9 +++++---- | ||
| 47 | os/io.c | 4 ++++ | ||
| 48 | 2 files changed, 9 insertions(+), 4 deletions(-) | ||
| 49 | |||
| 50 | diff --git a/dix/dispatch.c b/dix/dispatch.c | ||
| 51 | index 9e98d54..20473f1 100644 | ||
| 52 | --- a/dix/dispatch.c | ||
| 53 | +++ b/dix/dispatch.c | ||
| 54 | @@ -513,9 +513,10 @@ Dispatch(void) | ||
| 55 | |||
| 56 | /* now, finally, deal with client requests */ | ||
| 57 | result = ReadRequestFromClient(client); | ||
| 58 | - if (result <= 0) { | ||
| 59 | - if (result < 0) | ||
| 60 | - CloseDownClient(client); | ||
| 61 | + if (result == 0) | ||
| 62 | + break; | ||
| 63 | + else if (result == -1) { | ||
| 64 | + CloseDownClient(client); | ||
| 65 | break; | ||
| 66 | } | ||
| 67 | |||
| 68 | @@ -536,7 +537,7 @@ Dispatch(void) | ||
| 69 | client->index, | ||
| 70 | client->requestBuffer); | ||
| 71 | #endif | ||
| 72 | - if (result > (maxBigRequestSize << 2)) | ||
| 73 | + if (result < 0 || result > (maxBigRequestSize << 2)) | ||
| 74 | result = BadLength; | ||
| 75 | else { | ||
| 76 | result = XaceHookDispatch(client, client->majorOp); | ||
| 77 | diff --git a/os/io.c b/os/io.c | ||
| 78 | index 841a0ee..aeece86 100644 | ||
| 79 | --- a/os/io.c | ||
| 80 | +++ b/os/io.c | ||
| 81 | @@ -296,6 +296,10 @@ ReadRequestFromClient(ClientPtr client) | ||
| 82 | needed = get_big_req_len(request, client); | ||
| 83 | } | ||
| 84 | client->req_len = needed; | ||
| 85 | + if (needed > MAXINT >> 2) { | ||
| 86 | + /* Check for potential integer overflow */ | ||
| 87 | + return -(BadLength); | ||
| 88 | + } | ||
| 89 | needed <<= 2; /* needed is in bytes now */ | ||
| 90 | } | ||
| 91 | if (gotnow < needed) { | ||
| 92 | -- | ||
| 93 | 2.40.0 | ||
diff --git a/meta/recipes-graphics/xwayland/xwayland/CVE-2025-49176-0002.patch b/meta/recipes-graphics/xwayland/xwayland/CVE-2025-49176-0002.patch new file mode 100644 index 0000000000..6d7df79111 --- /dev/null +++ b/meta/recipes-graphics/xwayland/xwayland/CVE-2025-49176-0002.patch | |||
| @@ -0,0 +1,38 @@ | |||
| 1 | From 4fc4d76b2c7aaed61ed2653f997783a3714c4fe1 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Olivier Fourdan <ofourdan@redhat.com> | ||
| 3 | Date: Wed, 18 Jun 2025 08:39:02 +0200 | ||
| 4 | Subject: [PATCH] os: Check for integer overflow on BigRequest length | ||
| 5 | |||
| 6 | Check for another possible integer overflow once we get a complete xReq | ||
| 7 | with BigRequest. | ||
| 8 | |||
| 9 | Related to CVE-2025-49176 | ||
| 10 | |||
| 11 | Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> | ||
| 12 | Suggested-by: Peter Harris <pharris2@rocketsoftware.com> | ||
| 13 | Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2028> | ||
| 14 | |||
| 15 | CVE: CVE-2025-49176 | ||
| 16 | |||
| 17 | Upstream-Status: Backport [https://gitlab.freedesktop.org/xorg/xserver/-/commit/4fc4d76b2c7aaed61ed2653f997783a3714c4fe1] | ||
| 18 | |||
| 19 | Signed-off-by: Archana Polampalli <archana.polampalli@windriver.com> | ||
| 20 | --- | ||
| 21 | os/io.c | 2 ++ | ||
| 22 | 1 file changed, 2 insertions(+) | ||
| 23 | |||
| 24 | diff --git a/os/io.c b/os/io.c | ||
| 25 | index aeece86..67465f9 100644 | ||
| 26 | --- a/os/io.c | ||
| 27 | +++ b/os/io.c | ||
| 28 | @@ -395,6 +395,8 @@ ReadRequestFromClient(ClientPtr client) | ||
| 29 | needed = get_big_req_len(request, client); | ||
| 30 | } | ||
| 31 | client->req_len = needed; | ||
| 32 | + if (needed > MAXINT >> 2) | ||
| 33 | + return -(BadLength); | ||
| 34 | needed <<= 2; | ||
| 35 | } | ||
| 36 | if (gotnow < needed) { | ||
| 37 | -- | ||
| 38 | 2.40.0 | ||
diff --git a/meta/recipes-graphics/xwayland/xwayland_23.2.5.bb b/meta/recipes-graphics/xwayland/xwayland_23.2.5.bb index b9b4aa1a6a..72396dcd40 100644 --- a/meta/recipes-graphics/xwayland/xwayland_23.2.5.bb +++ b/meta/recipes-graphics/xwayland/xwayland_23.2.5.bb | |||
| @@ -25,6 +25,8 @@ SRC_URI = "https://www.x.org/archive/individual/xserver/xwayland-${PV}.tar.xz \ | |||
| 25 | file://CVE-2025-26601-3.patch \ | 25 | file://CVE-2025-26601-3.patch \ |
| 26 | file://CVE-2025-26601-4.patch \ | 26 | file://CVE-2025-26601-4.patch \ |
| 27 | file://CVE-2025-49175.patch \ | 27 | file://CVE-2025-49175.patch \ |
| 28 | file://CVE-2025-49176-0001.patch \ | ||
| 29 | file://CVE-2025-49176-0002.patch \ | ||
| 28 | " | 30 | " |
| 29 | SRC_URI[sha256sum] = "33ec7ff2687a59faaa52b9b09aa8caf118e7ecb6aed8953f526a625ff9f4bd90" | 31 | SRC_URI[sha256sum] = "33ec7ff2687a59faaa52b9b09aa8caf118e7ecb6aed8953f526a625ff9f4bd90" |
| 30 | 32 | ||
