From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 7EBAC479873; Sat, 12 Sep 2026 12:00:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789214430; cv=none; b=NyLnwf1glr++Nz3mkRMQ44zZywrvfHvpvMhzPbpxqMsN/gH+oxjv6T63mlH5v2uhKwCfgRBj+LiSVb0tQY2TDpzabbBAAKlVVsPegJqBOqfsxgxat9PxFyU1G/LNFfbaFrbKZnZ+wXYFrNroQAn+/FkGAdt50Z1qem2TfxaBrRE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789214430; c=relaxed/simple; bh=Or8q8Xa5XMdKIaW5uO1AR9Yqrjp+7HGZhJlXAjsBeH0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EfYKPD5qrHC9Q+43TbVTkJ8liHsJyeFKsHzVxaz04YMhDS39XpVSuVE+UmIaTC09O0fae1YdUQBxOWDX7GNWSb0n7ijf95O7hUXN0BOOiU6TtbDnudquJIISe1VL0oYATA9gCBCqcWi4lf5maE2BSGeEMBNqKhpWaQnD//NjQ+w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=e8Fbt4lT; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="e8Fbt4lT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A8D1F1F000FF; Sat, 12 Sep 2026 12:00:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789214427; bh=g9zguBnPkkMGy2wRjPmT8EYmMvjW65mveQJ3EVEpvZE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=e8Fbt4lT5QaMP4u54Qz0oqYWvpuBjxNSK1UVRACsqN9i9f6+WD/MWrWb/P+uO1uPK voNRTdPUsfcIk4oM0At+GMOTSjPC3g0a1EqndS/QYonnzqWsbN/fe1dgLnMNdLm/Xn YlwsevfaSO+/CCJ1Ok7h73B7wZG3wI78yAYv6zRE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Michael Bommarito , Jiri Kosina , Sasha Levin Subject: [PATCH 6.12 0323/1376] HID: roccat: bound device-supplied profile index Date: Sat, 12 Sep 2026 08:45:49 +0200 Message-ID: <20260912065614.745755146@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260912065607.535295758@linuxfoundation.org> References: <20260912065607.535295758@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Michael Bommarito [ Upstream commit 43fae42628a8c10fa8981773d7ec9f1a367821a7 ] kone_keep_values_up_to_date() and kone_profile_activated() use an 8-bit, device-supplied profile value as an index into the 5-element kone->profiles[] array without a range check. A malicious USB device claiming the Roccat Kone id can send a switch-profile event (or a startup_profile read at probe) with an out-of-range value and make the driver read out of bounds; the result is exposed via the actual_dpi sysfs attribute. Reject out-of-range indices in both paths. This was found with static analysis and confirmed with the KUnit test added in the following patch (KASAN: slab-out-of-bounds). Fixes: 14bf62cde7942 ("HID: add driver for Roccat Kone gaming mouse") Assisted-by: Claude:claude-opus-4-8 Signed-off-by: Michael Bommarito Signed-off-by: Jiri Kosina Signed-off-by: Sasha Levin --- drivers/hid/hid-roccat-kone.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/hid/hid-roccat-kone.c b/drivers/hid/hid-roccat-kone.c index 3f8f459edcf3c..dd206531fc79f 100644 --- a/drivers/hid/hid-roccat-kone.c +++ b/drivers/hid/hid-roccat-kone.c @@ -36,6 +36,8 @@ static uint profile_numbers[5] = {0, 1, 2, 3, 4}; static void kone_profile_activated(struct kone_device *kone, uint new_profile) { + if (new_profile < 1 || new_profile > ARRAY_SIZE(kone->profiles)) + new_profile = 1; kone->actual_profile = new_profile; kone->actual_dpi = kone->profiles[new_profile - 1].startup_dpi; } @@ -793,8 +795,10 @@ static void kone_keep_values_up_to_date(struct kone_device *kone, { switch (event->event) { case kone_mouse_event_switch_profile: - kone->actual_dpi = kone->profiles[event->value - 1]. - startup_dpi; + if (event->value >= 1 && + event->value <= ARRAY_SIZE(kone->profiles)) + kone->actual_dpi = + kone->profiles[event->value - 1].startup_dpi; fallthrough; case kone_mouse_event_osd_profile: kone->actual_profile = event->value; -- 2.53.0