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]
Message-ID: <20101019204127.GB3487@quack.suse.cz>
Date:	Tue, 19 Oct 2010 22:41:28 +0200
From:	Jan Kara <jack@...e.cz>
To:	Namhyung Kim <namhyung@...il.com>
Cc:	Jan Kara <jack@...e.cz>, Andrew Morton <akpm@...ux-foundation.org>,
	Andreas Dilger <adilger.kernel@...ger.ca>,
	linux-ext4@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] ext3: Check return value of sb_getblk()

On Tue 19-10-10 16:57:29, Namhyung Kim wrote:
> 2010-10-19 (화), 15:34 +0900, Namhyung Kim:
> > Check return value of sb_getblk() is NULL. unlikely is addded here
> > since it is called from a loop and we've been OK without the check
> > until now.
> > 
> > Signed-off-by: Namhyung Kim <namhyung@...il.com>
> > ---
> >  fs/ext3/inode.c |    6 ++++++
> >  1 files changed, 6 insertions(+), 0 deletions(-)
> > 
> > diff --git a/fs/ext3/inode.c b/fs/ext3/inode.c
> > index ef1c23a..a7ac778 100644
> > --- a/fs/ext3/inode.c
> > +++ b/fs/ext3/inode.c
> > @@ -655,6 +655,12 @@ static int ext3_alloc_branch(handle_t *handle, struct inode *inode,
> >  		 * parent to disk.
> >  		 */
> >  		bh = sb_getblk(inode->i_sb, new_blocks[n-1]);
> > +		if (unlikely(!bh)) {
> > +			n--;
> > +			err = -ENOMEM;
> > +			goto failed;
> > +		}
> > +
> >  		branch[n].bh = bh;
> >  		lock_buffer(bh);
> >  		BUFFER_TRACE(bh, "call get_create_access");
> 
> Maybe EIO would be more proper error code, I guess.
  Hmm, for ext3, sb_getblk() cannot really realistically fail. Block
numbers are 32-bit so they can never be big enough to overflow pagecache
index and grow_buffers() loops indefinitely if it cannot allocate buffers.
But OK, EIO might be a reasonable return value and we can have the check
there just in case sb_getblk() grows some other possiblility to fail.

								Honza

-- 
Jan Kara <jack@...e.cz>
SUSE Labs, CR
--
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