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

From: Johan Hovold

Date: Mon Sep 07 2026 - 07:46:25 EST


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:
> >> 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:
>
> [..]
> >>> 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
> >
> > Why do you think so? TIOCGICOUNT just returns the current counters.
>
> 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.

Johan