Re: [PATCH] serial: core: Fix atomicity violation in uart_tiocmget
From: Gui-Dong Han
Date: Fri Jan 12 2024 - 06:23:33 EST
Hi,
You are correct about the 'Fixes' tag. It should indeed be c5f4644e6c8b
("[PATCH] Serial: Adjust serial locking"). I will update this in the
patch v2.
Regarding the issue found in Linux 5.17, I mistakenly used git blame
which led to the incorrect identification of commit 559c7ff4e324. The
issue indeed exists in Linux 5.17 and I acknowledge the error in tracing
the commit.
In uart_tiocmget(), the result variable is stable. However, there's a
risk of inconsistency due to the updates in uart_update_mctrl().
Consider a scenario where uart_tiocmget() reads uport->mctrl into result
before entering the critical section. If uart_update_mctrl() updates
port->mctrl and calls set_mctrl concurrently, the subsequent execution
of result |= uport->ops->get_mctrl(uport); in uart_tiocmget() might
yield an inaccurate result. This happens because result contains the old
value of port->mctrl, which no longer matches the updated state
retrieved by get_mctrl.
Thanks,
Han