Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3698213imu; Mon, 7 Jan 2019 07:57:20 -0800 (PST) X-Google-Smtp-Source: ALg8bN7OZwrZCbvr/epUSB2FioHarFnvWHlscf1H9oIZWLVMk9rcBB+pAZsdGfcfWuy7AQWVJ+sM X-Received: by 2002:a17:902:1e9:: with SMTP id b96mr61912242plb.150.1546876639947; Mon, 07 Jan 2019 07:57:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546876639; cv=none; d=google.com; s=arc-20160816; b=veYWWyx/5w+y0QHrYY4l6ThBjIVIKVR1vVa8/J6kygilEiEHp0DekQeL26dyGDQ2KG 1gUF5KlEqXBY2ALM8YvdiPCQZdMeO8O2AXZjVXYQRFTXGxD7+XwTsuNNeCPj1KItnX13 3Cl2Q5K/a9jwn1Zmyt4/P0sZ2vDQeJo6Pe2qLRfMfr15jOiwAaUqQWEwt+pCofLbS82N lPJ67U3H3eIvBWYForJbvRr/hn76pLAk1sdx8hlM5UwrNaCSshTuH5HgfJbTtKUgkSye HQctqxcxBRU6j5Gdz2fdZjzHYg5o1a36Nw4kXlCYfiBrSWFnhOxCuPoWd1Ni9av6+vC/ K3mw== 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=K7ClnCgOa+plZWodCXxv2QXsaPmOl99gQXrfB8Z5Y8Y=; b=qKBz4A73NHwTtB1JjT1I++bs4Edk42FOKqdqTIj53rUy+K/S8C9i1magt6YJDA+trw sPWfXAVsV0rnAlSu2beaACVZ4rB3VaQqRZMrpty8srmU28NxUrwX//fnr4lW9lhKkHhP PMvx4lzFpspOOCULFCWUMVkABTOBo3VkIWZDcNr8/Pj7eYgCIlHMpqy6XhiCmngln4oQ J6Yi6lS7OdLixgE99HV7Z/+MUKvJ1hU3yRCeHpheQNsbEEiM86QaXUPTXECaWGv+ObTt fwnkzyq5ZpLCEbS4t6mHHRkqXlx7PtWT22zu28lhTio4NZCee4As+9N5PWwBwS2LOJZ8 kS9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=XbVh8lln; 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 w12si17677811ply.404.2019.01.07.07.57.04; Mon, 07 Jan 2019 07:57:19 -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=XbVh8lln; 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 S1727303AbfAGMei (ORCPT + 99 others); Mon, 7 Jan 2019 07:34:38 -0500 Received: from mail.kernel.org ([198.145.29.99]:47014 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727273AbfAGMed (ORCPT ); Mon, 7 Jan 2019 07:34:33 -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 9195C217D4; Mon, 7 Jan 2019 12:34:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1546864473; bh=uPMU5OdZMfKhH0Tn5DfiVlRy+/d4oEbRIt5htITOVqY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XbVh8llntXO8DYamAmkzwYh+wBt5w/H23vlAgKd8+wc/WJx/LFjuoWu6LnBEwYPQz z7uiiZgKdOw53DCJJezlfEvvn+gpAGBW7tycfvGN3Gzj4RTYZ+UGi+D+dU7fY0z/HJ tTLHH60U9a4g+Cs1Ao5LjGEtUSOAjNdF3Pos4bgs= 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.20 023/145] ALSA: pcm: Fix potential Spectre v1 vulnerability Date: Mon, 7 Jan 2019 13:31:00 +0100 Message-Id: <20190107104440.359498680@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 commit 94ffb030b6d31ec840bb811be455dd2e26a4f43e upstream. stream 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/core/pcm.c:140 snd_pcm_control_ioctl() warn: potential spectre issue 'pcm->streams' [r] (local cap) Fix this by sanitizing stream before using it to index pcm->streams 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 Cc: stable@vger.kernel.org Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- sound/core/pcm.c | 2 ++ 1 file changed, 2 insertions(+) --- a/sound/core/pcm.c +++ b/sound/core/pcm.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -129,6 +130,7 @@ static int snd_pcm_control_ioctl(struct return -EFAULT; if (stream < 0 || stream > 1) return -EINVAL; + stream = array_index_nospec(stream, 2); if (get_user(subdevice, &info->subdevice)) return -EFAULT; mutex_lock(®ister_mutex);