Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp618651pxj; Thu, 20 May 2021 18:05:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz/fsDYYL6NSEbVreEIIqKBC3ydOPEjE8Pi49tg4oeNxdiq0jp0GyZPP5qAUfvxk6PpwcZF X-Received: by 2002:a17:906:4cc5:: with SMTP id q5mr7385295ejt.302.1621559102776; Thu, 20 May 2021 18:05:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621559102; cv=none; d=google.com; s=arc-20160816; b=dXB5dyR6UWbbDaVRrZrdUTJAK3Ru2CGEDnLVDr9EhgCEDYTC36Yh3187NsJtO1vKAj TofRW85xEJ2GSxH2iDkBhzzGBoZWq0D4aaHTwtqTwrKo3usNXFk8J8YRBrpbWnM3N9n5 Gooo0YshMEQuo7Puie1pCyRJ6NSPMKN5W5doXJtp8vcPXeS3yoX26yaVqCKvIhzTj3ou 7loeh3MFhs2f5Z0NKpGcytKv8iEEV5dGy9eoty1JjSabEsAGkvvTZ2e/gzGg9LIggzH4 bT7kefxOxZSVBMnNWkw0ZdyHE2lpo8SUd8tM8d8QqfRePBNTx2P7xOldze8tH/jhLubD YlCQ== 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=F8GctUduCYAAMSJ6vG2WY9aY4pFwiOuRQWVeDVKbDcw=; b=esEheHZgLVluya72TRYbXxsPY2mcntSs1l9G6spiMDTw3pWkVvTgPbaECrGcV3KKM+ GTanPo57llAgOBIzjI5WelFSldL1Wp5laXFvPLivvSIYF8l3/HAHJrG6wANgAmyb+W1k xhEpDk4+35easbqymL0eK5UXO2vE6RegWUjZtqFSpok7lbakqq9c9xblfNpU4gXzorc5 DfYJ+6HsXNbcjF06u39giXBTVtETb06Zf8W+extEbhOgTXZf+O6NfOeq69AGLXMqxwiy KSRsEG0xQxCScmXIJC68QZhp5i8Za0IpG65Mycydb7JvDTY2Aq5zUcpe3av/W242dAaP jBrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="x4yr/H0H"; 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 b13si4420025ede.412.2021.05.20.18.04.21; Thu, 20 May 2021 18:05:02 -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="x4yr/H0H"; 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 S240283AbhETLgE (ORCPT + 99 others); Thu, 20 May 2021 07:36:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:38798 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240413AbhETLPt (ORCPT ); Thu, 20 May 2021 07:15:49 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A626461D61; Thu, 20 May 2021 10:09:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621505351; bh=lxGFtPBaiPfFOBd6ka0NMvca45bMyhFaOUkmSEoWGiU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=x4yr/H0HyzVneek9+DRQeMh9bGNReL5GL6/IprQ8k1y9y+DK3XdbaYBlQL4/FM8tT soNihp7cJRxM0GlrtwAlzutDzueyMmIeQzfrjjden5DCBCqkipz3ODy7nmODJhvXa5 rAxIXYDeBQF481iBVtxgctIquPhWbO9AiftzjN7Y= 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.4 095/190] tty: fix return value for unsupported ioctls Date: Thu, 20 May 2021 11:22:39 +0200 Message-Id: <20210520092105.341421997@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092102.149300807@linuxfoundation.org> References: <20210520092102.149300807@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 dff507cd0250..bdb25b23e8d3 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -2762,14 +2762,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); @@ -2787,7 +2787,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) */ @@ -2799,7 +2799,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 161052477f77..6d8db1555260 100644 --- a/include/linux/tty_driver.h +++ b/include/linux/tty_driver.h @@ -235,7 +235,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