* [PATCH 1/2] drm/logicvc: Avoid possible overflow in layer buffer setup variables
@ 2023-10-25 13:09 Paul Kocialkowski
2023-10-25 13:09 ` [PATCH 2/2] drm/logicvc: Define max dimensions from USHRT_MAX Paul Kocialkowski
2023-11-21 14:29 ` [PATCH 1/2] drm/logicvc: Avoid possible overflow in layer buffer setup variables Paul Kocialkowski
0 siblings, 2 replies; 3+ messages in thread
From: Paul Kocialkowski @ 2023-10-25 13:09 UTC (permalink / raw)
To: dri-devel, linux-kernel
Cc: Paul Kocialkowski, David Airlie, Daniel Vetter, Maxime Ripard,
Dan Carpenter
The buffer_sel, voffset and hoffset values are calculated from u32
values and might overflow under certain conditions.
Move them to u32 definitions instead of u8/u16 to avoid the issue.
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Fixes: efeeaefe9be5 ("drm: Add support for the LogiCVC display controller")
---
drivers/gpu/drm/logicvc/logicvc_layer.c | 6 +++---
drivers/gpu/drm/logicvc/logicvc_layer.h | 6 +++---
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/logicvc/logicvc_layer.c b/drivers/gpu/drm/logicvc/logicvc_layer.c
index 464000aea765..eea22379d042 100644
--- a/drivers/gpu/drm/logicvc/logicvc_layer.c
+++ b/drivers/gpu/drm/logicvc/logicvc_layer.c
@@ -268,9 +268,9 @@ int logicvc_layer_buffer_find_setup(struct logicvc_drm *logicvc,
u32 layer_stride = layer_bytespp * logicvc->config.row_stride;
u32 base_offset = layer->config.base_offset * layer_stride;
u32 buffer_offset = layer->config.buffer_offset * layer_stride;
- u8 buffer_sel = 0;
- u16 voffset = 0;
- u16 hoffset = 0;
+ u32 buffer_sel = 0;
+ u32 voffset = 0;
+ u32 hoffset = 0;
phys_addr_t fb_addr;
u32 fb_offset;
u32 gap;
diff --git a/drivers/gpu/drm/logicvc/logicvc_layer.h b/drivers/gpu/drm/logicvc/logicvc_layer.h
index 4a4b02e9b819..a06feeda3abf 100644
--- a/drivers/gpu/drm/logicvc/logicvc_layer.h
+++ b/drivers/gpu/drm/logicvc/logicvc_layer.h
@@ -18,9 +18,9 @@
#define LOGICVC_LAYER_ALPHA_PIXEL 1
struct logicvc_layer_buffer_setup {
- u8 buffer_sel;
- u16 voffset;
- u16 hoffset;
+ u32 buffer_sel;
+ u32 voffset;
+ u32 hoffset;
};
struct logicvc_layer_config {
--
2.42.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 2/2] drm/logicvc: Define max dimensions from USHRT_MAX
2023-10-25 13:09 [PATCH 1/2] drm/logicvc: Avoid possible overflow in layer buffer setup variables Paul Kocialkowski
@ 2023-10-25 13:09 ` Paul Kocialkowski
2023-11-21 14:29 ` [PATCH 1/2] drm/logicvc: Avoid possible overflow in layer buffer setup variables Paul Kocialkowski
1 sibling, 0 replies; 3+ messages in thread
From: Paul Kocialkowski @ 2023-10-25 13:09 UTC (permalink / raw)
To: dri-devel, linux-kernel
Cc: Paul Kocialkowski, David Airlie, Daniel Vetter, Maxime Ripard,
Dan Carpenter
Use the existing macro instead of redefining it.
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
---
drivers/gpu/drm/logicvc/logicvc_regs.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/logicvc/logicvc_regs.h b/drivers/gpu/drm/logicvc/logicvc_regs.h
index 4aae27e9ba2b..0fc413fef6dd 100644
--- a/drivers/gpu/drm/logicvc/logicvc_regs.h
+++ b/drivers/gpu/drm/logicvc/logicvc_regs.h
@@ -10,7 +10,7 @@
#ifndef _LOGICVC_REGS_H_
#define _LOGICVC_REGS_H_
-#define LOGICVC_DIMENSIONS_MAX (BIT(16) - 1)
+#define LOGICVC_DIMENSIONS_MAX USHRT_MAX
#define LOGICVC_HSYNC_FRONT_PORCH_REG 0x00
#define LOGICVC_HSYNC_REG 0x08
--
2.42.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] drm/logicvc: Avoid possible overflow in layer buffer setup variables
2023-10-25 13:09 [PATCH 1/2] drm/logicvc: Avoid possible overflow in layer buffer setup variables Paul Kocialkowski
2023-10-25 13:09 ` [PATCH 2/2] drm/logicvc: Define max dimensions from USHRT_MAX Paul Kocialkowski
@ 2023-11-21 14:29 ` Paul Kocialkowski
1 sibling, 0 replies; 3+ messages in thread
From: Paul Kocialkowski @ 2023-11-21 14:29 UTC (permalink / raw)
To: dri-devel, linux-kernel
Cc: David Airlie, Daniel Vetter, Maxime Ripard, Dan Carpenter
[-- Attachment #1: Type: text/plain, Size: 2132 bytes --]
Hi folks,
On Wed 25 Oct 23, 15:09, Paul Kocialkowski wrote:
> The buffer_sel, voffset and hoffset values are calculated from u32
> values and might overflow under certain conditions.
>
> Move them to u32 definitions instead of u8/u16 to avoid the issue.
Any chance to get a quick review on this simple fixup (and the next one)?
I can certainly push them myself after that.
Thanks,
Paul
> Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Fixes: efeeaefe9be5 ("drm: Add support for the LogiCVC display controller")
> ---
> drivers/gpu/drm/logicvc/logicvc_layer.c | 6 +++---
> drivers/gpu/drm/logicvc/logicvc_layer.h | 6 +++---
> 2 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/logicvc/logicvc_layer.c b/drivers/gpu/drm/logicvc/logicvc_layer.c
> index 464000aea765..eea22379d042 100644
> --- a/drivers/gpu/drm/logicvc/logicvc_layer.c
> +++ b/drivers/gpu/drm/logicvc/logicvc_layer.c
> @@ -268,9 +268,9 @@ int logicvc_layer_buffer_find_setup(struct logicvc_drm *logicvc,
> u32 layer_stride = layer_bytespp * logicvc->config.row_stride;
> u32 base_offset = layer->config.base_offset * layer_stride;
> u32 buffer_offset = layer->config.buffer_offset * layer_stride;
> - u8 buffer_sel = 0;
> - u16 voffset = 0;
> - u16 hoffset = 0;
> + u32 buffer_sel = 0;
> + u32 voffset = 0;
> + u32 hoffset = 0;
> phys_addr_t fb_addr;
> u32 fb_offset;
> u32 gap;
> diff --git a/drivers/gpu/drm/logicvc/logicvc_layer.h b/drivers/gpu/drm/logicvc/logicvc_layer.h
> index 4a4b02e9b819..a06feeda3abf 100644
> --- a/drivers/gpu/drm/logicvc/logicvc_layer.h
> +++ b/drivers/gpu/drm/logicvc/logicvc_layer.h
> @@ -18,9 +18,9 @@
> #define LOGICVC_LAYER_ALPHA_PIXEL 1
>
> struct logicvc_layer_buffer_setup {
> - u8 buffer_sel;
> - u16 voffset;
> - u16 hoffset;
> + u32 buffer_sel;
> + u32 voffset;
> + u32 hoffset;
> };
>
> struct logicvc_layer_config {
> --
> 2.42.0
>
--
Paul Kocialkowski, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-11-21 14:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-25 13:09 [PATCH 1/2] drm/logicvc: Avoid possible overflow in layer buffer setup variables Paul Kocialkowski
2023-10-25 13:09 ` [PATCH 2/2] drm/logicvc: Define max dimensions from USHRT_MAX Paul Kocialkowski
2023-11-21 14:29 ` [PATCH 1/2] drm/logicvc: Avoid possible overflow in layer buffer setup variables Paul Kocialkowski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®