Linux-USB Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH 0/3] USB: cdc-acm: TIOCSSERIAL fixes
@ 2021-04-07 10:28 Johan Hovold
  2021-04-07 10:28 ` [PATCH 1/3] Revert "USB: cdc-acm: fix rounding error in TIOCSSERIAL" Johan Hovold
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Johan Hovold @ 2021-04-07 10:28 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Oliver Neukum, linux-usb, linux-kernel, Johan Hovold

This series fixes up a few issues with cdc-acm TIOCSSERIAL
implementation.

Johan


Johan Hovold (3):
  Revert "USB: cdc-acm: fix rounding error in TIOCSSERIAL"
  USB: cdc-acm: fix unprivileged TIOCCSERIAL
  USB: cdc-acm: fix TIOCGSERIAL implementation

 drivers/usb/class/cdc-acm.c | 16 +++-------------
 1 file changed, 3 insertions(+), 13 deletions(-)

-- 
2.26.3


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 1/3] Revert "USB: cdc-acm: fix rounding error in TIOCSSERIAL"
  2021-04-07 10:28 [PATCH 0/3] USB: cdc-acm: TIOCSSERIAL fixes Johan Hovold
@ 2021-04-07 10:28 ` Johan Hovold
  2021-04-07 11:04   ` Anthony Mallet
  2021-04-07 10:28 ` [PATCH 2/3] USB: cdc-acm: fix unprivileged TIOCCSERIAL Johan Hovold
  2021-04-07 10:28 ` [PATCH 3/3] USB: cdc-acm: fix TIOCGSERIAL implementation Johan Hovold
  2 siblings, 1 reply; 15+ messages in thread
From: Johan Hovold @ 2021-04-07 10:28 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Oliver Neukum, linux-usb, linux-kernel, Johan Hovold,
	Anthony Mallet, stable

This reverts commit b401f8c4f492cbf74f3f59c9141e5be3071071bb.

The offending commit claimed that trying to set the values reported back
by TIOCGSERIAL as a regular user could result in an -EPERM error when HZ
is 250, but that was never the case.

With HZ=250, the default 0.5 second value of close_delay is converted to
125 jiffies when set and is converted back to 50 centiseconds by
TIOCGSERIAL as expected (not 12 cs as was claimed).

Comparing the internal current and new jiffies values is just fine to
determine if the value is about to change so drop the bogus workaround
(which was also backported to stable).

For completeness: With different default values for these parameters or
with a HZ value not divisible by two, the lack of rounding when setting
the default values in tty_port_init() could result in an -EPERM being
returned, but this is hardly something we need to worry about.

Cc: Anthony Mallet <anthony.mallet@laas.fr>
Cc: stable@vger.kernel.org
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/usb/class/cdc-acm.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 3fda1ec961d7..96e221803fa6 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -942,7 +942,6 @@ static int set_serial_info(struct tty_struct *tty, struct serial_struct *ss)
 {
 	struct acm *acm = tty->driver_data;
 	unsigned int closing_wait, close_delay;
-	unsigned int old_closing_wait, old_close_delay;
 	int retval = 0;
 
 	close_delay = msecs_to_jiffies(ss->close_delay * 10);
@@ -950,17 +949,11 @@ static int set_serial_info(struct tty_struct *tty, struct serial_struct *ss)
 			ASYNC_CLOSING_WAIT_NONE :
 			msecs_to_jiffies(ss->closing_wait * 10);
 
-	/* we must redo the rounding here, so that the values match */
-	old_close_delay	= jiffies_to_msecs(acm->port.close_delay) / 10;
-	old_closing_wait = acm->port.closing_wait == ASYNC_CLOSING_WAIT_NONE ?
-				ASYNC_CLOSING_WAIT_NONE :
-				jiffies_to_msecs(acm->port.closing_wait) / 10;
-
 	mutex_lock(&acm->port.mutex);
 
 	if (!capable(CAP_SYS_ADMIN)) {
-		if ((ss->close_delay != old_close_delay) ||
-		    (ss->closing_wait != old_closing_wait))
+		if ((close_delay != acm->port.close_delay) ||
+		    (closing_wait != acm->port.closing_wait))
 			retval = -EPERM;
 		else
 			retval = -EOPNOTSUPP;
-- 
2.26.3


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 2/3] USB: cdc-acm: fix unprivileged TIOCCSERIAL
  2021-04-07 10:28 [PATCH 0/3] USB: cdc-acm: TIOCSSERIAL fixes Johan Hovold
  2021-04-07 10:28 ` [PATCH 1/3] Revert "USB: cdc-acm: fix rounding error in TIOCSSERIAL" Johan Hovold
