Skip to contentSkip to conversation

module: do not print allocation-fail warning on bogus user buffer size

PATCH In review Kirill A. Shutemov 2 participants 2 messages Feb 16, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 module: do not print allocation-fail warning on bogus user buffer size

init_module(2) passes user-specified buffer length directly to vmalloc(). It makes warn_alloc_failed() to print out a lot of info into dmesg if user specified insane size, like -1.

Let's silence the warning. It doesn't add much value to -ENOMEM return code. Without the patch the syscall is prohibitive noisy for testing with trinity.

---
 kernel/module.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/module.c +2 -1
index b34813f725e9..f63e5e8f3385 100644
@@ -2494,7 +2494,8 @@ static int copy_module_from_user(const void __user *umod, unsigned long len,
 		return err;
 
 	/* Suck in entire file: we'll want most of it. */
-	info->hdr = vmalloc(info->len);
+	info->hdr = __vmalloc(info->len,
+			GFP_KERNEL | __GFP_HIGHMEM | __GFP_NOWARN, PAGE_KERNEL);
 	if (!info->hdr)
 		return -ENOMEM;
 
Signature · 1 line
2.1.4
#1 lore raw
Quoted 7 lines · Kirill A. Shutemov

init_module(2) passes user-specified buffer length directly to vmalloc(). It makes warn_alloc_failed() to print out a lot of info into dmesg if user specified insane size, like -1.

Let's silence the warning. It doesn't add much value to -ENOMEM return code. Without the patch the syscall is prohibitive noisy for testing with trinity.

Heh, we used to have an explicit length check because vmalloc would BUG(). So I guess this is progress...

Applied thanks,
Rusty.