]> git.karo-electronics.de Git - karo-tx-linux.git/commit
ocfs2: avoid access invalid address when read o2dlm debug messages
authorjiangyiwen <jiangyiwen@huawei.com>
Tue, 7 Apr 2015 23:43:58 +0000 (09:43 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Tue, 7 Apr 2015 23:43:58 +0000 (09:43 +1000)
commit8b4beb712f364fa2bcaf4835c0623cdff4ba55c1
tree26a109eda62af06fcf4f96b57e3445281898d860
parent828c6595df5c78a5d670bbd83b0066b93a626b59
ocfs2: avoid access invalid address when read o2dlm debug messages

The following case will lead to a lockres is freed but is still in use.

cat /sys/kernel/debug/o2dlm/locking_state dlm_thread
lockres_seq_start
    -> lock dlm->track_lock
    -> get resA
                                                resA->refs decrease to 0,
                                                call dlm_lockres_release,
                                                and wait for "cat" unlock.
Although resA->refs is already set to 0,
increase resA->refs, and then unlock
                                                lock dlm->track_lock
                                                    -> list_del_init()
                                                    -> unlock
                                                    -> free resA

In such a race case, invalid address access may occurs.  So we should
delete list res->tracking before resA->refs decrease to 0.

Signed-off-by: Yiwen Jiang <jiangyiwen@huawei.com>
Reviewed-by: Joseph Qi <joseph.qi@huawei.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Mark Fasheh <mfasheh@suse.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
fs/ocfs2/dlm/dlmmaster.c
fs/ocfs2/dlm/dlmthread.c