lkml.org 
[lkml]   [2013]   [Apr]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH] sysfs: check if one entry has been removed before freeing
From
On Wed, Apr 3, 2013 at 1:35 PM, Greg Kroah-Hartman
<gregkh@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 <davej@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 release_sysfs_dirent(struct sysfs_dirent * sd)
>> > > */
>> > > parent_sd = sd->s_parent;
>> > >
>> > > + if (unlikely(!(sd->s_flags & SYSFS_FLAG_REMOVED))) {
>> > > + printk(KERN_ERR "sysfs: free using entry: %s/%s\n",
>> > > + parent_sd ? parent_sd->s_name : "",
>> > > + sd->s_name);
>> > > + BUG();
>> > > + }
>> >
>> > Please use WARN instead of BUG. For an in-ram filesystem like
>> > sysfs, there's no real reason to lock-up the machine in this way
>> > making it harder to debug.
>>
>> If WARN is used, the freed memory will be allocated to other
>> kernel components, then sysfs may change the memory and cause
>> destruction, so maybe it is better to use BUG to stop kernel.
>
> No, it's never ok to call BUG(), sorry, please fix this.

Sorry, could you explain it in a bit detail? IMO, it is really a bug
when code runs here, and there are much similar BUG_ON()
uses in current sysfs code too.

Thanks,
--
Ming Lei


\
 
 \ /
  Last update: 2013-04-03 09:41    [W:0.185 / U:0.024 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site