Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1781948imm; Thu, 27 Sep 2018 02:22:49 -0700 (PDT) X-Google-Smtp-Source: ACcGV63JBsqLjx03moEGxaakYvCBMEV8faDxljjopNwv8VMDMHqzph9l+YtxNA2XN8zInHVSIner X-Received: by 2002:a17:902:6bc5:: with SMTP id m5-v6mr9858443plt.274.1538040169412; Thu, 27 Sep 2018 02:22:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538040169; cv=none; d=google.com; s=arc-20160816; b=bMOX3iFkfTvwewUZ3Ay+NF3RkxmjIG7jFDjR5ZkDQclZqoYIcaLCG86XMHm4s5tGpm tJ87rnMHEbbXu0jlDblUm/pXTgdVV2IxewxKAyzN2+DmQHsasUx9n4q5BzkXlAlEVDLj mCwaM9YPHS3br5E5FCMqdnGh8ckOd2SpZLwn3ptOzGwSPdCkYYASyMFuhLMYQVPhYvnm xJ0rTTAFdylyka6WPONyXcmCPYPVBTnijQKdyQ24YKOQjyf/zyId+e4mTY6AIu/6Fq9m ijJ0UZvjSKe1fNozMzwY2HuLHQ8N2Q+/WN/M4o9uBbcZRkZoKW3uK+NxnbxQcpFOe1ZV 3lrg== 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; bh=c9/5C0HDb242mP+k3OTvhZf6oywSZXPDYK4eIAF2lCE=; b=jentokYg1F5ntfCukteQeVL8q6xpjzeI9Oyrleex6h8pelMJI0alL9O2XiHH1pps8S lrmgxd5UFN0SrQLNwIq/radfrAQ3uL4YLZr5eszR7dpIPRe8TKI45PRwfc670nx6qBx3 0mLdcVl3iPtUJdt7XDphq/dYG1l45z1d1ACQ0iApcsd9cQ1328KKIq9MsiKUEEC+dzzY vRCrOOpVMhvZAX/O0lgoUgh03VVXf/OxE79C6ZQRM2KjLEsWzEsJmls5i3Ei6RqYbbL9 f1/9cSIcHK/GrMCUfvdHFxeFKg8p6uWXRTdzboWstt+2A6tVjyrbQZGYqe8Pt3AIQ5cE +I6w== 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 97-v6si1606266pld.124.2018.09.27.02.22.34; Thu, 27 Sep 2018 02:22:49 -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 S1728117AbeI0Pjt (ORCPT + 99 others); Thu, 27 Sep 2018 11:39:49 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:56498 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727057AbeI0Pjs (ORCPT ); Thu, 27 Sep 2018 11:39:48 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 2CD601072; Thu, 27 Sep 2018 09:22:28 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Gustavo A. R. Silva" , Alan Cox Subject: [PATCH 4.14 50/64] tty: vt_ioctl: fix potential Spectre v1 Date: Thu, 27 Sep 2018 11:04:07 +0200 Message-Id: <20180927090256.998011927@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180927090249.801943776@linuxfoundation.org> References: <20180927090249.801943776@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Gustavo A. R. Silva commit e97267cb4d1ee01ca0929638ec0fcbb0904f903d upstream. vsa.console 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/tty/vt/vt_ioctl.c:711 vt_ioctl() warn: potential spectre issue 'vc_cons' [r] Fix this by sanitizing vsa.console before using it to index vc_cons 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 Reviewed-by: Alan Cox Signed-off-by: Greg Kroah-Hartman --- drivers/tty/vt/vt_ioctl.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/drivers/tty/vt/vt_ioctl.c +++ b/drivers/tty/vt/vt_ioctl.c @@ -32,6 +32,8 @@ #include #include +#include + #include #include #include @@ -700,6 +702,8 @@ int vt_ioctl(struct tty_struct *tty, if (vsa.console == 0 || vsa.console > MAX_NR_CONSOLES) ret = -ENXIO; else { + vsa.console = array_index_nospec(vsa.console, + MAX_NR_CONSOLES + 1); vsa.console--; console_lock(); ret = vc_allocate(vsa.console);