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

netdevsim: Avoid allocation warnings triggered from user space

We need to suppress warnings from sily map sizes. Also switch
from GFP_USER to GFP_KERNEL_ACCOUNT, I'm pretty sure I misunderstood
the flags when writing this code.

Fixes: 395cacb5f1a0 ("netdevsim: bpf: support fake map offload")
Reported-by: syzbot+ad24705d3fd6463b18c6@syzkaller.appspotmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20220726213605.154204-1-kuba@kernel.org

authored by

Jakub Kicinski and committed by
Andrii Nakryiko
d0b80a9e 3b317abc

+5 -3
+5 -3
drivers/net/netdevsim/bpf.c
··· 351 351 { 352 352 struct nsim_bpf_bound_map *nmap = offmap->dev_priv; 353 353 354 - nmap->entry[idx].key = kmalloc(offmap->map.key_size, GFP_USER); 354 + nmap->entry[idx].key = kmalloc(offmap->map.key_size, 355 + GFP_KERNEL_ACCOUNT | __GFP_NOWARN); 355 356 if (!nmap->entry[idx].key) 356 357 return -ENOMEM; 357 - nmap->entry[idx].value = kmalloc(offmap->map.value_size, GFP_USER); 358 + nmap->entry[idx].value = kmalloc(offmap->map.value_size, 359 + GFP_KERNEL_ACCOUNT | __GFP_NOWARN); 358 360 if (!nmap->entry[idx].value) { 359 361 kfree(nmap->entry[idx].key); 360 362 nmap->entry[idx].key = NULL; ··· 498 496 if (offmap->map.map_flags) 499 497 return -EINVAL; 500 498 501 - nmap = kzalloc(sizeof(*nmap), GFP_USER); 499 + nmap = kzalloc(sizeof(*nmap), GFP_KERNEL_ACCOUNT); 502 500 if (!nmap) 503 501 return -ENOMEM; 504 502