From nobody@FreeBSD.org  Wed Aug 21 07:50:54 2013
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
	(using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by hub.freebsd.org (Postfix) with ESMTP id 458299E7
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 21 Aug 2013 07:50:54 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from oldred.freebsd.org (oldred.freebsd.org [8.8.178.121])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.freebsd.org (Postfix) with ESMTPS id 33B522101
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 21 Aug 2013 07:50:54 +0000 (UTC)
Received: from oldred.freebsd.org ([127.0.1.6])
	by oldred.freebsd.org (8.14.5/8.14.7) with ESMTP id r7L7orcD043615
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 21 Aug 2013 07:50:53 GMT
	(envelope-from nobody@oldred.freebsd.org)
Received: (from nobody@localhost)
	by oldred.freebsd.org (8.14.5/8.14.5/Submit) id r7L7orbK043609;
	Wed, 21 Aug 2013 07:50:53 GMT
	(envelope-from nobody)
Message-Id: <201308210750.r7L7orbK043609@oldred.freebsd.org>
Date: Wed, 21 Aug 2013 07:50:53 GMT
From: Daria <dariaz@mellanox.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Using sysctl for mlxen stats might crash the kernel.
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         181448
>Category:       kern
>Synopsis:       [mlxen] [patch] Using sysctl for mlxen stats might crash the kernel.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Aug 21 08:00:02 UTC 2013
>Closed-Date:    
>Last-Modified:  Thu Aug 22 01:46:59 UTC 2013
>Originator:     Daria
>Release:        9.1
>Organization:
Mellanox
>Environment:
FreeBSD 9.1-RELEASE FreeBSD 9.1-RELEASE  root@farrell.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC amd64
>Description:
When reloading mlxen there are messages in the logs:

can't re-use a leaf (various leaf names)!

then, when trying to read these leafs - the kernel crashes.

>How-To-Repeat:
reload mlxen then try sysctl -a or a certain problematic leaf.
>Fix:
The order of releasing resources in mlxen needed to be corrected.

Index: sys/ofed/drivers/net/mlx4/en_netdev.c
===================================================================
--- sys/ofed/drivers/net/mlx4/en_netdev.c       (revision 254594)
+++ sys/ofed/drivers/net/mlx4/en_netdev.c       (working copy)
@@ -924,9 +924,6 @@ void mlx4_en_destroy_netdev(struct net_device *dev
        if (priv->allocated)
                mlx4_free_hwq_res(mdev->dev, &priv->res, MLX4_EN_PAGE_SIZE);

-       if (priv->sysctl)
-               sysctl_ctx_free(&priv->conf_ctx);
-
        cancel_delayed_work(&priv->stats_task);
        /* flush any pending task for this netdev */
        flush_workqueue(mdev->workqueue);
@@ -937,6 +934,10 @@ void mlx4_en_destroy_netdev(struct net_device *dev
        mutex_unlock(&mdev->state_lock);

        mlx4_en_free_resources(priv);
+
+       if (priv->sysctl)
+               sysctl_ctx_free(&priv->conf_ctx);
+
        mtx_destroy(&priv->stats_lock.m);
        mtx_destroy(&priv->vlan_lock.m);
        kfree(priv);


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-amd64->freebsd-bugs 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Thu Aug 22 01:45:52 UTC 2013 
Responsible-Changed-Why:  
not amd64-specific. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=181448 
>Unformatted:
