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] [thread-next>] [day] [month] [year] [list]
Message-ID: <20070511072939.GA25727@infradead.org>
Date:	Fri, 11 May 2007 08:29:39 +0100
From:	Christoph Hellwig <hch@...radead.org>
To:	Andrew Morton <akpm@...ux-foundation.org>
Cc:	Cyrill Gorcunov <gorcunov@...il.com>,
	LKML <linux-kernel@...r.kernel.org>,
	Ben Fennema <bfennema@...con.csc.calpoly.edu>,
	Jan Kara <jack@....cz>
Subject: Re: [PATCH] UDF: check for allocated memory for inode data

On Thu, May 10, 2007 at 03:46:40PM -0700, Andrew Morton wrote:
> On Thu, 10 May 2007 18:00:00 +0400
> Cyrill Gorcunov <gorcunov@...il.com> wrote:
> 
> > This patch adds cheking for granted memory while
> > filling up inode data to prevent possible NULL
> > pointer usage. If there is not enough memory to
> > fill inode data we just mark it as "bad".
> > 
> > Signed-off-by: Cyrill Gorcunov <gorcunov@...il.com>
> > 
> > Please check the patch, maybe just marking inode as
> > "bad" is not a good solution.
> > 
> 
> yes, make_bad_inode() is appropriate here.
> 
> > 
> > diff --git a/fs/udf/inode.c b/fs/udf/inode.c
> > index c846155..91cddae 100644
> > --- a/fs/udf/inode.c
> > +++ b/fs/udf/inode.c
> > @@ -1144,6 +1144,13 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh)
> >  		UDF_I_EFE(inode) = 1;
> >  		UDF_I_USE(inode) = 0;
> >  		UDF_I_DATA(inode) = kmalloc(inode->i_sb->s_blocksize - sizeof(struct extendedFileEntry), GFP_KERNEL);
> > +		if (!UDF_I_DATA(inode))
> > +		{
> > +			printk(KERN_ERR "udf: udf_fill_inode(ino %ld) no free memory\n",
> > +			       inode->i_ino);
> > +			make_bad_inode(inode);
> > +			return;
> > +		}
> 
> But please let's not add three copies of identical code.  Do something like:
> 
> static int udf_check_inode(struct inode *inode)
> {
> 	if (!UDF_I_DATA(inode)) {
> 		printk(KERN_ERR "udf: udf_fill_inode(ino %ld) no free memory\n",
> 			inode->i_ino);
> 		make_bad_inode(inode);
> 		return -1;
> 	}
> 	return 0;
> }
> 
> 
> 	if (udf_check_inode(inode))
> 		return;
> 
> In fact you can also do the kmalloc in that helper function too:
> 
> static int udf_alloc_i_data(struct inode *inode, size_t size)
> {
> 	UDF_I_DATA(inode) = kmalloc(...);
> 	...
> }

And please get rid of the UDF_I_* macro for everything you touch, just
put a

	struct udf_inode_info *uip = UDF_I(inode);

at the beginning of the function and use the fields directly.
-
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