Received: by 10.192.165.148 with SMTP id m20csp4174542imm; Mon, 30 Apr 2018 13:11:59 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpKi1tynO4Bx/Dkk94IdNXU2Fep3ZD4KY0WI3mDktykedW2AoQW+F7aL6c9Q2XJU/MWTd6O X-Received: by 10.98.108.69 with SMTP id h66mr13150496pfc.43.1525119119163; Mon, 30 Apr 2018 13:11:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525119119; cv=none; d=google.com; s=arc-20160816; b=oZDKOAGPcI7uXaJolOtS1i5pjR1H979CF4XaWTuCZVVfaB0/wZt3fIiQDqqE82OWQ/ H7Qsh55oadc5eBVw94XdE/JxSSbRFV9PHLTx0z3c+yLcruRLgHb9fkr2GZWcxnorHRQ2 XFUWpdGYFykPRhfvgIoW7y9o8Cu9nibmldSRj5YJhPZgEJVAH1Mc3EuzkWYFx3P7BbK6 kGOFQpQhb/ZJ+pvdXxBEohYmintQVZUwXwvIL3TGOc+Hsqo5grBm1I+1UBeuWu+4QKiY 3ZRI/YKaxPEZN93ZlscC/pMZEyup95FVad0O5hFc/e82rnGDHYVLuoQeKK4NAN9zkq7G Zs9g== 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=Cr/xQ1NPAIk1GtPZUYNBNo27oUxoy2J8B1hghssUNO8=; b=DfMTwKLyeykH7cdL19hPWZTB1wIVjEQn/LCo0cLZhLzKDp+JzDN+7LMjs9is4XEguS TEEDz/5cEFYz77WRRDLLhYhD/jC00zRBJDRoyY7Y+EwOyXPOFi17SFYpCuQTTIt6Lnx9 riFYNOA/zboSNV7ShqiDSryw6J2He4yUHk/Fclm8FCe9W/v7AG9QvJOxpcD5k9tNefw/ dHoSepz6XsB1xXu4o7b5VC8L31L2ZQuehGKQM+cpXAK3fHZ5rzdfmoJ8+iqNJe9g5v8Q T+ZM2H5qWwwAPeDNpt/mqfQIg6rdJcetOvI0Zx/6+QxGtuelP8PPxKcQHLCYcW3704ZM p9Pw== 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 k4-v6si6516365pgq.683.2018.04.30.13.11.45; Mon, 30 Apr 2018 13:11:59 -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 S932155AbeD3T1P (ORCPT + 99 others); Mon, 30 Apr 2018 15:27:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:33424 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755883AbeD3T1M (ORCPT ); Mon, 30 Apr 2018 15:27:12 -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 418D522DC1; Mon, 30 Apr 2018 19:27:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 418D522DC1 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 37/91] ALSA: opl3: Hardening for potential Spectre v1 Date: Mon, 30 Apr 2018 12:24:19 -0700 Message-Id: <20180430184006.106444963@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 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 */