@ 2021-04-07 10:28 ` Johan Hovold
  2021-04-08  7:48   ` Oliver Neukum
  2021-04-07 10:28 ` [PATCH 3/3] USB: cdc-acm: fix TIOCGSERIAL implementation Johan Hovold
  2 siblings, 1 reply; 15+ messages in thread
From: Johan Hovold @ 2021-04-07 10:28 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Oliver Neukum, linux-usb, linux-kernel, Johan Hovold

TIOCSSERIAL is a horrid, underspecified, legacy interface which for most
serial devices is only useful for setting the close_delay and
closing_wait parameters.

A non-privileged user has only ever been able to set the since long
deprecated ASYNC_SPD flags and trying to change any other *supported*
feature should result in -EPERM being returned. Setting the current
values for any supported features should return success.

Fix the cdc-acm implementation which instead indicated that the
TIOCSSERIAL ioctl was not even implemented when a non-privileged user
set the current values.

Fixes: ba2d8ce9db0a ("cdc-acm: implement TIOCSSERIAL to avoid blocking close(2)")
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/usb/class/cdc-acm.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 96e221803fa6..43e31dad4831 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -955,8 +955,6 @@ static int set_serial_info(struct tty_struct *tty, struct serial_struct *ss)
 		if ((close_delay != acm->port.close_delay) ||
 		    (closing_wait != acm->port.closing_wait))
 			retval = -EPERM;
-		else
-			retval = -EOPNOTSUPP;
 	} else {
 		acm->port.close_delay  = close_delay;
 		acm->port.closing_wait = closing_wait;
-- 
2.26.3


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 3/3] USB: cdc-acm: fix TIOCGSERIAL implementation
  2021-04-07 10:28 [PATCH 0/3] USB: cdc-acm: TIOCSSERIAL fixes Johan Hovold
  2021-04-07 10:28 ` [PATCH 1/3] Revert "USB: cdc-acm: fix rounding error in TIOCSSERIAL" Johan Hovold
  2021-04-07 10:28 ` [PATCH 2/3] USB: cdc-acm: fix unprivileged TIOCCSERIAL Johan Hovold
@ 2021-04-07 10:28 ` Johan Hovold
  2021-04-08  8:36   ` Oliver Neukum
  2 siblings, 1 reply; 15+ messages in thread
From: Johan Hovold @ 2021-04-07 10:28 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Oliver Neukum, linux-usb, linux-kernel, Johan Hovold

TIOCSSERIAL is a horrid, underspecified, legacy interface which for most
serial devices is only useful for setting the close_delay and
closing_wait parameters.

The xmit_fifo_size parameter could be used to set the hardware transmit
fifo size of a legacy UART when it could not be detected, but the
interface is limited to eight bits and should be left unset when it is
not used.

Similarly, baud_base could be used to set the uart base clock when it
could not be detected, but might as well be left unset when it is not
known.

Fix the cdc-acm TIOCGSERIAL implementation by dropping its custom
interpretation of the unused xmit_fifo_size and baud_base fields, which
overflowed the former with the URB buffer size and set the latter to the
current line speed. Also return the port line number, which is the only
other value used besides the close parameters.

Fixes: 18c75720e667 ("USB: allow users to run setserial with cdc-acm")
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/usb/class/cdc-acm.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 43e31dad4831..b74713518b3a 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -929,8 +929,7 @@ static int get_serial_info(struct tty_struct *tty, struct serial_struct *ss)
 {
 	struct acm *acm = tty->driver_data;
 
-	ss->xmit_fifo_size = acm->writesize;
-	ss->baud_base = le32_to_cpu(acm->line.dwDTERate);
+	ss->line = acm->minor;
 	ss->close_delay	= jiffies_to_msecs(acm->port.close_delay) / 10;
 	ss->closing_wait = acm->port.closing_wait == ASYNC_CLOSING_WAIT_NONE ?
 				ASYNC_CLOSING_WAIT_NONE :
-- 
2.26.3


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 1/3] Revert "USB: cdc-acm: fix rounding error in TIOCSSERIAL"
  2021-04-07 10:28 ` [PATCH 1/3] Revert "USB: cdc-acm: fix rounding error in TIOCSSERIAL" Johan Hovold
