From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0931E3FD941 for ; Wed, 1 Jul 2026 09:52:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782899565; cv=none; b=KYww1NilhbHhaAE6zjGmDF4oI2L8g4wJvQEUU07TAX7+NGocbt+O9xZImVVOqv9nXnXePzCvGDZHXbNXJSZXpjLhgCJ4xUX4/dvIKwOkoXiCLvH7ddk8fM4xOC+6jtwLR2IVRKQOCiA4BA/AksHaTT3mfphu4CK7vVnLau+P5e4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782899565; c=relaxed/simple; bh=3a1+2nbXhZcTj4NeTgnKV87B2okzAssG60+kH78Twao=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Vl+KP7opJc9cpLj0bzr6WAT4uojR1DScD3COpjVrTvc6kkCD6eyPUcTsldKGyDmd7gbYMN6oFuwT6EX9XKnFRWm7cDze4eYBq6FwyDhN4O+dt4+z+3k5DLqbRXAu0XP6z4dr2VenTFn2AhdOdXvJ1GISw2oS3uRiRwKmOmpDdiQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=qg0owHf3; arc=none smtp.client-ip=209.85.216.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="qg0owHf3" Received: by mail-pj1-f49.google.com with SMTP id 98e67ed59e1d1-37df72c9984so172643a91.3 for ; Wed, 01 Jul 2026 02:52:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782899563; x=1783504363; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=8mVJevA43xSAbcO4XqhY7+SohvyRUWiP3RuKf16nZNc=; b=qg0owHf3MUSdtGbd/ij8LNpShNt375wMuwK4tvW6JxsKT73IkPryVWOiMzIvJaaNi9 aRiMP3reyuHWGCI+GBm4xsric1MimiiiQLMXPHdfkNtu7bloeejmYYBBo7wG1xyuMlmb kMwOmUMfJ/THgi9rB99u+z49LrVVGoqP9muBQYLGrp4VPklQG/ND9ZCaj2opLyurkpDA W8NYHC/xgBbsmTGZBDOeZ1xad+fYdPpnu9mg0jkk3mX2IYN0/I+k3Wj19GBeHvRRELnF NfjLEUlFIGf8Gl0M87dJQAJZDH1aFfgowekEFxGLFAGBcQtaSCEEA07y0B+laUcVflsU sLxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782899563; x=1783504363; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=8mVJevA43xSAbcO4XqhY7+SohvyRUWiP3RuKf16nZNc=; b=T73NAk/K8a+Xn4AE1knfv8m+bhtuwDdK+7a3OsVlxBn2ZxLH3kb0EfW4smZzOOaK5A 7CAEDa4wE6GV1bI9rn3Gmkg6E8vJLvymB33qCPQw/CZhwGiF5YUmlxZ3uONH8GPItzSt 6/trt2vuPgVemLbBxVs7nTyRUWx5TapnsJjzwn1MvTiUyGEfUBoUxVShptBrOqrLd2a1 8IVC3F4p0kIDvx3Au+T/LtNhE55f4CJDrLaMFwRCgKSNX+1iFxVEszi7rOpsf+T2ntmC M5b8eEsst66BmqVm1BlSx0CPqLvH98lTQbxsNeXls8SnHOFAfWk3H4eta/RO50S8M+Wf gjsQ== X-Forwarded-Encrypted: i=1; AHgh+RpmDc21/LLhVbzP/u5oDZjnLKLWU6TKp31iix68BZtw8ObRFAynJTwh/Up7Vw6HvjOsqxGu38Rx5BW5bqA=@vger.kernel.org X-Gm-Message-State: AOJu0YyvZGp1Bh7bDntOta6j9PefCcHI7X60kZ5Ap1uzLlF+7+O883Np HN6M92uYpVpV6XLCCps1iYN3SIBlpRkUMwxG6k90uhZjVCd/ulcG9Q6y X-Gm-Gg: AfdE7cn4o7d24AOs4boLC88F9hcQfeQ/wERDAVZggvA5NO/i0Bxy8+Lz7uACFzTBmwc HNwTtYGQnOUaKjQj5eP+mPbMIGj2oZuEzMKpVvxOnjEVNlVM4eqgP0SH6NbbqFuQOqbkH/QlH/w orhj3sr1uo7sEsIc/vI1u5ajhZ/08BlFleQFwvq7sQyb43W3g8Nmi96ivdlf2qLZf9/QwMzgXm+ fAx46sS7OBc69FSUnoA8OdA/Fj7OJN47aOULnGkvemGJtpunEc9jQhrratp4ygp5QbogLAz+WfB cJtbMzN/naLEfPYY4kmiJPKHFKhSaueso1o/gFxVQYHUjXTA1C2rWUW7QkYMJHFPpmel+qyPZ/k AUY8XfqM47SSWuqgV6HBLtASeCM9ply/bSiO32BF8SZr15DsZsTtm94Hrp7jA3K01vNzVjPjjQn KZBANOsJeisZ4LXlqb9tcwMqf5SQ2k34HSb2TnY8dmaidHrCDfeyHtVR1ETIeI1HW6Z6SFeBVbH N75Ew== X-Received: by 2002:a17:90a:d647:b0:369:a359:b181 with SMTP id 98e67ed59e1d1-380aa221bf1mr776096a91.23.1782899563156; Wed, 01 Jul 2026 02:52:43 -0700 (PDT) Received: from nugod-NUC15CRHU5.tail9f095a.ts.net ([218.237.104.87]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-38095d6d45asm1596801a91.9.2026.07.01.02.52.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jul 2026 02:52:42 -0700 (PDT) From: HyeongJun An To: Takashi Iwai , Jaroslav Kysela Cc: =?UTF-8?q?=C5=A0erif=20Rami?= , linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, HyeongJun An , stable@vger.kernel.org Subject: [PATCH] ALSA: usx2y: us144mkii: fix work UAF on disconnect Date: Wed, 1 Jul 2026 18:52:31 +0900 Message-ID: <20260701095231.1020811-1-sammiee5311@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit tascam_disconnect() cancels capture_work and midi_in_work before usb_kill_anchored_urbs() kills the capture/MIDI-in URBs. Those URBs self-resubmit, and their completion handlers reschedule the work. A URB that completes in the small window between cancel_work_sync() and usb_kill_anchored_urbs() therefore re-arms the work after its only cancel. Nothing cancels it again before snd_card_free() frees the card-private tascam structure, so the work handler then runs on freed memory. Kill the anchored URBs before cancelling the work; once the work is cancelled no remaining URB can complete to re-arm it. Fixes: c1bb0c13e430 ("ALSA: usb-audio: us144mkii: Implement audio capture and decoding") Cc: stable@vger.kernel.org Assisted-by: Claude:claude-opus-4-8 Signed-off-by: HyeongJun An --- sound/usb/usx2y/us144mkii.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/sound/usb/usx2y/us144mkii.c b/sound/usb/usx2y/us144mkii.c index 94553b61013c..58ef23146f20 100644 --- a/sound/usb/usx2y/us144mkii.c +++ b/sound/usb/usx2y/us144mkii.c @@ -585,19 +585,24 @@ static void tascam_disconnect(struct usb_interface *intf) return; if (intf->cur_altsetting->desc.bInterfaceNumber == 0) { - /* Ensure all deferred work is complete before freeing resources */ snd_card_disconnect(tascam->card); - cancel_work_sync(&tascam->stop_work); - cancel_work_sync(&tascam->capture_work); - cancel_work_sync(&tascam->midi_in_work); - cancel_work_sync(&tascam->midi_out_work); - cancel_work_sync(&tascam->stop_pcm_work); + /* + * Kill the URBs before cancelling the work, so a late URB + * completion cannot re-arm a work that then runs after + * snd_card_free(). + */ usb_kill_anchored_urbs(&tascam->playback_anchor); usb_kill_anchored_urbs(&tascam->capture_anchor); usb_kill_anchored_urbs(&tascam->feedback_anchor); usb_kill_anchored_urbs(&tascam->midi_in_anchor); usb_kill_anchored_urbs(&tascam->midi_out_anchor); + + cancel_work_sync(&tascam->stop_work); + cancel_work_sync(&tascam->capture_work); + cancel_work_sync(&tascam->midi_in_work); + cancel_work_sync(&tascam->midi_out_work); + cancel_work_sync(&tascam->stop_pcm_work); timer_delete_sync(&tascam->error_timer); tascam_free_urbs(tascam); snd_card_free(tascam->card); -- 2.43.0