From: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
To: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Cc: David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch>,
Maxime Ripard <mripard@kernel.org>,
Dan Carpenter <dan.carpenter@oracle.com>
Subject: Re: [PATCH 1/2] drm/logicvc: Avoid possible overflow in layer buffer setup variables
Date: Tue, 21 Nov 2023 15:29:14 +0100 [thread overview]
Message-ID: <ZVy-uuMnNktDnepS@aptenodytes> (raw)
In-Reply-To: <20231025130946.119957-1-paul.kocialkowski@bootlin.com>
[-- 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 --]
prev parent reply other threads:[~2023-11-21 14:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Paul Kocialkowski [this message]
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=ZVy-uuMnNktDnepS@aptenodytes \
--to=paul.kocialkowski@bootlin.com \
--cc=airlied@gmail.com \
--cc=dan.carpenter@oracle.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mripard@kernel.org \
/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
all inboxes | Powered by JetHome®