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]
Date:   Mon, 29 Jul 2019 15:25:04 +0800
From:   Jia-Ju Bai <baijiaju1990@...il.com>
To:     "Darrick J. Wong" <darrick.wong@...cle.com>
Cc:     bfoster@...hat.com, sandeen@...deen.net, linux-xfs@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] fs: xfs: Fix possible null-pointer dereferences in
 xchk_da_btree_block_check_sibling()



On 2019/7/29 12:20, Darrick J. Wong wrote:
> On Mon, Jul 29, 2019 at 11:24:01AM +0800, Jia-Ju Bai wrote:
>> In xchk_da_btree_block_check_sibling(), there is an if statement on
>> line 274 to check whether ds->state->altpath.blk[level].bp is NULL:
>>      if (ds->state->altpath.blk[level].bp)
>>
>> When ds->state->altpath.blk[level].bp is NULL, it is used on line 281:
>>      xfs_trans_brelse(..., ds->state->altpath.blk[level].bp);
>>          struct xfs_buf_log_item	*bip = bp->b_log_item;
>>          ASSERT(bp->b_transp == tp);
>>
>> Thus, possible null-pointer dereferences may occur.
>>
>> To fix these bugs, ds->state->altpath.blk[level].bp is checked before
>> being used.
>>
>> These bugs are found by a static analysis tool STCheck written by us.
>>
>> Signed-off-by: Jia-Ju Bai <baijiaju1990@...il.com>
>> ---
>>   fs/xfs/scrub/dabtree.c | 4 +++-
>>   1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/fs/xfs/scrub/dabtree.c b/fs/xfs/scrub/dabtree.c
>> index 94c4f1de1922..33ff90c0dd70 100644
>> --- a/fs/xfs/scrub/dabtree.c
>> +++ b/fs/xfs/scrub/dabtree.c
>> @@ -278,7 +278,9 @@ xchk_da_btree_block_check_sibling(
>>   	/* Compare upper level pointer to sibling pointer. */
>>   	if (ds->state->altpath.blk[level].blkno != sibling)
>>   		xchk_da_set_corrupt(ds, level);
>> -	xfs_trans_brelse(ds->dargs.trans, ds->state->altpath.blk[level].bp);
>> +	if (ds->state->altpath.blk[level].bp)
>> +		xfs_trans_brelse(ds->dargs.trans,
>> +						ds->state->altpath.blk[level].bp);
> Indentation here (in xfs we use two spaces)

Okay, I will fix this.

>
> Also, uh, shouldn't we set ds->state->altpath.blk[level].bp to NULL
> since we've released the buffer?

So I should set ds->state->altpath.blk[level].bp to NULL at the end of 
the function xchk_da_btree_block_check_sibling()?
Like:
     if (ds->state->altpath.blk[level].bp)
         xfs_trans_brelse(ds->dargs.trans,
                 ds->state->altpath.blk[level].bp);
     ds->state->altpath.blk[level].bp = NULL;


Best wishes,
Jia-Ju Bai

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