Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp341488pxj; Thu, 20 May 2021 10:31:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzAg3h+1dbS/w10vWMBkqGmlrU3dJzZ5AIgOmwBRmzv/3EE74QOqmEcvKMG8xZCHNHp5zkk X-Received: by 2002:a17:906:110d:: with SMTP id h13mr5743232eja.45.1621531910912; Thu, 20 May 2021 10:31:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621531910; cv=none; d=google.com; s=arc-20160816; b=hJ1Z8QxLTnDEhyxJ3nQotpwx6ljXXxE/+Ej1+AEpY3mrO2CtelSGr460EYxkTzvJYb 8yZS0bwDYq9bq3e3dIGxP7VOo02KAh7rv2G51oe0aAeiZ8oCrNCZGwWEmDSvGAi3JrRr 4bGkiRYPWXkvgpG6sy8tqM++J8ZV244H2X2eF2eAK7zEgdAUZN2Pcxt897kAV+0g4cGs hREnKcAsKZDBnPmZ6zefHDUZVonAAc9is0NZP2HnCnFxM0avIbI0JTI2fb5CyTBZrNCT 1WVQevRX8iD6EOuNsDpJFUaIonQo5i/8Qzw/1YRJBJ7TtTdel8lXR+662N5B6NZLx/GM RqYA== 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=qZWJB27YkB5i9NKfYOJpgqGbnuTpad91iXTNdbHSR3Y=; b=hfZbg2NLO+yDDLoHFUnTwBagSmBxKT1sHiKQ5SRE7PxbWFTbBS0y3FEm5g5BOeta+D 5glGSDbiUO6n71dl2ZXGP5w1oRKQVnMCyt5ZMkh8jTuI1/fikRjhlOkKVbc5uqyYn0XR 84LBJg0y10iUFI2VSji+tCNtWJeY7v9L+40aNw6nhCY8ovDhbkzBx847906re94ZVblv G29D5GEe44SXhvX6JNqk5u2Z7iZFntPmAA8+J7zjC4ykSLYkP+1uRoCr5+Za6E6+aNYr 5hLdHkO0weMmhXDK9MTyDpzYQ3B1/FDJMcNcA9yoylV/Tq6ghzEn+1TCA8TziBNeKIHW iJ5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1lFQ8m2+; 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 q19si1120726edv.397.2021.05.20.10.31.27; Thu, 20 May 2021 10:31:50 -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=1lFQ8m2+; 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 S234158AbhETKAr (ORCPT + 99 others); Thu, 20 May 2021 06:00:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:59108 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235132AbhETJzw (ORCPT ); Thu, 20 May 2021 05:55:52 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 55EF7613C5; Thu, 20 May 2021 09:37:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621503442; bh=ApkxEpZg2x3SxkswIrVOAFnNbYX/wS1LHnzpYfVq7o4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1lFQ8m2+H+0gzLxhXW2P71isVFlnXUjvsf6LmMSSKXbhYfNftdMjKOb6+zuXjFE1g LHsETiBjV1o78bEJLvApTeclFULMLXhKd8XltIIW4wOyNVpsVBxYvC/1VAG33aRiee AbudK5hdC3niFL7t0K4I4RURBTQMRjEO1wNcWhvA= 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.19 216/425] tty: fix return value for unsupported ioctls Date: Thu, 20 May 2021 11:19:45 +0200 Message-Id: <20210520092138.524123358@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092131.308959589@linuxfoundation.org> References: <20210520092131.308959589@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 ff6a360eef1e..9e9343adc2b4 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -2432,14 +2432,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); @@ -2457,7 +2457,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) */ @@ -2469,7 +2469,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 71dbc891851a..e10b09672345 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