Received: by 10.192.165.148 with SMTP id m20csp4187037imm; Mon, 30 Apr 2018 13:27:51 -0700 (PDT) X-Google-Smtp-Source: AB8JxZo2tR6z6av/kD7ZKpU0B5uyIUjj7pSfMbo/5RgaGRS0fw7ERcUsl5BAuiK2SPpZCgKSRwLL X-Received: by 2002:a17:902:6a8b:: with SMTP id n11-v6mr13488079plk.36.1525120071702; Mon, 30 Apr 2018 13:27:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525120071; cv=none; d=google.com; s=arc-20160816; b=jeVpEhxBGnwFxgv/hqn1gZmbstt97onGwQiX9A4OKgLJs0EoBBdiTfvgZO9KaZI1V9 FNMkqJEVm21hMbn62ItVrGuRV7wQezPM+ZBqOtlcaWxZKeu3hgR0p1vv9mZ39eI8oPhx ueMHHrWUzofOSWHlI0wXTPLnT65yT1Iqfk9NEDKoaIsq5CPWYuaDoaMVScKOHGAWG+n6 G3qW/uxqWkEE8DV2r8PkrTorkjV2CeZNvd/ih2hbd2Y8nZjdfQfO2Fnzxcf2pPor1RnP sgj6s2zvup4LWtvjHyyRp9WYBgFxasRa35vw/i6/2PA3EC9YN1ZrCKxqqbNZ8nxvEvGB UHDQ== 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=ng9vU5M3GzLhHtECK5iYMD62EqV3dMSxwo0CoqOoU4g=; b=rFVFd0P+pTDng4IEig+cZA0s1ib0KUeaPvFMiAL2yxrdOVBQwpqOzr5AnvPjamvA/P jx4w0GK2ir+aX2qXj1L5ul6ORtLWxMhXbmkaYVbLiD98igJBH6VAmJVU8o8cgF3ljNQG ieeLjTVM2SpFGoi8oVKXFhVTWzSYbwrP5jCWycwAOhpuDWrjao+7aWvceUc4a9jSn2Iq L9UOLv4XtrrEbXZL8UahNE4pbs/jbu6y38jBTV7wAr5bHUyFRS6VWLr74elfH2CBxFeJ XpwuXV3EQkle2hTO9YSRo8BP3pvp2i9A4dlN77wKSUeFj9jVVQ/NXYmrGtjm9ogPPxfG 9kow== 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 u16-v6si1972816pgv.225.2018.04.30.13.27.37; Mon, 30 Apr 2018 13:27:51 -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 S1755809AbeD3U0T (ORCPT + 99 others); Mon, 30 Apr 2018 16:26:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:60202 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755640AbeD3T03 (ORCPT ); Mon, 30 Apr 2018 15:26:29 -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 74C6922E03; Mon, 30 Apr 2018 19:26:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 74C6922E03 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.9 29/61] ALSA: rme9652: Hardening for potential Spectre v1 Date: Mon, 30 Apr 2018 12:24:32 -0700 Message-Id: <20180430183953.884169906@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180430183951.312721450@linuxfoundation.org> References: <20180430183951.312721450@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.9-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;