Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp798895pxb; Tue, 3 Nov 2020 12:51:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJykCgYJzzn9Kz4Ke2PRvrEN+6SyLONznWbfl3bBut732pUOL9OvTbrYacHsXT+eVCyoqI7l X-Received: by 2002:a17:907:2110:: with SMTP id qn16mr22561759ejb.133.1604436702951; Tue, 03 Nov 2020 12:51:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604436702; cv=none; d=google.com; s=arc-20160816; b=p+OF2zH3ZOFtnxCyMo5JJEP6bh08QNVuG2orlT/7pezdwCsvqdpphhPRGqvqIE9Tny KigbHqUqQoPKbJp9tbapxPp3jKePd0QJLDMZ30xkjAHTBZmQXjHXYU8XtW2PeGbg24A5 L3rUNveMe3GoQ+d82b0/2MHUI9/SED7/d68NODKQkb9g56tZD8vpQUpPK08o9lykh2An CXy8oMniQ8cqauXoAF45vThaQaRH3vVM+FtglATGqKFBwhyxZ4YnMy3Kbptausk/yl9n 7X75xSEoYWJ2TP+J7D4ZyfohZVAX/I919diK/lu7HTYp72wmbWdB7yndUd4YISv1jsPC 4QpQ== 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=cQkNRHNAXGuknDxYsHVWzPvZ0ghIIxTnHfdL6buW+Z8=; b=gAwupYKAfCc3ajX2S5129Y9b/Pzm6Qd1o/T/GgxIiosVUesbBgZrbRi8k9A/81lbHt c2P+xkIGuf/f4FS9/SZt/oEyivubdwlRLP7t+NTlVRNpBnsWLkNoG5Z6UztOmhDid1Y6 ASphd/M7U+HxDOa91eZ3/IacO04+o8TrixUEQXhvlY+5F+ATY3KMOYlwiWNiThRk4oMX +q0Phe5+5ewK8/uYr8YVM91YgyYBAvtA03XME2wHBi7o6UUqr75/Lk6gSHZ9bvsD2BOZ 8e361ex7uNMYR90khNjiNw9Vxc53IeF18d0Hx833oBt5jPuzebISKczY2pKwWUeQZV/w 5OxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=QWUyQOyM; 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=fail (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 c8si13477549edl.252.2020.11.03.12.51.19; Tue, 03 Nov 2020 12:51:42 -0800 (PST) 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=@kernel.org header.s=default header.b=QWUyQOyM; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731370AbgKCUrh (ORCPT + 99 others); Tue, 3 Nov 2020 15:47:37 -0500 Received: from mail.kernel.org ([198.145.29.99]:38084 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731352AbgKCUrf (ORCPT ); Tue, 3 Nov 2020 15:47:35 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 BE19A20719; Tue, 3 Nov 2020 20:47:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604436454; bh=5fK79m+5E9BogoI86LILJfXfRx4KDEPqdPAPrzc+1qg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QWUyQOyMp1kf5qUt9xScbpX1O3avo6TaWSzb95r9xxRxhDm70ApzLRjGbAoH5MoxB RmYDM53BlLb9lHAkw1p80+Gg46Z6ve86/q4dDvaygMl987wATQ7m7KOEKDuX0VBveZ kZCU+M1qW15JRTNCF3gsm0mILA3/jTZMF796SzcY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Fabian Vogt , Jiri Slaby Subject: [PATCH 5.9 256/391] vt_ioctl: fix GIO_UNIMAP regression Date: Tue, 3 Nov 2020 21:35:07 +0100 Message-Id: <20201103203404.296513919@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203348.153465465@linuxfoundation.org> References: <20201103203348.153465465@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: Jiri Slaby commit d54654790302ccaa72589380dce060d376ef8716 upstream. In commit 5ba127878722, we shuffled with the check of 'perm'. But my brain somehow inverted the condition in 'do_unimap_ioctl' (I thought it is ||, not &&), so GIO_UNIMAP stopped working completely. Move the 'perm' checks back to do_unimap_ioctl and do them right again. In fact, this reverts this part of code to the pre-5ba127878722 state. Except 'perm' is now a bool. Fixes: 5ba127878722 ("vt_ioctl: move perm checks level up") Cc: stable@vger.kernel.org Reported-by: Fabian Vogt Signed-off-by: Jiri Slaby Link: https://lore.kernel.org/r/20201026055419.30518-1-jslaby@suse.cz Signed-off-by: Greg Kroah-Hartman --- drivers/tty/vt/vt_ioctl.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) --- a/drivers/tty/vt/vt_ioctl.c +++ b/drivers/tty/vt/vt_ioctl.c @@ -550,7 +550,7 @@ static int vt_io_fontreset(struct consol } static inline int do_unimap_ioctl(int cmd, struct unimapdesc __user *user_ud, - struct vc_data *vc) + bool perm, struct vc_data *vc) { struct unimapdesc tmp; @@ -558,9 +558,11 @@ static inline int do_unimap_ioctl(int cm return -EFAULT; switch (cmd) { case PIO_UNIMAP: + if (!perm) + return -EPERM; return con_set_unimap(vc, tmp.entry_ct, tmp.entries); case GIO_UNIMAP: - if (fg_console != vc->vc_num) + if (!perm && fg_console != vc->vc_num) return -EPERM; return con_get_unimap(vc, tmp.entry_ct, &(user_ud->entry_ct), tmp.entries); @@ -640,10 +642,7 @@ static int vt_io_ioctl(struct vc_data *v case PIO_UNIMAP: case GIO_UNIMAP: - if (!perm) - return -EPERM; - - return do_unimap_ioctl(cmd, up, vc); + return do_unimap_ioctl(cmd, up, perm, vc); default: return -ENOIOCTLCMD;