Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp778792ybc; Sat, 16 Nov 2019 08:32:08 -0800 (PST) X-Google-Smtp-Source: APXvYqzhdZWDYbSr95XWekp3P64suDDUwxHUpzbRymE7EExcDHU4S1rz8VCXeFuKjrebr9ZewqPc X-Received: by 2002:adf:dc8d:: with SMTP id r13mr5506438wrj.391.1573921927995; Sat, 16 Nov 2019 08:32:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573921927; cv=none; d=google.com; s=arc-20160816; b=YjefW/W1X90VPMFX0dBXnm5ZvyIlv/XpoMxTfiXJ2KkYHEqeNelrXweUKZdcvLprlU g4Hv3DRlQPQ9e/cirutfA5ioMGBHAtfPrpqNT6ypsRjo4CIE988YeY7xKg9w3XnXyFLv wjwt02bvyroQGEgzZ55Npn/CeF6I68hLgIH3gOXV8BmZifsq2OAep3vNBmHJLqR740EB s7db17ulf7AyG7V1W+2yo7KIREl9qX7YUMoJEFEWC7tTcScdjFexexB1pPTiXNZ9E0q9 kw7WBEn/+Gs37kzVSWARvS1ue/MmH2uqMi7hbmVpz0hwC5DNnvoJqWqp5jZyFQposJ6K /DFA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=71U13VnsmllGcNdwiNaue2izY3iEAg4sZNGny9iCBhU=; b=DhlR3HuolYpueY3LygjPDluRWNz0oljtaRLXXAJk1I/hipcd6dBO+TfmZgkwkrP5qL 4Q8VKoKInb4UtNCDuhWSRYiBTHJg+stQLQI+x0LF8swdrjnrAUo531jjlv9l77JGXZD3 6mlOmcYC85vY25UKbe+kt1GAkqZ+lzLRtkMcbY/zo/yQVEU9dqZiXwwxn7l4UPYunNZC 64wz/vAxiCYcm9MBsFv36gxeyosi12SZJ1BpQolAZ/hJDpF65eL0cY6n23JdXl3yYL6E +g+SmdLBxSaRr2x0kU1ntUimITcDkOqT3xWiaSVVtOoEBxRed0HZfB5HihE4zOFRFsI2 2Huw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="YZUU022/"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c29si9020156ede.50.2019.11.16.08.31.43; Sat, 16 Nov 2019 08:32:07 -0800 (PST) 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="YZUU022/"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729369AbfKPQ2Z (ORCPT + 99 others); Sat, 16 Nov 2019 11:28:25 -0500 Received: from mail.kernel.org ([198.145.29.99]:44296 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727801AbfKPPlT (ORCPT ); Sat, 16 Nov 2019 10:41:19 -0500 Received: from sasha-vm.mshome.net (unknown [50.234.116.4]) (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 6C7372075B; Sat, 16 Nov 2019 15:41:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573918878; bh=3rZd8WAF0bdHLPMC9H3Bv1cYv1WRtPTVMC3DphGZp8Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YZUU022/PcOd2DEu/kYBsk8LMN4SgAhUDqObdwW/eN6jVwn5NM65XLvuh4X96Zpmm zCQsRNISC/q+y+VeseoyZCo7sWujcYQX+nYQ8oj45jjDqLy88dui9AfIGVHEhucDw6 XyDH7sI4WiYtZPofK1SCioOdq2mV5OZOt2R3Szt0= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Al Viro , Sasha Levin Subject: [PATCH AUTOSEL 4.19 008/237] pty: fix compat ioctls Date: Sat, 16 Nov 2019 10:37:23 -0500 Message-Id: <20191116154113.7417-8-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191116154113.7417-1-sashal@kernel.org> References: <20191116154113.7417-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Al Viro [ Upstream commit 50f45326afab723df529eca54095e2feac24da2d ] pointer-taking ones need compat_ptr(); int-taking one doesn't. Signed-off-by: Al Viro Signed-off-by: Sasha Levin --- drivers/tty/pty.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c index 678406e0948b2..00099a8439d21 100644 --- a/drivers/tty/pty.c +++ b/drivers/tty/pty.c @@ -28,6 +28,7 @@ #include #include #include +#include #undef TTY_DEBUG_HANGUP #ifdef TTY_DEBUG_HANGUP @@ -488,6 +489,7 @@ static int pty_bsd_ioctl(struct tty_struct *tty, return -ENOIOCTLCMD; } +#ifdef CONFIG_COMPAT static long pty_bsd_compat_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg) { @@ -495,8 +497,11 @@ static long pty_bsd_compat_ioctl(struct tty_struct *tty, * PTY ioctls don't require any special translation between 32-bit and * 64-bit userspace, they are already compatible. */ - return pty_bsd_ioctl(tty, cmd, arg); + return pty_bsd_ioctl(tty, cmd, (unsigned long)compat_ptr(arg)); } +#else +#define pty_bsd_compat_ioctl NULL +#endif static int legacy_count = CONFIG_LEGACY_PTY_COUNT; /* @@ -676,6 +681,7 @@ static int pty_unix98_ioctl(struct tty_struct *tty, return -ENOIOCTLCMD; } +#ifdef CONFIG_COMPAT static long pty_unix98_compat_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg) { @@ -683,8 +689,12 @@ static long pty_unix98_compat_ioctl(struct tty_struct *tty, * PTY ioctls don't require any special translation between 32-bit and * 64-bit userspace, they are already compatible. */ - return pty_unix98_ioctl(tty, cmd, arg); + return pty_unix98_ioctl(tty, cmd, + cmd == TIOCSIG ? arg : (unsigned long)compat_ptr(arg)); } +#else +#define pty_unix98_compat_ioctl NULL +#endif /** * ptm_unix98_lookup - find a pty master -- 2.20.1