From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.6 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 50B5AC43387 for ; Mon, 7 Jan 2019 12:36:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2099121736 for ; Mon, 7 Jan 2019 12:36:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1546864618; bh=jsODWWm8EonB42K8AAbilYPqLG+Uy3Dg5sOP9ElX3z8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=uBf+z/rgUgLQQDP7xz4jL9567qwPKiTkkSSSK5qFmoED9y2/ABIa453OU7bxlNqXJ YdixPtCJ92oWDZ/iMuM9pIgaxYaPbDlG9GzxyoYbAltSRDEq59v93Hk8Hy6CaVX9mT skRp8xmGDai34cpkOi51KLDaVu1gufgZi1eQROc4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727742AbfAGMg5 (ORCPT ); Mon, 7 Jan 2019 07:36:57 -0500 Received: from mail.kernel.org ([198.145.29.99]:51732 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726718AbfAGMg4 (ORCPT ); Mon, 7 Jan 2019 07:36:56 -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 A1E7520859; Mon, 7 Jan 2019 12:36:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1546864615; bh=jsODWWm8EonB42K8AAbilYPqLG+Uy3Dg5sOP9ElX3z8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QrFXOmUuF2zhbwVB0hph5eDjmXOU5b8qRAKCIyjpq5Oo2O7A4suxQmb9T0+3P3PfV MroHITES2U/kwOY5r5LkTbxb+b2LhegXDUJGk+5WVMlFDOuyH2Q5O0l7tLCNFF0gH8 Ga8pO4RXa7+imNUXHdVz145sY+94pHKAO4KYHEFE= 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.20 016/145] phonet: af_phonet: Fix Spectre v1 vulnerability Date: Mon, 7 Jan 2019 13:30:53 +0100 Message-Id: <20190107104439.479395203@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190107104437.308206189@linuxfoundation.org> References: <20190107104437.308206189@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.20-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]);