Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp878586imu; Fri, 11 Jan 2019 10:37:58 -0800 (PST) X-Google-Smtp-Source: ALg8bN6PkZo3ysbWLSXl0l24Ns8vzq3ZnRewkYUZ/VPnz3Njtp0QgsjxQUBqdqRSLJQbDu9KixAV X-Received: by 2002:a65:4381:: with SMTP id m1mr14126151pgp.358.1547231878049; Fri, 11 Jan 2019 10:37:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547231878; cv=none; d=google.com; s=arc-20160816; b=h0/ZwlqhNfvQX24nt3Lt/or5XDRAqQC+KhbpoDzKS8RxNQYAbjn3pKUZZeMIsInYhx hITnzek+Zat5JDhqatGhP91Wc7LA02r6vwLG66Ai7zi5RqBlvUOpr/539MgmECXzq8Rn TuvAqM/5FXkrNEYga4m7f9fyNz9Lngx4rF/gwIZto1HcHgNhDq4o0pUS3w7N5SHbyWp8 8Yl13QO578O/Z8E+98dWQArCPxzVwEqm2mtcExoKtab+UHh0lk/pn5OV1cVzlh/VraPo TV8M5RG3l+aUHOBpuuVvDj+7OxQxkZe/pfO1V+1Hln9ZSPWwqJOqm+Ll1WdRlJxh/5p5 QZfA== 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=+fdXRWJGv/44rRHo5eYpwnWbtjn1Duzzm/UXdHB0y3U=; b=tZAtufAcPabecHSkUSeRjrILvB4slZDhiMM0WGlrfR3BqvVTmMCH+24dITrcuOvnAr IEuFO13kQzYtVMyFoBUhvRCHv2I+QblRVe/yXgyX46tzsJ5vdyunLTxAKaoukcWj1kUh VZaYLvBONxGbQS3w+nqNDXbdhSxXXduRhPka60gQ/3f0cJBOEbBcGl8sS/k2MOaLRKIM 6GmJm/ya7vm7Vq0scPN371XsKtpFUdzlBPOy+esLG0LElVif6RymwooDafcVkHh0g5rL vqwNbMQPMvmTlCyIMJJaGVPP1ZRq2RBcTXNKWxz9d1HKVrWcqbd/S1RU1bIiEIjjs9A1 hxrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=kzE8WvHA; 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 d189si23825255pfa.70.2019.01.11.10.37.39; Fri, 11 Jan 2019 10:37:58 -0800 (PST) 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=kzE8WvHA; 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 S1731028AbfAKOS1 (ORCPT + 99 others); Fri, 11 Jan 2019 09:18:27 -0500 Received: from mail.kernel.org ([198.145.29.99]:34870 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732016AbfAKOSW (ORCPT ); Fri, 11 Jan 2019 09:18:22 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.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 D54FA21783; Fri, 11 Jan 2019 14:18:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1547216301; bh=CLrQ2f7p0BCYFcPPNIjenI59IyS/5WiGqT6KibLjFhA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kzE8WvHALP/eRPwAvNbhu/BsduxNM5JTHBrmU3WR8EeRqMJE9x3ciQEddvTlXPffm OZEidFYdIfT2iHyQTLTu6/Ox6bhm8lgQ3iXaN7jNJM6+a4nEaUdxDmSxDNlQHvPYvj pRJrPUz9MNLicLlqBq/alEE2eJzqBuGWUIca6JCY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Gustavo A. R. Silva" , "David S. Miller" Subject: [PATCH 4.4 15/88] ipv4: Fix potential Spectre v1 vulnerability Date: Fri, 11 Jan 2019 15:07:44 +0100 Message-Id: <20190111131048.434148956@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190111131045.137499039@linuxfoundation.org> References: <20190111131045.137499039@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: "Gustavo A. R. Silva" [ Upstream commit 5648451e30a0d13d11796574919a359025d52cce ] vr.vifi is indirectly controlled by user-space, hence leading to a potential exploitation of the Spectre variant 1 vulnerability. This issue was detected with the help of Smatch: net/ipv4/ipmr.c:1616 ipmr_ioctl() warn: potential spectre issue 'mrt->vif_table' [r] (local cap) net/ipv4/ipmr.c:1690 ipmr_compat_ioctl() warn: potential spectre issue 'mrt->vif_table' [r] (local cap) Fix this by sanitizing vr.vifi before using it to index mrt->vif_table' 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://marc.info/?l=linux-kernel&m=152449131114778&w=2 Signed-off-by: Gustavo A. R. Silva Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv4/ipmr.c | 2 ++ 1 file changed, 2 insertions(+) --- a/net/ipv4/ipmr.c +++ b/net/ipv4/ipmr.c @@ -66,6 +66,7 @@ #include #include #include +#include #if defined(CONFIG_IP_PIMSM_V1) || defined(CONFIG_IP_PIMSM_V2) #define CONFIG_IP_PIMSM 1 @@ -1574,6 +1575,7 @@ int ipmr_compat_ioctl(struct sock *sk, u return -EFAULT; if (vr.vifi >= mrt->maxvif) return -EINVAL; + vr.vifi = array_index_nospec(vr.vifi, mrt->maxvif); read_lock(&mrt_lock); vif = &mrt->vif_table[vr.vifi]; if (VIF_EXISTS(mrt, vr.vifi)) {