Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp917467pxb; Wed, 1 Sep 2021 12:38:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyTqyx/6urGfXk+7/b3R7XF53vh2zc1JjpyrfhGiBkarDRo5eEArE7l16rGNLIqCi7r7weT X-Received: by 2002:a6b:8f4e:: with SMTP id r75mr1020834iod.172.1630525093814; Wed, 01 Sep 2021 12:38:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630525093; cv=none; d=google.com; s=arc-20160816; b=TH247PBNpjxCkj44cNhOqEueBMIuRhyEuxmUglLGx7YtGK6zy3HMtKPp3MKjwk9s3F OopR5UW5aniPfflvH8ZPPKJO9yNMlObgrBvAnwbTw0VMQd4K+XSsz4aaUBJZKJbO4yFo lHqdWX8VNdSPSvGcOiD8rQ9LGgrm5p+d1WOH1UWqVE3H32OFH3btIo/GyVSsgrFj46h/ r+q+wjmt2KTw1Cif7xyMJIrSxXSBVKqDVE3pu68Q+2a1rFdWcW6Ig/o3PQnEqpOyg4hB Uta0WEfppS+sAwTniRUwc2fxwlOakQxXcaZKdx1eg0K47HvkxMaDH+hur1kslZ+LyD+l scrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=+ypuvQWPQ9KSVlN0lTaVlZhrcyHtmD44Y5kZvxIuYNk=; b=EgJn+eOkxpsxJiL9oxMCOqppgQYYUU6ndj+lH/woFXwcsiyTEz5epaWRcKd9va6TqG iwpO7fZA+zFjvodKot9d9OzaOOsKJx25zgYt+7LbQUfLaPsx+tJtOwpQ2QxJK3jAIEkK LbSBlWH6SF4dxidGMyLC8q1cRiHIwSkcdoX4svN610SRm5cm3fuoW0v7SotwHSGZItRg PEsONRkis2hRVraGtepu77REpurtt2JHZbXyDsom43FzA0xqqIpssypsJs3fraUHV5E0 CsfxsCY1Sqx5UuOlMaW0W742C0b3MS+tW/EduRarOcGc3Em68rNeUI0XiSDIs5YnDzkM cw2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=aDcBsvTm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z26si396830ioc.55.2021.09.01.12.38.00; Wed, 01 Sep 2021 12:38:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=aDcBsvTm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345398AbhIAMoM (ORCPT + 99 others); Wed, 1 Sep 2021 08:44:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:42460 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344826AbhIAMkI (ORCPT ); Wed, 1 Sep 2021 08:40:08 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0097E60F21; Wed, 1 Sep 2021 12:36:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1630499761; bh=s3gyVITa2PR9fxfQHuANQGwIuSOn3PTmdB3yN6wvSzE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aDcBsvTm5xuW6Tl6UbkCuFVp0MBPf9FyW+I2mFO67iIkfan9SzWCOiVParyoHUPvZ OdyJPBjjc7Bm1xVB5hK8Dgg/zoe+VOXDWUJ/j/9Gmt0hAHF3oBhwNksUcTWKbq5ZXN uweVuMZnpWn80E7KebYu/n7M++JqlWwNP3GTPBgc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Minh Yuan , Jiri Slaby , Linus Torvalds Subject: [PATCH 5.10 076/103] vt_kdsetmode: extend console locking Date: Wed, 1 Sep 2021 14:28:26 +0200 Message-Id: <20210901122303.118427446@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210901122300.503008474@linuxfoundation.org> References: <20210901122300.503008474@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Linus Torvalds commit 2287a51ba822384834dafc1c798453375d1107c7 upstream. As per the long-suffering comment. Reported-by: Minh Yuan Cc: Greg Kroah-Hartman Cc: Jiri Slaby Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- drivers/tty/vt/vt_ioctl.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) --- a/drivers/tty/vt/vt_ioctl.c +++ b/drivers/tty/vt/vt_ioctl.c @@ -246,6 +246,8 @@ int vt_waitactive(int n) * * XXX It should at least call into the driver, fbdev's definitely need to * restore their engine state. --BenH + * + * Called with the console lock held. */ static int vt_kdsetmode(struct vc_data *vc, unsigned long mode) { @@ -262,7 +264,6 @@ static int vt_kdsetmode(struct vc_data * return -EINVAL; } - /* FIXME: this needs the console lock extending */ if (vc->vc_mode == mode) return 0; @@ -271,12 +272,10 @@ static int vt_kdsetmode(struct vc_data * return 0; /* explicitly blank/unblank the screen if switching modes */ - console_lock(); if (mode == KD_TEXT) do_unblank_screen(1); else do_blank_screen(1); - console_unlock(); return 0; } @@ -378,7 +377,10 @@ static int vt_k_ioctl(struct tty_struct if (!perm) return -EPERM; - return vt_kdsetmode(vc, arg); + console_lock(); + ret = vt_kdsetmode(vc, arg); + console_unlock(); + return ret; case KDGETMODE: return put_user(vc->vc_mode, (int __user *)arg);