Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit db52d09e authored by Eric Sandeen's avatar Eric Sandeen Committed by Dave Chinner
Browse files

xfs: catch invalid negative blknos in _xfs_buf_find()



Here blkno is a daddr_t, which is a __s64; it's possible to hold
a value which is negative, and thus pass the (blkno >= eofs)
test.  Then we try to do a xfs_perag_get() for a ridiculous
agno via xfs_daddr_to_agno(), and bad things happen when that
fails, and returns a null pag which is dereferenced shortly
thereafter.

Found via a user-supplied fuzzed image...

Signed-off-by: default avatarEric Sandeen <sandeen@redhat.com>
Reviewed-by: default avatarMark Tinguely <tinguely@sgi.com>
Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
parent 91ee575f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -461,7 +461,7 @@ _xfs_buf_find(
	 * have to check that the buffer falls within the filesystem bounds.
	 */
	eofs = XFS_FSB_TO_BB(btp->bt_mount, btp->bt_mount->m_sb.sb_dblocks);
	if (blkno >= eofs) {
	if (blkno < 0 || blkno >= eofs) {
		/*
		 * XXX (dgc): we should really be returning -EFSCORRUPTED here,
		 * but none of the higher level infrastructure supports