From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (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 B9AC43C6A39 for ; Tue, 5 May 2026 13:37:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777988275; cv=none; b=GuwCkxmdwfWEAKQ5dfWzTjjaKXRzuMs72/zPEFY3soZzg0f4MyhErlYMllAbY4R/HzMh3O6bS2Tv+sf8MwsQZ48IBAog4PSFanpMELfRzpogSfQYSXCtNO7rcJiDa3nNIJ0Vrvnd2jFAkt2yzKl35COsEN2WuqpdHpnY6SexAuQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777988275; c=relaxed/simple; bh=nI482rHAbt5nXbKBqEJDa7o2nSrbcSlgM1ZPd6rpVsQ=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=rvC4pHjkIZULf8e7NyVpFCjm/wWqb6aUJyae12Ea1TizTEmtY/UX5cZF5UVKX6uW0p55JHr6pml0KAH867H3AWz/HQwWiIgmT7GNko9LZuQFqFgGLqeaCebSzRaySw3qdU/o7yUwWEmP949YHmX2NRQN3XYUbGPMMbw+RSqbG4U= 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=nAh4ZExN; arc=none smtp.client-ip=209.85.128.54 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="nAh4ZExN" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-488ad135063so50083825e9.0 for ; Tue, 05 May 2026 06:37:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777988272; x=1778593072; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=8zqGy9FCxsyto+kn1sLwjo8QRhEdeQTEmwhLR5OXod0=; b=nAh4ZExNWY5zSJTf1wuqWZzlvDsn3P98+RtvyT+v2D64+8/f5KhYTaTT1Uxt/Ur+4d ZTvfBzCpHUkNlREgCkfs7EjiFHzY0lqaX+ZZmC7YyyYSGRzDqE/0mGf8QpO4Z1V4Q65o qPtsLlX76ZNUIN5Ww1jwotx3bh0BtkVh3zl2B8N/dLJF+iHL2gyE24O2us7CJ53rXOkk U+GdOwIH8/yyScGd2fz862t0iJTbNqT0SRSqX/MskMpAIFaJTgxp2j0EFOz8QMb9bna4 GktlV6l/l2kzKiVCJppPij2QsdEOHoLNNO7TD5rSu8Gyu00NOX8KQKVbyBkYjJt/2J8F xfRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777988272; x=1778593072; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=8zqGy9FCxsyto+kn1sLwjo8QRhEdeQTEmwhLR5OXod0=; b=iqdzyL/MI9p6BIKeDv983NNxjcRLbLYbFrZQWRRHbY83DTuPuCbBuBSCJ4ilmYDEYg D84u7/9TaUbQVNJy9wATy2JhxPq/9tbNBZnhMEa9K3x76mGUeyxqDh35ccwZQQG393fH w8lGj7rpR5jipt8PH/zveX8tRM6kXMzMqpKQP17nkXkEdCiFmVaBE4GsQf8f8j10hF9E UTQa7kGx9fUm0QZ6F9hGs1ZrWed5JQ8oVo7r/YcMxQv98mc13F6BvxrI7bs2PudzBEJk 9SkpzpmB8N43k1tTU2cwIWEFWCxr59aqEfZCQ2nl1AmS1LTv9NwBgQbPDUc5UGD6V+CA 38uQ== X-Forwarded-Encrypted: i=1; AFNElJ+Ft8EGpNr2I8Iu70vOZR5xE13hWFucOKm4drSadQFvcwX7syKjTYAOUVKkI0y82X8GqTGOXftu2rZ4In0=@vger.kernel.org X-Gm-Message-State: AOJu0YyXU+ZpOOUE2DQJu++eFAFuBC6d0wRlB24i3FRCiw5Sru4UHdf/ b2r+96shiTvVKfh3Iq1QlutzoXz3r9yfnsRK4yQtZoHmUCK2Jde+R5uM X-Gm-Gg: AeBDietuF+Hw6sF8dwHCyRuivd7Q9ENi6AtEt7eIVzV+qs7IMD9AodR8ZHlpKY3fa00 M+PbZUJH48nLpMgd2ROo0qJ5YYAVLu0w8XMzOCqu8c5IZkUF9URUVJKFQBM+dfP4ctv83kWXSZ9 PbDms2MSOrQGVDws7ci2Bm/GGI8MxPoP8tiZwWAiF9bM/HawY9627XZ/DdTb323dNphQgujYNCm UG8sg5XNAIW7xrVJoE9hTZ5YmUYJ6IKrtXXe9zNfIH7UqbR4tnjfla0p1p+QyEgd5C35gjOVE6f ZB+sjAP74kYRGycqWDktQDV7GxcH/q3aAi6YqTnB1EIytMLgCQ7qP2wHWfNoRYCQ0x95hWydiN5 UOiTZwpngeC+e7FsQVGizHFtlddY1Mcq9otDiHnbVoioNJKM8BI3S1k21jp5Tg7xe4SCCvTOdSk kSF5qZW2xidBmrdV0YYDVhu2MWoRRuELUL+QxFHWv6Fc2GUV7w1zRW+XROuvmpkfWhHuVLx8qD0 nSlQYQlzEWpyu6XjBlpzToSdIAgFqCq X-Received: by 2002:a05:600c:3596:b0:488:fd7e:1063 with SMTP id 5b1f17b1804b1-48a988cee29mr269575315e9.29.1777988271858; Tue, 05 May 2026 06:37:51 -0700 (PDT) Received: from dohko.chello.ie (188-141-5-72.dynamic.upc.ie. [188.141.5.72]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48a81b99127sm391200295e9.0.2026.05.05.06.37.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 May 2026 06:37:51 -0700 (PDT) From: David Carlier To: Jonathan Cameron Cc: dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, David Carlier Subject: [PATCH] iio: gyro: itg3200: fix i2c read into the wrong stack location Date: Tue, 5 May 2026 14:37:48 +0100 Message-ID: <20260505133748.51355-1-devnexen@gmail.com> X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit itg3200_read_all_channels() takes `__be16 *buf' as a parameter and fills the i2c_msg destination as `(char *)&buf'. Since `buf' is the parameter (a pointer), `&buf' is the address of the local pointer slot on the stack of itg3200_read_all_channels(), not the address of the caller's scan buffer. The (char *) cast hides the type mismatch. i2c_transfer() therefore writes ITG3200_SCAN_ELEMENTS * sizeof(s16) = 8 bytes into the parameter's stack slot, which is discarded when the function returns. The caller's scan buffer in itg3200_trigger_handler() is never written to, so iio_push_to_buffers_with_timestamp() pushes uninitialised stack contents to userspace via /dev/iio:deviceX every scan -- both a functional bug (no actual gyroscope or temperature data is delivered through the triggered buffer) and an information leak. The non-buffered read_raw() path is unaffected: it goes through itg3200_read_reg_s16() which uses `&out' on a local s16 value, where that is correct. Drop the spurious `&' so the i2c read writes into the caller's buffer. Fixes: 9dbf091da080 ("iio: gyro: Add itg3200") Cc: stable@vger.kernel.org Signed-off-by: David Carlier --- drivers/iio/gyro/itg3200_buffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/gyro/itg3200_buffer.c b/drivers/iio/gyro/itg3200_buffer.c index a624400a239c..0d3a50031d76 100644 --- a/drivers/iio/gyro/itg3200_buffer.c +++ b/drivers/iio/gyro/itg3200_buffer.c @@ -34,7 +34,7 @@ static int itg3200_read_all_channels(struct i2c_client *i2c, __be16 *buf) .addr = i2c->addr, .flags = i2c->flags | I2C_M_RD, .len = ITG3200_SCAN_ELEMENTS * sizeof(s16), - .buf = (char *)&buf, + .buf = (char *)buf, }, }; -- 2.53.0