@ 2021-04-07 11:04   ` Anthony Mallet
  2021-04-07 11:25     ` Johan Hovold
  0 siblings, 1 reply; 15+ messages in thread
From: Anthony Mallet @ 2021-04-07 11:04 UTC (permalink / raw)
  To: Johan Hovold
  Cc: Greg Kroah-Hartman, Oliver Neukum, linux-usb, linux-kernel, stable

On Wednesday  7 Apr 2021, at 12:28, Johan Hovold wrote:
> With HZ=250, the default 0.5 second value of close_delay is converted to
> 125 jiffies when set and is converted back to 50 centiseconds by
> TIOCGSERIAL as expected (not 12 cs as was claimed).

It was "12" (instead of 50) because the conversion gor TIOCGSERIAL was
initially broken, and that was fixed in the previous commit
633e2b2ded739a34bd0fb1d8b5b871f7e489ea29

> For completeness: With different default values for these parameters or
> with a HZ value not divisible by two, the lack of rounding when setting
> the default values in tty_port_init() could result in an -EPERM being
> returned, but this is hardly something we need to worry about.

The -EPERM is harmful when a regular user wants to update other
members of serial_struct without changing the close delays,
e.g. ASYNC_LOW_LATENCY, which is granted to regular users.

Best,
Anthony

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 1/3] Revert "USB: cdc-acm: fix rounding error in TIOCSSERIAL"
  2021-04-07 11:04   ` Anthony Mallet
@ 2021-04-07 11:25     ` Johan Hovold
  0 siblings, 0 replies; 15+ messages in thread
From: Johan Hovold @ 2021-04-07 11:25 UTC (permalink / raw)
  To: Anthony Mallet
  Cc: Greg Kroah-Hartman, Oliver Neukum, linux-usb, linux-kernel, stable

On Wed, Apr 07, 2021 at 01:04:31PM +0200, Anthony Mallet wrote:
> On Wednesday  7 Apr 2021, at 12:28, Johan Hovold wrote:
> > With HZ=250, the default 0.5 second value of close_delay is converted to
> > 125 jiffies when set and is converted back to 50 centiseconds by
> > TIOCGSERIAL as expected (not 12 cs as was claimed).
> 
> It was "12" (instead of 50) because the conversion gor TIOCGSERIAL was
> initially broken, and that was fixed in the previous commit
> 633e2b2ded739a34bd0fb1d8b5b871f7e489ea29

Right, so this patch is still just broken. The missing jiffies
conversion had already been added.

> > For completeness: With different default values for these parameters or
> > with a HZ value not divisible by two, the lack of rounding when setting
> > the default values in tty_port_init() could result in an -EPERM being
> > returned, but this is hardly something we need to worry about.
> 
> The -EPERM is harmful when a regular user wants to update other
> members of serial_struct without changing the close delays,
> e.g. ASYNC_LOW_LATENCY, which is granted to regular users.

You're missing the point; -EPERM will *not* be returned -- and this
patch was never needed.

