[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CACRpkdZOyK=CSG2C64ELXXiieHUd_BaHBBR=iLrG6moYDUTC4w@mail.gmail.com>
Date: Thu, 2 May 2024 10:15:08 +0200
From: Linus Walleij <linus.walleij@...aro.org>
To: Douglas Anderson <dianders@...omium.org>
Cc: dri-devel@...ts.freedesktop.org, Jani Nikula <jani.nikula@...ux.intel.com>,
Dmitry Baryshkov <dmitry.baryshkov@...aro.org>,
Cong Yang <yangcong5@...qin.corp-partner.google.com>, Hsin-Yi Wang <hsinyi@...gle.com>,
Brian Norris <briannorris@...omium.org>, Sam Ravnborg <sam@...nborg.org>,
Neil Armstrong <neil.armstrong@...aro.org>, Javier Martinez Canillas <javierm@...hat.com>,
Joel Selvaraj <jo@...amily.in>, lvzhaoxiong@...qin.corp-partner.google.com,
Daniel Vetter <daniel@...ll.ch>, David Airlie <airlied@...il.com>,
Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>, Maxime Ripard <mripard@...nel.org>,
Thomas Zimmermann <tzimmermann@...e.de>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3 1/9] drm/mipi-dsi: Fix theoretical int overflow in mipi_dsi_dcs_write_seq()
On Wed, May 1, 2024 at 5:43 PM Douglas Anderson <dianders@...omium.org> wrote:
> The mipi_dsi_dcs_write_seq() macro makes a call to
> mipi_dsi_dcs_write_buffer() which returns a type ssize_t. The macro
> then stores it in an int and checks to see if it's negative. This
> could theoretically be a problem if "ssize_t" is larger than "int".
>
> To see the issue, imagine that "ssize_t" is 32-bits and "int" is
> 16-bits, you could see a problem if there was some code out there that
> looked like:
>
> mipi_dsi_dcs_write_seq(dsi, cmd, <32767 bytes as arguments>);
>
> ...since we'd get back that 32768 bytes were transferred and 32768
> stored in a 16-bit int would look negative.
>
> Though there are no callsites where we'd actually hit this (even if
> "int" was only 16-bit), it's cleaner to make the types match so let's
> fix it.
>
> Fixes: 2a9e9daf7523 ("drm/mipi-dsi: Introduce mipi_dsi_dcs_write_seq macro")
> Signed-off-by: Douglas Anderson <dianders@...omium.org>
All right! Nice work.
Reviewed-by: Linus Walleij <linus.walleij@...aro.org>
Yours,
Linus Walleij
Powered by blists - more mailing lists