Skip to content

Commit cc725ef

Browse files
guojia1992torvalds
authored andcommitted
ocfs2: fix a panic problem caused by o2cb_ctl
In the process of creating a node, it will cause NULL pointer dereference in kernel if o2cb_ctl failed in the interval (mkdir, o2cb_set_node_attribute(node_num)] in function o2cb_add_node. The node num is initialized to 0 in function o2nm_node_group_make_item, o2nm_node_group_drop_item will mistake the node number 0 for a valid node number when we delete the node before the node number is set correctly. If the local node number of the current host happens to be 0, cluster->cl_local_node will be set to O2NM_INVALID_NODE_NUM while o2hb_thread still running. The panic stack is generated as follows: o2hb_thread \-o2hb_do_disk_heartbeat \-o2hb_check_own_slot |-slot = &reg->hr_slots[o2nm_this_node()]; //o2nm_this_node() return O2NM_INVALID_NODE_NUM We need to check whether the node number is set when we delete the node. Link: http://lkml.kernel.org/r/133d8045-72cc-863e-8eae-5013f9f6bc51@huawei.com Signed-off-by: Jia Guo <guojia12@huawei.com> Reviewed-by: Joseph Qi <jiangqi903@gmail.com> Acked-by: Jun Piao <piaojun@huawei.com> Cc: Mark Fasheh <mark@fasheh.com> Cc: Joel Becker <jlbec@evilplan.org> Cc: Junxiao Bi <junxiao.bi@oracle.com> Cc: Changwei Ge <ge.changwei@h3c.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 6855369 commit cc725ef

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

fs/ocfs2/cluster/nodemanager.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -621,13 +621,15 @@ static void o2nm_node_group_drop_item(struct config_group *group,
621621
struct o2nm_node *node = to_o2nm_node(item);
622622
struct o2nm_cluster *cluster = to_o2nm_cluster(group->cg_item.ci_parent);
623623

624-
o2net_disconnect_node(node);
624+
if (cluster->cl_nodes[node->nd_num] == node) {
625+
o2net_disconnect_node(node);
625626

626-
if (cluster->cl_has_local &&
627-
(cluster->cl_local_node == node->nd_num)) {
628-
cluster->cl_has_local = 0;
629-
cluster->cl_local_node = O2NM_INVALID_NODE_NUM;
630-
o2net_stop_listening(node);
627+
if (cluster->cl_has_local &&
628+
(cluster->cl_local_node == node->nd_num)) {
629+
cluster->cl_has_local = 0;
630+
cluster->cl_local_node = O2NM_INVALID_NODE_NUM;
631+
o2net_stop_listening(node);
632+
}
631633
}
632634

633635
/* XXX call into net to stop this node from trading messages */

0 commit comments

Comments
 (0)