Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4557418pxj; Wed, 12 May 2021 08:09:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzTULDZEZ+OQuB7yijkIrlRmCUmhqAylzMR0+mqsv+MLDV2mqnPoiqXwylMBRdLNJaFx/jp X-Received: by 2002:aa7:cd0c:: with SMTP id b12mr43652370edw.236.1620832165055; Wed, 12 May 2021 08:09:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620832165; cv=none; d=google.com; s=arc-20160816; b=qEN6DdmQRxdePfzF75S2Jp6trIhMUmuHTSkJ1PEV2UWLnSYmGDoO07WZuKBPhzxr51 AwaC3UHyAej/ccfqlitgm1sVxtvpvhjSCnsipqMfLuiMYVWXS+T70ZwHpFNTIIkwM0SK phqKb6QalvVXwJLWQsOkwOWElAXBqdjXBECrj/IU4waGP8+mlKDuZHY+zFZcj3P9EkeD JSGVIy7FsefK+smgG9MG0fq9DLv2N9CXpLL9a+pri6UFrMFlYB6mXeSl23XkLBHM+wpV 9EIt7CLiW9fERnqg0/P38GOB6bBW65gW/48Ybuig88/+4K9eu0YksFhcTMY/HGtMkxV6 rN9A== 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=qZZMHlrhRaWH5Mo5oXkXAaxxGOyQgHUPXM4YTKtaOWk=; b=Jx/nY+LesQN/zI5tbRtC09jZuETHpw6J7AfQE8hmeMvcefVbuvfuTLK3Geqfq6bwNb S2yNlH9QiK5pbR+F+XXGHTd+n8uZ7n+a+FnnppfQXzSpJf0NfnjOwsDeZeK/8vFjjybj Wr+gmudqQX2JRd6cua73ADyE2KsS2UM7K6JCsQZ9Nfqcf4+zshGS3Jro3S+8egCDVD1S dipdlIIQxh38JzxDAkGTl4Y63DJ/EiftZc6cRuRs2ZtmjbCdFrwT+GoP6RkoQm5gaOx5 1UvEo/Nmonsvk8MkwjvkBtBwcH3PhYNxrXvbEkfRk2lyw2OvcqWjzQ9hPLwEvd5ro2FZ XiSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RGWUys9A; 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 cs15si184629ejc.258.2021.05.12.08.09.00; Wed, 12 May 2021 08:09:25 -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=RGWUys9A; 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 S232314AbhELPF4 (ORCPT + 99 others); Wed, 12 May 2021 11:05:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:58748 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232108AbhELPCF (ORCPT ); Wed, 12 May 2021 11:02:05 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2147161462; Wed, 12 May 2021 14:57:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620831454; bh=Es2SDol4C80vE6hnZOjQ4PKmC+/q1sDD9q2YA8/5uGM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RGWUys9Ae+1h//Y1gABQNwFiZXUfz/dofdADPBqJFgQ5FqGvFR3gaxr7hHmUqotR1 c1SEBaixbDnfnqLDnbKm4RhT6kIzGIZMpc4W0OI29MV/hbSudtGRacW+ZxVyWpJDq/ D/XmHN8qajHMD8aopvStT5Rf3FbYivbCbnkZJacA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johan Hovold , Sasha Levin Subject: [PATCH 5.4 127/244] tty: fix return value for unsupported ioctls Date: Wed, 12 May 2021 16:48:18 +0200 Message-Id: <20210512144747.077987571@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144743.039977287@linuxfoundation.org> References: <20210512144743.039977287@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: Johan Hovold [ Upstream commit 1b8b20868a6d64cfe8174a21b25b74367bdf0560 ] Drivers should return -ENOTTY ("Inappropriate I/O control operation") when an ioctl isn't supported, while -EINVAL is used for invalid arguments. Fix up the TIOCMGET, TIOCMSET and TIOCGICOUNT helpers which returned -EINVAL when a tty driver did not implement the corresponding operations. Note that the TIOCMGET and TIOCMSET helpers predate git and do not get a corresponding Fixes tag below. Fixes: d281da7ff6f7 ("tty: Make tiocgicount a handler") Signed-off-by: Johan Hovold Link: https://lore.kernel.org/r/20210407095208.31838-3-johan@kernel.org Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/tty/tty_io.c | 8 ++++---- include/linux/tty_driver.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index 642765bf1023..cee7514c3aaf 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -2407,14 +2407,14 @@ out: * @p: pointer to result * * Obtain the modem status bits from the tty driver if the feature - * is supported. Return -EINVAL if it is not available. + * is supported. Return -ENOTTY if it is not available. * * Locking: none (up to the driver) */ static int tty_tiocmget(struct tty_struct *tty, int __user *p) { - int retval = -EINVAL; + int retval = -ENOTTY; if (tty->ops->tiocmget) { retval = tty->ops->tiocmget(tty); @@ -2432,7 +2432,7 @@ static int tty_tiocmget(struct tty_struct *tty, int __user *p) * @p: pointer to desired bits * * Set the modem status bits from the tty driver if the feature - * is supported. Return -EINVAL if it is not available. + * is supported. Return -ENOTTY if it is not available. * * Locking: none (up to the driver) */ @@ -2444,7 +2444,7 @@ static int tty_tiocmset(struct tty_struct *tty, unsigned int cmd, unsigned int set, clear, val; if (tty->ops->tiocmset == NULL) - return -EINVAL; + return -ENOTTY; retval = get_user(val, p); if (retval) diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h index 358446247ccd..7186d77f431e 100644 --- a/include/linux/tty_driver.h +++ b/include/linux/tty_driver.h @@ -236,7 +236,7 @@ * * Called when the device receives a TIOCGICOUNT ioctl. Passed a kernel * structure to complete. This method is optional and will only be called - * if provided (otherwise EINVAL will be returned). + * if provided (otherwise ENOTTY will be returned). */ #include -- 2.30.2