Skip to contentSkip to conversation

ocfs2: Fix freeing uninitialized resource on ocfs2_dlm_shutdown

PATCH Superseded Heming Zhao via Ocfs2-devel 1 participant 2 messages Aug 11, 2022 – Aug 15, 2022 OCFS2

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ocfs2: Fix freeing uninitialized resource on ocfs2_dlm_shutdown

On local mount mode, no dlm resource is initialized. If ocfs2_mount_volume() fails in ocfs2_find_slot(), error handling will call ocfs2_dlm_shutdown(), then does dlm resource cleanup job, which will trigger kernel crash.

Fixes 0737e01de9c4 ("ocfs2: ocfs2_mount_volume does cleanup job before return error")

---
draft -> v1:
- separate to a single patch
- by review comment:
- do free lockres in shutdown path
- put 'Fixes' string in one line
- revise misspelled & grammar mistake in commit log

---
 fs/ocfs2/dlmglue.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
fs/ocfs2/dlmglue.c +5 -3
index 801e60bab955..c28bc983a7b1 100644
@@ -3403,10 +3403,12 @@ void ocfs2_dlm_shutdown(struct ocfs2_super *osb,
 	ocfs2_lock_res_free(&osb->osb_nfs_sync_lockres);
 	ocfs2_lock_res_free(&osb->osb_orphan_scan.os_lockres);
 
-	ocfs2_cluster_disconnect(osb->cconn, hangup_pending);
-	osb->cconn = NULL;
+	if (osb->cconn) {
+		ocfs2_cluster_disconnect(osb->cconn, hangup_pending);
+		osb->cconn = NULL;
 
-	ocfs2_dlm_shutdown_debug(osb);
+		ocfs2_dlm_shutdown_debug(osb);
+	}
 }
 
 static int ocfs2_drop_lock(struct ocfs2_super *osb,
Signature · 7 lines
2.37.1


_______________________________________________
Ocfs2-devel mailing list
[email protected]
https://oss.oracle.com/mailman/listinfo/ocfs2-devel
#1 lore raw
Quoted 2 lines · Heming Zhao

On local mount mode, no dlm resource is initialized. If ocfs2_mount_volume() fails in ocfs2_find_slot(), error handling

In fact, any procedure after ocfs2_dlm_init() fails will trigger this issue. So we'd better describe it clearly, or just take the above case as a example.

Quoted 26 lines

will call ocfs2_dlm_shutdown(), then does dlm resource cleanup job, which will trigger kernel crash.

Fixes 0737e01de9c4 ("ocfs2: ocfs2_mount_volume does cleanup job before return error")

---
draft -> v1:
- separate to a single patch
- by review comment:
- do free lockres in shutdown path
- put 'Fixes' string in one line
- revise misspelled & grammar mistake in commit log

---
 fs/ocfs2/dlmglue.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
fs/ocfs2/dlmglue.c +0 -2
index 801e60bab955..c28bc983a7b1 100644
@@ -3403,10 +3403,12 @@ void ocfs2_dlm_shutdown(struct ocfs2_super *osb,
 	ocfs2_lock_res_free(&osb->osb_nfs_sync_lockres);
 	ocfs2_lock_res_free(&osb->osb_orphan_scan.os_lockres);
 
-	ocfs2_cluster_disconnect(osb->cconn, hangup_pending);
-	osb->cconn = NULL;

fs/ocfs2/dlmglue.c void ocfs2_dlm_shutdown(struct ocfs2_super *osb, · line 3414

Quoted 10 lines
fs/ocfs2/dlmglue.c +5 -1
+	if (osb->cconn) {
+		ocfs2_cluster_disconnect(osb->cconn, hangup_pending);
+		osb->cconn = NULL;
 
-	ocfs2_dlm_shutdown_debug(osb);
+		ocfs2_dlm_shutdown_debug(osb);
+	}
 }
 
 static int ocfs2_drop_lock(struct ocfs2_super *osb,

The checking osb->cconn in ocfs2_dismount_volume() has to be removed.

Thanks,
Joseph

_______________________________________________
Ocfs2-devel mailing list
[email protected]
https://oss.oracle.com/mailman/listinfo/ocfs2-devel