From nobody Fri Jul 24 21:29:31 2026 Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) (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 5205D43BDD6 for ; Fri, 24 Jul 2026 14:27:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784903230; cv=none; b=SehouUyCmMLrx57EIwUSt+LNR7BAeiIjmV2jJamBWpRGlaz9B6A4WDPbUeJAeoBdoQDsXyucU8UAfwkGt9qj5Zsvpf6XVw8dv1LIUrx+SbxhuqqPC8nRJ1HNPxPOCtRH4S8eavwebKYHzCkhXvxL+/LC0d8qaFpSUqPl+Yc/q/g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784903230; c=relaxed/simple; bh=Zj74hJMn5EEa+Tdvo+oBwE3+v+XfzQe/LuZObDwPF1I=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=RA36zCIvI22VElLCtf33beNAllEERBQQB/OFQetKAyT3lqS0RSfzre++uEbgX+Z62yW6vWdet7e+yLBa5cyW/S98Vt/dl2bhP2tu7+jWohfiTI32WQb2Qw+wqjMF2MlbDiBTEgZTIof+CmlxiB4y5pNaCgbqrAaUpLJJ8YppA6s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=0sec.ai; spf=pass smtp.mailfrom=0sec.ai; dkim=temperror (0-bit key) header.d=0sec.ai header.i=@0sec.ai header.b=kuEyiKhS; arc=none smtp.client-ip=209.85.221.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=0sec.ai Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=0sec.ai Authentication-Results: smtp.subspace.kernel.org; dkim=temperror (0-bit key) header.d=0sec.ai header.i=@0sec.ai header.b="kuEyiKhS" Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-476a130c138so577214f8f.0 for ; Fri, 24 Jul 2026 07:27:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=0sec.ai; s=google; t=1784903226; x=1785508026; 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:content-type; bh=FOrMfHhwgNyC11nXJyc1Bax0nC8w1A9xAnO4x+p5G4g=; b=kuEyiKhSeQeFZ5YSDQNA8JchxlAjUsg14ePTQJAxNc4InmyViaCxfzYCKeaFI/gFyK AkeARS54GHCVR9+gHipXJruaFn9MXTEXYQe1z9H7S8UPU8ovioZIBSamwaC2st+38YOp MxWdjQBRlgvYlI+V9hXtEI1wBHFsZFDtYMrN0o0CArHFiM4I77/9hM5UCMPLlFjNeVef P5kUV5cHmUMkM1ewazxJBOyj++pyGnhZlXu/4kuNZMrdaMK7MQJ8Ek5ThzW8MO84I35T yGrt5m+eBMn/CXjcnoTNRgX/nGiGykUnQfgAoAsVR95D1txrmaBy6tOpVo90NLt/1xJv 6nsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784903226; x=1785508026; 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:content-type; bh=FOrMfHhwgNyC11nXJyc1Bax0nC8w1A9xAnO4x+p5G4g=; b=A51o/xP+S5/rpRc0cnBtw/TMy0fheL9Pl5XA8wlUIkUlKrADVn4LMoxwkbpDN5bfsO +7whaKrKHOPcWJAVMTDOvCBJisBd9QNQwWdNuiXRG6nRMYF1+ZEQ5Am9WG8qDzQh+FxF LHiD+dbWAFHbsrVOXLSKREGz5hOafMRFBx2ym86rF2xVovgVDcdd4U5fIzQrnnr+BQGu MOP9VZkdwTHF9DoNxM7ASmjvefTY+iy9qMkN4kQDgAVAzyd2GA0P4HrP4gFV8v77Fd8m dLsXjYhbSCUo1tjvAxrEZRi+2rzsS++U6T4HX9yValXN1Tf00i6v9t3bBQtQvRWfukKu k5tw== X-Forwarded-Encrypted: i=1; AHgh+RqpD8A+XI7yCbBu6gkQCxmgFlByla6Zm8Z5oKHAYQMof3pHCtGUGSLs7bLvQ+oXcktvOEzLEDMqdlMy2fk=@vger.kernel.org X-Gm-Message-State: AOJu0YxVZasaUZ9w61qDSVeixX3rF8J6lD21yGRXferHsk4oKjXXFRji EAP1m5xspoYP7FI2vJQf42P37hgPyFQOnTO/8LphwfcLZDENmbLWH6jJcRjOY/la2qXA X-Gm-Gg: AR+sD108f+SsDZ+2pgq42UUjw+GJ8J9XJ75iJVVu7NuscE2pnA3c/ODXMb5yR375FS7 1sBt0PpkDmYZP1llF4ol9EMJSXiHDGMeGTE0S+F+ceDSA3VxllSpDKoYruBMYiPJxIH8hGc/RSp Ze410aTz/rqFyLIFesOZxFWs6fO286feBuZg/UOwhE/gSq7ZWcBRJFg5Kcvu3+KVDBpaHUXwDVA q9wd013MVnYdz9GRyvO0einmhgJN8PUOZBl2Axdei+KBCPIpTarOWBvQXeEUtsynIZqdWR2ymBK eKOX4lzWvjYYoTJSJPWCieN/kH0Kxr/AW/QI9bkSdCiC30qh0cJJrgTNj8JUaKfq/PegahcNRlo X1BDxCN/TLr4IDkb0LQTpC9HZv5ZcxahQ0LzeYZTJgYvbiaFkQDS9Djw3jLOdC3ERGfUiZejriw QY2y7sbM9vRxtaaprGcAseFeyJLUXW1p7WM6Hzi6jMErb19fFh+SWOixBKXT35prL/0fOrhyZR8 LypgyLfjMpohGx1p6zhnfTmKro3Gc70q4+G X-Received: by 2002:a05:6000:2906:b0:479:e2ea:3d51 with SMTP id ffacd0b85a97d-47f8da6c47amr8782491f8f.17.1784903226005; Fri, 24 Jul 2026 07:27:06 -0700 (PDT) Received: from PeakBook-Mini.tail8e484.ts.net ([178.197.219.241]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47f85b9a64dsm26761420f8f.1.2026.07.24.07.27.04 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 24 Jul 2026 07:27:05 -0700 (PDT) From: Doruk Tan Ozturk To: Jiri Kosina , Benjamin Tissoires Cc: Pascal Giard , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH v2] HID: sony: fix UAF of ghl_poke_timer / ghl_urb at driver unbind Date: Fri, 24 Jul 2026 16:27:03 +0200 Message-ID: <20260724142703.55813-1-doruk@0sec.ai> X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" For GHL (Guitar Hero Live) dongles, sony_probe() arms a periodic timer: ghl_magic_poke() (the timer callback) submits sc->ghl_urb, and the URB completion ghl_magic_poke_cb() re-arms the timer with mod_timer(). sony_remove() drained the timer with timer_delete_sync() and then freed the URB with usb_free_urb(): timer_delete_sync(&sc->ghl_poke_timer); usb_free_urb(sc->ghl_urb); timer_delete_sync() does not block re-arming, and while the URB is in flight the timer is not pending, so the sync delete is a no-op. A URB completion that runs after the delete re-arms the timer, and usb_free_urb() only drops a reference -- it does not kill an in-flight URB. sc is allocated with devm_kzalloc() and freed once sony_remove() returns, so the re-armed ghl_poke_timer (embedded in sc) then fires on freed memory, a use-after-free from timer softirq. This is a disconnect/rmmod race. Poison the URB first, then shut the timer down, before freeing the URB. usb_poison_urb() kills any in-flight URB and permanently rejects further submissions, so a poke timer that is still pending cannot re-submit the URB from ghl_magic_poke() in the window before timer_shutdown_sync() runs. usb_kill_urb() would not suffice: it only cancels the in-flight URB and leaves it submittable once it returns, so the pending timer could re-submit it and put a fresh URB in flight over the freed sc. timer_shutdown_sync() then drains any last callback and blocks re-arming. The probe error path is unaffected: it is only reached before the timer is armed. Reproduced under KASAN on next-20260710 via dummy_hcd + raw-gadget emulation of the GHL PS4 dongle (VID 0x1430 / PID 0x07bb): hid-sony binds and arms the poke timer, the poke URB is held in flight, the driver is unbound (freeing sc), then the URB is released. The completion re-arms the timer on the freed sc, and the re-armed timer fires ~8 s later: BUG: KASAN: slab-use-after-free in ghl_magic_poke+0x98/0xb0 Read of size 8 at addr ffff88810b02fd50 by task swapper/0/0 ghl_magic_poke+0x98/0xb0 call_timer_fn+0x35/0x2b0 __run_timers+0x69c/0x9a0 run_timer_softirq+0x173/0x2a0 Allocated by task 169: sony_probe Freed by task 338: devres_release_group <- hid_device_remove (sony_r= emove) Found by 0sec (https://0sec.ai) using automated source analysis. Fixes: cc894ac55360 ("HID: sony: support for ghlive ps3/wii u dongles") Cc: stable@vger.kernel.org Assisted-by: 0sec:multi-model Signed-off-by: Doruk Tan Ozturk --- v2: use usb_poison_urb() instead of usb_kill_urb(). usb_kill_urb() only cancels the in-flight URB and leaves it submittable once it returns, so a still-pending poke timer could re-submit between the kill and timer_shutdown_sync() and race the free (Sashiko review). Inline comment kept terse; rationale in the log. drivers/hid/hid-sony.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c index 253fff4066eb..112d1deaf3f3 100644 --- a/drivers/hid/hid-sony.c +++ b/drivers/hid/hid-sony.c @@ -2431,7 +2431,9 @@ static void sony_remove(struct hid_device *hdev) struct sony_sc *sc =3D hid_get_drvdata(hdev); =20 if (sc->quirks & (GHL_GUITAR_PS3WIIU | GHL_GUITAR_PS4)) { - timer_delete_sync(&sc->ghl_poke_timer); + /* poison, not kill: a pending timer must not re-submit during teardown = */ + usb_poison_urb(sc->ghl_urb); + timer_shutdown_sync(&sc->ghl_poke_timer); usb_free_urb(sc->ghl_urb); } =20 --=20 2.43.0