From mboxrd@z Thu Jan 1 00:00:00 1970 From: chao@kernel.org (Chao Yu) Date: Thu, 6 Dec 2018 21:51:07 +0800 Subject: [PATCH chao/erofs-dev 1/7] staging: erofs: fix use-after-free of on-stack `z_erofs_vle_unzip_io' In-Reply-To: <20181201183211.27406-1-gaoxiang25@huawei.com> References: <20181201183211.27406-1-gaoxiang25@huawei.com> Message-ID: <4bdd6147-d162-c5d3-b969-70d55d3bf447@kernel.org> On 2018-12-2 2:32, Gao Xiang wrote: > The root cause is the race as follows: > Thread #0 Thread #1 > > z_erofs_vle_unzip_kickoff z_erofs_submit_and_unzip > > struct z_erofs_vle_unzip_io io[] > atomic_add_return() > wait_event() > [end of function] > wake_up() > > Fix it by taking the waitqueue lock between atomic_add_return and > wake_up to close such the race. > > kernel message: > > Unable to handle kernel paging request at virtual address 97f7052caa1303dc > ... > Workqueue: kverityd verity_work > task: ffffffe32bcb8000 task.stack: ffffffe3298a0000 > PC is at __wake_up_common+0x48/0xa8 > LR is at __wake_up+0x3c/0x58 > ... > Call trace: > ... > [] __wake_up_common+0x48/0xa8 > [] __wake_up+0x3c/0x58 > [] z_erofs_vle_unzip_kickoff+0x40/0x64 > [] z_erofs_vle_read_endio+0x94/0x134 > [] bio_endio+0xe4/0xf8 > [] dec_pending+0x134/0x32c > [] clone_endio+0x90/0xf4 > [] bio_endio+0xe4/0xf8 > [] verity_work+0x210/0x368 > [] process_one_work+0x188/0x4b4 > [] worker_thread+0x140/0x458 > [] kthread+0xec/0x108 > [] ret_from_fork+0x10/0x1c > Code: d1006273 54000260 f9400804 b9400019 (b85fc081) > ---[ end trace be9dde154f677cd1 ]--- > > Signed-off-by: Gao Xiang > --- > Hi Chao, > could you please kindly update this patch series and > take a look them all? Thanks in advance. Sorry for the delay. Reviewed-by: Chao Yu Thanks,