1 #include <linux/kernel.h>
2 #include <linux/export.h>
5 #include <asm/word-at-a-time.h>
9 # define aligned_byte_mask(n) ((1ul << 8*(n))-1)
11 # define aligned_byte_mask(n) (~0xfful << (BITS_PER_LONG - 8 - 8*(n)))
27 static inline long do_strnlen_user(
const char __user *
src,
unsigned long count,
unsigned long max)
44 align = (
sizeof(
long) - 1) & (
unsigned long)src;
54 if (has_zero(c, &data, &constants)) {
57 return res + find_zero(data) + 1 -
align;
59 res +=
sizeof(
unsigned long);
60 if (
unlikely(max <
sizeof(
unsigned long)))
62 max -=
sizeof(
unsigned long);
103 src_addr = (
unsigned long)str;
104 if (
likely(src_addr < max_addr)) {
106 return do_strnlen_user(str, count, max);
131 src_addr = (
unsigned long)str;
132 if (
likely(src_addr < max_addr)) {
134 return do_strnlen_user(str, ~0ul, max);