From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0F9EA27280A; Mon, 13 Apr 2026 16:16:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776096988; cv=none; b=IJ9wNh8AKlGH7AeqB7QVsnsuJcKXqn05+IxyiRWcTnRhDHo/dYFZyA+/ClWyOEcst4KZJ1l6zGRnYYGSVBpTX5Uhnw3RzXBpce5rQwvzhfsQ9ezsHVzfKfIQ9pI/+QNcO1RRgaPI7hYeBqnMFHOxp1IZLggFDWpIfZvKF9JCWZQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776096988; c=relaxed/simple; bh=88dFMIVITCfwV7bYC56EXSalDLRob1qdhYnkOTEbi8Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=V011RMKddHXqR2Lo2Ly/FPiTqrFoaojwUxdfk5Iyxb1Kja8Jnm20JwgzsFCBUFIOBH2XixhxyNH87Ig1a3GcNc5beVtjtrYWYWAxSgfZDxizAY8+x1Q+7Nfzpf6LZZ6hWlsljo4S4rrZvFiO38XPfPNJxn/7DLdJWTMoSIM04a4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=R2T+L/hL; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="R2T+L/hL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 99B38C2BCAF; Mon, 13 Apr 2026 16:16:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1776096987; bh=88dFMIVITCfwV7bYC56EXSalDLRob1qdhYnkOTEbi8Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R2T+L/hLMLUw0/rWdjhgFpFyazj8rwouCprwD9nEYmh8jntbaUcqUG7vCG7flkQvS izGzBMRawxCZ+kxe05XBfqbk42JxQkrx5PaF6b+EaUPULanlLFLwIz92K0+YIXBV+B 9oNAKwUUsM9YYlRvEceE0QKhLLl3D2pLZhVw+0yQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Mikhail Gavrilov , Dmitry Torokhov Subject: [PATCH 6.1 06/55] Input: uinput - take event lock when submitting FF request "event" Date: Mon, 13 Apr 2026 18:00:40 +0200 Message-ID: <20260413155725.063294503@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260413155724.820472494@linuxfoundation.org> References: <20260413155724.820472494@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dmitry Torokhov commit ff14dafde15c11403fac61367a34fea08926e9ee upstream. To avoid racing with FF playback events and corrupting device's event queue take event_lock spinlock when calling uinput_dev_event() when submitting a FF upload or erase "event". Tested-by: Mikhail Gavrilov Link: https://patch.msgid.link/adXkf6MWzlB8LA_s@google.com Cc: stable@vger.kernel.org Signed-off-by: Dmitry Torokhov Signed-off-by: Greg Kroah-Hartman --- drivers/input/misc/uinput.c | 7 +++++++ 1 file changed, 7 insertions(+) --- a/drivers/input/misc/uinput.c +++ b/drivers/input/misc/uinput.c @@ -25,8 +25,10 @@ #include #include #include +#include #include #include +#include #include #include "../input-compat.h" @@ -75,6 +77,8 @@ static int uinput_dev_event(struct input struct uinput_device *udev = input_get_drvdata(dev); struct timespec64 ts; + lockdep_assert_held(&dev->event_lock); + ktime_get_ts64(&ts); udev->buff[udev->head] = (struct input_event) { @@ -146,6 +150,7 @@ static void uinput_request_release_slot( static int uinput_request_send(struct uinput_device *udev, struct uinput_request *request) { + unsigned long flags; int retval = 0; spin_lock(&udev->state_lock); @@ -159,7 +164,9 @@ static int uinput_request_send(struct ui * Tell our userspace application about this new request * by queueing an input event. */ + spin_lock_irqsave(&udev->dev->event_lock, flags); uinput_dev_event(udev->dev, EV_UINPUT, request->code, request->id); + spin_unlock_irqrestore(&udev->dev->event_lock, flags); out: spin_unlock(&udev->state_lock);