From: Jani Nikula <jani.nikula@linux.intel.com>
To: Andi Shyti <andi.shyti@kernel.org>,
Krzysztof Karas <krzysztof.karas@intel.com>
Cc: intel-gfx@lists.freedesktop.org,
Andi Shyti <andi.shyti@linux.intel.com>,
Sebastian Brzezinka <sebastian.brzezinka@intel.com>,
Krzysztof Niemiec <krzysztof.niemiec@intel.com>
Subject: Re: [PATCH v3 1/5] drm: Avoid suspicious operations in drm_fb_dma_get_gem_addr()
Date: Tue, 16 Sep 2025 13:25:53 +0300 [thread overview]
Message-ID: <7c34d67eebe9e43aa9150d394b16d51b0b6d01d9@intel.com> (raw)
In-Reply-To: <37gdqefdlckaqa2kwwcu2wcwfq6vyrxiz43tc2tgornr357ok4@w6vwdtf7p44y>
On Tue, 16 Sep 2025, Andi Shyti <andi.shyti@kernel.org> wrote:
> Hi Krzysztof,
>
> On Tue, Sep 16, 2025 at 06:33:00AM +0000, Krzysztof Karas wrote:
>> There are two unsafe scenarios in that function:
>> 1) drm_format_info_block_width/height() may return 0 and cause
>> division by 0 down the line. Return early if any of these values
>> are 0.
>> 2) dma_addr calculations are carried out using 32-bit
>> arithmetic, which could cause a truncation of the values
>> before they are extended to 64 bits. Cast one of the operands
>> to dma_addr_t, so 64-bit arithmetic is used.
>>
>> Fixes: 8c30eecc6769 ("drm/gem: rename struct drm_gem_dma_object.{paddr => dma_addr}")
>
> This doesn't need the Fixes tag as it's a very unlikely thing to
> happen.
>
>> Cc: Danilo Krummrich <dakr@redhat.com>
>> Cc: <stable@vger.kernel.org> # v6.1+
>> Reviewed-by: Sebastian Brzezinka <sebastian.brzezinka@intel.com>
>> Signed-off-by: Krzysztof Karas <krzysztof.karas@intel.com>
>> ---
>> drivers/gpu/drm/drm_fb_dma_helper.c | 7 +++++--
>> 1 file changed, 5 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/drm_fb_dma_helper.c b/drivers/gpu/drm/drm_fb_dma_helper.c
>> index fd71969d2fb1..00aaad648a33 100644
>> --- a/drivers/gpu/drm/drm_fb_dma_helper.c
>> +++ b/drivers/gpu/drm/drm_fb_dma_helper.c
>> @@ -85,6 +85,9 @@ dma_addr_t drm_fb_dma_get_gem_addr(struct drm_framebuffer *fb,
>> u32 block_start_y;
>> u32 num_hblocks;
>>
>> + if (block_w == 0 || block_h == 0)
>> + return 0;
>
> This can't go unnoticed, you make the analyzer happy but you
> create bigger issues by silently returning '0'.
>
> If you are really concerned you can place here a BUG_ON or
> WARN_ON_ONCE.
Never BUG* though.
>
> Andi
>
>> +
>> obj = drm_fb_dma_get_gem_obj(fb, plane);
>> if (!obj)
>> return 0;
--
Jani Nikula, Intel
next prev parent reply other threads:[~2025-09-16 10:26 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-16 6:32 [PATCH v3 0/5] drm: Miscellaneous fixes in drm code Krzysztof Karas
2025-09-16 6:33 ` [PATCH v3 1/5] drm: Avoid suspicious operations in drm_fb_dma_get_gem_addr() Krzysztof Karas
2025-09-16 10:20 ` Andi Shyti
2025-09-16 10:25 ` Jani Nikula [this message]
2025-09-16 6:33 ` [PATCH v3 2/5] drm: Do not attempt to round_up() zeros in drm_suballoc_try_alloc() Krzysztof Karas
2025-09-16 10:23 ` Andi Shyti
2025-09-16 6:34 ` [PATCH v3 3/5] drm: Avoid undefined behavior on u16 multiplication in drm_vram_helper_mode_valid_internal() Krzysztof Karas
2025-09-16 10:37 ` Andi Shyti
2025-09-16 6:34 ` [PATCH v3 4/5] drm: Avoid undefined behavior on u16 multiplication in mipi_dbi_dev_init() Krzysztof Karas
2025-09-16 6:35 ` [PATCH v3 5/5] drm: Avoid undefined behavior on u16 multiplication in drm_crtc_vblank_helper_get_vblank_timestamp_internal() Krzysztof Karas
2025-09-16 7:41 ` ✓ i915.CI.BAT: success for drm: Miscellaneous fixes in drm code (rev3) Patchwork
2025-09-16 9:48 ` ✓ i915.CI.Full: " Patchwork
2025-09-16 10:41 ` [PATCH v3 0/5] drm: Miscellaneous fixes in drm code Andi Shyti
2025-09-17 6:31 ` Krzysztof Karas
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=7c34d67eebe9e43aa9150d394b16d51b0b6d01d9@intel.com \
--to=jani.nikula@linux.intel.com \
--cc=andi.shyti@kernel.org \
--cc=andi.shyti@linux.intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=krzysztof.karas@intel.com \
--cc=krzysztof.niemiec@intel.com \
--cc=sebastian.brzezinka@intel.com \
/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