Received: by 10.192.165.148 with SMTP id m20csp4176430imm; Mon, 30 Apr 2018 13:14:15 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrG0k/lZ/YxEDS1avjdTK4hCi/ZA40/IfjRRZEFiVpaq1EiaQCpVDd4eTK2M6491xyNLcZH X-Received: by 2002:a17:902:64d0:: with SMTP id y16-v6mr13430898pli.349.1525119255836; Mon, 30 Apr 2018 13:14:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525119255; cv=none; d=google.com; s=arc-20160816; b=pe+oNP5/YgGOWkXlIy5pj82/oDnyVK+YJbCKYifHDB6U30GA+y4/FcoypUabczIJ8E vIN76N8Lx+GeN/IFZQXSuzBY4rj580xL3ZuWUT9Ks9EtQY90KeGbfu+DKNNSgV6ri6i+ 5EMqOp0LzuSj9k82mzVlDARJDpkciMV7Xevxnhlfo50YMIyhbFVE1j6jnr3PRLeegnSi 3FiqRL3S4tunIqT1ulc6NZXjsQ2I2LmHlm7+cjWm74O10EzG+5Ojn1L6BzhbLzXxb6en 3Rnuajmcuc1K3GNAx8N8Lf+PFLqtYQZdBMh9yY7V0sYX0OVdNYqBh1gBK8ugwav0rK4q 00sg== 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=xBw8BUfViPWyQp3CfD4Mu1TqLz343twx/1LKE1MVP28=; b=e2jOS7I7r7jrgk4qvD7GJycBWQZLkygOCySyP/w9/LswNDNCinwDNrfiO/Gu/2xJfO 9hnKknxsv/jw7pBEkPwmtpg9Yz1ZBSD4gUfTUVtTKdr/j6tLuWK/c4M/ZxFHFlm8ZS6g q31R/rMprYNTGD3rTrR89kMmyHLOl4epOEkMBBOc7ad3OVLRDq6VlZjuCxfE+3YNM894 ykXRUGQw462aKy88gaMXl0CP3821FRVLT0GeGNIdax9q62st3dhcRoRLGxMXTzRSapWp jc+B5zsqrv1baoq5cfnENgtlMs0pLDzs5ibVnkHcmJK0QKauHzcV5W68vUvdX8FAwYtC jDLA== 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 g28-v6si8014907plj.529.2018.04.30.13.13.31; Mon, 30 Apr 2018 13:14:15 -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 S1755922AbeD3T1R (ORCPT + 99 others); Mon, 30 Apr 2018 15:27:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:33482 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753482AbeD3T1O (ORCPT ); Mon, 30 Apr 2018 15:27: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 1C6E022E01; Mon, 30 Apr 2018 19:27:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1C6E022E01 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.14 40/91] ALSA: rme9652: Hardening for potential Spectre v1 Date: Mon, 30 Apr 2018 12:24:22 -0700 Message-Id: <20180430184006.262431681@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180430184004.216234025@linuxfoundation.org> References: <20180430184004.216234025@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.14-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;