Re: [PATCH 1/2] USB: cdc-acm: fix racy tty buffer accesses

From: Oliver Neukum
Date: Thu Sep 30 2021 - 05:04:28 EST



On 29.09.21 11:09, Johan Hovold wrote:
> A recent change that started reporting break events to the line
> discipline caused the tty-buffer insertions to no longer be serialised
> by inserting events also from the completion handler for the interrupt
> endpoint.
>
> Completion calls for distinct endpoints are not guaranteed to be
> serialised. For example, in case a host-controller driver uses
> bottom-half completion, the interrupt and bulk-in completion handlers
> can end up running in parallel on two CPUs (high-and low-prio tasklets,
> respectively) thereby breaking the tty layer's single producer
> assumption.
>
> Fix this by holding the read lock also when inserting characters from
> the bulk endpoint.
>
> Fixes: 08dff274edda ("cdc-acm: fix BREAK rx code path adding necessary calls")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Johan Hovold <johan@xxxxxxxxxx>
Acked-by: Oliver Neukum <oneukum@xxxxxxxx>