@@ -612,8 +612,8 @@ static inline long strnlen_user(const char __user *s, long n)
{
long res;
- if (!access_ok(s, n))
- return -0;
+ if (!access_ok(s, 1))
+ return 0;
might_fault();
__asm__ __volatile__(
At the other hand, I search strndup_user() in the kernel tree, the second
argument of them are almost a macro or a fixed value which is relatively
small, such as PAGE_SIZE, PATH_MAX. So I think maybe we can use ARG_MAX as
second argument of strndup_user() in load_module().
With this patch, the load_module() failure disappered and we can login
normally through a graphical interface.
[1] https://lore.kernel.org/patchwork/patch/1411214/
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
kernel/module.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
@@ -3998,7 +3998,7 @@ static int load_module(struct load_info *info, const char __user *uargs,
flush_module_icache(mod);
/* Now copy in args */
- mod->args = strndup_user(uargs, ~0UL >> 1);
+ mod->args = strndup_user(uargs, ARG_MAX);
if (IS_ERR(mod->args)) {
err = PTR_ERR(mod->args);
goto free_arch_cleanup;