Received: by 10.192.165.148 with SMTP id m20csp4190704imm; Mon, 30 Apr 2018 13:31:53 -0700 (PDT) X-Google-Smtp-Source: AB8JxZo8UPG3beTwm3zKfwWlc3u82smPV+3cp3EAjyoQf20kIQmNBRA7GZCy37XeyFb136axAp1H X-Received: by 2002:a65:4309:: with SMTP id j9-v6mr10867601pgq.375.1525120313715; Mon, 30 Apr 2018 13:31:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525120313; cv=none; d=google.com; s=arc-20160816; b=k5I2M3ttUgNaO6gAVJSNl/qEVUNKfn9DD2r3kTEwJXjlaQhMYlx2ydCQCgjW2SiybN R5Fo5a/DWvAt85TmgCDRjCokhDGSMfOYl+u8hq9/hdBnq4xsbrUOQTk4GBegguQkYR+7 1gX4LuaLaRh8bAbdeOSGY5Oms9dZgSzrPeqt5nEL6uVXsmrty67aCf5oeTe3m2KzT/oU aQOr12rl4AsDinDtp54N+UEeKSNuMWmz26fhUqy6km0HDU6OWoGnf6pj0Tevr3NCGa8u N7QRPspOrhAUuAPKKNYBdSbp6SROKXVw/Mg7LchljYe7LmRztth4PKOQqRsgkHsQlqjj hH1w== 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=0518rMqu1KG5bPoiHuzW/uxqTPvRmuaQ2/T/OK50gZo=; b=rK5MQ1XZ4cU6208wfBsgrGNKlmWPbYvotyiSBONPLZR4jVwLtq/SQwNUMf/bskycAb nccUPJ9qkr4uDGBrqjVOUQ+laQpgGvskJzhmtNkE8IO8HktrXeDq8or1vH7pfM0pmW/e 1oIOCLrLFucP7VeXxE2pdUpoSHAbquivwjIMfzMWjivjaW1FyOqjGegbiRJXS9nOooCS SLf2ZId9+26LuPrZb1Iz7mOLp0MI1CZNmPuAOnpFhWcEiY4ImAfR0ecTdK9R/uN2TK5n v9C6xngxWJpKOOyYn/GXNNnJogWn1isA4iO5XMN1qKJZwpJgWd/UptJCS+QIztuVFJjr f7lg== 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 k17si254986pfj.310.2018.04.30.13.31.09; Mon, 30 Apr 2018 13:31:53 -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 S1755759AbeD3Ua7 (ORCPT + 99 others); Mon, 30 Apr 2018 16:30:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:59568 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755217AbeD3T0N (ORCPT ); Mon, 30 Apr 2018 15:26:13 -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 A813322DAE; Mon, 30 Apr 2018 19:26:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A813322DAE 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.4 23/44] ALSA: rme9652: Hardening for potential Spectre v1 Date: Mon, 30 Apr 2018 12:24:34 -0700 Message-Id: <20180430190947.269049780@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180430190946.093694747@linuxfoundation.org> References: <20180430190946.093694747@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.4-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 @@ -2036,9 +2037,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;