* [Intel-gfx] [PATCH] drm/i915: Fix a crash in shmem_pin_map() error handling
@ 2020-10-23 11:34 Dan Carpenter
2020-10-23 11:36 ` [Intel-gfx] ✗ Fi.CI.BUILD: failure for " Patchwork
2020-10-23 12:19 ` [Intel-gfx] [PATCH] " Christoph Hellwig
0 siblings, 2 replies; 4+ messages in thread
From: Dan Carpenter @ 2020-10-23 11:34 UTC (permalink / raw)
To: Jani Nikula, Christoph Hellwig
Cc: David Airlie, intel-gfx, kernel-janitors, linux-kernel, dri-devel,
Chris Wilson, Matthew Auld, Andrew Morton
There is a signedness bug in shmem_pin_map() error handling because "i"
is unsigned. The "while (--i >= 0)" will loop forever until the system
crashes.
Fixes: bfed6708d6c9 ("drm/i915: use vmap in shmem_pin_map")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
drivers/gpu/drm/i915/gt/shmem_utils.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/i915/gt/shmem_utils.c b/drivers/gpu/drm/i915/gt/shmem_utils.c
index f011ea42487e..7eb542018219 100644
--- a/drivers/gpu/drm/i915/gt/shmem_utils.c
+++ b/drivers/gpu/drm/i915/gt/shmem_utils.c
@@ -52,8 +52,9 @@ struct file *shmem_create_from_object(struct drm_i915_gem_object *obj)
void *shmem_pin_map(struct file *file)
{
struct page **pages;
- size_t n_pages, i;
+ size_t n_pages;
void *vaddr;
+ int i;
n_pages = file->f_mapping->host->i_size >> PAGE_SHIFT;
pages = kvmalloc_array(n_pages, sizeof(*pages), GFP_KERNEL);
--
2.28.0
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [Intel-gfx] ✗ Fi.CI.BUILD: failure for drm/i915: Fix a crash in shmem_pin_map() error handling
2020-10-23 11:34 [Intel-gfx] [PATCH] drm/i915: Fix a crash in shmem_pin_map() error handling Dan Carpenter
@ 2020-10-23 11:36 ` Patchwork
2020-10-23 12:19 ` [Intel-gfx] [PATCH] " Christoph Hellwig
1 sibling, 0 replies; 4+ messages in thread
From: Patchwork @ 2020-10-23 11:36 UTC (permalink / raw)
To: Dan Carpenter; +Cc: intel-gfx
== Series Details ==
Series: drm/i915: Fix a crash in shmem_pin_map() error handling
URL : https://patchwork.freedesktop.org/series/82989/
State : failure
== Summary ==
Applying: drm/i915: Fix a crash in shmem_pin_map() error handling
Using index info to reconstruct a base tree...
M drivers/gpu/drm/i915/gt/shmem_utils.c
Falling back to patching base and 3-way merge...
Auto-merging drivers/gpu/drm/i915/gt/shmem_utils.c
CONFLICT (content): Merge conflict in drivers/gpu/drm/i915/gt/shmem_utils.c
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 drm/i915: Fix a crash in shmem_pin_map() error handling
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Intel-gfx] [PATCH] drm/i915: Fix a crash in shmem_pin_map() error handling
2020-10-23 11:34 [Intel-gfx] [PATCH] drm/i915: Fix a crash in shmem_pin_map() error handling Dan Carpenter
2020-10-23 11:36 ` [Intel-gfx] ✗ Fi.CI.BUILD: failure for " Patchwork
@ 2020-10-23 12:19 ` Christoph Hellwig
2020-10-24 13:47 ` Dan Carpenter
1 sibling, 1 reply; 4+ messages in thread
From: Christoph Hellwig @ 2020-10-23 12:19 UTC (permalink / raw)
To: Dan Carpenter
Cc: dri-devel, David Airlie, intel-gfx, kernel-janitors, linux-kernel,
Chris Wilson, Matthew Auld, Andrew Morton, Christoph Hellwig
On Fri, Oct 23, 2020 at 02:34:01PM +0300, Dan Carpenter wrote:
> There is a signedness bug in shmem_pin_map() error handling because "i"
> is unsigned. The "while (--i >= 0)" will loop forever until the system
> crashes.
I actually sent a patch to Andrew before the end of the merge window
to use a for loop with a new j iterator to fix this based on your
automated report, but it looks like that didn't go in.
> Fixes: bfed6708d6c9 ("drm/i915: use vmap in shmem_pin_map")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> drivers/gpu/drm/i915/gt/shmem_utils.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/i915/gt/shmem_utils.c b/drivers/gpu/drm/i915/gt/shmem_utils.c
> index f011ea42487e..7eb542018219 100644
> --- a/drivers/gpu/drm/i915/gt/shmem_utils.c
> +++ b/drivers/gpu/drm/i915/gt/shmem_utils.c
> @@ -52,8 +52,9 @@ struct file *shmem_create_from_object(struct drm_i915_gem_object *obj)
> void *shmem_pin_map(struct file *file)
> {
> struct page **pages;
> - size_t n_pages, i;
> + size_t n_pages;
> void *vaddr;
> + int i;
>
> n_pages = file->f_mapping->host->i_size >> PAGE_SHIFT;
> pages = kvmalloc_array(n_pages, sizeof(*pages), GFP_KERNEL);
This assumes we never have more than INT_MAX worth of pages before
a failure.
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Intel-gfx] [PATCH] drm/i915: Fix a crash in shmem_pin_map() error handling
2020-10-23 12:19 ` [Intel-gfx] [PATCH] " Christoph Hellwig
@ 2020-10-24 13:47 ` Dan Carpenter
0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2020-10-24 13:47 UTC (permalink / raw)
To: Christoph Hellwig
Cc: dri-devel, David Airlie, intel-gfx, kernel-janitors, linux-kernel,
Chris Wilson, Matthew Auld, Andrew Morton
On Fri, Oct 23, 2020 at 02:19:41PM +0200, Christoph Hellwig wrote:
> > diff --git a/drivers/gpu/drm/i915/gt/shmem_utils.c b/drivers/gpu/drm/i915/gt/shmem_utils.c
> > index f011ea42487e..7eb542018219 100644
> > --- a/drivers/gpu/drm/i915/gt/shmem_utils.c
> > +++ b/drivers/gpu/drm/i915/gt/shmem_utils.c
> > @@ -52,8 +52,9 @@ struct file *shmem_create_from_object(struct drm_i915_gem_object *obj)
> > void *shmem_pin_map(struct file *file)
> > {
> > struct page **pages;
> > - size_t n_pages, i;
> > + size_t n_pages;
> > void *vaddr;
> > + int i;
> >
> > n_pages = file->f_mapping->host->i_size >> PAGE_SHIFT;
> > pages = kvmalloc_array(n_pages, sizeof(*pages), GFP_KERNEL);
>
> This assumes we never have more than INT_MAX worth of pages before
> a failure.
Doh. Yeah. My bad.
regards,
dan carpenter
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-10-24 18:03 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-23 11:34 [Intel-gfx] [PATCH] drm/i915: Fix a crash in shmem_pin_map() error handling Dan Carpenter
2020-10-23 11:36 ` [Intel-gfx] ✗ Fi.CI.BUILD: failure for " Patchwork
2020-10-23 12:19 ` [Intel-gfx] [PATCH] " Christoph Hellwig
2020-10-24 13:47 ` Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox