X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=lib%2Fstrnlen_user.c;h=41670d4a5816530d7b948fe29f0fad20a44ec2ed;hb=4a9892d75cfb964da23dc56d0538175aa8e161a7;hp=6c0005d5dd5c43e7ed4097c24d5fc785a794110e;hpb=84629d4370b8e6b7871d97440babece3eb1108a5;p=mirror_ubuntu-focal-kernel.git diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c index 6c0005d5dd5c..41670d4a5816 100644 --- a/lib/strnlen_user.c +++ b/lib/strnlen_user.c @@ -26,13 +26,6 @@ static inline long do_strnlen_user(const char __user *src, unsigned long count, unsigned long align, res = 0; unsigned long c; - /* - * Truncate 'max' to the user-specified limit, so that - * we only have one limit we need to check in the loop - */ - if (max > count) - max = count; - /* * Do everything aligned. But that means that we * need to also expand the maximum.. @@ -109,6 +102,13 @@ long strnlen_user(const char __user *str, long count) unsigned long max = max_addr - src_addr; long retval; + /* + * Truncate 'max' to the user-specified limit, so that + * we only have one limit we need to check in the loop + */ + if (max > count) + max = count; + if (user_access_begin(str, max)) { retval = do_strnlen_user(str, count, max); user_access_end();