public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [patch] xfs: check for underflow in xfs_iformat_fork()
@ 2013-08-15  5:53 Dan Carpenter
  2013-08-15 10:10 ` Jeff Liu
  0 siblings, 1 reply; 8+ messages in thread
From: Dan Carpenter @ 2013-08-15  5:53 UTC (permalink / raw)
  To: Ben Myers; +Cc: Alex Elder, xfs, linux-kernel, kernel-janitors

The "di_size" variable comes from the disk and it's a signed 64 bit.
We check the upper limit but we should check for negative numbers as
well.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/fs/xfs/xfs_inode_fork.c b/fs/xfs/xfs_inode_fork.c
index 123971b..849fc70 100644
--- a/fs/xfs/xfs_inode_fork.c
+++ b/fs/xfs/xfs_inode_fork.c
@@ -167,7 +167,8 @@ xfs_iformat_fork(
 			}
 
 			di_size = be64_to_cpu(dip->di_size);
-			if (unlikely(di_size > XFS_DFORK_DSIZE(dip, ip->i_mount))) {
+			if (unlikely(di_size < 0 ||
+				     di_size > XFS_DFORK_DSIZE(dip, ip->i_mount))) {
 				xfs_warn(ip->i_mount,
 			"corrupt inode %Lu (bad size %Ld for local inode).",
 					(unsigned long long) ip->i_ino,

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2013-08-26 16:12 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-15  5:53 [patch] xfs: check for underflow in xfs_iformat_fork() Dan Carpenter
2013-08-15 10:10 ` Jeff Liu
2013-08-15 14:37   ` Ben Myers
2013-08-15 15:47     ` Dan Carpenter
2013-08-15 22:26     ` Dave Chinner
2013-08-23 17:36       ` Ben Myers
2013-08-26 14:37         ` Dan Carpenter
2013-08-26 16:12           ` Ben Myers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox