Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3916827imu; Mon, 7 Jan 2019 11:53:36 -0800 (PST) X-Google-Smtp-Source: ALg8bN6//q2lTb1bA7tbNvApF28/UrUQ/ePfKu0yVdNgPrh64XhyheBrBhK0RQ8NBGorph1ytxGT X-Received: by 2002:a17:902:27a8:: with SMTP id d37mr63375814plb.182.1546890816277; Mon, 07 Jan 2019 11:53:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546890816; cv=none; d=google.com; s=arc-20160816; b=TxvXew97KIpQ3qXjdKm8P/UVA/m/S4OloZ9eMeOqmVcxO4riOcYfForA/TOxvRCdv+ 0waLch/GhpaAB8n+SwAf4sjv1qTJqdc6fDxnWRj20bWr+ZsvtgbeZSp7P+mre3HEGeOM 4Vi0bobBxqS7fEovba02z3Rrwc7qmGtyIlSTcPq8eCL06NEXVwaEboimvzwtFr0IgmZM TWjIDAJpcLamSBensWSuwR5I3QOzWMiIIDBX8Cw+90V3WV65HMPYJrd3782OUJ/BaAe5 5YSewLADezgHSW3gSijpHp0yAOC1VSgTm6OZJah5Rz3pC0U96cJRKRlu5QhAPjUFbIx0 YrSw== 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=BRWXyoFA6dUtxqTI4uCzkOScB9E7a47qnBq+0Yo9424=; b=ZtoA+tFtJg5PR8alXaEf/1k8E9DvK6nd9cXo3VMPuQPUn1P9jQyAgjLilqmJwyzYZc 5RP8e2Ak7Fv1oZqjwv6Ta8p8SLiN+xjFJopQZeQmVKsuV9SleaN8vp3PcWaAzS4PhdYl LTM09Ib9aHdRBED14JVbzuMlcAoKpGRaJxdYk8G2e3P9f78u9KDu188VltwaMND1TuT3 uNwgEL3A2hATbd6HNJ2MxPju1XXqmCws9BhvJdM6AL65Va+kxV9wvdGVoWNlrfaB5Ep+ DcrdkY5K+G1j3fS5fI/q6Cih/ADHz19mY8rwLbunWbcCgr/MSHmQFY40WsVnEyZnsJaF Iprw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=y45UMitn; 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 v185si11159201pfb.65.2019.01.07.11.53.20; Mon, 07 Jan 2019 11:53:36 -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=y45UMitn; 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 S1730305AbfAGNQw (ORCPT + 99 others); Mon, 7 Jan 2019 08:16:52 -0500 Received: from mail.kernel.org ([198.145.29.99]:47928 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730462AbfAGNAZ (ORCPT ); Mon, 7 Jan 2019 08:00:25 -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 7573721736; Mon, 7 Jan 2019 13:00:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1546866025; bh=g8C1nGI/CiMNcaSGHLqCCTe17+yv/EdejMjaH8Ui+ak=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=y45UMitnlA8xugrDjNSIJlkRUDcIn+b1C824HREfnMI8C/ik2d6rIuwmGC67wlp+P nJSHoL5wk+IuCr0998ZaZYws5fxW9kCw9dQojQMY+J/ilO1R8NlwogZOvhE3evFLd5 tyH8AOzqe7N1gCt9GcW+bTtMY3QADYLPxHLGa8ZY= 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.14 003/101] ipv4: Fix potential Spectre v1 vulnerability Date: Mon, 7 Jan 2019 13:31:51 +0100 Message-Id: <20190107105330.587860461@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190107105330.372621917@linuxfoundation.org> References: <20190107105330.372621917@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.14-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 | 3 +++ 1 file changed, 3 insertions(+) --- a/net/ipv4/ipmr.c +++ b/net/ipv4/ipmr.c @@ -68,6 +68,8 @@ #include #include +#include + struct ipmr_rule { struct fib_rule common; }; @@ -1620,6 +1622,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)) {