Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp5264480ybi; Tue, 30 Jul 2019 17:22:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqw2fRe0XsNWQ5CZOL8X/pxzyRYYMJdf3sVtdcifmbZSWSXabBKYC+Bcn6XcDCyslfbaCiKt X-Received: by 2002:a17:90a:20c6:: with SMTP id f64mr52326pjg.57.1564532574338; Tue, 30 Jul 2019 17:22:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564532574; cv=none; d=google.com; s=arc-20160816; b=W0fcqVAeN0K+/zmPl8GLQgAUSc6LBMF6fcENXJ9sqxut4oRElIMBUYfLfW+TVgKQ+M K3mHhK2n8Qzuc7aQGLq0MD3TsgKZSehMGBOP6ObjcCaY/XfDe4v60wsIMo7sMpGS7j8n D5XHgwraHnWiV+3MxvTda38Az2EIc3ENEB5wgBty3UrqvUht0MteihFfviRb4s0RGCDE yHRExLkzu/hqLmn+AbNafNOoLx8xFu+seD8C5t//Kcj6OvAszKyDEtSFiL1N1kkd1mwm HMX4NpqVk/zD/DOyIrRfJILnFfgGklra0kav3vsi+nn2SwxswZ5bzsdXDP1oaKYbl4f7 JQ4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=3W2dYlc5MQOfFGa7RMCYKmJZ4LsiZuZPoCa7ZEKtWqk=; b=M1nIuUiM0vpTs+HjhpSlf3nVt0JsuCcMkxzD7QO/nKR+BoQxRpXWn9O7taHZlVVnnP 5z3F8E4w3dp5GnwT6dDGaX73hfmM15JZVjY6wHANwwPgFaVzLHgOzpZvOvxg0+j1HJ7s rc0mfHzlATPVQhhDVE5kfIv4aClihRGsXg8fxmn7S3A2UvtDHWsarw2D+KDFtRbxSZar 06XSaw5NyRTq9yefbNFfgF0yZoVqA4BH7uuEBHo7cb4VQjugy5EQQQbjUEv6PbjEUBSx dTgsgKnarHR4COxpVCkH5Ml90M85Q+uIcTyR5p8bF/PEiChhNhn6AsiYu/sDdR4pvWA6 b1Yg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w11si29707592pgr.321.2019.07.30.17.22.38; Tue, 30 Jul 2019 17:22:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727647AbfG3Xer (ORCPT + 99 others); Tue, 30 Jul 2019 19:34:47 -0400 Received: from mga07.intel.com ([134.134.136.100]:22466 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725877AbfG3Xeq (ORCPT ); Tue, 30 Jul 2019 19:34:46 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Jul 2019 16:34:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,327,1559545200"; d="scan'208";a="196124120" Received: from iweiny-desk2.sc.intel.com ([10.3.52.157]) by fmsmga004.fm.intel.com with ESMTP; 30 Jul 2019 16:34:45 -0700 Date: Tue, 30 Jul 2019 16:34:45 -0700 From: Ira Weiny To: Tony Luck Cc: Doug Ledford , Jason Gunthorpe , Leon Romanovsky , Parav Pandit , linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] IB/core: Add mitigation for Spectre V1 Message-ID: <20190730233444.GA13835@iweiny-DESK2.sc.intel.com> References: <20190730202407.31046-1-tony.luck@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190730202407.31046-1-tony.luck@intel.com> User-Agent: Mutt/1.11.1 (2018-12-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 30, 2019 at 01:24:07PM -0700, Tony Luck wrote: > Some processors may mispredict an array bounds check and > speculatively access memory that they should not. With > a user supplied array index we like to play things safe > by masking the value with the array size before it is > used as an index. > > Signed-off-by: Tony Luck Reviewed-by: Ira Weiny Tested-by: Ira Weiny > --- > > [I don't have h/w, so just compile tested] > > drivers/infiniband/core/user_mad.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/infiniband/core/user_mad.c b/drivers/infiniband/core/user_mad.c > index 9f8a48016b41..fdce254e4f65 100644 > --- a/drivers/infiniband/core/user_mad.c > +++ b/drivers/infiniband/core/user_mad.c > @@ -49,6 +49,7 @@ > #include > #include > #include > +#include > > #include > > @@ -888,6 +889,7 @@ static int ib_umad_unreg_agent(struct ib_umad_file *file, u32 __user *arg) > mutex_lock(&file->port->file_mutex); > mutex_lock(&file->mutex); > > + id = array_index_nospec(id, IB_UMAD_MAX_AGENTS); > if (id >= IB_UMAD_MAX_AGENTS || !__get_agent(file, id)) { > ret = -EINVAL; > goto out; > -- > 2.20.1 >