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-next>] [day] [month] [year] [list]
Date:	Mon, 12 Jul 2010 23:09:09 +0800
From:	"crosslonelyover" <crosslonelyover@...il.com>
To:	"linux-ext4" <linux-ext4@...r.kernel.org>,
	"linux-kernel" <linux-kernel@...r.kernel.org>,
	"kernel-janitors" <kernel-janitors@...r.kernel.org>
Subject: [PATCH] remove unnecesary while loop in ext2_xattr_get

Hi,
     In ext2_xattr_get, we'll check the xattr entry one 
by one in the following loop:
         entry = FIRST_ENTRY(bh);
         while (!IS_LAST_ENTRY(entry)) {
                 struct ext2_xattr_entry *next =
                         EXT2_XATTR_NEXT(entry);
                 if ((char *)next >= end)
                         goto bad_block;
                 if (name_index == entry->e_name_index &&
                     name_len == entry->e_name_len &&
                     memcmp(name, entry->e_name, name_len) == 0)
                         goto found;
                 entry = next;
         }
We can only execute the code immediately following 
the loop when !IS_LAST_ENTRY(entry) is true. So the
followed while loop seems unnecessary. I think we can
remove it.
      Following is my patch. It's against 2.6.35-rc4.
Please check it.


Signed-off-by: Wang Sheng-Hui <crosslonelyover@...il.com>
---
 fs/ext2/xattr.c |    9 +--------
 1 files changed, 1 insertions(+), 8 deletions(-)

diff --git a/fs/ext2/xattr.c b/fs/ext2/xattr.c
index 0b94d61..a6bccdb 100644
--- a/fs/ext2/xattr.c
+++ b/fs/ext2/xattr.c
@@ -201,14 +201,7 @@ bad_block:	ext2_error(inode->i_sb, "ext2_xattr_get",
 			goto found;
 		entry = next;
 	}
-	/* Check the remaining name entries */
-	while (!IS_LAST_ENTRY(entry)) {
-		struct ext2_xattr_entry *next =
-			EXT2_XATTR_NEXT(entry);
-		if ((char *)next >= end)
-			goto bad_block;
-		entry = next;
-	}
+
 	if (ext2_xattr_cache_insert(bh))
 		ea_idebug(inode, "cache insert failed");
 	error = -ENODATA;
-- 
1.7.1.1


--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