From nobody Tue Dec 16 16:38:01 2025 Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) (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 6F93B21A457 for ; Thu, 11 Dec 2025 03:11:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765422699; cv=none; b=PhC/GoVHXi59L6PvszknTlqbhimpfmQ4XE6AwYetnSMrqA6HGG/FoRuYrgIsXBP0WATp8xvpjkrl2h0bCfqeBaOVbngVhutXIRvL3UfO2QqunDiFQ6r17aQf7VzASpt6ySkPHvI6eD3CTt8qcEVIUUCaP+CkFz9FvbMZ1lPFpNI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765422699; c=relaxed/simple; bh=FBUewJzNttvBj6dhO4FEss/Md1jJMTZhw+mgqA17V14=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=UrnCvDaP8Ws2DjKFnH/g2e+mfOpur0U9a+mHfLyaDxVfi9hscOsSq2ybYMN0pqmBiES56K9lzA0sJSrE27jfC4dya+CF08oE2tdzQbXFJBEzgD7jII2sMtuXxyCP0TSpdVJujC2jqc12dHHp4XtDlINbwwOB3fKaN8miX/+6gDg= 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=AJRzOHK1; arc=none smtp.client-ip=209.85.216.51 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="AJRzOHK1" Received: by mail-pj1-f51.google.com with SMTP id 98e67ed59e1d1-349ff18445aso407302a91.3 for ; Wed, 10 Dec 2025 19:11:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1765422698; x=1766027498; 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=KGCWABPnAEr262wrNDG5Ce38cd3v/xWYcwemzU2UFZE=; b=AJRzOHK1eBaII2lpqOu1Sy8rYh6O7WAeu7l7Dmtrns/dCxjV2hFZS07Dh347HFbahC erybmc/gwALK0qXLSbRW9c2gZdqGUx48cJdC/lxQDBUpZ0hnnQ0F3xV76ZFkQz9UsGAi wuhxcNuJoVjxbqmqmCr1e8HjIjjYlmWE8qHAjnlenDGlRXb1J9WvN+d86KLz4Fuxiwsl E/By+O0jGGcniM6XWCXk0/d5a5BOScOfl4oYwxwXZBPoGRJvRZK2JFSm5MFTTs9wNAAe S2b18c9WZnK7RfGcaJTVc1dSPtuvmXE6N6MwFUP4SHE7cuAs8ZyMc6MQwK4f9MuGA478 QVUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765422698; x=1766027498; 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=KGCWABPnAEr262wrNDG5Ce38cd3v/xWYcwemzU2UFZE=; b=IjNL8/arobVs5xWglQJdXwij9IH82Rio9XjTCa14iU9cXYIReEFi669b0dGeCu9ym5 GEbNkA/iO+7FqgCXgnO8w7Bof6yG4ES9VXL+JFGSOMAeNgv++vMKWHc0J7PuFfvGy5OD FhQChUZYUmXQjVBtuqvX8iIrTNzXClRpVBlBzqDCAXKr0h7Hr7wwbDQEDJwAnQxmDlBO iEp0YS72B2bCl6n8fSGewibp5b6c22xm8/oW08XJ7LAcLRtC1wLJpkJCpMbm0Y0ukFzy cefT5tLd+9EeHWr5Y/aKoIvjE00aIeC0tEZAcQ7bPmhWI2UrHO8sUlVBdrTHfF4AoS6n 82Kw== X-Forwarded-Encrypted: i=1; AJvYcCWQgZ0MSoelzFgA0d2XXLLtokNG8NgndUTJ++vVUUMK0CeHD6Bb/2i+ByzG+BBKDZTI7CHg5ZKMgSghOLE=@vger.kernel.org X-Gm-Message-State: AOJu0YygYtqAE/4TWMoIRcGkSA5jLuLFgQkUlr0aag8zExyPJNxXLXAo AU7deUesoKbaufjpVk9c2uN7vdxomPFRqCX1uwtiwCMgwQJVaPLOb3og X-Gm-Gg: AY/fxX4ihFfIEIbb9NcEDt7JDX0cdqYBwtSNLbCW42pw4Fd7oTpQaitygITurgdXeYJ BQbg/AgVKvh74sDq1VxWqDnvoIWi0tqV9ihGlQMQTV1bJvzWyW6wBAqrdlZHaSqbKwFSaXsSjsX oZA5B9EitKntuXELl2JpvkJaZNwmHL8Fh7axLwVO+hgL4Tbbcnb/4mI6wILgnuOLO9TCuxHoXYA 0RQCJpscRoQXq1CgJ9cP80qGf9NMNA7161Jsl2g4CLOwwKtgiH5D24SaqsqMjKvDHHq8v3fOjI6 ZtT3ZEz7QwvE2BDqXP+p3a9C1sDz+BIAOXeK8JZkj5jE8pgQJ8cSL1aOhTaE46bKna6E4JRnxPv j6Bu09s5HYrAL3/j1iTUduOvK+ZuezxNnRNAHiv/5yXOHQgC61v1dGXHlw0wjePgLTx8lDOcoeK bLL1Wf7XOKrf3r9Op/d//2K6g+TBTlUw== X-Google-Smtp-Source: AGHT+IHWcmTOZsaghTibxhIuW0UStAShWvIpbZoqG6v/jKdNCs6tlxwCwwle4nhzr+QPOqrUn6J2HA== X-Received: by 2002:a17:90b:3847:b0:340:e8e9:cc76 with SMTP id 98e67ed59e1d1-34a7284d09fmr4788926a91.11.1765422697736; Wed, 10 Dec 2025 19:11:37 -0800 (PST) Received: from localhost.localdomain ([121.190.139.95]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c0c2ad5961asm774231a12.18.2025.12.10.19.11.35 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 10 Dec 2025 19:11:37 -0800 (PST) From: Minseong Kim To: Dmitry Torokhov Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Minseong Kim Subject: [PATCH] input: lkkbd: cancel pending work before freeing device Date: Thu, 11 Dec 2025 12:11:31 +0900 Message-Id: <20251211031131.27141-1-ii4gsp@gmail.com> X-Mailer: git-send-email 2.39.5 (Apple Git-154) 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" lkkbd_interrupt() schedules lk->tq with schedule_work(), and the work handler lkkbd_reinit() dereferences the lkkbd structure and its serio/input_dev fields. lkkbd_disconnect() frees the lkkbd structure without cancelling this work, so the work can run after the structure has been freed, leading to a potential use-after-free. Cancel the pending work in lkkbd_disconnect() before unregistering and freeing the device, following the same pattern as sunkbd. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Reported-by: Minseong Kim Cc: stable@vger.kernel.org Signed-off-by: Minseong Kim --- drivers/input/keyboard/lkkbd.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/input/keyboard/lkkbd.c b/drivers/input/keyboard/lkkbd.c index c035216dd27c..72c477aab1fc 100644 --- a/drivers/input/keyboard/lkkbd.c +++ b/drivers/input/keyboard/lkkbd.c @@ -684,6 +684,8 @@ static void lkkbd_disconnect(struct serio *serio) { struct lkkbd *lk =3D serio_get_drvdata(serio); =20 + cancel_work_sync(&lk->tq); + input_get_device(lk->dev); input_unregister_device(lk->dev); serio_close(serio); --=20 2.39.5