summaryrefslogtreecommitdiff
path: root/io_uring
diff options
context:
space:
mode:
authorFelix Moessbauer <felix.moessbauer@siemens.com>2024-09-16 13:11:50 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-10-17 15:21:15 +0200
commitee3e8b2933f794df732333e04c001bd5cb22654a (patch)
tree2bb523cf545eb2fd0363323967b0b06e33c497cc /io_uring
parentebc7db40b847a17aa8b19abb63a82f67f5a6b1db (diff)
downloadlinux-ee3e8b2933f794df732333e04c001bd5cb22654a.tar.gz
linux-ee3e8b2933f794df732333e04c001bd5cb22654a.tar.bz2
linux-ee3e8b2933f794df732333e04c001bd5cb22654a.zip
io_uring/sqpoll: do not put cpumask on stack
commit 7f44beadcc11adb98220556d2ddbe9c97aa6d42d upstream. Putting the cpumask on the stack is deprecated for a long time (since 2d3854a37e8), as these can be big. Given that, change the on-stack allocation of allowed_mask to be dynamically allocated. Fixes: f011c9cf04c0 ("io_uring/sqpoll: do not allow pinning outside of cpuset") Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com> Link: https://lore.kernel.org/r/20240916111150.1266191-1-felix.moessbauer@siemens.com Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'io_uring')
-rw-r--r--io_uring/sqpoll.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/io_uring/sqpoll.c b/io_uring/sqpoll.c
index 10a2a20d89af..3331daa0aae3 100644
--- a/io_uring/sqpoll.c
+++ b/io_uring/sqpoll.c
@@ -395,15 +395,22 @@ __cold int io_sq_offload_create(struct io_ring_ctx *ctx,
return 0;
if (p->flags & IORING_SETUP_SQ_AFF) {
- struct cpumask allowed_mask;
+ cpumask_var_t allowed_mask;
int cpu = p->sq_thread_cpu;
ret = -EINVAL;
if (cpu >= nr_cpu_ids || !cpu_online(cpu))
goto err_sqpoll;
- cpuset_cpus_allowed(current, &allowed_mask);
- if (!cpumask_test_cpu(cpu, &allowed_mask))
+ ret = -ENOMEM;
+ if (!alloc_cpumask_var(&allowed_mask, GFP_KERNEL))
goto err_sqpoll;
+ ret = -EINVAL;
+ cpuset_cpus_allowed(current, allowed_mask);
+ if (!cpumask_test_cpu(cpu, allowed_mask)) {
+ free_cpumask_var(allowed_mask);
+ goto err_sqpoll;
+ }
+ free_cpumask_var(allowed_mask);
sqd->sq_cpu = cpu;
} else {
sqd->sq_cpu = -1;