Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1776367imm; Thu, 27 Sep 2018 02:16:29 -0700 (PDT) X-Google-Smtp-Source: ACcGV60KcIUDRMPYMMurgQ3FnSMAm6N/THc7q7Ww37mr+f2SSLxWIEjEGZuaDio7iycV1d7WiS1O X-Received: by 2002:a17:902:7c83:: with SMTP id y3-v6mr2531555pll.330.1538039789804; Thu, 27 Sep 2018 02:16:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538039789; cv=none; d=google.com; s=arc-20160816; b=wDll7MsJbfZzjc0/o0p7nBO+IYmbFiAITxmoOD3aBaqSbwusYynAF1aF71V/J1WL7e 8dxpXLCLQT0QoA8O0aHLzhauzmwX6LUXh5RMnfop20xV7uL4WV10LLPseLC9NcfWh5PZ nLgCzZfnUy9PstWVl+Z1gGYwIsMS1+aBtyMnlU2GAAUbTZgsSJpav9+ETHxGZ+DR4KQy 1RrfGpki/fa2E2ULb2OGEZiBuzEXF/refoPeFuwOLgKRylI0rrwxpGeY/pCMUE8TU6aD 2SxC4skja6EyW2TcuYOibQatURWEzdNIzTyLc7t4XRvyXzWloojjnxiQAEl+YPbhxKHR GsAw== 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=RTZIMW7ZLyS9Fqh9xuW/t09zPAgMJNMlSgptgl//El8=; b=g3X8IjhxYwSj3sOYkYiXG1oKaW8xNeSeXPgo/b0ULFlubLKLoBM9LAA+0MNwZIwRka ZO6GLNKZschYU+Ct0RVd5Iz/yFBX5fKTdoNR01cQPrZwC70D4zYzJqwpDOrelwElvYLe vP3MSrPF6hKyyEFgoWiQkKSa0URsSrehio2qeWxmZyIDM7tgmxZJd6dZzX7qfgC9q1i6 S6ZPlMpups+OWIwXHvBhGei8DH17RaPKwd8JzUK0ZKH+o20q6x0gnrZsLOBCCpxI3Aaq QDJXO5sv54Z5Ev1VIuxqeot5Z02QWfs71OjxSZ449CL/eY8Q+h2gTSOQgLuQK/mjOkUa ne0g== 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 s20-v6si1520525pfh.256.2018.09.27.02.16.14; Thu, 27 Sep 2018 02:16:29 -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 S1728436AbeI0PbR (ORCPT + 99 others); Thu, 27 Sep 2018 11:31:17 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:55504 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727404AbeI0PbQ (ORCPT ); Thu, 27 Sep 2018 11:31:16 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id B6FB91117; Thu, 27 Sep 2018 09:13:59 +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.18 75/88] tty: vt_ioctl: fix potential Spectre v1 Date: Thu, 27 Sep 2018 11:03:56 +0200 Message-Id: <20180927090309.724692356@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180927090300.631426620@linuxfoundation.org> References: <20180927090300.631426620@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.18-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);