Skip to content

Commit b41c1fa

Browse files
oneukumgregkh
authored andcommitted
USB: class: CDC-ACM: fix race between get_serial and set_serial
TIOCGSERIAL is an ioctl. Thus it must be atomic. It returns two values. Racing with set_serial it can return an inconsistent result. The mutex must be taken. In terms of logic the bug is as old as the driver. In terms of code it goes back to the conversion to the get_serial and set_serial methods. Signed-off-by: Oliver Neukum <[email protected]> Cc: stable <[email protected]> Fixes: 99f75a1 ("cdc-acm: switch to ->[sg]et_serial()") Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 9ae0f26 commit b41c1fa

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/usb/class/cdc-acm.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -962,10 +962,12 @@ static int get_serial_info(struct tty_struct *tty, struct serial_struct *ss)
962962
struct acm *acm = tty->driver_data;
963963

964964
ss->line = acm->minor;
965+
mutex_lock(&acm->port.mutex);
965966
ss->close_delay = jiffies_to_msecs(acm->port.close_delay) / 10;
966967
ss->closing_wait = acm->port.closing_wait == ASYNC_CLOSING_WAIT_NONE ?
967968
ASYNC_CLOSING_WAIT_NONE :
968969
jiffies_to_msecs(acm->port.closing_wait) / 10;
970+
mutex_unlock(&acm->port.mutex);
969971
return 0;
970972
}
971973

0 commit comments

Comments
 (0)