Skip to contentSkip to conversation

mm: Don't let userspace spam allocations warnings

PATCH In review Daniel Vetter 3 participants 3 messages Feb 20, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm: Don't let userspace spam allocations warnings

memdump_user usually gets fed unchecked userspace input. Blasting a full backtrace into dmesg every time is a bit excessive - I'm not sure on the kernel rule in general, but at least in drm we're trying not to let unpriviledge userspace spam the logs freely. Definitely not entire warning backtraces.

It also means more filtering for our CI, because our testsuite exercises these corner cases and so hits these a lot.

Cc Andrew Morton <[email protected]>
Cc Mike Rapoport <[email protected]>
Cc Michal Hocko <[email protected]>
Cc Roman Gushchin <[email protected]>
Cc Vlastimil Babka <[email protected]>
Cc Jan Stancek <[email protected]>
Cc Kees Cook <[email protected]>
Cc Andrey Ryabinin <[email protected]>
Cc "Michael S. Tsirkin" <[email protected]>
Cc Huang Ying <[email protected]>
Cc Bartosz Golaszewski <[email protected]>
---
 mm/util.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/util.c +1 -1
index 1ea055138043..379319b1bcfd 100644
@@ -150,7 +150,7 @@ void *memdup_user(const void __user *src, size_t len)
 {
 	void *p;
 
-	p = kmalloc_track_caller(len, GFP_USER);
+	p = kmalloc_track_caller(len, GFP_USER | __GFP_NOWARN);
 	if (!p)
 		return ERR_PTR(-ENOMEM);
 
Signature · 1 line
2.20.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Daniel Vetter

memdump_user usually gets fed unchecked userspace input. Blasting a full backtrace into dmesg every time is a bit excessive - I'm not sure on the kernel rule in general, but at least in drm we're trying not to let unpriviledge userspace spam the logs freely. Definitely not entire warning backtraces.

It also means more filtering for our CI, because our testsuite exercises these corner cases and so hits these a lot.

-Kees

Quoted 32 lines
Cc Andrew Morton <[email protected]>
Cc Mike Rapoport <[email protected]>
Cc Michal Hocko <[email protected]>
Cc Roman Gushchin <[email protected]>
Cc Vlastimil Babka <[email protected]>
Cc Jan Stancek <[email protected]>
Cc Kees Cook <[email protected]>
Cc Andrey Ryabinin <[email protected]>
Cc "Michael S. Tsirkin" <[email protected]>
Cc Huang Ying <[email protected]>
Cc Bartosz Golaszewski <[email protected]>
---
 mm/util.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/util.c +1 -2
index 1ea055138043..379319b1bcfd 100644
@@ -150,7 +150,7 @@ void *memdup_user(const void __user *src, size_t len)
 {
        void *p;
 
-       p = kmalloc_track_caller(len, GFP_USER);
+       p = kmalloc_track_caller(len, GFP_USER | __GFP_NOWARN);
        if (!p)
                return ERR_PTR(-ENOMEM);
 
--

2.20.1

Signature · 5 lines
Kees Cook
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Acked-by on v1 1/1
#2 lore raw
In reply to Daniel Vetter
Quoted 5 lines · Daniel Vetter

memdump_user usually gets fed unchecked userspace input. Blasting a full backtrace into dmesg every time is a bit excessive - I'm not sure on the kernel rule in general, but at least in drm we're trying not to let unpriviledge userspace spam the logs freely. Definitely not entire warning backtraces.

Yes, this makes sense to me. This API sounds like an example where returning ENOMEM to the userspace right away is much better than spamming the log for large allocation requests. Smaller allocations simply do not fail and the OOM killer report will be printed regardless of __GFP_NOWARN.

Quoted 16 lines

It also means more filtering for our CI, because our testsuite exercises these corner cases and so hits these a lot.

Cc Andrew Morton <[email protected]>
Cc Mike Rapoport <[email protected]>
Cc Michal Hocko <[email protected]>
Cc Roman Gushchin <[email protected]>
Cc Vlastimil Babka <[email protected]>
Cc Jan Stancek <[email protected]>
Cc Kees Cook <[email protected]>
Cc Andrey Ryabinin <[email protected]>
Cc "Michael S. Tsirkin" <[email protected]>
Cc Huang Ying <[email protected]>
Cc Bartosz Golaszewski <[email protected]>
Quoted 20 lines
---
 mm/util.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/util.c +1 -1
index 1ea055138043..379319b1bcfd 100644
@@ -150,7 +150,7 @@ void *memdup_user(const void __user *src, size_t len)
 {
 	void *p;
 
-	p = kmalloc_track_caller(len, GFP_USER);
+	p = kmalloc_track_caller(len, GFP_USER | __GFP_NOWARN);
 	if (!p)
 		return ERR_PTR(-ENOMEM);
 
Signature · 1 line
2.20.1
Signature · 2 lines
Michal Hocko
SUSE Labs