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 C5CFB2C1595; Sun, 7 Jun 2026 10:39:55 +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=1780828796; cv=none; b=iYN1+lzWoR2HKO53Q22yU7h11usJS4XGwK8cxvDbGsiit8eEcycos+MZyoYNpOi+yfuXU4LkY2fFCgI2KmOOLIIqlk7lNgul/+3PLhaxzwxtrjkyf9ZQLlow+VuKSHcJNV6MGz02YdzYqbb076ukQEhwO+ZrR/nN7h4IAxuQ7mw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780828796; c=relaxed/simple; bh=mHW8nUuNKjXXFM3NLLRfossLV2tnku5n/kiYB3uP0sY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EHyDJJcM057yK87vhmcDlkLOd4f1WIXvLkdqbd19chMrgyXNTRi4bG7JYrcJYXrjTjV5mMpIvJPSGbLyw9St5LilurCB+9eV7fyeTrp0BMH0sz8f+n9eqc8rKk24YKaI3rVTHzOWMrEUe7qck8QHlvd17m9vkWNtDjoI96CoFpc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=iLayhDoV; 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="iLayhDoV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 15DCB1F00893; Sun, 7 Jun 2026 10:39:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1780828795; bh=4wL3YiPgqmayevBJpOUaVaU5uLqo5OlyiIkR8Y3KYBk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=iLayhDoVWfa0xtwIeg89522ct8/BSl4O8Hv03fW1pKAqUAhieegKR6YMWRZ0fB9qX 4vRboFX7NmKdSF0HyPlo0hD4DTQUgzxj5RR8bIHWm4ae6OKCfXhKB9BlxsPfP/7ZZE 6gxEMsJpPoze9wJF6hultSfjlaue9+IB6fgsceq4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, David Carlier , Andy Shevchenko , Jonathan Cameron Subject: [PATCH 6.12 169/307] iio: gyro: itg3200: fix i2c read into the wrong stack location Date: Sun, 7 Jun 2026 11:59:26 +0200 Message-ID: <20260607095733.929591579@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260607095727.647295505@linuxfoundation.org> References: <20260607095727.647295505@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: David Carlier commit 6bdc3023d62ed5c7d591f0eb27a5adb37fb892ae upstream. 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 Reviewed-by: Andy Shevchenko Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/iio/gyro/itg3200_buffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/iio/gyro/itg3200_buffer.c +++ b/drivers/iio/gyro/itg3200_buffer.c @@ -34,7 +34,7 @@ static int itg3200_read_all_channels(str .addr = i2c->addr, .flags = i2c->flags | I2C_M_RD, .len = ITG3200_SCAN_ELEMENTS * sizeof(s16), - .buf = (char *)&buf, + .buf = (char *)buf, }, };