]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
net: qrtr: ns: Fix use-after-free in driver remove()
authorManivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
Thu, 9 Apr 2026 17:34:16 +0000 (23:04 +0530)
committerJakub Kicinski <kuba@kernel.org>
Mon, 13 Apr 2026 22:34:07 +0000 (15:34 -0700)
commit7809fea20c9404bfcfa6112ec08d1fe1d3520beb
treea34e2e9d489c5c4c9af22058d875eacd383d95a3
parent27d5e84e810b0849d08b9aec68e48570461ce313
net: qrtr: ns: Fix use-after-free in driver remove()

In the remove callback, if a packet arrives after destroy_workqueue() is
called, but before sock_release(), the qrtr_ns_data_ready() callback will
try to queue the work, causing use-after-free issue.

Fix this issue by saving the default 'sk_data_ready' callback during
qrtr_ns_init() and use it to replace the qrtr_ns_data_ready() callback at
the start of remove(). This ensures that even if a packet arrives after
destroy_workqueue(), the work struct will not be dereferenced.

Note that it is also required to ensure that the RX threads are completed
before destroying the workqueue, because the threads could be using the
qrtr_ns_data_ready() callback.

Cc: stable@vger.kernel.org
Fixes: 0c2204a4ad71 ("net: qrtr: Migrate nameservice to kernel from userspace")
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
Link: https://patch.msgid.link/20260409-qrtr-fix-v3-5-00a8a5ff2b51@oss.qualcomm.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/qrtr/ns.c