From patchwork Mon Nov 23 12:21:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 330657 Delivered-To: patch@linaro.org Received: by 2002:a92:ae0b:0:0:0:0:0 with SMTP id s11csp1959275ilh; Mon, 23 Nov 2020 04:36:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJwYjxre6uGCpUKIC2mCvw9Y7d56dEJs1QNS4lLldACIzAOeZ37LsVELmJRmY4uAu0I6aDKg X-Received: by 2002:a17:906:6013:: with SMTP id o19mr42718845ejj.348.1606134974915; Mon, 23 Nov 2020 04:36:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606134974; cv=none; d=google.com; s=arc-20160816; b=YF26Il/NAkXweZl/MubfXkxpjnzDdDFt6wqjFB2tAFN0X3Gxp2Cmfv+ENJMRzejsLz i7T8HNOOgSbsyMmWhRwCJ6m2U9M8FB25XUI8g5JELPqPRKiEoPetIH6G3pvOJAgpI0ao xBxX0q2lOLid0+FutQlKSvNIAoSVm5OrKxNRCh2Vh4N5We+fOXDrsPPlHXbUBODmUTm0 jOQnUI2zJdlrdY0Xv0tPi9K+fqPhR6r0wSKyx07zIPZ9jxK657KskyRtv1wS3fAtlNMZ sa+M3ENcC2HA9vM4RV2zLCduVsVB97I4zHL2apYu6HU9XMLN4Kqte2Jgnn2seCAT14Z2 4+JA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=J+fCjaBHvBQ83W8K9pyupo4GK/gLWNwkVsmxPv2lR3Q=; b=G1L4Xi/NiIkAiDjVL9yNRSLo03a/SnzYozQzkYKI2+ZGq8LqHO/9v5eRb1t0MTlgiG OS2lIf5AzvtyzbWIN1VdU4Kyqzh+xSYfRToYuAL1pwW97mZC3jfHcfOcuhW6agPj6Md4 GJXPU9CY5XS0mN2AxMauRFgR3KZwvWXaB5kSMB2mlKw9wjg6xNa9GCsZePUtDw1Iz7kS 5kPexpbgjry4j7qSw8qZ2ygY3Ziz6Ku/tJNYiagqUW+paL5FFvzCMp7tQWkYeTx5aOvj 8oKE8MagkxIphI7fOjSmHzeOthKDY13ZgfNAOeijF05NUGa/ALgPmxUwQLF/bHXgdjfz QiLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2PvP2aOh; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s15si1087184edx.431.2020.11.23.04.36.14; Mon, 23 Nov 2020 04:36:14 -0800 (PST) Received-SPF: pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2PvP2aOh; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731465AbgKWMe7 (ORCPT + 14 others); Mon, 23 Nov 2020 07:34:59 -0500 Received: from mail.kernel.org ([198.145.29.99]:46672 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731457AbgKWMe6 (ORCPT ); Mon, 23 Nov 2020 07:34:58 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 732342065E; Mon, 23 Nov 2020 12:34:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606134898; bh=bEbapw5/VVp1IRlz7gDCpdXyeD9oqpWUXCEzLsHBmhA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2PvP2aOhfT5owBeTqfOxqQc1i1JkSgtogT8WcRUFiKcP5ZxSp26Q5jXK/DO6IbYLx Mcw8SllyldwdOevTiuEJzth22mv32gPa+MWVa6jW0ejJnOPFN776P0l9Y4uaxlYZ8E KjLV2LaviMypTS4FfmkiXIiLf2nAZavsaONA7WuQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Joel Stanley , Samuel Mendoza-Jonas , Jakub Kicinski Subject: [PATCH 5.4 032/158] net/ncsi: Fix netlink registration Date: Mon, 23 Nov 2020 13:21:00 +0100 Message-Id: <20201123121821.486700156@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201123121819.943135899@linuxfoundation.org> References: <20201123121819.943135899@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Joel Stanley [ Upstream commit 1922a46b8c18cb09d33e06a6cc2e43844ac1b9d0 ] If a user unbinds and re-binds a NC-SI aware driver the kernel will attempt to register the netlink interface at runtime. The structure is marked __ro_after_init so registration fails spectacularly at this point. # echo 1e660000.ethernet > /sys/bus/platform/drivers/ftgmac100/unbind # echo 1e660000.ethernet > /sys/bus/platform/drivers/ftgmac100/bind ftgmac100 1e660000.ethernet: Read MAC address 52:54:00:12:34:56 from chip ftgmac100 1e660000.ethernet: Using NCSI interface 8<--- cut here --- Unable to handle kernel paging request at virtual address 80a8f858 pgd = 8c768dd6 [80a8f858] *pgd=80a0841e(bad) Internal error: Oops: 80d [#1] SMP ARM CPU: 0 PID: 116 Comm: sh Not tainted 5.10.0-rc3-next-20201111-00003-gdd25b227ec1e #51 Hardware name: Generic DT based system PC is at genl_register_family+0x1f8/0x6d4 LR is at 0xff26ffff pc : [<8073f930>] lr : [] psr: 20000153 sp : 8553bc80 ip : 81406244 fp : 8553bd04 r10: 8085d12c r9 : 80a8f73c r8 : 85739000 r7 : 00000017 r6 : 80a8f860 r5 : 80c8ab98 r4 : 80a8f858 r3 : 00000000 r2 : 00000000 r1 : 81406130 r0 : 00000017 Flags: nzCv IRQs on FIQs off Mode SVC_32 ISA ARM Segment none Control: 00c5387d Table: 85524008 DAC: 00000051 Process sh (pid: 116, stack limit = 0x1f1988d6) ... Backtrace: [<8073f738>] (genl_register_family) from [<80860ac0>] (ncsi_init_netlink+0x20/0x48) r10:8085d12c r9:80c8fb0c r8:85739000 r7:00000000 r6:81218000 r5:85739000 r4:8121c000 [<80860aa0>] (ncsi_init_netlink) from [<8085d740>] (ncsi_register_dev+0x1b0/0x210) r5:8121c400 r4:8121c000 [<8085d590>] (ncsi_register_dev) from [<805a8060>] (ftgmac100_probe+0x6e0/0x778) r10:00000004 r9:80950228 r8:8115bc10 r7:8115ab00 r6:9eae2c24 r5:813b6f88 r4:85739000 [<805a7980>] (ftgmac100_probe) from [<805355ec>] (platform_drv_probe+0x58/0xa8) r9:80c76bb0 r8:00000000 r7:80cd4974 r6:80c76bb0 r5:8115bc10 r4:00000000 [<80535594>] (platform_drv_probe) from [<80532d58>] (really_probe+0x204/0x514) r7:80cd4974 r6:00000000 r5:80cd4868 r4:8115bc10 Jakub pointed out that ncsi_register_dev is obviously broken, because there is only one family so it would never work if there was more than one ncsi netdev. Fix the crash by registering the netlink family once on boot, and drop the code to unregister it. Fixes: 955dc68cb9b2 ("net/ncsi: Add generic netlink family") Signed-off-by: Joel Stanley Reviewed-by: Samuel Mendoza-Jonas Link: https://lore.kernel.org/r/20201112061210.914621-1-joel@jms.id.au Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- net/ncsi/ncsi-manage.c | 5 ----- net/ncsi/ncsi-netlink.c | 22 +++------------------- net/ncsi/ncsi-netlink.h | 3 --- 3 files changed, 3 insertions(+), 27 deletions(-) --- a/net/ncsi/ncsi-manage.c +++ b/net/ncsi/ncsi-manage.c @@ -1667,9 +1667,6 @@ struct ncsi_dev *ncsi_register_dev(struc ndp->ptype.dev = dev; dev_add_pack(&ndp->ptype); - /* Set up generic netlink interface */ - ncsi_init_netlink(dev); - return nd; } EXPORT_SYMBOL_GPL(ncsi_register_dev); @@ -1826,8 +1823,6 @@ void ncsi_unregister_dev(struct ncsi_dev list_del_rcu(&ndp->node); spin_unlock_irqrestore(&ncsi_dev_lock, flags); - ncsi_unregister_netlink(nd->dev); - kfree(ndp); } EXPORT_SYMBOL_GPL(ncsi_unregister_dev); --- a/net/ncsi/ncsi-netlink.c +++ b/net/ncsi/ncsi-netlink.c @@ -766,24 +766,8 @@ static struct genl_family ncsi_genl_fami .n_ops = ARRAY_SIZE(ncsi_ops), }; -int ncsi_init_netlink(struct net_device *dev) +static int __init ncsi_init_netlink(void) { - int rc; - - rc = genl_register_family(&ncsi_genl_family); - if (rc) - netdev_err(dev, "ncsi: failed to register netlink family\n"); - - return rc; -} - -int ncsi_unregister_netlink(struct net_device *dev) -{ - int rc; - - rc = genl_unregister_family(&ncsi_genl_family); - if (rc) - netdev_err(dev, "ncsi: failed to unregister netlink family\n"); - - return rc; + return genl_register_family(&ncsi_genl_family); } +subsys_initcall(ncsi_init_netlink); --- a/net/ncsi/ncsi-netlink.h +++ b/net/ncsi/ncsi-netlink.h @@ -22,7 +22,4 @@ int ncsi_send_netlink_err(struct net_dev struct nlmsghdr *nlhdr, int err); -int ncsi_init_netlink(struct net_device *dev); -int ncsi_unregister_netlink(struct net_device *dev); - #endif /* __NCSI_NETLINK_H__ */