All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sven Eckelmann <sven.eckelmann@gmx.de>
To: b.a.t.m.a.n@lists.open-mesh.org
Cc: devel <devel@driverdev.osuosl.org>,
	b.a.t.m.a.n@lists.open-mesh.net,
	Greg Kroah-Hartman <gregkh@suse.de>,
	linux-kernel@vger.kernel.org,
	Simon Wunderlich <siwu@hrz.tu-chemnitz.de>,
	Joe Perches <joe@perches.com>,
	Marek Lindner <lindner_marek@yahoo.de>
Subject: Re: [B.A.T.M.A.N.] [PATCH] drivers/staging/batman-adv: Use (pr|netdev)_<level> macro helpers
Date: Wed, 16 Jun 2010 00:23:02 +0200	[thread overview]
Message-ID: <201006160023.04296.sven.eckelmann@gmx.de> (raw)
In-Reply-To: <1275509466.23599.43.camel@Joe-Laptop.home>

[-- Attachment #1: Type: Text/Plain, Size: 2261 bytes --]

Joe Perches wrote:
> Compile tested only
> 
> Add #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> Remove "batman-adv:" from format strings
> Use pr_<level>
> Use netdev_<level>
> 
> Signed-off-by: Joe Perches <joe@perches.com>
> ---

Found some time to play a little bit around with your patch and noticed that
it crashes the kernel. I did my tests using following "interesting" part:

[....]
> @@ -152,18 +155,18 @@ static ssize_t store_vis_mode(struct kobject *kobj,
> struct attribute *attr, if (buff[count - 1] == '\n')
>  			buff[count - 1] = '\0';
> 
> -		printk(KERN_INFO "batman-adv:Invalid parameter for 'vis mode' setting on mesh %s received: %s\n",
> -		       net_dev->name, buff);
> +		netdev_info(net_dev, "Invalid parameter for 'vis mode' setting on mesh received: %s\n",
> +			    buff);
>  		return -EINVAL;
>  	}
> 
>  	if (atomic_read(&bat_priv->vis_mode) == vis_mode_tmp)
>  		return count;
> 
> -	printk(KERN_INFO "batman-adv:Changing vis mode from: %s to: %s on mesh: %s\n",
> -	       atomic_read(&bat_priv->vis_mode) == VIS_TYPE_CLIENT_UPDATE ?
> -	       "client" : "server", vis_mode_tmp == VIS_TYPE_CLIENT_UPDATE ?
> -	       "client" : "server", net_dev->name);
> +	netdev_info(net_dev, "Changing vis mode from: %s to: %s on mesh\n",
> +		    atomic_read(&bat_priv->vis_mode) == VIS_TYPE_CLIENT_UPDATE ?
> +		    "client" : "server",
> +		    vis_mode_tmp == VIS_TYPE_CLIENT_UPDATE ? "client" : "server");
> 
>  	atomic_set(&bat_priv->vis_mode, (unsigned)vis_mode_tmp);
>  	return count;
[...]

I compiled the module and loaded it using `insmod batman-adv.ko`. This will
create some files in /sys. Just changed the vis mode to server using:

echo 0 > /sys/class/net/bat0/mesh/vis_mode

And then it will crash at that netdev_info call.

The problem seems to be that dev_printk is used by netdev_printk (which is
used by netdev_info). netdev_printk will add (netdev)->dev.parent as second
parameter of dev_printk (and parent is NULL in our case). This macro will now
call dev_driver_string with NULL as parameter and just dereference this null pointer.

Maybe it is related to something else, but at least I think that this could be
the cause of the crash.

Best regards,
	Sven

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: Sven Eckelmann <sven.eckelmann@gmx.de>
To: b.a.t.m.a.n@lists.open-mesh.org
Cc: Joe Perches <joe@perches.com>,
	Marek Lindner <lindner_marek@yahoo.de>,
	Simon Wunderlich <siwu@hrz.tu-chemnitz.de>,
	Andrew Lunn <andrew@lunn.ch>,
	"Greg Kroah-Hartman" <gregkh@suse.de>,
	devel <devel@driverdev.osuosl.org>,
	b.a.t.m.a.n@lists.open-mesh.net, linux-kernel@vger.kernel.org
Subject: Re: [B.A.T.M.A.N.] [PATCH] drivers/staging/batman-adv: Use (pr|netdev)_<level> macro helpers
Date: Wed, 16 Jun 2010 00:23:02 +0200	[thread overview]
Message-ID: <201006160023.04296.sven.eckelmann@gmx.de> (raw)
In-Reply-To: <1275509466.23599.43.camel@Joe-Laptop.home>

[-- Attachment #1: Type: Text/Plain, Size: 2261 bytes --]

Joe Perches wrote:
> Compile tested only
> 
> Add #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> Remove "batman-adv:" from format strings
> Use pr_<level>
> Use netdev_<level>
> 
> Signed-off-by: Joe Perches <joe@perches.com>
> ---

Found some time to play a little bit around with your patch and noticed that
it crashes the kernel. I did my tests using following "interesting" part:

[....]
> @@ -152,18 +155,18 @@ static ssize_t store_vis_mode(struct kobject *kobj,
> struct attribute *attr, if (buff[count - 1] == '\n')
>  			buff[count - 1] = '\0';
> 
> -		printk(KERN_INFO "batman-adv:Invalid parameter for 'vis mode' setting on mesh %s received: %s\n",
> -		       net_dev->name, buff);
> +		netdev_info(net_dev, "Invalid parameter for 'vis mode' setting on mesh received: %s\n",
> +			    buff);
>  		return -EINVAL;
>  	}
> 
>  	if (atomic_read(&bat_priv->vis_mode) == vis_mode_tmp)
>  		return count;
> 
> -	printk(KERN_INFO "batman-adv:Changing vis mode from: %s to: %s on mesh: %s\n",
> -	       atomic_read(&bat_priv->vis_mode) == VIS_TYPE_CLIENT_UPDATE ?
> -	       "client" : "server", vis_mode_tmp == VIS_TYPE_CLIENT_UPDATE ?
> -	       "client" : "server", net_dev->name);
> +	netdev_info(net_dev, "Changing vis mode from: %s to: %s on mesh\n",
> +		    atomic_read(&bat_priv->vis_mode) == VIS_TYPE_CLIENT_UPDATE ?
> +		    "client" : "server",
> +		    vis_mode_tmp == VIS_TYPE_CLIENT_UPDATE ? "client" : "server");
> 
>  	atomic_set(&bat_priv->vis_mode, (unsigned)vis_mode_tmp);
>  	return count;
[...]

I compiled the module and loaded it using `insmod batman-adv.ko`. This will
create some files in /sys. Just changed the vis mode to server using:

echo 0 > /sys/class/net/bat0/mesh/vis_mode

And then it will crash at that netdev_info call.

The problem seems to be that dev_printk is used by netdev_printk (which is
used by netdev_info). netdev_printk will add (netdev)->dev.parent as second
parameter of dev_printk (and parent is NULL in our case). This macro will now
call dev_driver_string with NULL as parameter and just dereference this null pointer.

Maybe it is related to something else, but at least I think that this could be
the cause of the crash.

Best regards,
	Sven

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

  parent reply	other threads:[~2010-06-15 22:23 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-02 17:10 [PATCH] drivers/staging/batman-adv: Convert MAC_FMT to %pM Joe Perches
2010-06-02 18:12 ` [PATCH] drivers/staging/batman-adv: Use (pr|netdev)_<level> macro helpers Joe Perches
2010-06-02 18:53 ` [PATCH] drivers/staging/batman-adv: Convert MAC_FMT to %pM Greg KH
2010-06-02 20:08   ` [PATCH] MAINTAINERS: Add staging/b.a.t.m.a.n Joe Perches
2010-06-02 20:17     ` Greg KH
2010-06-02 20:19       ` Randy Dunlap
2010-06-02 20:27         ` Joe Perches
2010-06-02 20:11 ` [B.A.T.M.A.N.] [PATCH] drivers/staging/batman-adv: Use (pr|netdev)_<level> macro helpers Joe Perches
2010-06-02 20:11   ` Joe Perches
2010-06-03 15:53   ` [B.A.T.M.A.N.] [PATCH-trunk] batman-adv: " Sven Eckelmann
2010-06-03 17:27     ` Sven Eckelmann
2010-06-04 14:20   ` [B.A.T.M.A.N.] [PATCHv2-trunk] " Sven Eckelmann
2010-06-04 14:21     ` Sven Eckelmann
2010-06-04 14:25       ` [B.A.T.M.A.N.] [PATCHv2-maint] " Sven Eckelmann
2010-06-15 22:23   ` Sven Eckelmann [this message]
2010-06-15 22:23     ` [B.A.T.M.A.N.] [PATCH] drivers/staging/batman-adv: " Sven Eckelmann
2010-06-15 22:37     ` Sven Eckelmann
2010-06-15 22:58       ` Joe Perches
2010-06-15 22:58         ` Joe Perches
2010-06-15 22:58         ` [B.A.T.M.A.N.] " Joe Perches

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201006160023.04296.sven.eckelmann@gmx.de \
    --to=sven.eckelmann@gmx.de \
    --cc=b.a.t.m.a.n@lists.open-mesh.net \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@suse.de \
    --cc=joe@perches.com \
    --cc=lindner_marek@yahoo.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=siwu@hrz.tu-chemnitz.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.