* [PATCH] s390/kaslr: Fix casts in get_random
@ 2020-02-08 14:10 Nathan Chancellor
2020-02-08 17:12 ` Nick Desaulniers
2020-02-08 20:17 ` Joe Perches
0 siblings, 2 replies; 5+ messages in thread
From: Nathan Chancellor @ 2020-02-08 14:10 UTC (permalink / raw)
To: Heiko Carstens, Vasily Gorbik, Christian Borntraeger
Cc: linux-s390, linux-kernel, clang-built-linux, Nathan Chancellor
Clang warns:
../arch/s390/boot/kaslr.c:78:25: warning: passing 'char *' to parameter
of type 'const u8 *' (aka 'const unsigned char *') converts between
pointers to integer
types with different sign [-Wpointer-sign]
(char *) entropy, (char *) entropy,
^~~~~~~~~~~~~~~~
../arch/s390/include/asm/cpacf.h:280:28: note: passing argument to
parameter 'src' here
u8 *dest, const u8 *src, long src_len)
^
2 warnings generated.
Fix the cast to match what else is done in this function.
Fixes: b2d24b97b2a9 ("s390/kernel: add support for kernel address space layout randomization (KASLR)")
Link: https://github.com/ClangBuiltLinux/linux/issues/862
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
arch/s390/boot/kaslr.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/s390/boot/kaslr.c b/arch/s390/boot/kaslr.c
index 5d12352545c5..5591243d673e 100644
--- a/arch/s390/boot/kaslr.c
+++ b/arch/s390/boot/kaslr.c
@@ -75,7 +75,7 @@ static unsigned long get_random(unsigned long limit)
*(unsigned long *) prng.parm_block ^= seed;
for (i = 0; i < 16; i++) {
cpacf_kmc(CPACF_KMC_PRNG, prng.parm_block,
- (char *) entropy, (char *) entropy,
+ (u8 *) entropy, (u8 *) entropy,
sizeof(entropy));
memcpy(prng.parm_block, entropy, sizeof(entropy));
}
--
2.25.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] s390/kaslr: Fix casts in get_random 2020-02-08 14:10 [PATCH] s390/kaslr: Fix casts in get_random Nathan Chancellor @ 2020-02-08 17:12 ` Nick Desaulniers 2020-02-08 20:17 ` Joe Perches 1 sibling, 0 replies; 5+ messages in thread From: Nick Desaulniers @ 2020-02-08 17:12 UTC (permalink / raw) To: Nathan Chancellor Cc: Heiko Carstens, Vasily Gorbik, Christian Borntraeger, linux-s390, LKML, clang-built-linux On Sat, Feb 8, 2020 at 3:11 PM Nathan Chancellor <natechancellor@gmail.com> wrote: > > Clang warns: > > ../arch/s390/boot/kaslr.c:78:25: warning: passing 'char *' to parameter > of type 'const u8 *' (aka 'const unsigned char *') converts between > pointers to integer > types with different sign [-Wpointer-sign] > (char *) entropy, (char *) entropy, > ^~~~~~~~~~~~~~~~ > ../arch/s390/include/asm/cpacf.h:280:28: note: passing argument to > parameter 'src' here > u8 *dest, const u8 *src, long src_len) > ^ > 2 warnings generated. > > Fix the cast to match what else is done in this function. > > Fixes: b2d24b97b2a9 ("s390/kernel: add support for kernel address space layout randomization (KASLR)") > Link: https://github.com/ClangBuiltLinux/linux/issues/862 > Signed-off-by: Nathan Chancellor <natechancellor@gmail.com> Thanks for the patch! Reviewed-by: Nick Desaulniers <ndesaulniers@google.com> > --- > arch/s390/boot/kaslr.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/s390/boot/kaslr.c b/arch/s390/boot/kaslr.c > index 5d12352545c5..5591243d673e 100644 > --- a/arch/s390/boot/kaslr.c > +++ b/arch/s390/boot/kaslr.c > @@ -75,7 +75,7 @@ static unsigned long get_random(unsigned long limit) > *(unsigned long *) prng.parm_block ^= seed; > for (i = 0; i < 16; i++) { > cpacf_kmc(CPACF_KMC_PRNG, prng.parm_block, > - (char *) entropy, (char *) entropy, > + (u8 *) entropy, (u8 *) entropy, > sizeof(entropy)); > memcpy(prng.parm_block, entropy, sizeof(entropy)); > } > -- > 2.25.0 > > -- > You received this message because you are subscribed to the Google Groups "Clang Built Linux" group. > To unsubscribe from this group and stop receiving emails from it, send an email to clang-built-linux+unsubscribe@googlegroups.com. > To view this discussion on the web visit https://groups.google.com/d/msgid/clang-built-linux/20200208141052.48476-1-natechancellor%40gmail.com. -- Thanks, ~Nick Desaulniers ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] s390/kaslr: Fix casts in get_random 2020-02-08 14:10 [PATCH] s390/kaslr: Fix casts in get_random Nathan Chancellor 2020-02-08 17:12 ` Nick Desaulniers @ 2020-02-08 20:17 ` Joe Perches 2020-02-14 6:46 ` Nathan Chancellor 1 sibling, 1 reply; 5+ messages in thread From: Joe Perches @ 2020-02-08 20:17 UTC (permalink / raw) To: Nathan Chancellor, Heiko Carstens, Vasily Gorbik, Christian Borntraeger Cc: linux-s390, linux-kernel, clang-built-linux On Sat, 2020-02-08 at 07:10 -0700, Nathan Chancellor wrote: > Clang warns: > > ../arch/s390/boot/kaslr.c:78:25: warning: passing 'char *' to parameter > of type 'const u8 *' (aka 'const unsigned char *') converts between > pointers to integer > types with different sign [-Wpointer-sign] > (char *) entropy, (char *) entropy, > ^~~~~~~~~~~~~~~~ > ../arch/s390/include/asm/cpacf.h:280:28: note: passing argument to > parameter 'src' here > u8 *dest, const u8 *src, long src_len) > ^ > 2 warnings generated. > > Fix the cast to match what else is done in this function. > > Fixes: b2d24b97b2a9 ("s390/kernel: add support for kernel address space layout randomization (KASLR)") > Link: https://github.com/ClangBuiltLinux/linux/issues/862 > Signed-off-by: Nathan Chancellor <natechancellor@gmail.com> > --- > arch/s390/boot/kaslr.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/s390/boot/kaslr.c b/arch/s390/boot/kaslr.c > index 5d12352545c5..5591243d673e 100644 > --- a/arch/s390/boot/kaslr.c > +++ b/arch/s390/boot/kaslr.c > @@ -75,7 +75,7 @@ static unsigned long get_random(unsigned long limit) > *(unsigned long *) prng.parm_block ^= seed; > for (i = 0; i < 16; i++) { > cpacf_kmc(CPACF_KMC_PRNG, prng.parm_block, > - (char *) entropy, (char *) entropy, > + (u8 *) entropy, (u8 *) entropy, Why not change the function to take void *? static inline int cpacf_kmc(unsigned long func, void *param, u8 *dest, const u8 *src, long src_len) vs: static inline int cpacf_kmc(unsigned long func, void *param, void *dest, const void *src, long src_len) and remove the casts? ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] s390/kaslr: Fix casts in get_random 2020-02-08 20:17 ` Joe Perches @ 2020-02-14 6:46 ` Nathan Chancellor 2020-02-17 17:13 ` Vasily Gorbik 0 siblings, 1 reply; 5+ messages in thread From: Nathan Chancellor @ 2020-02-14 6:46 UTC (permalink / raw) To: Joe Perches Cc: Heiko Carstens, Vasily Gorbik, Christian Borntraeger, linux-s390, linux-kernel, clang-built-linux On Sat, Feb 08, 2020 at 12:17:20PM -0800, Joe Perches wrote: > On Sat, 2020-02-08 at 07:10 -0700, Nathan Chancellor wrote: > > Clang warns: > > > > ../arch/s390/boot/kaslr.c:78:25: warning: passing 'char *' to parameter > > of type 'const u8 *' (aka 'const unsigned char *') converts between > > pointers to integer > > types with different sign [-Wpointer-sign] > > (char *) entropy, (char *) entropy, > > ^~~~~~~~~~~~~~~~ > > ../arch/s390/include/asm/cpacf.h:280:28: note: passing argument to > > parameter 'src' here > > u8 *dest, const u8 *src, long src_len) > > ^ > > 2 warnings generated. > > > > Fix the cast to match what else is done in this function. > > > > Fixes: b2d24b97b2a9 ("s390/kernel: add support for kernel address space layout randomization (KASLR)") > > Link: https://github.com/ClangBuiltLinux/linux/issues/862 > > Signed-off-by: Nathan Chancellor <natechancellor@gmail.com> > > --- > > arch/s390/boot/kaslr.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/arch/s390/boot/kaslr.c b/arch/s390/boot/kaslr.c > > index 5d12352545c5..5591243d673e 100644 > > --- a/arch/s390/boot/kaslr.c > > +++ b/arch/s390/boot/kaslr.c > > @@ -75,7 +75,7 @@ static unsigned long get_random(unsigned long limit) > > *(unsigned long *) prng.parm_block ^= seed; > > for (i = 0; i < 16; i++) { > > cpacf_kmc(CPACF_KMC_PRNG, prng.parm_block, > > - (char *) entropy, (char *) entropy, > > + (u8 *) entropy, (u8 *) entropy, > > Why not change the function to take void *? > > static inline int cpacf_kmc(unsigned long func, void *param, > u8 *dest, const u8 *src, long src_len) > > vs: > > static inline int cpacf_kmc(unsigned long func, void *param, > void *dest, const void *src, long src_len) > > and remove the casts? I can certainly do that if the maintainers prefer it. Cheers, Nathan ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] s390/kaslr: Fix casts in get_random 2020-02-14 6:46 ` Nathan Chancellor @ 2020-02-17 17:13 ` Vasily Gorbik 0 siblings, 0 replies; 5+ messages in thread From: Vasily Gorbik @ 2020-02-17 17:13 UTC (permalink / raw) To: Nathan Chancellor Cc: Joe Perches, Heiko Carstens, Christian Borntraeger, linux-s390, linux-kernel, clang-built-linux On Thu, Feb 13, 2020 at 11:46:28PM -0700, Nathan Chancellor wrote: > On Sat, Feb 08, 2020 at 12:17:20PM -0800, Joe Perches wrote: > > On Sat, 2020-02-08 at 07:10 -0700, Nathan Chancellor wrote: > > > Clang warns: > > > > > > ../arch/s390/boot/kaslr.c:78:25: warning: passing 'char *' to parameter > > > of type 'const u8 *' (aka 'const unsigned char *') converts between > > > pointers to integer > > > types with different sign [-Wpointer-sign] > > > (char *) entropy, (char *) entropy, > > > ^~~~~~~~~~~~~~~~ > > > ../arch/s390/include/asm/cpacf.h:280:28: note: passing argument to > > > parameter 'src' here > > > u8 *dest, const u8 *src, long src_len) > > > ^ > > > 2 warnings generated. > > > > > > Fix the cast to match what else is done in this function. > > > > > > Fixes: b2d24b97b2a9 ("s390/kernel: add support for kernel address space layout randomization (KASLR)") > > > Link: https://github.com/ClangBuiltLinux/linux/issues/862 > > > Signed-off-by: Nathan Chancellor <natechancellor@gmail.com> > > > --- > > > arch/s390/boot/kaslr.c | 2 +- > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > diff --git a/arch/s390/boot/kaslr.c b/arch/s390/boot/kaslr.c > > > index 5d12352545c5..5591243d673e 100644 > > > --- a/arch/s390/boot/kaslr.c > > > +++ b/arch/s390/boot/kaslr.c > > > @@ -75,7 +75,7 @@ static unsigned long get_random(unsigned long limit) > > > *(unsigned long *) prng.parm_block ^= seed; > > > for (i = 0; i < 16; i++) { > > > cpacf_kmc(CPACF_KMC_PRNG, prng.parm_block, > > > - (char *) entropy, (char *) entropy, > > > + (u8 *) entropy, (u8 *) entropy, > > > > Why not change the function to take void *? > > > > static inline int cpacf_kmc(unsigned long func, void *param, > > u8 *dest, const u8 *src, long src_len) > > > > vs: > > > > static inline int cpacf_kmc(unsigned long func, void *param, > > void *dest, const void *src, long src_len) > > > > and remove the casts? > > I can certainly do that if the maintainers prefer it. > > Cheers, > Nathan KBUILD_CFLAGS contains -Wno-pointer-sign but special arch/s390/boot code has a separate set of build flags. Anyhow the change makes sense as it is. Applied to fixes, thanks ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-02-17 17:13 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2020-02-08 14:10 [PATCH] s390/kaslr: Fix casts in get_random Nathan Chancellor 2020-02-08 17:12 ` Nick Desaulniers 2020-02-08 20:17 ` Joe Perches 2020-02-14 6:46 ` Nathan Chancellor 2020-02-17 17:13 ` Vasily Gorbik
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox