Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3540093imu; Mon, 7 Jan 2019 05:19:25 -0800 (PST) X-Google-Smtp-Source: ALg8bN7s2EZyKrNlix5IEYb++EMDBKmMRzzX+3A6MGfOObDvkq8Y2JV0JwEVgqjGMJ/7j7IpuQfm X-Received: by 2002:a17:902:8ec8:: with SMTP id x8mr61719544plo.210.1546867165359; Mon, 07 Jan 2019 05:19:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546867165; cv=none; d=google.com; s=arc-20160816; b=xDjyYRXfPWZ754hMrXV13qErpUuwlKDbXP3tKcCds1qI2w31qmG+9nDfIAdGf+F8H+ ROJ3tmoBHUvg0X2k0IC6IGcwtvHvLIdCFN3/VwUT9g89sPXO3bSkyCefXRamUdxmq/5k ttbHR+08vD7psa+k7zvd0AZsWMsgWXK8lDcwfDQNNiuQw9kieGS7JoOVMzifFdEZozR8 TTgKbKoVeR4QVfz+n8j93LWz3wrsdCmvlCqgN+CLRVGSD2BgT0jIMBHWUxa7mkZEEHYp zkUwIYqkxnznHrcnOEudgJhV9UXHM9RsyEKpNx7spKUM3AT0n0iFXJZTh4nkRcqkHSU0 D2fw== 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=zg45M7+E1SGSmEEfaR6IO00BPfNxgC6mcmFd5pZrsTQ=; b=qUAe+d81viuFFJZQmufM9sUxlrrnFRnXOJOuN4WUjGXUi+rehFTrYw7HBj5XRbyx+j hMZLjWFLdsOZU6fRblTUbZNFneQiM1mqLwjZhnzZSqMESduF9Li++zUD5OIJCYzDCiRn xoVuIUAwRwTmWk6t8hQGRDCHaqrqfQK8HoxZarplzNLf3YEH41Ad9q7HcjsfddZW3Cxl HSk6QdS/hs8EDUMrITQ2FL1P65jeKWNkvhlZgQj8C54bvxxgD6wBS1jRqzRAymsTeGQc pIFj0+Ul2oCLvt+MkT3zrGZnN0PuHLXKX5a1XW6fFBeMZUCnZ/Aau4YVLRmU/7Z0Dv5x AHqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pVJG1nnX; 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 p14si7963745plq.25.2019.01.07.05.19.09; Mon, 07 Jan 2019 05:19:25 -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=pVJG1nnX; 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 S1730335AbfAGM7x (ORCPT + 99 others); Mon, 7 Jan 2019 07:59:53 -0500 Received: from mail.kernel.org ([198.145.29.99]:47386 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730325AbfAGM7u (ORCPT ); Mon, 7 Jan 2019 07:59:50 -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 1C10F2089F; Mon, 7 Jan 2019 12:59:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1546865989; bh=oPCrHrX9ZqlxMvDD2q7lz7GXv0buO9OPhJDx9TH6XtE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pVJG1nnXZNnp+Mw6xz9Tkh4y0G45HUttDl5cz2ygfHcrf5kYfWCJArPhdObhNGrRF iOrzsQbLM9SdjN7oMRtoAbk3L1m4ZurcgcLD59zTCOYo6lCQ9a+q+5bEG37pTyHPNu SFXvRSoGXXC2RsYiUgVtwo8XSRhocOdO0SJxle+E= 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 002/101] net: core: Fix Spectre v1 vulnerability Date: Mon, 7 Jan 2019 13:31:50 +0100 Message-Id: <20190107105330.528127680@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 50d5258634aee2e62832aa086d2fb0de00e72b91 ] flen 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/core/filter.c:1101 bpf_check_classic() warn: potential spectre issue 'filter' [w] Fix this by sanitizing flen before using it to index filter at line 1101: switch (filter[flen - 1].code) { and through pc at line 1040: const struct sock_filter *ftest = &filter[pc]; 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/core/filter.c | 2 ++ 1 file changed, 2 insertions(+) --- a/net/core/filter.c +++ b/net/core/filter.c @@ -56,6 +56,7 @@ #include #include #include +#include /** * sk_filter_trim_cap - run a packet through a socket filter @@ -823,6 +824,7 @@ static int bpf_check_classic(const struc bool anc_found; int pc; + flen = array_index_nospec(flen, BPF_MAXINSNS + 1); /* Check the filter code now */ for (pc = 0; pc < flen; pc++) { const struct sock_filter *ftest = &filter[pc];