Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3525598imu; Mon, 7 Jan 2019 05:05:56 -0800 (PST) X-Google-Smtp-Source: AFSGD/VpTZtyvg86F2whdKh5nUQpgaThaRy1PknyRTKbvrIDTMgwhpNV2WDug231BW0TNRpcatHz X-Received: by 2002:a62:546:: with SMTP id 67mr61634003pff.99.1546866356544; Mon, 07 Jan 2019 05:05:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546866356; cv=none; d=google.com; s=arc-20160816; b=N0c72jmnNf1jWT+Xct5af+pTC7EOMZFC4mTbDBucxi0FijU+zaR5GHznqwLit5ehKx syJEqL0jBz6ALuqpgq6tk2yxqRI8Elb/cxtmYN+Czjw7Ipy+lujKwRNtdp2d1OZTjJcg 2RUArZor7buPuK8EspXRpmHwD0ClrO9TIEUvJApJTZ2Kq+akTzFbOqkKiYztWEAQ1zaF ApfTPv5eWOPXXyKL/PQT+I/v3cheeSGIFambqFqUNkHAOZplp2esP5kmnKnwzdWI9/54 G8caKWWG1NT4eE4yG9Z6Ua5J+a50vikRJfcXnUREC6iEkh1d7CFscHfXhwdrjVuvfDzw SmWA== 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=5ll3KXo7mV052DURnGPNyHnYX15jaxr0XiSiwVthXew=; b=hLTM+tzMu3tuLOppDlPNtgnlyqb9j2KOgYWi2a2IgbSC0fkrqrbpyRoIJtXe75KsnP sK8xaS5IUkGuQHOivTDDIFVGN4MIuK09KNlNUDpcIQ8lZCY/0tCyuqkYpcKYeb9meEkX 2tqxT+R/aDcliNc+9blu4YE5YRgMA3EHpdZR+UIVoQC93wAa0RbeB0Vz3+7dG9EjiJNQ lJzlUrbZf9wxI8wQ0aQcbtiL6rVNNiWkPEKvnlY9ZlxRwMSvEHak5vnzcc3QkUGSAIIV teTNJ8E2vxGiT6u9Q+HCYHekoTRktXtPB+99kQAgh+Xokk7Oc2ayWkUN5QUpkJSYwkp5 +4yQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jTkAMS5Q; 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 g124si989369pgc.568.2019.01.07.05.05.41; Mon, 07 Jan 2019 05:05:56 -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=jTkAMS5Q; 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 S1727355AbfAGNDn (ORCPT + 99 others); Mon, 7 Jan 2019 08:03:43 -0500 Received: from mail.kernel.org ([198.145.29.99]:51152 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731045AbfAGNDl (ORCPT ); Mon, 7 Jan 2019 08:03:41 -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 27101206BB; Mon, 7 Jan 2019 13:03:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1546866220; bh=s7c7C+w2nt06au10LKZ+XwRkweQv0/rMu3+k72A1zlY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jTkAMS5QDTiCFmHJZF3GF9RFjdKEXhQ21xxfv4ro7celZGKB9FgeAJo7LsyMLvHLg Whn12RAvo9BoQOhpLH0szEAabqJtA+iJH7WrMgBh/cLG7/Nwahno0TNKJp2FKPs8LM BNoWFo0LSFfigIgZiojs2eE5NPMUstqve6Y4w/dA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Gustavo A. R. Silva" , Takashi Iwai Subject: [PATCH 4.14 039/101] ALSA: emu10k1: Fix potential Spectre v1 vulnerabilities Date: Mon, 7 Jan 2019 13:32:27 +0100 Message-Id: <20190107105335.053797714@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190107105330.372621917@linuxfoundation.org> References: <20190107105330.372621917@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.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Gustavo A. R. Silva commit 5ae4f61f012a097df93de2285070ec8e34716d29 upstream. ipcm->substream 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: sound/pci/emu10k1/emufx.c:1031 snd_emu10k1_ipcm_poke() warn: potential spectre issue 'emu->fx8010.pcm' [r] (local cap) sound/pci/emu10k1/emufx.c:1075 snd_emu10k1_ipcm_peek() warn: potential spectre issue 'emu->fx8010.pcm' [r] (local cap) Fix this by sanitizing ipcm->substream before using it to index emu->fx8010.pcm 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 Cc: stable@vger.kernel.org Signed-off-by: Gustavo A. R. Silva Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- sound/pci/emu10k1/emufx.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/sound/pci/emu10k1/emufx.c +++ b/sound/pci/emu10k1/emufx.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -1033,6 +1034,8 @@ static int snd_emu10k1_ipcm_poke(struct if (ipcm->substream >= EMU10K1_FX8010_PCM_COUNT) return -EINVAL; + ipcm->substream = array_index_nospec(ipcm->substream, + EMU10K1_FX8010_PCM_COUNT); if (ipcm->channels > 32) return -EINVAL; pcm = &emu->fx8010.pcm[ipcm->substream]; @@ -1079,6 +1082,8 @@ static int snd_emu10k1_ipcm_peek(struct if (ipcm->substream >= EMU10K1_FX8010_PCM_COUNT) return -EINVAL; + ipcm->substream = array_index_nospec(ipcm->substream, + EMU10K1_FX8010_PCM_COUNT); pcm = &emu->fx8010.pcm[ipcm->substream]; mutex_lock(&emu->fx8010.lock); spin_lock_irq(&emu->reg_lock);