All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johan Hovold <johan@kernel.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jirislaby@kernel.org>,
	linux-staging@lists.linux.dev, greybus-dev@lists.linaro.org,
	linux-kernel@vger.kernel.org, Johan Hovold <johan@kernel.org>,
	stable@vger.kernel.org
Subject: [PATCH 14/16] tty: mxser: fix TIOCSSERIAL permission check
Date: Wed,  7 Apr 2021 12:23:32 +0200	[thread overview]
Message-ID: <20210407102334.32361-15-johan@kernel.org> (raw)
In-Reply-To: <20210407102334.32361-1-johan@kernel.org>

Changing the port type and closing_wait parameter are privileged
operations so make sure to return -EPERM if a regular user tries to
change them.

Note that the closing_wait parameter would not actually have been
changed but the return value did not indicate that.

Cc: stable@vger.kernel.org
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/tty/mxser.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index 914b23071961..2d8e76263a25 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -1270,6 +1270,7 @@ static int mxser_set_serial_info(struct tty_struct *tty,
 	if (!capable(CAP_SYS_ADMIN)) {
 		if ((ss->baud_base != info->baud_base) ||
 				(close_delay != info->port.close_delay) ||
+				(closing_wait != info->port.closing_wait) ||
 				((ss->flags & ~ASYNC_USR_MASK) != (info->port.flags & ~ASYNC_USR_MASK))) {
 			mutex_unlock(&port->mutex);
 			return -EPERM;
@@ -1296,11 +1297,11 @@ static int mxser_set_serial_info(struct tty_struct *tty,
 			baud = ss->baud_base / ss->custom_divisor;
 			tty_encode_baud_rate(tty, baud, baud);
 		}
-	}
 
-	info->type = ss->type;
+		info->type = ss->type;
 
-	process_txrx_fifo(info);
+		process_txrx_fifo(info);
+	}
 
 	if (tty_port_initialized(port)) {
 		if (flags != (port->flags & ASYNC_SPD_MASK)) {
-- 
2.26.3


  parent reply	other threads:[~2021-04-07 10:23 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-07 10:23 [PATCH 00/16] tty: TIOCSSERIAL fixes and clean ups Johan Hovold
2021-04-07 10:23 ` [PATCH 01/16] staging: fwserial: fix TIOCSSERIAL jiffies conversions Johan Hovold
2021-04-07 10:23 ` [PATCH 02/16] staging: fwserial: fix TIOCSSERIAL permission check Johan Hovold
2021-04-07 10:23 ` [PATCH 03/16] staging: fwserial: fix TIOCSSERIAL implementation Johan Hovold
2021-04-07 10:23 ` [PATCH 04/16] staging: fwserial: fix TIOCGSERIAL implementation Johan Hovold
2021-04-07 10:23 ` [PATCH 05/16] staging: greybus: uart: fix TIOCSSERIAL jiffies conversions Johan Hovold
2021-04-07 10:23 ` [PATCH 06/16] staging: greybus: uart: fix unprivileged TIOCCSERIAL Johan Hovold
2021-04-07 10:23 ` [PATCH 07/16] staging: greybus: uart: clean up TIOCGSERIAL Johan Hovold
2021-04-07 10:23 ` [PATCH 08/16] tty: amiserial: fix TIOCSSERIAL permission check Johan Hovold
2021-04-07 10:23 ` [PATCH 09/16] tty: amiserial: add missing TIOCSSERIAL jiffies conversions Johan Hovold
2021-04-07 10:23 ` [PATCH 10/16] tty: moxa: fix " Johan Hovold
2021-04-07 10:23 ` [PATCH 11/16] tty: moxa: fix TIOCSSERIAL permission check Johan Hovold
2021-04-07 10:23 ` [PATCH 12/16] tty: moxa: fix TIOCSSERIAL implementation Johan Hovold
2021-04-07 10:23 ` [PATCH 13/16] tty: mxser: fix TIOCSSERIAL jiffies conversions Johan Hovold
2021-04-07 10:23 ` Johan Hovold [this message]
2021-04-07 10:23 ` [PATCH 15/16] pcmcia: synclink_cs: drop redundant tty-port initialisation Johan Hovold
2021-04-07 10:23 ` [PATCH 16/16] tty: synclink_gt: " Johan Hovold
2021-04-07 15:22 ` [PATCH 00/16] tty: TIOCSSERIAL fixes and clean ups Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210407102334.32361-15-johan@kernel.org \
    --to=johan@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=greybus-dev@lists.linaro.org \
    --cc=jirislaby@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.