arch: xtensa: Update arch_user_string_nlen()

When calling device_get_binding(NULL) from userspace, this eventually
funnels down to a call to arch_user_string_nlen() where it tried to
verify that the kernel has access to this address (0x0).  But since
this originates from userspace, we really want to know if this is
accessible from userspace, so using arch_buffer_validate() instead
of xtensa_mem_kernel_has_access() is preferable.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
This commit is contained in:
Peter Mitsis 2025-05-13 11:06:15 -07:00 committed by Benjamin Cabé
commit 2f2eaf7b6f

View file

@ -115,7 +115,7 @@ size_t arch_user_string_nlen(const char *s, size_t maxsize, int *err_arg)
* For MPU systems, this would simply results in access errors
* and the exception handler will terminate the thread.
*/
if (!xtensa_mem_kernel_has_access(s, maxsize, 0)) {
if (arch_buffer_validate(s, maxsize, 0)) {
/*
* API says we need to set err_arg to -1 if there are
* any errors.