Johan

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 2/3] USB: cdc-acm: fix unprivileged TIOCCSERIAL
  2021-04-07 10:28 ` [PATCH 2/3] USB: cdc-acm: fix unprivileged TIOCCSERIAL Johan Hovold
@ 2021-04-08  7:48   ` Oliver Neukum
  2021-04-08  9:42     ` Johan Hovold
  0 siblings, 1 reply; 15+ messages in thread
From: Oliver Neukum @ 2021-04-08  7:48 UTC (permalink / raw)
  To: Johan Hovold, Greg Kroah-Hartman; +Cc: linux-usb, linux-kernel

Am Mittwoch, den 07.04.2021, 12:28 +0200 schrieb Johan Hovold:
> TIOCSSERIAL is a horrid, underspecified, legacy interface which for most
> serial devices is only useful for setting the close_delay and
> closing_wait parameters.
> 
> A non-privileged user has only ever been able to set the since long
> deprecated ASYNC_SPD flags and trying to change any other *supported*
> feature should result in -EPERM being returned. Setting the current
> values for any supported features should return success.
> 
> Fix the cdc-acm implementation which instead indicated that the
> TIOCSSERIAL ioctl was not even implemented when a non-privileged user
> set the current values.

Hi,

the idea here was that you are setting something else, if you are
not changing a parameter that can be changed. That conclusion is
dubious, but at the same time, this implementation can change
only these two parameters. So can the test really be dropped
as opposed to be modified?

	Regards
		Oliver



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 3/3] USB: cdc-acm: fix TIOCGSERIAL implementation
  2021-04-07 10:28 ` [PATCH 3/3] USB: cdc-acm: fix TIOCGSERIAL implementation Johan Hovold
@ 2021-04-08  8:36   ` Oliver Neukum
  2021-04-08  9:48     ` Johan Hovold
  0 siblings, 1 reply; 15+ messages in thread
From: Oliver Neukum @ 2021-04-08  8:36 UTC (permalink / raw)
  To: Johan Hovold, Greg Kroah-Hartman; +Cc: linux-usb, linux-kernel

Am Mittwoch, den 07.04.2021, 12:28 +0200 schrieb Johan Hovold:
> TIOCSSERIAL is a horrid, underspecified, legacy interface which for most
> serial devices is only useful for setting the close_delay and
> closing_wait parameters.
> 
> The xmit_fifo_size parameter could be used to set the hardware transmit
> fifo size of a legacy UART when it could not be detected, but the
> interface is limited to eight bits and should be left unset when it is
> not used.

OK.

> Similarly, baud_base could be used to set the uart base clock when it
> could not be detected, but might as well be left unset when it is not
> known.

Well, the devices report it. It is part of the standard.

