Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3538085imu; Mon, 7 Jan 2019 05:17:27 -0800 (PST) X-Google-Smtp-Source: ALg8bN4NNhhyhyOPttBiKkj8Y5WI0Ln9XIe+cOit5aFftnr66lZ4jJ1uSzJKWJ5spiR/BVwC3JMj X-Received: by 2002:a63:db48:: with SMTP id x8mr10602028pgi.365.1546867047338; Mon, 07 Jan 2019 05:17:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546867047; cv=none; d=google.com; s=arc-20160816; b=PvySxSgt+gxWFaoGmLWRfqCUI49fpdVQMs/zRj80fRLagUcmRm8bt3CWV4yqEb3fcK VfVHfYn/se6nGTNAawTB9PwwMgrpg2G8Wba9WWr69hWyKUNWI5D8/lJX6QmwGfOrsVBP xu+JoLIRoGTq9ohVEbzpFTOsDd2xtbnPZsSMYEALqCslcAEzNPWrpI8XNFqRST13FRO5 o8ORD+1tenTrmfUEOIm5QDqogLLZtO8Y0H7cImtJwfK2CQqoy4PUsWqlS1BoQEj/8+37 CEB84vBjQLSglFtly1R+bvs0s42GjioYfIgwpS9Yj4/N+u8s48yxevo4ZK6LD3/T2Flx kscg== 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=ppinKAe3F6RyjuBcNhaY81gSedUpkEwQR9hRv3rSbVY=; b=S4LeTyP4uPLCzlk8dPUo/XSFoYkcNwbD3Ym8CnEfcjYGdPVTmy9OvrvOi2R1HPN1Fv r5vtpcB8D/3auMhRM9m22oKBn/vBxF13AlyK+GtUfvxYkvGAfc0yq0EC7O9VmICiVICV vBodYhiWMqQ7tzaE34tieKl54HnORiEUN9skpvvqx7y0RXzehxH6Q/ez/+ZOYVDA7Khw wGVPo1fcWiNsA44XjlYOq7cc5VQwdDHma6DQbFtjTnDA6ND6RrAuOQPt21qu23QYNNdk 64M9cXmbfsSV5pdsW0GBVjdDl4BAXtk/LoE7aQfp7MKjreBbJLMiRGjnWEXSz8HJVs8B 5vZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yQElSbyJ; 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 j12si14896936pgq.26.2019.01.07.05.17.12; Mon, 07 Jan 2019 05:17:27 -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=yQElSbyJ; 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 S1731601AbfAGNPh (ORCPT + 99 others); Mon, 7 Jan 2019 08:15:37 -0500 Received: from mail.kernel.org ([198.145.29.99]:49168 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730659AbfAGNBm (ORCPT ); Mon, 7 Jan 2019 08:01:42 -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 68BA32089F; Mon, 7 Jan 2019 13:01:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1546866101; bh=Ozth432OK93FKKPG4ihba7ggkBZbjLWcAz8VyGRIXRY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yQElSbyJTlfQPyPPfT39O0mIwyrxwtpdad8P1RG4HfMa7y6XmKqDDA1NfPYDKJVu0 FMl5eod1OKviiunvrv+rZHBnMYNC4wQd2ge9cNTJiFO+mb8lahWH4uWeO+nlYuCO/5 8Sd//lkWAA4QmoDqBJLQBaIeFPBc3S9kyKytLNGM= 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 001/101] phonet: af_phonet: Fix Spectre v1 vulnerability Date: Mon, 7 Jan 2019 13:31:49 +0100 Message-Id: <20190107105330.456283338@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 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 struct phonet_protocol *proto_tab[PHONET_NPROTO] __read_mostly; @@ -43,6 +45,7 @@ static struct phonet_protocol *phonet_pr if (protocol >= PHONET_NPROTO) return NULL; + protocol = array_index_nospec(protocol, PHONET_NPROTO); rcu_read_lock(); pp = rcu_dereference(proto_tab[protocol]);