mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: "Alex Deucher" <alexdeucher@gmail.com>,
	"Michel Dänzer" <michel@daenzer.net>
Cc: "Gustavo A. R. Silva" <gustavo@embeddedor.com>,
	"David (ChunMing) Zhou" <David1.Zhou@amd.com>,
	David Airlie <airlied@linux.ie>,
	LKML <linux-kernel@vger.kernel.org>,
	amd-gfx list <amd-gfx@lists.freedesktop.org>,
	Maling list - DRI developers  <dri-devel@lists.freedesktop.org>,
	Alex Deucher <alexander.deucher@amd.com>
Subject: Re: [PATCH] drm/amdgpu/pm: Fix potential Spectre v1
Date: Tue, 31 Jul 2018 08:46:10 +0200	[thread overview]
Message-ID: <658cd654-be3e-659a-20a7-f33034c231ce@amd.com> (raw)
In-Reply-To: <CADnq5_MKR=qYCX-m4wKA47F0EejNcUmS7jsnY9=1nyKKEQhqJQ@mail.gmail.com>

Am 30.07.2018 um 22:14 schrieb Alex Deucher:
> On Mon, Jul 30, 2018 at 5:55 AM, Michel Dänzer <michel@daenzer.net> wrote:
>> On 2018-07-24 10:53 PM, Alex Deucher wrote:
>>> On Mon, Jul 23, 2018 at 12:32 PM, Gustavo A. R. Silva
>>> <gustavo@embeddedor.com> wrote:
>>>> idx can be indirectly controlled by user-space, hence leading to a
>>>> potential exploitation of the Spectre variant 1 vulnerability.
>>>>
>>>> This issue was detected with the help of Smatch:
>>>>
>>>> drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c:408 amdgpu_set_pp_force_state()
>>>> warn: potential spectre issue 'data.states'
>>>>
>>>> Fix this by sanitizing idx before using it to index data.states
>>> Is this actually necessary?  We already check that idx is valid a few
>>> lines before:
>>>          if (ret || idx >= ARRAY_SIZE(data.states)) {
>>>                          count = -EINVAL;
>>>                          goto fail;
>>>                  }
>> A Spectre attack would be based on idx ending up too large, but the CPU
>> speculatively executing the following code assuming idx <
>> ARRAY_SIZE(data.states), and extracting information from the incorrectly
>> speculated code via side channels.
>>
>> I'm not sure if that's actually possible in this case, but better safe
>> than sorry?
> Yeah, I'm not sure.  I guess this can't hurt.

Well is idx actually controlable by userspace in an IOCTL? I guess the 
answer is no.

On the other hand the array_index_nospec() macro makes the overhead 
absolute negligible.

So I agree that we should be better safe than sorry.

Christian.

>
> Alex


  reply	other threads:[~2018-07-31  6:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-23 16:32 Gustavo A. R. Silva
2018-07-24 20:53 ` Alex Deucher
2018-07-30  9:55   ` Michel Dänzer
2018-07-30 20:14     ` Alex Deucher
2018-07-31  6:46       ` Christian König [this message]
2018-07-31 21:29         ` Alex Deucher

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=658cd654-be3e-659a-20a7-f33034c231ce@amd.com \
    --to=christian.koenig@amd.com \
    --cc=David1.Zhou@amd.com \
    --cc=airlied@linux.ie \
    --cc=alexander.deucher@amd.com \
    --cc=alexdeucher@gmail.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gustavo@embeddedor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michel@daenzer.net \
    /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®