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-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2c8c5fa4-b0f7-4ca5-b003-4b37cc036664@roeck-us.net>
Date: Fri, 9 Feb 2024 13:25:36 -0800
From: Guenter Roeck <linux@...ck-us.net>
To: Mark Brown <broonie@...nel.org>
Cc: linux-kernel@...r.kernel.org
Subject: Re: [PATCH] regmap: kunit: Ensure that changed bytes are actually
 different

Hi Mark,

On 2/9/24 12:05, Mark Brown wrote:
> On Fri, Feb 09, 2024 at 08:02:27PM +0000, Mark Brown wrote:
>> During the cache sync test we verify that values we expect to have been
>> written only to the cache do not appear in the hardware. This works most
>> of the time but since we randomly generate both the original and new values
>> there is a low probability that these values may actually be the same.
>> Wrap get_random_bytes() to ensure that the values are different, it is
>> likely we will want a similar pattern for other tests in the future.
> 
> Sorry, works better if you actally check stuff in.  v2 coming.


I don't know how v2 looks like (I think some of the hw_buf index values are
wrong), but have a look at the diff below.

Guenter

---
diff --git a/drivers/base/regmap/regmap-kunit.c b/drivers/base/regmap/regmap-kunit.c
index 6fe259a2a73f..e73bdf01f118 100644
--- a/drivers/base/regmap/regmap-kunit.c
+++ b/drivers/base/regmap/regmap-kunit.c
@@ -1283,7 +1283,13 @@ static void raw_sync(struct kunit *test)

         hw_buf = (u16 *)data->vals;

-       get_changed_bytes(&hw_buf[6], &val[0], sizeof(val));
+       get_changed_bytes(&hw_buf[4], &val[0], sizeof(val));
+       // Let's cheat.
+       // Remember, the above code doesn't look into hw_buf[2..3],
+       // so anything might be in there, including the values from
+       // the val[] array.
+       hw_buf[2] = val[0];
+       hw_buf[3] = val[1];

         /* Do a regular write and a raw write in cache only mode */
         regcache_cache_only(map, true);
@@ -1331,7 +1337,7 @@ static void raw_sync(struct kunit *test)

         /* The values should now appear in the "hardware" */
         KUNIT_EXPECT_MEMEQ(test, &hw_buf[2], val, sizeof(val));
-       KUNIT_EXPECT_MEMEQ(test, &hw_buf[6], val, sizeof(u16));
+       KUNIT_EXPECT_MEMEQ(test, &hw_buf[4], val, sizeof(u16));

         regmap_exit(map);
  }


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