> Fix the cdc-acm TIOCGSERIAL implementation by dropping its custom
> interpretation of the unused xmit_fifo_size and baud_base fields, which
> overflowed the former with the URB buffer size and set the latter to the
> current line speed. Also return the port line number, which is the only
> other value used besides the close parameters.
> 
> Fixes: 18c75720e667 ("USB: allow users to run setserial with cdc-acm")
> Signed-off-by: Johan Hovold <johan@kernel.org>
> ---
>  drivers/usb/class/cdc-acm.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
> index 43e31dad4831..b74713518b3a 100644
> --- a/drivers/usb/class/cdc-acm.c
> +++ b/drivers/usb/class/cdc-acm.c
> @@ -929,8 +929,7 @@ static int get_serial_info(struct tty_struct *tty, struct serial_struct *ss)
>  {
>  	struct acm *acm = tty->driver_data;
>  
> -	ss->xmit_fifo_size = acm->writesize;
> -	ss->baud_base = le32_to_cpu(acm->line.dwDTERate);

If we do this, we have a value that can be set, but is not reported.
That looks a bit strange to me.

	Regards
		Oliver



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 2/3] USB: cdc-acm: fix unprivileged TIOCCSERIAL
  2021-04-08  7:48   ` Oliver Neukum
@ 2021-04-08  9:42     ` Johan Hovold
  2021-04-08 11:35       ` Oliver Neukum
  0 siblings, 1 reply; 15+ messages in thread
From: Johan Hovold @ 2021-04-08  9:42 UTC (permalink / raw)
  To: Oliver Neukum; +Cc: Greg Kroah-Hartman, linux-usb, linux-kernel

On Thu, Apr 08, 2021 at 09:48:38AM +0200, Oliver Neukum wrote:
> Am Mittwoch, den 07.04.2021, 12:28 +0200 schrieb Johan Hovold:
> > TIOCSSERIAL is a horrid, underspecified, legacy interface which for most
> > serial devices is only useful for setting the close_delay and
> > closing_wait parameters.
> > 
> > A non-privileged user has only ever been able to set the since long
> > deprecated ASYNC_SPD flags and trying to change any other *supported*
> > feature should result in -EPERM being returned. Setting the current
> > values for any supported features should return success.
> > 
> > Fix the cdc-acm implementation which instead indicated that the
> > TIOCSSERIAL ioctl was not even implemented when a non-privileged user
> > set the current values.
> 
> Hi,
> 
> the idea here was that you are setting something else, if you are
> not changing a parameter that can be changed. That conclusion is
> dubious, but at the same time, this implementation can change
> only these two parameters. So can the test really be dropped
> as opposed to be modified?

The de-facto standard for how to handle change requests for
non-supported features (e.g. changing the I/O port or IRQ) is to simply
ignore them and return 0.

For most (non-legacy) serial devices the only relevant parameters are
close_delay and closing_wait. And as we need to return -EPERM when a
non-privileged user tries to change these, we cannot drop the test.

(And returning -EOPNOTSUPP was never correct as the ioctl is indeed
supported.)

Johan

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 3/3] USB: cdc-acm: fix TIOCGSERIAL implementation
  2021-04-08  8:36   ` Oliver Neukum
@ 2021-04-08  9:48     ` Johan Hovold
  2021-04-08 11:34       ` Oliver Neukum
  0 siblings, 1 reply; 15+ messages in thread
From: Johan Hovold @ 2021-04-08  9:48 UTC (permalink / raw)
  To: Oliver Neukum; +Cc: Greg Kroah-Hartman, linux-usb, linux-kernel

On Thu, Apr 08, 2021 at 10:36:46AM +0200, Oliver Neukum wrote:
> Am Mittwoch, den 07.04.2021, 12:28 +0200 schrieb Johan Hovold:
> > TIOCSSERIAL is a horrid, underspecified, legacy interface which for most
> > serial devices is only useful for setting the close_delay and
> > closing_wait parameters.
> > 
> > The xmit_fifo_size parameter could be used to set the hardware transmit
> > fifo size of a legacy UART when it could not be detected, but the
> > interface is limited to eight bits and should be left unset when it is
> > not used.
> 
> OK.
> 
> > Similarly, baud_base could be used to set the uart base clock when it
> > could not be detected, but might as well be left unset when it is not
> > known.
> 
> Well, the devices report it. It is part of the standard.

No, the standard doesn't include anything about a baud-base clock
AFAICT.

