Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp840229yba; Wed, 24 Apr 2019 10:26:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqzo+SzVCe12qhdbOs/2+yX+uoyL9CZ53cgs8nzUpe79QieCuf5ct2KqLbPtMANhrD5vDqHR X-Received: by 2002:a63:730f:: with SMTP id o15mr13510570pgc.315.1556126783860; Wed, 24 Apr 2019 10:26:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556126783; cv=none; d=google.com; s=arc-20160816; b=WN1YXU2ihYlgUzY8shwCSwTVfwMFqdl/ucMwNQNQ0lvr2fNpD9+khJhLQhfwhHy8He q3SqKJcFqTb/mc1prgCgSFXDBlJrXS/RgsW0Bqm4dywd6H43RJf/UXWWbSGZZh9Gfzee V2ugnpZaqYs4phaC8YLQtGX2ElchEuo8rBoAaqtL337CjPXhI72Sa/7LFMVA3VmnHPqh LGmra/9Ez6h8ccrOf5TQCbQMiJ3PSV+EH/s+02XgrBkoQVrU3H8Vq5bGa5Icq2xxVA3r Y99nfYXodkkApQ8WeQdOAIoeasf7V70Xg3rDG+A/hbk8LBVTUlXcCnr03EBD3E9mE9i3 tVJg== 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=wUA2Enva7BE+7z6ZXKylqpr38taGroT7oJx8jzqBibI=; b=GkqyBPibBwZcvmBMFneLzods4vK/DrEy74puZ0afoGNfLT1ZUJoMkDMCyHJ/YXF36i H84hk1GmnZilnlkreX0ugsqoIReeybwD4aAI9IAWoZdm1lwBsZRD9xPdrNNmMCr38/1b tAG/c1v7BW42Pxd8biJRw1k1xt13JUdYuS6BhSex1CfSIwqtMYd6gVgiEuxmp04MfzkR BcrTuJdS/hLp1UMlG3u6mC3bmZGGiNAJXpgs/p+CPcCXqeottgEOODRa+TU+wwDJZ+eb SZ1mJUPDHUwfQj7X680Bg7fAGRQOlhIWwWt8QR+54VA2fqbK1Hhl0iTgEzeNNZQZxiYG BBrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=r4xyEjHo; 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 y10si18358801pga.96.2019.04.24.10.26.08; Wed, 24 Apr 2019 10:26:23 -0700 (PDT) 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=r4xyEjHo; 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 S2389879AbfDXRYc (ORCPT + 99 others); Wed, 24 Apr 2019 13:24:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:50394 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731465AbfDXRY3 (ORCPT ); Wed, 24 Apr 2019 13:24:29 -0400 Received: from localhost (62-193-50-229.as16211.net [62.193.50.229]) (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 8B89521903; Wed, 24 Apr 2019 17:24:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556126669; bh=X24OnzlI9tkRjZTZkzSoiqWyq6vPOPNeBSIj+qpEvyo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r4xyEjHo7nUPt1sggCfouAjgUAYFRlVi1Kg7oYTnvNg2Drps/W8p1wNosXgFQQG26 M/V23Ksho5Nqt8Ihx8Y4VQ6oxl+3uUrw6tclhZ7/qqAjumS2Yk1tOo6FoU0CJ9Xx1x 0fYQeJmpJwH1mGtO7zKu3MxC8H7LsRGqJ9Kst328= 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 02/44] net: atm: Fix potential Spectre v1 vulnerabilities Date: Wed, 24 Apr 2019 19:09:40 +0200 Message-Id: <20190424170841.168956648@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190424170839.924291114@linuxfoundation.org> References: <20190424170839.924291114@linuxfoundation.org> User-Agent: quilt/0.66 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 From: "Gustavo A. R. Silva" [ Upstream commit 899537b73557aafbdd11050b501cf54b4f5c45af ] arg is 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/atm/lec.c:715 lec_mcast_attach() warn: potential spectre issue 'dev_lec' [r] (local cap) Fix this by sanitizing arg before using it to index dev_lec. 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://lore.kernel.org/lkml/20180423164740.GY17484@dhcp22.suse.cz/ Signed-off-by: Gustavo A. R. Silva Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/atm/lec.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- a/net/atm/lec.c +++ b/net/atm/lec.c @@ -721,7 +721,10 @@ static int lec_vcc_attach(struct atm_vcc static int lec_mcast_attach(struct atm_vcc *vcc, int arg) { - if (arg < 0 || arg >= MAX_LEC_ITF || !dev_lec[arg]) + if (arg < 0 || arg >= MAX_LEC_ITF) + return -EINVAL; + arg = array_index_nospec(arg, MAX_LEC_ITF); + if (!dev_lec[arg]) return -EINVAL; vcc->proto_data = dev_lec[arg]; return lec_mcast_make(netdev_priv(dev_lec[arg]), vcc); @@ -739,6 +742,7 @@ static int lecd_attach(struct atm_vcc *v i = arg; if (arg >= MAX_LEC_ITF) return -EINVAL; + i = array_index_nospec(arg, MAX_LEC_ITF); if (!dev_lec[i]) { int size;