1 From f045f459d925138fe7d6193a8c86406bda7e49da Mon Sep 17 00:00:00 2001
2 From: Ben Skeggs <bskeggs@redhat.com>
3 Date: Thu, 2 Jun 2016 12:23:31 +1000
4 Subject: drm/nouveau/fbcon: fix out-of-bounds memory accesses
6 From: Ben Skeggs <bskeggs@redhat.com>
8 commit f045f459d925138fe7d6193a8c86406bda7e49da upstream.
12 Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
13 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
16 drivers/gpu/drm/nouveau/nouveau_fbcon.c | 1 +
17 drivers/gpu/drm/nouveau/nv04_fbcon.c | 7 ++-----
18 drivers/gpu/drm/nouveau/nv50_fbcon.c | 6 ++----
19 drivers/gpu/drm/nouveau/nvc0_fbcon.c | 6 ++----
20 4 files changed, 7 insertions(+), 13 deletions(-)
22 --- a/drivers/gpu/drm/nouveau/nouveau_fbcon.c
23 +++ b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
24 @@ -557,6 +557,7 @@ nouveau_fbcon_init(struct drm_device *de
28 + fbcon->helper.fbdev->pixmap.buf_align = 4;
32 --- a/drivers/gpu/drm/nouveau/nv04_fbcon.c
33 +++ b/drivers/gpu/drm/nouveau/nv04_fbcon.c
34 @@ -82,7 +82,6 @@ nv04_fbcon_imageblit(struct fb_info *inf
39 uint32_t *data = (uint32_t *)image->data;
42 @@ -93,9 +92,6 @@ nv04_fbcon_imageblit(struct fb_info *inf
46 - width = ALIGN(image->width, 8);
47 - dsize = ALIGN(width * image->height, 32) >> 5;
49 if (info->fix.visual == FB_VISUAL_TRUECOLOR ||
50 info->fix.visual == FB_VISUAL_DIRECTCOLOR) {
51 fg = ((uint32_t *) info->pseudo_palette)[image->fg_color];
52 @@ -111,10 +107,11 @@ nv04_fbcon_imageblit(struct fb_info *inf
53 ((image->dx + image->width) & 0xffff));
56 - OUT_RING(chan, (image->height << 16) | width);
57 + OUT_RING(chan, (image->height << 16) | image->width);
58 OUT_RING(chan, (image->height << 16) | image->width);
59 OUT_RING(chan, (image->dy << 16) | (image->dx & 0xffff));
61 + dsize = ALIGN(image->width * image->height, 32) >> 5;
63 int iter_len = dsize > 128 ? 128 : dsize;
65 --- a/drivers/gpu/drm/nouveau/nv50_fbcon.c
66 +++ b/drivers/gpu/drm/nouveau/nv50_fbcon.c
67 @@ -95,7 +95,7 @@ nv50_fbcon_imageblit(struct fb_info *inf
68 struct nouveau_fbdev *nfbdev = info->par;
69 struct nouveau_drm *drm = nouveau_drm(nfbdev->dev);
70 struct nouveau_channel *chan = drm->channel;
71 - uint32_t width, dwords, *data = (uint32_t *)image->data;
72 + uint32_t dwords, *data = (uint32_t *)image->data;
73 uint32_t mask = ~(~0 >> (32 - info->var.bits_per_pixel));
74 uint32_t *palette = info->pseudo_palette;
76 @@ -107,9 +107,6 @@ nv50_fbcon_imageblit(struct fb_info *inf
80 - width = ALIGN(image->width, 32);
81 - dwords = (width * image->height) >> 5;
83 BEGIN_NV04(chan, NvSub2D, 0x0814, 2);
84 if (info->fix.visual == FB_VISUAL_TRUECOLOR ||
85 info->fix.visual == FB_VISUAL_DIRECTCOLOR) {
86 @@ -128,6 +125,7 @@ nv50_fbcon_imageblit(struct fb_info *inf
88 OUT_RING(chan, image->dy);
90 + dwords = ALIGN(image->width * image->height, 32) >> 5;
92 int push = dwords > 2047 ? 2047 : dwords;
94 --- a/drivers/gpu/drm/nouveau/nvc0_fbcon.c
95 +++ b/drivers/gpu/drm/nouveau/nvc0_fbcon.c
96 @@ -95,7 +95,7 @@ nvc0_fbcon_imageblit(struct fb_info *inf
97 struct nouveau_fbdev *nfbdev = info->par;
98 struct nouveau_drm *drm = nouveau_drm(nfbdev->dev);
99 struct nouveau_channel *chan = drm->channel;
100 - uint32_t width, dwords, *data = (uint32_t *)image->data;
101 + uint32_t dwords, *data = (uint32_t *)image->data;
102 uint32_t mask = ~(~0 >> (32 - info->var.bits_per_pixel));
103 uint32_t *palette = info->pseudo_palette;
105 @@ -107,9 +107,6 @@ nvc0_fbcon_imageblit(struct fb_info *inf
109 - width = ALIGN(image->width, 32);
110 - dwords = (width * image->height) >> 5;
112 BEGIN_NVC0(chan, NvSub2D, 0x0814, 2);
113 if (info->fix.visual == FB_VISUAL_TRUECOLOR ||
114 info->fix.visual == FB_VISUAL_DIRECTCOLOR) {
115 @@ -128,6 +125,7 @@ nvc0_fbcon_imageblit(struct fb_info *inf
117 OUT_RING (chan, image->dy);
119 + dwords = ALIGN(image->width * image->height, 32) >> 5;
121 int push = dwords > 2047 ? 2047 : dwords;