Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp820490imu; Fri, 11 Jan 2019 09:35:43 -0800 (PST) X-Google-Smtp-Source: ALg8bN72MqZsA5wYK6NMLu/Htzhh23qXsvCIWNsvD82eR0TdwILxFy4BKo0jk4ORRxeU3eZUSEMw X-Received: by 2002:a17:902:14e:: with SMTP id 72mr15637914plb.287.1547228143295; Fri, 11 Jan 2019 09:35:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547228143; cv=none; d=google.com; s=arc-20160816; b=onUiG7anWnSkj0YPMO4dEnHH+UjWGhroVMLQ0S+eZtCh0FsA36Ig2Lt2aVBXMOWBYj m3tKrngzJQAyvEofXEJB+RjrhHKacDMadCKvZJWlCoIgtetwZyoT00w8X3vZTw6D5Wif p55l+pKn9zfBfALn0gTnbrfoC3Iqvp2rGq/SiS5uHiZaeCFya0arnCEpy0Z/vWsaGwC1 9wb2pmkNtxDS7rsBmf6u2OtbPXio1lCR0zSN2OgAY0dYHtcDzyL4+wk4P4/I1DM9IvrX TfzeaBQxZSb10hgHoOwuF3xO2P3QhysMeqoCeE6dj3YKkO2qYnUK8ahgFtnSGgQL8ZCL dJCQ== 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=gSO9WKFr82w7NPNS3nK+Yq89Fj7ka7YhY40DofUCW0k=; b=KzmM045syNwVsDAJyzauTR7erhAzc6izu2xHDRuHTaNiNsyrLYzfH+sZNM430xWaGO aeYbswZEzhH6CqlnVykt0AmxTMH0s1jY8iXSm8u8jQAJu6Yab5XWIf+zu+JDzzCpdZ/o eqxWlmmv2ymzyynuHMF3rvoSfEkkD732pzaDpzyLbKlYANaJ2hqb52IDypcR/LDXPphV rxrkHJaZm5pczNkkwCyi1276HKwy5FjJ6A+puKaD3LogM34qrEob4zGRitjUnsxN4l8Q Grc3uvhsvF017DGLY/moEi2s2lCYjeu6Nt87JXB9pJU0NltNZlOReJj69CB7zSQ6gr6N dDww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="pYX/BHWy"; 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 e11si38160523pfh.147.2019.01.11.09.35.28; Fri, 11 Jan 2019 09:35:43 -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="pYX/BHWy"; 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 S1730372AbfAKOSX (ORCPT + 99 others); Fri, 11 Jan 2019 09:18:23 -0500 Received: from mail.kernel.org ([198.145.29.99]:34816 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730092AbfAKOST (ORCPT ); Fri, 11 Jan 2019 09:18:19 -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 D4BF92177B; Fri, 11 Jan 2019 14:18:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1547216298; bh=qgU6V4POssyL23AE/+FYVEkRnCwvO6mWddpLPhLjP1Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pYX/BHWynu8yz/NzafgG6yP6N41/9F480VROUh+wwJbmNAY2zPsKGQ0D7V7WFUUh2 V25zGI5B819OjjE4XWoPncyWOS/6h+U46IG7pT+lhNk/xNHj4G7zly+QFBkW8h36+w HDkc6wQCeGH6wW3HcrijNw8zajaT6Z/IP7SpxW4o= 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 14/88] ip6mr: Fix potential Spectre v1 vulnerability Date: Fri, 11 Jan 2019 15:07:43 +0100 Message-Id: <20190111131048.253702315@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 69d2c86766da2ded2b70281f1bf242cb0d58a778 ] vr.mifi 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/ipv6/ip6mr.c:1845 ip6mr_ioctl() warn: potential spectre issue 'mrt->vif_table' [r] (local cap) net/ipv6/ip6mr.c:1919 ip6mr_compat_ioctl() warn: potential spectre issue 'mrt->vif_table' [r] (local cap) Fix this by sanitizing vr.mifi 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/ipv6/ip6mr.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/net/ipv6/ip6mr.c +++ b/net/ipv6/ip6mr.c @@ -72,6 +72,8 @@ struct mr6_table { #endif }; +#include + struct ip6mr_rule { struct fib_rule common; }; @@ -1871,6 +1873,7 @@ int ip6mr_ioctl(struct sock *sk, int cmd return -EFAULT; if (vr.mifi >= mrt->maxvif) return -EINVAL; + vr.mifi = array_index_nospec(vr.mifi, mrt->maxvif); read_lock(&mrt_lock); vif = &mrt->vif6_table[vr.mifi]; if (MIF_EXISTS(mrt, vr.mifi)) { @@ -1945,6 +1948,7 @@ int ip6mr_compat_ioctl(struct sock *sk, return -EFAULT; if (vr.mifi >= mrt->maxvif) return -EINVAL; + vr.mifi = array_index_nospec(vr.mifi, mrt->maxvif); read_lock(&mrt_lock); vif = &mrt->vif6_table[vr.mifi]; if (MIF_EXISTS(mrt, vr.mifi)) {