Re: [PATCH net v2] ppp: serialize channel operations with unregister

From: Simon Horman

Date: Thu Nov 26 2026 - 09:30:56 EST


On Thu, Nov 19, 2026 at 04:43:33PM +0800, Haoli Zhang wrote:
> The channel unregister path disconnects a channel before clearing
> pch->chan. A concurrent PPPIOCCONNECT can observe pch->ppp as NULL while
> pch->chan is still valid and attach the channel again. Unregister can
> then clear pch->chan and release the channel while its clist remains
> linked to a PPP unit.
>
> Serialize PPPIOCCONNECT with unregister using chan_sem. Hold the mutex
> from before disconnecting the channel until it has been removed from the
> channel list and marked dead. An in-flight connect completes before
> unregister disconnects the channel; later connects see the cleared
> channel and fail.
>
> PPPIOCDISCONN must use the same mutex. An in-progress PPPIOCDISCONN can
> clear pch->ppp before it has removed pch->clist and completed
> synchronize_net(). Without the mutex, unregister can see pch->ppp as NULL
> and proceed before that disconnect has finished unlinking the channel and
> waiting for network readers. Taking chan_sem in both paths makes
> unregister wait for the disconnect to finish before clearing pch->chan.
>
> Bridge establishment must also be serialized with unregistering either
> endpoint. Hold both channels' chan_sem mutexes in a stable order while
> establishing the bridge, and reject channels that have been marked dead.
> Unregister holds its channel mutex through unbridging and marking the
> channel dead, so bridge establishment cannot pass the teardown step and
> leave a new bridge reference behind.
>
> The transmit fast path is unchanged. chan_sem drains channel ioctl
> callbacks. ppp_disconnect_channel() removes the channel from the PPP unit
> and waits for network readers before unregister clears pch->chan.
>
> Fixes: 6a196e83a1a7 ("ppp: disconnect channel before nullifying pch->chan")
> Reported-by: syzbot+6b18da3ef22e33061add@xxxxxxxxxxxxxxxxxxxxxxxxx
> Closes: https://syzbot.org/bug?extid=6b18da3ef22e33061add
> Co-developed-by: Jinning Zhang <25031212117@xxxxxxxxxxxxxxxxx>
> Signed-off-by: Jinning Zhang <25031212117@xxxxxxxxxxxxxxxxx>
> Co-developed-by: Bin Yu <byu@xxxxxxxxxxxxx>
> Signed-off-by: Bin Yu <byu@xxxxxxxxxxxxx>
> Signed-off-by: Haoli Zhang <26031212468@xxxxxxxxxxxxxxxxx>
> ---
> Changes in v2:
> - Serialize PPPIOCDISCONN with channel unregister.
> - Serialize bridge establishment with unregistering either endpoint.
> - Clarify the chan_sem comment and bridge lock ordering.

Reviewed-by: Simon Horman <horms@xxxxxxxxxx>