Skip to content

Commit 85d5fb8

Browse files
dhowellsgregkh
authored andcommitted
afs: Fix netns teardown to cancel the preallocation charger
commit 47694fb upstream. Fix the teardown of an afs network namespace to make sure it cancels the work item that keeps the preallocated rxrpc call/conn/peer queue charged before incoming calls are disabled (i.e. listen 0). Also, if net->live is false because the afs netns is being deleted, make afs_charge_preallocation() skip charging and make afs_rx_new_call() avoid requeuing the charger. (This was found by AI review). Fixes: 00e9071 ("rxrpc: Preallocate peers, conns and calls for incoming service requests") Reported-by: Simon Horman <horms@kernel.org> Signed-off-by: David Howells <dhowells@redhat.com> cc: Li Daming <d4n.for.sec@gmail.com> cc: Ren Wei <n05ec@lzu.edu.cn> cc: Marc Dionne <marc.dionne@auristor.com> cc: Jeffrey Altman <jaltman@auristor.com> cc: linux-afs@lists.infradead.org cc: stable@kernel.org Link: https://patch.msgid.link/20260609140911.838677-5-dhowells@redhat.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 86eff31 commit 85d5fb8

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

fs/afs/rxrpc.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ void afs_close_socket(struct afs_net *net)
109109
{
110110
_enter("");
111111

112+
cancel_work_sync(&net->charge_preallocation_work);
112113
kernel_listen(net->socket, 0);
113114
flush_workqueue(afs_async_calls);
114115

@@ -727,7 +728,7 @@ void afs_charge_preallocation(struct work_struct *work)
727728
container_of(work, struct afs_net, charge_preallocation_work);
728729
struct afs_call *call = net->spare_incoming_call;
729730

730-
for (;;) {
731+
while (READ_ONCE(net->live)) {
731732
if (!call) {
732733
call = afs_alloc_call(net, &afs_RXCMxxxx, GFP_KERNEL);
733734
if (!call)
@@ -772,7 +773,8 @@ static void afs_rx_new_call(struct sock *sk, struct rxrpc_call *rxcall,
772773
{
773774
struct afs_net *net = afs_sock2net(sk);
774775

775-
queue_work(afs_wq, &net->charge_preallocation_work);
776+
if (net->live)
777+
queue_work(afs_wq, &net->charge_preallocation_work);
776778
}
777779

778780
/*

0 commit comments

Comments
 (0)