Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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.

Reported-by: Dmitry Vyukov <dvyukov@google.com>
Acked-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Julian Calaby <julian.calaby@gmail.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>

authored by

Cong Wang and committed by
Samuel Ortiz
81ca7835 667f0063

+2 -2
+2 -2
net/nfc/llcp_commands.c
··· 663 663 return -ENOBUFS; 664 664 } 665 665 666 - msg_data = kzalloc(len, GFP_KERNEL); 666 + msg_data = kmalloc(len, GFP_USER | __GFP_NOWARN); 667 667 if (msg_data == NULL) 668 668 return -ENOMEM; 669 669 ··· 729 729 if (local == NULL) 730 730 return -ENODEV; 731 731 732 - msg_data = kzalloc(len, GFP_KERNEL); 732 + msg_data = kmalloc(len, GFP_USER | __GFP_NOWARN); 733 733 if (msg_data == NULL) 734 734 return -ENOMEM; 735 735