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 35938415F29; Fri, 4 Sep 2026 05:58:18 +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=1788501499; cv=none; b=RCghbKEsAMyj2sjnikqBX4i4NxO2A0HW+5zNtlXZ3jlBXVoO64fo0egWXSruMcW+hzi0CAF437+3m9BcENVbkkLvzIKyfKZL/iYARyaMSaiEnt5eNIyTmPgJ/Xkp4xcZosREytlfys15HpEdGZgq1lj/ngFXeJItgL8BkFwGDiU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788501499; c=relaxed/simple; bh=axZVweUIJ6aqoute1IqQxWuOPea85gjZRhH8CCvHq4A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=V9S7dpyrt6VMCqoh19fvKzBvW1hqcR88A4b3HmzH3NoHKgzZ4+/4YTQ668sArQolwVEP1+2ASd5Py+x3Dd6kOwho3vXkQZJYB7m4EM9gIUHa0iLIRWk2NymRjH8vsYJV5ixAsfj23YjjIYpQfaYaa6WBGRVzVcCl2YnqCfLWgo8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=d8pa8vAr; 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="d8pa8vAr" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8AF1C1F00A3D; Fri, 4 Sep 2026 05:58:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1788501498; bh=rkA0Onr+se/GCltbp3l4Nyl3gtmxQL/hXJ3iNSCzWUY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=d8pa8vArwLxEj/SRxRhzyqElAlJk4fiU/BdBAY/JluhfSLYw/Bcmkq4+wm1mZpC1e aO504gick5FGUD/TEr2/9xgG2+9ikF0mwBAvPRkDcDXpeWmigFvYjVy0I8neYHO0kx kIDKEbRUjh/PjDqYyGO7Nso5ryib+otJg3yDAYLM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Bryam Vargas , Tzung-Bi Shih Subject: [PATCH 6.18 430/552] platform/chrome: sensorhub: Bound the EC-reported sensor number Date: Fri, 4 Sep 2026 06:59:47 +0200 Message-ID: <20260904045800.343706999@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260904045747.813364717@linuxfoundation.org> References: <20260904045747.813364717@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.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Bryam Vargas commit 833740a2333c2e4db4e02e3d0ffba04e8718a5f3 upstream. Each EC FIFO event carries an 8-bit sensor number (in->sensor_num). cros_ec_sensorhub_ring_handler() validates the FIFO event count, the per-read count and the ring bound, but not the sensor number, which cros_ec_sensor_ring_process_event() then uses unchecked to index sensorhub->batch_state[] - allocated with only sensorhub->sensor_num entries. A sensor number of sensor_num or larger is an out-of-bounds read and write of batch_state[]. Validate the sensor number in the ring handler, where each event is read from the EC, and drop a malformed event before it is used. Fixes: 145d59baff59 ("platform/chrome: cros_ec_sensorhub: Add FIFO support") Cc: stable@vger.kernel.org Signed-off-by: Bryam Vargas Link: https://lore.kernel.org/r/20260618-b4-disp-adb3f790-v3-1-3a164ed63cbd@proton.me Signed-off-by: Tzung-Bi Shih Signed-off-by: Greg Kroah-Hartman --- drivers/platform/chrome/cros_ec_sensorhub_ring.c | 8 ++++++++ 1 file changed, 8 insertions(+) --- a/drivers/platform/chrome/cros_ec_sensorhub_ring.c +++ b/drivers/platform/chrome/cros_ec_sensorhub_ring.c @@ -879,6 +879,14 @@ static void cros_ec_sensorhub_ring_handl for (in = sensorhub->resp->fifo_read.data, j = 0; j < number_data; j++, in++) { + /* Skip event if sensor_num from EC is out of bounds. */ + if (in->sensor_num >= sensorhub->sensor_num) { + dev_warn_ratelimited(sensorhub->dev, + "Invalid sensor number %u from EC\n", + in->sensor_num); + continue; + } + if (cros_ec_sensor_ring_process_event( sensorhub, fifo_info, fifo_timestamp,