Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4562733imu; Tue, 29 Jan 2019 03:51:56 -0800 (PST) X-Google-Smtp-Source: ALg8bN7N33HfZzNOFW+Hc812aiHdLxfk3+OSYUO5vYc0kav+wEZEwkaCfR/x6NySW8IAGf8F51DF X-Received: by 2002:a62:2702:: with SMTP id n2mr26427205pfn.29.1548762716076; Tue, 29 Jan 2019 03:51:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548762716; cv=none; d=google.com; s=arc-20160816; b=tkR64gDe3G+cqE2nQdoU7PUCuD6Uo2XdP1279hMdWxEVs5lily9hTxKEUyqBhYvwCR PDp5DFUhGAj5EILy97bqbLctPmFeVEjxzzk9QRxy8QXPFY5UhCIJetKfWePGRcVWWKCC pZ/fcVkEm+Ii7WWElxt+avqDXb6RQJshwylL71fBOjC4cwBHkkxNYOnkU6uUCb+82Qvj 6lq2SeCN8agzCjDKI5bDexsJrJJGTUrASUtM43beTEPG90lGaKlBNb7+lJvglsyGEK37 3n4A4fG6oc5zCOpVlC88eWtHXurMO1hK3RHuKbQthXKzN/DAmfuboGs8VCWpqIhdXRJm jI8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=qQbLiHhQws8d515f7OWW40f/8M5CoizyZO01dungZOA=; b=ZEx6Nje/nAc0fm4FQ4LDNMvI6bweSDkHf3cY3UacRBZCX1SmOtjVysP/KFaT0iTMCG On1xoJrGSQIEVbfAg85C+rI5Qf045keTgEa7GUQmQ5OuNKDjY4xF6SfXJoQpPP9g1CLY Jp8Bpny8l6wBoyad1A2G5kSonSH81MKilWWB8jOVLMoaA2eQx9lzDLIfQ5JbfPJ2OPhe hqR7b7kBeqmn7OWGKxNsB0kveljGO4rNdyvqEl4qQoQaW5CRNnlHsbYS7lRsoopI5bY5 0CVQyWn2cTajDW9cMEwEKYXkhF+AvRiYjDWopog1hUpLTQsRRGhK1WlAdgsaGi9cRcRz Jb/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OzK9qEYJ; 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 p4si8118636pli.432.2019.01.29.03.51.40; Tue, 29 Jan 2019 03:51:56 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=OzK9qEYJ; 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 S1731899AbfA2Lve (ORCPT + 99 others); Tue, 29 Jan 2019 06:51:34 -0500 Received: from mail.kernel.org ([198.145.29.99]:43026 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731889AbfA2Lvb (ORCPT ); Tue, 29 Jan 2019 06:51:31 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (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 E0E4B2086C; Tue, 29 Jan 2019 11:51:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548762690; bh=Nrwdy9u0vK483DrziIXVrZfhNGvu1O+DV6fmbULOYuQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OzK9qEYJnbcvW0NIYD2o+PuomINZOHnd0yM9qMVn9Go33xamAPpOhmYBrxVQ6hX7W NwNX9Bzyt+WMiN8p2JPUXDs46neN22Oa+mwpKF6ch2aZE/3LWO7EL/u+SlI2QB80VO FB1JQGCAsaOkHbQ6+pTcF8kAj1+ZsrpgVDS/Brf4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Gustavo A. R. Silva" Subject: [PATCH 4.9 17/44] char/mwave: fix potential Spectre v1 vulnerability Date: Tue, 29 Jan 2019 12:36:12 +0100 Message-Id: <20190129113141.385394175@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190129113139.826927690@linuxfoundation.org> References: <20190129113139.826927690@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: Gustavo A. R. Silva commit 701956d4018e5d5438570e39e8bda47edd32c489 upstream. ipcnum is indirectly controlled by user-space, hence leading to a potential exploitation of the Spectre variant 1 vulnerability. This issue was detected with the help of Smatch: drivers/char/mwave/mwavedd.c:299 mwave_ioctl() warn: potential spectre issue 'pDrvData->IPCs' [w] (local cap) Fix this by sanitizing ipcnum before using it to index pDrvData->IPCs. Notice that given that speculation windows are large, the policy is to kill the speculation on the first load and not worry if it can be completed with a dependent load/store [1]. [1] https://marc.info/?l=linux-kernel&m=152449131114778&w=2 Cc: stable@vger.kernel.org Signed-off-by: Gustavo A. R. Silva Signed-off-by: Greg Kroah-Hartman --- drivers/char/mwave/mwavedd.c | 7 +++++++ 1 file changed, 7 insertions(+) --- a/drivers/char/mwave/mwavedd.c +++ b/drivers/char/mwave/mwavedd.c @@ -59,6 +59,7 @@ #include #include #include +#include #include "smapi.h" #include "mwavedd.h" #include "3780i.h" @@ -289,6 +290,8 @@ static long mwave_ioctl(struct file *fil ipcnum); return -EINVAL; } + ipcnum = array_index_nospec(ipcnum, + ARRAY_SIZE(pDrvData->IPCs)); PRINTK_3(TRACE_MWAVE, "mwavedd::mwave_ioctl IOCTL_MW_REGISTER_IPC" " ipcnum %x entry usIntCount %x\n", @@ -317,6 +320,8 @@ static long mwave_ioctl(struct file *fil " Invalid ipcnum %x\n", ipcnum); return -EINVAL; } + ipcnum = array_index_nospec(ipcnum, + ARRAY_SIZE(pDrvData->IPCs)); PRINTK_3(TRACE_MWAVE, "mwavedd::mwave_ioctl IOCTL_MW_GET_IPC" " ipcnum %x, usIntCount %x\n", @@ -383,6 +388,8 @@ static long mwave_ioctl(struct file *fil ipcnum); return -EINVAL; } + ipcnum = array_index_nospec(ipcnum, + ARRAY_SIZE(pDrvData->IPCs)); mutex_lock(&mwave_mutex); if (pDrvData->IPCs[ipcnum].bIsEnabled == true) { pDrvData->IPCs[ipcnum].bIsEnabled = false;