Commit ecf818a5 authored by Yu Kuai's avatar Yu Kuai Committed by Yongqiang Liu
Browse files

cfq: fix memory leak for cfqq

hulk inclusion
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/I6CGZN


CVE: NA

--------------------------------

If cfqq is merged with another cfqq(assume that no cfqq is merged to
this cfqq) and then user thread is moved to another cgroup, then
check_blkcg_changed() will set cic->cfqq[0] to NULL. However, this cfqq is
still merged and no one will referece this cfqq, which will cause
following kmemleak:

comm "cgexec", pid 2541110, jiffies 4317578508 (age 5728.064s)
hex dump (first 32 bytes):
03 00 00 00 90 03 00 00 80 8d 0f be 20 80 ff ff ............ ...
a0 16 c6 a1 21 80 ff ff 00 00 00 00 00 00 00 00 ....!...........
backtrace:
[<0000000071d2775e>] kmem_cache_alloc_node+0x13c/0x660
[<00000000e827e6fd>] cfq_get_queue+0x318/0x6f0
[<00000000945249ee>] cfq_set_request+0x724/0xe38
[<00000000af64d5a9>] elv_set_request+0x84/0xd0
[<0000000047344f0d>] __get_request+0x970/0xf90
[<00000000d016bd51>] get_request+0x278/0x970
[<0000000052512d36>] blk_queue_bio+0x278/0xcc0
[<0000000085282101>] generic_make_request+0x3c0/0x778
[<0000000089f69c24>] submit_bio+0xdc/0x408
[<00000000748509ae>] ext4_mpage_readpages+0xc84/0x13b8 [ext4]
[<0000000078bfc705>] ext4_readpages+0x80/0xc0 [ext4]
[<00000000317f2ed7>] read_pages+0xd0/0x610
[<00000000e7ab01d2>] __do_page_cache_readahead+0x36c/0x430
[<0000000071df2285>] ondemand_readahead+0x24c/0x6b0
[<00000000124a824a>] page_cache_sync_readahead+0x188/0x448
[<00000000bca561ae>] generic_file_buffered_read+0x648/0x2b58
unreferenced object 0xffffa028411d4720 (size 240):

Fix the problem by put cooperator in check_blkcg_changed(), so that old
cfqq can be freed.

Signed-off-by: default avatarYu Kuai <yukuai3@huawei.com>
Reviewed-by: default avatarHou Tao <houtao1@huawei.com>
Signed-off-by: default avatarYongqiang Liu <liuyongqiang13@huawei.com>
parent ea2f18c2
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment