Received: by 2002:a17:90a:1609:0:0:0:0 with SMTP id n9csp849911pja; Wed, 1 Apr 2020 09:49:10 -0700 (PDT) X-Google-Smtp-Source: APiQypLcr/MOcwSCEqveGUAkTge04M+mB9hGfuKsmU79HLYpRJKFzWbEXfp0ICqd319M7B+ImdWy X-Received: by 2002:aca:a857:: with SMTP id r84mr3552807oie.65.1585759750629; Wed, 01 Apr 2020 09:49:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585759750; cv=none; d=google.com; s=arc-20160816; b=OGcgQYvGugbbhFb4krhREM1j17ls7OCSOIvRSQUtkW87e1zlwWJ+Sitot073nJU3b7 uKIal31+sN55eCpUiFtmzcMOs9kPn0K/z1yO5aB69zp4itdrl2ZrRKhZh2tdpTSbSDhh aOG/ZFlGpcMqZ26lTBItEoBt943U3RCpZ3Z8R9C9QQFQpY5R0AnhBvbVS33gzUhnsjVR A0CMb0qsqEDJY2Vva22uqLPFPqmUYwP8dZM7r9qPgCl496ZnN9aonDVyaxT67Z03+Bee 7sOhkhyeLcCT+pZmTTLXgkeZtriHDsSmtRRY8oCZ+iw9taC+V5qxlEeSL/AWl74O5tzk DKlw== 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=TNqUPPs89o4i0TrAq47yg+On913zHdp/ppRc0FP8ltE=; b=vqiK4JK5rZ8Jy1b9aGJ4wOjxtTqsNQYT5iN/ZxcFlUN1kjDldOGUMlhLmT5//WF0qV PC9GSG73Nnve/5bjiMis0a4PB96YWiWf5NhR8HM4hE1nd3AYJCUGdJp5Re6p95q+8ska mGV9Nk++U1ViKUyr+1nRKnlLKZhWGp3eZ7TsCVVHEdVqFQ+IUowwk1ByrZqgXzLqmdTm DVfl2sx7GNhV82dsYoaNcLWqwElERJ2PyUYNqwNo9+bQHsbCqpAweDOLOKGHv8PD6iO4 m04kAPrU6oYz1RIX500yHiMseICqXqIU8I23b1tpSWWduqLSO+XUQFLedUg/V/iOiKDY nKiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rIKVgK74; 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 141si1022443oii.44.2020.04.01.09.48.58; Wed, 01 Apr 2020 09:49:10 -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; dkim=pass header.i=@kernel.org header.s=default header.b=rIKVgK74; 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 S2387690AbgDAQqw (ORCPT + 99 others); Wed, 1 Apr 2020 12:46:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:48390 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389993AbgDAQqv (ORCPT ); Wed, 1 Apr 2020 12:46:51 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.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 DE44620784; Wed, 1 Apr 2020 16:46:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585759610; bh=9/GVYEdPPBR2AV0UCFVKcd7QD1qTeXd0Zbj4nmO0Pls=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rIKVgK74JXblWiN+wYo7wNNS+ZkACleesRvtZXEm28Uvs8LIOEpT+48dkia6+YjNn ARP11naS9XhVnM50UDjKPSeM95JN6kak55Gkk52tMqlLhfxWjhBjxzUxY1iSp4CwpU 2WJJEZLoAb08RHDZhyOWLaRxMYwXYdMGoU5LHvzo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Biggers Subject: [PATCH 4.14 135/148] vt: vt_ioctl: remove unnecessary console allocation checks Date: Wed, 1 Apr 2020 18:18:47 +0200 Message-Id: <20200401161605.247003463@linuxfoundation.org> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200401161552.245876366@linuxfoundation.org> References: <20200401161552.245876366@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Eric Biggers commit 1aa6e058dd6cd04471b1f21298270014daf48ac9 upstream. The vc_cons_allocated() checks in vt_ioctl() and vt_compat_ioctl() are unnecessary because they can only be reached by calling ioctl() on an open tty, which implies the corresponding virtual console is allocated. And even if the virtual console *could* be freed concurrently, then these checks would be broken since they aren't done under console_lock, and the vc_data is dereferenced before them anyway. So, remove these unneeded checks to avoid confusion. Signed-off-by: Eric Biggers Link: https://lore.kernel.org/r/20200224080326.295046-1-ebiggers@kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/tty/vt/vt_ioctl.c | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) --- a/drivers/tty/vt/vt_ioctl.c +++ b/drivers/tty/vt/vt_ioctl.c @@ -350,22 +350,13 @@ int vt_ioctl(struct tty_struct *tty, { struct vc_data *vc = tty->driver_data; struct console_font_op op; /* used in multiple places here */ - unsigned int console; + unsigned int console = vc->vc_num; unsigned char ucval; unsigned int uival; void __user *up = (void __user *)arg; int i, perm; int ret = 0; - console = vc->vc_num; - - - if (!vc_cons_allocated(console)) { /* impossible? */ - ret = -ENOIOCTLCMD; - goto out; - } - - /* * To have permissions to do most of the vt ioctls, we either have * to be the owner of the tty, or have CAP_SYS_TTY_CONFIG. @@ -1195,18 +1186,10 @@ long vt_compat_ioctl(struct tty_struct * { struct vc_data *vc = tty->driver_data; struct console_font_op op; /* used in multiple places here */ - unsigned int console; void __user *up = (void __user *)arg; int perm; int ret = 0; - console = vc->vc_num; - - if (!vc_cons_allocated(console)) { /* impossible? */ - ret = -ENOIOCTLCMD; - goto out; - } - /* * To have permissions to do most of the vt ioctls, we either have * to be the owner of the tty, or have CAP_SYS_TTY_CONFIG. @@ -1266,7 +1249,7 @@ long vt_compat_ioctl(struct tty_struct * arg = (unsigned long)compat_ptr(arg); goto fallback; } -out: + return ret; fallback: