Received: by 10.192.165.148 with SMTP id m20csp4186165imm; Mon, 30 Apr 2018 13:26:39 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqat0iEoOEUfP4mCrY/f3K/SlyzuL8umx+h4lpX1R9v3SaGLZ/FWP3MGn7QOy1DBhSTzoaK X-Received: by 2002:a17:902:bd8b:: with SMTP id q11-v6mr3158697pls.178.1525119999482; Mon, 30 Apr 2018 13:26:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525119999; cv=none; d=google.com; s=arc-20160816; b=Ej1QgJiSco2tvXqdlOxMes6Ua5Whb+4QyPOMQfepFtHu5Ef9MHqKHIe/GKn2uEqDAE 7UNF93dzq1KgjeqsN1PYBKnJTZ5Jmc6grbs4/4L9TILMPa1NVIgpECiFVjzpKi2yVEbd nta6e71BMaqRTMqJsLYgp3pPyHZR/kA7W5jMuAusnjEH6HBQyViIf5WXUIL7mOMrW/2V Acdzzu4ocw2cTAgm7+bJ3lrJrcdBSsuwZriun+rgJxe/pTE1Yth4w/aov23Q1rIksV/6 M6/iaXHzWgN6cooAsirinMkXRoIgJftKAYZRdAB6UIjJCAqftQ4xUJZccFnKPaF5Uw56 oWlQ== 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=8KwZPFSe28Xd8wlxfx2M5ZqXMVJUiQr4zqjXWUi/Gdg=; b=QSIufP7qX0HlrTMP/dE7slrkzoV4PzvH6ldn6xd7blCTnyLH6YqTS8x5o3sKVoXXSO +rqQ8BUbOP+wYiRCGt2yDiRrUImQFfTE+OoIe/nxntjyjmJivQaM5mq8SBzw+7JlTT/J B3d8QHwZ51YE9k+Go+llYrPBsByIFdqEh4WNavRZfaxC9WSndBuNyyjaNEziE6BwqWnv 5AUF/OR19xT9TZbusNaJaQ36VrnjUV3tuviH0zRKkN5nYkW/oSomie+ColIC+Y8gZ+K1 dnrDHf5a/s9gUEGolVRWPg68drRZN7+eGxHSzkjUJNNVnjlyE3JpJfBPQgWeImE+QEys C6pw== 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 h3-v6si6570708pgf.314.2018.04.30.13.26.25; Mon, 30 Apr 2018 13:26:39 -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 S1755650AbeD3T03 (ORCPT + 99 others); Mon, 30 Apr 2018 15:26:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:60120 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754120AbeD3T01 (ORCPT ); Mon, 30 Apr 2018 15:26:27 -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 7E07422E03; Mon, 30 Apr 2018 19:26:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7E07422E03 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 26/61] ALSA: opl3: Hardening for potential Spectre v1 Date: Mon, 30 Apr 2018 12:24:29 -0700 Message-Id: <20180430183953.663995864@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 7f054a5bee0987f1e2d4e59daea462421c76f2cb upstream. As recently Smatch suggested, one place in OPL3 driver may expand the array directly from the user-space value with speculation: sound/drivers/opl3/opl3_synth.c:476 snd_opl3_set_voice() warn: potential spectre issue 'snd_opl3_regmap' 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/drivers/opl3/opl3_synth.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) --- a/sound/drivers/opl3/opl3_synth.c +++ b/sound/drivers/opl3/opl3_synth.c @@ -21,6 +21,7 @@ #include #include +#include #include #include @@ -448,7 +449,7 @@ static int snd_opl3_set_voice(struct snd { unsigned short reg_side; unsigned char op_offset; - unsigned char voice_offset; + unsigned char voice_offset, voice_op; unsigned short opl3_reg; unsigned char reg_val; @@ -473,7 +474,9 @@ static int snd_opl3_set_voice(struct snd voice_offset = voice->voice - MAX_OPL2_VOICES; } /* Get register offset of operator */ - op_offset = snd_opl3_regmap[voice_offset][voice->op]; + voice_offset = array_index_nospec(voice_offset, MAX_OPL2_VOICES); + voice_op = array_index_nospec(voice->op, 4); + op_offset = snd_opl3_regmap[voice_offset][voice_op]; reg_val = 0x00; /* Set amplitude modulation (tremolo) effect */