From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.176 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795407664; b=O0jUuTQdunUFsUX2HFtS46evoacFLY2fC5/9/btDgzxz19x2qG6+bFNqCfmSl/Fwqy8h 9tURUmmuPhJNOfcuQQVpzSf4j/FA5l96mZQ44Yb199pW9ZTYNQt42d6O0hJRDufuOzkFs Ibq4RYVmuFNIgJiRvSbHhE0OGBJ4Lbg1U6p5rGRMxDTQgOD8rgPCws7zCy/l+jy2b/9UI Ccqv7N0wJaYCX6Bj3nCYdUAE2KaD65Y3gpZDPJdY/fY2L0ZGa+4hBo8QDUvZjIDgib+7Q IEK0I5Usomk+IG40pgNsfGwPOxm74e/zbDeHRwanTyJnzSI/T+UVeUgUg+AgUs/p2mA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795407664; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=QM77UDij6XwSYk3JC8OYB2FX+P8AANH4ekRQtOvst7s=; b=Yu9jfZTIn8ROFO7o7+pT0WwwPQmFw59LhKqE9Wm6+x3xhrISLse4Tt9O1OXluUoPREou jIhHZPn9TSs4Qgy7cZaL+WezpZcTw1+5aXT4+D9rNl8pehLDCt7CDsh4x2A7dbh1g0oaK 27ehGn66+uEGbfL48WoKbIpdYkey2LS7kRzowiYlQbPvQPHIxPcTwclPkUA7FJs8Xqba+ t6JkvapUA+RGBFfvvW8yt+lDRA7m8Y06O04aggrLWDreR+y5s8fo/AWuuOE5i57z9dJGd Zxplso2U6x5ddCoxAaAHEVVcsjRb4ft/uPSQT9cruww//vrIIihEBvGlcBXU3ZB1NHQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=xgSKbUeW; arc=none smtp.remote-ip=74.125.82.176 Received: from mail-dy1-f176.google.com (mail-dy1-f176.google.com [74.125.82.176]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8A94D606A33C for ; Mon, 23 Nov 2026 04:21:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 8A94D606A33C 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.a=rsa-sha256 header.s=20260707 header.b=xgSKbUeW Received: by mail-dy1-f176.google.com with SMTP id 5a478bee46e88-380b40312e2so6910412eec.1 for ; Sun, 22 Nov 2026 20:21:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795407663; x=1796012463; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=QM77UDij6XwSYk3JC8OYB2FX+P8AANH4ekRQtOvst7s=; b=xgSKbUeW26WHi5TH0F2XJfhO+bPd4rfB7Ka0bBEdAokxE5ALhDRZQRCs23BnK+TB4+ B9RHuwDpg7cvN906V9B/9JSxaViPIhXqvIUiy8dw5udSGi0Jy8eBT20fp62KgRTxavnK /+fo/FyJVNuIgpdknYbXBJNpx2tUOZaZUChFBqMGeUqydDRyNKAwTzBVufCHnVPDMNX3 B/jVFAzpfBhjjrvXHD/mQTmd2esv8dqVZIvo4apefaMKbH+NP8wWFs6ZAcasHEpqaBs9 5B6RmjizrQ+lDQJFhhx0qhOaRIMcxCIOyu4hjYv6oNlP8PsyVqUgasLKRBxTJ6CJ9MBV hXew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795407663; x=1796012463; h=content-transfer-encoding:mime-version:references:in-reply-to :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=QM77UDij6XwSYk3JC8OYB2FX+P8AANH4ekRQtOvst7s=; b=ObsfS2Su5kVrMleWpUYw8jdOoUZOb9ueDMU8d/Y/Jrcu8sWCl00z30FubCbWfisGUO eTrimpOKpGViX1OVY5u5+fVwvhFUK2QVKpBqtJD7q8/VNhj/6IAjav+0gOQe1EjpQuwT Iz0UNvPdVSLfOFZT34XPjBGUbpWf0T6TgunkA8tc6FZ46mKOFzNmsaiIGLwD8xzgO8ox fXy59mSHvW9hZ4bV7CMZYIP0iN3i8JIAWol1AmyLSMcqDjhp45SjzSFbvIRXXSfdzbit JxRyiDd9Fk0AwwQ4422SI2r6Wv62Tg2CJ2My4q+8obOyYuxJwRW01HX4mkUd0rfWTvvQ JoNA== X-Forwarded-Encrypted: i=1; AL+hErF3IVIxC1Xl6D6hVL/jPcsKLnam84vn0X/LAK0cewypqfFsali5JuKi2C45u4Q2p1HmaMWhwP7VSHuG3FQ=@vger.kernel.org X-Gm-Message-State: APuU4Z/ap7kQeo+y3E1cmr1YAHhrxJ130JD+M8MuyTcvilFQR/p0+c00 ZayZbhK1gOqfGGhukEePUaTtbE+pDuMJ7IDTYMXLTCCabTcB8/OWYs+L X-Gm-Gg: AZFdTZeVQA5qgWRm7PYMSmMuG6CcxQS8VFEfQET1yFS5h9jfmBT+wDS6wyAxTsPxNb5 K5qamMkAuAVt7C1WAoQcosDUvxXvCDe0kX4c7AiyQ/ExA05PGB2pjGFpeoDmsgy/u4GkNeMia0e SLuDWI8PkuZf5lvcH3RB+ibsloiLl5a5q2Q2hE9xt6q6lxthOlWr3/bhni421DigltzAH2Scuh9 ViskPChbxYu/JwnJZeM3+Mu+RMs2fjgwxK6reYPmmSYNfYWjJuLStF+fSwdqad2nk6bBnFIL2M9 7She8mYtNXTfmKqwd2Kes24M2XBNf4JPYd11xhDt+WaNW+4WhdvCF9R2TG8TsIMrCUs04HL10nb ctnP8fjDW+FgIq+eMAV9RtIymRL6FWRKDIgZghGvNW9r/VXqhJiMk74fC5Zh8SyeZN3uJydHHDa 40adjvYirqkGWV7zfoEFy8RILprPdC5pNmBMRCcrFiPyqH4du87FJHV3CnZ1UDfXd+ocmUNzRvn 0+JumHkXW1CcH4rg5bw3Twr5drZL3Lb6+cbd1nGhUzkxEH/ypSMha+C8bW7GV5ZPL7bZzS6bqM9 Pp0KnniOuicKWOQdWEFwzm/t2MjfSSWcUC+KC5FwG8QcAPaaEom2nYe0UASrBACxWm0eJjnngsj h02G4pGhBoPqd2TWrI5mK7E+xpuVKcU8r5yQgKu+n/+tcJNc= X-Received: by 2002:a05:7301:c005:b0:386:a0c0:5e59 with SMTP id 5a478bee46e88-386a0c0757fmr6668638eec.20.1795407662629; Sun, 22 Nov 2026 20:21:02 -0800 (PST) Received: from spark-da2e.tail8e743c.ts.net ([211.105.22.106]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-385672c6f31sm30804737eec.15.2026.11.22.20.21.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Nov 2026 20:21:02 -0800 (PST) From: Jinmo Yang To: ping.cheng@wacom.com, jason.gerecke@wacom.com, jikos@kernel.org, bentiss@kernel.org Cc: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Jinmo Yang , stable@vger.kernel.org, "Claude Opus 4 . 6" Subject: [PATCH v5 2/6] HID: wacom: check the input devices in the legacy irq handlers Date: Mon, 23 Nov 2026 04:20:11 +0000 Message-ID: <1dd28b561f3380cf3b76bfe096ba676a83f33229.1795405057.git.jinmo44.yang@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit wacom_penpartner_irq(), wacom_pl_irq(), wacom_ptu_irq(), wacom_dtu_irq(), wacom_dtus_irq() and wacom_graphire_irq() dereference pen_input and, for the latter two, pad_input without checking them. As described in "HID: wacom: check the input device in the shared report helpers", a partial interface leaves one or two of the three input devices NULL on a fully successful probe, and wacom_wac_irq() still dispatches to these handlers. Seven locations fault, each reproduced on linux-next 20260925 (x86_64, KASAN) from one /dev/uhid device plus a single UHID_INPUT2 write. For wacom_dtus_irq() and wacom_graphire_irq(), all hardware served by these handlers is expected to have both pen and pad on a single interface, with two exceptions: GRAPHIRE (pen-only) and DTUSX (pen-only, no pad buttons). Guard the expected input devices at function entry, skipping the pad_input requirement for those two types. For DTUSX, also guard the DTUSPAD branch in case a spoofed device sends a pad report anyway. wacom_dtu_irq() gets a check too. Its only dereference is in a dev_dbg(), so it does not fault with CONFIG_DYNAMIC_DEBUG=n, but it is unconditional in the source. Fixes: 2a6cdbdd4cc0 ("HID: wacom: Introduce new 'touch_input' device") Fixes: 862cf5535c0c ("HID: wacom: Introduce a new WACOM_DEVICETYPE_PAD device_type") Cc: stable@vger.kernel.org Signed-off-by: Jinmo Yang Co-Authored-By: Claude Opus 4.6 Reviewed-by: Jason Gerecke --- drivers/hid/wacom_wac.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c index c7bf0e5988e5..d5c2efcc09b8 100644 --- a/drivers/hid/wacom_wac.c +++ b/drivers/hid/wacom_wac.c @@ -128,6 +128,12 @@ static int wacom_penpartner_irq(struct wacom_wac *wacom) unsigned char *data = wacom->data; struct input_dev *input = wacom->pen_input; + if (!input) { + dev_warn_once(&container_of(wacom, struct wacom, wacom_wac)->hdev->dev, + "%s: pen_input is NULL\n", __func__); + return 0; + } + switch (data[0]) { case 1: if (data[5] & 0x80) { @@ -174,6 +180,12 @@ static int wacom_pl_irq(struct wacom_wac *wacom) struct input_dev *input = wacom->pen_input; int prox, pressure; + if (!input) { + dev_warn_once(&container_of(wacom, struct wacom, wacom_wac)->hdev->dev, + "%s: pen_input is NULL\n", __func__); + return 0; + } + if (data[0] != WACOM_REPORT_PENABLED) { dev_dbg(input->dev.parent, "%s: received unknown report #%d\n", __func__, data[0]); @@ -233,6 +245,12 @@ static int wacom_ptu_irq(struct wacom_wac *wacom) unsigned char *data = wacom->data; struct input_dev *input = wacom->pen_input; + if (!input) { + dev_warn_once(&container_of(wacom, struct wacom, wacom_wac)->hdev->dev, + "%s: pen_input is NULL\n", __func__); + return 0; + } + if (data[0] != WACOM_REPORT_PENABLED) { dev_dbg(input->dev.parent, "%s: received unknown report #%d\n", __func__, data[0]); @@ -263,6 +281,12 @@ static int wacom_dtu_irq(struct wacom_wac *wacom) struct input_dev *input = wacom->pen_input; int prox = data[1] & 0x20; + if (!input) { + dev_warn_once(&container_of(wacom, struct wacom, wacom_wac)->hdev->dev, + "%s: pen_input is NULL\n", __func__); + return 0; + } + dev_dbg(input->dev.parent, "%s: received report #%d", __func__, data[0]); @@ -289,16 +313,26 @@ static int wacom_dtu_irq(struct wacom_wac *wacom) static int wacom_dtus_irq(struct wacom_wac *wacom) { + struct wacom_features *features = &wacom->features; unsigned char *data = wacom->data; struct input_dev *input = wacom->pen_input; unsigned short prox, pressure = 0; + if (!input || (!wacom->pad_input && features->type != DTUSX)) { + dev_warn_once(&container_of(wacom, struct wacom, wacom_wac)->hdev->dev, + "%s: missing input device(s)\n", + __func__); + return 0; + } + if (data[0] != WACOM_REPORT_DTUS && data[0] != WACOM_REPORT_DTUSPAD) { dev_dbg(input->dev.parent, "%s: received unknown report #%d", __func__, data[0]); return 0; } else if (data[0] == WACOM_REPORT_DTUSPAD) { input = wacom->pad_input; + if (!input) + return 0; input_report_key(input, BTN_0, (data[1] & 0x01)); input_report_key(input, BTN_1, (data[1] & 0x02)); input_report_key(input, BTN_2, (data[1] & 0x04)); @@ -349,6 +383,12 @@ static int wacom_graphire_irq(struct wacom_wac *wacom) int rw = 0; int retval = 0; + if (!input || (!pad_input && features->type != GRAPHIRE)) { + dev_warn_once(&container_of(wacom, struct wacom, wacom_wac)->hdev->dev, + "%s: missing input device(s)\n", __func__); + return 0; + } + if (features->type == GRAPHIRE_BT) { if (data[0] != WACOM_REPORT_PENABLED_BT) { dev_dbg(input->dev.parent, -- 2.43.0