On Wed, Mar 29, 2023, at 18:03, Oleg Nesterov wrote: > On 03/29, Arnd Bergmann wrote: >> >> I think the idea of TASK_SIZE_MAX is that it is a compile-time constant and in fact independent of current, while TASK_SIZE >> takes TIF_32BIT into account. > > Say, arch/loongarch defines TASK_SIZE which depends on > test_thread_flag(TIF_32BIT_ADDR) > but it doesn't define TASK_SIZE_MAX, so __access_ok() will use TASK_SIZE. I'd consider that a bug in loongarch, though it's as harmless as it gets: The only downside is that it's missing an optimization from constant-folding the value, and since there is no CONFIG_COMPAT on loongarch yet, it doesn't even have a different value. TASK_SIZE_MAX become mandatory here when I worked on the optimized access_ok() across architectures, and the reason it's safe to use is that access_ok() has to only guarantee that a task cannot access data that it can't already access, i.e. kernel data. Passing a pointer between TASK_SIZE and TASK_SIZE_MAX will still cause a -EFAULT error because of the trap. Arnd