dirhash potential bug

Ian Dowse iedowse at maths.tcd.ie
Fri Mar 11 11:10:42 PST 2005


In message <4231D417.9060705 at errno.com>, Sam Leffler writes:
>Coverity's analysis tool claims there might be a null bp dereferenced in
>ufsdirhash_lookup.  Attached is a patch to add a KASSERT but it'd be
>good for someone more familiar with the code to check if a change is
>required.

Sam, maybe you missed my reply to your original message about this?
Here it is again anyway.

Ian

(Message freebsd-commit:11710)
 -- using template mhl.format --
Date:    Thu, 24 Feb 2005 01:32:24 GMT
To:      Sam Leffler <sam at errno.com>
cc:      dwmalone at freebsd.org, iedowse at freebsd.org

From:    Ian Dowse <iedowse at maths.tcd.ie>
Subject: Re: dirhash potential bug 

In message <421D0D59.1090001 at errno.com>, Sam Leffler writes:
>Coverity's analysis tool claims there might be a null bp dereferenced in 
>ufsdirhash_lookup.  Attached is a patch to add a KASSERT but it'd be 
>good for someone more familiar with the code to check if a change is 
>required (the analysis tool can be fooled by indirect logic).
>
>If you commit a change (even this assert) please make sure you mark the 
>commit with attribution.  If this cannot happen please let me know so I 
>can mark the analysis db I'm going through.  Thanks.

Hi Sam,

As far as I can tell the code is safe as is. Simplified it looks
like this:

	blkoff = -1;
	bp = NULL;
	for (...) {
		offset = non-negative value;
		if ((offset & ~bmask) != blkoff)
			bp = non-NULL;
		[dereference bp]
	}

So it is guaranteed that `((offset & ~bmask) != blkoff)' will be true
the first time around the loop and hence bp will be non-NULL.

Does that seem ok?

Ian



More information about the freebsd-fs mailing list