[PATCH v2 net] nfc: use GFP_USER for user-controlled kmalloc

Subsystems: networking [general], nfc subsystem, the rest

STALE3850d

3 messages, 3 authors, 2016-01-29 · open the first message on its own page

[PATCH v2 net] nfc: use GFP_USER for user-controlled kmalloc

From: Cong Wang <hidden>
Date: 2016-01-29 19:24:24

These two functions are called in sendmsg path, and the
'len' is passed from user-space, so we should not allow
malicious users to OOM kernel on purpose.

Reported-by: Dmitry Vyukov <redacted>
Cc: Lauro Ramos Venancio <redacted>
Cc: Aloisio Almeida Jr <redacted>
Cc: Samuel Ortiz <sameo-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Signed-off-by: Cong Wang <redacted>
---
 net/nfc/llcp_commands.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/nfc/llcp_commands.c b/net/nfc/llcp_commands.c
index 3621a90..3425532 100644
--- a/net/nfc/llcp_commands.c
+++ b/net/nfc/llcp_commands.c
@@ -663,7 +663,7 @@ int nfc_llcp_send_i_frame(struct nfc_llcp_sock *sock,
 		return -ENOBUFS;
 	}
 
-	msg_data = kzalloc(len, GFP_KERNEL);
+	msg_data = kmalloc(len, GFP_USER | __GFP_NOWARN);
 	if (msg_data == NULL)
 		return -ENOMEM;
 
@@ -729,7 +729,7 @@ int nfc_llcp_send_ui_frame(struct nfc_llcp_sock *sock, u8 ssap, u8 dsap,
 	if (local == NULL)
 		return -ENODEV;
 
-	msg_data = kzalloc(len, GFP_KERNEL);
+	msg_data = kmalloc(len, GFP_USER | __GFP_NOWARN);
 	if (msg_data == NULL)
 		return -ENOMEM;
 
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Re: [PATCH v2 net] nfc: use GFP_USER for user-controlled kmalloc

From: Eric Dumazet <hidden>
Date: 2016-01-29 19:46:05

On Fri, 2016-01-29 at 11:24 -0800, Cong Wang wrote:
These two functions are called in sendmsg path, and the
'len' is passed from user-space, so we should not allow
malicious users to OOM kernel on purpose.

Reported-by: Dmitry Vyukov <dvyukov@google.com>
Cc: Lauro Ramos Venancio <redacted>
Cc: Aloisio Almeida Jr <redacted>
Cc: Samuel Ortiz <redacted>
Signed-off-by: Cong Wang <redacted>
---
Note that the issue is not OOM the kernel (as the allocation is
attempted even after your patch), but having a way to
spill stack traces in the syslog.

Acked-by: Eric Dumazet <edumazet@google.com>

Thanks!

Re: [PATCH v2 net] nfc: use GFP_USER for user-controlled kmalloc

From: Julian Calaby <hidden>
Date: 2016-01-29 22:02:16

Hi Cong

On Sat, Jan 30, 2016 at 6:46 AM, Eric Dumazet [off-list ref] wrote:
On Fri, 2016-01-29 at 11:24 -0800, Cong Wang wrote:
quoted
These two functions are called in sendmsg path, and the
'len' is passed from user-space, so we should not allow
malicious users to OOM kernel on purpose.

Reported-by: Dmitry Vyukov <dvyukov@google.com>
Cc: Lauro Ramos Venancio <redacted>
Cc: Aloisio Almeida Jr <redacted>
Cc: Samuel Ortiz <redacted>
Signed-off-by: Cong Wang <redacted>
---
Note that the issue is not OOM the kernel (as the allocation is
attempted even after your patch), but having a way to
spill stack traces in the syslog.

Acked-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Julian Calaby <redacted>

Thanks,

-- 
Julian Calaby

Email: julian.calaby@gmail.com
Profile: http://www.google.com/profiles/julian.calaby/
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help