diff options
author | Jia-Ju Bai <baijiaju1990@gmail.com> | 2019-01-08 08:04:48 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2019-01-11 20:56:47 -0500 |
commit | 2ff33d6637393fe9348357285931811b76e1402f (patch) | |
tree | f6090d0aa33f29b60ad0460e63e9916c7a0997a2 | |
parent | 7fbe078c37aba3088359c9256c1a1d0c3e39ee81 (diff) |
isdn: i4l: isdn_tty: Fix some concurrency double-free bugs
The functions isdn_tty_tiocmset() and isdn_tty_set_termios() may be
concurrently executed.
isdn_tty_tiocmset
isdn_tty_modem_hup
line 719: kfree(info->dtmf_state);
line 721: kfree(info->silence_state);
line 723: kfree(info->adpcms);
line 725: kfree(info->adpcmr);
isdn_tty_set_termios
isdn_tty_modem_hup
line 719: kfree(info->dtmf_state);
line 721: kfree(info->silence_state);
line 723: kfree(info->adpcms);
line 725: kfree(info->adpcmr);
Thus, some concurrency double-free bugs may occur.
These possible bugs are found by a static tool written by myself and
my manual code review.
To fix these possible bugs, the mutex lock "modem_info_mutex" used in
isdn_tty_tiocmset() is added in isdn_tty_set_termios().
Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/isdn/i4l/isdn_tty.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c index 1b2239c1d569..dc1cded716c1 100644 --- a/drivers/isdn/i4l/isdn_tty.c +++ b/drivers/isdn/i4l/isdn_tty.c | |||
@@ -1437,15 +1437,19 @@ isdn_tty_set_termios(struct tty_struct *tty, struct ktermios *old_termios) | |||
1437 | { | 1437 | { |
1438 | modem_info *info = (modem_info *) tty->driver_data; | 1438 | modem_info *info = (modem_info *) tty->driver_data; |
1439 | 1439 | ||
1440 | mutex_lock(&modem_info_mutex); | ||
1440 | if (!old_termios) | 1441 | if (!old_termios) |
1441 | isdn_tty_change_speed(info); | 1442 | isdn_tty_change_speed(info); |
1442 | else { | 1443 | else { |
1443 | if (tty->termios.c_cflag == old_termios->c_cflag && | 1444 | if (tty->termios.c_cflag == old_termios->c_cflag && |
1444 | tty->termios.c_ispeed == old_termios->c_ispeed && | 1445 | tty->termios.c_ispeed == old_termios->c_ispeed && |
1445 | tty->termios.c_ospeed == old_termios->c_ospeed) | 1446 | tty->termios.c_ospeed == old_termios->c_ospeed) { |
1447 | mutex_unlock(&modem_info_mutex); | ||
1446 | return; | 1448 | return; |
1449 | } | ||
1447 | isdn_tty_change_speed(info); | 1450 | isdn_tty_change_speed(info); |
1448 | } | 1451 | } |
1452 | mutex_unlock(&modem_info_mutex); | ||
1449 | } | 1453 | } |
1450 | 1454 | ||
1451 | /* | 1455 | /* |