Re: [PATCH] USB: cdc-acm: fix racy TIOCMIWAIT implementation

From: Oliver Neukum

Date: Mon Sep 07 2026 - 05:51:01 EST




On 07.09.26 10:47, Johan Hovold wrote:
On Mon, Sep 07, 2026 at 10:17:38AM +0200, Oliver Neukum wrote:
On 07.09.26 08:55, Johan Hovold wrote:
The wakeup condition needs to be checked after adding the task to the
waitqueue and updating the task state to avoid missing a racing modem
status update or disconnect.

I am sorry, but in this case I have to ask:
Isn't TIOCMIWAIT inherently racy against the hardware?

What do you mean?

The interface does not state from or to which state it changed.
Now you could say that it is implicitly the last time TIOCMGET
was called, but that is

1. not clearly stated
2. not enforceable
Looking at the implementation again now, it seems further changes are
needed to fix the implementation, though. The completion handler should
not be updating old_count. That's for each TIOCMIWAIT to do.

I am sorry to be obnoxious about that, but I am afraid that would
break TIOCGICOUNT

Regards
Oliver