Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1171291yba; Wed, 24 Apr 2019 16:41:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqyRa8smXK30ePKpF5CAr1HfKIHc3+11CqfvakMkIqpZkfvIh7azc0fItn8dtsRuOnHKUi8f X-Received: by 2002:a17:902:aa91:: with SMTP id d17mr34988411plr.43.1556149264391; Wed, 24 Apr 2019 16:41:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556149264; cv=none; d=google.com; s=arc-20160816; b=LjNdQFxn5JQiTbAi4pV75pdzLGQ40f8ytdmmBJlwHpOIWhBnSzvjaqkevE0Fhf4I2x WH8sDlSqO83kT8cpmn99/vkycg+a4z3gr8why03WbxyMHyWGBq6cdSOV1acCsbpYc8Uw fB+xG9NRhglrCNqrNGmFC3WEr7MIe1PcS8UfEmAKNlhNDRYzj2wV0BQ/kNEu8nON6cnj XjjF4c3dwo5c49WB+nv19WEDw6lAWJ7+oecoOTM6JhA1ZUOZ5BcTVTEswJDvOAWe/CFR Q/FQc2RxkqagCtpi4VHabehWIOcHM6uJchb+N0glNHOcmNwNhcViwSZMkFVXxm+acEhY Surw== 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=hrVrvoAx+ekRXfNYLyG/+E6eHRC+pTXl556ioG8bXDw=; b=R4+cjgdI4zwmKaynLdQsEdzzx1PVZasXwBCAnaT55gEV5SPVyu7jhZ9znDuJFHw4OT M1lG7iKgRfTzXJs+3upb1gjgaKz4fnWYIa3N1qO62nVOwNjbsr0pGHVMqaH2dgEVFdAF 7HbHTAkYL3wneiuoIDqeMm5BSWHLnz1qB/4kBOqZFrRnUEX0bxe1v7W/z1+vMO0J3lHd TkMkhyYdLV8TtYwAbRFaupT6MgtVvqs5EyO7q6+79QGyHpNb0+ktbgIXCdmoTEsN80+o nLzTwlRzz9ydAqhuV1SVH6MAUbMv/LQJDLVFEIq16OTeEO6NuaOrfvEeUzE9eOetrcLg b80A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uKidOHsi; 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 j127si21820434pfb.25.2019.04.24.16.40.48; Wed, 24 Apr 2019 16:41:04 -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=uKidOHsi; 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 S2391671AbfDXReP (ORCPT + 99 others); Wed, 24 Apr 2019 13:34:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:33034 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391656AbfDXReL (ORCPT ); Wed, 24 Apr 2019 13:34:11 -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 F20252054F; Wed, 24 Apr 2019 17:34:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556127250; bh=xVPnCDpvjq+4f8yvQyjOEVXBiQ/TucphsaCudmWFGGw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uKidOHsijiIfRbNulFSA6Ld5u2Mm54a62y7OGMZDHXdxMZ5JgPgtCg2CIpmvdx/+c xiEvwlrhlteUfZB6I+w9Vqewi9UZA9H62MNRIv9YFwX2bb/l3Bi5ykqMxfk0NRjvIE LyZeiaL8SlK6wbYvIEXy/TLsGhYRs9OA3Ct8dyf0= 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 5.0 003/115] net: atm: Fix potential Spectre v1 vulnerabilities Date: Wed, 24 Apr 2019 19:08:59 +0200 Message-Id: <20190424170925.112729845@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190424170924.797924502@linuxfoundation.org> References: <20190424170924.797924502@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 @@ -710,7 +710,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); @@ -728,6 +731,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;