Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp451884pxj; Thu, 20 May 2021 13:16:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxRIoq/kWyINp05JX+7HqCYYrtVsBKUITJ2waqZUtMywzdTWogZFW57zzZxZHDDcYRtwe09 X-Received: by 2002:a92:c60c:: with SMTP id p12mr3558808ilm.116.1621541761875; Thu, 20 May 2021 13:16:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621541761; cv=none; d=google.com; s=arc-20160816; b=gRqAzcyKRw/SX2N0Cxj1LdS/Hk28HNWCUhm9tpice6tt++/b0y1Rugj+B7XdhSOJnt 1dwiUqtDhS5qBrkqm4onswRyO1moXqbi+lwCvDLXuviaRPVY/puf3Et4Wnu6eTBfLpLd h/KzkaB5+6CtU3RKT8OSoJbxZtQVd1YoeizsEhIiBVFac0MnBoC620YxYayLtgopt0sQ ibV7ESmeCldRdAA6WAWf+aIrVSVcPIAHY9tlTZZyDoIGZ48+2gyFA+lwpEbaP4SyaTnM 0IGIsqeSIJcn+5mB6+Uke8qTCvRmpqV8b7jwsVzOmpmcAiu7fge2oFyHvGROuWPRVwSo tObw== 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=LiohcMZttBvRkh4HiXjARYdV/QuEtsTNXIhKfX5hhzs=; b=nJzN1qdotfCrENg46ZM575Pi0UuXBrr3Ts8VOUdASt3NP15Lfqk1Y+SJnllr3183Du yPy8LYlBkL1BcOyci26Fb9Q0Mzq/HCZPkZpbV9+BMLKINBGJLrWHHSJXdGOI7zGqvigt xEKToDp3IrXD8nmihETclqi+gXByKJy6jOWGPNFRXFru9+gTWeuIz3SqyaldYZkDB/tO uiMlDUGWPnD2lq9q7wIYTlHavZF/d+ZewDLK4a1ZOdi1NjdyZiMWRn9LePKJawhE3qFx 8ZX58QIdcrouxATtl3A9rE6w+iyODWDiE/sg7/VBqTuB5UaxH6MM1XV93U2wI8VIVIai zf/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BgyjE8yH; 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 w14si3052134iom.23.2021.05.20.13.15.48; Thu, 20 May 2021 13:16:01 -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=BgyjE8yH; 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 S237797AbhETKsP (ORCPT + 99 others); Thu, 20 May 2021 06:48:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:33278 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236968AbhETKcY (ORCPT ); Thu, 20 May 2021 06:32:24 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7052C61C44; Thu, 20 May 2021 09:52:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621504351; bh=uvhpI6Q/SHPZ/xU7JSDPSFlerRc05DpY9Z2169ObaMk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BgyjE8yH62izYZdEOpa9fThwpTa9x+HoDAjKUNcgOHQMeJB1qR6Jf6Zs7n2B4lySK oX8K0s3U2zeo1na8DzVfy6cbz2fVTxW+9mNmxzGxkOhUNCHYOLBmrS8Vv5M8AWju8H UMaa8izxbreXeErHoV/ysLDEGE0bPO+uvn8ys3vg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johan Hovold , Sasha Levin Subject: [PATCH 4.14 173/323] tty: fix return value for unsupported ioctls Date: Thu, 20 May 2021 11:21:05 +0200 Message-Id: <20210520092126.039045155@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092120.115153432@linuxfoundation.org> References: <20210520092120.115153432@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 d7e56de19c58..ae3af8debf67 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -2424,14 +2424,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); @@ -2449,7 +2449,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) */ @@ -2461,7 +2461,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 31c2b5b166de..ebca9e4a2fed 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