Nouveau Archive mirror
 help / color / mirror / Atom feed
From: Danilo Krummrich <dakr@redhat.com>
To: Mikhail Kobuk <m.kobuk@ispras.ru>
Cc: Lyude Paul <lyude@redhat.com>, David Airlie <airlied@gmail.com>,
	Daniel Vetter <daniel@ffwll.ch>, Ben Skeggs <bskeggs@redhat.com>,
	Francisco Jerez <currojerez@riseup.net>,
	dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org,
	linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org,
	Fedor Pchelkin <pchelkin@ispras.ru>,
	Alexey Khoroshilov <khoroshilov@ispras.ru>,
	Karol Herbst <kherbst@redhat.com>
Subject: Re: [PATCH v2] drm: nv04: Fix out of bounds access
Date: Mon, 15 Apr 2024 11:03:24 +0200	[thread overview]
Message-ID: <ad01f30e-4944-44f6-9efa-8e04726d1486@redhat.com> (raw)
In-Reply-To: <20240411110854.16701-1-m.kobuk@ispras.ru>

On 4/11/24 13:08, Mikhail Kobuk wrote:
> When Output Resource (dcb->or) value is assigned in
> fabricate_dcb_output(), there may be out of bounds access to
> dac_users array in case dcb->or is zero because ffs(dcb->or) is
> used as index there.
> The 'or' argument of fabricate_dcb_output() must be interpreted as a
> number of bit to set, not value.
> 
> Utilize macros from 'enum nouveau_or' in calls instead of hardcoding.
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> 
> Fixes: 2e5702aff395 ("drm/nouveau: fabricate DCB encoder table for iMac G4")
> Fixes: 670820c0e6a9 ("drm/nouveau: Workaround incorrect DCB entry on a GeForce3 Ti 200.")
> Signed-off-by: Mikhail Kobuk <m.kobuk@ispras.ru>

Applied to drm-misc-fixes, thanks!

> ---
> Changes in v2:
> - Instead of checking ffs(dcb->or), adjust function calls to match
>    argument semantics
> - Link to v1: https://lore.kernel.org/all/20240331064552.6112-1-m.kobuk@ispras.ru/
> 
>   drivers/gpu/drm/nouveau/nouveau_bios.c | 13 +++++++------
>   1 file changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
> index 479effcf607e..79cfab53f80e 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_bios.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
> @@ -23,6 +23,7 @@
>    */
>   
>   #include "nouveau_drv.h"
> +#include "nouveau_bios.h"
>   #include "nouveau_reg.h"
>   #include "dispnv04/hw.h"
>   #include "nouveau_encoder.h"
> @@ -1677,7 +1678,7 @@ apply_dcb_encoder_quirks(struct drm_device *dev, int idx, u32 *conn, u32 *conf)
>   	 */
>   	if (nv_match_device(dev, 0x0201, 0x1462, 0x8851)) {
>   		if (*conn == 0xf2005014 && *conf == 0xffffffff) {
> -			fabricate_dcb_output(dcb, DCB_OUTPUT_TMDS, 1, 1, 1);
> +			fabricate_dcb_output(dcb, DCB_OUTPUT_TMDS, 1, 1, DCB_OUTPUT_B);
>   			return false;
>   		}
>   	}
> @@ -1763,26 +1764,26 @@ fabricate_dcb_encoder_table(struct drm_device *dev, struct nvbios *bios)
>   #ifdef __powerpc__
>   	/* Apple iMac G4 NV17 */
>   	if (of_machine_is_compatible("PowerMac4,5")) {
> -		fabricate_dcb_output(dcb, DCB_OUTPUT_TMDS, 0, all_heads, 1);
> -		fabricate_dcb_output(dcb, DCB_OUTPUT_ANALOG, 1, all_heads, 2);
> +		fabricate_dcb_output(dcb, DCB_OUTPUT_TMDS, 0, all_heads, DCB_OUTPUT_B);
> +		fabricate_dcb_output(dcb, DCB_OUTPUT_ANALOG, 1, all_heads, DCB_OUTPUT_C);
>   		return;
>   	}
>   #endif
>   
>   	/* Make up some sane defaults */
>   	fabricate_dcb_output(dcb, DCB_OUTPUT_ANALOG,
> -			     bios->legacy.i2c_indices.crt, 1, 1);
> +			     bios->legacy.i2c_indices.crt, 1, DCB_OUTPUT_B);
>   
>   	if (nv04_tv_identify(dev, bios->legacy.i2c_indices.tv) >= 0)
>   		fabricate_dcb_output(dcb, DCB_OUTPUT_TV,
>   				     bios->legacy.i2c_indices.tv,
> -				     all_heads, 0);
> +				     all_heads, DCB_OUTPUT_A);
>   
>   	else if (bios->tmds.output0_script_ptr ||
>   		 bios->tmds.output1_script_ptr)
>   		fabricate_dcb_output(dcb, DCB_OUTPUT_TMDS,
>   				     bios->legacy.i2c_indices.panel,
> -				     all_heads, 1);
> +				     all_heads, DCB_OUTPUT_B);
>   }
>   
>   static int


      reply	other threads:[~2024-04-15  9:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-11 11:08 [PATCH v2] drm: nv04: Fix out of bounds access Mikhail Kobuk
2024-04-15  9:03 ` Danilo Krummrich [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=ad01f30e-4944-44f6-9efa-8e04726d1486@redhat.com \
    --to=dakr@redhat.com \
    --cc=airlied@gmail.com \
    --cc=bskeggs@redhat.com \
    --cc=currojerez@riseup.net \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kherbst@redhat.com \
    --cc=khoroshilov@ispras.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lvc-project@linuxtesting.org \
    --cc=lyude@redhat.com \
    --cc=m.kobuk@ispras.ru \
    --cc=nouveau@lists.freedesktop.org \
    --cc=pchelkin@ispras.ru \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).