Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3527985imu; Mon, 7 Jan 2019 05:08:04 -0800 (PST) X-Google-Smtp-Source: AFSGD/Vpj9erlc7H8quUo3p2Y3AS6HIZqLE7saG8NKFu0kPi2aPQzou68sb9XBLym48eJJqaaPl4 X-Received: by 2002:a62:2e46:: with SMTP id u67mr61696549pfu.3.1546866484618; Mon, 07 Jan 2019 05:08:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546866484; cv=none; d=google.com; s=arc-20160816; b=siy03k6w/wiGA0yWp5jVj2lx9KpUKtWhLwRq9jV67BSvpl9xz2wEY0Z8xRtwQQjbkU S4z584dT+k5s9Yvpi8rdYSm+9rLc9X9RgcTR0z2xYr68SILUJ0YBEeFCt+EYj88ptZ2I TyBaxfN8e3bXrNB46moj8X91IxKQk7a7RvUHhdE1/p7Hf7sesgcho7ChBJZgmuauMwKq hMZhf5nbqBs/LxRQBo8LyUjYRNWoajX7f/Nh53XNFot/3cHRH8cyd+e/WurRa2FCFS7q vXcBqdBgKfeja866lsbWU2xbn2OpVkJ8NmR5UWMBCdSvR0dC9VUCLye72CKPLhxQD0UJ FEXg== 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=WrmG3p3IXHzsyt5gKeZffF4Ll+Mr3H/kgdYQhhN/lic=; b=YAi1gvdrErKQLo1YuKPKNKJDOuMQE2ITCpTELseFWUHNGZZlxZA2Mv5GfMsannZJgl wbqubzHhBELW24FKuTnB4tTx1+iCUqgLyEtzCvZKgSxcd1HvkrtUnYWDhMfK3QrNG1sP QTSJufmhtGuShfRnC43ycM/Ndj8gsOnZ5jpTkFIH0XZ9o38ISLA3LTXo3kPJEra/gtQN IVJnmw5y0dfhzxTc8kWBvpcbG9FH+FuQ+I7rAZytnavcfFRVwbVFl9F1TioK1NkHCM1w Q5Hqfbx1shVYaQHLZWzQll5PPTniRszhTOzu3Og88vZ6AbanPz3jdtIivfG4Db5wqjOh riDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=eOvukLll; 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 33si1606587plt.228.2019.01.07.05.07.49; Mon, 07 Jan 2019 05:08:04 -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=eOvukLll; 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 S1731514AbfAGNGB (ORCPT + 99 others); Mon, 7 Jan 2019 08:06:01 -0500 Received: from mail.kernel.org ([198.145.29.99]:53512 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727786AbfAGNGA (ORCPT ); Mon, 7 Jan 2019 08:06:00 -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 417BA217D4; Mon, 7 Jan 2019 13:05:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1546866359; bh=848c5EXCAMChJV4lobp6UKu9PQQ3UB6BXwM+uUVsZu0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eOvukLllOsT/7IqcyfoctQ2G7ZuHcOAyI229nA94Dp+zHE1xq9WOLc56qiDDdu5Ii YvCAlwteVsnIukTilK+kY4Uu3N9vXn3L9cT+aazV/rYumTgUC5pZsmElNSf9nsIQPh PrCECyFwhaCpE/h6vxpDb6ujQxG2JdzDq3pNbsMs= 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.9 05/71] phonet: af_phonet: Fix Spectre v1 vulnerability Date: Mon, 7 Jan 2019 13:32:34 +0100 Message-Id: <20190107105330.590339037@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190107105330.280153213@linuxfoundation.org> References: <20190107105330.280153213@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.9-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]);