Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3511695imu; Mon, 7 Jan 2019 04:52:06 -0800 (PST) X-Google-Smtp-Source: ALg8bN7v3x8x+9HACPAMaJxmMe2o1bqFzxcDv/NGtzlaD2II8Fs3PnDd0xbv4duhnjwP5GObQRM0 X-Received: by 2002:a17:902:7e44:: with SMTP id a4mr61259173pln.338.1546865526126; Mon, 07 Jan 2019 04:52:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546865526; cv=none; d=google.com; s=arc-20160816; b=uZHjCmAUcPh7Dgijm18FSBSeRDTW7HNQVvsEVmYO9jK4gFIAnrzqEhjYaqiksO5D8q WRGddST9OLlEetuVTK9oCTOzMefvCRIBtWco7KKh1rLidxsZfhImNtSN8tzSn5mJmcXt qAUCciUAWNjDKluKVSkQYXLPQ8NW+eCyU3TivMfwX//zHA7PuRCeJ028wfJyAutAxsgz 6+drevR0KW77MDP3H+Y6dYascD3aQehjzSFPeF/zVLjsLaS6ewj9zToZyUzUm9cD0w5k z9FQcW7tV1HxiOfXvwcD1S1xrUixTupVbbjZp21Zb1GFN0lS7hGuxt25qhq1/dee/uYB VWgg== 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=xSEzmwgQRWiKMeenxvgU7TQaS8Xgk5fDu/0JIgy9SWA=; b=h4/ArmuOUZ5yyOkGxJ10V+vNwY5mbKbU5t4aDuegq3sGLkZHQ48DQgWzu+J1DxK5St /jcd66y9sU4s7rnvHdVbPMMEkwvTXvD/65Xu4XJsrIKWhN/LLA7y4B+MFldNWa8aa2/J /+s6VS9Zt814Pt1gL6/1dv7Ubuxulp+QdaLz+gmIhk1Hb98M5VCOCX4xQJFYBIpbWrwZ JdlwFSTzwlhIlKQB9efcToEiEdwDA4Z2R95wBYlH2er2gUIy3+D8NoLoS6j4qdfXf5fg oPr6C0Fi0oRQo6bwC0HfQwnm9o6QAz6aC1MHKjJZwf7HCqmiIS1JXr/xR3Rxtm6LXwH3 dd9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OxfoJKYK; 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 d39si21455780pla.278.2019.01.07.04.51.51; Mon, 07 Jan 2019 04:52:06 -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=OxfoJKYK; 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 S1729308AbfAGMtF (ORCPT + 99 others); Mon, 7 Jan 2019 07:49:05 -0500 Received: from mail.kernel.org ([198.145.29.99]:39944 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729300AbfAGMtE (ORCPT ); Mon, 7 Jan 2019 07:49:04 -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 E8CF120651; Mon, 7 Jan 2019 12:49:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1546865343; bh=Jb2/5CL62w9yQgmAOukgXo7E2fIoPC2BTMJ8vCSHyFM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OxfoJKYKme4JueurkMgXLaozX3qlMNYonDRr7E9+bcyd9fnFvEV0ojuaV0PCnELqh sFp+n847/BOglFNIkeM3zaNyuDADN1e4bXkMo7ZbHApKYpO6uALvvCcMRnpmxV3OMg oKHVvm1lxHRnDJmc+Fnh3i1KK6/ir6sLAOnwOEag= 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.19 025/170] phonet: af_phonet: Fix Spectre v1 vulnerability Date: Mon, 7 Jan 2019 13:30:52 +0100 Message-Id: <20190107104456.064296316@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190107104452.953560660@linuxfoundation.org> References: <20190107104452.953560660@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.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: "Gustavo A. R. Silva" [ Upstream commit d686026b1e6ed4ea27d630d8f54f9a694db088b2 ] protocol 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/phonet/af_phonet.c:48 phonet_proto_get() warn: potential spectre issue 'proto_tab' [w] (local cap) Fix this by sanitizing protocol before using it to index proto_tab. 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/phonet/af_phonet.c | 3 +++ 1 file changed, 3 insertions(+) --- a/net/phonet/af_phonet.c +++ b/net/phonet/af_phonet.c @@ -34,6 +34,8 @@ #include #include +#include + /* Transport protocol registration */ static const struct phonet_protocol *proto_tab[PHONET_NPROTO] __read_mostly; @@ -43,6 +45,7 @@ static const struct phonet_protocol *pho if (protocol >= PHONET_NPROTO) return NULL; + protocol = array_index_nospec(protocol, PHONET_NPROTO); rcu_read_lock(); pp = rcu_dereference(proto_tab[protocol]);