Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2757162rwd; Fri, 9 Jun 2023 16:55:48 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ616ilwXyztHXVvXgkvhupEzueqAqrnB2qRS6eEPBPHDgHGtvkkJBv04FOu55Z28hrBo67l X-Received: by 2002:a05:6a20:918f:b0:10b:9dc1:c5e5 with SMTP id v15-20020a056a20918f00b0010b9dc1c5e5mr2379298pzd.34.1686354948597; Fri, 09 Jun 2023 16:55:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686354948; cv=none; d=google.com; s=arc-20160816; b=z3zx8KTu8+MVWrVwP95hAHHGBqdiBO2FcDlTvb2ijSDU8CHnqoWu8s7Me3cYZMlcml Gb8vi/sj6vW0fAtyPRFopHU5qWEF3cKr5wJK9Ld3cn+F4oCjko6eXz13PIa7htouZrEr 9KhsqOVDRIa7Qc5pLNDasSEmouVH1mThFy3uA8ebUo6W5G4BbulRlsJ5FcX9GHiL/nYx 4MTbC7Gw9yUpuJboJxBFdLUXZ8RPMTuGrPuXpQNYAPy7LD7bHTHvDhlu6BO7kxoCXkTw 4C+oQ5nUA9eHcqzkA6RyRcW1rFIwpMfs08T4zZ8PJzGrBFCAzFYEzdanYQBKFa6ieJMM pYEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=U+J2bE6o/je3gMFzEuEwPa6ODGvPwRTrAflzc3jkG1U=; b=mrPveLqILq3GjzmFUD6ZHNMp64+Le7zoXDPGoO+MAL2QrJGPkgzuT50FARZyALDgYw udkJqfmO4Pua+YtLUeiQWdmB/nrMS2f+eFDesUJURh84cJfMOLcrV1NSg7c2uGYpCJoc DH0XY509Ylb+PgIfkdj4MILQ5QPRwYLEMsuq6+ZosEkqVbsrECnsX7L/q+20ScXMmgea 4W1JRgWwPQRANLwNZLLDNeQwqxdo/cbiGUuinj2943a/OD5y/EPobxTA1N6e1AVu+oYr gXSdsMP8GmMZLXVWI3f7rkljWN2GNFkaSZ4Wkm426SBEeHFxlFB4Y6xqoiel8bYqtNln Aaow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=J6vKapJq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id az9-20020a056a02004900b0053fb78a9abesi3407165pgb.411.2023.06.09.16.55.35; Fri, 09 Jun 2023 16:55:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=J6vKapJq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229854AbjFIXq1 (ORCPT + 99 others); Fri, 9 Jun 2023 19:46:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229679AbjFIXqZ (ORCPT ); Fri, 9 Jun 2023 19:46:25 -0400 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F356B30FE for ; Fri, 9 Jun 2023 16:46:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686354385; x=1717890385; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=4HsSE/uhcsnZXiarm4S5bjp5qiVOuFJwIva9sHYvHFk=; b=J6vKapJqP0mf44k4y1N4r6URYIAN7byHLTf/YLfNpWahnxIxbWk0iISu GD53dfuyQ+d8QKQxiFas6zZK+QAQkEN90AsXch8Svf1CTjQgis7pSaBEH oCMCH7z9t6xJdTbH0nlUCBVHehWwo24hLyjsx07AVzbQasXAhClJo4+nG Cy9Mhde49l5qikNbbUHDTPQ99AYxR5Z6cA1merntWjo70dsqBHFBEulvt bqpJYd+DMv1bQeabQeCt85s5lHhoYGMhTKQCsrCRVghgxEfy/02TigaAr xLmqHWWpO9yQzg6oAP51LadUy86W/WKMJ3FUsgaTmEXgsi2+EtkzPW/k9 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10736"; a="342384659" X-IronPort-AV: E=Sophos;i="6.00,230,1681196400"; d="scan'208";a="342384659" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2023 16:46:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10736"; a="704715256" X-IronPort-AV: E=Sophos;i="6.00,230,1681196400"; d="scan'208";a="704715256" Received: from cdhirema-mobl5.amr.corp.intel.com (HELO desk) ([10.251.26.88]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2023 16:46:24 -0700 Date: Fri, 9 Jun 2023 16:46:19 -0700 From: Pawan Gupta To: Jordy Zomer Cc: linux-kernel@vger.kernel.org, phil@philpotter.co.uk Subject: Re: [PATCH 1/1] cdrom: Fix spectre-v1 gadget Message-ID: <20230609234619.3bkmlgpxzaetua4d@desk> References: <20230609131355.71130-1-jordyzomer@google.com> <20230609131355.71130-2-jordyzomer@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230609131355.71130-2-jordyzomer@google.com> X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 09, 2023 at 01:13:55PM +0000, Jordy Zomer wrote: > This patch fixes a spectre-v1 gadget in cdrom. > The gadget could be triggered by, > speculatviely bypassing the cdi->capacity check. > > Signed-off-by: Jordy Zomer > --- > drivers/cdrom/cdrom.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c > index 416f723a2dbb..3c349bc0a269 100644 > --- a/drivers/cdrom/cdrom.c > +++ b/drivers/cdrom/cdrom.c > @@ -233,6 +233,7 @@ > > -------------------------------------------------------------------------*/ > > +#include "asm/barrier.h" > #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt > > #define REVISION "Revision: 3.20" > @@ -2329,6 +2330,8 @@ static int cdrom_ioctl_media_changed(struct cdrom_device_info *cdi, > if (arg >= cdi->capacity) > return -EINVAL; > > + arg = array_index_mask_nospec(arg, cdi->capacity); array_index_nospec() is the correct function to use. The above generates a mask and not the original value. Also it is effective when the second argument is a build time constant. If thats not possible and this function is not called very often barrier_nospec() is also an option.