From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB87BC35679 for ; Mon, 24 Feb 2020 08:07:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7D99420714 for ; Mon, 24 Feb 2020 08:07:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582531666; bh=OAXJTTmgTmEwVHhk5H89yyZFslSLfmpQCmgtbI60Lhw=; h=From:To:Cc:Subject:Date:List-ID:From; b=IFbn7u8Vo3kaDnjt1U0nGr5k5zewgT30xxgqDYdhdYuRODb+pSMdiDSDX03hqt1Le ZxSVVu29fSA7WV7Ion6VHp4vuNCUMazOxTh1DbofScaArIWKT1kb8gWBc3pMFLWYfF YD+f64PvcMYaRBW7OPUUni24HsajWz4zdGLfaH9s= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727239AbgBXIHp (ORCPT ); Mon, 24 Feb 2020 03:07:45 -0500 Received: from mail.kernel.org ([198.145.29.99]:33328 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726216AbgBXIHo (ORCPT ); Mon, 24 Feb 2020 03:07:44 -0500 Received: from sol.hsd1.ca.comcast.net (c-107-3-166-239.hsd1.ca.comcast.net [107.3.166.239]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D0C1020658; Mon, 24 Feb 2020 08:07:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582531664; bh=OAXJTTmgTmEwVHhk5H89yyZFslSLfmpQCmgtbI60Lhw=; h=From:To:Cc:Subject:Date:From; b=E1vM+3wjaToZ2s1x4W5c7Dom2Z7kVhwudHTheTqJ1p0GWFwAus8mxD07N/b1NtwJI HwL56jAS85wEcXV31NrIbD4hyqnfPtnelblYc0fQjINvC3QfAN4xu1MMSwstu7OKB6 yBNIetODIrrhv9eux4D/Mcr61IxwMf6mihi5TXwI= From: Eric Biggers To: Greg Kroah-Hartman , Jiri Slaby Cc: linux-kernel@vger.kernel.org Subject: [PATCH] vt: vt_ioctl: remove unnecessary console allocation checks Date: Mon, 24 Feb 2020 00:03:26 -0800 Message-Id: <20200224080326.295046-1-ebiggers@kernel.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 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 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 --- drivers/tty/vt/vt_ioctl.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/drivers/tty/vt/vt_ioctl.c b/drivers/tty/vt/vt_ioctl.c index 57d681706fa85..400000a8830a1 100644 --- a/drivers/tty/vt/vt_ioctl.c +++ b/drivers/tty/vt/vt_ioctl.c @@ -339,22 +339,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. @@ -1184,14 +1175,9 @@ long vt_compat_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 = vc->vc_num; void __user *up = compat_ptr(arg); int perm; - - if (!vc_cons_allocated(console)) /* impossible? */ - return -ENOIOCTLCMD; - /* * 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. -- 2.25.1