> > Fix the cdc-acm TIOCGSERIAL implementation by dropping its custom
> > interpretation of the unused xmit_fifo_size and baud_base fields, which
> > overflowed the former with the URB buffer size and set the latter to the
> > current line speed. Also return the port line number, which is the only
> > other value used besides the close parameters.
> > 
> > Fixes: 18c75720e667 ("USB: allow users to run setserial with cdc-acm")
> > Signed-off-by: Johan Hovold <johan@kernel.org>
> > ---
> >  drivers/usb/class/cdc-acm.c | 3 +--
> >  1 file changed, 1 insertion(+), 2 deletions(-)
> > 
> > diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
> > index 43e31dad4831..b74713518b3a 100644
> > --- a/drivers/usb/class/cdc-acm.c
> > +++ b/drivers/usb/class/cdc-acm.c
> > @@ -929,8 +929,7 @@ static int get_serial_info(struct tty_struct *tty, struct serial_struct *ss)
> >  {
> >  	struct acm *acm = tty->driver_data;
> >  
> > -	ss->xmit_fifo_size = acm->writesize;
> > -	ss->baud_base = le32_to_cpu(acm->line.dwDTERate);
> 
> If we do this, we have a value that can be set, but is not reported.
> That looks a bit strange to me.

Again, no, the baud_base cannot be set and it is unknown and unused.

The only reason to report back baud_base is to support the deprecated
ASYNC_SPD_CUST interface used to set a custom divisor. cdc-acm has never
supported that for obvious reasons.

Johan

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 3/3] USB: cdc-acm: fix TIOCGSERIAL implementation
  2021-04-08  9:48     ` Johan Hovold
@ 2021-04-08 11:34       ` Oliver Neukum
  2021-04-08 11:54         ` Johan Hovold
  0 siblings, 1 reply; 15+ messages in thread
From: Oliver Neukum @ 2021-04-08 11:34 UTC (permalink / raw)
  To: Johan Hovold; +Cc: Greg Kroah-Hartman, linux-usb, linux-kernel

Am Donnerstag, den 08.04.2021, 11:48 +0200 schrieb Johan Hovold:
> On Thu, Apr 08, 2021 at 10:36:46AM +0200, Oliver Neukum wrote:
> > Am Mittwoch, den 07.04.2021, 12:28 +0200 schrieb Johan Hovold:

> > Well, the devices report it. It is part of the standard.
> 
> No, the standard doesn't include anything about a baud-base clock
> AFAICT.

Unfortunately it does.
dwDTERate - chapter 6.3.11 - table 17

If we does this wrongly, we should certainly fix it, but just removing
the reporting doesn't look right to me.

	Regards
		Oliver



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 2/3] USB: cdc-acm: fix unprivileged TIOCCSERIAL
  2021-04-08  9:42     ` Johan Hovold
@ 2021-04-08 11:35       ` Oliver Neukum
  0 siblings, 0 replies; 15+ messages in thread
From: Oliver Neukum @ 2021-04-08 11:35 UTC (permalink / raw)
  To: Johan Hovold; +Cc: Greg Kroah-Hartman, linux-usb, linux-kernel

Am Donnerstag, den 08.04.2021, 11:42 +0200 schrieb Johan Hovold:
> On Thu, Apr 08, 2021 at 09:48:38AM +0200, Oliver Neukum wrote:
> > Am Mittwoch, den 07.04.2021, 12:28 +0200 schrieb Johan Hovold:
> > > TIOCSSERIAL is a horrid, underspecified, legacy interface which for most
> > > serial devices is only useful for setting the close_delay and
> > > closing_wait parameters.
> > > 
> > > A non-privileged user has only ever been able to set the since long
> > > deprecated ASYNC_SPD flags and trying to change any other *supported*
> > > feature should result in -EPERM being returned. Setting the current
> > > values for any supported features should return success.
> > > 
> > > Fix the cdc-acm implementation which instead indicated that the
> > > TIOCSSERIAL ioctl was not even implemented when a non-privileged user
> > > set the current values.
> > 
> > Hi,
> > 
> > the idea here was that you are setting something else, if you are
> > not changing a parameter that can be changed. That conclusion is
> > dubious, but at the same time, this implementation can change
> > only these two parameters. So can the test really be dropped
> > as opposed to be modified?
> 
> The de-facto standard for how to handle change requests for
> non-supported features (e.g. changing the I/O port or IRQ) is to simply
> ignore them and return 0.
> 
> For most (non-legacy) serial devices the only relevant parameters are
> close_delay and closing_wait. And as we need to return -EPERM when a
> non-privileged user tries to change these, we cannot drop the test.
> 
> (And returning -EOPNOTSUPP was never correct as the ioctl is indeed
> supported.)

OK, thanks for clarification. Yes the fix makes sense.

	Regards
		Oliver



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 3/3] USB: cdc-acm: fix TIOCGSERIAL implementation
  2021-04-08 11:34       ` Oliver Neukum
