Received: by 10.223.176.5 with SMTP id f5csp702655wra; Fri, 9 Feb 2018 05:58:12 -0800 (PST) X-Google-Smtp-Source: AH8x224YJ93C6dgxUKPbehiqY44g1KBnD+bVmeKUXnN3Iw1tH9eLBKnSK8jHW8rIZSUAagLD91Jj X-Received: by 2002:a17:902:1a4:: with SMTP id b33-v6mr2682864plb.58.1518184692348; Fri, 09 Feb 2018 05:58:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518184692; cv=none; d=google.com; s=arc-20160816; b=LnpfIFp18zii4I45av/ha3x7TWFXECFSn/ubz+PSL2nF3ks82ASHCTaMpYO1BgyqyY dtxWh5wbTAOul85Hw8XNpkLsMq554kpZ9KKA9LUjoybBWQbGODeirgMVsKvPNoqRmJ79 V3utMeRmqLSLznXzUOpPTTw8WIkzA7puOhHJqB0TwoiFDwCEWr8gxDCgRCrp56ECtH4b wh1w5t61vNLk1R1w2X/H9nFhzpNgXsDUNY8VMiSDv+tSVeQDQ3xg9H9CVK1FGscGd0Lq VMHTb3tv2lBE/HGv5QbW5I0kpghPDOVgT9oz4gWdS35jTPvUc6Ymn17yxesFzHZWUzBV G2fQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=xoUKUGve1Le95uOxASYIxFLjUE5gxZVbTfigc7IfD0s=; b=AI5Dr6QGF46tCxPCpc3sH+mkcewaqpSq7ewoCE8AFWCDmaRCEOGfBePdeDVrEtxHfh a37Sc7hfFeTpLsSNGbyCcsoVFSyI1A4UWGxkzcRJXhw7zneiVHGMYQ9csd1YzmI9EMJF DofkZYcOJalIFRomI6Ichp5da93LiFI+lPZjSBEG9AigvlPXoLuNo1bpzC6Q5NZ7cBix 1fNtqbF1lU8z+df1fIgps/Ak5Y1jSWslxhh0F8UqGb1zxX9ZNuFMkypFlgw12kK005TE jJLWhp89eITb+uRcG/BJNgNC4VbITyqR3Mlgvy90nHCaxOGONnugr4afPAqxWid4e4lp jk8A== ARC-Authentication-Results: i=1; mx.google.com; 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 l11si1416372pgc.502.2018.02.09.05.57.58; Fri, 09 Feb 2018 05:58:12 -0800 (PST) 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; 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 S1753801AbeBIN4G (ORCPT + 99 others); Fri, 9 Feb 2018 08:56:06 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:51738 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753567AbeBINpK (ORCPT ); Fri, 9 Feb 2018 08:45:10 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 89FB810D4; Fri, 9 Feb 2018 13:45:09 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jiri Pirko , "David S. Miller" Subject: [PATCH 4.14 13/22] rocker: fix possible null pointer dereference in rocker_router_fib_event_work Date: Fri, 9 Feb 2018 14:40:02 +0100 Message-Id: <20180209133935.020219288@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180209133934.024795822@linuxfoundation.org> References: <20180209133934.024795822@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jiri Pirko [ Upstream commit a83165f00f16c0e0ef5b7cec3cbd0d4788699265 ] Currently, rocker user may experience following null pointer derefence bug: [ 3.062141] BUG: unable to handle kernel NULL pointer dereference at 00000000000000d0 [ 3.065163] IP: rocker_router_fib_event_work+0x36/0x110 [rocker] The problem is uninitialized rocker->wops pointer that is initialized only with the first initialized port. So move the port initialization before registering the fib events. Fixes: 936bd486564a ("rocker: use FIB notifications instead of switchdev calls") Signed-off-by: Jiri Pirko Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/rocker/rocker_main.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) --- a/drivers/net/ethernet/rocker/rocker_main.c +++ b/drivers/net/ethernet/rocker/rocker_main.c @@ -2902,6 +2902,12 @@ static int rocker_probe(struct pci_dev * goto err_alloc_ordered_workqueue; } + err = rocker_probe_ports(rocker); + if (err) { + dev_err(&pdev->dev, "failed to probe ports\n"); + goto err_probe_ports; + } + /* Only FIBs pointing to our own netdevs are programmed into * the device, so no need to pass a callback. */ @@ -2918,22 +2924,16 @@ static int rocker_probe(struct pci_dev * rocker->hw.id = rocker_read64(rocker, SWITCH_ID); - err = rocker_probe_ports(rocker); - if (err) { - dev_err(&pdev->dev, "failed to probe ports\n"); - goto err_probe_ports; - } - dev_info(&pdev->dev, "Rocker switch with id %*phN\n", (int)sizeof(rocker->hw.id), &rocker->hw.id); return 0; -err_probe_ports: - unregister_switchdev_notifier(&rocker_switchdev_notifier); err_register_switchdev_notifier: unregister_fib_notifier(&rocker->fib_nb); err_register_fib_notifier: + rocker_remove_ports(rocker); +err_probe_ports: destroy_workqueue(rocker->rocker_owq); err_alloc_ordered_workqueue: free_irq(rocker_msix_vector(rocker, ROCKER_MSIX_VEC_EVENT), rocker); @@ -2961,9 +2961,9 @@ static void rocker_remove(struct pci_dev { struct rocker *rocker = pci_get_drvdata(pdev); - rocker_remove_ports(rocker); unregister_switchdev_notifier(&rocker_switchdev_notifier); unregister_fib_notifier(&rocker->fib_nb); + rocker_remove_ports(rocker); rocker_write32(rocker, CONTROL, ROCKER_CONTROL_RESET); destroy_workqueue(rocker->rocker_owq); free_irq(rocker_msix_vector(rocker, ROCKER_MSIX_VEC_EVENT), rocker);