diff options
| author | ZhaoLong Wang <wangzhaolong1@huawei.com> | 2023-03-04 09:41:41 +0800 | 
|---|---|---|
| committer | Richard Weinberger <richard@nod.at> | 2023-03-04 17:59:12 +0100 | 
| commit | f773f0a331d6c41733b17bebbc1b6cae12e016f5 (patch) | |
| tree | 611ebfffc8ddbb2d2da158bddd8fb4e8497b2be3 /tools/testing/selftests/bpf/prog_tests/timer.c | |
| parent | 0988a0ea791999ebbf95693f2676381825b05033 (diff) | |
ubi: Fix deadlock caused by recursively holding work_sem
During the processing of the bgt, if the sync_erase() return -EBUSY
or some other error code in __erase_worker(),schedule_erase() called
again lead to the down_read(ubi->work_sem) hold twice and may get
block by down_write(ubi->work_sem) in ubi_update_fastmap(),
which cause deadlock.
          ubi bgt                        other task
 do_work
  down_read(&ubi->work_sem)          ubi_update_fastmap
  erase_worker                         # Blocked by down_read
   __erase_worker                      down_write(&ubi->work_sem)
    schedule_erase
     schedule_ubi_work
      down_read(&ubi->work_sem)
Fix this by changing input parameter @nested of the schedule_erase() to
'true' to avoid recursively acquiring the down_read(&ubi->work_sem).
Also, fix the incorrect comment about @nested parameter of the
schedule_erase() because when down_write(ubi->work_sem) is held, the
@nested is also need be true.
Link: https://bugzilla.kernel.org/show_bug.cgi?id=217093
Fixes: 2e8f08deabbc ("ubi: Fix races around ubi_refill_pools()")
Signed-off-by: ZhaoLong Wang <wangzhaolong1@huawei.com>
Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
Diffstat (limited to 'tools/testing/selftests/bpf/prog_tests/timer.c')
0 files changed, 0 insertions, 0 deletions
