Received: by 10.192.165.148 with SMTP id m20csp4191572imm; Mon, 30 Apr 2018 13:32:53 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqbqlrQnOsAXQ1u8ZGAb85oSiLlUphefN4JvJ6w1V9IF1gPEKxdXV/1ZOyM8n4UDDL5vKi6 X-Received: by 2002:a65:4c4f:: with SMTP id l15-v6mr11128236pgr.61.1525120373116; Mon, 30 Apr 2018 13:32:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525120373; cv=none; d=google.com; s=arc-20160816; b=REFBZet+2xiT2mSrNUVYacu4CtMRBUq9tCMdyZx0C3TNiWS3QIxvij8uTNqv+HHkyH wPEy7dHyNdgtZ7kSv87MrQ2vj3Wd9foWQtQkrzUfJrE38NFyoGig+/sPBalPgq6Rj9aE oVA+5skea0mORqL/BIr2CfYXMRQ9BflqI+IMr5k9sDXruUnHTEUvp7RiHsSWr0n0uWJP 2hf3uq2w+KfcjWqqbq3JmT7CFQOrrJ83dMzdXoUW+Nm42UjNAGkT1feldoKFQsX/x3k+ e75GTQzpLPhwvGrDe/4dvg4rCPGqg5cl69+lZgdFIc2tTrvSPd0r/oy0j2q5Kdu6sn1T OTcg== 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=ihgVskkEh2dApA7/XQ3roK45SHLuvI1Toq5pwxrqeaA=; b=DsieGKJf6iO5HUP09GD7hFa1xdowUiPoeWVhlpRag9Adz281fZmpV+JIrZ9ZhUSQO/ ZK6BK3d9Ph30JwsFNvGA8Pq8SG2KHVgVNr9ANMMPAcIhMyMzBhT2OykQplqkcpynC4Uv rP2H1KOWPT9zExAgY1ygue0MKKMYqDBvZ4YJUY+aGAgtUYVvZWhdUIA98vusSB3eAtQc F7ZMSMcpDNgQ8xAP5kD760M7Of2tHeTnS/ucIajNbCSBRMMbyuPgHaOyhglpsOUth9MS jvvFD7rZO4k2JwFy0lKnMLlmWvoBBGFQunVFV3tnY9FTygyJCfAqO/nzrCH8WZQ/6i5M pHLA== 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 y1-v6si6677833pge.198.2018.04.30.13.32.38; Mon, 30 Apr 2018 13:32: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 S1755788AbeD3UbY (ORCPT + 99 others); Mon, 30 Apr 2018 16:31:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:59486 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755517AbeD3T0J (ORCPT ); Mon, 30 Apr 2018 15:26:09 -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 D302022DAE; Mon, 30 Apr 2018 19:26:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D302022DAE 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 20/44] ALSA: opl3: Hardening for potential Spectre v1 Date: Mon, 30 Apr 2018 12:24:31 -0700 Message-Id: <20180430190947.152790912@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 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 */