xfs-masters
[Top] [All Lists]

[PATCH 6/8] xfs: fix unsigned underflow

To: kernel-janitors@xxxxxxxxxxxxxxx
Subject: [PATCH 6/8] xfs: fix unsigned underflow
From: Kulikov Vasiliy <segooon@xxxxxxxxx>
Date: Thu, 15 Jul 2010 22:46:45 +0400
Cc: Alex Elder <aelder@xxxxxxx>, xfs-masters@xxxxxxxxxxx, Christoph Hellwig <hch@xxxxxx>, Dave Chinner <dchinner@xxxxxxxxxx>, Felix Blyakher <felixb@xxxxxxx>, xfs@xxxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer; bh=tQrJqAficn8DtyKkePgGsBLoXkM/j/Awix1DTS5xl64=; b=EdJsJbfDpZ5QoIZsrP8nJ29Pr9DjEpo2qGEPRn8ALmMGtPnspUu6NKa1Utbo3rEDNv kcXNM4qpvS7HS1JvYXAYFe89JMoMuTEQ2ija8rUXJ4LRk88YA6gCOeoyJFgYQASipMla 7+wWYvAMgIqncIyG3BokHbhoMFLPcLYZ7WfTs=
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=XcGeEhY5fWpvPtsynpL08r/Q1nF15TIbRkCntUVqNFiZHlDc8k/ElLqS25WxiNuLzR +mJESkyRpkabTwRWjBWFVoAeB51/GF0p++w27YpiHbLMsX8h6ZP+KlpwSnFrmXDC0zd2 0LBny8oEZvS9DRHuAEyo7AwbJqgWKjVThT3SA=
map_len is unsigned. Checking map_len <= 0 is buggy when it should be
below zero. So, check exact expression instead of map_len.

Signed-off-by: Kulikov Vasiliy <segooon@xxxxxxxxx>
---
 fs/xfs/xfs_vnodeops.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c
index 65e0879..66d585c 100644
--- a/fs/xfs/xfs_vnodeops.c
+++ b/fs/xfs/xfs_vnodeops.c
@@ -591,9 +591,9 @@ xfs_free_eofblocks(
         */
        end_fsb = XFS_B_TO_FSB(mp, ((xfs_ufsize_t)ip->i_size));
        last_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)XFS_MAXIOFFSET(mp));
-       map_len = last_fsb - end_fsb;
-       if (map_len <= 0)
+       if (last_fsb <= end_fsb)
                return 0;
+       map_len = last_fsb - end_fsb;
 
        nimaps = 1;
        xfs_ilock(ip, XFS_ILOCK_SHARED);
-- 
1.7.0.4

<Prev in Thread] Current Thread [Next in Thread>