Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp4309467rdh; Tue, 28 Nov 2023 19:04:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IEK2AkE2HxDvFA+WwkC17EDX6WiiXdq8MNX7r7pAzAKEOZe64aQVvYKQ0xMla54gkmHXgno X-Received: by 2002:a05:6a20:4415:b0:187:b16f:e779 with SMTP id ce21-20020a056a20441500b00187b16fe779mr20271910pzb.5.1701227048683; Tue, 28 Nov 2023 19:04:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701227048; cv=none; d=google.com; s=arc-20160816; b=IFDutTQ6UQ2BO5qK/RQ2nGLuVBlVZ/ZEF9SVMxodupxkmp1SRi5HnBoocvXqUH7bzo ONm7zVQx3mlF6bjHWQ8P8gHxeZKkm5yqNi3PERPMGuQgGfwFJir+z3GCyHg3LiuYEEPQ cFrrWBIN1ZSagrZV2Lh1tjtyTZXeyF+ua3qCtrDwgvVi2LRlbSgP0808FM5cRtoK5AiA oix2wXaU58tRdgaMqSkA1+6abBlY8Mkfbj351MxtgmndHQaQtoayIbRhm89cI0xz8stv NYOSdnpikrEaPJ7Yj2xr4GqWhlhiy/Q8fwTBhSaj1Gm6rDjo/LhAmkM1N0CM/C38c7OE 67lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:dlp-filter:cms-type :content-transfer-encoding:mime-version:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=1xxcviCzwplVYwof4YqPkHybqVAQfpPegoq5Qwuh5DM=; fh=eqB4vt6MWNHj4rshyZATJPfI6+c/hdITvrIvZ22YvBM=; b=UdlJ25Uia/un4/kKgjSxv7+5ZmxwxUl3BV5vJXzRFBvevuUl6WEnMtdWPQ/fSkAToM /SAkjOWPgCNBkQ+av6XW8l5UAHbB89+PLBgNs68APbYb7K11a4je4qICGTYSFIy9k80b WWXcExitodhG86p8Ff/udWnR+7kLwOIZrIn11+CqPXL533OPh30ndRWh3AMqzvhlawD2 0KLrYZ52BOlWezeaIBNbsty+LC9PSTO4XlUR0AxQOj0UZfOCdfOuaYx7b8dl7wkCJo/I gVyDmDBpPPx9cY2KTQlDecSbMzWZULlP4AUlnzLS+0up+y6xE2uPHMjN40ry4RKS8bCi OQww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b="DpT/q3xM"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id k14-20020a17090a404e00b002773d013d02si385113pjg.140.2023.11.28.19.03.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 19:04:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b="DpT/q3xM"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 6232F80C0351; Tue, 28 Nov 2023 19:03:53 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376882AbjK2DDn (ORCPT + 99 others); Tue, 28 Nov 2023 22:03:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376877AbjK2DDm (ORCPT ); Tue, 28 Nov 2023 22:03:42 -0500 Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F0541990 for ; Tue, 28 Nov 2023 19:03:47 -0800 (PST) Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20231129030345epoutp01187ec81dd2413f9fa644e9fccf93ac4e~b_PdTKtKG0638406384epoutp019 for ; Wed, 29 Nov 2023 03:03:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20231129030345epoutp01187ec81dd2413f9fa644e9fccf93ac4e~b_PdTKtKG0638406384epoutp019 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1701227025; bh=1xxcviCzwplVYwof4YqPkHybqVAQfpPegoq5Qwuh5DM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DpT/q3xMbc4oTuvsUuz07ueC5MeY526zHQFnXiXfCrMcocptTDrDk+j1YMjxByPQa RJbn6WZcsphR/ghxgednEv8wFAo2r0fHJ3t8WG7Dz+mPC2hM+KwAmnVAwB+mSZ2Re+ kEmUgH67RvV00GBy31Q9VVas1eljXMNSZvmnHNI4= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20231129030344epcas5p4f9261482a7b6ce51f84fa7318760d94d~b_PcmWPE01349813498epcas5p4H; Wed, 29 Nov 2023 03:03:44 +0000 (GMT) Received: from epsmgec5p1-new.samsung.com (unknown [182.195.38.176]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4Sg40H2y83z4x9Pr; Wed, 29 Nov 2023 03:03:43 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmgec5p1-new.samsung.com (Symantec Messaging Gateway) with SMTP id 45.E2.19369.F0AA6656; Wed, 29 Nov 2023 12:03:43 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20231128123634epcas5p201af168ff4ef4a8a129e5448bccca1a6~byaUEM9fi3276732767epcas5p2F; Tue, 28 Nov 2023 12:36:34 +0000 (GMT) Received: from epsmgmcp1.samsung.com (unknown [182.195.42.82]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20231128123634epsmtrp2f314d812b7ad3af5576c1348d52796e6~byaUDiCJB3270432704epsmtrp2U; Tue, 28 Nov 2023 12:36:34 +0000 (GMT) X-AuditID: b6c32a50-c99ff70000004ba9-59-6566aa0f6c4d Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgmcp1.samsung.com (Symantec Messaging Gateway) with SMTP id 24.E7.18939.2DED5656; Tue, 28 Nov 2023 21:36:34 +0900 (KST) Received: from green245.sa.corp.samsungelectronics.net (unknown [107.99.41.245]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20231128123632epsmtip1ed1f5bef850d4524e25f2dbb5bee7d30~byaSSu3Ba0450104501epsmtip1Z; Tue, 28 Nov 2023 12:36:32 +0000 (GMT) From: Nitesh Shetty To: Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg , James Smart , Chaitanya Kulkarni Cc: error27@gmail.com, gost.dev@samsung.com, nitheshshetty@gmail.com, Nitesh Shetty , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] nvme: prevent potential spectre v1 gadget Date: Tue, 28 Nov 2023 17:59:57 +0530 Message-Id: <20231128122958.2235-2-nj.shetty@samsung.com> X-Mailer: git-send-email 2.35.1.500.gb896f729e2 In-Reply-To: <20231128122958.2235-1-nj.shetty@samsung.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrAJsWRmVeSWpSXmKPExsWy7bCmpi7/qrR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ks41Ir/Cq215np519POR/3rejnurmmMXl0h Uc+e6M78n/rR4/Hsc7vjUuNEHfNjVr/w/dn9+KdVW7rGvOX/dno8E+5Ys1B8qYcmp9Kn5KBj G0P9zhcfDz0jsOxoZV/lIe0lje98izMXt38za9Q4Wbt5nRJLcUaioRZzUXEiALe9M4IFAwAA X-CMS-MailID: 20231128123634epcas5p201af168ff4ef4a8a129e5448bccca1a6 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20231128123634epcas5p201af168ff4ef4a8a129e5448bccca1a6 References: <20231128122958.2235-1-nj.shetty@samsung.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 28 Nov 2023 19:03:53 -0800 (PST) This patch fixes the smatch warning, "nvmet_ns_ana_grpid_store() warn: potential spectre issue 'nvmet_ana_group_enabled' [w] (local cap)" Prevent the contents of kernel memory from being leaked to user space via speculative execution by using array_index_nospec. Signed-off-by: Nitesh Shetty --- drivers/nvme/target/configfs.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/nvme/target/configfs.c b/drivers/nvme/target/configfs.c index e307a044b1a1..d937fe05129e 100644 --- a/drivers/nvme/target/configfs.c +++ b/drivers/nvme/target/configfs.c @@ -18,6 +18,7 @@ #include #include #include +#include #include "nvmet.h" @@ -621,6 +622,7 @@ static ssize_t nvmet_ns_ana_grpid_store(struct config_item *item, down_write(&nvmet_ana_sem); oldgrpid = ns->anagrpid; + newgrpid = array_index_nospec(newgrpid, NVMET_MAX_ANAGRPS); nvmet_ana_group_enabled[newgrpid]++; ns->anagrpid = newgrpid; nvmet_ana_group_enabled[oldgrpid]--; @@ -1812,6 +1814,7 @@ static struct config_group *nvmet_ana_groups_make_group( grp->grpid = grpid; down_write(&nvmet_ana_sem); + grpid = array_index_nospec(grpid, NVMET_MAX_ANAGRPS); nvmet_ana_group_enabled[grpid]++; up_write(&nvmet_ana_sem); -- 2.35.1.500.gb896f729e2