[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] ui/cursor: incomplete check for integer overflow in cursor_a
|
From: |
Mauro Matteo Cascella |
|
Subject: |
Re: [PATCH] ui/cursor: incomplete check for integer overflow in cursor_alloc |
|
Date: |
Mon, 22 May 2023 20:05:38 +0200 |
On Mon, May 8, 2023 at 4:20 PM Mauro Matteo Cascella
<mcascell@redhat.com> wrote:
>
> The cursor_alloc function still accepts a signed integer for both the cursor
> width and height. A specially crafted negative width/height could make
> datasize
> wrap around and cause the next allocation to be 0, potentially leading to a
> heap buffer overflow. Modify QEMUCursor struct and cursor_alloc prototype to
> accept unsigned ints.
>
> Fixes: CVE-2023-1601
> Fixes: fa892e9a ("ui/cursor: fix integer overflow in cursor_alloc
> (CVE-2021-4206)")
> Signed-off-by: Mauro Matteo Cascella <mcascell@redhat.com>
> Reported-by: Jacek Halon <jacek.halon@gmail.com>
Addendum:
Reported-by: Yair Mizrahi <yairh33@gmail.com>
Reported-by: Elsayed El-Refa'ei <e.elrefaei99@gmail.com>
> ---
> include/ui/console.h | 4 ++--
> ui/cursor.c | 2 +-
> 2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/include/ui/console.h b/include/ui/console.h
> index 2a8fab091f..92a4d90a1b 100644
> --- a/include/ui/console.h
> +++ b/include/ui/console.h
> @@ -144,13 +144,13 @@ typedef struct QemuUIInfo {
>
> /* cursor data format is 32bit RGBA */
> typedef struct QEMUCursor {
> - int width, height;
> + uint32_t width, height;
> int hot_x, hot_y;
> int refcount;
> uint32_t data[];
> } QEMUCursor;
>
> -QEMUCursor *cursor_alloc(int width, int height);
> +QEMUCursor *cursor_alloc(uint32_t width, uint32_t height);
> QEMUCursor *cursor_ref(QEMUCursor *c);
> void cursor_unref(QEMUCursor *c);
> QEMUCursor *cursor_builtin_hidden(void);
> diff --git a/ui/cursor.c b/ui/cursor.c
> index 6fe67990e2..b5fcb64839 100644
> --- a/ui/cursor.c
> +++ b/ui/cursor.c
> @@ -90,7 +90,7 @@ QEMUCursor *cursor_builtin_left_ptr(void)
> return cursor_parse_xpm(cursor_left_ptr_xpm);
> }
>
> -QEMUCursor *cursor_alloc(int width, int height)
> +QEMUCursor *cursor_alloc(uint32_t width, uint32_t height)
> {
> QEMUCursor *c;
> size_t datasize = width * height * sizeof(uint32_t);
> --
> 2.40.1
>
--
Mauro Matteo Cascella
Red Hat Product Security
PGP-Key ID: BB3410B0
- Re: [PATCH] ui/cursor: incomplete check for integer overflow in cursor_alloc, (continued)
- Re: [PATCH] ui/cursor: incomplete check for integer overflow in cursor_alloc, Marc-André Lureau, 2023/05/09
- Re: [PATCH] ui/cursor: incomplete check for integer overflow in cursor_alloc, Philippe Mathieu-Daudé, 2023/05/22
- Re: [PATCH] ui/cursor: incomplete check for integer overflow in cursor_alloc, Mauro Matteo Cascella, 2023/05/22
- Re: [PATCH] ui/cursor: incomplete check for integer overflow in cursor_alloc, Gerd Hoffmann, 2023/05/23
- Re: [PATCH] ui/cursor: incomplete check for integer overflow in cursor_alloc, Daniel P . Berrangé, 2023/05/23
- Re: [PATCH] ui/cursor: incomplete check for integer overflow in cursor_alloc, Philippe Mathieu-Daudé, 2023/05/23
- Re: [PATCH] ui/cursor: incomplete check for integer overflow in cursor_alloc, Mauro Matteo Cascella, 2023/05/23
- Re: [PATCH] ui/cursor: incomplete check for integer overflow in cursor_alloc, Philippe Mathieu-Daudé, 2023/05/23
- Re: [PATCH] ui/cursor: incomplete check for integer overflow in cursor_alloc, Mauro Matteo Cascella, 2023/05/23
Re: [PATCH] ui/cursor: incomplete check for integer overflow in cursor_alloc, Michael Tokarev, 2023/05/10
Re: [PATCH] ui/cursor: incomplete check for integer overflow in cursor_alloc,
Mauro Matteo Cascella <=
Re: [PATCH] ui/cursor: incomplete check for integer overflow in cursor_alloc, Daniel P . Berrangé, 2023/05/23