Re: [PATCH net v2 1/2] wireguard: peer: free packets left on the per-peer queues on removal

From: Andrii Pasichnyk

Date: Fri Nov 27 2026 - 05:00:11 EST


Sashiko AI review wrote:
> [Severity: High]
> Can this purge of peer->tx_queue run while peer->transmit_packet_work is
> still pending or running on packet_crypt_wq?

Yes, it can. An encrypt worker that the second flush waits for can queue
transmit_packet_work after that flush has started, and then nothing
waits for it. Before this patch that was harmless, because the entries
on tx_queue keep the peer alive until the worker has consumed them. The
purge breaks that.

> Would a flush_work() or cancel_work_sync() on &peer->transmit_packet_work
> before purging tx_queue close this window?

It would, but the tx_queue purge is not needed at all. The leak I
reproduced is on rx_queue only: the transmit worker has no budget and
drains everything that is ready. So v3 will drop the tx_queue purge and
free only what the disabled NAPI left on rx_queue.

As far as I can see rx_queue does not have the same window: a decrypt
worker queues no further work when it is done, it only schedules the
NAPI, and napi_disable() waits for the poll.

> [Severity: Low]
> That makes the new comment the accurate one. Should the old comment be
> updated to match?

Yes. v3 updates it and says why tx_queue is left alone.

Thanks,
Andrii

pw-bot: cr