Whamcloud - gitweb
LU-12225 obdclass: fix race access vs removal of jobid_hash 07/35007/2
authorWang Shilong <wshilong@ddn.com>
Mon, 29 Apr 2019 12:46:47 +0000 (20:46 +0800)
committerOleg Drokin <green@whamcloud.com>
Sat, 8 Jun 2019 02:38:49 +0000 (02:38 +0000)
commit1dd46563439cc35b54ca97a6446eeaf0fe1ccd8c
tree0aee9bb8baf5e33290f4325133357f6ab4d7f032
parent2059acdcaee186256ce0eeae2f28b090058b0b39
LU-12225 obdclass: fix race access vs removal of jobid_hash

We added @pidmap into hash and reference count will be 1.
However, another thread might reclaim this newely added
@pidmap from hash list, we try to access this @pidmap
will become a user-after-free operation.

Fix this problem by init reference count as 1 before
adding hash list, which gurantee memory could be not
freed during our access.

Check other places where memory reclaim used did similar
idea like this.

Lustre-change: https://review.whamcloud.com/34763
Lustre-commit: b664182e0361731fa409ac6a0a0f19637a7e5288

Change-Id: Idd5f429b97e064e29b6883243f8a012c2b4b4ae7
Signed-off-by: Wang Shilong <wshilong@ddn.com>
Reviewed-by: Patrick Farrell <pfarrell@whamcloud.com>
Reviewed-by: Gu Zheng <gzheng@ddn.com>
Signed-off-by: Minh Diep <mdiep@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/35007
Tested-by: Jenkins
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/obdclass/jobid.c