[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241018005233.styuaj7eyn7b6nux@treble>
Date: Thu, 17 Oct 2024 17:52:33 -0700
From: Josh Poimboeuf <jpoimboe@...nel.org>
To: Jens Axboe <axboe@...nel.dk>
Cc: Phillip Potter <phil@...lpotter.co.uk>, linux-kernel@...r.kernel.org,
Jordy Zomer <jordyzomer@...gle.com>
Subject: Re: [PATCH] cdrom: Avoid barrier_nospec() in
cdrom_ioctl_media_changed()
On Thu, Oct 17, 2024 at 06:33:24PM -0600, Jens Axboe wrote:
> On 10/17/24 4:09 PM, Josh Poimboeuf wrote:
> > The barrier_nospec() after the array bounds check is overkill and
> > painfully slow for arches which implement it.
> >
> > Furthermore, most arches don't implement it, so they remain exposed to
> > Spectre v1 (which can affect pretty much any CPU with branch
> > prediction).
> >
> > Instead, clamp the user pointer to a valid range so it's guaranteed to
> > be a valid array index even when the bounds check mispredicts.
>
> It's a cdrom, and media change detection to be more specific. I really
> don't think anyone would care about performance here, it's not even
> a hot path for a cdrom driver. That said, I don't disagree with
> the change, just don't think it'll make one iota of difference
> in the real world.
Fair, though it's also about hardening as barrier_nospec() is only
implemented by x86 and powerpc (see 2nd paragraph). Most/all arches are
affected by Spectre v1.
--
Josh
Powered by blists - more mailing lists