lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Wed, 23 Jun 2010 09:20:46 -0400
From:	Davidlohr Bueso <dave.bueso@...il.com>
To:	Andrew Morton <akpm@...ux-foundation.org>
Cc:	linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org
Subject: Re: [PATCH fs/ramfs] inode.c: Fix incorrect variable freeing.

On Tue, 2010-06-22 at 12:41 -0700, Andrew Morton wrote:
> On Sun, 20 Jun 2010 15:27:37 -0400
> Davidlohr Bueso <dave.bueso@...il.com> wrote:
> 
> > Hi,
> > 
> > In ramfs_fill_super(), if fsi's memory allocation fails, it will go to 'fail', 
> > which immediately tries to free the variable, potentially producing an Oops. 
> > This patch addresses this issue.
> > 
> > Thanks.
> > 
> > Signed-off-by: Davidlohr Bueso <dave@....org>
> > ---
> >  fs/ramfs/inode.c |    8 +++++---
> >  1 files changed, 5 insertions(+), 3 deletions(-)
> > 
> > diff --git a/fs/ramfs/inode.c b/fs/ramfs/inode.c
> > index a5ebae7..40af7a2 100644
> > --- a/fs/ramfs/inode.c
> > +++ b/fs/ramfs/inode.c
> > @@ -219,7 +219,7 @@ int ramfs_fill_super(struct super_block *sb, void *data, int silent)
> >  	sb->s_fs_info = fsi;
> >  	if (!fsi) {
> >  		err = -ENOMEM;
> > -		goto fail;
> > +		goto fail2;
> >  	}
> >  
> >  	err = ramfs_parse_options(data, &fsi->mount_opts);
> > @@ -247,11 +247,13 @@ int ramfs_fill_super(struct super_block *sb, void *data, int silent)
> >  	}
> >  
> >  	return 0;
> > -fail:
> > -	kfree(fsi);
> > +fail2:
> >  	sb->s_fs_info = NULL;
> >  	iput(inode);
> >  	return err;
> > +fail:
> > +	kfree(fsi);
> > +	goto fail2;
> >  }
> >  
> >  int ramfs_get_sb(struct file_system_type *fs_type,
> 
> notabug.  kfree(NULL) is an OK thing to do.  The kernel does this
> pretty regularly in recovery paths - it usually results in slightly
> simpler and slightly smaller code.

Yeah I kind of knew that but slipped my mind. Sorry for the noise.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