]> git.baikalelectronics.ru Git - kernel.git/commit
tty: n_gsm: fix race condition in gsmld_write()
authorDaniel Starke <daniel.starke@siemens.com>
Fri, 1 Jul 2022 06:16:52 +0000 (08:16 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 Aug 2022 12:24:05 +0000 (14:24 +0200)
commit4d43eba1fb3acff2efaf35bd3532a19dadd32ef7
treee58debfaa634bb3607ce0f2155e2bb394a1a45d8
parentc2399be9010f6147000370b390ace8a49f851b63
tty: n_gsm: fix race condition in gsmld_write()

[ Upstream commit 5326d1492ede5e82b2e7d08db965026e57787fb4 ]

The function may be used by the user directly and also by the n_gsm
internal functions. They can lead into a race condition which results in
interleaved frames if both are writing at the same time. The receiving side
is not able to decode those interleaved frames correctly.

Add a lock around the low side tty write to avoid race conditions and frame
interleaving between user originated writes and n_gsm writes.

Fixes: 99551fa31543 ("tty: n_gsm line discipline")
Signed-off-by: Daniel Starke <daniel.starke@siemens.com>
Link: https://lore.kernel.org/r/20220701061652.39604-9-daniel.starke@siemens.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/tty/n_gsm.c