Re: [PATCH] USB: cdc-acm: fix racy TIOCMIWAIT implementation
From: Johan Hovold
Date: Mon Sep 07 2026 - 09:22:13 EST
On Mon, Sep 07, 2026 at 02:46:16PM +0200, Oliver Neukum wrote:
>
>
> On 07.09.26 13:38, Johan Hovold wrote:
> > On Mon, Sep 07, 2026 at 12:28:46PM +0200, Oliver Neukum wrote:
> >>
> >>
> >> On 07.09.26 12:01, Johan Hovold wrote:
> >>> On Mon, Sep 07, 2026 at 11:50:41AM +0200, Oliver Neukum wrote:
>
> >> Yes, but user space can call TIOCGICOUNT multiple times in sequence
> >> _without_ calling TIOCMIWAIT in between.
> >> In that case the counters have to increase if a line changes, don't they?
> >> For that to happen you need to handle a status change in the completion
> >> handler.
> >
> > Yes, the completion handler needs to handle the status change (i.e.
> > compare new and previous status and increment the counters), but it
> > shouldn't update any old *icount* structure.
>
> We could do that and it would indeed be simpler.
>
> But it would change the semantics so that past status changes
> no longer show up in TIOCMIWAIT. Is that really a good idea?
Yes, as the current behaviour is both non-standard and inconsistent.
If you have multiple tasks waiting waiting on status change, then only
one of them will detect it, for example.
And if there are multiple changes (before or during TIOCMIWAIT) events
may be lost too.
Johan