@ 2021-04-08 11:54         ` Johan Hovold
  2021-04-08 11:59           ` Oliver Neukum
  0 siblings, 1 reply; 15+ messages in thread
From: Johan Hovold @ 2021-04-08 11:54 UTC (permalink / raw)
  To: Oliver Neukum; +Cc: Greg Kroah-Hartman, linux-usb, linux-kernel

On Thu, Apr 08, 2021 at 01:34:12PM +0200, Oliver Neukum wrote:
> Am Donnerstag, den 08.04.2021, 11:48 +0200 schrieb Johan Hovold:
> > On Thu, Apr 08, 2021 at 10:36:46AM +0200, Oliver Neukum wrote:
> > > Am Mittwoch, den 07.04.2021, 12:28 +0200 schrieb Johan Hovold:
> 
> > > Well, the devices report it. It is part of the standard.
> > 
> > No, the standard doesn't include anything about a baud-base clock
> > AFAICT.
> 
> Unfortunately it does.
> dwDTERate - chapter 6.3.11 - table 17

That's not the base clock rate, that's just the currently configured
line speed which you can read from termios.
 
> If we does this wrongly, we should certainly fix it, but just removing
> the reporting doesn't look right to me.

The driver got its interpretation of baud_base wrong, and CDC doesn't
even have a concept of base clock rate so removing it is the right thing
to do.

Again, baud_base is really only relevant with legacy UARTs and when
using the deprecated ASYNC_SPD_CUST.

And if the user wants to knows the current line speed we have a
different interface for that.

Johan

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 3/3] USB: cdc-acm: fix TIOCGSERIAL implementation
  2021-04-08 11:54         ` Johan Hovold
@ 2021-04-08 11:59           ` Oliver Neukum
  2021-04-08 12:07             ` Greg Kroah-Hartman
  0 siblings, 1 reply; 15+ messages in thread
From: Oliver Neukum @ 2021-04-08 11:59 UTC (permalink / raw)
  To: Johan Hovold; +Cc: Greg Kroah-Hartman, linux-usb, linux-kernel

Am Donnerstag, den 08.04.2021, 13:54 +0200 schrieb Johan Hovold:
> On Thu, Apr 08, 2021 at 01:34:12PM +0200, Oliver Neukum wrote:
> > Am Donnerstag, den 08.04.2021, 11:48 +0200 schrieb Johan Hovold:
> > > On Thu, Apr 08, 2021 at 10:36:46AM +0200, Oliver Neukum wrote:
> > > > Am Mittwoch, den 07.04.2021, 12:28 +0200 schrieb Johan Hovold:
> > > > Well, the devices report it. It is part of the standard.
> > > 
> > > No, the standard doesn't include anything about a baud-base clock
> > > AFAICT.
> > 
> > Unfortunately it does.
> > dwDTERate - chapter 6.3.11 - table 17
> 
> That's not the base clock rate, that's just the currently configured
> line speed which you can read from termios 
> > If we does this wrongly, we should certainly fix it, but just removing
> > the reporting doesn't look right to me.
> 
> The driver got its interpretation of baud_base wrong, and CDC doesn't
> even have a concept of base clock rate so removing it is the right thing
> to do.
> 
> Again, baud_base is really only relevant with legacy UARTs and when
> using the deprecated ASYNC_SPD_CUST.
> 
> And if the user wants to knows the current line speed we have a
> different interface for that.

Hi,

thank you, that clarifies things. I am happy with the patch itself,
but could I ask you to do two things:

1. Edit the commit description
making clear that the difference
between the base clock rate and the line speed.

2. Mark the patch specially to NOT be included in stable. We may
have
users misusing the current API.

	Regards
		Oliver



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 3/3] USB: cdc-acm: fix TIOCGSERIAL implementation
  2021-04-08 11:59           ` Oliver Neukum
