Re: [PATCH] sysfs: check if one entry has been removed before freeing

2013-04-04 Thread Ming Lei
On Thu, Apr 4, 2013 at 12:08 AM, Greg Kroah-Hartman wrote: > > Then make it a WARN() call, like David said, to give us a chance to get > the report from a user so we can fix it. If the machine crashes after > that, fine, but hopefully we will get a oops report out of it. OK, got it, and console

Re: [PATCH] sysfs: check if one entry has been removed before freeing

2013-04-04 Thread Ming Lei
On Thu, Apr 4, 2013 at 12:08 AM, Greg Kroah-Hartman gre...@linuxfoundation.org wrote: Then make it a WARN() call, like David said, to give us a chance to get the report from a user so we can fix it. If the machine crashes after that, fine, but hopefully we will get a oops report out of it.

Re: [PATCH] sysfs: check if one entry has been removed before freeing

2013-04-03 Thread Greg Kroah-Hartman
On Wed, Apr 03, 2013 at 03:05:37PM +0800, Ming Lei wrote: > On Wed, Apr 3, 2013 at 1:35 PM, Greg Kroah-Hartman > wrote: > > On Wed, Apr 03, 2013 at 11:52:39AM +0800, Ming Lei wrote: > >> On Wed, Apr 3, 2013 at 11:04 AM, Dave Jones wrote: > >> > On Wed, Apr 03, 2013 at 10:58:23AM +0800, Ming Lei

Re: [PATCH] sysfs: check if one entry has been removed before freeing

2013-04-03 Thread Ming Lei
On Wed, Apr 3, 2013 at 1:35 PM, Greg Kroah-Hartman wrote: > On Wed, Apr 03, 2013 at 11:52:39AM +0800, Ming Lei wrote: >> On Wed, Apr 3, 2013 at 11:04 AM, Dave Jones wrote: >> > On Wed, Apr 03, 2013 at 10:58:23AM +0800, Ming Lei wrote: >> > >> > > diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c >>

Re: [PATCH] sysfs: check if one entry has been removed before freeing

2013-04-03 Thread Ming Lei
On Wed, Apr 3, 2013 at 1:35 PM, Greg Kroah-Hartman gre...@linuxfoundation.org wrote: On Wed, Apr 03, 2013 at 11:52:39AM +0800, Ming Lei wrote: On Wed, Apr 3, 2013 at 11:04 AM, Dave Jones da...@redhat.com wrote: On Wed, Apr 03, 2013 at 10:58:23AM +0800, Ming Lei wrote: diff --git

Re: [PATCH] sysfs: check if one entry has been removed before freeing

2013-04-03 Thread Greg Kroah-Hartman
On Wed, Apr 03, 2013 at 03:05:37PM +0800, Ming Lei wrote: On Wed, Apr 3, 2013 at 1:35 PM, Greg Kroah-Hartman gre...@linuxfoundation.org wrote: On Wed, Apr 03, 2013 at 11:52:39AM +0800, Ming Lei wrote: On Wed, Apr 3, 2013 at 11:04 AM, Dave Jones da...@redhat.com wrote: On Wed, Apr 03, 2013

Re: [PATCH] sysfs: check if one entry has been removed before freeing

2013-04-02 Thread Greg Kroah-Hartman
On Wed, Apr 03, 2013 at 11:52:39AM +0800, Ming Lei wrote: > On Wed, Apr 3, 2013 at 11:04 AM, Dave Jones wrote: > > On Wed, Apr 03, 2013 at 10:58:23AM +0800, Ming Lei wrote: > > > > > diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c > > > index 1bf016b..328ef9b 100644 > > > --- a/fs/sysfs/dir.c > >

Re: [PATCH] sysfs: check if one entry has been removed before freeing

2013-04-02 Thread Ming Lei
On Wed, Apr 3, 2013 at 11:04 AM, Dave Jones wrote: > On Wed, Apr 03, 2013 at 10:58:23AM +0800, Ming Lei wrote: > > > diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c > > index 1bf016b..328ef9b 100644 > > --- a/fs/sysfs/dir.c > > +++ b/fs/sysfs/dir.c > > @@ -268,6 +268,13 @@ void

Re: [PATCH] sysfs: check if one entry has been removed before freeing

2013-04-02 Thread Dave Jones
On Wed, Apr 03, 2013 at 10:58:23AM +0800, Ming Lei wrote: > diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c > index 1bf016b..328ef9b 100644 > --- a/fs/sysfs/dir.c > +++ b/fs/sysfs/dir.c > @@ -268,6 +268,13 @@ void release_sysfs_dirent(struct sysfs_dirent * sd) > */ > parent_sd =

[PATCH] sysfs: check if one entry has been removed before freeing

2013-04-02 Thread Ming Lei
It might be a kernel disaster if one sysfs entry is freed but still referenced by sysfs tree. Recently Dave and Sasha reported one use-after-free problem on sysfs entry, and the problem has been troubleshooted with help of debug message added in this patch. Given sysfs_get_dirent/sysfs_put are

[PATCH] sysfs: check if one entry has been removed before freeing

2013-04-02 Thread Ming Lei
It might be a kernel disaster if one sysfs entry is freed but still referenced by sysfs tree. Recently Dave and Sasha reported one use-after-free problem on sysfs entry, and the problem has been troubleshooted with help of debug message added in this patch. Given sysfs_get_dirent/sysfs_put are

Re: [PATCH] sysfs: check if one entry has been removed before freeing

2013-04-02 Thread Dave Jones
On Wed, Apr 03, 2013 at 10:58:23AM +0800, Ming Lei wrote: diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c index 1bf016b..328ef9b 100644 --- a/fs/sysfs/dir.c +++ b/fs/sysfs/dir.c @@ -268,6 +268,13 @@ void release_sysfs_dirent(struct sysfs_dirent * sd) */ parent_sd =

Re: [PATCH] sysfs: check if one entry has been removed before freeing

2013-04-02 Thread Ming Lei
On Wed, Apr 3, 2013 at 11:04 AM, Dave Jones da...@redhat.com wrote: On Wed, Apr 03, 2013 at 10:58:23AM +0800, Ming Lei wrote: diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c index 1bf016b..328ef9b 100644 --- a/fs/sysfs/dir.c +++ b/fs/sysfs/dir.c @@ -268,6 +268,13 @@ void

Re: [PATCH] sysfs: check if one entry has been removed before freeing

2013-04-02 Thread Greg Kroah-Hartman
On Wed, Apr 03, 2013 at 11:52:39AM +0800, Ming Lei wrote: On Wed, Apr 3, 2013 at 11:04 AM, Dave Jones da...@redhat.com wrote: On Wed, Apr 03, 2013 at 10:58:23AM +0800, Ming Lei wrote: diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c index 1bf016b..328ef9b 100644 --- a/fs/sysfs/dir.c