From: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
To: Phillip Potter <phil@philpotter.co.uk>
Cc: linux-kernel@vger.kernel.org, jordyzomer@google.com,
linux-block@vger.kernel.org
Subject: Re: [PATCH v2 1/1] cdrom: Fix spectre-v1 gadget
Date: Thu, 15 Jun 2023 20:14:47 -0700 [thread overview]
Message-ID: <20230616031447.yslq6ep7lxe6sjv4@desk> (raw)
In-Reply-To: <ZIufZn+reW0rza1H@equinox>
On Fri, Jun 16, 2023 at 12:31:50AM +0100, Phillip Potter wrote:
> I've now looked at this. It is possible for cdi->capacity to be > 1, as
> it is set via get_capabilities() -> cdrom_number_of_slots(), if the
> device is an individual or cartridge changer.
Ohk. Is there an upper limit to cdi->capacity? If not, we are left with
barrier_nospec().
> Therefore, I think using CDI_MAX_CAPACITY of 1 is not the correct
> approach. Jordy's V2 patch is fine therefore, but perhaps using
> array_index_nospec() with cdi->capacity is still better than a
> do/while loop from a performance perspective, given it would be cached
> etc. at that point, so possibly quicker. Thoughts? (I'm no expert on
> spectre-v1 I'll admit).
array_index_nospec() can only clip the arg correctly if the upper bound
is correct. Problem with array_index_nospec(arg, cdi->capacity) is
cdi->capacity is not a constant, so it suffers from the same problem as
arg i.e. cdi->capacity could also be speculated. Although having to
control 2 loads makes the attack difficult, but does not rules out
completely.
barrier_nospec() makes the CPU wait for all previous loads to retire
before executing following instructions speculatively. This causes the
conditional branch to resolve correctly. I hope this does not fall into
a hotpath.
next prev parent reply other threads:[~2023-06-16 3:15 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20230612110040.849318-1-jordyzomer@google.com>
[not found] ` <20230612110040.849318-2-jordyzomer@google.com>
2023-06-15 8:12 ` [PATCH v2 1/1] cdrom: Fix spectre-v1 gadget Phillip Potter
[not found] ` <20230615163125.td3aodpfwth5n4mc@desk>
2023-06-15 23:31 ` Phillip Potter
2023-06-16 3:14 ` Pawan Gupta [this message]
2023-06-16 9:39 ` Jordy Zomer
2023-06-16 12:59 ` Randy Dunlap
2023-06-17 9:40 ` Phillip Potter
2023-06-17 9:37 ` Phillip Potter
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=20230616031447.yslq6ep7lxe6sjv4@desk \
--to=pawan.kumar.gupta@linux.intel.com \
--cc=jordyzomer@google.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=phil@philpotter.co.uk \
/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