|
| 1 | +From 85b776571487f52e756f68a069c768757369bfe3 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Matthieu Herrb < [email protected]> |
| 3 | +Date: Thu, 10 Oct 2024 10:37:28 +0200 |
| 4 | +Subject: [PATCH] xkb: Fix buffer overflow in _XkbSetCompatMap() |
| 5 | +MIME-Version: 1.0 |
| 6 | +Content-Type: text/plain; charset=UTF-8 |
| 7 | +Content-Transfer-Encoding: 8bit |
| 8 | + |
| 9 | +The _XkbSetCompatMap() function attempts to resize the `sym_interpret` |
| 10 | +buffer. |
| 11 | + |
| 12 | +However, It didn't update its size properly. It updated `num_si` only, |
| 13 | +without updating `size_si`. |
| 14 | + |
| 15 | +This may lead to local privilege escalation if the server is run as root |
| 16 | +or remote code execution (e.g. x11 over ssh). |
| 17 | + |
| 18 | +CVE-2024-9632, ZDI-CAN-24756 |
| 19 | + |
| 20 | +This vulnerability was discovered by: |
| 21 | +Jan-Niklas Sohn working with Trend Micro Zero Day Initiative |
| 22 | + |
| 23 | +Reviewed-by: Peter Hutterer < [email protected]> |
| 24 | +Tested-by: Peter Hutterer < [email protected]> |
| 25 | +Reviewed-by: José Expósito < [email protected]> |
| 26 | +Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1733> |
| 27 | +--- |
| 28 | + xkb/xkb.c | 8 ++++---- |
| 29 | + 1 file changed, 4 insertions(+), 4 deletions(-) |
| 30 | + |
| 31 | +diff --git a/xkb/xkb.c b/xkb/xkb.c |
| 32 | +index 868d7c1e64..aaf9716b36 100644 |
| 33 | +--- a/xkb/xkb.c |
| 34 | ++++ b/xkb/xkb.c |
| 35 | +@@ -2990,13 +2990,13 @@ _XkbSetCompatMap(ClientPtr client, DeviceIntPtr dev, |
| 36 | + XkbSymInterpretPtr sym; |
| 37 | + unsigned int skipped = 0; |
| 38 | + |
| 39 | +- if ((unsigned) (req->firstSI + req->nSI) > compat->num_si) { |
| 40 | +- compat->num_si = req->firstSI + req->nSI; |
| 41 | ++ if ((unsigned) (req->firstSI + req->nSI) > compat->size_si) { |
| 42 | ++ compat->num_si = compat->size_si = req->firstSI + req->nSI; |
| 43 | + compat->sym_interpret = reallocarray(compat->sym_interpret, |
| 44 | +- compat->num_si, |
| 45 | ++ compat->size_si, |
| 46 | + sizeof(XkbSymInterpretRec)); |
| 47 | + if (!compat->sym_interpret) { |
| 48 | +- compat->num_si = 0; |
| 49 | ++ compat->num_si = compat->size_si = 0; |
| 50 | + return BadAlloc; |
| 51 | + } |
| 52 | + } |
| 53 | +-- |
| 54 | +GitLab |
0 commit comments