Skip to content

Commit c9efde1

Browse files
Votokina Victoriakuba-moo
authored andcommitted
nfc: hci: shdlc: Stop timers and work before freeing context
llc_shdlc_deinit() purges SHDLC skb queues and frees the llc_shdlc structure while its timers and state machine work may still be active. Timer callbacks can schedule sm_work, and sm_work accesses SHDLC state and the skb queues. If teardown happens in parallel with a queued/running work item, it can lead to UAF and other shutdown races. Stop all SHDLC timers and cancel sm_work synchronously before purging the queues and freeing the context. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: 4a61cd6 ("NFC: Add an shdlc llc module to llc core") Signed-off-by: Votokina Victoria <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent e1aa5ef commit c9efde1

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

net/nfc/hci/llc_shdlc.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,14 @@ static void llc_shdlc_deinit(struct nfc_llc *llc)
762762
{
763763
struct llc_shdlc *shdlc = nfc_llc_get_data(llc);
764764

765+
timer_shutdown_sync(&shdlc->connect_timer);
766+
timer_shutdown_sync(&shdlc->t1_timer);
767+
timer_shutdown_sync(&shdlc->t2_timer);
768+
shdlc->t1_active = false;
769+
shdlc->t2_active = false;
770+
771+
cancel_work_sync(&shdlc->sm_work);
772+
765773
skb_queue_purge(&shdlc->rcv_q);
766774
skb_queue_purge(&shdlc->send_q);
767775
skb_queue_purge(&shdlc->ack_pending_q);

0 commit comments

Comments
 (0)