Received: by 10.192.165.148 with SMTP id m20csp4153608imm; Mon, 30 Apr 2018 12:47:10 -0700 (PDT) X-Google-Smtp-Source: AB8JxZq6H8OzEnBoYuReVVIjX7tx3bNGL7vjr0MTSMQqRgqSNn0B0VfyBgJF6S6MWH114XIAvjSB X-Received: by 10.98.217.5 with SMTP id s5mr13278331pfg.20.1525117630916; Mon, 30 Apr 2018 12:47:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525117630; cv=none; d=google.com; s=arc-20160816; b=cnWq89bwx1bYZmM5OcYAmX5jIUJHPY/zCckbloDSiJ5PugOGjrx9IUnsoG3x8kHUdk jNZufisX2w5fu4C1/DW2Wjt+ubW6FnN9jdDQ2/PaLagdcUl/hmEVCZkjZJ/iGQfd19Z8 JQm2kxGtUVjU6wQU/YMMVpFCX2splAQ2F/SNrMASbTSjrXOcRRHN6UnHThlyvq2VSub0 2RkKJwV4fdNm15xo0gqyRIoPITq8zFMQQzAmgIXjWnu/tRohU8soKLYm7TqmM+1iIa43 GWBBvA4oaExGHW8H1+agSNhgGzJ3kmtsBElvxHVVfKtPO1/pYh+w0k7sCwaVyeKgCE2T 81tg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dmarc-filter :arc-authentication-results; bh=GVxOIDHi+K6xlg+Wj3xP4gUGFSY8inCHN5ClMbD2kaE=; b=WBzVVEAZnJvwDkmKauvWJZPXZDRyrXjESdcA4Rez477ZN7Egw/+sENLEsEueielAKM oEKNkMGgr+n9cBBEMEert0hom4NxyEqTfw9V1xeV1qIxE1i5G1TjCa0Q9BeqsR39hGbf nhXOJOV840VBVu2iDzhfwjM4MUbM3Vi1wyCarBO8/Ezpz/oD7MxMDzSbP9K3FrPuWOZ0 bmnrQBbTMk8vycO0E6phvLYHO7ISji6MMaoDwXrjC06tGMPHn0YBj0VNuMYUXb3YkaB0 UunNHUccPBmLFJyAKcLqT4hlu55ZQCM6XBnSzyjCh4RmmzsTmy7HOHWZJKOHbPoJdmQd sAiA== ARC-Authentication-Results: i=1; mx.google.com; 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 d9-v6si6686779pga.192.2018.04.30.12.46.56; Mon, 30 Apr 2018 12:47:10 -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; 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 S932250AbeD3T2V (ORCPT + 99 others); Mon, 30 Apr 2018 15:28:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:35720 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755602AbeD3T2O (ORCPT ); Mon, 30 Apr 2018 15:28:14 -0400 Received: from localhost (unknown [104.132.1.102]) (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 1DD5B22DC1; Mon, 30 Apr 2018 19:28:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1DD5B22DC1 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: mail.kernel.org; spf=fail smtp.mailfrom=gregkh@linuxfoundation.org From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Takashi Iwai Subject: [PATCH 4.16 044/113] ALSA: rme9652: Hardening for potential Spectre v1 Date: Mon, 30 Apr 2018 12:24:15 -0700 Message-Id: <20180430184016.910864220@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180430184015.043892819@linuxfoundation.org> References: <20180430184015.043892819@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Takashi Iwai commit f526afcd8f71945c23ce581d7864ace93de8a4f7 upstream. As recently Smatch suggested, one place in RME9652 driver may expand the array directly from the user-space value with speculation: sound/pci/rme9652/rme9652.c:2074 snd_rme9652_channel_info() warn: potential spectre issue 'rme9652->channel_map' (local cap) This patch puts array_index_nospec() for hardening against it. BugLink: https://marc.info/?l=linux-kernel&m=152411496503418&w=2 Reported-by: Dan Carpenter Cc: Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- sound/pci/rme9652/rme9652.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/sound/pci/rme9652/rme9652.c +++ b/sound/pci/rme9652/rme9652.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -2071,9 +2072,10 @@ static int snd_rme9652_channel_info(stru if (snd_BUG_ON(info->channel >= RME9652_NCHANNELS)) return -EINVAL; - if ((chn = rme9652->channel_map[info->channel]) < 0) { + chn = rme9652->channel_map[array_index_nospec(info->channel, + RME9652_NCHANNELS)]; + if (chn < 0) return -EINVAL; - } info->offset = chn * RME9652_CHANNEL_BUFFER_BYTES; info->first = 0;