Hi,
On 10/26/23 09:44, Kevin Brodsky wrote:
The logic to process aligned words in do_strnlen_user() is fairly complicated. This patch simplifies it a little bit, notably by moving it to its own function.
This refactoring is mainly done in preparation to a further patch that will prevent under- or over-reading the input string, when doing so is invalid.
Signed-off-by: Kevin Brodskykevin.brodsky@arm.com
lib/strnlen_user.c | 73 ++++++++++++++++++++++++++++------------------ 1 file changed, 45 insertions(+), 28 deletions(-)
diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c index e4d0f9adf5ff..60942cdfd3d2 100644 --- a/lib/strnlen_user.c +++ b/lib/strnlen_user.c @@ -7,6 +7,41 @@ #include <asm/word-at-a-time.h> +/*
- Returns the *index* of '\0' in src, or >= max if not found.
- */
I know that there are comments on the reason for aligned vs unaligned in the function do_strnlen_user(), but maybe some info in the comment on what exactly the 'align' parameter means/does may be helpful.
+static __always_inline long find_zero_aligned(const unsigned long __user *src,
unsigned long max,
unsigned long align)