random: Resolve circular include dependency and include <linux/percpu.h>
Subsystems (23)
v2 cover random: Resolve circular include dependency and include <linux/percpu.h>
Resent due to missing linux-kernel@ mailing list inclusion.
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 the 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--
We would like to include <linux/percpu.h> in <linux/prandom.h>. In [1] we would like to repurpose __percpu tag as a named address space qualifier, where __percpu macro uses defines from <linux/percpu.h>.
The major roadblock to inclusion of <linux/percpu.h> is the above mentioned legacy inclusion of <linux/prandom.h> in <linux/random.h> that causes circular include dependency that prevents <linux/percpu.h> inclusion.
This patch series is the "nice cleanup" part that:
a) Substitutes the inclusion of <linux/random.h> with the inclusion of <linux/prandom.h> where needed (patches 1 - 17).
b) Removes legacy inclusion of <linux/prandom.h> from <linux/random.h> (patch 18).
c) Includes <linux/percpu.h> in <linux/prandom.h> (patch 19).
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/[email protected]/
---
v2: - Reword commit messages to mention the removal of legacy inclusion
of <linux/prandom.h> from <linux/random.h>
- Add missing substitution in crypto/testmgr.c
(reported by kernel test robot)
- Add Acked-by:.
Uros Bizjak (19):
x86/kaslr: Include <linux/prandom.h> instead of <linux/random.h>
crypto: testmgr: 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/once.h> in fs/crypto/keyring.c
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> in <linux/random.h>
prandom: Include <linux/percpu.h> in <linux/prandom.h>
arch/x86/mm/kaslr.c | 2 +- crypto/testmgr.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 | 1 + 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 + 23 files changed, 22 insertions(+), 24 deletions(-)
Signature · 1 line
2.46.0
PATCH RESEND v2 1/19 x86/kaslr: Include <linux/prandom.h> instead of <linux/random.h>
Substitute the inclusion of <linux/random.h> header with <linux/prandom.h> to allow the removal of legacy inclusion of <linux/prandom.h> from <linux/random.h>.
--- arch/x86/mm/kaslr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/mm/kaslr.c +1 -1
@@ -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>
Signature · 1 line
2.46.0
PATCH RESEND v2 2/19 crypto: testmgr: Include <linux/prandom.h> instead of <linux/random.h>
In reply to Uros BizjakSubstitute the inclusion of <linux/random.h> header with <linux/prandom.h> to allow the removal of legacy inclusion of <linux/prandom.h> from <linux/random.h>.
--- crypto/testmgr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
crypto/testmgr.c +1 -1
@@ -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>
Signature · 1 line
2.46.0
PATCH RESEND v2 3/19 drm/i915/selftests: Include <linux/prandom.h> instead of <linux/random.h>
In reply to Uros BizjakSubstitute the inclusion of <linux/random.h> header with <linux/prandom.h> to allow the removal of legacy inclusion of <linux/prandom.h> from <linux/random.h>.
--- 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(-)
drivers/gpu/drm/i915/selftests/i915_gem.c +1 -1
@@ -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"
drivers/gpu/drm/i915/selftests/i915_random.h +1 -1
@@ -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"
drivers/gpu/drm/i915/selftests/scatterlist.c +1 -1
@@ -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"
Signature · 1 line
2.46.0
PATCH RESEND v2 4/19 drm/lib: Include <linux/prandom.h> instead of <linux/random.h>
In reply to Uros BizjakSubstitute the inclusion of <linux/random.h> header with <linux/prandom.h> to allow the removal of legacy inclusion of <linux/prandom.h> from <linux/random.h>.
--- drivers/gpu/drm/lib/drm_random.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/lib/drm_random.h +1 -1
@@ -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__; \
Signature · 1 line
2.46.0
PATCH RESEND v2 5/19 media: vivid: Include <linux/prandom.h> in vivid-vid-cap.c
In reply to Uros BizjakSubstitute the inclusion of <linux/random.h> header with <linux/prandom.h> to allow the removal of legacy inclusion of <linux/prandom.h> from <linux/random.h>.
--- drivers/media/test-drivers/vivid/vivid-vid-cap.c | 1 + 1 file changed, 1 insertion(+)
drivers/media/test-drivers/vivid/vivid-vid-cap.c +1 -0
@@ -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>
Signature · 1 line
2.46.0
PATCH RESEND v2 6/19 mtd: tests: Include <linux/prandom.h> instead of <linux/random.h>
In reply to Uros BizjakSubstitute the inclusion of <linux/random.h> header with <linux/prandom.h> to allow the removal of legacy inclusion of <linux/prandom.h> from <linux/random.h>.
--- 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(-)
drivers/mtd/tests/oobtest.c +1 -1
@@ -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"
drivers/mtd/tests/pagetest.c +1 -1
@@ -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"
drivers/mtd/tests/subpagetest.c +1 -1
@@ -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"
Signature · 1 line
2.46.0
PATCH RESEND v2 7/19 fscrypt: Include <linux/once.h> in fs/crypto/keyring.c
In reply to Uros BizjakInclude <linux/once.h> header to allow the removal of legacy inclusion of <linux/prandom.h> from <linux/random.h>.
---
v2: Include <linux/once.h> instead of <linux/prandom.h>
--- fs/crypto/keyring.c | 1 + 1 file changed, 1 insertion(+)
fs/crypto/keyring.c +1 -0
@@ -22,6 +22,7 @@#include <crypto/skcipher.h> #include <linux/key-type.h> #include <linux/random.h> +#include <linux/once.h> #include <linux/seq_file.h> #include "fscrypt_private.h"
Signature · 1 line
2.46.0
PATCH RESEND v2 8/19 scsi: libfcoe: Include <linux/prandom.h> instead of <linux/random.h>
In reply to Uros BizjakSubstitute the inclusion of <linux/random.h> header with <linux/prandom.h> to allow the removal of legacy inclusion of <linux/prandom.h> from <linux/random.h>.
--- include/scsi/libfcoe.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/scsi/libfcoe.h +1 -1
@@ -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>
Signature · 1 line
2.46.0
PATCH RESEND v2 9/19 bpf: Include <linux/prandom.h> instead of <linux/random.h>
In reply to Uros BizjakSubstitute the inclusion of <linux/random.h> header with <linux/prandom.h> to allow the removal of legacy inclusion of <linux/prandom.h> from <linux/random.h>.
--- kernel/bpf/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/bpf/core.c +1 -1
@@ -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>
Signature · 1 line
2.46.0
PATCH RESEND v2 10/19 lib/interval_tree_test.c: Include <linux/prandom.h> instead of <linux/random.h>
In reply to Uros BizjakSubstitute the inclusion of <linux/random.h> header with <linux/prandom.h> to allow the removal of legacy inclusion of <linux/prandom.h> from <linux/random.h>.
--- lib/interval_tree_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/interval_tree_test.c +1 -1
@@ -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>
Signature · 1 line
2.46.0
PATCH RESEND v2 11/19 kunit: string-stream-test: Include <linux/prandom.h> instead of <linux/random.h>
In reply to Uros BizjakSubstitute the inclusion of <linux/random.h> header with <linux/prandom.h> to allow the removal of legacy inclusion of <linux/prandom.h> from <linux/random.h>.
--- lib/kunit/string-stream-test.c | 1 + 1 file changed, 1 insertion(+)
lib/kunit/string-stream-test.c +1 -0
@@ -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>
Signature · 1 line
2.46.0
PATCH RESEND v2 12/19 random32: Include <linux/prandom.h> instead of <linux/random.h>
In reply to Uros BizjakSubstitute the inclusion of <linux/random.h> header with <linux/prandom.h> to allow the removal of legacy inclusion of <linux/prandom.h> from <linux/random.h>.
--- lib/random32.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/random32.c +1 -1
@@ -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>
Signature · 1 line
2.46.0
PATCH RESEND v2 13/19 lib/rbtree-test: Include <linux/prandom.h> instead of <linux/random.h>
In reply to Uros BizjakSubstitute the inclusion of <linux/random.h> header with <linux/prandom.h> to allow the removal of legacy inclusion of <linux/prandom.h> from <linux/random.h>.
--- lib/rbtree_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/rbtree_test.c +1 -1
@@ -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>
Signature · 1 line
2.46.0
PATCH RESEND v2 14/19 bpf/tests: Include <linux/prandom.h> instead of <linux/random.h>
In reply to Uros BizjakSubstitute the inclusion of <linux/random.h> header with <linux/prandom.h> to allow the removal of legacy inclusion of <linux/prandom.h> from <linux/random.h>.
--- lib/test_bpf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/test_bpf.c +1 -1
@@ -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>
Signature · 1 line
2.46.0
PATCH RESEND v2 15/19 lib/test_parman: Include <linux/prandom.h> instead of <linux/random.h>
In reply to Uros BizjakSubstitute the inclusion of <linux/random.h> header with <linux/prandom.h> to allow the removal of legacy inclusion of <linux/prandom.h> from <linux/random.h>.
--- lib/test_parman.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/test_parman.c +1 -1
@@ -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 */
Signature · 1 line
2.46.0
PATCH RESEND v2 16/19 lib/test_scanf: Include <linux/prandom.h> instead of <linux/random.h>
In reply to Uros BizjakSubstitute the inclusion of <linux/random.h> header with <linux/prandom.h> to allow the removal of legacy inclusion of <linux/prandom.h> from <linux/random.h>.
--- lib/test_scanf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/test_scanf.c +1 -1
@@ -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>
Signature · 1 line
2.46.0
PATCH RESEND v2 17/19 netem: Include <linux/prandom.h> in sch_netem.c
In reply to Uros BizjakInclude <linux/prandom.h> header to allow the removal of legacy inclusion of <linux/prandom.h> from <linux/random.h>.
--- net/sched/sch_netem.c | 1 + 1 file changed, 1 insertion(+)
net/sched/sch_netem.c +1 -0
@@ -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>
Signature · 1 line
2.46.0
PATCH RESEND v2 18/19 random: Do not include <linux/prandom.h> in <linux/random.h>
In reply to Uros BizjakFiles that use prandom infrastructure are now converted to use <linux/prandom.h> header instead of <linux/random.h>. Remove the legacy inclusion of <linux/prandom.h> from <linux/random.h>.
This is the "nice cleanup" part, wished in c0842fbc1b18.
--- include/linux/random.h | 7 ------- 1 file changed, 7 deletions(-)
include/linux/random.h +0 -7
@@ -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);
Signature · 1 line
2.46.0
PATCH RESEND v2 19/19 prandom: Include <linux/percpu.h> in <linux/prandom.h>
In reply to Uros Bizjak<linux/percpu.h> include was removed from <linux/prandom.h> in d9f29deb7fe8 ("prandom: Remove unused include") because this inclusion broke arm64 due to a circular dependency on include files.
__percpu tag is defined in include/linux/compiler_types.h, so there is currently 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>.
The circular dependency was removed in xxxxxxxxxxxx ("random: Do not include <linux/prandom.h> in <linux/random.h>") and it cleared the path for the inclusion of <linux/percpu.h> in <linux/prandom.h>.
This patch is basically a revert of d9f29deb7fe8
("prandom: Remove unused include").
[1] https://lore.kernel.org/lkml/[email protected]/
--- include/linux/prandom.h | 1 + 1 file changed, 1 insertion(+)
include/linux/prandom.h +1 -0
@@ -10,6 +10,7 @@#include <linux/types.h> #include <linux/once.h> +#include <linux/percpu.h> #include <linux/random.h> struct rnd_state {
Signature · 1 line
2.46.0
Re: [PATCH RESEND v2 06/19] mtd: tests: Include <linux/prandom.h> instead of <linux/random.h>
In reply to Uros BizjakHi Uros,
[email protected] wrote on Mon, 9 Sep 2024 09:53:49 +0200:
Quoted 3 lines
Substitute the inclusion of <
linux/random.h> header with <linux/prandom.h> to allow the removal of legacy inclusion of <linux/prandom.h> from <linux/random.h>.
Quoted 5 lines
Signed-off-by Uros Bizjak <[email protected]>Cc Miquel Raynal <[email protected]>Cc Richard Weinberger <[email protected]>Cc Vignesh Raghavendra <[email protected]>
Miquèl
Re: [PATCH RESEND v2 05/19] media: vivid: Include <linux/prandom.h> in vivid-vid-cap.c
In reply to Uros BizjakQuoted 5 lines · Uros Bizjak
Substitute the inclusion of <
linux/random.h> header with <linux/prandom.h> to allow the removal of legacy inclusion of <linux/prandom.h> from <linux/random.h>.Signed-off-by Uros Bizjak <[email protected]>
Regards,
Hans
Quoted 19 lines
--- drivers/media/test-drivers/vivid/vivid-vid-cap.c | 1 + 1 file changed, 1 insertion(+)drivers/media/test-drivers/vivid/vivid-vid-cap.c +1
-0@@ -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>
Re: [PATCH RESEND v2 16/19] lib/test_scanf: Include <linux/prandom.h> instead of <linux/random.h>
In reply to Uros BizjakQuoted 5 lines · Uros Bizjak
Substitute the inclusion of <
linux/random.h> header with <linux/prandom.h> to allow the removal of legacy inclusion of <linux/prandom.h> from <linux/random.h>.Signed-off-by Uros Bizjak <[email protected]>
I have just acked v1 and missed that there already is v2. Just for record:
Best Regards,
Petr
Jason A. Donenfeld
maintainerHi Uros,
Quoted 7 lines · Uros Bizjak
a) Substitutes the inclusion of <
linux/random.h> with the inclusion of <linux/prandom.h> where needed (patches 1 - 17).b) Removes legacy inclusion of <
linux/prandom.h> from <linux/random.h> (patch 18).c) Includes <
linux/percpu.h> in <linux/prandom.h> (patch 19).
Thanks for doing this. That seems like a fine initiative to me. (I'm also curious about the future percpu changes you've got planned.)
Tree-wise, were you expecting me to take this through random.git? And if so, what timeframe did you have in mind? For 6.12 next week (can you poke folks for acks in time?), or punt it for 6.13? Or did you have a different tree in mind for treewide changes (in which case, I'll send you an ack for the [p]random.h changes).
Regards,
Jason
Quoted 11 lines · Jason A. Donenfeld
Quoted 7 lines · Uros Bizjak
a) Substitutes the inclusion of <
linux/random.h> with the inclusion of <linux/prandom.h> where needed (patches 1 - 17).b) Removes legacy inclusion of <
linux/prandom.h> from <linux/random.h> (patch 18).c) Includes <
linux/percpu.h> in <linux/prandom.h> (patch 19).Thanks for doing this. That seems like a fine initiative to me. (I'm also curious about the future percpu changes you've got planned.)
As explained in the cover letter, recent GCCs are able to track address space of variables in percpu address space from the declaration to its usage site. There are certain rules regarding casts of variables and their pointers (when this named address space is not considered a subspace of the generic address space), so it is possible to create much more effective checks for cast-from-as type casts than what sparse can achieve.
Besides GCC, clang can define various named address space via address_space attribute:
--cut here--
#define __as(N) __attribute__((address_space(N)))
void *foo(void __as(1) *x) { return x; } // error
void *bar(void __as(1) *x) { return (void *)x; } // fine --cut here--
When compiling this, the compiler returns:
clang-as.c:3:37: error: returning '__as(1) void *' from a function with result type 'void *' changes address space of pointer
Although clang currently errors out when __seg_gs and __seg_fs named address space designators are used, we can explore its named address spaces functionality to implement percpu checks for all targets. The percpu address space checks patchset, referred to in the cover letter, also supports this functionality when per_cpu_qual is defined to __attribute__((address_space(N))).
Perhaps we can use different address spaces to also handle __user, __iomem and __rcu address spaces. This way the compiler will be able to handle address space checks instead of sparse.
Quoted 5 lines
Tree-wise, were you expecting me to take this through random.git? And if so, what timeframe did you have in mind? For 6.12 next week (can you poke folks for acks in time?), or punt it for 6.13? Or did you have a different tree in mind for treewide changes (in which case, I'll send you an ack for the [p]random.h changes).
I think that the best approach is to target this patchset for linux 6.13 via random.git tree. I will prepare a v3 after 6.12rc1, so when committed to random.git, the patchset will be able to spend some time in linux-next. This way, there will be plenty of time for CI robots to do additional checks also for some less popular targets (although individual patches are dead simple, removing these kinds of "legacy" includes can be tricky), and I will also be able to collect Acked-by:s in the meantime.
While the patchset is an improvement by itself, its inclusion is not time sensitive. The follow up percpu named address checking functionality requires a very recent feature (__typeof_unqual__ keyword), which is only supported in recent compilers (gcc-14 and clang-20). Besides compiler support, sparse doesn't know about __typeof_unqual__, resulting in broken type tracing and hundreds of sparse errors with C=1 due to unknown keyword.
So, I think we are not in a hurry and can take the slow and safe path.
Thanks and best regards,
Uros.
Jason A. Donenfeld
maintainerHi Uros,
Quoted 8 lines · Uros Bizjak
Besides GCC, clang can define various named address space via
address_spaceattribute:--cut here--
#define__as(N)__attribute__((address_space(N)))void *foo(void
__as(1)*x) { return x; } // error
Quoted 7 lines
void *bar(void
__as(1)*x) { return (void *)x; } // fine --cut here--When compiling this, the compiler returns:
clang-as.c:3:37: error: returning '
__as(1)void *' from a function with result type 'void *' changes address space of pointer
Super cool. Looking forward to having it all wired up and the bugs we'll find with it.
Quoted 17 lines
I think that the best approach is to target this patchset for linux 6.13 via random.git tree. I will prepare a v3 after 6.12rc1, so when committed to random.git, the patchset will be able to spend some time in linux-next. This way, there will be plenty of time for CI robots to do additional checks also for some less popular targets (although individual patches are dead simple, removing these kinds of "legacy" includes can be tricky), and I will also be able to collect Acked-by:s in the meantime.
While the patchset is an improvement by itself, its inclusion is not time sensitive. The follow up percpu named address checking functionality requires a very recent feature (
__typeof_unqual__keyword), which is only supported in recent compilers (gcc-14 and clang-20). Besides compiler support, sparse doesn't know about__typeof_unqual__, resulting in broken type tracing and hundreds of sparse errors with C=1 due to unknown keyword.
Quoted 1 line
So, I think we are not in a hurry and can take the slow and safe path.
Okay, sure, that sounds good to me. I'll keep my eyes open for v3 in a few weeks then.
Jason
Re: [PATCH RESEND v2 07/19] fscrypt: Include <linux/once.h> in fs/crypto/keyring.c
In reply to Uros BizjakQuoted 18 lines · Uros Bizjak
Include <
linux/once.h> header to allow the removal of legacy inclusion of <linux/prandom.h> from <linux/random.h>.Signed-off-by Uros Bizjak <[email protected]>Cc Eric Biggers <[email protected]>Cc "Theodore Y. Ts'o" <[email protected]>Cc Jaegeuk Kim <[email protected]>---
v2: Include <linux/once.h> instead of <linux/prandom.h>--- fs/crypto/keyring.c | 1 + 1 file changed, 1 insertion(+)fs/crypto/keyring.c +0
-0
fs/crypto/keyring.c line 28
Quoted 7 lines
fs/crypto/keyring.c +1
-0@@ -22,6 +22,7 @@#include <crypto/skcipher.h> #include <linux/key-type.h> #include <linux/random.h> +#include <linux/once.h> #include <linux/seq_file.h> #include "fscrypt_private.h"
- Eric
Re: [PATCH RESEND v2 08/19] scsi: libfcoe: Include <linux/prandom.h> instead of <linux/random.h>
In reply to Uros BizjakQuoted 17 lines · Uros Bizjak
Substitute the inclusion of <
linux/random.h> header with <linux/prandom.h> to allow the removal of legacy inclusion of <linux/prandom.h> from <linux/random.h>.Signed-off-by Uros Bizjak <[email protected]>Cc Hannes Reinecke <[email protected]>Cc "James E.J. Bottomley" <[email protected]>Cc "Martin K. Petersen" <[email protected]>--- include/scsi/libfcoe.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)include/scsi/libfcoe.h +0
-0
include/scsi/libfcoe.h line 21
Quoted 8 lines
include/scsi/libfcoe.h +1
-1@@ -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>
Re: [PATCH RESEND v2 02/19] crypto: testmgr: Include <linux/prandom.h> instead of <linux/random.h>
In reply to Uros BizjakQuoted 10 lines · Uros Bizjak
Substitute the inclusion of <
linux/random.h> header with <linux/prandom.h> to allow the removal of legacy inclusion of <linux/prandom.h> from <linux/random.h>.Signed-off-by Uros Bizjak <[email protected]>Cc Herbert Xu <[email protected]>Cc "David S. Miller" <[email protected]>---
crypto/testmgr.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt