Skip to content

Commit 7f44bea

Browse files
fmoessbaueraxboe
authored andcommitted
io_uring/sqpoll: do not put cpumask on stack
Putting the cpumask on the stack is deprecated for a long time (since 2d3854a), as these can be big. Given that, change the on-stack allocation of allowed_mask to be dynamically allocated. Fixes: f011c9c ("io_uring/sqpoll: do not allow pinning outside of cpuset") Signed-off-by: Felix Moessbauer <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent a09c172 commit 7f44bea

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

io_uring/sqpoll.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -461,15 +461,22 @@ __cold int io_sq_offload_create(struct io_ring_ctx *ctx,
461461
return 0;
462462

463463
if (p->flags & IORING_SETUP_SQ_AFF) {
464-
struct cpumask allowed_mask;
464+
cpumask_var_t allowed_mask;
465465
int cpu = p->sq_thread_cpu;
466466

467467
ret = -EINVAL;
468468
if (cpu >= nr_cpu_ids || !cpu_online(cpu))
469469
goto err_sqpoll;
470-
cpuset_cpus_allowed(current, &allowed_mask);
471-
if (!cpumask_test_cpu(cpu, &allowed_mask))
470+
ret = -ENOMEM;
471+
if (!alloc_cpumask_var(&allowed_mask, GFP_KERNEL))
472472
goto err_sqpoll;
473+
ret = -EINVAL;
474+
cpuset_cpus_allowed(current, allowed_mask);
475+
if (!cpumask_test_cpu(cpu, allowed_mask)) {
476+
free_cpumask_var(allowed_mask);
477+
goto err_sqpoll;
478+
}
479+
free_cpumask_var(allowed_mask);
473480
sqd->sq_cpu = cpu;
474481
} else {
475482
sqd->sq_cpu = -1;

0 commit comments

Comments
 (0)