All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] video: fbdev: vermilion: use 64-bit arithmetic instead of 32-bit
@ 2018-02-07  0:04   ` Gustavo A. R. Silva
  0 siblings, 0 replies; 5+ messages in thread
From: Gustavo A. R. Silva @ 2018-02-07  0:04 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz
  Cc: dri-devel, linux-fbdev, linux-kernel, Gustavo A. R. Silva

Cast _pitch_ to u64 in order to give the compiler complete information
about the proper arithmetic to use. Notice that this variable is
being used in a context that expects an expression of type u64
(64 bits, unsigned).

The expression pitch * var->yres_virtual is currently being evaluated
using 32-bit arithmetic and the result of the operation is being stored
into variable mem, which is a variable of type u64. Based on that,
chances are there is a potential integer overflow as a result of the
operation.

Addresses-Coverity-ID: 200655 ("Unintentional integer overflow")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
 drivers/video/fbdev/vermilion/vermilion.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/video/fbdev/vermilion/vermilion.c b/drivers/video/fbdev/vermilion/vermilion.c
index 6f8d444..5172fa5 100644
--- a/drivers/video/fbdev/vermilion/vermilion.c
+++ b/drivers/video/fbdev/vermilion/vermilion.c
@@ -651,7 +651,7 @@ static int vmlfb_check_var_locked(struct fb_var_screeninfo *var,
 	}
 
 	pitch = ALIGN((var->xres * var->bits_per_pixel) >> 3, 0x40);
-	mem = pitch * var->yres_virtual;
+	mem = (u64)pitch * var->yres_virtual;
 	if (mem > vinfo->vram_contig_size) {
 		return -ENOMEM;
 	}
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH] video: fbdev: vermilion: use 64-bit arithmetic instead of 32-bit
@ 2018-02-07  0:04   ` Gustavo A. R. Silva
  0 siblings, 0 replies; 5+ messages in thread
From: Gustavo A. R. Silva @ 2018-02-07  0:04 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz
  Cc: dri-devel, linux-fbdev, linux-kernel, Gustavo A. R. Silva

Cast _pitch_ to u64 in order to give the compiler complete information
about the proper arithmetic to use. Notice that this variable is
being used in a context that expects an expression of type u64
(64 bits, unsigned).

The expression pitch * var->yres_virtual is currently being evaluated
using 32-bit arithmetic and the result of the operation is being stored
into variable mem, which is a variable of type u64. Based on that,
chances are there is a potential integer overflow as a result of the
operation.

Addresses-Coverity-ID: 200655 ("Unintentional integer overflow")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
 drivers/video/fbdev/vermilion/vermilion.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/video/fbdev/vermilion/vermilion.c b/drivers/video/fbdev/vermilion/vermilion.c
index 6f8d444..5172fa5 100644
--- a/drivers/video/fbdev/vermilion/vermilion.c
+++ b/drivers/video/fbdev/vermilion/vermilion.c
@@ -651,7 +651,7 @@ static int vmlfb_check_var_locked(struct fb_var_screeninfo *var,
 	}
 
 	pitch = ALIGN((var->xres * var->bits_per_pixel) >> 3, 0x40);
-	mem = pitch * var->yres_virtual;
+	mem = (u64)pitch * var->yres_virtual;
 	if (mem > vinfo->vram_contig_size) {
 		return -ENOMEM;
 	}
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] video: fbdev: vermilion: use 64-bit arithmetic instead of 32-bit
  2018-02-07  0:04   ` Gustavo A. R. Silva
  (?)
@ 2018-03-12 15:58     ` Bartlomiej Zolnierkiewicz
  -1 siblings, 0 replies; 5+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2018-03-12 15:58 UTC (permalink / raw)
  To: Gustavo A. R. Silva
  Cc: dri-devel, linux-fbdev, linux-kernel, Gustavo A. R. Silva

On Tuesday, February 06, 2018 06:04:24 PM Gustavo A. R. Silva wrote:
> Cast _pitch_ to u64 in order to give the compiler complete information
> about the proper arithmetic to use. Notice that this variable is
> being used in a context that expects an expression of type u64
> (64 bits, unsigned).
> 
> The expression pitch * var->yres_virtual is currently being evaluated
> using 32-bit arithmetic and the result of the operation is being stored
> into variable mem, which is a variable of type u64. Based on that,
> chances are there is a potential integer overflow as a result of the
> operation.
> 
> Addresses-Coverity-ID: 200655 ("Unintentional integer overflow")
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>

Patch queued for 4.17, thanks.

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] video: fbdev: vermilion: use 64-bit arithmetic instead of 32-bit
@ 2018-03-12 15:58     ` Bartlomiej Zolnierkiewicz
  0 siblings, 0 replies; 5+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2018-03-12 15:58 UTC (permalink / raw)
  To: Gustavo A. R. Silva
  Cc: linux-fbdev, Gustavo A. R. Silva, linux-kernel, dri-devel

On Tuesday, February 06, 2018 06:04:24 PM Gustavo A. R. Silva wrote:
> Cast _pitch_ to u64 in order to give the compiler complete information
> about the proper arithmetic to use. Notice that this variable is
> being used in a context that expects an expression of type u64
> (64 bits, unsigned).
> 
> The expression pitch * var->yres_virtual is currently being evaluated
> using 32-bit arithmetic and the result of the operation is being stored
> into variable mem, which is a variable of type u64. Based on that,
> chances are there is a potential integer overflow as a result of the
> operation.
> 
> Addresses-Coverity-ID: 200655 ("Unintentional integer overflow")
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>

Patch queued for 4.17, thanks.

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] video: fbdev: vermilion: use 64-bit arithmetic instead of 32-bit
@ 2018-03-12 15:58     ` Bartlomiej Zolnierkiewicz
  0 siblings, 0 replies; 5+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2018-03-12 15:58 UTC (permalink / raw)
  To: Gustavo A. R. Silva
  Cc: linux-fbdev, Gustavo A. R. Silva, linux-kernel, dri-devel

On Tuesday, February 06, 2018 06:04:24 PM Gustavo A. R. Silva wrote:
> Cast _pitch_ to u64 in order to give the compiler complete information
> about the proper arithmetic to use. Notice that this variable is
> being used in a context that expects an expression of type u64
> (64 bits, unsigned).
> 
> The expression pitch * var->yres_virtual is currently being evaluated
> using 32-bit arithmetic and the result of the operation is being stored
> into variable mem, which is a variable of type u64. Based on that,
> chances are there is a potential integer overflow as a result of the
> operation.
> 
> Addresses-Coverity-ID: 200655 ("Unintentional integer overflow")
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>

Patch queued for 4.17, thanks.

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-03-12 15:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20180207000429epcas3p49ce7f7528d02b9799713e8806d77847d@epcas3p4.samsung.com>
2018-02-07  0:04 ` [PATCH] video: fbdev: vermilion: use 64-bit arithmetic instead of 32-bit Gustavo A. R. Silva
2018-02-07  0:04   ` Gustavo A. R. Silva
2018-03-12 15:58   ` Bartlomiej Zolnierkiewicz
2018-03-12 15:58     ` Bartlomiej Zolnierkiewicz
2018-03-12 15:58     ` Bartlomiej Zolnierkiewicz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.