Received: by 2002:a17:90a:1609:0:0:0:0 with SMTP id n9csp831585pja; Wed, 1 Apr 2020 09:30:15 -0700 (PDT) X-Google-Smtp-Source: APiQypLgbT7UDZdpvCSsqiQzgTwQjIcy3icjf0Ce2VClkBpX1uBrwqe5DoquWl7Q6qxi/Qo4SVet X-Received: by 2002:aca:75d5:: with SMTP id q204mr3547166oic.9.1585758614971; Wed, 01 Apr 2020 09:30:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585758614; cv=none; d=google.com; s=arc-20160816; b=u145ZrQnQp0URZ5ch9wiRJg+shMYNDxg9b0yUsDRSltqDMfYpQJDw1lYjt19JKBGqg fkl5R3kVnUSuyV6uqbCLd1Herp1SKSyu9UHLa1KiOnRQvSIDqXUGh+0VqP7h8QQQXHSv uChIRidhjiiWU0cF3bNgq45foGBrdSgk5OgYcn4SgufwY5LADiljbBiofQKHZgxZ2Z0W G+EbIotNSqGXaqrT4PrxVpnxdL3naLn2R46yaTlGW2EYcItFJxEcQQfbhZataw1sMoQn KdftqPT0Ow5Pvl77ZlypW3TPrjhPs17lFrQSezZLnbPAdEBjuRSEulmHTPznNjUjAUIX /yqQ== 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=iaBKG83yVktJuXAjG62sGH/ei8neOlEbiS+YM3nn7Ic2G0COhpFcTqDaIUeAzPcqOj YOa83b4PMC9V6NCNwDELWrVNlXYJ6oMNfFGLzQF5demSQj6eS1lxd18Wc8qTBk4XJr7v TiVlbDdrdhTidF+TSyhM4OleCsfJRROiXiCN3ZB7NmBVzVi4T7/y0BSngjJ3/5Da+COD i9iASKBU9avKRAB57Yzpcu28OhNkEA3avx+EWWuYLLVggYnDsosWgsTg4fN0f4aRWhPP cMy/IA5xqne6PVXJ+tCmKAOneQearUBxDgcZ4jFYUvW6SOUV6zUu2wtr6YYddYjLGd5L aAgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2civH5oU; 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 h6si953794oom.43.2020.04.01.09.30.02; Wed, 01 Apr 2020 09:30:14 -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=2civH5oU; 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 S2388064AbgDAQ16 (ORCPT + 99 others); Wed, 1 Apr 2020 12:27:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:53074 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388062AbgDAQ15 (ORCPT ); Wed, 1 Apr 2020 12:27:57 -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 A0DC820BED; Wed, 1 Apr 2020 16:27:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585758477; bh=9/GVYEdPPBR2AV0UCFVKcd7QD1qTeXd0Zbj4nmO0Pls=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2civH5oU96qNOqBZ7Yy4wrBu5xC3zLk17DdGdtWCRO5bUByZEn+EEqRt6nQ0o1PxX NECz92sZCoRF2Bg3vTaZ6hbBmmJ2tFSjWrcTAl07e0iRXxilWZWboGucLCCShPRjlP bwpQyXdDJsFEKucsBDAnIJKhbUdtfmQfKl587IDk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Biggers Subject: [PATCH 4.19 101/116] vt: vt_ioctl: remove unnecessary console allocation checks Date: Wed, 1 Apr 2020 18:17:57 +0200 Message-Id: <20200401161555.195453535@linuxfoundation.org> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200401161542.669484650@linuxfoundation.org> References: <20200401161542.669484650@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: