From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1B667C4CEC9 for ; Wed, 18 Sep 2019 06:24:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DEF6321A4C for ; Wed, 18 Sep 2019 06:24:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1568787876; bh=EwNbQegCWsoYpEDw6vHvc3YzAC+pDYfqVNYn+RGVlo0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=heE/mhPT/JdPMvK0y/KeU2my+csaWEG38wJn5zSGEEhXa6lZTwdqWz7+WX0D9K0Dm eHqyb1/k7ESR6eZXn9HIFzck5vfBapDsGQfRA2VU1iMdl9Tlu6g2JSuWKPQMQAwu4B /DGLBRX6qyYfLGZHUzpuS7gl8tJXOLNsa/trfrh4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729876AbfIRGYf (ORCPT ); Wed, 18 Sep 2019 02:24:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:45066 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728780AbfIRGYc (ORCPT ); Wed, 18 Sep 2019 02:24:32 -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 6710721920; Wed, 18 Sep 2019 06:24:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1568787871; bh=EwNbQegCWsoYpEDw6vHvc3YzAC+pDYfqVNYn+RGVlo0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LxBqNRAhQZCZz1GsQP0kH0wLzR0jypJGCmRyql7Ihq+Gn7z50EGFVFvJYnE3aID8Y whPq6VARJOstayCKo41h7J5Zi0yKkmGS6Yz8KTP15wa5DEFUNS11RTt7cujnJlr0qy GYEUgKK0zONStPfQXzJlQF0TjmdAhit7yZoBLvIQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Li Shuang , Xin Long , "David S. Miller" Subject: [PATCH 5.2 15/85] tipc: add NULL pointer check before calling kfree_rcu Date: Wed, 18 Sep 2019 08:18:33 +0200 Message-Id: <20190918061234.627889799@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190918061234.107708857@linuxfoundation.org> References: <20190918061234.107708857@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Xin Long [ Upstream commit 42dec1dbe38239cf91cc1f4df7830c66276ced37 ] Unlike kfree(p), kfree_rcu(p, rcu) won't do NULL pointer check. When tipc_nametbl_remove_publ returns NULL, the panic below happens: BUG: unable to handle kernel NULL pointer dereference at 0000000000000068 RIP: 0010:__call_rcu+0x1d/0x290 Call Trace: tipc_publ_notify+0xa9/0x170 [tipc] tipc_node_write_unlock+0x8d/0x100 [tipc] tipc_node_link_down+0xae/0x1d0 [tipc] tipc_node_check_dest+0x3ea/0x8f0 [tipc] ? tipc_disc_rcv+0x2c7/0x430 [tipc] tipc_disc_rcv+0x2c7/0x430 [tipc] ? tipc_rcv+0x6bb/0xf20 [tipc] tipc_rcv+0x6bb/0xf20 [tipc] ? ip_route_input_slow+0x9cf/0xb10 tipc_udp_recv+0x195/0x1e0 [tipc] ? tipc_udp_is_known_peer+0x80/0x80 [tipc] udp_queue_rcv_skb+0x180/0x460 udp_unicast_rcv_skb.isra.56+0x75/0x90 __udp4_lib_rcv+0x4ce/0xb90 ip_local_deliver_finish+0x11c/0x210 ip_local_deliver+0x6b/0xe0 ? ip_rcv_finish+0xa9/0x410 ip_rcv+0x273/0x362 Fixes: 97ede29e80ee ("tipc: convert name table read-write lock to RCU") Reported-by: Li Shuang Signed-off-by: Xin Long Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/tipc/name_distr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/net/tipc/name_distr.c +++ b/net/tipc/name_distr.c @@ -223,7 +223,8 @@ static void tipc_publ_purge(struct net * publ->key); } - kfree_rcu(p, rcu); + if (p) + kfree_rcu(p, rcu); } /**