From patchwork Fri Jan 25 06:05:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jia Guo X-Patchwork-Id: 10780605 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BE52791E for ; Fri, 25 Jan 2019 06:07:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9DF812E82E for ; Fri, 25 Jan 2019 06:07:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 91B6A2F071; Fri, 25 Jan 2019 06:07:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from userp2130.oracle.com (userp2130.oracle.com [156.151.31.86]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E15C52E82E for ; Fri, 25 Jan 2019 06:07:37 +0000 (UTC) Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id x0P63lYn174564; Fri, 25 Jan 2019 06:07:26 GMT Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2130.oracle.com with ESMTP id 2q3uav3uff-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 25 Jan 2019 06:07:25 +0000 Received: from oss.oracle.com (oss-old-reserved.oracle.com [137.254.22.2]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id x0P67MTk006527 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 25 Jan 2019 06:07:22 GMT Received: from localhost ([127.0.0.1] helo=lb-oss.oracle.com) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1gmueA-0003Y5-Gb; Thu, 24 Jan 2019 22:07:22 -0800 Received: from aserv0022.oracle.com ([141.146.126.234]) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1gmudE-0003WN-JZ for ocfs2-devel@oss.oracle.com; Thu, 24 Jan 2019 22:06:25 -0800 Received: from userp2040.oracle.com (userp2040.oracle.com [156.151.31.90]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id x0P66Nk8001538 (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 25 Jan 2019 06:06:24 GMT Received: from pps.filterd (userp2040.oracle.com [127.0.0.1]) by userp2040.oracle.com (8.16.0.22/8.16.0.22) with SMTP id x0P5xTBP033928 for ; Fri, 25 Jan 2019 06:06:23 GMT Received: from huawei.com (szxga04-in.huawei.com [45.249.212.190]) by userp2040.oracle.com with ESMTP id 2q7mmx1vmw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Fri, 25 Jan 2019 06:06:23 +0000 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id E327E2AB661CD73FEC0D; Fri, 25 Jan 2019 14:06:18 +0800 (CST) Received: from [10.177.218.160] (10.177.218.160) by smtp.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.408.0; Fri, 25 Jan 2019 14:06:12 +0800 To: "mark@fasheh.com" , "jlbec@evilplan.org" , "junxiao.bi@oracle.com" , "jiangqi903@gmail.com" , "akpm@linux-foundation.org" From: Jia Guo Message-ID: <00174f72-6e5f-e049-2144-d0bb177e24a5@huawei.com> Date: Fri, 25 Jan 2019 14:05:51 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 Content-Language: en-US X-Originating-IP: [10.177.218.160] X-CFilter-Loop: Reflected X-CLX-Shades: MLX X-CLX-Response: 1TFkXGBoTEQpMehcbGBwRCllEF2cTbWAbW2VCH359EQpZTEMXZWRfQlhJHUg cTlkRCllDF2loGllaWW5/HBoSEQpZTRdnZnIRCllJFxpxGhAadwYbEhNxHR0QGncGGBoGGhEKWV 4XaG5mEQpJRhdFWEtJRk91WlhFTl9JXkNFRBl1T0sRCkNOF2lvbn9AeUxOZUhEYnxYcH5AUl1lf 25/f35CT38cXmcYEQpYXBcfBBoEGxwbBx4aSxhOEk8fBRsaBBsaGgQeEgQbEBseGh8aEQpeWRd+ TW9cHBEKTVwXHxodEQpMWhdpaGlCTV0RCk1OF2gRCkNaFx4fBBgeEwQYGxgEGxMaEQpCXhcbEQp EXhcbGhEKREkXHhEKQkYXZxNtYBtbZUIffn0RCkJcFxoRCkJFF2NBYBJZQh1kGEcZEQpCThdsQk hZUxpNZXh4HREKQkwXa3BaS0hGBV1TbhIRCkJsF2BtE2wBGkFoThx7EQpCQBdve1tpTmlJaHBCY BEKQlgXYn1veQFPGBlwcHsRClpYFxgRCnBoF3pfbX5LTlxbExwSEBoRCnBoF2xDfBITGhNwAWNk EBoRCnBoF2QTGh99cnlleGZfEBoRCnBoF21YGUsbX31nQh8dEBoRCnBoF2ZsXW5+T35mW2NOEBo RCnBsF2B6GX4cRF5rWgEZEBkaEQptfhcaEQpYTRdLESA= X-PDR: PASS X-Source-IP: 45.249.212.190 X-ServerName: szxga04-in.huawei.com X-Proofpoint-SPF-Result: pass X-Proofpoint-SPF-Record: v=spf1 ip4:45.249.212.32 ip4:45.249.212.35 ip4:119.145.14.93 ip4:58.251.152.93 ip4:206.16.17.72 ip4:45.249.212.255 ip4:45.249.212.187/29 ip4:45.249.212.191 ip4:185.176.76.210 ~all X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9146 signatures=668682 X-Proofpoint-DMARC-Record: none X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=126 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=209 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901250049 X-Spam: Clean Cc: "ocfs2-devel@oss.oracle.com" Subject: [Ocfs2-devel] [PATCH] ocfs2: fix a panic problem caused by o2cb_ctl X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.9 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ocfs2-devel-bounces@oss.oracle.com Errors-To: ocfs2-devel-bounces@oss.oracle.com X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9146 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901250049 X-Virus-Scanned: ClamAV using ClamSMTP In the process of creating a node, it will cause NULL pointer reference 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. Signed-off-by: Jia Guo --- fs/ocfs2/cluster/nodemanager.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/fs/ocfs2/cluster/nodemanager.c b/fs/ocfs2/cluster/nodemanager.c index 0e4166c..992ccc0 100644 --- a/fs/ocfs2/cluster/nodemanager.c +++ b/fs/ocfs2/cluster/nodemanager.c @@ -620,10 +620,16 @@ 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); + int nd_num_set = 0; - o2net_disconnect_node(node); + /* nd_num might be 0 if the node number hasn't been set.. */ + if (cluster->cl_nodes[node->nd_num] == node) { + nd_num_set = 1; + + if (nd_num_set) + o2net_disconnect_node(node); - if (cluster->cl_has_local && + if (nd_num_set && cluster->cl_has_local && (cluster->cl_local_node == node->nd_num)) { cluster->cl_has_local = 0; cluster->cl_local_node = O2NM_INVALID_NODE_NUM; @@ -638,8 +644,7 @@ static void o2nm_node_group_drop_item(struct config_group *group, if (node->nd_ipv4_address) rb_erase(&node->nd_ip_node, &cluster->cl_node_ip_tree); - /* nd_num might be 0 if the node number hasn't been set.. */ - if (cluster->cl_nodes[node->nd_num] == node) { + if (nd_num_set) { cluster->cl_nodes[node->nd_num] = NULL; clear_bit(node->nd_num, cluster->cl_nodes_bitmap); }