Skip to content

Commit 99b8874

Browse files
seedatorvalds
authored andcommitted
o2dlm: fix NULL pointer dereference in o2dlm_blocking_ast_wrapper
A tiny race between BAST and unlock message causes the NULL dereference. A node sends an unlock request to master and receives a response. Before processing the response it receives a BAST from the master. Since both requests are processed by different threads it creates a race. While the BAST is being processed, lock can get freed by unlock code. This patch makes bast to return immediately if lock is found but unlock is pending. The code should handle this race. We also have to fix master node to skip sending BAST after receiving unlock message. Below is the crash stack BUG: unable to handle kernel NULL pointer dereference at 0000000000000048 IP: o2dlm_blocking_ast_wrapper+0xd/0x16 dlm_do_local_bast+0x8e/0x97 [ocfs2_dlm] dlm_proxy_ast_handler+0x838/0x87e [ocfs2_dlm] o2net_process_message+0x395/0x5b8 [ocfs2_nodemanager] o2net_rx_until_empty+0x762/0x90d [ocfs2_nodemanager] worker_thread+0x14d/0x1ed [[email protected]: coding-style fixes] Signed-off-by: Srinivas Eeda <[email protected]> Reviewed-by: Mark Fasheh <[email protected]> Cc: Joel Becker <[email protected]> Cc: Joseph Qi <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 10ab881 commit 99b8874

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

fs/ocfs2/dlm/dlmast.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,8 +385,12 @@ int dlm_proxy_ast_handler(struct o2net_msg *msg, u32 len, void *data,
385385
head = &res->granted;
386386

387387
list_for_each_entry(lock, head, list) {
388-
if (lock->ml.cookie == cookie)
388+
/* if lock is found but unlock is pending ignore the bast */
389+
if (lock->ml.cookie == cookie) {
390+
if (lock->unlock_pending)
391+
break;
389392
goto do_ast;
393+
}
390394
}
391395

392396
mlog(0, "Got %sast for unknown lock! cookie=%u:%llu, name=%.*s, "

0 commit comments

Comments
 (0)