io_uring/io-wq: Fix memory leak in io_wq_create() on success path
Subsystems (2)
PATCH v2 1/1 io_uring/io-wq: Fix memory leak in io_wq_create() on success path
[ This is a stable-only patch for 6.1.y ]
Commit 657ca82526d0 ("io_uring/io-wq: inherit cpuset of cgroup in io worker") was backported from upstream commit 84eacf177faa to 6.1.y.
In linux-6.1.y, this backport introduced a temporary allowed_mask variable in io_wq_create(). It is correctly freed on the error path, but is not freed on the success path. As a result, every successful call to io_wq_create() leaks cpumask_size() bytes of memory.
This is a 6.1-specific backport issue caused by the differences in the io-wq implementation, so the fix only applies to 6.1.y.
---
Hi Greg, Sasha, and io-uring maintainers,
This patch is specific to 6.1.y. Commit 657ca82526d0 was a manual backport of upstream commit 84eacf177faa ("io_uring/io-wq: inherit cpuset of cgroup in io worker"). Due to significant differences in the io-wq implementation between 6.1 and later kernels, the upstream change had to be adapted for 6.1.
Later stable kernels do not contain this 6.1-specific backported implementation of io_wq_create(), and therefore do not contain the leaked allowed_mask. The corresponding upstream implementation also does not have this allocation.
Therefore, this fix is only applicable to 6.1.y and should not be backported to other stable kernel series.
upstream patch: https://lore.kernel.org/all/[email protected]/
backport patch: https://lore.kernel.org/all/[email protected]/
Could you please queue it for 6.1.y?
Thanks,
Chen Xiaokun
Changes since v1:
- Reword the commit message (clarify that this is a 6.1-specific backport patch)
- No functional changes
io_uring/io-wq.c | 1 + 1 file changed, 1 insertion(+)
io_uring/io-wq.c +1 -0
@@ -1221,6 +1221,7 @@ struct io_wq *io_wq_create(unsigned bounded, struct io_wq_data *data) wq->task =get_task_struct (data->task);atomic_set (&wq->worker_refs,1 );init_completion (&wq->worker_done); +free_cpumask_var (allowed_mask);return wq; err:io_wq_put_hash (data->hash);
Signature · 1 line
2.55.0
Quoted 10 lines · Chen Xiaokun
[ This is a stable-only patch for 6.1.y ]
Commit
657ca82526d0("io_uring/io-wq: inherit cpuset of cgroup in io worker") was backported from upstream commit84eacf177faato 6.1.y.In linux-6.1.y, this backport introduced a temporary
allowed_maskvariable inio_wq_create(). It is correctly freed on the error path, but is not freed on the success path. As a result, every successful call toio_wq_create()leakscpumask_size()bytes of memory.
Quoted 5 lines
This is a 6.1-specific backport issue caused by the differences in the io-wq implementation, so the fix only applies to 6.1.y.
Fixes 657ca82526d0 ("io_uring/io-wq: inherit cpuset of cgroup in io worker")Signed-off-by Chen Xiaokun <[email protected]>
Thanks for the fix!
Felix
Quoted 47 lines
---
Hi Greg, Sasha, and io-uring maintainers,This patch is specific to 6.1.y. Commit
657ca82526d0was a manual backport of upstream commit84eacf177faa("io_uring/io-wq: inherit cpuset of cgroup in io worker"). Due to significant differences in the io-wq implementation between 6.1 and later kernels, the upstream change had to be adapted for 6.1.Later stable kernels do not contain this 6.1-specific backported implementation of
io_wq_create(), and therefore do not contain the leakedallowed_mask. The corresponding upstream implementation also does not have this allocation.Therefore, this fix is only applicable to 6.1.y and should not be backported to other stable kernel series.
upstream patch: https://lore.kernel.org/all/[email protected]/
backport patch: https://lore.kernel.org/all/[email protected]/Could you please queue it for 6.1.y?
Thanks,
Chen XiaokunChanges since v1:
- Reword the commit message (clarify that this is a 6.1-specific backport patch)
- No functional changesio_uring/io-wq.c | 1 + 1 file changed, 1 insertion(+)io_uring/io-wq.c +1
-0@@ -1221,6 +1221,7 @@ struct io_wq *io_wq_create(unsigned bounded, struct io_wq_data *data) wq->task =get_task_struct (data->task);atomic_set (&wq->worker_refs,1 );init_completion (&wq->worker_done); +free_cpumask_var (allowed_mask);return wq; err:io_wq_put_hash (data->hash);Signature · 1 line
2.55.0
Quoted 4 lines
In linux-6.1.y, this backport introduced a temporary
allowed_maskvariable inio_wq_create(). It is correctly freed on the error path, but is not freed on the success path. As a result, every successful call toio_wq_create()leakscpumask_size()bytes of memory.
Queued for 6.1, thanks.
Signature · 2 lines
Thanks, Sasha