Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5290754rwd; Mon, 12 Jun 2023 02:56:46 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4lV3JnDuHv4OtTNWx/Xj1OLCFU4+hmGZc0ROj5Q+JDcFq3noJoNDwQaFegNd3zw0tWk9qF X-Received: by 2002:a17:907:948f:b0:973:afe2:a01 with SMTP id dm15-20020a170907948f00b00973afe20a01mr7925715ejc.75.1686563805698; Mon, 12 Jun 2023 02:56:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686563805; cv=none; d=google.com; s=arc-20160816; b=PoiCPrNxMZhunDr0Xkka5+Oo2jaz+k0BP/yJ/CssVZsv1gfIzOqM9Bw3fl6tBBecq8 F25ZmDQhSqA59s+Wu1G8VZXI+ClZmwYIlTZort9cG8fMnGRLWCKhHAKI5sdYrrf3T+Xd GFasiuKl2vfP7cEdivG6QWWTOKOwSlyBhcB1hqGAcUavPzsAFtojZLGCbIFGM/kIqBKK egWSZi5JF8j15oMd8hnPgklgHxTndrWoaXTvuaSSqmJFvSaBKSs+HPyDI0T4V4AQjAMw WzNnaBaSSuRlNwTGPtaPfNQe5uccwgIpwZ0XtiVLc5IDyBpwyaCsNct2GPtfmNiiJ7A6 21wQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=29GQz4N1RuYE3YAahRNzsPBKqNihkCK7xJvEQHxVFP8=; b=xirf355EH/5SWU0lV7SGX/SvTzfMQANLfZWtAPtgVE7Syi2V8/MzZXpQ7CBKDN7sJW angIroQjUf9CJhyR0ENGP/GCw9fnT/7zRUlFOC3o8EESJS5klVkqJNsHeaYehRKKsdvp JwlxfsqeCW4Mmv29J0WyzgshvvmMul0yM6Xdrno3QSHIEZlHR796Zvt+VOZfwy97QDzm /5KRcYZS6nryDKaF+HWF7Td8Bq7SQyZDe0OyRGKxf8wwvER02YGsgZLuHJ8iL7Apfjq2 L2rJwek6LqjwowLvkhX2LEer4M/73oPnRnwVIAG/vSpGmLK87AtBEdWuuNrxEVcjXA8x nlKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=h5PXdrEX; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h21-20020a1709063b5500b00973c8a1a376si5163510ejf.248.2023.06.12.02.56.11; Mon, 12 Jun 2023 02:56:45 -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=@google.com header.s=20221208 header.b=h5PXdrEX; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231518AbjFLJuj (ORCPT + 99 others); Mon, 12 Jun 2023 05:50:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231321AbjFLJuE (ORCPT ); Mon, 12 Jun 2023 05:50:04 -0400 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49C8159E6 for ; Mon, 12 Jun 2023 02:35:23 -0700 (PDT) Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1b1fdab9d68so218135ad.0 for ; Mon, 12 Jun 2023 02:35:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686562514; x=1689154514; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=29GQz4N1RuYE3YAahRNzsPBKqNihkCK7xJvEQHxVFP8=; b=h5PXdrEXv3zRjkg/o1XhxWAB8orJ+9cw1KEkb5ZfVk54k7CDl58HC3ZT13QTFKKljA 9eyR3GgiTntD4bEDoiL8LfajNUDevgkS5amQXFd8KlyStubkhdnitkm9rN0DJ+/l+qMc gKAhq08hcqqYwpLb6pNUFFLhk2ZIEmrh9c3G29zVIh04p+8SW9mHw4JP7I7rOgJlxJf4 CRfJhAqu9RlgloFE9x0RLhD7vOWOaqBSQef6WHA6qivk6f92tXVvTTXa24d7A+yEg84G dBgYgR/IR6jiKQKRFqwB18u84Cf5RoMggL0CNWTi9cCY8ytvVP/ylbxOCFII3gTFDyEq T3zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686562514; x=1689154514; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=29GQz4N1RuYE3YAahRNzsPBKqNihkCK7xJvEQHxVFP8=; b=ixcRiKR30WreEZSm/oP0bbAtJtM7MvFJ7r2q92NkE5xgOKW9b1kTJFpSl6jc9rdIO+ Hjazt4Hj2BXe/2Dd2UkXmFhI3q/GjKJi08y8BVaW/XjU9z6HarIsK+GAAiOFeu8dFFRA s36JUwIhG7JU3SSB2uz9XOIdsl+cuuGL/KxKkQ/GMSZGQ3Xnv+M2Wb/fPm05WawkC//U IjAsm4bOnD7F38V2bKYW+QmP3/eQ8vxkEPodlRtwILVjFs9DBipSps9T/N6Lq5PobN0w AbeZJvtAkjziXHE0fUyEMr+9yRTelb+H5O9SieoOYSehvV8lHTkz2OX+yTBk4+9APaLc +4Fg== X-Gm-Message-State: AC+VfDwLz8wlbkf0UrdnkTAjzMjFV6Yp3QIOV/klzk00C9cwD21i7FVC ufOsQYlOwMKOxQDAtj1wws3l5YSEhUWTmQoymRwhEg== X-Received: by 2002:a17:902:e849:b0:1b1:d1fe:e73 with SMTP id t9-20020a170902e84900b001b1d1fe0e73mr229259plg.8.1686562514065; Mon, 12 Jun 2023 02:35:14 -0700 (PDT) MIME-Version: 1.0 References: <20230609131355.71130-1-jordyzomer@google.com> <20230609131355.71130-2-jordyzomer@google.com> In-Reply-To: From: Jordy Zomer Date: Mon, 12 Jun 2023 11:35:03 +0200 Message-ID: Subject: Re: [PATCH 1/1] cdrom: Fix spectre-v1 gadget To: Phillip Potter Cc: linux-kernel@vger.kernel.org, pawan.kumar.gupta@linux.intel.com, linux-block@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 Thanks both! I assumed array_index_mask_nospec was the same as array_index_nospec. I'll send a V2 your way soon :) On Sat, Jun 10, 2023 at 9:10=E2=80=AFPM Phillip Potter wrote: > > 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 >=3D cdi->capacity) > > return -EINVAL; > > > > + arg =3D array_index_mask_nospec(arg, cdi->capacity); > > + > > info =3D kmalloc(sizeof(*info), GFP_KERNEL); > > if (!info) > > return -ENOMEM; > > -- > > 2.41.0.162.gfafddb0af9-goog > > > > Hi Jordy, > > Thanks for the patch, much appreciated. Sadly, as Pawan has already > pointed out, array_index_mask_nospec actually changes the behaviour of > this function, such that 'arg' would no longer be an array index. > > In addition, it seems to have triggered the kernel test robot with an > alpha build error. > > Regards, > Phil