lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240223172936.it.875-kees@kernel.org>
Date: Fri, 23 Feb 2024 09:29:39 -0800
From: Kees Cook <keescook@...omium.org>
To: Jonathan Cameron <jic23@...nel.org>
Cc: Kees Cook <keescook@...omium.org>,
	"Lars-Peter Clausen" <lars@...afoo.de>,
	Uwe Kleine-König <u.kleine-koenig@...gutronix.de>,
	"Andy Shevchenko" <andriy.shevchenko@...ux.intel.com>,
	Nuno Sá <nuno.sa@...log.com>,
	linux-iio@...r.kernel.org,
	"Nathan Chancellor" <nathan@...nel.org>,
	"Nick Desaulniers" <ndesaulniers@...gle.com>,
	"Bill Wendling" <morbo@...gle.com>,
	"Justin Stitt" <justinstitt@...gle.com>,
	llvm@...ts.linux.dev,
	Tomislav Denis <tomislav.denis@....com>,
	linux-kernel@...r.kernel.org,
	linux-hardening@...r.kernel.org
Subject: [PATCH v2] iio: pressure: dlhl60d: Initialize empty DLH bytes

3 bytes were being read but 4 were being written. Explicitly initialize
the unused bytes to 0 and refactor the loop to use direct array
indexing, which appears to silence a Clang false positive warning[1].

Link: https://github.com/ClangBuiltLinux/linux/issues/2000 [1]
Fixes: ac78c6aa4a5d ("iio: pressure: Add driver for DLH pressure sensors")
Signed-off-by: Kees Cook <keescook@...omium.org>
---
Cc: Jonathan Cameron <jic23@...nel.org>
Cc: "Lars-Peter Clausen" <lars@...afoo.de>
Cc: "Uwe Kleine-König" <u.kleine-koenig@...gutronix.de>
Cc: "Andy Shevchenko" <andriy.shevchenko@...ux.intel.com>
Cc: "Nuno Sá" <nuno.sa@...log.com>
Cc: linux-iio@...r.kernel.org
Cc: "Nathan Chancellor" <nathan@...nel.org>
Cc: "Nick Desaulniers" <ndesaulniers@...gle.com>
Cc: "Bill Wendling" <morbo@...gle.com>
Cc: "Justin Stitt" <justinstitt@...gle.com>
Cc: llvm@...ts.linux.dev
 v2: drop comments, array expansion, and WARN. refactor loop.
 v1: https://lore.kernel.org/linux-hardening/20240222222335.work.759-kees@kernel.org/
---
 drivers/iio/pressure/dlhl60d.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/pressure/dlhl60d.c b/drivers/iio/pressure/dlhl60d.c
index 28c8269ba65d..0bba4c5a8d40 100644
--- a/drivers/iio/pressure/dlhl60d.c
+++ b/drivers/iio/pressure/dlhl60d.c
@@ -250,18 +250,17 @@ static irqreturn_t dlh_trigger_handler(int irq, void *private)
 	struct dlh_state *st = iio_priv(indio_dev);
 	int ret;
 	unsigned int chn, i = 0;
-	__be32 tmp_buf[2];
+	__be32 tmp_buf[2] = { };
 
 	ret = dlh_start_capture_and_read(st);
 	if (ret)
 		goto out;
 
 	for_each_set_bit(chn, indio_dev->active_scan_mask,
-		indio_dev->masklength) {
-		memcpy(tmp_buf + i,
+			 indio_dev->masklength) {
+		memcpy(&tmp_buf[i++],
 			&st->rx_buf[1] + chn * DLH_NUM_DATA_BYTES,
 			DLH_NUM_DATA_BYTES);
-		i++;
 	}
 
 	iio_push_to_buffers(indio_dev, tmp_buf);
-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