linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Koenig, Christian" <Christian.Koenig@amd.com>
To: Wenwen Wang <wang6495@umn.edu>
Cc: Kangjie Lu <kjlu@umn.edu>,
	"Deucher, Alexander" <Alexander.Deucher@amd.com>,
	"Zhou, David(ChunMing)" <David1.Zhou@amd.com>,
	David Airlie <airlied@linux.ie>,
	"open list:RADEON and AMDGPU DRM DRIVERS" 
	<amd-gfx@lists.freedesktop.org>,
	"open list:DRM DRIVERS" <dri-devel@lists.freedesktop.org>,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] drm/radeon: fix a missing-check bug
Date: Fri, 19 Oct 2018 07:02:16 +0000	[thread overview]
Message-ID: <90c22763-fdba-0415-c570-ef8e85bf5889@amd.com> (raw)
In-Reply-To: <1539882809-7189-1-git-send-email-wang6495@umn.edu>

Am 18.10.18 um 19:13 schrieb Wenwen Wang:
> In radeon_read_bios(), the bios rom is firstly mapped to the IO memory
> region 'bios' through pci_map_rom(). Then the first two bytes of 'bios' are
> copied to 'val1' and 'val2' respectively through readb(). After that,
> 'val1' and 'val2' are checked to see whether they have expected values,
> i.e., 0x55 and 0xaa, respectively. If yes, the whole data in 'bios' is then
> copied to 'rdev->bios' through memcpy_fromio(). Obviously, the first two
> bytes in 'bios' are copied twice. More importantly, no check is enforced on
> the first two bytes of 'rdev->bios' after memcpy_fromio(). Given that the
> IO memory region can also be accessed by the device, it is possible that a
> malicious device can race to modify these two bytes between the two copies
> and thus after memcpy_fromio(), the first two bytes in 'rdev->bios' can
> have unexpected values.  This can cause undefined behavior of the kernel
> and introduce potential security risk, if the device can be controlled by
> attackers.
>
> This patch rewrites the first two bytes of 'rdev->bios' after
> memcpy_fromio() with expected values. Through this way, the above issue can
> be avoided.

Well NAK, that doesn't make any sense to me.

First of all we don't map VRAM, but rather the ROM which is a read only 
flash. Writing to the flash is not supported through the BAR as far as I 
know.

Then we check the first two bytes to make sure that the ROM is correctly 
mapped and not to prevent any malicious attacks.

Regards,
Christian.

>
> Signed-off-by: Wenwen Wang <wang6495@umn.edu>
> ---
>   drivers/gpu/drm/radeon/radeon_bios.c | 2 ++
>   1 file changed, 2 insertions(+)
>
> diff --git a/drivers/gpu/drm/radeon/radeon_bios.c b/drivers/gpu/drm/radeon/radeon_bios.c
> index 04c0ed4..f336719 100644
> --- a/drivers/gpu/drm/radeon/radeon_bios.c
> +++ b/drivers/gpu/drm/radeon/radeon_bios.c
> @@ -98,6 +98,8 @@ static bool radeon_read_bios(struct radeon_device *rdev)
>   		return false;
>   	}
>   	memcpy_fromio(rdev->bios, bios, size);
> +	rdev->bios[0] = val1;
> +	rdev->bios[1] = val2;
>   	pci_unmap_rom(rdev->pdev, bios);
>   	return true;
>   }


  reply	other threads:[~2018-10-19  7:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-18 17:13 [PATCH] drm/radeon: fix a missing-check bug Wenwen Wang
2018-10-19  7:02 ` Koenig, Christian [this message]
  -- strict thread matches above, loose matches on Subject: below --
2018-10-18 16:42 Wenwen Wang

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=90c22763-fdba-0415-c570-ef8e85bf5889@amd.com \
    --to=christian.koenig@amd.com \
    --cc=Alexander.Deucher@amd.com \
    --cc=David1.Zhou@amd.com \
    --cc=airlied@linux.ie \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kjlu@umn.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=wang6495@umn.edu \
    /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 NNTP newsgroup(s).