Received: by 2002:a25:b323:0:0:0:0:0 with SMTP id l35csp1247940ybj; Fri, 20 Sep 2019 07:29:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqyXKgx6HAXseYJwS3wHofRak2Q8tUGSaJwvzMxXnm4dPhzdKZ0QtBc736loPTW0Hpy/GdxO X-Received: by 2002:a17:907:2124:: with SMTP id qo4mr19091248ejb.311.1568989755433; Fri, 20 Sep 2019 07:29:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568989755; cv=none; d=google.com; s=arc-20160816; b=KdUSC8+ah/8h5EHI2mESiSSwtwfnev0yh0HHy0LMVTi4oADE3lnFD5JRKdp063uO4/ LLS0z5QRvOlvWOZj8sAPkD3HjP/MVpXCEGILWMLKVkcGl1H1k6FSGG2IskBuqbJtZ6b5 yXRom25cRb28Qz7CdS6wKL6JJnD0eWYOAlO3Ngd6KTdJGHT1IYUdE0oHuPARhVMcbk+g Xo0+Jr98BMt23v15nKTd/9agKx2xjgb4X3bBAUDICO44esKE2zHLn5AkYODtf45ZTck+ MPEzCHoWLBG/lCP8Clm2Bd46sXneWsrQNteg+FTfaljNkoOp8iTEvAazCq0pw0iquWR4 7e5Q== 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=Kabupgoeq7M4DCaKVlFxLprPC3pxgWhQlP45Zm+TQ4w=; b=03Ou/6VRCQbZSTc2b/6hpVmcjV+NI8nCRRp75IsW5dw9QnL1adjSFm0xi2r9+HUTlS ZNUTixWneuGwLZBQIsR1JQUuBllQH2ZoCOsjcitel2sZxhbULwdcd1uufYtYRLhq/u7k YPSbvwVeCxYakiqpBJUxnSGHMkWrMN3pbfaOdz/YENZBQ1itdK4M+5jCeROT/CvtABN7 5J5wJiYCcLn8tCWrcwDiKwZvF6Zlr+SwXEaROVspLvRD377gJGleGt/LHeC1P+x+0UXA F6xnk9GEMH50MqrRlFiLaax/B5ZJm/2vv3azF7XaRwFWs0gM1Hf+1mjHN8bBt/sEpVdB bf+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bB2ioGJ8; 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 nl6si1148412ejb.207.2019.09.20.07.28.51; Fri, 20 Sep 2019 07:29:15 -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=bB2ioGJ8; 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 S2406936AbfISWWx (ORCPT + 99 others); Thu, 19 Sep 2019 18:22:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:38114 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406910AbfISWWv (ORCPT ); Thu, 19 Sep 2019 18:22:51 -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 0882A21920; Thu, 19 Sep 2019 22:22:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1568931770; bh=JZD1Aid+y/Gpw+xCYHlRE+v2aDotVsNhARNQaLCm6K8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bB2ioGJ8nZpXKHPbjVSrcFeoObL2n68AX/8KRU1Q/E+74gPdWunq4Dg8dsvgXw92G AnKOy7fh1s90dcI/MvAZSBjwtKMhceVG7A5VA22IknktVbinhZl1ojZB8ypQZUF/jB QBoR+M0zRexgIB50P5ZkpS+E8DZZvLRlUCbl9UXs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sean Tranchetti , Subash Abhinov Kasiviswanathan , "David S. Miller" Subject: [PATCH 4.4 05/56] net: Fix null de-reference of device refcount Date: Fri, 20 Sep 2019 00:03:46 +0200 Message-Id: <20190919214746.405086721@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190919214742.483643642@linuxfoundation.org> References: <20190919214742.483643642@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: Subash Abhinov Kasiviswanathan [ Upstream commit 10cc514f451a0f239aa34f91bc9dc954a9397840 ] In event of failure during register_netdevice, free_netdev is invoked immediately. free_netdev assumes that all the netdevice refcounts have been dropped prior to it being called and as a result frees and clears out the refcount pointer. However, this is not necessarily true as some of the operations in the NETDEV_UNREGISTER notifier handlers queue RCU callbacks for invocation after a grace period. The IPv4 callback in_dev_rcu_put tries to access the refcount after free_netdev is called which leads to a null de-reference- 44837.761523: <6> Unable to handle kernel paging request at virtual address 0000004a88287000 44837.761651: <2> pc : in_dev_finish_destroy+0x4c/0xc8 44837.761654: <2> lr : in_dev_finish_destroy+0x2c/0xc8 44837.762393: <2> Call trace: 44837.762398: <2> in_dev_finish_destroy+0x4c/0xc8 44837.762404: <2> in_dev_rcu_put+0x24/0x30 44837.762412: <2> rcu_nocb_kthread+0x43c/0x468 44837.762418: <2> kthread+0x118/0x128 44837.762424: <2> ret_from_fork+0x10/0x1c Fix this by waiting for the completion of the call_rcu() in case of register_netdevice errors. Fixes: 93ee31f14f6f ("[NET]: Fix free_netdev on register_netdev failure.") Cc: Sean Tranchetti Signed-off-by: Subash Abhinov Kasiviswanathan Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/core/dev.c | 2 ++ 1 file changed, 2 insertions(+) --- a/net/core/dev.c +++ b/net/core/dev.c @@ -6837,6 +6837,8 @@ int register_netdevice(struct net_device ret = notifier_to_errno(ret); if (ret) { rollback_registered(dev); + rcu_barrier(); + dev->reg_state = NETREG_UNREGISTERED; } /*