Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4724742pxj; Wed, 12 May 2021 11:46:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwGOzNFNTIIDm0dRGkSnqjfTTyRZZA7IxDGpESEmE7mN10+fsuiLxPyJkrPAvRo0t6O1glC X-Received: by 2002:a05:6402:c8:: with SMTP id i8mr45919079edu.57.1620845208687; Wed, 12 May 2021 11:46:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620845208; cv=none; d=google.com; s=arc-20160816; b=TCZkDb4ejSVEcI6BT3KG5yXBlxLyBikhaYNmjxAWyukNY7JFJxWkUgp7lIe7FqTH7C m4I2FTopjhA5GuGeCBC9atAiYf4zVnFzY3+1Sgxw9gt9U6UxKLd409fzRU3a2IBi2gyw 61b233QOevFOJlEULJ7VwPZ7UngstY3uWyGpf8wlY0mhQCX8nTRMNmuZk9GA3XilVZhQ 6hm5jx6FoLaB8Tvx56SVfA8/z7EYb6pF2+TXcFmQwWFSiamQW+iRNPWN7UaAEizKV+Ao wDbWLwsuU5y5i5Gu7LE+gMkJcVpt52p/wqgt4+SbEgzXkJfh4GjDjQ2kDjmlx6ekNM1u aG/g== 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=VaSP2I/nYs5fBkeNfNYTVdE5ZUe7LpxwQQneWqYPG7k=; b=SbE/9z9Js5ujuhi4PqfxiB4mIwq+MhpaUeTw6kuS4xPIE9hLAcc6esIBbHRt7ABJXB XaSG5kSWEi4Y/YHJ/LTMnXJZ2khZpgshy7K4aofIWt+EZko0sHRGucEj5dlQqoZyKaPS pwxMwP+uJIiGjLd6KBeE9F5ynyUJWbcXuCNYgoFeUit90N8/XlRiVVnc4UQWf2EA+YUe BduEBttRroHIPWgfU8MHc8gXlfXTLOmb7vrUEg1ip3ghBEcY467eo7LaBSSjujdSE/KB vdSaBK5xziHeE5e0RfF/zWN18qhpMrbTcaik1wWqsRAyYMVk+VgaOVCXM18ozJwEeaOR xvOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="1S/2NI9c"; 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 h20si493172edv.406.2021.05.12.11.46.25; Wed, 12 May 2021 11:46:48 -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="1S/2NI9c"; 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 S243670AbhELSkV (ORCPT + 99 others); Wed, 12 May 2021 14:40:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:57122 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241276AbhELQjd (ORCPT ); Wed, 12 May 2021 12:39:33 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5117761E35; Wed, 12 May 2021 16:03:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620835417; bh=tVm34UfxAoSmKEjFtffWzw/5KXqJ6gT7D2R9JQlFA8I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1S/2NI9cIxY31ze5JSgoipSx4NnSy+vkd2J20qa3cCni2Rx9QK6UhfcpRsaKPr5ZO c59jdbsnBDDOA3tSmAQq3PeX6TCF2J0+BfFXz2wIks3tFt1y6JskyMNEWnLwiznSA3 OfOJ5jhn886vxcBuIrdFdUSs14fueeDoG5vrt7xE= 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.12 302/677] tty: fix return value for unsupported ioctls Date: Wed, 12 May 2021 16:45:48 +0200 Message-Id: <20210512144847.238607000@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144837.204217980@linuxfoundation.org> References: <20210512144837.204217980@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 | 10 +++++----- include/linux/tty_driver.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index 391bada4cedb..adbcbfa11b29 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -2530,14 +2530,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); @@ -2555,7 +2555,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) */ @@ -2567,7 +2567,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) @@ -2607,7 +2607,7 @@ int tty_get_icount(struct tty_struct *tty, if (tty->ops->get_icount) return tty->ops->get_icount(tty, icount); else - return -EINVAL; + return -ENOTTY; } EXPORT_SYMBOL_GPL(tty_get_icount); diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h index 61c3372d3f32..2f719b471d52 100644 --- a/include/linux/tty_driver.h +++ b/include/linux/tty_driver.h @@ -228,7 +228,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