mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-09-22 09:34:56 +02:00
bpf: tcp: Make mem flags configurable through bpf_iter_tcp_realloc_batch
[ Upstream commit8271bec9fc] Prepare for the next patch which needs to be able to choose either GFP_USER or GFP_NOWAIT for calls to bpf_iter_tcp_realloc_batch. Signed-off-by: Jordan Rife <jordan@jrife.io> Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org> Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com> Acked-by: Stanislav Fomichev <sdf@fomichev.me> Stable-dep-of:e5fd3f514e("bpf: tcp: Fix use-after-free in bpf_iter_tcp_established_batch()") Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
ccbbbca21d
commit
524f2d0409
+5
-4
@@ -2810,12 +2810,12 @@ static void bpf_iter_tcp_put_batch(struct bpf_tcp_iter_state *iter)
|
||||
}
|
||||
|
||||
static int bpf_iter_tcp_realloc_batch(struct bpf_tcp_iter_state *iter,
|
||||
unsigned int new_batch_sz)
|
||||
unsigned int new_batch_sz, gfp_t flags)
|
||||
{
|
||||
struct sock **new_batch;
|
||||
|
||||
new_batch = kvmalloc(sizeof(*new_batch) * new_batch_sz,
|
||||
GFP_USER | __GFP_NOWARN);
|
||||
flags | __GFP_NOWARN);
|
||||
if (!new_batch)
|
||||
return -ENOMEM;
|
||||
|
||||
@@ -2927,7 +2927,8 @@ again:
|
||||
return sk;
|
||||
}
|
||||
|
||||
if (!resized && !bpf_iter_tcp_realloc_batch(iter, expected * 3 / 2)) {
|
||||
if (!resized && !bpf_iter_tcp_realloc_batch(iter, expected * 3 / 2,
|
||||
GFP_USER)) {
|
||||
resized = true;
|
||||
goto again;
|
||||
}
|
||||
@@ -3355,7 +3356,7 @@ static int bpf_iter_init_tcp(void *priv_data, struct bpf_iter_aux_info *aux)
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
err = bpf_iter_tcp_realloc_batch(iter, INIT_BATCH_SZ);
|
||||
err = bpf_iter_tcp_realloc_batch(iter, INIT_BATCH_SZ, GFP_USER);
|
||||
if (err) {
|
||||
bpf_iter_fini_seq_net(priv_data);
|
||||
return err;
|
||||
|
||||
Reference in New Issue
Block a user