From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f178.google.com (mail-qk1-f178.google.com [209.85.222.178]) (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 0C55C3CCFB0 for ; Tue, 28 Jul 2026 07:25:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785223559; cv=none; b=OHgniS+hKmsGL/SzO0RSz+9wkBJhk2OX1KSDCS4Y3UDYKuE4Ftw84ESf4HZdNwbCKBlkdk4t8r+9+DSxdBQhOIWr3LVK4azGhtMA6LNS/WKk8TLgDmtU2IVnfcECEr1HbPuHwtIVsTzEtxX+9nmyuyY3DjEIjYsEcXBPMUUuXyQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785223559; c=relaxed/simple; bh=6/KDwlm5ghMlZoZDr+8u5LRQ6G5KIkP2c8ShBPpCI34=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=rRMGajgRGtPSD/EnND3ZisF3nD8CNFYipeHPRYZ53sArBhEdOhBFmCnH1OlVO5ktoysHmxT+rSmVHL6gPwtXJd5jh0d99Tf0jIukm9gy2I1Gxx/D8bugi8Ip24k/XTkANldbxVt/k36BB2ubBQLNByJX4oU3yRT4tOUELr7X+Xg= 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=RLk2XQk8; arc=none smtp.client-ip=209.85.222.178 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="RLk2XQk8" Received: by mail-qk1-f178.google.com with SMTP id af79cd13be357-92edb12cdf2so226868985a.3 for ; Tue, 28 Jul 2026 00:25:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785223557; x=1785828357; darn=vger.kernel.org; h=content-transfer-encoding:content-type: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=8REJpVmdZHTajWXPY+els9sTJ1vLLgIwaTgLYZy06Ew=; b=RLk2XQk8Yz52IJxVjSPxJI8dtJwgeceabtgD4w2gZpoOU1X36vQsDyvX8uGQEqVDhr BGzzVtXqYBYoEwN4+ncBxPByy5IqZ4nOlej4ed54of98ImeCLcMJq26hly186ACWfi5Y MfJWQ58G+mpv9bwEfmL0RH2pBdrBS6apaOcJB6pgFVLXEYjZSWIBaYAKTzZbDusnFtUu IOVFE8cO9BAeed71IIk/2e0921K6BNNmjt33QD1Gfy6TOClat3xxLWXmn6VleEDX0Wa+ 84MAoecY/l3cE7DA0bNz3f/zP08vY5G4/VihsMtHZMtNDaOSqWphPI+e0X5e4YMJhAnr wIcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785223557; x=1785828357; h=content-transfer-encoding:content-type: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=8REJpVmdZHTajWXPY+els9sTJ1vLLgIwaTgLYZy06Ew=; b=EtStSO96cvAPNglvh/9Sw0eGRzHUSnrPvdLoi9iWPraEtkHb64cma1MggGciQUhf64 O4sB8FkdOSnHxXpW3GLveXEBQYbB2c+hyCvk/44Lnpv4PGekCbyESABAw26Fw01DbqJS EXAD0OSIS3XR47ICUR/26vxVGmXacpyvbpBIBcRH3JeryJ3sxxiBCJ6P9P72AlJNaaXw iaoIpCy9IOvwRK3GEodAEvrgzUG/CRkdtscd5VdvrncnQvcUx05WE36g2xdoEyZjvnIf +M/Nf9oIN2aRLJWM4BeGhvSpIKSbkn1oZRgVumbxmUboRLWn9Yel8mKYeJsaj/oROu5I 3qgA== X-Forwarded-Encrypted: i=1; AHgh+RrfUGWlXEd73adYz7ufiPaIXUSv036GAOpnb4mxzYvi3fHbk3hYQ+4j4mV0O9u0P1i1kBGhX80luspPRJE=@vger.kernel.org X-Gm-Message-State: AOJu0YzBnUV1XKCC1UtO06w21Zj8oNwXWIiJ/SlAe2RvVZzdlKtIHgyE P0lTHJMB7GZjjgo23dSkG0jnuATKL4MOFW4r4A2aEAXqjhkI2nkXL284 X-Gm-Gg: AR+sD11bAL/UTX+lxTfep6TuH0fHIIOToKYl6a9w3tye+pbHow/1+inM1xY6/ceUq/9 USS0adLwLQHa5hP+hG+4xUHXtHqrC80ZVuVY+5pAw5EmtgTNy08FJoJEsG76o8lPoqz1hdiaKNO yYlz0sDsFUa2RGY0oTeeJquu614pieOsOWoBpintI+KZ7JpftjhnIqqL2cmrCqZ4lKBjKHq9Kwh 7zxQJ4gjlh3vFDFYzmD0b4VmZFAHm07FkiRK0BQ3+WNrPnbr4OlkPeBGvaCDx/giUyQrLvn04Ww uKr1PEfProbepJdcFwT5AzjtcV01d/GQEjt/gNJKxvNaTDEndQcsNFGCNEaO64neUaM0D2ECM/X 9grr6T8qtOX5kyOJyBfTWWNRdnauXpx9Vfi3KQqoCZ7OFeNshMHbukV1d+Wj9JQJKEY/XpqOtWR pzeSn4ljEyLHjQTRNURaSUnpo= X-Received: by 2002:a05:620a:1729:b0:930:e918:c737 with SMTP id af79cd13be357-93302719a1amr103406085a.62.1785223556768; Tue, 28 Jul 2026 00:25:56 -0700 (PDT) Received: from FairplayBox ([2601:5cf:837e:d920::f9a2]) by smtp.gmail.com with ESMTPSA id af79cd13be357-932de635f7asm795939185a.29.2026.07.28.00.25.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jul 2026 00:25:55 -0700 (PDT) From: Alec Hall To: pepemontfort@gmail.com Cc: jikos@kernel.org, bentiss@kernel.org, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] HID: magicmouse: reject devices that bind without an input device Date: Tue, 28 Jul 2026 03:25:40 -0400 Message-ID: <20260728072554.47069-1-signshop.alec@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260715195853.1302765-1-pepemontfort@gmail.com> References: <20260715195853.1302765-1-pepemontfort@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On Wed, Jul 15, 2026, Jose VillaseƱor Montfort wrote: > Move the msc->input check ahead of the early return so it covers every > bind path. Legitimate devices register an input during hid_hw_start() > and are unaffected. The second half of that turns out not to hold on real hardware. A USB Magic Trackpad 2 exposes four HID interfaces, and only the first two register an input; interfaces 2 and 3 are vendor-defined, hiddev/hidraw only. With this patch applied (stacked on the pending battery series, kernel 7.1.5), plugging in a Magic Trackpad 2 over USB rejects both of them: magicmouse 0003:05AC:0265.001F: magicmouse input not registered magicmouse 0003:05AC:0265.0020: magicmouse input not registered I confirmed with a temporary printk in probe that interfaces 2/3 reach the moved check with msc->input == NULL and hdev->claimed == 0x6 (hiddev|hidraw, no input), while interfaces 0/1 probe with an input and claimed == 0x7 and keep working, battery included. The rejected interfaces then end up bound to nothing -- hid-generic declines them because a specific driver matches the ID -- so their hidraw nodes disappear, and every cable plug logs two -ENOMEM probe failures for a healthy device. Nothing user-facing breaks (touch and battery live on interfaces 0/1), but the driver has claimed those interfaces ever since 0b91b4e4dae6, and silently unbinding them with an error doesn't seem right for a stable-tagged fix. Bluetooth is unaffected: that path already required an input before the early return, and a Magic Trackpad 2 + Magic Keyboard over BT show no change with this patch. > I went with fixing the probe path (rejecting a bind without an input) > rather than adding per-callback "if (!msc->input) return 0;" guards, > since a single check at probe covers both ->raw_event and ->event and > addresses the root asymmetry. Happy to switch to per-callback guards if > reviewers prefer that. Given the above I think the per-callback guard is the better shape after all: it keeps the legitimate input-less USB interfaces bound exactly as today, while still closing the NULL deref in ->raw_event/->event -- and those interfaces demonstrate that a bind with msc->input == NULL is a state real devices reach, not only spoofed ones. Happy to re-test a v2 on the same hardware over both USB and Bluetooth.