Received: by 2002:a17:90a:1609:0:0:0:0 with SMTP id n9csp836842pja; Wed, 1 Apr 2020 09:35:22 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtwekDCwqXD8JJAwS52N+jL4Xa7ndc8gzFVsBijjz5cgUWIBy8qwbwfoAplesXizcsbBEFf X-Received: by 2002:a9d:220e:: with SMTP id o14mr7407915ota.88.1585758922299; Wed, 01 Apr 2020 09:35:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585758922; cv=none; d=google.com; s=arc-20160816; b=i9mDyCafSkKFDOQaSQ6usFHGjNwRwwt3im0cQwQW5SxkmSQqBk5E19KHVOidqkwNnp btoBDtlj5mbNQeQqOMSQKDBn159wTHACoYNYhMHSCh3LJuiDmrql87kGStsKP5x5yQ3D XwwL2OCl57NtThUO2VKPW3AzaHLnOzirbENpEBFn5KoQE3xQ/fM3R3TIGxpUbhnbV0MQ fcKIwoPoEClgF4e0gSnjjh3G6iPMGHFJ+5TstDufB+XCe6wO9BW4kf/aa/78iTCi5krx xYQN8XFDFGsXXPQQ8UPHavMJIpqDbuATglqgijk8t1SeUBMCQPnRF1A9WrjOocaZ/u5X T+7Q== 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=3D6cWGc0gr/zU8GQ2EVUPCdMnVfHfghhASDIJdiwLLA=; b=YKVwjQN+gVuPC3vF24W6MASxNaY/rGENM/GkkIsT3HduuyaDuUmxRrsa4BfUKjjH0p ARKrAg3JWQJmjZ3JRHBLd9vlkaYoZvmhMQF9pI1434uJEp0H8ogk8frznsYldyq2v6vf Ar5Ol/FWUygL4Rent649m6264wOThnnFCJEsWI6cuhwv6kLGec+gxpwJVZlmkLEz9ofE J1tzw1mdWQGCWrffBtk4s4iWw7mjzQFRJG2JDnIVFJ6RSokIFkRk3GIfJlxSDzhf403h 7VNECtdzjc+ULFicZNMRf26ppos2N3nN8iwyeeTCV8nYKqL5q3XHl6xfAZt3KKnjFxap hQ/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=XmLwIOKc; 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 t6si1109666oib.255.2020.04.01.09.35.09; Wed, 01 Apr 2020 09:35:22 -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=XmLwIOKc; 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 S2388580AbgDAQdl (ORCPT + 99 others); Wed, 1 Apr 2020 12:33:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:60274 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388573AbgDAQdk (ORCPT ); Wed, 1 Apr 2020 12:33:40 -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 DD19520658; Wed, 1 Apr 2020 16:33:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585758819; bh=a3ZuDnxMQgCSScO4KDDz8FyS389uR0PmI/11HSciiD8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XmLwIOKcqcTbC6m47Az+1fSc0vjjOjaA75qt0Vub7eOM+p5dEjrl5c1YkIop1edGS leXcuQI9o7asl7iK9jt4+g4+w6PNqzTiInLCm9whLhJZb4hfJbm2DUrghH5uijJZKn HyqGjbnnUhZ0S8qU/II0DmpU3TDgDMvZB/xbT67Q= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Biggers Subject: [PATCH 4.4 85/91] vt: vt_ioctl: remove unnecessary console allocation checks Date: Wed, 1 Apr 2020 18:18:21 +0200 Message-Id: <20200401161539.366293605@linuxfoundation.org> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200401161512.917494101@linuxfoundation.org> References: <20200401161512.917494101@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 @@ -353,22 +353,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. @@ -1208,18 +1199,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. @@ -1279,7 +1262,7 @@ long vt_compat_ioctl(struct tty_struct * arg = (unsigned long)compat_ptr(arg); goto fallback; } -out: + return ret; fallback: