* [PATCH 01/16] staging: fwserial: fix TIOCSSERIAL jiffies conversions
[not found] <20210407102334.32361-1-johan@kernel.org>
@ 2021-04-07 10:23 ` Johan Hovold
2021-04-07 10:23 ` [PATCH 02/16] staging: fwserial: fix TIOCSSERIAL permission check Johan Hovold
` (6 subsequent siblings)
7 siblings, 0 replies; 8+ messages in thread
From: Johan Hovold @ 2021-04-07 10:23 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Jiri Slaby, linux-staging, greybus-dev, linux-kernel,
Johan Hovold, stable
The port close_delay parameter set by TIOCSSERIAL is specified in
jiffies, while the value returned by TIOCGSERIAL is specified in
centiseconds.
Add the missing conversions so that TIOCGSERIAL works as expected also
when HZ is not 100.
Fixes: 7355ba3445f2 ("staging: fwserial: Add TTY-over-Firewire serial driver")
Cc: stable@vger.kernel.org # 3.8
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/staging/fwserial/fwserial.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/fwserial/fwserial.c b/drivers/staging/fwserial/fwserial.c
index c368082aae1a..c963848522b1 100644
--- a/drivers/staging/fwserial/fwserial.c
+++ b/drivers/staging/fwserial/fwserial.c
@@ -1223,7 +1223,7 @@ static int get_serial_info(struct tty_struct *tty,
ss->flags = port->port.flags;
ss->xmit_fifo_size = FWTTY_PORT_TXFIFO_LEN;
ss->baud_base = 400000000;
- ss->close_delay = port->port.close_delay;
+ ss->close_delay = jiffies_to_msecs(port->port.close_delay) / 10;
mutex_unlock(&port->port.mutex);
return 0;
}
@@ -1245,7 +1245,7 @@ static int set_serial_info(struct tty_struct *tty,
return -EPERM;
}
}
- port->port.close_delay = ss->close_delay * HZ / 100;
+ port->port.close_delay = msecs_to_jiffies(ss->close_delay * 10);
mutex_unlock(&port->port.mutex);
return 0;
--
2.26.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 02/16] staging: fwserial: fix TIOCSSERIAL permission check
[not found] <20210407102334.32361-1-johan@kernel.org>
2021-04-07 10:23 ` [PATCH 01/16] staging: fwserial: fix TIOCSSERIAL jiffies conversions Johan Hovold
@ 2021-04-07 10:23 ` Johan Hovold
2021-04-07 10:23 ` [PATCH 05/16] staging: greybus: uart: fix TIOCSSERIAL jiffies conversions Johan Hovold
` (5 subsequent siblings)
7 siblings, 0 replies; 8+ messages in thread
From: Johan Hovold @ 2021-04-07 10:23 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Jiri Slaby, linux-staging, greybus-dev, linux-kernel,
Johan Hovold, stable
Changing the port close-delay parameter is a privileged operation so
make sure to return -EPERM if a regular user tries to change it.
Fixes: 7355ba3445f2 ("staging: fwserial: Add TTY-over-Firewire serial driver")
Cc: stable@vger.kernel.org # 3.8
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/staging/fwserial/fwserial.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/fwserial/fwserial.c b/drivers/staging/fwserial/fwserial.c
index c963848522b1..440d11423812 100644
--- a/drivers/staging/fwserial/fwserial.c
+++ b/drivers/staging/fwserial/fwserial.c
@@ -1232,20 +1232,24 @@ static int set_serial_info(struct tty_struct *tty,
struct serial_struct *ss)
{
struct fwtty_port *port = tty->driver_data;
+ unsigned int cdelay;
if (ss->irq != 0 || ss->port != 0 || ss->custom_divisor != 0 ||
ss->baud_base != 400000000)
return -EPERM;
+ cdelay = msecs_to_jiffies(ss->close_delay * 10);
+
mutex_lock(&port->port.mutex);
if (!capable(CAP_SYS_ADMIN)) {
- if (((ss->flags & ~ASYNC_USR_MASK) !=
+ if (cdelay != port->port.close_delay ||
+ ((ss->flags & ~ASYNC_USR_MASK) !=
(port->port.flags & ~ASYNC_USR_MASK))) {
mutex_unlock(&port->port.mutex);
return -EPERM;
}
}
- port->port.close_delay = msecs_to_jiffies(ss->close_delay * 10);
+ port->port.close_delay = cdelay;
mutex_unlock(&port->port.mutex);
return 0;
--
2.26.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 05/16] staging: greybus: uart: fix TIOCSSERIAL jiffies conversions
[not found] <20210407102334.32361-1-johan@kernel.org>
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 ` Johan Hovold
2021-04-07 10:23 ` [PATCH 08/16] tty: amiserial: fix TIOCSSERIAL permission check Johan Hovold
` (4 subsequent siblings)
7 siblings, 0 replies; 8+ messages in thread
From: Johan Hovold @ 2021-04-07 10:23 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Jiri Slaby, linux-staging, greybus-dev, linux-kernel,
Johan Hovold, stable
The port close_delay and closing_wait parameters set by TIOCSSERIAL are
specified in jiffies and not milliseconds.
Add the missing conversions so that TIOCSSERIAL works as expected also
when HZ is not 1000.
Fixes: e68453ed28c5 ("greybus: uart-gb: now builds, more framework added")
Cc: stable@vger.kernel.org # 4.9
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/staging/greybus/uart.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/greybus/uart.c b/drivers/staging/greybus/uart.c
index 607378bfebb7..29846dc1e1bf 100644
--- a/drivers/staging/greybus/uart.c
+++ b/drivers/staging/greybus/uart.c
@@ -614,10 +614,12 @@ static int get_serial_info(struct tty_struct *tty,
ss->line = gb_tty->minor;
ss->xmit_fifo_size = 16;
ss->baud_base = 9600;
- ss->close_delay = gb_tty->port.close_delay / 10;
+ ss->close_delay = jiffies_to_msecs(gb_tty->port.close_delay) / 10;
ss->closing_wait =
gb_tty->port.closing_wait == ASYNC_CLOSING_WAIT_NONE ?
- ASYNC_CLOSING_WAIT_NONE : gb_tty->port.closing_wait / 10;
+ ASYNC_CLOSING_WAIT_NONE :
+ jiffies_to_msecs(gb_tty->port.closing_wait) / 10;
+
return 0;
}
@@ -629,9 +631,10 @@ static int set_serial_info(struct tty_struct *tty,
unsigned int close_delay;
int retval = 0;
- close_delay = ss->close_delay * 10;
+ close_delay = msecs_to_jiffies(ss->close_delay * 10);
closing_wait = ss->closing_wait == ASYNC_CLOSING_WAIT_NONE ?
- ASYNC_CLOSING_WAIT_NONE : ss->closing_wait * 10;
+ ASYNC_CLOSING_WAIT_NONE :
+ msecs_to_jiffies(ss->closing_wait * 10);
mutex_lock(&gb_tty->port.mutex);
if (!capable(CAP_SYS_ADMIN)) {
--
2.26.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 08/16] tty: amiserial: fix TIOCSSERIAL permission check
[not found] <20210407102334.32361-1-johan@kernel.org>
` (2 preceding siblings ...)
2021-04-07 10:23 ` [PATCH 05/16] staging: greybus: uart: fix TIOCSSERIAL jiffies conversions Johan Hovold
@ 2021-04-07 10:23 ` Johan Hovold
2021-04-07 10:23 ` [PATCH 10/16] tty: moxa: fix TIOCSSERIAL jiffies conversions Johan Hovold
` (3 subsequent siblings)
7 siblings, 0 replies; 8+ messages in thread
From: Johan Hovold @ 2021-04-07 10:23 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Jiri Slaby, linux-staging, greybus-dev, linux-kernel,
Johan Hovold, stable
Changing the port closing_wait parameter is a privileged operation.
Add the missing check to TIOCSSERIAL so that -EPERM is returned in case
an unprivileged user tries to change the closing-wait setting.
Cc: stable@vger.kernel.org
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/tty/amiserial.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
index 0c8157fab17f..ec6802ba2bf8 100644
--- a/drivers/tty/amiserial.c
+++ b/drivers/tty/amiserial.c
@@ -970,6 +970,7 @@ static int set_serial_info(struct tty_struct *tty, struct serial_struct *ss)
if (!serial_isroot()) {
if ((ss->baud_base != state->baud_base) ||
(ss->close_delay != port->close_delay) ||
+ (ss->closing_wait != port->closing_wait) ||
(ss->xmit_fifo_size != state->xmit_fifo_size) ||
((ss->flags & ~ASYNC_USR_MASK) !=
(port->flags & ~ASYNC_USR_MASK))) {
--
2.26.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 10/16] tty: moxa: fix TIOCSSERIAL jiffies conversions
[not found] <20210407102334.32361-1-johan@kernel.org>
` (3 preceding siblings ...)
2021-04-07 10:23 ` [PATCH 08/16] tty: amiserial: fix TIOCSSERIAL permission check Johan Hovold
@ 2021-04-07 10:23 ` Johan Hovold
2021-04-07 10:23 ` [PATCH 11/16] tty: moxa: fix TIOCSSERIAL permission check Johan Hovold
` (2 subsequent siblings)
7 siblings, 0 replies; 8+ messages in thread
From: Johan Hovold @ 2021-04-07 10:23 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Jiri Slaby, linux-staging, greybus-dev, linux-kernel,
Johan Hovold, stable
The port close_delay parameter set by TIOCSSERIAL is specified in
jiffies, while the value returned by TIOCGSERIAL is specified in
centiseconds.
Add the missing conversions so that TIOCGSERIAL works as expected also
when HZ is not 100.
Cc: stable@vger.kernel.org
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/tty/moxa.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
index 32eb6b5e510f..5b7bc7af8b1e 100644
--- a/drivers/tty/moxa.c
+++ b/drivers/tty/moxa.c
@@ -2038,7 +2038,7 @@ static int moxa_get_serial_info(struct tty_struct *tty,
ss->line = info->port.tty->index,
ss->flags = info->port.flags,
ss->baud_base = 921600,
- ss->close_delay = info->port.close_delay;
+ ss->close_delay = jiffies_to_msecs(info->port.close_delay) / 10;
mutex_unlock(&info->port.mutex);
return 0;
}
@@ -2067,7 +2067,7 @@ static int moxa_set_serial_info(struct tty_struct *tty,
return -EPERM;
}
}
- info->port.close_delay = ss->close_delay * HZ / 100;
+ info->port.close_delay = msecs_to_jiffies(ss->close_delay * 10);
MoxaSetFifo(info, ss->type == PORT_16550A);
--
2.26.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 11/16] tty: moxa: fix TIOCSSERIAL permission check
[not found] <20210407102334.32361-1-johan@kernel.org>
` (4 preceding siblings ...)
2021-04-07 10:23 ` [PATCH 10/16] tty: moxa: fix TIOCSSERIAL jiffies conversions Johan Hovold
@ 2021-04-07 10:23 ` Johan Hovold
2021-04-07 10:23 ` [PATCH 13/16] tty: mxser: fix TIOCSSERIAL jiffies conversions Johan Hovold
2021-04-07 10:23 ` [PATCH 14/16] tty: mxser: fix TIOCSSERIAL permission check Johan Hovold
7 siblings, 0 replies; 8+ messages in thread
From: Johan Hovold @ 2021-04-07 10:23 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Jiri Slaby, linux-staging, greybus-dev, linux-kernel,
Johan Hovold, stable
Changing the port close delay or type are privileged operations so make
sure to return -EPERM if a regular user tries to change them.
Cc: stable@vger.kernel.org
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/tty/moxa.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
index 5b7bc7af8b1e..63e440d900ff 100644
--- a/drivers/tty/moxa.c
+++ b/drivers/tty/moxa.c
@@ -2048,6 +2048,7 @@ static int moxa_set_serial_info(struct tty_struct *tty,
struct serial_struct *ss)
{
struct moxa_port *info = tty->driver_data;
+ unsigned int close_delay;
if (tty->index == MAX_PORTS)
return -EINVAL;
@@ -2059,19 +2060,24 @@ static int moxa_set_serial_info(struct tty_struct *tty,
ss->baud_base != 921600)
return -EPERM;
+ close_delay = msecs_to_jiffies(ss->close_delay * 10);
+
mutex_lock(&info->port.mutex);
if (!capable(CAP_SYS_ADMIN)) {
- if (((ss->flags & ~ASYNC_USR_MASK) !=
+ if (close_delay != info->port.close_delay ||
+ ss->type != info->type ||
+ ((ss->flags & ~ASYNC_USR_MASK) !=
(info->port.flags & ~ASYNC_USR_MASK))) {
mutex_unlock(&info->port.mutex);
return -EPERM;
}
- }
- info->port.close_delay = msecs_to_jiffies(ss->close_delay * 10);
+ } else {
+ info->port.close_delay = close_delay;
- MoxaSetFifo(info, ss->type == PORT_16550A);
+ MoxaSetFifo(info, ss->type == PORT_16550A);
- info->type = ss->type;
+ info->type = ss->type;
+ }
mutex_unlock(&info->port.mutex);
return 0;
}
--
2.26.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 13/16] tty: mxser: fix TIOCSSERIAL jiffies conversions
[not found] <20210407102334.32361-1-johan@kernel.org>
` (5 preceding siblings ...)
2021-04-07 10:23 ` [PATCH 11/16] tty: moxa: fix TIOCSSERIAL permission check Johan Hovold
@ 2021-04-07 10:23 ` Johan Hovold
2021-04-07 10:23 ` [PATCH 14/16] tty: mxser: fix TIOCSSERIAL permission check Johan Hovold
7 siblings, 0 replies; 8+ messages in thread
From: Johan Hovold @ 2021-04-07 10:23 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Jiri Slaby, linux-staging, greybus-dev, linux-kernel,
Johan Hovold, stable
The port close_delay and closing wait parameters set by TIOCSSERIAL are
specified in jiffies, while the values returned by TIOCGSERIAL are
specified in centiseconds.
Add the missing conversions so that TIOCSSERIAL works as expected also
when HZ is not 100.
Cc: stable@vger.kernel.org
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/tty/mxser.c | 24 ++++++++++++++++++------
1 file changed, 18 insertions(+), 6 deletions(-)
diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index 4203b64bccdb..914b23071961 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -1208,19 +1208,26 @@ static int mxser_get_serial_info(struct tty_struct *tty,
{
struct mxser_port *info = tty->driver_data;
struct tty_port *port = &info->port;
+ unsigned int closing_wait, close_delay;
if (tty->index == MXSER_PORTS)
return -ENOTTY;
mutex_lock(&port->mutex);
+
+ close_delay = jiffies_to_msecs(info->port.close_delay) / 10;
+ closing_wait = info->port.closing_wait;
+ if (closing_wait != ASYNC_CLOSING_WAIT_NONE)
+ closing_wait = jiffies_to_msecs(closing_wait) / 10;
+
ss->type = info->type,
ss->line = tty->index,
ss->port = info->ioaddr,
ss->irq = info->board->irq,
ss->flags = info->port.flags,
ss->baud_base = info->baud_base,
- ss->close_delay = info->port.close_delay,
- ss->closing_wait = info->port.closing_wait,
+ ss->close_delay = close_delay;
+ ss->closing_wait = closing_wait;
ss->custom_divisor = info->custom_divisor,
mutex_unlock(&port->mutex);
return 0;
@@ -1233,7 +1240,7 @@ static int mxser_set_serial_info(struct tty_struct *tty,
struct tty_port *port = &info->port;
speed_t baud;
unsigned long sl_flags;
- unsigned int flags;
+ unsigned int flags, close_delay, closing_wait;
int retval = 0;
if (tty->index == MXSER_PORTS)
@@ -1255,9 +1262,14 @@ static int mxser_set_serial_info(struct tty_struct *tty,
flags = port->flags & ASYNC_SPD_MASK;
+ close_delay = msecs_to_jiffies(ss->close_delay * 10);
+ closing_wait = ss->closing_wait;
+ if (closing_wait != ASYNC_CLOSING_WAIT_NONE)
+ closing_wait = msecs_to_jiffies(closing_wait * 10);
+
if (!capable(CAP_SYS_ADMIN)) {
if ((ss->baud_base != info->baud_base) ||
- (ss->close_delay != info->port.close_delay) ||
+ (close_delay != info->port.close_delay) ||
((ss->flags & ~ASYNC_USR_MASK) != (info->port.flags & ~ASYNC_USR_MASK))) {
mutex_unlock(&port->mutex);
return -EPERM;
@@ -1271,8 +1283,8 @@ static int mxser_set_serial_info(struct tty_struct *tty,
*/
port->flags = ((port->flags & ~ASYNC_FLAGS) |
(ss->flags & ASYNC_FLAGS));
- port->close_delay = ss->close_delay * HZ / 100;
- port->closing_wait = ss->closing_wait * HZ / 100;
+ port->close_delay = close_delay;
+ port->closing_wait = closing_wait;
if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST &&
(ss->baud_base != info->baud_base ||
ss->custom_divisor !=
--
2.26.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 14/16] tty: mxser: fix TIOCSSERIAL permission check
[not found] <20210407102334.32361-1-johan@kernel.org>
` (6 preceding siblings ...)
2021-04-07 10:23 ` [PATCH 13/16] tty: mxser: fix TIOCSSERIAL jiffies conversions Johan Hovold
@ 2021-04-07 10:23 ` Johan Hovold
7 siblings, 0 replies; 8+ messages in thread
From: Johan Hovold @ 2021-04-07 10:23 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Jiri Slaby, linux-staging, greybus-dev, linux-kernel,
Johan Hovold, stable
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
^ permalink raw reply related [flat|nested] 8+ messages in thread
end of thread, other threads:[~2021-04-07 10:23 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20210407102334.32361-1-johan@kernel.org>
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 05/16] staging: greybus: uart: fix TIOCSSERIAL jiffies conversions Johan Hovold
2021-04-07 10:23 ` [PATCH 08/16] tty: amiserial: fix TIOCSSERIAL permission check Johan Hovold
2021-04-07 10:23 ` [PATCH 10/16] tty: moxa: fix TIOCSSERIAL jiffies conversions Johan Hovold
2021-04-07 10:23 ` [PATCH 11/16] tty: moxa: fix TIOCSSERIAL permission check Johan Hovold
2021-04-07 10:23 ` [PATCH 13/16] tty: mxser: fix TIOCSSERIAL jiffies conversions Johan Hovold
2021-04-07 10:23 ` [PATCH 14/16] tty: mxser: fix TIOCSSERIAL permission check Johan Hovold
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).