@ 2021-04-08 12:07             ` Greg Kroah-Hartman
  0 siblings, 0 replies; 15+ messages in thread
From: Greg Kroah-Hartman @ 2021-04-08 12:07 UTC (permalink / raw)
  To: Oliver Neukum; +Cc: Johan Hovold, linux-usb, linux-kernel

On Thu, Apr 08, 2021 at 01:59:43PM +0200, Oliver Neukum wrote:
> Am Donnerstag, den 08.04.2021, 13:54 +0200 schrieb Johan Hovold:
> > On Thu, Apr 08, 2021 at 01:34:12PM +0200, Oliver Neukum wrote:
> > > Am Donnerstag, den 08.04.2021, 11:48 +0200 schrieb Johan Hovold:
> > > > On Thu, Apr 08, 2021 at 10:36:46AM +0200, Oliver Neukum wrote:
> > > > > Am Mittwoch, den 07.04.2021, 12:28 +0200 schrieb Johan Hovold:
> > > > > Well, the devices report it. It is part of the standard.
> > > > 
> > > > No, the standard doesn't include anything about a baud-base clock
> > > > AFAICT.
> > > 
> > > Unfortunately it does.
> > > dwDTERate - chapter 6.3.11 - table 17
> > 
> > That's not the base clock rate, that's just the currently configured
> > line speed which you can read from termios 
> > > If we does this wrongly, we should certainly fix it, but just removing
> > > the reporting doesn't look right to me.
> > 
> > The driver got its interpretation of baud_base wrong, and CDC doesn't
> > even have a concept of base clock rate so removing it is the right thing
> > to do.
> > 
> > Again, baud_base is really only relevant with legacy UARTs and when
> > using the deprecated ASYNC_SPD_CUST.
> > 
> > And if the user wants to knows the current line speed we have a
> > different interface for that.
> 
> Hi,
> 
> thank you, that clarifies things. I am happy with the patch itself,
> but could I ask you to do two things:
> 
> 1. Edit the commit description
> making clear that the difference
> between the base clock rate and the line speed.
> 
> 2. Mark the patch specially to NOT be included in stable. We may
> have
> users misusing the current API.

That doesn't matter, if there are misusers then their use will "break"
on newer kernels.  And if so, then it doesn't deserve to be in any
release.

If a change is good enough for Linus's tree, that means it is good
enough for a stable tree, the requirements are exactly the same when it
comes to userspace interactions.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, back to index

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-07 10:28 [PATCH 0/3] USB: cdc-acm: TIOCSSERIAL fixes Johan Hovold
2021-04-07 10:28 ` [PATCH 1/3] Revert "USB: cdc-acm: fix rounding error in TIOCSSERIAL" Johan Hovold
2021-04-07 11:04   ` Anthony Mallet
2021-04-07 11:25     ` Johan Hovold
2021-04-07 10:28 ` [PATCH 2/3] USB: cdc-acm: fix unprivileged TIOCCSERIAL Johan Hovold
2021-04-08  7:48   ` Oliver Neukum
2021-04-08  9:42     ` Johan Hovold
2021-04-08 11:35       ` Oliver Neukum
2021-04-07 10:28 ` [PATCH 3/3] USB: cdc-acm: fix TIOCGSERIAL implementation Johan Hovold
2021-04-08  8:36   ` Oliver Neukum
2021-04-08  9:48     ` Johan Hovold
2021-04-08 11:34       ` Oliver Neukum
2021-04-08 11:54         ` Johan Hovold
2021-04-08 11:59           ` Oliver Neukum
2021-04-08 12:07             ` Greg Kroah-Hartman

Linux-USB Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-usb/0 linux-usb/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-usb linux-usb/ https://lore.kernel.org/linux-usb \
		linux-usb@vger.kernel.org
	public-inbox-index linux-usb

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-usb


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git