* [PATCH 00/18] random: Include <linux/percpu.h> and resolve circular include dependency
@ 2024-09-05 12:17 Uros Bizjak
2024-09-05 12:17 ` [PATCH 01/18] x86/kaslr: Include <linux/prandom.h> instead of <linux/random.h> Uros Bizjak
` (18 more replies)
0 siblings, 19 replies; 32+ messages in thread
From: Uros Bizjak @ 2024-09-05 12:17 UTC (permalink / raw)
To: linux-kernel
Cc: Uros Bizjak, Dave Hansen, Andy Lutomirski, Peter Zijlstra,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, x86,
H. Peter Anvin, Jani Nikula, Joonas Lahtinen, Rodrigo Vivi,
Tvrtko Ursulin, David Airlie, Daniel Vetter, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, Hans Verkuil,
Mauro Carvalho Chehab, Miquel Raynal, Richard Weinberger,
Vignesh Raghavendra, Eric Biggers, Theodore Y. Ts'o,
Jaegeuk Kim, Jason A. Donenfeld, Linus Torvalds, Hannes Reinecke,
James E.J. Bottomley, Martin K. Petersen, Alexei Starovoitov,
Daniel Borkmann, John Fastabend, Andrii Nakryiko,
Martin KaFai Lau, Eduard Zingerman, Song Liu, Yonghong Song,
KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa, Andrew Morton,
Brendan Higgins, David Gow, Rae Moar, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Jiri Pirko,
Petr Mladek, Steven Rostedt, Andy Shevchenko, Rasmus Villemoes,
Sergey Senozhatsky, Stephen Hemminger, Jamal Hadi Salim,
Cong Wang, Kent Overstreet, intel-gfx, dri-devel, linux-media,
linux-mtd, linux-fscrypt, linux-scsi, bpf, linux-kselftest,
kunit-dev
There were several attempts to resolve circular include dependency
after the addition of percpu.h: 1c9df907da83 ("random: fix circular
include dependency on arm64 after addition of percpu.h"), c0842fbc1b18
("random32: move the pseudo-random 32-bit definitions to prandom.h") and
finally d9f29deb7fe8 ("prandom: Remove unused include") that completely
removes inclusion of <linux/percpu.h>.
Due to legacy reasons, <linux/random.h> includes <linux/prandom.h>, but
with the commit entry remark:
--quote--
A further cleanup step would be to remove this from <linux/random.h>
entirely, and make people who use the prandom infrastructure include
just the new header file. That's a bit of a churn patch, but grepping
for "prandom_" and "next_pseudo_random32" "struct rnd_state" should
catch most users.
But it turns out that that nice cleanup step is fairly painful, because
a _lot_ of code currently seems to depend on the implicit include of
<linux/random.h>, which can currently come in a lot of ways, including
such fairly core headfers as <linux/net.h>.
So the "nice cleanup" part may or may never happen.
--/quote--
__percpu tag is currently defined in include/linux/compiler_types.h,
so there is no direct need for the inclusion of <linux/percpu.h>.
However, in [1] we would like to repurpose __percpu tag as a named
address space qualifier, where __percpu macro uses defines from
<linux/percpu.h>.
This patch series is the "nice cleanup" part, and allows us to finally
include <linux/percpu.h> in prandom.h.
The whole series was tested by compiling the kernel for x86_64 allconfig
and some popular architectures, namely arm64 defconfig, powerpc defconfig
and loongarch defconfig.
[1] https://lore.kernel.org/lkml/20240812115945.484051-4-ubizjak@gmail.com/
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: x86@kernel.org
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: Tvrtko Ursulin <tursulin@ursulin.net>
Cc: David Airlie <airlied@gmail.com>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Maxime Ripard <mripard@kernel.org>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Hans Verkuil <hverkuil@xs4all.nl>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Richard Weinberger <richard@nod.at>
Cc: Vignesh Raghavendra <vigneshr@ti.com>
Cc: Eric Biggers <ebiggers@kernel.org>
Cc: "Theodore Y. Ts'o" <tytso@mit.edu>
Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Cc: "Jason A. Donenfeld" <Jason@zx2c4.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Hannes Reinecke <hare@suse.de>
Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: John Fastabend <john.fastabend@gmail.com>
Cc: Andrii Nakryiko <andrii@kernel.org>
Cc: Martin KaFai Lau <martin.lau@linux.dev>
Cc: Eduard Zingerman <eddyz87@gmail.com>
Cc: Song Liu <song@kernel.org>
Cc: Yonghong Song <yonghong.song@linux.dev>
Cc: KP Singh <kpsingh@kernel.org>
Cc: Stanislav Fomichev <sdf@fomichev.me>
Cc: Hao Luo <haoluo@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Brendan Higgins <brendan.higgins@linux.dev>
Cc: David Gow <davidgow@google.com>
Cc: Rae Moar <rmoar@google.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: Jiri Pirko <jiri@resnulli.us>
Cc: Petr Mladek <pmladek@suse.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: Stephen Hemminger <stephen@networkplumber.org>
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Cc: Cong Wang <xiyou.wangcong@gmail.com>
Cc: Uros Bizjak <ubizjak@gmail.com>
Cc: Kent Overstreet <kent.overstreet@linux.dev>
Cc: intel-gfx@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org
Cc: linux-media@vger.kernel.org
Cc: linux-mtd@lists.infradead.org
Cc: linux-fscrypt@vger.kernel.org
Cc: linux-scsi@vger.kernel.org
Cc: bpf@vger.kernel.org
Cc: linux-kselftest@vger.kernel.org
Cc: kunit-dev@googlegroups.com
Uros Bizjak (18):
x86/kaslr: Include <linux/prandom.h> instead of <linux/random.h>
drm/i915/selftests: Include <linux/prandom.h> instead of
<linux/random.h>
drm/lib: Include <linux/prandom.h> instead of <linux/random.h>
media: vivid: Include <linux/prandom.h> in vivid-vid-cap.c
mtd: tests: Include <linux/prandom.h> instead of <linux/random.h>
fscrypt: Include <linux/prandom.h> instead of <linux/random.h>
scsi: libfcoe: Include <linux/prandom.h> instead of <linux/random.h>
bpf: Include <linux/prandom.h> instead of <linux/random.h>
lib/interval_tree_test.c: Include <linux/prandom.h> instead of
<linux/random.h>
kunit: string-stream-test: Include <linux/prandom.h> instead of
<linux/random.h>
random32: Include <linux/prandom.h> instead of <linux/random.h>
lib/rbtree-test: Include <linux/prandom.h> instead of <linux/random.h>
bpf/tests: Include <linux/prandom.h> instead of <linux/random.h>
lib/test_parman: Include <linux/prandom.h> instead of <linux/random.h>
lib/test_scanf: Include <linux/prandom.h> instead of <linux/random.h>
netem: Include <linux/prandom.h> in sch_netem.c
random: Do not include <linux/prandom.h>
prandom: Include <linux/percpu.h>
arch/x86/mm/kaslr.c | 2 +-
drivers/gpu/drm/i915/selftests/i915_gem.c | 2 +-
drivers/gpu/drm/i915/selftests/i915_random.h | 2 +-
drivers/gpu/drm/i915/selftests/scatterlist.c | 2 +-
drivers/gpu/drm/lib/drm_random.h | 2 +-
drivers/media/test-drivers/vivid/vivid-vid-cap.c | 1 +
drivers/mtd/tests/oobtest.c | 2 +-
drivers/mtd/tests/pagetest.c | 2 +-
drivers/mtd/tests/subpagetest.c | 2 +-
fs/crypto/keyring.c | 2 +-
include/linux/prandom.h | 1 +
include/linux/random.h | 7 -------
include/scsi/libfcoe.h | 2 +-
kernel/bpf/core.c | 2 +-
lib/interval_tree_test.c | 2 +-
lib/kunit/string-stream-test.c | 1 +
lib/random32.c | 2 +-
lib/rbtree_test.c | 2 +-
lib/test_bpf.c | 2 +-
lib/test_parman.c | 2 +-
lib/test_scanf.c | 2 +-
net/sched/sch_netem.c | 1 +
22 files changed, 21 insertions(+), 24 deletions(-)
--
2.46.0
^ permalink raw reply [flat|nested] 32+ messages in thread
* [PATCH 01/18] x86/kaslr: Include <linux/prandom.h> instead of <linux/random.h>
2024-09-05 12:17 [PATCH 00/18] random: Include <linux/percpu.h> and resolve circular include dependency Uros Bizjak
@ 2024-09-05 12:17 ` Uros Bizjak
2024-09-05 12:17 ` [PATCH 02/18] drm/i915/selftests: " Uros Bizjak
` (17 subsequent siblings)
18 siblings, 0 replies; 32+ messages in thread
From: Uros Bizjak @ 2024-09-05 12:17 UTC (permalink / raw)
To: linux-kernel
Cc: Uros Bizjak, Dave Hansen, Andy Lutomirski, Peter Zijlstra,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, x86,
H. Peter Anvin
Usage of pseudo-random functions requires inclusion of
<linux/prandom.h> header instead of <linux/random.h>.
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: x86@kernel.org
Cc: "H. Peter Anvin" <hpa@zytor.com>
---
arch/x86/mm/kaslr.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/mm/kaslr.c b/arch/x86/mm/kaslr.c
index 230f1dee4f09..e17e6e27b7ec 100644
--- a/arch/x86/mm/kaslr.c
+++ b/arch/x86/mm/kaslr.c
@@ -22,7 +22,7 @@
#include <linux/kernel.h>
#include <linux/init.h>
-#include <linux/random.h>
+#include <linux/prandom.h>
#include <linux/memblock.h>
#include <linux/pgtable.h>
--
2.46.0
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH 02/18] drm/i915/selftests: Include <linux/prandom.h> instead of <linux/random.h>
2024-09-05 12:17 [PATCH 00/18] random: Include <linux/percpu.h> and resolve circular include dependency Uros Bizjak
2024-09-05 12:17 ` [PATCH 01/18] x86/kaslr: Include <linux/prandom.h> instead of <linux/random.h> Uros Bizjak
@ 2024-09-05 12:17 ` Uros Bizjak
2024-09-05 13:06 ` Jani Nikula
2024-09-05 12:17 ` [PATCH 03/18] drm/lib: " Uros Bizjak
` (16 subsequent siblings)
18 siblings, 1 reply; 32+ messages in thread
From: Uros Bizjak @ 2024-09-05 12:17 UTC (permalink / raw)
To: linux-kernel
Cc: Uros Bizjak, Jani Nikula, Joonas Lahtinen, Rodrigo Vivi,
Tvrtko Ursulin, David Airlie, Daniel Vetter, intel-gfx, dri-devel
Usage of pseudo-random functions requires inclusion of
<linux/prandom.h> header instead of <linux/random.h>.
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: Tvrtko Ursulin <tursulin@ursulin.net>
Cc: David Airlie <airlied@gmail.com>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: intel-gfx@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org
---
drivers/gpu/drm/i915/selftests/i915_gem.c | 2 +-
drivers/gpu/drm/i915/selftests/i915_random.h | 2 +-
drivers/gpu/drm/i915/selftests/scatterlist.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/i915/selftests/i915_gem.c b/drivers/gpu/drm/i915/selftests/i915_gem.c
index 61da4ed9d521..0727492576be 100644
--- a/drivers/gpu/drm/i915/selftests/i915_gem.c
+++ b/drivers/gpu/drm/i915/selftests/i915_gem.c
@@ -4,7 +4,7 @@
* Copyright © 2018 Intel Corporation
*/
-#include <linux/random.h>
+#include <linux/prandom.h>
#include "gem/i915_gem_internal.h"
#include "gem/i915_gem_pm.h"
diff --git a/drivers/gpu/drm/i915/selftests/i915_random.h b/drivers/gpu/drm/i915/selftests/i915_random.h
index 05364eca20f7..70330a2e80f2 100644
--- a/drivers/gpu/drm/i915/selftests/i915_random.h
+++ b/drivers/gpu/drm/i915/selftests/i915_random.h
@@ -26,7 +26,7 @@
#define __I915_SELFTESTS_RANDOM_H__
#include <linux/math64.h>
-#include <linux/random.h>
+#include <linux/prandom.h>
#include "../i915_selftest.h"
diff --git a/drivers/gpu/drm/i915/selftests/scatterlist.c b/drivers/gpu/drm/i915/selftests/scatterlist.c
index 805c4bfb85fe..7e59591bbed6 100644
--- a/drivers/gpu/drm/i915/selftests/scatterlist.c
+++ b/drivers/gpu/drm/i915/selftests/scatterlist.c
@@ -22,7 +22,7 @@
*/
#include <linux/prime_numbers.h>
-#include <linux/random.h>
+#include <linux/prandom.h>
#include "i915_selftest.h"
#include "i915_utils.h"
--
2.46.0
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH 03/18] drm/lib: Include <linux/prandom.h> instead of <linux/random.h>
2024-09-05 12:17 [PATCH 00/18] random: Include <linux/percpu.h> and resolve circular include dependency Uros Bizjak
2024-09-05 12:17 ` [PATCH 01/18] x86/kaslr: Include <linux/prandom.h> instead of <linux/random.h> Uros Bizjak
2024-09-05 12:17 ` [PATCH 02/18] drm/i915/selftests: " Uros Bizjak
@ 2024-09-05 12:17 ` Uros Bizjak
2024-09-05 12:17 ` [PATCH 04/18] media: vivid: Include <linux/prandom.h> in vivid-vid-cap.c Uros Bizjak
` (15 subsequent siblings)
18 siblings, 0 replies; 32+ messages in thread
From: Uros Bizjak @ 2024-09-05 12:17 UTC (permalink / raw)
To: linux-kernel
Cc: Uros Bizjak, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
David Airlie, Daniel Vetter, dri-devel
Usage of pseudo-random functions requires inclusion of
<linux/prandom.h> header instead of <linux/random.h>.
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Maxime Ripard <mripard@kernel.org>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: David Airlie <airlied@gmail.com>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: dri-devel@lists.freedesktop.org
---
drivers/gpu/drm/lib/drm_random.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/lib/drm_random.h b/drivers/gpu/drm/lib/drm_random.h
index 5543bf0474bc..9f827260a89d 100644
--- a/drivers/gpu/drm/lib/drm_random.h
+++ b/drivers/gpu/drm/lib/drm_random.h
@@ -6,7 +6,7 @@
* be transposed to lib/ at the earliest convenience.
*/
-#include <linux/random.h>
+#include <linux/prandom.h>
#define DRM_RND_STATE_INITIALIZER(seed__) ({ \
struct rnd_state state__; \
--
2.46.0
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH 04/18] media: vivid: Include <linux/prandom.h> in vivid-vid-cap.c
2024-09-05 12:17 [PATCH 00/18] random: Include <linux/percpu.h> and resolve circular include dependency Uros Bizjak
` (2 preceding siblings ...)
2024-09-05 12:17 ` [PATCH 03/18] drm/lib: " Uros Bizjak
@ 2024-09-05 12:17 ` Uros Bizjak
2024-09-05 12:17 ` [PATCH 05/18] mtd: tests: Include <linux/prandom.h> instead of <linux/random.h> Uros Bizjak
` (14 subsequent siblings)
18 siblings, 0 replies; 32+ messages in thread
From: Uros Bizjak @ 2024-09-05 12:17 UTC (permalink / raw)
To: linux-kernel
Cc: Uros Bizjak, Hans Verkuil, Mauro Carvalho Chehab, linux-media
Usage of pseudo-random functions requires inclusion of
<linux/prandom.h> header.
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: Hans Verkuil <hverkuil@xs4all.nl>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: linux-media@vger.kernel.org
---
drivers/media/test-drivers/vivid/vivid-vid-cap.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/media/test-drivers/vivid/vivid-vid-cap.c b/drivers/media/test-drivers/vivid/vivid-vid-cap.c
index 69620e0a35a0..184460eb356e 100644
--- a/drivers/media/test-drivers/vivid/vivid-vid-cap.c
+++ b/drivers/media/test-drivers/vivid/vivid-vid-cap.c
@@ -10,6 +10,7 @@
#include <linux/sched.h>
#include <linux/vmalloc.h>
#include <linux/videodev2.h>
+#include <linux/prandom.h>
#include <linux/v4l2-dv-timings.h>
#include <media/v4l2-common.h>
#include <media/v4l2-event.h>
--
2.46.0
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH 05/18] mtd: tests: Include <linux/prandom.h> instead of <linux/random.h>
2024-09-05 12:17 [PATCH 00/18] random: Include <linux/percpu.h> and resolve circular include dependency Uros Bizjak
` (3 preceding siblings ...)
2024-09-05 12:17 ` [PATCH 04/18] media: vivid: Include <linux/prandom.h> in vivid-vid-cap.c Uros Bizjak
@ 2024-09-05 12:17 ` Uros Bizjak
2024-09-06 15:10 ` Miquel Raynal
2024-09-05 12:17 ` [PATCH 06/18] fscrypt: " Uros Bizjak
` (13 subsequent siblings)
18 siblings, 1 reply; 32+ messages in thread
From: Uros Bizjak @ 2024-09-05 12:17 UTC (permalink / raw)
To: linux-kernel
Cc: Uros Bizjak, Miquel Raynal, Richard Weinberger,
Vignesh Raghavendra, linux-mtd
Usage of pseudo-random functions requires inclusion of
<linux/prandom.h> header instead of <linux/random.h>.
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Richard Weinberger <richard@nod.at>
Cc: Vignesh Raghavendra <vigneshr@ti.com>
Cc: linux-mtd@lists.infradead.org
---
drivers/mtd/tests/oobtest.c | 2 +-
drivers/mtd/tests/pagetest.c | 2 +-
drivers/mtd/tests/subpagetest.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/mtd/tests/oobtest.c b/drivers/mtd/tests/oobtest.c
index 13fed398937e..e1ee68f8b8f8 100644
--- a/drivers/mtd/tests/oobtest.c
+++ b/drivers/mtd/tests/oobtest.c
@@ -17,7 +17,7 @@
#include <linux/mtd/mtd.h>
#include <linux/slab.h>
#include <linux/sched.h>
-#include <linux/random.h>
+#include <linux/prandom.h>
#include "mtd_test.h"
diff --git a/drivers/mtd/tests/pagetest.c b/drivers/mtd/tests/pagetest.c
index 8eb40b6e6dfa..6878700d2fc0 100644
--- a/drivers/mtd/tests/pagetest.c
+++ b/drivers/mtd/tests/pagetest.c
@@ -17,7 +17,7 @@
#include <linux/mtd/mtd.h>
#include <linux/slab.h>
#include <linux/sched.h>
-#include <linux/random.h>
+#include <linux/prandom.h>
#include "mtd_test.h"
diff --git a/drivers/mtd/tests/subpagetest.c b/drivers/mtd/tests/subpagetest.c
index 05250a080139..f34bbf033c4d 100644
--- a/drivers/mtd/tests/subpagetest.c
+++ b/drivers/mtd/tests/subpagetest.c
@@ -15,7 +15,7 @@
#include <linux/mtd/mtd.h>
#include <linux/slab.h>
#include <linux/sched.h>
-#include <linux/random.h>
+#include <linux/prandom.h>
#include "mtd_test.h"
--
2.46.0
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH 06/18] fscrypt: Include <linux/prandom.h> instead of <linux/random.h>
2024-09-05 12:17 [PATCH 00/18] random: Include <linux/percpu.h> and resolve circular include dependency Uros Bizjak
` (4 preceding siblings ...)
2024-09-05 12:17 ` [PATCH 05/18] mtd: tests: Include <linux/prandom.h> instead of <linux/random.h> Uros Bizjak
@ 2024-09-05 12:17 ` Uros Bizjak
2024-09-05 23:02 ` Eric Biggers
2024-09-05 12:17 ` [PATCH 07/18] scsi: libfcoe: " Uros Bizjak
` (12 subsequent siblings)
18 siblings, 1 reply; 32+ messages in thread
From: Uros Bizjak @ 2024-09-05 12:17 UTC (permalink / raw)
To: linux-kernel; +Cc: Uros Bizjak, Eric Biggers, Theodore Y. Ts'o, Jaegeuk Kim
Usage of pseudo-random functions requires inclusion of
<linux/prandom.h> header instead of <linux/random.h>.
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: Eric Biggers <ebiggers@kernel.org>
Cc: "Theodore Y. Ts'o" <tytso@mit.edu>
Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Cc. linux-fscrypt@vger.kernel.org
---
fs/crypto/keyring.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/crypto/keyring.c b/fs/crypto/keyring.c
index 6681a71625f0..e2c10b3b960b 100644
--- a/fs/crypto/keyring.c
+++ b/fs/crypto/keyring.c
@@ -21,7 +21,7 @@
#include <asm/unaligned.h>
#include <crypto/skcipher.h>
#include <linux/key-type.h>
-#include <linux/random.h>
+#include <linux/prandom.h>
#include <linux/seq_file.h>
#include "fscrypt_private.h"
--
2.46.0
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH 07/18] scsi: libfcoe: Include <linux/prandom.h> instead of <linux/random.h>
2024-09-05 12:17 [PATCH 00/18] random: Include <linux/percpu.h> and resolve circular include dependency Uros Bizjak
` (5 preceding siblings ...)
2024-09-05 12:17 ` [PATCH 06/18] fscrypt: " Uros Bizjak
@ 2024-09-05 12:17 ` Uros Bizjak
2024-09-05 12:17 ` [PATCH 08/18] bpf: " Uros Bizjak
` (11 subsequent siblings)
18 siblings, 0 replies; 32+ messages in thread
From: Uros Bizjak @ 2024-09-05 12:17 UTC (permalink / raw)
To: linux-kernel
Cc: Uros Bizjak, Hannes Reinecke, James E.J. Bottomley,
Martin K. Petersen, linux-scsi
Usage of pseudo-random functions requires inclusion of
<linux/prandom.h> header instead of <linux/random.h>.
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: Hannes Reinecke <hare@suse.de>
Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org
---
include/scsi/libfcoe.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/scsi/libfcoe.h b/include/scsi/libfcoe.h
index 3c5899290aed..6616348e59b9 100644
--- a/include/scsi/libfcoe.h
+++ b/include/scsi/libfcoe.h
@@ -15,7 +15,7 @@
#include <linux/skbuff.h>
#include <linux/workqueue.h>
#include <linux/local_lock.h>
-#include <linux/random.h>
+#include <linux/prandom.h>
#include <scsi/fc/fc_fcoe.h>
#include <scsi/libfc.h>
#include <scsi/fcoe_sysfs.h>
--
2.46.0
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH 08/18] bpf: Include <linux/prandom.h> instead of <linux/random.h>
2024-09-05 12:17 [PATCH 00/18] random: Include <linux/percpu.h> and resolve circular include dependency Uros Bizjak
` (6 preceding siblings ...)
2024-09-05 12:17 ` [PATCH 07/18] scsi: libfcoe: " Uros Bizjak
@ 2024-09-05 12:17 ` Uros Bizjak
2024-09-05 12:17 ` [PATCH 09/18] lib/interval_tree_test.c: " Uros Bizjak
` (10 subsequent siblings)
18 siblings, 0 replies; 32+ messages in thread
From: Uros Bizjak @ 2024-09-05 12:17 UTC (permalink / raw)
To: linux-kernel
Cc: Uros Bizjak, Alexei Starovoitov, Daniel Borkmann, John Fastabend,
Andrii Nakryiko, Martin KaFai Lau, Eduard Zingerman, Song Liu,
Yonghong Song, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
bpf
Usage of pseudo-random functions requires inclusion of
<linux/prandom.h> header instead of <linux/random.h>.
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: John Fastabend <john.fastabend@gmail.com>
Cc: Andrii Nakryiko <andrii@kernel.org>
Cc: Martin KaFai Lau <martin.lau@linux.dev>
Cc: Eduard Zingerman <eddyz87@gmail.com>
Cc: Song Liu <song@kernel.org>
Cc: Yonghong Song <yonghong.song@linux.dev>
Cc: KP Singh <kpsingh@kernel.org>
Cc: Stanislav Fomichev <sdf@fomichev.me>
Cc: Hao Luo <haoluo@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: bpf@vger.kernel.org
---
kernel/bpf/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
index 7ee62e38faf0..3f0d1eb7f5b0 100644
--- a/kernel/bpf/core.c
+++ b/kernel/bpf/core.c
@@ -21,7 +21,7 @@
#include <linux/filter.h>
#include <linux/skbuff.h>
#include <linux/vmalloc.h>
-#include <linux/random.h>
+#include <linux/prandom.h>
#include <linux/bpf.h>
#include <linux/btf.h>
#include <linux/objtool.h>
--
2.46.0
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH 09/18] lib/interval_tree_test.c: Include <linux/prandom.h> instead of <linux/random.h>
2024-09-05 12:17 [PATCH 00/18] random: Include <linux/percpu.h> and resolve circular include dependency Uros Bizjak
` (7 preceding siblings ...)
2024-09-05 12:17 ` [PATCH 08/18] bpf: " Uros Bizjak
@ 2024-09-05 12:17 ` Uros Bizjak
2024-09-05 12:17 ` [PATCH 10/18] kunit: string-stream-test: " Uros Bizjak
` (9 subsequent siblings)
18 siblings, 0 replies; 32+ messages in thread
From: Uros Bizjak @ 2024-09-05 12:17 UTC (permalink / raw)
To: linux-kernel; +Cc: Uros Bizjak, Andrew Morton
Usage of pseudo-random functions requires inclusion of
<linux/prandom.h> header instead of <linux/random.h>.
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
---
lib/interval_tree_test.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/interval_tree_test.c b/lib/interval_tree_test.c
index f37f4d44faa9..837064b83a6c 100644
--- a/lib/interval_tree_test.c
+++ b/lib/interval_tree_test.c
@@ -2,7 +2,7 @@
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/interval_tree.h>
-#include <linux/random.h>
+#include <linux/prandom.h>
#include <linux/slab.h>
#include <asm/timex.h>
--
2.46.0
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH 10/18] kunit: string-stream-test: Include <linux/prandom.h> instead of <linux/random.h>
2024-09-05 12:17 [PATCH 00/18] random: Include <linux/percpu.h> and resolve circular include dependency Uros Bizjak
` (8 preceding siblings ...)
2024-09-05 12:17 ` [PATCH 09/18] lib/interval_tree_test.c: " Uros Bizjak
@ 2024-09-05 12:17 ` Uros Bizjak
2024-09-05 12:17 ` [PATCH 11/18] random32: " Uros Bizjak
` (8 subsequent siblings)
18 siblings, 0 replies; 32+ messages in thread
From: Uros Bizjak @ 2024-09-05 12:17 UTC (permalink / raw)
To: linux-kernel
Cc: Uros Bizjak, Brendan Higgins, David Gow, Rae Moar,
linux-kselftest, kunit-dev
Usage of pseudo-random functions requires inclusion of
<linux/prandom.h> header instead of <linux/random.h>.
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: Brendan Higgins <brendan.higgins@linux.dev>
Cc: David Gow <davidgow@google.com>
Cc: Rae Moar <rmoar@google.com>
Cc: linux-kselftest@vger.kernel.org
Cc: kunit-dev@googlegroups.com
---
lib/kunit/string-stream-test.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/lib/kunit/string-stream-test.c b/lib/kunit/string-stream-test.c
index 7511442ea98f..7734e33156f9 100644
--- a/lib/kunit/string-stream-test.c
+++ b/lib/kunit/string-stream-test.c
@@ -9,6 +9,7 @@
#include <kunit/static_stub.h>
#include <kunit/test.h>
#include <linux/ktime.h>
+#include <linux/prandom.h>
#include <linux/slab.h>
#include <linux/timekeeping.h>
--
2.46.0
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH 11/18] random32: Include <linux/prandom.h> instead of <linux/random.h>
2024-09-05 12:17 [PATCH 00/18] random: Include <linux/percpu.h> and resolve circular include dependency Uros Bizjak
` (9 preceding siblings ...)
2024-09-05 12:17 ` [PATCH 10/18] kunit: string-stream-test: " Uros Bizjak
@ 2024-09-05 12:17 ` Uros Bizjak
2024-09-05 12:17 ` [PATCH 12/18] lib/rbtree-test: " Uros Bizjak
` (7 subsequent siblings)
18 siblings, 0 replies; 32+ messages in thread
From: Uros Bizjak @ 2024-09-05 12:17 UTC (permalink / raw)
To: linux-kernel
Cc: Uros Bizjak, Andrew Morton, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, netdev
Usage of pseudo-random functions requires inclusion of
<linux/prandom.h> header instead of <linux/random.h>.
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: netdev@vger.kernel.org
---
lib/random32.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/random32.c b/lib/random32.c
index 32060b852668..31fc2ca68856 100644
--- a/lib/random32.c
+++ b/lib/random32.c
@@ -36,7 +36,7 @@
#include <linux/percpu.h>
#include <linux/export.h>
#include <linux/jiffies.h>
-#include <linux/random.h>
+#include <linux/prandom.h>
#include <linux/sched.h>
#include <linux/bitops.h>
#include <linux/slab.h>
--
2.46.0
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH 12/18] lib/rbtree-test: Include <linux/prandom.h> instead of <linux/random.h>
2024-09-05 12:17 [PATCH 00/18] random: Include <linux/percpu.h> and resolve circular include dependency Uros Bizjak
` (10 preceding siblings ...)
2024-09-05 12:17 ` [PATCH 11/18] random32: " Uros Bizjak
@ 2024-09-05 12:17 ` Uros Bizjak
2024-09-05 12:17 ` [PATCH 13/18] bpf/tests: " Uros Bizjak
` (6 subsequent siblings)
18 siblings, 0 replies; 32+ messages in thread
From: Uros Bizjak @ 2024-09-05 12:17 UTC (permalink / raw)
To: linux-kernel; +Cc: Uros Bizjak, Andrew Morton
Usage of pseudo-random functions requires inclusion of
<linux/prandom.h> header instead of <linux/random.h>.
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
---
lib/rbtree_test.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/rbtree_test.c b/lib/rbtree_test.c
index 41ae3c7570d3..8655a76d29a1 100644
--- a/lib/rbtree_test.c
+++ b/lib/rbtree_test.c
@@ -2,7 +2,7 @@
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/rbtree_augmented.h>
-#include <linux/random.h>
+#include <linux/prandom.h>
#include <linux/slab.h>
#include <asm/timex.h>
--
2.46.0
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH 13/18] bpf/tests: Include <linux/prandom.h> instead of <linux/random.h>
2024-09-05 12:17 [PATCH 00/18] random: Include <linux/percpu.h> and resolve circular include dependency Uros Bizjak
` (11 preceding siblings ...)
2024-09-05 12:17 ` [PATCH 12/18] lib/rbtree-test: " Uros Bizjak
@ 2024-09-05 12:17 ` Uros Bizjak
2024-09-05 12:17 ` [PATCH 14/18] lib/test_parman: " Uros Bizjak
` (5 subsequent siblings)
18 siblings, 0 replies; 32+ messages in thread
From: Uros Bizjak @ 2024-09-05 12:17 UTC (permalink / raw)
To: linux-kernel
Cc: Uros Bizjak, Andrew Morton, Alexei Starovoitov, Daniel Borkmann,
Andrii Nakryiko, Martin KaFai Lau, Eduard Zingerman, Song Liu,
Yonghong Song, John Fastabend, KP Singh, Stanislav Fomichev,
Hao Luo, Jiri Olsa, bpf
Usage of pseudo-random functions requires inclusion of
<linux/prandom.h> header instead of <linux/random.h>.
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: Andrii Nakryiko <andrii@kernel.org>
Cc: Martin KaFai Lau <martin.lau@linux.dev>
Cc: Eduard Zingerman <eddyz87@gmail.com>
Cc: Song Liu <song@kernel.org>
Cc: Yonghong Song <yonghong.song@linux.dev>
Cc: John Fastabend <john.fastabend@gmail.com>
Cc: KP Singh <kpsingh@kernel.org>
Cc: Stanislav Fomichev <sdf@fomichev.me>
Cc: Hao Luo <haoluo@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: bpf@vger.kernel.org
---
lib/test_bpf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/test_bpf.c b/lib/test_bpf.c
index ca4b0eea81a2..eb4a1915e4d2 100644
--- a/lib/test_bpf.c
+++ b/lib/test_bpf.c
@@ -14,7 +14,7 @@
#include <linux/skbuff.h>
#include <linux/netdevice.h>
#include <linux/if_vlan.h>
-#include <linux/random.h>
+#include <linux/prandom.h>
#include <linux/highmem.h>
#include <linux/sched.h>
--
2.46.0
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH 14/18] lib/test_parman: Include <linux/prandom.h> instead of <linux/random.h>
2024-09-05 12:17 [PATCH 00/18] random: Include <linux/percpu.h> and resolve circular include dependency Uros Bizjak
` (12 preceding siblings ...)
2024-09-05 12:17 ` [PATCH 13/18] bpf/tests: " Uros Bizjak
@ 2024-09-05 12:17 ` Uros Bizjak
2024-09-05 12:17 ` [PATCH 15/18] lib/test_scanf: " Uros Bizjak
` (4 subsequent siblings)
18 siblings, 0 replies; 32+ messages in thread
From: Uros Bizjak @ 2024-09-05 12:17 UTC (permalink / raw)
To: linux-kernel; +Cc: Uros Bizjak, Andrew Morton, Jiri Pirko, netdev
Usage of pseudo-random functions requires inclusion of
<linux/prandom.h> header instead of <linux/random.h>.
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Jiri Pirko <jiri@resnulli.us>
Cc: netdev@vger.kernel.org
---
lib/test_parman.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/test_parman.c b/lib/test_parman.c
index 35e32243693c..f9b97426a337 100644
--- a/lib/test_parman.c
+++ b/lib/test_parman.c
@@ -39,7 +39,7 @@
#include <linux/slab.h>
#include <linux/bitops.h>
#include <linux/err.h>
-#include <linux/random.h>
+#include <linux/prandom.h>
#include <linux/parman.h>
#define TEST_PARMAN_PRIO_SHIFT 7 /* defines number of prios for testing */
--
2.46.0
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH 15/18] lib/test_scanf: Include <linux/prandom.h> instead of <linux/random.h>
2024-09-05 12:17 [PATCH 00/18] random: Include <linux/percpu.h> and resolve circular include dependency Uros Bizjak
` (13 preceding siblings ...)
2024-09-05 12:17 ` [PATCH 14/18] lib/test_parman: " Uros Bizjak
@ 2024-09-05 12:17 ` Uros Bizjak
2024-09-09 12:54 ` Petr Mladek
2024-09-05 12:17 ` [PATCH 16/18] netem: Include <linux/prandom.h> in sch_netem.c Uros Bizjak
` (3 subsequent siblings)
18 siblings, 1 reply; 32+ messages in thread
From: Uros Bizjak @ 2024-09-05 12:17 UTC (permalink / raw)
To: linux-kernel
Cc: Uros Bizjak, Petr Mladek, Steven Rostedt, Andy Shevchenko,
Rasmus Villemoes, Sergey Senozhatsky, Andrew Morton
Usage of pseudo-random functions requires inclusion of
<linux/prandom.h> header instead of <linux/random.h>.
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: Petr Mladek <pmladek@suse.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
---
lib/test_scanf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/test_scanf.c b/lib/test_scanf.c
index 7257b1768545..44f8508c9d88 100644
--- a/lib/test_scanf.c
+++ b/lib/test_scanf.c
@@ -11,7 +11,7 @@
#include <linux/module.h>
#include <linux/overflow.h>
#include <linux/printk.h>
-#include <linux/random.h>
+#include <linux/prandom.h>
#include <linux/slab.h>
#include <linux/string.h>
--
2.46.0
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH 16/18] netem: Include <linux/prandom.h> in sch_netem.c
2024-09-05 12:17 [PATCH 00/18] random: Include <linux/percpu.h> and resolve circular include dependency Uros Bizjak
` (14 preceding siblings ...)
2024-09-05 12:17 ` [PATCH 15/18] lib/test_scanf: " Uros Bizjak
@ 2024-09-05 12:17 ` Uros Bizjak
2024-09-05 12:17 ` [PATCH 17/18] random: Do not include <linux/prandom.h> Uros Bizjak
` (2 subsequent siblings)
18 siblings, 0 replies; 32+ messages in thread
From: Uros Bizjak @ 2024-09-05 12:17 UTC (permalink / raw)
To: linux-kernel
Cc: Uros Bizjak, Stephen Hemminger, Jamal Hadi Salim, Cong Wang,
Jiri Pirko, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, netdev
Usage of pseudo-random functions requires inclusion of
<linux/prandom.h> header.
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: Stephen Hemminger <stephen@networkplumber.org>
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Cc: Cong Wang <xiyou.wangcong@gmail.com>
Cc: Jiri Pirko <jiri@resnulli.us>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: netdev@vger.kernel.org
---
net/sched/sch_netem.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c
index 0f8d581438c3..2d919f590772 100644
--- a/net/sched/sch_netem.c
+++ b/net/sched/sch_netem.c
@@ -17,6 +17,7 @@
#include <linux/errno.h>
#include <linux/skbuff.h>
#include <linux/vmalloc.h>
+#include <linux/prandom.h>
#include <linux/rtnetlink.h>
#include <linux/reciprocal_div.h>
#include <linux/rbtree.h>
--
2.46.0
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH 17/18] random: Do not include <linux/prandom.h>
2024-09-05 12:17 [PATCH 00/18] random: Include <linux/percpu.h> and resolve circular include dependency Uros Bizjak
` (15 preceding siblings ...)
2024-09-05 12:17 ` [PATCH 16/18] netem: Include <linux/prandom.h> in sch_netem.c Uros Bizjak
@ 2024-09-05 12:17 ` Uros Bizjak
2024-09-06 13:30 ` kernel test robot
2024-09-06 14:21 ` kernel test robot
2024-09-05 12:17 ` [PATCH 18/18] prandom: Include <linux/percpu.h> Uros Bizjak
2024-09-05 12:40 ` [PATCH 00/18] random: Include <linux/percpu.h> and resolve circular include dependency Andy Shevchenko
18 siblings, 2 replies; 32+ messages in thread
From: Uros Bizjak @ 2024-09-05 12:17 UTC (permalink / raw)
To: linux-kernel
Cc: Uros Bizjak, Theodore Ts'o, Jason A. Donenfeld,
Linus Torvalds
Files that use prandom infrastructure are now converted to use
<linux/prandom.h> header instead of <linux/random.h>,
so remove inclusion of <linux/prandom.h> from random.h
This is the "nice cleanup" part, wished in c0842fbc1b18.
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Fixes: c0842fbc1b18 ("random32: move the pseudo-random 32-bit definitions to prandom.h")
Cc: "Theodore Ts'o" <tytso@mit.edu>
Cc: "Jason A. Donenfeld" <Jason@zx2c4.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
---
include/linux/random.h | 7 -------
1 file changed, 7 deletions(-)
diff --git a/include/linux/random.h b/include/linux/random.h
index b0a940af4fff..333cecfca93f 100644
--- a/include/linux/random.h
+++ b/include/linux/random.h
@@ -145,13 +145,6 @@ declare_get_random_var_wait(u64, u32)
declare_get_random_var_wait(long, unsigned long)
#undef declare_get_random_var
-/*
- * This is designed to be standalone for just prandom
- * users, but for now we include it from <linux/random.h>
- * for legacy reasons.
- */
-#include <linux/prandom.h>
-
#ifdef CONFIG_SMP
int random_prepare_cpu(unsigned int cpu);
int random_online_cpu(unsigned int cpu);
--
2.46.0
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH 18/18] prandom: Include <linux/percpu.h>
2024-09-05 12:17 [PATCH 00/18] random: Include <linux/percpu.h> and resolve circular include dependency Uros Bizjak
` (16 preceding siblings ...)
2024-09-05 12:17 ` [PATCH 17/18] random: Do not include <linux/prandom.h> Uros Bizjak
@ 2024-09-05 12:17 ` Uros Bizjak
2024-09-05 12:40 ` [PATCH 00/18] random: Include <linux/percpu.h> and resolve circular include dependency Andy Shevchenko
18 siblings, 0 replies; 32+ messages in thread
From: Uros Bizjak @ 2024-09-05 12:17 UTC (permalink / raw)
To: linux-kernel
Cc: Uros Bizjak, Theodore Ts'o, Jason A. Donenfeld,
Kent Overstreet
<linux/percpu.h> include was removed in d9f29deb7fe8 ("prandom:
Remove unused include") from prandom.h because this inclusion
broke arm64 due to a circular dependency on include files. Previous
patches resolved this issue.
__percpu tag is currently defined in include/linux/compiler_types.h,
so there is no direct need for the inclusion of <linux/percpu.h>.
However, in [1] we would like to repurpose __percpu tag as a named
address space qualifier, where __percpu macro uses defines from
<linux/percpu.h>.
This patch is basically a full revert of d9f29deb7fe8
("prandom: Remove unused include").
[1] https://lore.kernel.org/lkml/20240812115945.484051-4-ubizjak@gmail.com/
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: "Theodore Ts'o" <tytso@mit.edu>
Cc: "Jason A. Donenfeld" <Jason@zx2c4.com>
Cc: Kent Overstreet <kent.overstreet@linux.dev>
---
include/linux/prandom.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/include/linux/prandom.h b/include/linux/prandom.h
index f7f1e5251c67..f2ed5b72b3d6 100644
--- a/include/linux/prandom.h
+++ b/include/linux/prandom.h
@@ -10,6 +10,7 @@
#include <linux/types.h>
#include <linux/once.h>
+#include <linux/percpu.h>
#include <linux/random.h>
struct rnd_state {
--
2.46.0
^ permalink raw reply related [flat|nested] 32+ messages in thread
* Re: [PATCH 00/18] random: Include <linux/percpu.h> and resolve circular include dependency
2024-09-05 12:17 [PATCH 00/18] random: Include <linux/percpu.h> and resolve circular include dependency Uros Bizjak
` (17 preceding siblings ...)
2024-09-05 12:17 ` [PATCH 18/18] prandom: Include <linux/percpu.h> Uros Bizjak
@ 2024-09-05 12:40 ` Andy Shevchenko
2024-09-05 13:03 ` Uros Bizjak
18 siblings, 1 reply; 32+ messages in thread
From: Andy Shevchenko @ 2024-09-05 12:40 UTC (permalink / raw)
To: Uros Bizjak
Cc: linux-kernel, Dave Hansen, Andy Lutomirski, Peter Zijlstra,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, x86,
H. Peter Anvin, Jani Nikula, Joonas Lahtinen, Rodrigo Vivi,
Tvrtko Ursulin, David Airlie, Daniel Vetter, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, Hans Verkuil,
Mauro Carvalho Chehab, Miquel Raynal, Richard Weinberger,
Vignesh Raghavendra, Eric Biggers, Theodore Y. Ts'o,
Jaegeuk Kim, Jason A. Donenfeld, Linus Torvalds, Hannes Reinecke,
James E.J. Bottomley, Martin K. Petersen, Alexei Starovoitov,
Daniel Borkmann, John Fastabend, Andrii Nakryiko,
Martin KaFai Lau, Eduard Zingerman, Song Liu, Yonghong Song,
KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa, Andrew Morton,
Brendan Higgins, David Gow, Rae Moar, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Jiri Pirko,
Petr Mladek, Steven Rostedt, Rasmus Villemoes, Sergey Senozhatsky,
Stephen Hemminger, Jamal Hadi Salim, Cong Wang, Kent Overstreet,
intel-gfx, dri-devel, linux-media, linux-mtd, linux-fscrypt,
linux-scsi, bpf, linux-kselftest, kunit-dev
On Thu, Sep 05, 2024 at 02:17:08PM +0200, Uros Bizjak wrote:
> There were several attempts to resolve circular include dependency
> after the addition of percpu.h: 1c9df907da83 ("random: fix circular
> include dependency on arm64 after addition of percpu.h"), c0842fbc1b18
> ("random32: move the pseudo-random 32-bit definitions to prandom.h") and
> finally d9f29deb7fe8 ("prandom: Remove unused include") that completely
> removes inclusion of <linux/percpu.h>.
>
> Due to legacy reasons, <linux/random.h> includes <linux/prandom.h>, but
> with the commit entry remark:
>
> --quote--
> A further cleanup step would be to remove this from <linux/random.h>
> entirely, and make people who use the prandom infrastructure include
> just the new header file. That's a bit of a churn patch, but grepping
> for "prandom_" and "next_pseudo_random32" "struct rnd_state" should
> catch most users.
>
> But it turns out that that nice cleanup step is fairly painful, because
> a _lot_ of code currently seems to depend on the implicit include of
> <linux/random.h>, which can currently come in a lot of ways, including
> such fairly core headfers as <linux/net.h>.
>
> So the "nice cleanup" part may or may never happen.
> --/quote--
>
> __percpu tag is currently defined in include/linux/compiler_types.h,
> so there is no direct need for the inclusion of <linux/percpu.h>.
> However, in [1] we would like to repurpose __percpu tag as a named
> address space qualifier, where __percpu macro uses defines from
> <linux/percpu.h>.
>
> This patch series is the "nice cleanup" part, and allows us to finally
> include <linux/percpu.h> in prandom.h.
>
> The whole series was tested by compiling the kernel for x86_64 allconfig
> and some popular architectures, namely arm64 defconfig, powerpc defconfig
> and loongarch defconfig.
Obvious question(s) is(are):
1) have you seen the Ingo's gigantic patch series towards resolving issues with
the headers?
2) if not, please look at the preliminary work and take something from there, I
believe there are many useful changes already waiting for a couple of years to
be applied.
Because I haven't found any references nor mentions of that in the cover letter
here and explanation why it was not taking into consideration.
> [1] https://lore.kernel.org/lkml/20240812115945.484051-4-ubizjak@gmail.com/
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH 00/18] random: Include <linux/percpu.h> and resolve circular include dependency
2024-09-05 12:40 ` [PATCH 00/18] random: Include <linux/percpu.h> and resolve circular include dependency Andy Shevchenko
@ 2024-09-05 13:03 ` Uros Bizjak
2024-09-05 15:36 ` Andy Shevchenko
0 siblings, 1 reply; 32+ messages in thread
From: Uros Bizjak @ 2024-09-05 13:03 UTC (permalink / raw)
To: Andy Shevchenko
Cc: linux-kernel, Dave Hansen, Andy Lutomirski, Peter Zijlstra,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, x86,
H. Peter Anvin, Jani Nikula, Joonas Lahtinen, Rodrigo Vivi,
Tvrtko Ursulin, David Airlie, Daniel Vetter, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, Hans Verkuil,
Mauro Carvalho Chehab, Miquel Raynal, Richard Weinberger,
Vignesh Raghavendra, Eric Biggers, Theodore Y. Ts'o,
Jaegeuk Kim, Jason A. Donenfeld, Linus Torvalds, Hannes Reinecke,
James E.J. Bottomley, Martin K. Petersen, Alexei Starovoitov,
Daniel Borkmann, John Fastabend, Andrii Nakryiko,
Martin KaFai Lau, Eduard Zingerman, Song Liu, Yonghong Song,
KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa, Andrew Morton,
Brendan Higgins, David Gow, Rae Moar, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Jiri Pirko,
Petr Mladek, Steven Rostedt, Rasmus Villemoes, Sergey Senozhatsky,
Stephen Hemminger, Jamal Hadi Salim, Cong Wang, Kent Overstreet,
intel-gfx, dri-devel, linux-media, linux-mtd, linux-fscrypt,
linux-scsi, bpf, linux-kselftest, kunit-dev
On Thu, Sep 5, 2024 at 2:41 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> On Thu, Sep 05, 2024 at 02:17:08PM +0200, Uros Bizjak wrote:
> > There were several attempts to resolve circular include dependency
> > after the addition of percpu.h: 1c9df907da83 ("random: fix circular
> > include dependency on arm64 after addition of percpu.h"), c0842fbc1b18
> > ("random32: move the pseudo-random 32-bit definitions to prandom.h") and
> > finally d9f29deb7fe8 ("prandom: Remove unused include") that completely
> > removes inclusion of <linux/percpu.h>.
> >
> > Due to legacy reasons, <linux/random.h> includes <linux/prandom.h>, but
> > with the commit entry remark:
> >
> > --quote--
> > A further cleanup step would be to remove this from <linux/random.h>
> > entirely, and make people who use the prandom infrastructure include
> > just the new header file. That's a bit of a churn patch, but grepping
> > for "prandom_" and "next_pseudo_random32" "struct rnd_state" should
> > catch most users.
> >
> > But it turns out that that nice cleanup step is fairly painful, because
> > a _lot_ of code currently seems to depend on the implicit include of
> > <linux/random.h>, which can currently come in a lot of ways, including
> > such fairly core headfers as <linux/net.h>.
> >
> > So the "nice cleanup" part may or may never happen.
> > --/quote--
> >
> > __percpu tag is currently defined in include/linux/compiler_types.h,
> > so there is no direct need for the inclusion of <linux/percpu.h>.
> > However, in [1] we would like to repurpose __percpu tag as a named
> > address space qualifier, where __percpu macro uses defines from
> > <linux/percpu.h>.
> >
> > This patch series is the "nice cleanup" part, and allows us to finally
> > include <linux/percpu.h> in prandom.h.
> >
> > The whole series was tested by compiling the kernel for x86_64 allconfig
> > and some popular architectures, namely arm64 defconfig, powerpc defconfig
> > and loongarch defconfig.
>
> Obvious question(s) is(are):
> 1) have you seen the Ingo's gigantic patch series towards resolving issues with
> the headers?
> 2) if not, please look at the preliminary work and take something from there, I
> believe there are many useful changes already waiting for a couple of years to
> be applied.
>
> Because I haven't found any references nor mentions of that in the cover letter
> here and explanation why it was not taking into consideration.
I am aware of the series, but the patch takes only a small bite of it
and specifically resolves the inclusion of <linux/prandom.h> from
linux/random.h. The series fixes the missing inclusion of
<linux/prandom.h> in files that use pseudo-random function and it was
not meant to be a general header cleanup. The end goal is to allow us
to include <linux/percpu.h> in linux/prandom.h - which uses __percpu
tag without the correct include.
Thus, the patch series is only tangentially connected to Ingo's patch series.
Best regards,
Uros.
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH 02/18] drm/i915/selftests: Include <linux/prandom.h> instead of <linux/random.h>
2024-09-05 12:17 ` [PATCH 02/18] drm/i915/selftests: " Uros Bizjak
@ 2024-09-05 13:06 ` Jani Nikula
0 siblings, 0 replies; 32+ messages in thread
From: Jani Nikula @ 2024-09-05 13:06 UTC (permalink / raw)
To: Uros Bizjak, linux-kernel
Cc: Uros Bizjak, Joonas Lahtinen, Rodrigo Vivi, Tvrtko Ursulin,
David Airlie, Daniel Vetter, intel-gfx, dri-devel
On Thu, 05 Sep 2024, Uros Bizjak <ubizjak@gmail.com> wrote:
> Usage of pseudo-random functions requires inclusion of
> <linux/prandom.h> header instead of <linux/random.h>.
>
> Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
> Cc: Jani Nikula <jani.nikula@linux.intel.com>
> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
> Cc: Tvrtko Ursulin <tursulin@ursulin.net>
> Cc: David Airlie <airlied@gmail.com>
> Cc: Daniel Vetter <daniel@ffwll.ch>
> Cc: intel-gfx@lists.freedesktop.org
> Cc: dri-devel@lists.freedesktop.org
LGTM,
Acked-by: Jani Nikula <jani.nikula@intel.com>
for merging via whichever tree suits you best.
> ---
> drivers/gpu/drm/i915/selftests/i915_gem.c | 2 +-
> drivers/gpu/drm/i915/selftests/i915_random.h | 2 +-
> drivers/gpu/drm/i915/selftests/scatterlist.c | 2 +-
> 3 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/selftests/i915_gem.c b/drivers/gpu/drm/i915/selftests/i915_gem.c
> index 61da4ed9d521..0727492576be 100644
> --- a/drivers/gpu/drm/i915/selftests/i915_gem.c
> +++ b/drivers/gpu/drm/i915/selftests/i915_gem.c
> @@ -4,7 +4,7 @@
> * Copyright © 2018 Intel Corporation
> */
>
> -#include <linux/random.h>
> +#include <linux/prandom.h>
>
> #include "gem/i915_gem_internal.h"
> #include "gem/i915_gem_pm.h"
> diff --git a/drivers/gpu/drm/i915/selftests/i915_random.h b/drivers/gpu/drm/i915/selftests/i915_random.h
> index 05364eca20f7..70330a2e80f2 100644
> --- a/drivers/gpu/drm/i915/selftests/i915_random.h
> +++ b/drivers/gpu/drm/i915/selftests/i915_random.h
> @@ -26,7 +26,7 @@
> #define __I915_SELFTESTS_RANDOM_H__
>
> #include <linux/math64.h>
> -#include <linux/random.h>
> +#include <linux/prandom.h>
>
> #include "../i915_selftest.h"
>
> diff --git a/drivers/gpu/drm/i915/selftests/scatterlist.c b/drivers/gpu/drm/i915/selftests/scatterlist.c
> index 805c4bfb85fe..7e59591bbed6 100644
> --- a/drivers/gpu/drm/i915/selftests/scatterlist.c
> +++ b/drivers/gpu/drm/i915/selftests/scatterlist.c
> @@ -22,7 +22,7 @@
> */
>
> #include <linux/prime_numbers.h>
> -#include <linux/random.h>
> +#include <linux/prandom.h>
>
> #include "i915_selftest.h"
> #include "i915_utils.h"
--
Jani Nikula, Intel
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH 00/18] random: Include <linux/percpu.h> and resolve circular include dependency
2024-09-05 13:03 ` Uros Bizjak
@ 2024-09-05 15:36 ` Andy Shevchenko
0 siblings, 0 replies; 32+ messages in thread
From: Andy Shevchenko @ 2024-09-05 15:36 UTC (permalink / raw)
To: Uros Bizjak
Cc: linux-kernel, Dave Hansen, Andy Lutomirski, Peter Zijlstra,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, x86,
H. Peter Anvin, Jani Nikula, Joonas Lahtinen, Rodrigo Vivi,
Tvrtko Ursulin, David Airlie, Daniel Vetter, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, Hans Verkuil,
Mauro Carvalho Chehab, Miquel Raynal, Richard Weinberger,
Vignesh Raghavendra, Eric Biggers, Theodore Y. Ts'o,
Jaegeuk Kim, Jason A. Donenfeld, Linus Torvalds, Hannes Reinecke,
James E.J. Bottomley, Martin K. Petersen, Alexei Starovoitov,
Daniel Borkmann, John Fastabend, Andrii Nakryiko,
Martin KaFai Lau, Eduard Zingerman, Song Liu, Yonghong Song,
KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa, Andrew Morton,
Brendan Higgins, David Gow, Rae Moar, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Jiri Pirko,
Petr Mladek, Steven Rostedt, Rasmus Villemoes, Sergey Senozhatsky,
Stephen Hemminger, Jamal Hadi Salim, Cong Wang, Kent Overstreet,
intel-gfx, dri-devel, linux-media, linux-mtd, linux-fscrypt,
linux-scsi, bpf, linux-kselftest, kunit-dev
On Thu, Sep 05, 2024 at 03:03:24PM +0200, Uros Bizjak wrote:
> On Thu, Sep 5, 2024 at 2:41 PM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> >
> > On Thu, Sep 05, 2024 at 02:17:08PM +0200, Uros Bizjak wrote:
> > > There were several attempts to resolve circular include dependency
> > > after the addition of percpu.h: 1c9df907da83 ("random: fix circular
> > > include dependency on arm64 after addition of percpu.h"), c0842fbc1b18
> > > ("random32: move the pseudo-random 32-bit definitions to prandom.h") and
> > > finally d9f29deb7fe8 ("prandom: Remove unused include") that completely
> > > removes inclusion of <linux/percpu.h>.
> > >
> > > Due to legacy reasons, <linux/random.h> includes <linux/prandom.h>, but
> > > with the commit entry remark:
> > >
> > > --quote--
> > > A further cleanup step would be to remove this from <linux/random.h>
> > > entirely, and make people who use the prandom infrastructure include
> > > just the new header file. That's a bit of a churn patch, but grepping
> > > for "prandom_" and "next_pseudo_random32" "struct rnd_state" should
> > > catch most users.
> > >
> > > But it turns out that that nice cleanup step is fairly painful, because
> > > a _lot_ of code currently seems to depend on the implicit include of
> > > <linux/random.h>, which can currently come in a lot of ways, including
> > > such fairly core headfers as <linux/net.h>.
> > >
> > > So the "nice cleanup" part may or may never happen.
> > > --/quote--
> > >
> > > __percpu tag is currently defined in include/linux/compiler_types.h,
> > > so there is no direct need for the inclusion of <linux/percpu.h>.
> > > However, in [1] we would like to repurpose __percpu tag as a named
> > > address space qualifier, where __percpu macro uses defines from
> > > <linux/percpu.h>.
> > >
> > > This patch series is the "nice cleanup" part, and allows us to finally
> > > include <linux/percpu.h> in prandom.h.
> > >
> > > The whole series was tested by compiling the kernel for x86_64 allconfig
> > > and some popular architectures, namely arm64 defconfig, powerpc defconfig
> > > and loongarch defconfig.
> >
> > Obvious question(s) is(are):
> > 1) have you seen the Ingo's gigantic patch series towards resolving issues with
> > the headers?
> > 2) if not, please look at the preliminary work and take something from there, I
> > believe there are many useful changes already waiting for a couple of years to
> > be applied.
> >
> > Because I haven't found any references nor mentions of that in the cover letter
> > here and explanation why it was not taking into consideration.
>
> I am aware of the series, but the patch takes only a small bite of it
> and specifically resolves the inclusion of <linux/prandom.h> from
> linux/random.h. The series fixes the missing inclusion of
> <linux/prandom.h> in files that use pseudo-random function and it was
> not meant to be a general header cleanup. The end goal is to allow us
> to include <linux/percpu.h> in linux/prandom.h - which uses __percpu
> tag without the correct include.
Thank you for elaboration, it's all clear now.
> Thus, the patch series is only tangentially connected to Ingo's patch series.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH 06/18] fscrypt: Include <linux/prandom.h> instead of <linux/random.h>
2024-09-05 12:17 ` [PATCH 06/18] fscrypt: " Uros Bizjak
@ 2024-09-05 23:02 ` Eric Biggers
2024-09-06 8:09 ` Uros Bizjak
0 siblings, 1 reply; 32+ messages in thread
From: Eric Biggers @ 2024-09-05 23:02 UTC (permalink / raw)
To: Uros Bizjak
Cc: linux-kernel, Theodore Y. Ts'o, Jaegeuk Kim, linux-fscrypt
On Thu, Sep 05, 2024 at 02:17:14PM +0200, Uros Bizjak wrote:
> Usage of pseudo-random functions requires inclusion of
> <linux/prandom.h> header instead of <linux/random.h>.
>
> Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
> Cc: Eric Biggers <ebiggers@kernel.org>
> Cc: "Theodore Y. Ts'o" <tytso@mit.edu>
> Cc: Jaegeuk Kim <jaegeuk@kernel.org>
> Cc. linux-fscrypt@vger.kernel.org
> ---
> fs/crypto/keyring.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/crypto/keyring.c b/fs/crypto/keyring.c
> index 6681a71625f0..e2c10b3b960b 100644
> --- a/fs/crypto/keyring.c
> +++ b/fs/crypto/keyring.c
> @@ -21,7 +21,7 @@
> #include <asm/unaligned.h>
> #include <crypto/skcipher.h>
> #include <linux/key-type.h>
> -#include <linux/random.h>
> +#include <linux/prandom.h>
> #include <linux/seq_file.h>
>
1. linux-fscrypt wasn't actually Cc'ed on this patch, due to the typo of
"Cc." instead of "Cc:".
2. Currently <linux/random.h> includes <linux/prandom.h>, so the issue described
in the commit message does not exist. I assume this in changing in a later
patch that was not sent to me. The commit message should be rephrased to
clarify that this change is needed because of header refactoring, as
otherwise it sounds like a bug fix.
3. The proposed change does not make sense, because fs/crypto/keyring.c does not
use any "pseudo-random functions". It does use get_random_once(), which is
defined in <linux/once.h>. Currently <linux/random.h> includes
<linux/prandom.h> which includes <linux/once.h>. If the inclusion of
prandom.h by random.h is going away, then perhaps random.h should include
once.h directly so that get_random_once() continues to work? If not, then
this file should include once.h. Either way it should not include prandom.h.
- Eric
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH 06/18] fscrypt: Include <linux/prandom.h> instead of <linux/random.h>
2024-09-05 23:02 ` Eric Biggers
@ 2024-09-06 8:09 ` Uros Bizjak
0 siblings, 0 replies; 32+ messages in thread
From: Uros Bizjak @ 2024-09-06 8:09 UTC (permalink / raw)
To: Eric Biggers
Cc: linux-kernel, Theodore Y. Ts'o, Jaegeuk Kim, linux-fscrypt
On Fri, Sep 6, 2024 at 1:02 AM Eric Biggers <ebiggers@kernel.org> wrote:
>
> On Thu, Sep 05, 2024 at 02:17:14PM +0200, Uros Bizjak wrote:
> > Usage of pseudo-random functions requires inclusion of
> > <linux/prandom.h> header instead of <linux/random.h>.
> >
> > Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
> > Cc: Eric Biggers <ebiggers@kernel.org>
> > Cc: "Theodore Y. Ts'o" <tytso@mit.edu>
> > Cc: Jaegeuk Kim <jaegeuk@kernel.org>
> > Cc. linux-fscrypt@vger.kernel.org
> > ---
> > fs/crypto/keyring.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/fs/crypto/keyring.c b/fs/crypto/keyring.c
> > index 6681a71625f0..e2c10b3b960b 100644
> > --- a/fs/crypto/keyring.c
> > +++ b/fs/crypto/keyring.c
> > @@ -21,7 +21,7 @@
> > #include <asm/unaligned.h>
> > #include <crypto/skcipher.h>
> > #include <linux/key-type.h>
> > -#include <linux/random.h>
> > +#include <linux/prandom.h>
> > #include <linux/seq_file.h>
> >
>
> 1. linux-fscrypt wasn't actually Cc'ed on this patch, due to the typo of
> "Cc." instead of "Cc:".
Uh, thanks for noticing.
> 2. Currently <linux/random.h> includes <linux/prandom.h>, so the issue described
> in the commit message does not exist. I assume this in changing in a later
> patch that was not sent to me. The commit message should be rephrased to
> clarify that this change is needed because of header refactoring, as
> otherwise it sounds like a bug fix.
Yes, the goal of the patch series is to allow inclusion of
<linux/percpu.h> in linux/prandom.h. The major roadblock to achieve
this is the inclusion of <linux/prandom.h> in linux/random.h, since
this creates circular dependency which doesn't allow the inclusion of
<linux/percpu.h>. Please note that this legacy include is removed in
patch 17. I will mention this in the 0000 commit.
I will also mention header refactoring in individual commits.
OTOH, I think that while particular maintainers are CC'd only on their
individual patches, it is better to send the whole series to all
mentioned mailing lists. Will do that in v2.
> 3. The proposed change does not make sense, because fs/crypto/keyring.c does not
> use any "pseudo-random functions". It does use get_random_once(), which is
> defined in <linux/once.h>. Currently <linux/random.h> includes
> <linux/prandom.h> which includes <linux/once.h>. If the inclusion of
> prandom.h by random.h is going away, then perhaps random.h should include
> once.h directly so that get_random_once() continues to work? If not, then
> this file should include once.h. Either way it should not include prandom.h.
Due to the tricky nature of the whole series I tried to make
individual patches as mechanical as possible, IOW, change the
inclusion of <linux/random.h> to <linux/prandom.h>.
Looking at fs/crypto/keyring.c, it should still include
<linux/random.h> but should also include <linux/once.h>. The latter
was just accidentally included via <linux/random.h>/<linux/prandom.h>
path which is going away.
Will fix in v2.
Thanks,
Uros.
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH 17/18] random: Do not include <linux/prandom.h>
2024-09-05 12:17 ` [PATCH 17/18] random: Do not include <linux/prandom.h> Uros Bizjak
@ 2024-09-06 13:30 ` kernel test robot
2024-09-06 14:21 ` kernel test robot
1 sibling, 0 replies; 32+ messages in thread
From: kernel test robot @ 2024-09-06 13:30 UTC (permalink / raw)
To: Uros Bizjak, linux-kernel
Cc: oe-kbuild-all, Uros Bizjak, Theodore Ts'o, Jason A. Donenfeld
Hi Uros,
kernel test robot noticed the following build errors:
[auto build test ERROR on akpm-mm/mm-nonmm-unstable]
[also build test ERROR on mtd/mtd/next mtd/mtd/fixes linus/master v6.11-rc6 next-20240906]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Uros-Bizjak/x86-kaslr-Include-linux-prandom-h-instead-of-linux-random-h/20240905-202710
base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-nonmm-unstable
patch link: https://lore.kernel.org/r/20240905122020.872466-18-ubizjak%40gmail.com
patch subject: [PATCH 17/18] random: Do not include <linux/prandom.h>
config: arm-randconfig-002-20240906 (https://download.01.org/0day-ci/archive/20240906/202409062005.ue7L87dN-lkp@intel.com/config)
compiler: arm-linux-gnueabi-gcc (GCC) 14.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240906/202409062005.ue7L87dN-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202409062005.ue7L87dN-lkp@intel.com/
All error/warnings (new ones prefixed by >>):
>> crypto/testmgr.c:881:42: warning: 'struct rnd_state' declared inside parameter list will not be visible outside of this definition or declaration
881 | static inline void init_rnd_state(struct rnd_state *rng)
| ^~~~~~~~~
crypto/testmgr.c: In function 'init_rnd_state':
>> crypto/testmgr.c:883:9: error: implicit declaration of function 'prandom_seed_state' [-Wimplicit-function-declaration]
883 | prandom_seed_state(rng, get_random_u64());
| ^~~~~~~~~~~~~~~~~~
crypto/testmgr.c: At top level:
crypto/testmgr.c:886:36: warning: 'struct rnd_state' declared inside parameter list will not be visible outside of this definition or declaration
886 | static inline u8 prandom_u8(struct rnd_state *rng)
| ^~~~~~~~~
crypto/testmgr.c: In function 'prandom_u8':
>> crypto/testmgr.c:888:16: error: implicit declaration of function 'prandom_u32_state' [-Wimplicit-function-declaration]
888 | return prandom_u32_state(rng);
| ^~~~~~~~~~~~~~~~~
crypto/testmgr.c: At top level:
crypto/testmgr.c:891:44: warning: 'struct rnd_state' declared inside parameter list will not be visible outside of this definition or declaration
891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
| ^~~~~~~~~
crypto/testmgr.c:900:40: warning: 'struct rnd_state' declared inside parameter list will not be visible outside of this definition or declaration
900 | static inline bool prandom_bool(struct rnd_state *rng)
| ^~~~~~~~~
crypto/testmgr.c: In function 'prandom_bool':
>> crypto/testmgr.c:902:34: error: passing argument 1 of 'prandom_u32_below' from incompatible pointer type [-Wincompatible-pointer-types]
902 | return prandom_u32_below(rng, 2);
| ^~~
| |
| struct rnd_state *
crypto/testmgr.c:891:55: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
| ~~~~~~~~~~~~~~~~~~^~~
crypto/testmgr.c: At top level:
crypto/testmgr.c:905:48: warning: 'struct rnd_state' declared inside parameter list will not be visible outside of this definition or declaration
905 | static inline u32 prandom_u32_inclusive(struct rnd_state *rng,
| ^~~~~~~~~
crypto/testmgr.c: In function 'prandom_u32_inclusive':
crypto/testmgr.c:908:42: error: passing argument 1 of 'prandom_u32_below' from incompatible pointer type [-Wincompatible-pointer-types]
908 | return floor + prandom_u32_below(rng, ceil - floor + 1);
| ^~~
| |
| struct rnd_state *
crypto/testmgr.c:891:55: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
| ~~~~~~~~~~~~~~~~~~^~~
crypto/testmgr.c: At top level:
crypto/testmgr.c:912:51: warning: 'struct rnd_state' declared inside parameter list will not be visible outside of this definition or declaration
912 | static unsigned int generate_random_length(struct rnd_state *rng,
| ^~~~~~~~~
crypto/testmgr.c: In function 'generate_random_length':
crypto/testmgr.c:915:46: error: passing argument 1 of 'prandom_u32_below' from incompatible pointer type [-Wincompatible-pointer-types]
915 | unsigned int len = prandom_u32_below(rng, max_len + 1);
| ^~~
| |
| struct rnd_state *
crypto/testmgr.c:891:55: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
| ~~~~~~~~~~~~~~~~~~^~~
crypto/testmgr.c:917:35: error: passing argument 1 of 'prandom_u32_below' from incompatible pointer type [-Wincompatible-pointer-types]
917 | switch (prandom_u32_below(rng, 4)) {
| ^~~
| |
| struct rnd_state *
crypto/testmgr.c:891:55: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
| ~~~~~~~~~~~~~~~~~~^~~
crypto/testmgr.c:930:38: error: passing argument 1 of 'prandom_u32_below' from incompatible pointer type [-Wincompatible-pointer-types]
930 | if (len && prandom_u32_below(rng, 4) == 0)
| ^~~
| |
| struct rnd_state *
crypto/testmgr.c:891:55: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
| ~~~~~~~~~~~~~~~~~~^~~
crypto/testmgr.c: At top level:
crypto/testmgr.c:936:36: warning: 'struct rnd_state' declared inside parameter list will not be visible outside of this definition or declaration
936 | static void flip_random_bit(struct rnd_state *rng, u8 *buf, size_t size)
| ^~~~~~~~~
crypto/testmgr.c: In function 'flip_random_bit':
crypto/testmgr.c:940:36: error: passing argument 1 of 'prandom_u32_below' from incompatible pointer type [-Wincompatible-pointer-types]
940 | bitpos = prandom_u32_below(rng, size * 8);
| ^~~
| |
| struct rnd_state *
crypto/testmgr.c:891:55: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
| ~~~~~~~~~~~~~~~~~~^~~
crypto/testmgr.c: At top level:
crypto/testmgr.c:945:37: warning: 'struct rnd_state' declared inside parameter list will not be visible outside of this definition or declaration
945 | static void flip_random_byte(struct rnd_state *rng, u8 *buf, size_t size)
| ^~~~~~~~~
crypto/testmgr.c: In function 'flip_random_byte':
crypto/testmgr.c:947:31: error: passing argument 1 of 'prandom_u32_below' from incompatible pointer type [-Wincompatible-pointer-types]
947 | buf[prandom_u32_below(rng, size)] ^= 0xff;
| ^~~
| |
| struct rnd_state *
crypto/testmgr.c:891:55: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
| ~~~~~~~~~~~~~~~~~~^~~
crypto/testmgr.c: At top level:
crypto/testmgr.c:951:34: warning: 'struct rnd_state' declared inside parameter list will not be visible outside of this definition or declaration
951 | static void mutate_buffer(struct rnd_state *rng, u8 *buf, size_t size)
| ^~~~~~~~~
crypto/testmgr.c: In function 'mutate_buffer':
crypto/testmgr.c:957:31: error: passing argument 1 of 'prandom_u32_below' from incompatible pointer type [-Wincompatible-pointer-types]
957 | if (prandom_u32_below(rng, 4) == 0) {
| ^~~
| |
| struct rnd_state *
crypto/testmgr.c:891:55: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
| ~~~~~~~~~~~~~~~~~~^~~
In file included from include/linux/kernel.h:28,
from include/linux/cpumask.h:11,
from include/linux/smp.h:13,
from include/linux/lockdep.h:14,
from include/linux/spinlock.h:63,
from include/linux/swait.h:7,
from include/linux/completion.h:12,
from include/linux/crypto.h:15,
from include/crypto/aead.h:13,
from crypto/testmgr.c:19:
crypto/testmgr.c:958:66: error: passing argument 1 of 'prandom_u32_below' from incompatible pointer type [-Wincompatible-pointer-types]
958 | num_flips = min_t(size_t, 1 << prandom_u32_below(rng, 8),
| ^~~
| |
| struct rnd_state *
include/linux/minmax.h:93:23: note: in definition of macro '__cmp_once_unique'
93 | ({ type ux = (x); type uy = (y); __cmp(op, ux, uy); })
| ^
include/linux/minmax.h:213:27: note: in expansion of macro '__cmp_once'
213 | #define min_t(type, x, y) __cmp_once(min, type, x, y)
| ^~~~~~~~~~
crypto/testmgr.c:958:29: note: in expansion of macro 'min_t'
958 | num_flips = min_t(size_t, 1 << prandom_u32_below(rng, 8),
| ^~~~~
crypto/testmgr.c:891:55: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
| ~~~~~~~~~~~~~~~~~~^~~
>> crypto/testmgr.c:961:41: error: passing argument 1 of 'flip_random_bit' from incompatible pointer type [-Wincompatible-pointer-types]
961 | flip_random_bit(rng, buf, size);
| ^~~
| |
| struct rnd_state *
crypto/testmgr.c:936:47: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
936 | static void flip_random_bit(struct rnd_state *rng, u8 *buf, size_t size)
| ~~~~~~~~~~~~~~~~~~^~~
crypto/testmgr.c:965:31: error: passing argument 1 of 'prandom_u32_below' from incompatible pointer type [-Wincompatible-pointer-types]
965 | if (prandom_u32_below(rng, 4) == 0) {
| ^~~
| |
| struct rnd_state *
crypto/testmgr.c:891:55: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
| ~~~~~~~~~~~~~~~~~~^~~
crypto/testmgr.c:966:66: error: passing argument 1 of 'prandom_u32_below' from incompatible pointer type [-Wincompatible-pointer-types]
966 | num_flips = min_t(size_t, 1 << prandom_u32_below(rng, 8), size);
| ^~~
| |
| struct rnd_state *
include/linux/minmax.h:93:23: note: in definition of macro '__cmp_once_unique'
93 | ({ type ux = (x); type uy = (y); __cmp(op, ux, uy); })
| ^
include/linux/minmax.h:213:27: note: in expansion of macro '__cmp_once'
213 | #define min_t(type, x, y) __cmp_once(min, type, x, y)
| ^~~~~~~~~~
crypto/testmgr.c:966:29: note: in expansion of macro 'min_t'
966 | num_flips = min_t(size_t, 1 << prandom_u32_below(rng, 8), size);
| ^~~~~
crypto/testmgr.c:891:55: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
| ~~~~~~~~~~~~~~~~~~^~~
>> crypto/testmgr.c:968:42: error: passing argument 1 of 'flip_random_byte' from incompatible pointer type [-Wincompatible-pointer-types]
968 | flip_random_byte(rng, buf, size);
| ^~~
| |
| struct rnd_state *
crypto/testmgr.c:945:48: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
945 | static void flip_random_byte(struct rnd_state *rng, u8 *buf, size_t size)
| ~~~~~~~~~~~~~~~~~~^~~
crypto/testmgr.c: At top level:
crypto/testmgr.c:973:42: warning: 'struct rnd_state' declared inside parameter list will not be visible outside of this definition or declaration
973 | static void generate_random_bytes(struct rnd_state *rng, u8 *buf, size_t count)
| ^~~~~~~~~
crypto/testmgr.c: In function 'generate_random_bytes':
crypto/testmgr.c:982:35: error: passing argument 1 of 'prandom_u32_below' from incompatible pointer type [-Wincompatible-pointer-types]
982 | switch (prandom_u32_below(rng, 8)) { /* Choose a generation strategy */
| ^~~
| |
| struct rnd_state *
crypto/testmgr.c:891:55: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
| ~~~~~~~~~~~~~~~~~~^~~
crypto/testmgr.c:986:43: error: passing argument 1 of 'prandom_u32_below' from incompatible pointer type [-Wincompatible-pointer-types]
986 | switch (prandom_u32_below(rng, 4)) {
| ^~~
| |
| struct rnd_state *
crypto/testmgr.c:891:55: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
| ~~~~~~~~~~~~~~~~~~^~~
>> crypto/testmgr.c:994:40: error: passing argument 1 of 'prandom_u8' from incompatible pointer type [-Wincompatible-pointer-types]
994 | b = prandom_u8(rng);
| ^~~
| |
| struct rnd_state *
crypto/testmgr.c:886:47: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
886 | static inline u8 prandom_u8(struct rnd_state *rng)
| ~~~~~~~~~~~~~~~~~~^~~
>> crypto/testmgr.c:998:31: error: passing argument 1 of 'mutate_buffer' from incompatible pointer type [-Wincompatible-pointer-types]
998 | mutate_buffer(rng, buf, count);
| ^~~
| |
| struct rnd_state *
crypto/testmgr.c:951:45: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
951 | static void mutate_buffer(struct rnd_state *rng, u8 *buf, size_t size)
| ~~~~~~~~~~~~~~~~~~^~~
crypto/testmgr.c:1002:40: error: passing argument 1 of 'prandom_u8' from incompatible pointer type [-Wincompatible-pointer-types]
1002 | increment = prandom_u8(rng);
| ^~~
| |
| struct rnd_state *
crypto/testmgr.c:886:47: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
886 | static inline u8 prandom_u8(struct rnd_state *rng)
| ~~~~~~~~~~~~~~~~~~^~~
crypto/testmgr.c:1003:32: error: passing argument 1 of 'prandom_u8' from incompatible pointer type [-Wincompatible-pointer-types]
1003 | b = prandom_u8(rng);
| ^~~
| |
| struct rnd_state *
crypto/testmgr.c:886:47: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
886 | static inline u8 prandom_u8(struct rnd_state *rng)
| ~~~~~~~~~~~~~~~~~~^~~
crypto/testmgr.c:1006:31: error: passing argument 1 of 'mutate_buffer' from incompatible pointer type [-Wincompatible-pointer-types]
1006 | mutate_buffer(rng, buf, count);
| ^~~
| |
| struct rnd_state *
crypto/testmgr.c:951:45: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
951 | static void mutate_buffer(struct rnd_state *rng, u8 *buf, size_t size)
| ~~~~~~~~~~~~~~~~~~^~~
>> crypto/testmgr.c:1010:17: error: implicit declaration of function 'prandom_bytes_state' [-Wimplicit-function-declaration]
1010 | prandom_bytes_state(rng, buf, count);
| ^~~~~~~~~~~~~~~~~~~
crypto/testmgr.c: At top level:
crypto/testmgr.c:1014:51: warning: 'struct rnd_state' declared inside parameter list will not be visible outside of this definition or declaration
1014 | static char *generate_random_sgl_divisions(struct rnd_state *rng,
| ^~~~~~~~~
crypto/testmgr.c: In function 'generate_random_sgl_divisions':
>> crypto/testmgr.c:1026:64: error: passing argument 1 of 'prandom_bool' from incompatible pointer type [-Wincompatible-pointer-types]
1026 | if (div == &divs[max_divs - 1] || prandom_bool(rng))
| ^~~
| |
| struct rnd_state *
crypto/testmgr.c:900:51: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
900 | static inline bool prandom_bool(struct rnd_state *rng)
| ~~~~~~~~~~~~~~~~~~^~~
crypto/testmgr.c:1028:44: error: passing argument 1 of 'prandom_u32_below' from incompatible pointer type [-Wincompatible-pointer-types]
1028 | else if (prandom_u32_below(rng, 4) == 0)
| ^~~
| |
| struct rnd_state *
crypto/testmgr.c:891:55: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
| ~~~~~~~~~~~~~~~~~~^~~
>> crypto/testmgr.c:1031:58: error: passing argument 1 of 'prandom_u32_inclusive' from incompatible pointer type [-Wincompatible-pointer-types]
1031 | this_len = prandom_u32_inclusive(rng, 1, remaining);
| ^~~
| |
| struct rnd_state *
crypto/testmgr.c:905:59: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
905 | static inline u32 prandom_u32_inclusive(struct rnd_state *rng,
| ~~~~~~~~~~~~~~~~~~^~~
crypto/testmgr.c:1034:39: error: passing argument 1 of 'prandom_u32_below' from incompatible pointer type [-Wincompatible-pointer-types]
1034 | if (prandom_u32_below(rng, 4) == 0)
| ^~~
| |
| struct rnd_state *
crypto/testmgr.c:891:55: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
| ~~~~~~~~~~~~~~~~~~^~~
crypto/testmgr.c:1035:61: error: passing argument 1 of 'prandom_u32_inclusive' from incompatible pointer type [-Wincompatible-pointer-types]
1035 | div->offset = prandom_u32_inclusive(rng,
| ^~~
| |
| struct rnd_state *
crypto/testmgr.c:905:59: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
905 | static inline u32 prandom_u32_inclusive(struct rnd_state *rng,
| ~~~~~~~~~~~~~~~~~~^~~
crypto/testmgr.c:1038:39: error: passing argument 1 of 'prandom_bool' from incompatible pointer type [-Wincompatible-pointer-types]
1038 | else if (prandom_bool(rng))
| ^~~
| |
| struct rnd_state *
crypto/testmgr.c:900:51: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
900 | static inline bool prandom_bool(struct rnd_state *rng)
| ~~~~~~~~~~~~~~~~~~^~~
crypto/testmgr.c:1039:57: error: passing argument 1 of 'prandom_u32_below' from incompatible pointer type [-Wincompatible-pointer-types]
1039 | div->offset = prandom_u32_below(rng, 32);
| ^~~
| |
| struct rnd_state *
crypto/testmgr.c:891:55: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
| ~~~~~~~~~~~~~~~~~~^~~
crypto/testmgr.c:1041:57: error: passing argument 1 of 'prandom_u32_below' from incompatible pointer type [-Wincompatible-pointer-types]
1041 | div->offset = prandom_u32_below(rng, PAGE_SIZE);
| ^~~
| |
| struct rnd_state *
crypto/testmgr.c:891:55: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
| ~~~~~~~~~~~~~~~~~~^~~
crypto/testmgr.c:1042:39: error: passing argument 1 of 'prandom_u32_below' from incompatible pointer type [-Wincompatible-pointer-types]
1042 | if (prandom_u32_below(rng, 8) == 0)
| ^~~
| |
| struct rnd_state *
crypto/testmgr.c:891:55: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
| ~~~~~~~~~~~~~~~~~~^~~
crypto/testmgr.c:1047:51: error: passing argument 1 of 'prandom_u32_below' from incompatible pointer type [-Wincompatible-pointer-types]
1047 | switch (prandom_u32_below(rng, 4)) {
| ^~~
| |
| struct rnd_state *
crypto/testmgr.c:891:55: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
| ~~~~~~~~~~~~~~~~~~^~~
crypto/testmgr.c:1059:34: error: passing argument 1 of 'prandom_bool' from incompatible pointer type [-Wincompatible-pointer-types]
1059 | prandom_bool(rng))
| ^~~
| |
| struct rnd_state *
crypto/testmgr.c:900:51: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
900 | static inline bool prandom_bool(struct rnd_state *rng)
| ~~~~~~~~~~~~~~~~~~^~~
crypto/testmgr.c: At top level:
crypto/testmgr.c:1094:51: warning: 'struct rnd_state' declared inside parameter list will not be visible outside of this definition or declaration
1094 | static void generate_random_testvec_config(struct rnd_state *rng,
| ^~~~~~~~~
crypto/testmgr.c: In function 'generate_random_testvec_config':
crypto/testmgr.c:1107:35: error: passing argument 1 of 'prandom_u32_below' from incompatible pointer type [-Wincompatible-pointer-types]
1107 | switch (prandom_u32_below(rng, 4)) {
| ^~~
| |
| struct rnd_state *
crypto/testmgr.c:891:55: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
| ~~~~~~~~~~~~~~~~~~^~~
crypto/testmgr.c:1122:26: error: passing argument 1 of 'prandom_bool' from incompatible pointer type [-Wincompatible-pointer-types]
1122 | if (prandom_bool(rng)) {
| ^~~
| |
| struct rnd_state *
crypto/testmgr.c:900:51: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
900 | static inline bool prandom_bool(struct rnd_state *rng)
| ~~~~~~~~~~~~~~~~~~^~~
crypto/testmgr.c:1127:35: error: passing argument 1 of 'prandom_u32_below' from incompatible pointer type [-Wincompatible-pointer-types]
1127 | switch (prandom_u32_below(rng, 4)) {
| ^~~
| |
| struct rnd_state *
crypto/testmgr.c:891:55: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
| ~~~~~~~~~~~~~~~~~~^~~
crypto/testmgr.c:1143:34: error: passing argument 1 of 'prandom_bool' from incompatible pointer type [-Wincompatible-pointer-types]
1143 | if (prandom_bool(rng)) {
| ^~~
| |
| struct rnd_state *
crypto/testmgr.c:900:51: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
900 | static inline bool prandom_bool(struct rnd_state *rng)
| ~~~~~~~~~~~~~~~~~~^~~
crypto/testmgr.c:1147:34: error: passing argument 1 of 'prandom_bool' from incompatible pointer type [-Wincompatible-pointer-types]
1147 | if (prandom_bool(rng)) {
| ^~~
| |
| struct rnd_state *
crypto/testmgr.c:900:51: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
900 | static inline bool prandom_bool(struct rnd_state *rng)
| ~~~~~~~~~~~~~~~~~~^~~
>> crypto/testmgr.c:1154:43: error: passing argument 1 of 'generate_random_sgl_divisions' from incompatible pointer type [-Wincompatible-pointer-types]
1154 | p = generate_random_sgl_divisions(rng, cfg->src_divs,
| ^~~
| |
| struct rnd_state *
crypto/testmgr.c:1014:62: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
1014 | static char *generate_random_sgl_divisions(struct rnd_state *rng,
| ~~~~~~~~~~~~~~~~~~^~~
crypto/testmgr.c:1161:63: error: passing argument 1 of 'prandom_bool' from incompatible pointer type [-Wincompatible-pointer-types]
1161 | if (cfg->inplace_mode == OUT_OF_PLACE && prandom_bool(rng)) {
| ^~~
| |
| struct rnd_state *
crypto/testmgr.c:900:51: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
900 | static inline bool prandom_bool(struct rnd_state *rng)
| ~~~~~~~~~~~~~~~~~~^~~
crypto/testmgr.c:1163:51: error: passing argument 1 of 'generate_random_sgl_divisions' from incompatible pointer type [-Wincompatible-pointer-types]
1163 | p = generate_random_sgl_divisions(rng, cfg->dst_divs,
| ^~~
| |
| struct rnd_state *
crypto/testmgr.c:1014:62: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
1014 | static char *generate_random_sgl_divisions(struct rnd_state *rng,
| ~~~~~~~~~~~~~~~~~~^~~
crypto/testmgr.c:1170:26: error: passing argument 1 of 'prandom_bool' from incompatible pointer type [-Wincompatible-pointer-types]
1170 | if (prandom_bool(rng)) {
| ^~~
| |
| struct rnd_state *
crypto/testmgr.c:900:51: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
900 | static inline bool prandom_bool(struct rnd_state *rng)
| ~~~~~~~~~~~~~~~~~~^~~
crypto/testmgr.c:1171:56: error: passing argument 1 of 'prandom_u32_inclusive' from incompatible pointer type [-Wincompatible-pointer-types]
1171 | cfg->iv_offset = prandom_u32_inclusive(rng, 1,
| ^~~
| |
| struct rnd_state *
crypto/testmgr.c:905:59: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
905 | static inline u32 prandom_u32_inclusive(struct rnd_state *rng,
| ~~~~~~~~~~~~~~~~~~^~~
crypto/testmgr.c:1176:26: error: passing argument 1 of 'prandom_bool' from incompatible pointer type [-Wincompatible-pointer-types]
1176 | if (prandom_bool(rng)) {
| ^~~
| |
| struct rnd_state *
crypto/testmgr.c:900:51: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
900 | static inline bool prandom_bool(struct rnd_state *rng)
| ~~~~~~~~~~~~~~~~~~^~~
crypto/testmgr.c:1177:57: error: passing argument 1 of 'prandom_u32_inclusive' from incompatible pointer type [-Wincompatible-pointer-types]
1177 | cfg->key_offset = prandom_u32_inclusive(rng, 1,
| ^~~
| |
| struct rnd_state *
crypto/testmgr.c:905:59: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
905 | static inline u32 prandom_u32_inclusive(struct rnd_state *rng,
| ~~~~~~~~~~~~~~~~~~^~~
crypto/testmgr.c: In function 'test_hash_vec':
>> crypto/testmgr.c:1689:34: error: storage size of 'rng' isn't known
1689 | struct rnd_state rng;
| ^~~
>> crypto/testmgr.c:1689:34: warning: unused variable 'rng' [-Wunused-variable]
crypto/testmgr.c: At top level:
crypto/testmgr.c:1714:49: warning: 'struct rnd_state' declared inside parameter list will not be visible outside of this definition or declaration
1714 | static void generate_random_hash_testvec(struct rnd_state *rng,
| ^~~~~~~~~
crypto/testmgr.c: In function 'generate_random_hash_testvec':
>> crypto/testmgr.c:1722:45: error: passing argument 1 of 'generate_random_length' from incompatible pointer type [-Wincompatible-pointer-types]
1722 | vec->psize = generate_random_length(rng, maxdatasize);
| ^~~
| |
| struct rnd_state *
crypto/testmgr.c:912:62: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
912 | static unsigned int generate_random_length(struct rnd_state *rng,
| ~~~~~~~~~~~~~~~~~~^~~
>> crypto/testmgr.c:1723:31: error: passing argument 1 of 'generate_random_bytes' from incompatible pointer type [-Wincompatible-pointer-types]
1723 | generate_random_bytes(rng, (u8 *)vec->plaintext, vec->psize);
| ^~~
| |
| struct rnd_state *
crypto/testmgr.c:973:53: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
973 | static void generate_random_bytes(struct rnd_state *rng, u8 *buf, size_t count)
| ~~~~~~~~~~~~~~~~~~^~~
crypto/testmgr.c:1733:39: error: passing argument 1 of 'prandom_u32_below' from incompatible pointer type [-Wincompatible-pointer-types]
1733 | if (prandom_u32_below(rng, 4) == 0)
| ^~~
| |
| struct rnd_state *
crypto/testmgr.c:891:55: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
| ~~~~~~~~~~~~~~~~~~^~~
crypto/testmgr.c:1734:60: error: passing argument 1 of 'prandom_u32_inclusive' from incompatible pointer type [-Wincompatible-pointer-types]
1734 | vec->ksize = prandom_u32_inclusive(rng, 1, maxkeysize);
| ^~~
| |
| struct rnd_state *
crypto/testmgr.c:905:59: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
905 | static inline u32 prandom_u32_inclusive(struct rnd_state *rng,
| ~~~~~~~~~~~~~~~~~~^~~
crypto/testmgr.c:1735:39: error: passing argument 1 of 'generate_random_bytes' from incompatible pointer type [-Wincompatible-pointer-types]
1735 | generate_random_bytes(rng, (u8 *)vec->key, vec->ksize);
| ^~~
| |
| struct rnd_state *
crypto/testmgr.c:973:53: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
973 | static void generate_random_bytes(struct rnd_state *rng, u8 *buf, size_t count)
| ~~~~~~~~~~~~~~~~~~^~~
crypto/testmgr.c: In function 'test_hash_vs_generic_impl':
crypto/testmgr.c:1769:26: error: storage size of 'rng' isn't known
1769 | struct rnd_state rng;
| ^~~
crypto/testmgr.c:1769:26: warning: unused variable 'rng' [-Wunused-variable]
crypto/testmgr.c: In function 'test_aead_vec':
crypto/testmgr.c:2259:34: error: storage size of 'rng' isn't known
2259 | struct rnd_state rng;
| ^~~
crypto/testmgr.c:2259:34: warning: unused variable 'rng' [-Wunused-variable]
crypto/testmgr.c: At top level:
>> crypto/testmgr.c:2282:26: error: field 'rng' has incomplete type
2282 | struct rnd_state rng;
| ^~~
crypto/testmgr.c: In function 'mutate_aead_message':
crypto/testmgr.c:2308:26: error: passing argument 1 of 'prandom_bool' from incompatible pointer type [-Wincompatible-pointer-types]
2308 | if (prandom_bool(rng) && vec->alen > aad_tail_size) {
| ^~~
| |
| struct rnd_state *
crypto/testmgr.c:900:51: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
900 | static inline bool prandom_bool(struct rnd_state *rng)
| ~~~~~~~~~~~~~~~~~~^~~
crypto/testmgr.c:2310:33: error: passing argument 1 of 'flip_random_bit' from incompatible pointer type [-Wincompatible-pointer-types]
2310 | flip_random_bit(rng, (u8 *)vec->assoc,
| ^~~
| |
| struct rnd_state *
crypto/testmgr.c:936:47: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
936 | static void flip_random_bit(struct rnd_state *rng, u8 *buf, size_t size)
| ~~~~~~~~~~~~~~~~~~^~~
crypto/testmgr.c:2312:34: error: passing argument 1 of 'prandom_bool' from incompatible pointer type [-Wincompatible-pointer-types]
2312 | if (prandom_bool(rng))
| ^~~
| |
| struct rnd_state *
crypto/testmgr.c:900:51: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
900 | static inline bool prandom_bool(struct rnd_state *rng)
| ~~~~~~~~~~~~~~~~~~^~~
crypto/testmgr.c:2315:26: error: passing argument 1 of 'prandom_bool' from incompatible pointer type [-Wincompatible-pointer-types]
2315 | if (prandom_bool(rng)) {
| ^~~
| |
| struct rnd_state *
crypto/testmgr.c:900:51: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
900 | static inline bool prandom_bool(struct rnd_state *rng)
| ~~~~~~~~~~~~~~~~~~^~~
crypto/testmgr.c:2317:33: error: passing argument 1 of 'flip_random_bit' from incompatible pointer type [-Wincompatible-pointer-types]
2317 | flip_random_bit(rng, (u8 *)vec->ctext + vec->plen, authsize);
| ^~~
| |
| struct rnd_state *
crypto/testmgr.c:936:47: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
936 | static void flip_random_bit(struct rnd_state *rng, u8 *buf, size_t size)
| ~~~~~~~~~~~~~~~~~~^~~
crypto/testmgr.c:2320:33: error: passing argument 1 of 'flip_random_bit' from incompatible pointer type [-Wincompatible-pointer-types]
2320 | flip_random_bit(rng, (u8 *)vec->ctext, vec->clen);
| ^~~
| |
| struct rnd_state *
crypto/testmgr.c:936:47: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
936 | static void flip_random_bit(struct rnd_state *rng, u8 *buf, size_t size)
| ~~~~~~~~~~~~~~~~~~^~~
crypto/testmgr.c: In function 'generate_aead_message':
crypto/testmgr.c:2342:53: error: passing argument 1 of 'prandom_u32_below' from incompatible pointer type [-Wincompatible-pointer-types]
2342 | prandom_u32_below(rng, 4) == 0);
| ^~~
| |
| struct rnd_state *
crypto/testmgr.c:891:55: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
| ~~~~~~~~~~~~~~~~~~^~~
crypto/testmgr.c:2345:31: error: passing argument 1 of 'generate_random_bytes' from incompatible pointer type [-Wincompatible-pointer-types]
2345 | generate_random_bytes(rng, (u8 *)vec->assoc, vec->alen);
| ^~~
| |
| struct rnd_state *
crypto/testmgr.c:973:53: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
973 | static void generate_random_bytes(struct rnd_state *rng, u8 *buf, size_t count)
| ~~~~~~~~~~~~~~~~~~^~~
crypto/testmgr.c:2350:41: error: passing argument 1 of 'prandom_bool' from incompatible pointer type [-Wincompatible-pointer-types]
2350 | if (inauthentic && prandom_bool(rng)) {
| ^~~
| |
| struct rnd_state *
crypto/testmgr.c:900:51: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
900 | static inline bool prandom_bool(struct rnd_state *rng)
| ~~~~~~~~~~~~~~~~~~^~~
crypto/testmgr.c:2352:39: error: passing argument 1 of 'generate_random_bytes' from incompatible pointer type [-Wincompatible-pointer-types]
2352 | generate_random_bytes(rng, (u8 *)vec->ctext, vec->clen);
| ^~~
| |
| struct rnd_state *
crypto/testmgr.c:973:53: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
973 | static void generate_random_bytes(struct rnd_state *rng, u8 *buf, size_t count)
| ~~~~~~~~~~~~~~~~~~^~~
crypto/testmgr.c:2364:47: error: passing argument 1 of 'generate_random_bytes' from incompatible pointer type [-Wincompatible-pointer-types]
2364 | generate_random_bytes(rng, (u8 *)vec->ptext, vec->plen);
| ^~~
| |
| struct rnd_state *
crypto/testmgr.c:973:53: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
973 | static void generate_random_bytes(struct rnd_state *rng, u8 *buf, size_t count)
| ~~~~~~~~~~~~~~~~~~^~~
crypto/testmgr.c: In function 'generate_random_aead_testvec':
crypto/testmgr.c:2415:31: error: passing argument 1 of 'prandom_u32_below' from incompatible pointer type [-Wincompatible-pointer-types]
2415 | if (prandom_u32_below(rng, 4) == 0)
| ^~~
| |
| struct rnd_state *
crypto/testmgr.c:891:55: note: expected 'struct rnd_state *' but argument is of type 'struct rnd_state *'
891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
vim +/prandom_seed_state +883 crypto/testmgr.c
f2bb770ae89641 Eric Biggers 2019-04-11 873
f900fde2888360 Eric Biggers 2023-02-27 874 /*
f900fde2888360 Eric Biggers 2023-02-27 875 * The fuzz tests use prandom instead of the normal Linux RNG since they don't
f900fde2888360 Eric Biggers 2023-02-27 876 * need cryptographically secure random numbers. This greatly improves the
f900fde2888360 Eric Biggers 2023-02-27 877 * performance of these tests, especially if they are run before the Linux RNG
f900fde2888360 Eric Biggers 2023-02-27 878 * has been initialized or if they are run on a lockdep-enabled kernel.
f900fde2888360 Eric Biggers 2023-02-27 879 */
f900fde2888360 Eric Biggers 2023-02-27 880
f900fde2888360 Eric Biggers 2023-02-27 @881 static inline void init_rnd_state(struct rnd_state *rng)
f900fde2888360 Eric Biggers 2023-02-27 882 {
f900fde2888360 Eric Biggers 2023-02-27 @883 prandom_seed_state(rng, get_random_u64());
f900fde2888360 Eric Biggers 2023-02-27 884 }
f900fde2888360 Eric Biggers 2023-02-27 885
f900fde2888360 Eric Biggers 2023-02-27 886 static inline u8 prandom_u8(struct rnd_state *rng)
f900fde2888360 Eric Biggers 2023-02-27 887 {
f900fde2888360 Eric Biggers 2023-02-27 @888 return prandom_u32_state(rng);
f900fde2888360 Eric Biggers 2023-02-27 889 }
f900fde2888360 Eric Biggers 2023-02-27 890
f900fde2888360 Eric Biggers 2023-02-27 @891 static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
f900fde2888360 Eric Biggers 2023-02-27 892 {
f900fde2888360 Eric Biggers 2023-02-27 893 /*
f900fde2888360 Eric Biggers 2023-02-27 894 * This is slightly biased for non-power-of-2 values of 'ceil', but this
f900fde2888360 Eric Biggers 2023-02-27 895 * isn't important here.
f900fde2888360 Eric Biggers 2023-02-27 896 */
f900fde2888360 Eric Biggers 2023-02-27 897 return prandom_u32_state(rng) % ceil;
f900fde2888360 Eric Biggers 2023-02-27 898 }
f900fde2888360 Eric Biggers 2023-02-27 899
f900fde2888360 Eric Biggers 2023-02-27 900 static inline bool prandom_bool(struct rnd_state *rng)
f900fde2888360 Eric Biggers 2023-02-27 901 {
f900fde2888360 Eric Biggers 2023-02-27 @902 return prandom_u32_below(rng, 2);
f900fde2888360 Eric Biggers 2023-02-27 903 }
f900fde2888360 Eric Biggers 2023-02-27 904
f900fde2888360 Eric Biggers 2023-02-27 @905 static inline u32 prandom_u32_inclusive(struct rnd_state *rng,
f900fde2888360 Eric Biggers 2023-02-27 906 u32 floor, u32 ceil)
f900fde2888360 Eric Biggers 2023-02-27 907 {
f900fde2888360 Eric Biggers 2023-02-27 908 return floor + prandom_u32_below(rng, ceil - floor + 1);
f900fde2888360 Eric Biggers 2023-02-27 909 }
f900fde2888360 Eric Biggers 2023-02-27 910
f2bb770ae89641 Eric Biggers 2019-04-11 911 /* Generate a random length in range [0, max_len], but prefer smaller values */
f900fde2888360 Eric Biggers 2023-02-27 912 static unsigned int generate_random_length(struct rnd_state *rng,
f900fde2888360 Eric Biggers 2023-02-27 913 unsigned int max_len)
f2bb770ae89641 Eric Biggers 2019-04-11 914 {
f900fde2888360 Eric Biggers 2023-02-27 915 unsigned int len = prandom_u32_below(rng, max_len + 1);
f2bb770ae89641 Eric Biggers 2019-04-11 916
f900fde2888360 Eric Biggers 2023-02-27 917 switch (prandom_u32_below(rng, 4)) {
f2bb770ae89641 Eric Biggers 2019-04-11 918 case 0:
101e99c23af946 Eric Biggers 2024-07-03 919 len %= 64;
101e99c23af946 Eric Biggers 2024-07-03 920 break;
f2bb770ae89641 Eric Biggers 2019-04-11 921 case 1:
101e99c23af946 Eric Biggers 2024-07-03 922 len %= 256;
101e99c23af946 Eric Biggers 2024-07-03 923 break;
f2bb770ae89641 Eric Biggers 2019-04-11 924 case 2:
101e99c23af946 Eric Biggers 2024-07-03 925 len %= 1024;
101e99c23af946 Eric Biggers 2024-07-03 926 break;
f2bb770ae89641 Eric Biggers 2019-04-11 927 default:
101e99c23af946 Eric Biggers 2024-07-03 928 break;
f2bb770ae89641 Eric Biggers 2019-04-11 929 }
101e99c23af946 Eric Biggers 2024-07-03 930 if (len && prandom_u32_below(rng, 4) == 0)
101e99c23af946 Eric Biggers 2024-07-03 931 len = rounddown_pow_of_two(len);
101e99c23af946 Eric Biggers 2024-07-03 932 return len;
f2bb770ae89641 Eric Biggers 2019-04-11 933 }
f2bb770ae89641 Eric Biggers 2019-04-11 934
49763fc6b1af42 Eric Biggers 2019-12-01 935 /* Flip a random bit in the given nonempty data buffer */
f900fde2888360 Eric Biggers 2023-02-27 936 static void flip_random_bit(struct rnd_state *rng, u8 *buf, size_t size)
49763fc6b1af42 Eric Biggers 2019-12-01 937 {
49763fc6b1af42 Eric Biggers 2019-12-01 938 size_t bitpos;
49763fc6b1af42 Eric Biggers 2019-12-01 939
f900fde2888360 Eric Biggers 2023-02-27 940 bitpos = prandom_u32_below(rng, size * 8);
49763fc6b1af42 Eric Biggers 2019-12-01 941 buf[bitpos / 8] ^= 1 << (bitpos % 8);
49763fc6b1af42 Eric Biggers 2019-12-01 942 }
49763fc6b1af42 Eric Biggers 2019-12-01 943
49763fc6b1af42 Eric Biggers 2019-12-01 944 /* Flip a random byte in the given nonempty data buffer */
f900fde2888360 Eric Biggers 2023-02-27 945 static void flip_random_byte(struct rnd_state *rng, u8 *buf, size_t size)
49763fc6b1af42 Eric Biggers 2019-12-01 946 {
f900fde2888360 Eric Biggers 2023-02-27 947 buf[prandom_u32_below(rng, size)] ^= 0xff;
49763fc6b1af42 Eric Biggers 2019-12-01 948 }
49763fc6b1af42 Eric Biggers 2019-12-01 949
49763fc6b1af42 Eric Biggers 2019-12-01 950 /* Sometimes make some random changes to the given nonempty data buffer */
f900fde2888360 Eric Biggers 2023-02-27 951 static void mutate_buffer(struct rnd_state *rng, u8 *buf, size_t size)
f2bb770ae89641 Eric Biggers 2019-04-11 952 {
f2bb770ae89641 Eric Biggers 2019-04-11 953 size_t num_flips;
f2bb770ae89641 Eric Biggers 2019-04-11 954 size_t i;
f2bb770ae89641 Eric Biggers 2019-04-11 955
f2bb770ae89641 Eric Biggers 2019-04-11 956 /* Sometimes flip some bits */
f900fde2888360 Eric Biggers 2023-02-27 957 if (prandom_u32_below(rng, 4) == 0) {
f900fde2888360 Eric Biggers 2023-02-27 @958 num_flips = min_t(size_t, 1 << prandom_u32_below(rng, 8),
f900fde2888360 Eric Biggers 2023-02-27 959 size * 8);
49763fc6b1af42 Eric Biggers 2019-12-01 960 for (i = 0; i < num_flips; i++)
f900fde2888360 Eric Biggers 2023-02-27 @961 flip_random_bit(rng, buf, size);
f2bb770ae89641 Eric Biggers 2019-04-11 962 }
f2bb770ae89641 Eric Biggers 2019-04-11 963
f2bb770ae89641 Eric Biggers 2019-04-11 964 /* Sometimes flip some bytes */
f900fde2888360 Eric Biggers 2023-02-27 965 if (prandom_u32_below(rng, 4) == 0) {
f900fde2888360 Eric Biggers 2023-02-27 @966 num_flips = min_t(size_t, 1 << prandom_u32_below(rng, 8), size);
f2bb770ae89641 Eric Biggers 2019-04-11 967 for (i = 0; i < num_flips; i++)
f900fde2888360 Eric Biggers 2023-02-27 @968 flip_random_byte(rng, buf, size);
f2bb770ae89641 Eric Biggers 2019-04-11 969 }
f2bb770ae89641 Eric Biggers 2019-04-11 970 }
f2bb770ae89641 Eric Biggers 2019-04-11 971
f2bb770ae89641 Eric Biggers 2019-04-11 972 /* Randomly generate 'count' bytes, but sometimes make them "interesting" */
f900fde2888360 Eric Biggers 2023-02-27 973 static void generate_random_bytes(struct rnd_state *rng, u8 *buf, size_t count)
f2bb770ae89641 Eric Biggers 2019-04-11 974 {
f2bb770ae89641 Eric Biggers 2019-04-11 975 u8 b;
f2bb770ae89641 Eric Biggers 2019-04-11 976 u8 increment;
f2bb770ae89641 Eric Biggers 2019-04-11 977 size_t i;
f2bb770ae89641 Eric Biggers 2019-04-11 978
f2bb770ae89641 Eric Biggers 2019-04-11 979 if (count == 0)
f2bb770ae89641 Eric Biggers 2019-04-11 980 return;
f2bb770ae89641 Eric Biggers 2019-04-11 981
f900fde2888360 Eric Biggers 2023-02-27 982 switch (prandom_u32_below(rng, 8)) { /* Choose a generation strategy */
f2bb770ae89641 Eric Biggers 2019-04-11 983 case 0:
f2bb770ae89641 Eric Biggers 2019-04-11 984 case 1:
f2bb770ae89641 Eric Biggers 2019-04-11 985 /* All the same byte, plus optional mutations */
f900fde2888360 Eric Biggers 2023-02-27 @986 switch (prandom_u32_below(rng, 4)) {
f2bb770ae89641 Eric Biggers 2019-04-11 987 case 0:
f2bb770ae89641 Eric Biggers 2019-04-11 988 b = 0x00;
f2bb770ae89641 Eric Biggers 2019-04-11 989 break;
f2bb770ae89641 Eric Biggers 2019-04-11 990 case 1:
f2bb770ae89641 Eric Biggers 2019-04-11 991 b = 0xff;
f2bb770ae89641 Eric Biggers 2019-04-11 992 break;
f2bb770ae89641 Eric Biggers 2019-04-11 993 default:
f900fde2888360 Eric Biggers 2023-02-27 @994 b = prandom_u8(rng);
f2bb770ae89641 Eric Biggers 2019-04-11 995 break;
f2bb770ae89641 Eric Biggers 2019-04-11 996 }
f2bb770ae89641 Eric Biggers 2019-04-11 997 memset(buf, b, count);
f900fde2888360 Eric Biggers 2023-02-27 @998 mutate_buffer(rng, buf, count);
f2bb770ae89641 Eric Biggers 2019-04-11 999 break;
f2bb770ae89641 Eric Biggers 2019-04-11 1000 case 2:
f2bb770ae89641 Eric Biggers 2019-04-11 1001 /* Ascending or descending bytes, plus optional mutations */
f900fde2888360 Eric Biggers 2023-02-27 1002 increment = prandom_u8(rng);
f900fde2888360 Eric Biggers 2023-02-27 1003 b = prandom_u8(rng);
f2bb770ae89641 Eric Biggers 2019-04-11 1004 for (i = 0; i < count; i++, b += increment)
f2bb770ae89641 Eric Biggers 2019-04-11 1005 buf[i] = b;
f900fde2888360 Eric Biggers 2023-02-27 @1006 mutate_buffer(rng, buf, count);
f2bb770ae89641 Eric Biggers 2019-04-11 1007 break;
f2bb770ae89641 Eric Biggers 2019-04-11 1008 default:
f2bb770ae89641 Eric Biggers 2019-04-11 1009 /* Fully random bytes */
f900fde2888360 Eric Biggers 2023-02-27 @1010 prandom_bytes_state(rng, buf, count);
f2bb770ae89641 Eric Biggers 2019-04-11 1011 }
f2bb770ae89641 Eric Biggers 2019-04-11 1012 }
f2bb770ae89641 Eric Biggers 2019-04-11 1013
f900fde2888360 Eric Biggers 2023-02-27 1014 static char *generate_random_sgl_divisions(struct rnd_state *rng,
f900fde2888360 Eric Biggers 2023-02-27 1015 struct test_sg_division *divs,
25f9dddb928aee Eric Biggers 2019-01-31 1016 size_t max_divs, char *p, char *end,
6570737c7fa047 Eric Biggers 2019-03-12 1017 bool gen_flushes, u32 req_flags)
25f9dddb928aee Eric Biggers 2019-01-31 1018 {
25f9dddb928aee Eric Biggers 2019-01-31 1019 struct test_sg_division *div = divs;
25f9dddb928aee Eric Biggers 2019-01-31 1020 unsigned int remaining = TEST_SG_TOTAL;
25f9dddb928aee Eric Biggers 2019-01-31 1021
25f9dddb928aee Eric Biggers 2019-01-31 1022 do {
25f9dddb928aee Eric Biggers 2019-01-31 1023 unsigned int this_len;
6570737c7fa047 Eric Biggers 2019-03-12 1024 const char *flushtype_str;
25f9dddb928aee Eric Biggers 2019-01-31 1025
f900fde2888360 Eric Biggers 2023-02-27 @1026 if (div == &divs[max_divs - 1] || prandom_bool(rng))
25f9dddb928aee Eric Biggers 2019-01-31 1027 this_len = remaining;
101e99c23af946 Eric Biggers 2024-07-03 @1028 else if (prandom_u32_below(rng, 4) == 0)
101e99c23af946 Eric Biggers 2024-07-03 1029 this_len = (remaining + 1) / 2;
25f9dddb928aee Eric Biggers 2019-01-31 1030 else
f900fde2888360 Eric Biggers 2023-02-27 @1031 this_len = prandom_u32_inclusive(rng, 1, remaining);
25f9dddb928aee Eric Biggers 2019-01-31 1032 div->proportion_of_total = this_len;
25f9dddb928aee Eric Biggers 2019-01-31 1033
f900fde2888360 Eric Biggers 2023-02-27 1034 if (prandom_u32_below(rng, 4) == 0)
f900fde2888360 Eric Biggers 2023-02-27 1035 div->offset = prandom_u32_inclusive(rng,
f900fde2888360 Eric Biggers 2023-02-27 1036 PAGE_SIZE - 128,
f900fde2888360 Eric Biggers 2023-02-27 1037 PAGE_SIZE - 1);
f900fde2888360 Eric Biggers 2023-02-27 1038 else if (prandom_bool(rng))
f900fde2888360 Eric Biggers 2023-02-27 1039 div->offset = prandom_u32_below(rng, 32);
25f9dddb928aee Eric Biggers 2019-01-31 1040 else
f900fde2888360 Eric Biggers 2023-02-27 1041 div->offset = prandom_u32_below(rng, PAGE_SIZE);
f900fde2888360 Eric Biggers 2023-02-27 1042 if (prandom_u32_below(rng, 8) == 0)
25f9dddb928aee Eric Biggers 2019-01-31 1043 div->offset_relative_to_alignmask = true;
25f9dddb928aee Eric Biggers 2019-01-31 1044
25f9dddb928aee Eric Biggers 2019-01-31 1045 div->flush_type = FLUSH_TYPE_NONE;
25f9dddb928aee Eric Biggers 2019-01-31 1046 if (gen_flushes) {
f900fde2888360 Eric Biggers 2023-02-27 1047 switch (prandom_u32_below(rng, 4)) {
25f9dddb928aee Eric Biggers 2019-01-31 1048 case 0:
25f9dddb928aee Eric Biggers 2019-01-31 1049 div->flush_type = FLUSH_TYPE_REIMPORT;
25f9dddb928aee Eric Biggers 2019-01-31 1050 break;
25f9dddb928aee Eric Biggers 2019-01-31 1051 case 1:
25f9dddb928aee Eric Biggers 2019-01-31 1052 div->flush_type = FLUSH_TYPE_FLUSH;
25f9dddb928aee Eric Biggers 2019-01-31 1053 break;
25f9dddb928aee Eric Biggers 2019-01-31 1054 }
25f9dddb928aee Eric Biggers 2019-01-31 1055 }
25f9dddb928aee Eric Biggers 2019-01-31 1056
6570737c7fa047 Eric Biggers 2019-03-12 1057 if (div->flush_type != FLUSH_TYPE_NONE &&
6570737c7fa047 Eric Biggers 2019-03-12 1058 !(req_flags & CRYPTO_TFM_REQ_MAY_SLEEP) &&
f900fde2888360 Eric Biggers 2023-02-27 1059 prandom_bool(rng))
6570737c7fa047 Eric Biggers 2019-03-12 1060 div->nosimd = true;
6570737c7fa047 Eric Biggers 2019-03-12 1061
6570737c7fa047 Eric Biggers 2019-03-12 1062 switch (div->flush_type) {
6570737c7fa047 Eric Biggers 2019-03-12 1063 case FLUSH_TYPE_FLUSH:
6570737c7fa047 Eric Biggers 2019-03-12 1064 if (div->nosimd)
6570737c7fa047 Eric Biggers 2019-03-12 1065 flushtype_str = "<flush,nosimd>";
6570737c7fa047 Eric Biggers 2019-03-12 1066 else
6570737c7fa047 Eric Biggers 2019-03-12 1067 flushtype_str = "<flush>";
6570737c7fa047 Eric Biggers 2019-03-12 1068 break;
6570737c7fa047 Eric Biggers 2019-03-12 1069 case FLUSH_TYPE_REIMPORT:
6570737c7fa047 Eric Biggers 2019-03-12 1070 if (div->nosimd)
6570737c7fa047 Eric Biggers 2019-03-12 1071 flushtype_str = "<reimport,nosimd>";
6570737c7fa047 Eric Biggers 2019-03-12 1072 else
6570737c7fa047 Eric Biggers 2019-03-12 1073 flushtype_str = "<reimport>";
6570737c7fa047 Eric Biggers 2019-03-12 1074 break;
6570737c7fa047 Eric Biggers 2019-03-12 1075 default:
6570737c7fa047 Eric Biggers 2019-03-12 1076 flushtype_str = "";
6570737c7fa047 Eric Biggers 2019-03-12 1077 break;
6570737c7fa047 Eric Biggers 2019-03-12 1078 }
6570737c7fa047 Eric Biggers 2019-03-12 1079
25f9dddb928aee Eric Biggers 2019-01-31 1080 BUILD_BUG_ON(TEST_SG_TOTAL != 10000); /* for "%u.%u%%" */
6570737c7fa047 Eric Biggers 2019-03-12 1081 p += scnprintf(p, end - p, "%s%u.%u%%@%s+%u%s", flushtype_str,
25f9dddb928aee Eric Biggers 2019-01-31 1082 this_len / 100, this_len % 100,
25f9dddb928aee Eric Biggers 2019-01-31 1083 div->offset_relative_to_alignmask ?
25f9dddb928aee Eric Biggers 2019-01-31 1084 "alignmask" : "",
25f9dddb928aee Eric Biggers 2019-01-31 1085 div->offset, this_len == remaining ? "" : ", ");
25f9dddb928aee Eric Biggers 2019-01-31 1086 remaining -= this_len;
25f9dddb928aee Eric Biggers 2019-01-31 1087 div++;
25f9dddb928aee Eric Biggers 2019-01-31 1088 } while (remaining);
25f9dddb928aee Eric Biggers 2019-01-31 1089
25f9dddb928aee Eric Biggers 2019-01-31 1090 return p;
25f9dddb928aee Eric Biggers 2019-01-31 1091 }
25f9dddb928aee Eric Biggers 2019-01-31 1092
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH 17/18] random: Do not include <linux/prandom.h>
2024-09-05 12:17 ` [PATCH 17/18] random: Do not include <linux/prandom.h> Uros Bizjak
2024-09-06 13:30 ` kernel test robot
@ 2024-09-06 14:21 ` kernel test robot
2024-09-06 15:46 ` Uros Bizjak
1 sibling, 1 reply; 32+ messages in thread
From: kernel test robot @ 2024-09-06 14:21 UTC (permalink / raw)
To: Uros Bizjak, linux-kernel
Cc: llvm, oe-kbuild-all, Uros Bizjak, Theodore Ts'o,
Jason A. Donenfeld
Hi Uros,
kernel test robot noticed the following build errors:
[auto build test ERROR on akpm-mm/mm-nonmm-unstable]
[also build test ERROR on mtd/mtd/next mtd/mtd/fixes linus/master v6.11-rc6 next-20240906]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Uros-Bizjak/x86-kaslr-Include-linux-prandom-h-instead-of-linux-random-h/20240905-202710
base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-nonmm-unstable
patch link: https://lore.kernel.org/r/20240905122020.872466-18-ubizjak%40gmail.com
patch subject: [PATCH 17/18] random: Do not include <linux/prandom.h>
config: um-randconfig-002-20240906 (https://download.01.org/0day-ci/archive/20240906/202409062123.F3r9hB9z-lkp@intel.com/config)
compiler: clang version 20.0.0git (https://github.com/llvm/llvm-project 05f5a91d00b02f4369f46d076411c700755ae041)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240906/202409062123.F3r9hB9z-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202409062123.F3r9hB9z-lkp@intel.com/
All error/warnings (new ones prefixed by >>):
In file included from crypto/testmgr.c:27:
In file included from include/linux/scatterlist.h:8:
In file included from include/linux/mm.h:2228:
include/linux/vmstat.h:517:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
517 | return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
| ~~~~~~~~~~~ ^ ~~~
In file included from crypto/testmgr.c:27:
In file included from include/linux/scatterlist.h:9:
In file included from arch/um/include/asm/io.h:24:
include/asm-generic/io.h:548:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
548 | val = __raw_readb(PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:561:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
561 | val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
| ~~~~~~~~~~ ^
include/uapi/linux/byteorder/little_endian.h:37:51: note: expanded from macro '__le16_to_cpu'
37 | #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
| ^
In file included from crypto/testmgr.c:27:
In file included from include/linux/scatterlist.h:9:
In file included from arch/um/include/asm/io.h:24:
include/asm-generic/io.h:574:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
574 | val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
| ~~~~~~~~~~ ^
include/uapi/linux/byteorder/little_endian.h:35:51: note: expanded from macro '__le32_to_cpu'
35 | #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
| ^
In file included from crypto/testmgr.c:27:
In file included from include/linux/scatterlist.h:9:
In file included from arch/um/include/asm/io.h:24:
include/asm-generic/io.h:585:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
585 | __raw_writeb(value, PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:595:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
595 | __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:605:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
605 | __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:693:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
693 | readsb(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:701:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
701 | readsw(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:709:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
709 | readsl(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:718:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
718 | writesb(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:727:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
727 | writesw(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:736:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
736 | writesl(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
>> crypto/testmgr.c:881:42: warning: declaration of 'struct rnd_state' will not be visible outside of this function [-Wvisibility]
881 | static inline void init_rnd_state(struct rnd_state *rng)
| ^
>> crypto/testmgr.c:883:2: error: call to undeclared function 'prandom_seed_state'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
883 | prandom_seed_state(rng, get_random_u64());
| ^
crypto/testmgr.c:886:36: warning: declaration of 'struct rnd_state' will not be visible outside of this function [-Wvisibility]
886 | static inline u8 prandom_u8(struct rnd_state *rng)
| ^
>> crypto/testmgr.c:888:9: error: call to undeclared function 'prandom_u32_state'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
888 | return prandom_u32_state(rng);
| ^
crypto/testmgr.c:891:44: warning: declaration of 'struct rnd_state' will not be visible outside of this function [-Wvisibility]
891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
| ^
crypto/testmgr.c:897:9: error: call to undeclared function 'prandom_u32_state'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
897 | return prandom_u32_state(rng) % ceil;
| ^
crypto/testmgr.c:900:40: warning: declaration of 'struct rnd_state' will not be visible outside of this function [-Wvisibility]
900 | static inline bool prandom_bool(struct rnd_state *rng)
| ^
>> crypto/testmgr.c:902:27: error: incompatible pointer types passing 'struct rnd_state *' to parameter of type 'struct rnd_state *' [-Werror,-Wincompatible-pointer-types]
902 | return prandom_u32_below(rng, 2);
| ^~~
crypto/testmgr.c:891:55: note: passing argument to parameter 'rng' here
891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
| ^
crypto/testmgr.c:905:48: warning: declaration of 'struct rnd_state' will not be visible outside of this function [-Wvisibility]
905 | static inline u32 prandom_u32_inclusive(struct rnd_state *rng,
| ^
crypto/testmgr.c:908:35: error: incompatible pointer types passing 'struct rnd_state *' to parameter of type 'struct rnd_state *' [-Werror,-Wincompatible-pointer-types]
908 | return floor + prandom_u32_below(rng, ceil - floor + 1);
| ^~~
crypto/testmgr.c:891:55: note: passing argument to parameter 'rng' here
891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
| ^
crypto/testmgr.c:912:51: warning: declaration of 'struct rnd_state' will not be visible outside of this function [-Wvisibility]
912 | static unsigned int generate_random_length(struct rnd_state *rng,
| ^
crypto/testmgr.c:915:39: error: incompatible pointer types passing 'struct rnd_state *' to parameter of type 'struct rnd_state *' [-Werror,-Wincompatible-pointer-types]
915 | unsigned int len = prandom_u32_below(rng, max_len + 1);
| ^~~
crypto/testmgr.c:891:55: note: passing argument to parameter 'rng' here
891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
| ^
crypto/testmgr.c:917:28: error: incompatible pointer types passing 'struct rnd_state *' to parameter of type 'struct rnd_state *' [-Werror,-Wincompatible-pointer-types]
917 | switch (prandom_u32_below(rng, 4)) {
| ^~~
crypto/testmgr.c:891:55: note: passing argument to parameter 'rng' here
891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
| ^
crypto/testmgr.c:930:31: error: incompatible pointer types passing 'struct rnd_state *' to parameter of type 'struct rnd_state *' [-Werror,-Wincompatible-pointer-types]
930 | if (len && prandom_u32_below(rng, 4) == 0)
| ^~~
crypto/testmgr.c:891:55: note: passing argument to parameter 'rng' here
891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
| ^
crypto/testmgr.c:936:36: warning: declaration of 'struct rnd_state' will not be visible outside of this function [-Wvisibility]
936 | static void flip_random_bit(struct rnd_state *rng, u8 *buf, size_t size)
| ^
crypto/testmgr.c:940:29: error: incompatible pointer types passing 'struct rnd_state *' to parameter of type 'struct rnd_state *' [-Werror,-Wincompatible-pointer-types]
940 | bitpos = prandom_u32_below(rng, size * 8);
| ^~~
crypto/testmgr.c:891:55: note: passing argument to parameter 'rng' here
891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
| ^
crypto/testmgr.c:945:37: warning: declaration of 'struct rnd_state' will not be visible outside of this function [-Wvisibility]
945 | static void flip_random_byte(struct rnd_state *rng, u8 *buf, size_t size)
| ^
crypto/testmgr.c:947:24: error: incompatible pointer types passing 'struct rnd_state *' to parameter of type 'struct rnd_state *' [-Werror,-Wincompatible-pointer-types]
947 | buf[prandom_u32_below(rng, size)] ^= 0xff;
| ^~~
crypto/testmgr.c:891:55: note: passing argument to parameter 'rng' here
891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
| ^
crypto/testmgr.c:951:34: warning: declaration of 'struct rnd_state' will not be visible outside of this function [-Wvisibility]
951 | static void mutate_buffer(struct rnd_state *rng, u8 *buf, size_t size)
| ^
crypto/testmgr.c:957:24: error: incompatible pointer types passing 'struct rnd_state *' to parameter of type 'struct rnd_state *' [-Werror,-Wincompatible-pointer-types]
957 | if (prandom_u32_below(rng, 4) == 0) {
| ^~~
crypto/testmgr.c:891:55: note: passing argument to parameter 'rng' here
891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
| ^
crypto/testmgr.c:958:52: error: incompatible pointer types passing 'struct rnd_state *' to parameter of type 'struct rnd_state *' [-Werror,-Wincompatible-pointer-types]
958 | num_flips = min_t(size_t, 1 << prandom_u32_below(rng, 8),
| ^~~
include/linux/minmax.h:213:49: note: expanded from macro 'min_t'
213 | #define min_t(type, x, y) __cmp_once(min, type, x, y)
| ^
include/linux/minmax.h:96:30: note: expanded from macro '__cmp_once'
96 | __cmp_once_unique(op, type, x, y, __UNIQUE_ID(x_), __UNIQUE_ID(y_))
| ^
include/linux/minmax.h:93:16: note: expanded from macro '__cmp_once_unique'
93 | ({ type ux = (x); type uy = (y); __cmp(op, ux, uy); })
| ^
crypto/testmgr.c:891:55: note: passing argument to parameter 'rng' here
891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
| ^
crypto/testmgr.c:961:20: error: incompatible pointer types passing 'struct rnd_state *' to parameter of type 'struct rnd_state *' [-Werror,-Wincompatible-pointer-types]
961 | flip_random_bit(rng, buf, size);
| ^~~
crypto/testmgr.c:936:47: note: passing argument to parameter 'rng' here
936 | static void flip_random_bit(struct rnd_state *rng, u8 *buf, size_t size)
| ^
crypto/testmgr.c:965:24: error: incompatible pointer types passing 'struct rnd_state *' to parameter of type 'struct rnd_state *' [-Werror,-Wincompatible-pointer-types]
965 | if (prandom_u32_below(rng, 4) == 0) {
| ^~~
crypto/testmgr.c:891:55: note: passing argument to parameter 'rng' here
891 | static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
| ^
crypto/testmgr.c:966:52: error: incompatible pointer types passing 'struct rnd_state *' to parameter of type 'struct rnd_state *' [-Werror,-Wincompatible-pointer-types]
966 | num_flips = min_t(size_t, 1 << prandom_u32_below(rng, 8), size);
| ^~~
include/linux/minmax.h:213:49: note: expanded from macro 'min_t'
213 | #define min_t(type, x, y) __cmp_once(min, type, x, y)
| ^
include/linux/minmax.h:96:30: note: expanded from macro '__cmp_once'
96 | __cmp_once_unique(op, type, x, y, __UNIQUE_ID(x_), __UNIQUE_ID(y_))
| ^
include/linux/minmax.h:93:16: note: expanded from macro '__cmp_once_unique'
93 | ({ type ux = (x); type uy = (y); __cmp(op, ux, uy); })
vim +/prandom_seed_state +883 crypto/testmgr.c
f2bb770ae89641 Eric Biggers 2019-04-11 873
f900fde2888360 Eric Biggers 2023-02-27 874 /*
f900fde2888360 Eric Biggers 2023-02-27 875 * The fuzz tests use prandom instead of the normal Linux RNG since they don't
f900fde2888360 Eric Biggers 2023-02-27 876 * need cryptographically secure random numbers. This greatly improves the
f900fde2888360 Eric Biggers 2023-02-27 877 * performance of these tests, especially if they are run before the Linux RNG
f900fde2888360 Eric Biggers 2023-02-27 878 * has been initialized or if they are run on a lockdep-enabled kernel.
f900fde2888360 Eric Biggers 2023-02-27 879 */
f900fde2888360 Eric Biggers 2023-02-27 880
f900fde2888360 Eric Biggers 2023-02-27 @881 static inline void init_rnd_state(struct rnd_state *rng)
f900fde2888360 Eric Biggers 2023-02-27 882 {
f900fde2888360 Eric Biggers 2023-02-27 @883 prandom_seed_state(rng, get_random_u64());
f900fde2888360 Eric Biggers 2023-02-27 884 }
f900fde2888360 Eric Biggers 2023-02-27 885
f900fde2888360 Eric Biggers 2023-02-27 886 static inline u8 prandom_u8(struct rnd_state *rng)
f900fde2888360 Eric Biggers 2023-02-27 887 {
f900fde2888360 Eric Biggers 2023-02-27 @888 return prandom_u32_state(rng);
f900fde2888360 Eric Biggers 2023-02-27 889 }
f900fde2888360 Eric Biggers 2023-02-27 890
f900fde2888360 Eric Biggers 2023-02-27 @891 static inline u32 prandom_u32_below(struct rnd_state *rng, u32 ceil)
f900fde2888360 Eric Biggers 2023-02-27 892 {
f900fde2888360 Eric Biggers 2023-02-27 893 /*
f900fde2888360 Eric Biggers 2023-02-27 894 * This is slightly biased for non-power-of-2 values of 'ceil', but this
f900fde2888360 Eric Biggers 2023-02-27 895 * isn't important here.
f900fde2888360 Eric Biggers 2023-02-27 896 */
f900fde2888360 Eric Biggers 2023-02-27 897 return prandom_u32_state(rng) % ceil;
f900fde2888360 Eric Biggers 2023-02-27 898 }
f900fde2888360 Eric Biggers 2023-02-27 899
f900fde2888360 Eric Biggers 2023-02-27 900 static inline bool prandom_bool(struct rnd_state *rng)
f900fde2888360 Eric Biggers 2023-02-27 901 {
f900fde2888360 Eric Biggers 2023-02-27 @902 return prandom_u32_below(rng, 2);
f900fde2888360 Eric Biggers 2023-02-27 903 }
f900fde2888360 Eric Biggers 2023-02-27 904
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH 05/18] mtd: tests: Include <linux/prandom.h> instead of <linux/random.h>
2024-09-05 12:17 ` [PATCH 05/18] mtd: tests: Include <linux/prandom.h> instead of <linux/random.h> Uros Bizjak
@ 2024-09-06 15:10 ` Miquel Raynal
2024-09-06 15:58 ` Uros Bizjak
0 siblings, 1 reply; 32+ messages in thread
From: Miquel Raynal @ 2024-09-06 15:10 UTC (permalink / raw)
To: Uros Bizjak, linux-kernel
Cc: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra, linux-mtd
On Thu, 2024-09-05 at 12:17:13 UTC, Uros Bizjak wrote:
> Usage of pseudo-random functions requires inclusion of
> <linux/prandom.h> header instead of <linux/random.h>.
>
> Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
> Cc: Miquel Raynal <miquel.raynal@bootlin.com>
> Cc: Richard Weinberger <richard@nod.at>
> Cc: Vignesh Raghavendra <vigneshr@ti.com>
> Cc: linux-mtd@lists.infradead.org
Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next, thanks.
Miquel
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH 17/18] random: Do not include <linux/prandom.h>
2024-09-06 14:21 ` kernel test robot
@ 2024-09-06 15:46 ` Uros Bizjak
0 siblings, 0 replies; 32+ messages in thread
From: Uros Bizjak @ 2024-09-06 15:46 UTC (permalink / raw)
To: kernel test robot
Cc: linux-kernel, llvm, oe-kbuild-all, Theodore Ts'o,
Jason A. Donenfeld
On Fri, Sep 6, 2024 at 4:22 PM kernel test robot <lkp@intel.com> wrote:
>
> Hi Uros,
>
> kernel test robot noticed the following build errors:
>
> [auto build test ERROR on akpm-mm/mm-nonmm-unstable]
> [also build test ERROR on mtd/mtd/next mtd/mtd/fixes linus/master v6.11-rc6 next-20240906]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use '--base' as documented in
> https://git-scm.com/docs/git-format-patch#_base_tree_information]
>
> url: https://github.com/intel-lab-lkp/linux/commits/Uros-Bizjak/x86-kaslr-Include-linux-prandom-h-instead-of-linux-random-h/20240905-202710
> base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-nonmm-unstable
> patch link: https://lore.kernel.org/r/20240905122020.872466-18-ubizjak%40gmail.com
> patch subject: [PATCH 17/18] random: Do not include <linux/prandom.h>
> config: um-randconfig-002-20240906 (https://download.01.org/0day-ci/archive/20240906/202409062123.F3r9hB9z-lkp@intel.com/config)
> compiler: clang version 20.0.0git (https://github.com/llvm/llvm-project 05f5a91d00b02f4369f46d076411c700755ae041)
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240906/202409062123.F3r9hB9z-lkp@intel.com/reproduce)
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202409062123.F3r9hB9z-lkp@intel.com/
>
> All error/warnings (new ones prefixed by >>):
>
> In file included from crypto/testmgr.c:27:
Ah, here we have a negative config flag, enabled for allyesconfig, so
- the source is disabled with allyesconfig.
#ifdef CONFIG_CRYPTO_MANAGER_DISABLE_TESTS
...
#endif
Patch is as simple as:
--cut here--
diff --git a/crypto/testmgr.c b/crypto/testmgr.c
index f02cb075bd68..eeb7edd99a93 100644
--- a/crypto/testmgr.c
+++ b/crypto/testmgr.c
@@ -23,7 +23,7 @@
#include <linux/fips.h>
#include <linux/module.h>
#include <linux/once.h>
-#include <linux/random.h>
+#include <linux/prandom.h>
#include <linux/scatterlist.h>
#include <linux/slab.h>
#include <linux/string.h>
--cut here--
Will add the patch to v2 series.
Thanks to the kernel test robot,
Uros.
^ permalink raw reply related [flat|nested] 32+ messages in thread
* Re: [PATCH 05/18] mtd: tests: Include <linux/prandom.h> instead of <linux/random.h>
2024-09-06 15:10 ` Miquel Raynal
@ 2024-09-06 15:58 ` Uros Bizjak
2024-09-09 9:49 ` Miquel Raynal
0 siblings, 1 reply; 32+ messages in thread
From: Uros Bizjak @ 2024-09-06 15:58 UTC (permalink / raw)
To: Miquel Raynal
Cc: linux-kernel, Richard Weinberger, Vignesh Raghavendra, linux-mtd
On Fri, Sep 6, 2024 at 5:10 PM Miquel Raynal <miquel.raynal@bootlin.com> wrote:
>
> On Thu, 2024-09-05 at 12:17:13 UTC, Uros Bizjak wrote:
> > Usage of pseudo-random functions requires inclusion of
> > <linux/prandom.h> header instead of <linux/random.h>.
> >
> > Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
> > Cc: Miquel Raynal <miquel.raynal@bootlin.com>
> > Cc: Richard Weinberger <richard@nod.at>
> > Cc: Vignesh Raghavendra <vigneshr@ti.com>
> > Cc: linux-mtd@lists.infradead.org
>
> Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next, thanks.
Miquel, is it possible to just ACK the patch for now? The series
touches many parts of the kernel, so I guess it is best to harvest
Acked-by:s in this stage of development and commit all the patches
some time after the merge window. This will avoid merge conflicts with
the series.
Thanks,
Uros.
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH 05/18] mtd: tests: Include <linux/prandom.h> instead of <linux/random.h>
2024-09-06 15:58 ` Uros Bizjak
@ 2024-09-09 9:49 ` Miquel Raynal
0 siblings, 0 replies; 32+ messages in thread
From: Miquel Raynal @ 2024-09-09 9:49 UTC (permalink / raw)
To: Uros Bizjak
Cc: linux-kernel, Richard Weinberger, Vignesh Raghavendra, linux-mtd
Hi Uros,
ubizjak@gmail.com wrote on Fri, 6 Sep 2024 17:58:39 +0200:
> On Fri, Sep 6, 2024 at 5:10 PM Miquel Raynal <miquel.raynal@bootlin.com> wrote:
> >
> > On Thu, 2024-09-05 at 12:17:13 UTC, Uros Bizjak wrote:
> > > Usage of pseudo-random functions requires inclusion of
> > > <linux/prandom.h> header instead of <linux/random.h>.
> > >
> > > Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
> > > Cc: Miquel Raynal <miquel.raynal@bootlin.com>
> > > Cc: Richard Weinberger <richard@nod.at>
> > > Cc: Vignesh Raghavendra <vigneshr@ti.com>
> > > Cc: linux-mtd@lists.infradead.org
> >
> > Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next, thanks.
>
> Miquel, is it possible to just ACK the patch for now? The series
> touches many parts of the kernel, so I guess it is best to harvest
> Acked-by:s in this stage of development and commit all the patches
> some time after the merge window. This will avoid merge conflicts with
> the series.
Changing an include with a more specific include didn't look like a
dangerous change, but I'm fine dropping the patch. Please mention it
next time, because I didn't see it.
Thanks,
Miquèl
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH 15/18] lib/test_scanf: Include <linux/prandom.h> instead of <linux/random.h>
2024-09-05 12:17 ` [PATCH 15/18] lib/test_scanf: " Uros Bizjak
@ 2024-09-09 12:54 ` Petr Mladek
0 siblings, 0 replies; 32+ messages in thread
From: Petr Mladek @ 2024-09-09 12:54 UTC (permalink / raw)
To: Uros Bizjak
Cc: linux-kernel, Steven Rostedt, Andy Shevchenko, Rasmus Villemoes,
Sergey Senozhatsky, Andrew Morton
On Thu 2024-09-05 14:17:23, Uros Bizjak wrote:
> Usage of pseudo-random functions requires inclusion of
> <linux/prandom.h> header instead of <linux/random.h>.
>
> Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Looks good to me:
Acked-by: Petr Mladek <pmladek@suse.com>
Best Regards,
Petr
^ permalink raw reply [flat|nested] 32+ messages in thread
end of thread, other threads:[~2024-09-09 12:54 UTC | newest]
Thread overview: 32+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-05 12:17 [PATCH 00/18] random: Include <linux/percpu.h> and resolve circular include dependency Uros Bizjak
2024-09-05 12:17 ` [PATCH 01/18] x86/kaslr: Include <linux/prandom.h> instead of <linux/random.h> Uros Bizjak
2024-09-05 12:17 ` [PATCH 02/18] drm/i915/selftests: " Uros Bizjak
2024-09-05 13:06 ` Jani Nikula
2024-09-05 12:17 ` [PATCH 03/18] drm/lib: " Uros Bizjak
2024-09-05 12:17 ` [PATCH 04/18] media: vivid: Include <linux/prandom.h> in vivid-vid-cap.c Uros Bizjak
2024-09-05 12:17 ` [PATCH 05/18] mtd: tests: Include <linux/prandom.h> instead of <linux/random.h> Uros Bizjak
2024-09-06 15:10 ` Miquel Raynal
2024-09-06 15:58 ` Uros Bizjak
2024-09-09 9:49 ` Miquel Raynal
2024-09-05 12:17 ` [PATCH 06/18] fscrypt: " Uros Bizjak
2024-09-05 23:02 ` Eric Biggers
2024-09-06 8:09 ` Uros Bizjak
2024-09-05 12:17 ` [PATCH 07/18] scsi: libfcoe: " Uros Bizjak
2024-09-05 12:17 ` [PATCH 08/18] bpf: " Uros Bizjak
2024-09-05 12:17 ` [PATCH 09/18] lib/interval_tree_test.c: " Uros Bizjak
2024-09-05 12:17 ` [PATCH 10/18] kunit: string-stream-test: " Uros Bizjak
2024-09-05 12:17 ` [PATCH 11/18] random32: " Uros Bizjak
2024-09-05 12:17 ` [PATCH 12/18] lib/rbtree-test: " Uros Bizjak
2024-09-05 12:17 ` [PATCH 13/18] bpf/tests: " Uros Bizjak
2024-09-05 12:17 ` [PATCH 14/18] lib/test_parman: " Uros Bizjak
2024-09-05 12:17 ` [PATCH 15/18] lib/test_scanf: " Uros Bizjak
2024-09-09 12:54 ` Petr Mladek
2024-09-05 12:17 ` [PATCH 16/18] netem: Include <linux/prandom.h> in sch_netem.c Uros Bizjak
2024-09-05 12:17 ` [PATCH 17/18] random: Do not include <linux/prandom.h> Uros Bizjak
2024-09-06 13:30 ` kernel test robot
2024-09-06 14:21 ` kernel test robot
2024-09-06 15:46 ` Uros Bizjak
2024-09-05 12:17 ` [PATCH 18/18] prandom: Include <linux/percpu.h> Uros Bizjak
2024-09-05 12:40 ` [PATCH 00/18] random: Include <linux/percpu.h> and resolve circular include dependency Andy Shevchenko
2024-09-05 13:03 ` Uros Bizjak
2024-09-05 15:36 ` Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox