diff options
Diffstat (limited to 'kernel/bpf/syscall.c')
-rw-r--r-- | kernel/bpf/syscall.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c index 0937719b87e2..ace1cfaa24b6 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c | |||
@@ -126,7 +126,7 @@ static struct bpf_map *find_and_alloc_map(union bpf_attr *attr) | |||
126 | return map; | 126 | return map; |
127 | } | 127 | } |
128 | 128 | ||
129 | void *bpf_map_area_alloc(size_t size, int numa_node) | 129 | void *bpf_map_area_alloc(u64 size, int numa_node) |
130 | { | 130 | { |
131 | /* We really just want to fail instead of triggering OOM killer | 131 | /* We really just want to fail instead of triggering OOM killer |
132 | * under memory pressure, therefore we set __GFP_NORETRY to kmalloc, | 132 | * under memory pressure, therefore we set __GFP_NORETRY to kmalloc, |
@@ -141,6 +141,9 @@ void *bpf_map_area_alloc(size_t size, int numa_node) | |||
141 | const gfp_t flags = __GFP_NOWARN | __GFP_ZERO; | 141 | const gfp_t flags = __GFP_NOWARN | __GFP_ZERO; |
142 | void *area; | 142 | void *area; |
143 | 143 | ||
144 | if (size >= SIZE_MAX) | ||
145 | return NULL; | ||
146 | |||
144 | if (size <= (PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER)) { | 147 | if (size <= (PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER)) { |
145 | area = kmalloc_node(size, GFP_USER | __GFP_NORETRY | flags, | 148 | area = kmalloc_node(size, GFP_USER | __GFP_NORETRY | flags, |
146 | numa_node); | 149 | numa_node); |
@@ -197,7 +200,7 @@ static void bpf_uncharge_memlock(struct user_struct *user, u32 pages) | |||
197 | atomic_long_sub(pages, &user->locked_vm); | 200 | atomic_long_sub(pages, &user->locked_vm); |
198 | } | 201 | } |
199 | 202 | ||
200 | int bpf_map_charge_init(struct bpf_map_memory *mem, size_t size) | 203 | int bpf_map_charge_init(struct bpf_map_memory *mem, u64 size) |
201 | { | 204 | { |
202 | u32 pages = round_up(size, PAGE_SIZE) >> PAGE_SHIFT; | 205 | u32 pages = round_up(size, PAGE_SIZE) >> PAGE_SHIFT; |
203 | struct user_struct *user; | 206 | struct user_struct *user; |