Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp2756955ybh; Mon, 5 Aug 2019 06:22:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqzHfIAfZvtgasv8eopdAcQjqz5qfOwKvrC8deD6to4jyX8TQ6n+toEQ79a6kZOqbl8AsnSv X-Received: by 2002:a62:8246:: with SMTP id w67mr74821166pfd.226.1565011322437; Mon, 05 Aug 2019 06:22:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565011322; cv=none; d=google.com; s=arc-20160816; b=Rzi66Sy18Ch9/wkVLyq0cW0hYttU9mYpKmvwXH+gWQRj1j+z9yH84h6tmVeK/v5i/6 zDIdEwYDUG32ZsL+p/Wo04nstKGxzffuWPIrp2Cn+PjUt6KsU0V9qTsC5iJhjzshvRHO RlhCIF3DMp9GyjKRLoGDCbXFVhaEWbNTFdtN61ZwHljYYjJuv0JpeLt+JFE1QisTt4oa lhuhY8N9wQBptHbhrg5OsKGNSfaE4oGOyIoFphbRIzIxlVSbo2C1WtJkIxtbidHpwvmb B+AloPmAuq9c20JCoHSREjkGPLynKG4PgOoZZa/kYQQvTviGCMDmB1SJTyipnO6XVbfc 4feA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=JxNu/fis330BiPT/S68XgItbBpSlDqMpV827GrAFdq4=; b=XAdSHuZ+tISSRKh47gkFCeEWQZWh0nePMPKz2KEzi0JRD9UCPx8jt0BW4duL7Z7D9T ldOFPbzAsAuD9zQ5b/WtkAZMXxezfGXDEaKBT8WqxFRFBleJXOXN3Z+FGhjtrOChMVn8 N3ONWJF3sFZCJzUNqsDLa3twibBJuuXWp0TYpLu/wJANN7d2Hu4EkJiJRL+OmhYM3DRt xjAxzQBKNBfyacxqpOSs8uKxxQDdFjO6UHBhWd8TjHrfOT8g4sJ5WGOyw5p4PPbcoAF3 jU+Lp+A/y7E4uVgDAH01nRqpaE+bX0Lm+joJhm67PoXG0Lu8DHTrvldmsXFBg+fDWBjQ ul1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=iJVb+tSi; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a5si7355593pgw.454.2019.08.05.06.21.47; Mon, 05 Aug 2019 06:22:02 -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; dkim=pass header.i=@kernel.org header.s=default header.b=iJVb+tSi; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730175AbfHENUF (ORCPT + 99 others); Mon, 5 Aug 2019 09:20:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:56206 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730140AbfHENUD (ORCPT ); Mon, 5 Aug 2019 09:20:03 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 140802067D; Mon, 5 Aug 2019 13:20:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565011202; bh=03r97VGqXp/QJvnNHJqH2nCO4ax7jaxJtClnvljdmhk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iJVb+tSiXuJJjorosxvmz6oYKJB3UwqW6kMce+zh2EMUL1m2d9VsJucHspP0hThOF tbLEpIXcNQOjefhZCsOk6L5dgEqMpJoDdt625TWXa7WxOMgX+ufv1o8JwWjR21uHqi To16fgvTR8fi13ODt16nhmFkX/hrwwztCDY8plQo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Gustavo A. R. Silva" , Doug Ledford Subject: [PATCH 4.19 49/74] IB/hfi1: Fix Spectre v1 vulnerability Date: Mon, 5 Aug 2019 15:03:02 +0200 Message-Id: <20190805124939.857760420@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190805124935.819068648@linuxfoundation.org> References: <20190805124935.819068648@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Gustavo A. R. Silva commit 6497d0a9c53df6e98b25e2b79f2295d7caa47b6e upstream. sl is controlled by user-space, hence leading to a potential exploitation of the Spectre variant 1 vulnerability. Fix this by sanitizing sl before using it to index ibp->sl_to_sc. Notice that given that speculation windows are large, the policy is to kill the speculation on the first load and not worry if it can be completed with a dependent load/store [1]. [1] https://lore.kernel.org/lkml/20180423164740.GY17484@dhcp22.suse.cz/ Cc: stable@vger.kernel.org Signed-off-by: Gustavo A. R. Silva Link: https://lore.kernel.org/r/20190731175428.GA16736@embeddedor Signed-off-by: Doug Ledford Signed-off-by: Greg Kroah-Hartman --- drivers/infiniband/hw/hfi1/verbs.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/infiniband/hw/hfi1/verbs.c +++ b/drivers/infiniband/hw/hfi1/verbs.c @@ -54,6 +54,7 @@ #include #include #include +#include #include "hfi.h" #include "common.h" @@ -1596,6 +1597,7 @@ static int hfi1_check_ah(struct ib_devic sl = rdma_ah_get_sl(ah_attr); if (sl >= ARRAY_SIZE(ibp->sl_to_sc)) return -EINVAL; + sl = array_index_nospec(sl, ARRAY_SIZE(ibp->sl_to_sc)); sc5 = ibp->sl_to_sc[sl]; if (sc_to_vlt(dd, sc5) > num_vls && sc_to_vlt(dd, sc5) != 0xf)