Skip to contentSkip to conversation

nfc: use GFP_USER for user-controlled kmalloc

PATCH Applied Cong Wang 5 participants 8 messages Jan 29, 2016 – Feb 25, 2016 3 messages not in the archive

Subsystems (3)
lore
Share & tools
lore

Cong Wang

author
#0 lore raw

PATCH v2 1/1 nfc: use GFP_USER for user-controlled kmalloc

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.

Cc Lauro Ramos Venancio <[email protected]>
Cc Aloisio Almeida Jr <[email protected]>
Cc Samuel Ortiz <sameo-VuQAYsv1563Yd54FQh9/[email protected]>
---
 net/nfc/llcp_commands.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/nfc/llcp_commands.c +2 -2
index 3621a90..3425532 100644
@@ -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;
 
Signature · 6 lines
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Acked-by on v2 1/1
#1 lore raw
Quoted 10 lines · Cong Wang

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.

Cc Lauro Ramos Venancio <[email protected]>
Cc Aloisio Almeida Jr <[email protected]>
Cc Samuel Ortiz <[email protected]>

---

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.

Thanks!

Reviewed-by
#2 lore raw

Hi Cong

Quoted 12 lines · Eric Dumazet
Quoted 10 lines · Cong Wang

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.

Cc Lauro Ramos Venancio <[email protected]>
Cc Aloisio Almeida Jr <[email protected]>
Cc Samuel Ortiz <[email protected]>

---

Quoted 5 lines

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.

Thanks,

Signature · 4 lines
Julian Calaby

Email: [email protected]
Profile: http://www.google.com/profiles/julian.calaby/

A message that is not in the archive (sent off-list or not yet received): 1454095465-16685-1-git-send-email-xiyou.wangcong-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

author
#4 lore raw
Quoted 9 lines · Cong Wang

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.

Cc Lauro Ramos Venancio <[email protected]>
Cc Aloisio Almeida Jr <[email protected]>
Cc Samuel Ortiz <sameo-VuQAYsv1563Yd54FQh9/[email protected]>

Ping...

David, this patch seems still not applied, I guess you expect NFC maintainer to take it, but this doesn't happen. Could you take it?

(I can resend it if you need.)

Thanks!

Quoted 27 lines
---
 net/nfc/llcp_commands.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/nfc/llcp_commands.c +2 -3
index 3621a90..3425532 100644
@@ -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;
 
--
Quoted 2 lines

1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#5 lore raw

From: Cong Wang <[email protected]>
Date: Wed, 24 Feb 2016 10:41:29 -0800

Quoted 11 lines · Cong Wang
Quoted 9 lines

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.

Cc Lauro Ramos Venancio <[email protected]>
Cc Aloisio Almeida Jr <[email protected]>
Cc Samuel Ortiz <[email protected]>
Quoted 4 lines

Ping...

David, this patch seems still not applied, I guess you expect NFC maintainer to take it, but this doesn't happen. Could you take it?

The NFC maintainer needs to take this, ping them explicitly if you have to.

Thanks.

A message that is not in the archive (sent off-list or not yet received): 20160224.134521.961009575129127582.davem-fT/PcQaiUtIeIZ0/[email protected]

author
#7 lore raw
Quoted 14 lines · David Miller

From: Cong Wang <[email protected]>
Date: Wed, 24 Feb 2016 10:41:29 -0800

Quoted 11 lines · Cong Wang
Quoted 9 lines

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.

Cc Lauro Ramos Venancio <[email protected]>
Cc Aloisio Almeida Jr <[email protected]>
Cc Samuel Ortiz <sameo-VuQAYsv1563Yd54FQh9/[email protected]>
Quoted 7 lines
Quoted 4 lines

Ping...

David, this patch seems still not applied, I guess you expect NFC maintainer to take it, but this doesn't happen. Could you take it?

The NFC maintainer needs to take this, ping them explicitly if you have to.

OK. I think Samuel is looking at it now.

Thanks!
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): CAM_iQpX3X6YoFeMw2KYjJM8yBHi9=3iapo0+a9Cqtc0cxM_QNA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#9 lore raw
Quoted 11 lines · Cong Wang
Quoted 9 lines · Cong Wang

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.

Cc Lauro Ramos Venancio <[email protected]>
Cc Aloisio Almeida Jr <[email protected]>
Cc Samuel Ortiz <sameo-VuQAYsv1563Yd54FQh9/[email protected]>
Quoted 4 lines

Ping...

David, this patch seems still not applied, I guess you expect NFC maintainer to take it, but this doesn't happen. Could you take it?

I'll look at it later today.

Cheers,
Samuel.
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

Applied
#10 lore raw
In reply to a message not in the archive

Hi Cong,

Quoted 4 lines · Cong Wang

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.

Quoted 8 lines
Cc Lauro Ramos Venancio <[email protected]>
Cc Aloisio Almeida Jr <[email protected]>
Cc Samuel Ortiz <sameo-VuQAYsv1563Yd54FQh9/[email protected]>
---
 net/nfc/llcp_commands.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Applied to nfc-next, thanks.

Cheers,
Samuel.
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html