From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (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 C5C873A7F61 for ; Mon, 3 Aug 2026 23:48:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785800904; cv=none; b=Kws9HIbtjyDD8cGMB9xwKLOuuap477i7zWj+8itWTpOi14z4ra72p9t/kv0heGXgtiDLVxLWRx6YgT8NDQLGLuD65thhuXXlrgHMfLWBHAtMYn3GQ8mxJfXS9/rQLcMtCtrkEkoBqHICNDE6CR5i9vkqmz0o0VSoePuvzWm00B4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785800904; c=relaxed/simple; bh=AAFARNeKXceasPZwtKiPmdn3eYRuyGQsWoRLRDxFa+c=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=NQlZrvkcQf1xXeK5jV/pHXRkCsBv4jvELsBzhF6/+C9kqL4mjAV+ngAeIzCSdA788RDTPDndrUQFhISstm4XANqkVZQeDxDx5ksfN9ALj6ZSLstr6B6tIbtddgAMY8bVS8yGXkQZ90QsnPfLk0CSiLSLpeUUbUmKNFgzaxLM8h4= 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=Ybal8tbP; arc=none smtp.client-ip=209.85.214.174 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="Ybal8tbP" Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-2cf6d65d8a7so54873385ad.0 for ; Mon, 03 Aug 2026 16:48:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785800894; x=1786405694; darn=vger.kernel.org; h=content-disposition:content-type:mime-version:message-id:subject:cc :to:from:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=koNBidNkBzz3w3S5JKYG4xx62FxheLcPS+8lMG+vrIQ=; b=Ybal8tbPdeGnq8gSSDPO9oKSuU3umk3dEGSWKeRK8dj17ozJxOOR+IyOGph+r0dVVt hwkNw7mGxi0aES65EELe5h5ohv2T6FGUMnPRboXQE816E9yr+x2sXLSFZ9dZJnlx580m lk+Qw+nfAkkX/8WL0R6cP23COwPZSABSjSUQcOI4JIgkiwAPgCXsf/dgYrneDq0W5+YP 4DRyN3TG0kHWu6OShz30C6xIS1yP/KZ+f1AX6pJYTWNv9YDlDd6se3Tz6l11QrvXZ7B7 IuuRhIyJtTy6nqk9/QKs/tpqyHWk0lpNzQGyLiDTThG/FCootTprx3TWHyKm0xPOL5XH +rtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785800894; x=1786405694; h=content-disposition:content-type:mime-version:message-id:subject:cc :to:from:date:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=koNBidNkBzz3w3S5JKYG4xx62FxheLcPS+8lMG+vrIQ=; b=oRd6GOJqcJyMv9D5VD7UGiEagEKvSB/RyUGB5neOgJuq+39I7HI8nTZEkA68AlVQOo MjPmW/a8goRpcR0UKdDZcv7EKPx7WgU7vqpNe7/3vZV32DpjPu1cYtKEDHuShMNSmOg7 SYPNzeL3vrFHnjatebLYvMHwSXcydR7+jkpGTYgY+S+4C3j2yP/lWF3EIqWo5p6Znsg5 kgE1RXjijarYnm62yuNsMeGt5f7o0falcdwyXOORDm8VsmTXORds6ilVCyQSN50681ip WrRrM4ZWEf/5YuCMImR+jKSaBgAf/cvYQzdYlnUQb05cMZD6wEVyrna2QEtPGMEOhRdT GDbw== X-Gm-Message-State: AOJu0Yy7ZLlTRn9HnnvP/eRDnEPhEHGGDvifIk/wF0OX1GKpwqZlqyyh b7/Tpwn5pYcI3DCALV+83e1BM7TLa1q1c+ipSQZ/qcJDxpVxVqmc1cFGWzLxww== X-Gm-Gg: AR+sD136MFzc9PXKMT9Arrys4m/yx2JfJysqRDIn1u1fl8N5OzaRhKX6Fet7bQXrlA8 dFQDGs6Xe0WecygcG/t/0ZRj99HVbTvLvRVXjuIO/OyhNU0PSYjza+n01PzjkCHbiX6x0hESF21 m8Kr4l0d1hTxdzoTrXbY2PDzJFkurlEW6AnOeAZAzbtwo8nmgDy+O9kl/rvSOCk+it9EjjWXq9M i5QRgvWwTUXN+EnLUDoj5d5+Hdl/f58d2EZMgYKA9l+5XofE3xeg8rFUEhwMjzXpZ6RKmupOv/7 VWN+OAD8MG706F+HwYhzIWTQQsKJnhrjzNCvCLaj603y3V/3w1np8xy/KKHqRj/E3wIXSYE6nGM mxoq3vzY2V9cSACZqAQxLiEiY5HxhNdl4N+umIBw3m4PWZrM2C/SN3V+0Zf2iWLitEZZEjd5RJP E0Yho9HJvqBSq8Z5DfcnF6BDLI7gy/vX58PzqCbmsUKUojY7TobBRNCvHocaJ5Yh5wWSx8i30c6 M72ZoF63BewPX1gxo+rBcl7rcHR5w== X-Received: by 2002:a05:6a21:1644:b0:3b2:8685:1473 with SMTP id adf61e73a8af0-3c92a51df40mr11783580637.7.1785800894664; Mon, 03 Aug 2026 16:48:14 -0700 (PDT) Received: from google.com ([2a00:79e0:2ebe:8:d109:cdba:8a20:74ad]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3153e18e70esm69374770eec.29.2026.08.03.16.48.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Aug 2026 16:48:14 -0700 (PDT) Date: Mon, 3 Aug 2026 16:48:11 -0700 From: Dmitry Torokhov To: linux-input@vger.kernel.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH] Input: reject inhibit and uninhibit requests on unregistering devices Message-ID: 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=us-ascii Content-Disposition: inline When an input device is being unregistered via input_unregister_device(), input_disconnect_device() sets dev->going_away = true under dev->mutex and releases the mutex. If a concurrent sysfs write to the inhibited attribute executes input_inhibit_device() or input_uninhibit_device(), it acquires dev->mutex. Because neither function checks dev->going_away (unlike input_open_device()), input_uninhibit_device() proceeds to call dev->open() and start polling on a device that is in the middle of being unregistered and torn down. Fix this by checking dev->going_away in input_inhibit_device() and input_uninhibit_device() under dev->mutex and returning -ENODEV if the device is going away. Fixes: a181616487db ("Input: Add "inhibited" property") Reported-by: sashiko-bot@kernel.org Assisted-by: Antigravity:gemini-3.6-flash Signed-off-by: Dmitry Torokhov --- drivers/input/input.c | 6 ++++++ include/linux/input.h | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/input/input.c b/drivers/input/input.c index cf6fecea79b8..dcb1f72711c3 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c @@ -1756,6 +1756,9 @@ static int input_inhibit_device(struct input_dev *dev) { guard(mutex)(&dev->mutex); + if (dev->going_away) + return -ENODEV; + if (dev->inhibited) return 0; @@ -1784,6 +1787,9 @@ static int input_uninhibit_device(struct input_dev *dev) guard(mutex)(&dev->mutex); + if (dev->going_away) + return -ENODEV; + if (!dev->inhibited) return 0; diff --git a/include/linux/input.h b/include/linux/input.h index 76f7aa226202..bb97ebb815bf 100644 --- a/include/linux/input.h +++ b/include/linux/input.h @@ -117,7 +117,8 @@ enum input_clock_type { * user opens device and dev->close() is called when the very * last user closes the device * @going_away: marks devices that are in a middle of unregistering and - * causes input_open_device*() fail with -ENODEV. + * causes input_open_device() and input_inhibit/uninhibit_device() + * to fail with -ENODEV. * @dev: driver model's view of this device * @h_list: list of input handles associated with the device. When * accessing the list dev->mutex must be held -- 2.55.0.629.g250fe7f194-goog -- Dmitry