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 349C023E356; Fri, 24 Apr 2026 13:34:25 +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=1777037665; cv=none; b=aWGpgjIEaaLrzUOhaFOYuX/nE5hRfZG1GZGtqOqXqZ8I2eSwF+aiLWf6FwjMos9AejiSmOkP119lm/vwr9RXbDMciMoHd7xT4jSsohKm1maTcTYZMpShGjZdljJNFZVvAR+WPMucb7I26AY1XSnJicIxMnMeBfTdUB31q3zai+c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777037665; c=relaxed/simple; bh=uygLYQAJjCNje+jbLbEBG/DivuzpLmiXUcs/wRlcM6s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=rc2u+xGwnHzcN7UeNR1FOFgBfYvho4SXD/3tsX44YptD3BHQCCdFttCtpZsTm3AZOkkVFQIo3gq8eqMaEY+J18bd9VsBq6xORiEDnLHBaZMbeC89m9/OVZxROXZh425JxdSoLNETrjrvoaUfhC29kQJUVWacLE5IO3q+lkL0CD4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=TvhHG6UL; 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="TvhHG6UL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BF2CBC19425; Fri, 24 Apr 2026 13:34:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1777037665; bh=uygLYQAJjCNje+jbLbEBG/DivuzpLmiXUcs/wRlcM6s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TvhHG6ULRUQPQoa/ts8wo90nWLe65G6XmTpraPMzNca511HA4+QBJnG8Eyf+AiwiD 88sOWfy3FJVGUCM61YeZFnxXytjuKMTP1JtShfPBQ5DrGcekIliE0mJTPe07Q9yeKT Lc+Xjznb+0RCdHMFdaUbk+tXu37L2/Hqd+ExLtXQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, =?UTF-8?q?Beno=C3=AEt=20Sevens?= , Silvan Jegen , Jiri Kosina , Sasha Levin Subject: [PATCH 6.6 023/166] HID: roccat: fix use-after-free in roccat_report_event Date: Fri, 24 Apr 2026 15:28:57 +0200 Message-ID: <20260424132537.698674408@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260424132532.812258529@linuxfoundation.org> References: <20260424132532.812258529@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-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Benoît Sevens [ Upstream commit d802d848308b35220f21a8025352f0c0aba15c12 ] roccat_report_event() iterates over the device->readers list without holding the readers_lock. This allows a concurrent roccat_release() to remove and free a reader while it's still being accessed, leading to a use-after-free. Protect the readers list traversal with the readers_lock mutex. Signed-off-by: Benoît Sevens Reviewed-by: Silvan Jegen Signed-off-by: Jiri Kosina Signed-off-by: Sasha Levin --- drivers/hid/hid-roccat.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/hid/hid-roccat.c b/drivers/hid/hid-roccat.c index c7f7562e22e56..e413662f75082 100644 --- a/drivers/hid/hid-roccat.c +++ b/drivers/hid/hid-roccat.c @@ -257,6 +257,7 @@ int roccat_report_event(int minor, u8 const *data) if (!new_value) return -ENOMEM; + mutex_lock(&device->readers_lock); mutex_lock(&device->cbuf_lock); report = &device->cbuf[device->cbuf_end]; @@ -279,6 +280,7 @@ int roccat_report_event(int minor, u8 const *data) } mutex_unlock(&device->cbuf_lock); + mutex_unlock(&device->readers_lock); wake_up_interruptible(&device->wait); return 0; -- 2.53.0