Skip to contentSkip to conversation

error: implicit declaration of function 'zero_bytemask'

PATCH In review Michal Sojka 3 participants 5 messages Oct 7, 2015 – Oct 8, 2015 PowerPC

lore
Share & tools
lore
#0 lore raw

Dear Chris,

the following commit breaks my Linux build.

commit 990486c8af044f89bddfbde1d1cf9fde449bedbf
Author: Chris Metcalf <[email protected]>
Date: Tue Oct 6 12:37:41 2015 -0400

strscpy: zero any trailing garbage bytes in the destination

It's possible that the destination can be shadowed in userspace (as, for example, the perf buffers are now). So we should take care not to leak data that could be inspected by userspace.

The error message is:

lib/string.c: In function 'strscpy':
lib/string.c:209:4: error: implicit declaration of function 'zero_bytemask' [-Werror=implicit-function-declaration]
cc1: some warnings being treated as errors

I compile the kernel for PowerPC (32 bit) with the attached config.

Best regards,
-Michal

#1 lore raw
Quoted 14 lines · Michal Sojka

Dear Chris,

the following commit breaks my Linux build.

commit 990486c8af044f89bddfbde1d1cf9fde449bedbf
Author: Chris Metcalf <[email protected]>
Date: Tue Oct 6 12:37:41 2015 -0400

strscpy: zero any trailing garbage bytes in the destination

It's possible that the destination can be shadowed in userspace (as, for example, the perf buffers are now). So we should take care not to leak data that could be inspected by userspace.

Quoted 7 lines

The error message is:

lib/string.c: In function 'strscpy':
lib/string.c:209:4: error: implicit declaration of function 'zero_bytemask' [-Werror=implicit-function-declaration]
cc1: some warnings being treated as errors

I compile the kernel for PowerPC (32 bit) with the attached config.

Ah, it appears that big-endian powerpc does not provide zero_bytemask(), only little-endian. I'll fix this in v3 of the patch series - thanks!

Signature · 2 lines
Chris Metcalf, EZChip Semiconductor
http://www.ezchip.com
#2 lore raw
Quoted 21 lines · Chris Metcalf
Quoted 11 lines · Michal Sojka

Dear Chris,

the following commit breaks my Linux build.

commit 990486c8af044f89bddfbde1d1cf9fde449bedbf
Author: Chris Metcalf <[email protected]>
Date: Tue Oct 6 12:37:41 2015 -0400

strscpy: zero any trailing garbage bytes in the destination

It's possible that the destination can be shadowed in

userspace

Quoted 1 line

(as, for example, the perf buffers are now). So we should

take

Quoted 6 lines

care not to leak data that could be inspected by userspace.

The error message is:

lib/string.c: In function 'strscpy':
lib/string.c:209:4: error: implicit declaration of function

Quoted 8 lines

'zero_bytemask' [-Werror=implicit-function-declaration]

Quoted 3 lines

cc1: some warnings being treated as errors

I compile the kernel for PowerPC (32 bit) with the attached config.

Ah, it appears that big-endian powerpc does not provide zero_bytemask(), only little-endian. I'll fix this in v3 of the patch series - thanks!

The patch is already in mainline so I guess a fixup patch would be more appropriate.

Signature · 1 line
Odesláno z mého telefonu pomocí Kaiten Mail. Omluvte prosím mou stručnost.
#3 lore raw

PATCH 1/1 arch/powerpc: provide zero_bytemask() for big-endian

For some reason, only the little-endian flavor of powerpc provided the zero_bytemask() implementation.

---
 arch/powerpc/include/asm/word-at-a-time.h | 5 +++++
 1 file changed, 5 insertions(+)
arch/powerpc/include/asm/word-at-a-time.h +5 -0
index 5b3a903adae6..e4396a7d0f7c 100644
@@ -40,6 +40,11 @@ static inline bool has_zero(unsigned long val, unsigned long *data, const struct
 	return (val + c->high_bits) & ~rhs;
 }
 
+static inline unsigned long zero_bytemask(unsigned long mask)
+{
+	return ~1ul << __fls(mask);
+}
+
 #else
 
 #ifdef CONFIG_64BIT
Signature · 1 line
2.1.2
reviewer Acked-by on v1 1/1
#4 lore raw

Re: [PATCH] arch/powerpc: provide zero_bytemask() for big-endian

Quoted 2 lines · Chris Metcalf

For some reason, only the little-endian flavor of powerpc provided the zero_bytemask() implementation.

Because previously it was optional unless DCACHE_WORD_ACCESS was enabled.

Quoted 12 lines
---
 arch/powerpc/include/asm/word-at-a-time.h | 5 +++++
 1 file changed, 5 insertions(+)
arch/powerpc/include/asm/word-at-a-time.h +0 -0
index 5b3a903adae6..e4396a7d0f7c 100644
@@ -40,6 +40,11 @@ static inline bool has_zero(unsigned long val, unsigned long *data, const struct
 	return (val + c->high_bits) & ~rhs;

arch/powerpc/include/asm/word-at-a-time.h static inline bool has_zero(unsigned long val, unsigned long *data, const struct · line 50

Quoted 10 lines
arch/powerpc/include/asm/word-at-a-time.h +5 -0
 }
 
+static inline unsigned long zero_bytemask(unsigned long mask)
+{
+	return ~1ul << __fls(mask);
+}
+
 #else
 
 #ifdef CONFIG_64BIT

This looks right, and I tested it too so have an ack if you want it:

If you can CC [email protected] in future on powerpc patches I'll notice them quicker, I know I was CC'ed on this but because it also went to LKML it got put in my lkml folder.

cheers