From: Theodore Ts'o Subject: Re: [PATCH] ext4: Fix crash when working on a fuzzed ext2 fs image Date: Mon, 11 Dec 2017 15:09:47 -0500 Message-ID: <20171211200947.upnb5gt3vhh6pm3f@thunk.org> References: <20171207053818.23799-1-chandan@linux.vnet.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: linux-ext4@vger.kernel.org, abdhalee@linux.vnet.ibm.com To: Chandan Rajendra Return-path: Received: from imap.thunk.org ([74.207.234.97]:59862 "EHLO imap.thunk.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751289AbdLKUJu (ORCPT ); Mon, 11 Dec 2017 15:09:50 -0500 Content-Disposition: inline In-Reply-To: <20171207053818.23799-1-chandan@linux.vnet.ibm.com> Sender: linux-ext4-owner@vger.kernel.org List-ID: On Thu, Dec 07, 2017 at 11:08:18AM +0530, Chandan Rajendra wrote: > On a ppc64 machine, when mounting a fuzzed ext2 image (generated by > fsfuzzer) the following call trace is seen, > ... > > This happens because the directory that ext4_find_entry() looks up has > inode->i_size that is less than the block size of the filesystem. This > causes 'nblocks' to have a value of zero. ext4_bread_batch() ends up not > reading any of the directory file's blocks. This renders the entries in > bh_use[] array to continue to have garbage data. buffer_uptodate() on > bh_use[0] can then return a zero value upon which brelse() function is > invoked. Thanks for reporting the problem. Your patch wasn't quite right since ret is not an int, but rather a struct buffer_head *, and the right thing to do in this instnace is to return NULL: > nblocks = dir->i_size >> EXT4_BLOCK_SIZE_BITS(sb); > + if (!nblocks) { > + ret = NULL; > + goto cleanup_and_exit; > + } I'll fix up your patch and include it in the ext4 tree, thanks. - Ted