Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1027119yba; Thu, 4 Apr 2019 02:45:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqzmHe3itknkJCaCzH8A2Q8ANXKnE8kxdg4GOVWIJglH7kym2UlGep7N5Z5ipMh6xK7ImGHr X-Received: by 2002:a63:2ec6:: with SMTP id u189mr5013537pgu.170.1554371099998; Thu, 04 Apr 2019 02:44:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554371099; cv=none; d=google.com; s=arc-20160816; b=b7uAtCwTVDYNCqQzLuwvN97vkPJCnio9hhVakE5O/kGzO2Zgbn8U9+FXhh+lLVooWZ GDTvQGWgAc0G/aGaaEaHK/MhWj3Pwry6xjipdJWcJbqlUB+oiBmbTPX89Hi1empacchN II55qLfmuuW+y/v7srq83BNnQci/SxM6zAAc14uSzaYEowDrJ4iCu/6E8KvGfBpixURi 8ZcKy/e1k40NcCS/xQsJ1AjFCSCvFB+T2/RC8r9wVQ9quFgR7DWNuHQlHTRYVv6pSU+Q DSAnYxBDZtx2PCxhdRFF4+I03B2kQNCUqMmpY82R+IiaGmICNCyStsu5082FdFYsJ0qU 7UaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=w20ShxEshMlxSp3RoGY300l+ai/6Ah1+hoAweTj3lUQ=; b=t7wWzwy+9xGujCpuNynAv1ELmuv8Fwv5Lm99b6umxJvhN66HOY5tbUQWd0RIqYxDP3 sdYii6ZPwNKYS+eoPRRPpz0o8iY3VX5x7Wj3pMtM5AntG7SHIPUDxEuhlgqyoc7oEOgd GQHShTi8AKfwRAvFOQkDpBocHNOl583/IERHWRfY1PTcjHUutAFcjEATNRfiTroH+XUt VQRFrUG/uIsQXmQKJUutniBkg7FZ6T3xlYvrmRPwW6W/Kp7bN+sXioIlT8sV/pOQY3lb NOiEGj4B2fiRRnGbdwc0LIAZAgz81QD7FhHXYfzN3ByoKz9pFc11n+AMaaFp5LqtlVUy ysJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=d82IqcDY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c20si15576123pfi.259.2019.04.04.02.44.44; Thu, 04 Apr 2019 02:44:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=d82IqcDY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730638AbfDDJAU (ORCPT + 99 others); Thu, 4 Apr 2019 05:00:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:36990 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729400AbfDDJAT (ORCPT ); Thu, 4 Apr 2019 05:00:19 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7E9C120652; Thu, 4 Apr 2019 09:00:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554368418; bh=vJb1cmKw6P74F+kef0gqKkn37dF5a7rKyOzdAAlj9TA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d82IqcDYQm74kZ1cFjyyJ39kQE4JCRK8W/dXP8XmqeveZtPKxKjj7oY5qMtsXkqzf 5TygaRhzpnSpHSfHJLkozhUa7FXERPvWDaIJrxuSIImRAPqTNZ2nZHUHte7SVio+uw QdYwyn6rkfcsuhnRa8f2AJtlQhDRXthkjIJVz82U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jia Guo , Joseph Qi , Jun Piao , Mark Fasheh , Joel Becker , Junxiao Bi , Changwei Ge , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 4.19 032/187] ocfs2: fix a panic problem caused by o2cb_ctl Date: Thu, 4 Apr 2019 10:46:09 +0200 Message-Id: <20190404084604.574547146@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190404084603.119654039@linuxfoundation.org> References: <20190404084603.119654039@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit cc725ef3cb202ef2019a3c67c8913efa05c3cce6 ] 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 = ®->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 Reviewed-by: Joseph Qi Acked-by: Jun Piao Cc: Mark Fasheh Cc: Joel Becker Cc: Junxiao Bi Cc: Changwei Ge Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- fs/ocfs2/cluster/nodemanager.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/fs/ocfs2/cluster/nodemanager.c b/fs/ocfs2/cluster/nodemanager.c index 0e4166cc23a0..4ac775e32240 100644 --- a/fs/ocfs2/cluster/nodemanager.c +++ b/fs/ocfs2/cluster/nodemanager.c @@ -621,13 +621,15 @@ static void o2nm_node_group_drop_item(struct config_group *group, struct o2nm_node *node = to_o2nm_node(item); struct o2nm_cluster *cluster = to_o2nm_cluster(group->cg_item.ci_parent); - o2net_disconnect_node(node); + if (cluster->cl_nodes[node->nd_num] == node) { + o2net_disconnect_node(node); - if (cluster->cl_has_local && - (cluster->cl_local_node == node->nd_num)) { - cluster->cl_has_local = 0; - cluster->cl_local_node = O2NM_INVALID_NODE_NUM; - o2net_stop_listening(node); + if (cluster->cl_has_local && + (cluster->cl_local_node == node->nd_num)) { + cluster->cl_has_local = 0; + cluster->cl_local_node = O2NM_INVALID_NODE_NUM; + o2net_stop_listening(node); + } } /* XXX call into net to stop this node from trading messages */ -- 2.19.1