From: "Souza, Jose" <jose.souza@intel.com>
To: "intel-xe@lists.freedesktop.org" <intel-xe@lists.freedesktop.org>,
"Zanoni, Paulo R" <paulo.r.zanoni@intel.com>
Subject: Re: [Intel-xe] [PATCH 1/2 v2] drm/xe: fix bounds checking for 'len' in xe_engine_create_ioctl
Date: Tue, 27 Jun 2023 18:17:12 +0000 [thread overview]
Message-ID: <c386a297b512964a8d34b5df9a80ebb4eaa9229e.camel@intel.com> (raw)
In-Reply-To: <20230626212221.136640-1-paulo.r.zanoni@intel.com>
On Mon, 2023-06-26 at 14:22 -0700, Paulo Zanoni wrote:
> There's this shared machine running xe.ko and I often log in to see my
> tmux corrupted by messages such as:
>
> usercopy: Kernel memory overwrite attempt detected to wrapped address (offset 0, size 18446660151965198754)!
>
> I also sometimes see:
>
> kernel BUG at mm/usercopy.c:102!
>
> Someone is running a program that's definitely submitting random
> numbers to this ioctl. If you pass width=65535 and
> num_placements=32769 then you get a negative 'len', which avoids the
> EINVAL check, leading to the bug.
>
> Switch 'len' to u32. It is the result of the multiplication of two u16
> numbers, so it won't be able to overflow back into smaller numbers as
> an u32.
>
> Very simple reproducer:
> https://people.freedesktop.org/~pzanoni/engine-create-bug/
>
> v2: Make len u32 instead of checking for <=0 (José).
>
Reviewed-by: José Roberto de Souza <jose.souza@intel.com>
> Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
> ---
> drivers/gpu/drm/xe/xe_engine.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_engine.c b/drivers/gpu/drm/xe/xe_engine.c
> index 6e6b2913f766..530f55a33b03 100644
> --- a/drivers/gpu/drm/xe/xe_engine.c
> +++ b/drivers/gpu/drm/xe/xe_engine.c
> @@ -522,7 +522,7 @@ int xe_engine_create_ioctl(struct drm_device *dev, void *data,
> struct xe_engine *e = NULL;
> u32 logical_mask;
> u32 id;
> - int len;
> + u32 len;
> int err;
>
> if (XE_IOCTL_ERR(xe, args->flags) ||
next prev parent reply other threads:[~2023-06-27 18:17 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-26 21:22 [Intel-xe] [PATCH 1/2 v2] drm/xe: fix bounds checking for 'len' in xe_engine_create_ioctl Paulo Zanoni
2023-06-26 21:22 ` [Intel-xe] [PATCH 2/2] drm/xe: properly check bounds for xe_wait_user_fence_ioctl() Paulo Zanoni
2023-06-27 19:30 ` Lucas De Marchi
2023-06-27 21:25 ` Zanoni, Paulo R
2023-06-26 21:24 ` [Intel-xe] ✓ CI.Patch_applied: success for series starting with [1/2,v2] drm/xe: fix bounds checking for 'len' in xe_engine_create_ioctl Patchwork
2023-06-26 21:24 ` [Intel-xe] ✗ CI.checkpatch: warning " Patchwork
2023-06-26 21:26 ` [Intel-xe] ✓ CI.KUnit: success " Patchwork
2023-06-26 21:29 ` [Intel-xe] ✓ CI.Build: " Patchwork
2023-06-26 21:30 ` [Intel-xe] ✓ CI.Hooks: " Patchwork
2023-06-26 21:31 ` [Intel-xe] ✓ CI.checksparse: " Patchwork
2023-06-26 22:09 ` [Intel-xe] ○ CI.BAT: info " Patchwork
2023-06-26 22:25 ` [Intel-xe] [PATCH 1/2 v2] " Matthew Brost
2023-06-27 18:17 ` Souza, Jose [this message]
2023-06-27 19:10 ` Lucas De Marchi
2023-06-27 21:24 ` Zanoni, Paulo R
2023-06-29 4:06 ` Lucas De Marchi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c386a297b512964a8d34b5df9a80ebb4eaa9229e.camel@intel.com \
--to=jose.souza@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=paulo.r.zanoni@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox