All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zhang Zhen <zhenzhang.zhang@huawei.com>
To: <tytso@mit.edu>, Christoph Hellwig <hch@infradead.org>
Cc: <linux-ext4@vger.kernel.org>
Subject: [PATCH] ext4: avoid unneeded lookup when xattr name is invalid
Date: Fri, 11 Apr 2014 15:15:07 +0800	[thread overview]
Message-ID: <5347967B.5090401@huawei.com> (raw)
In-Reply-To: <1397199813-71623-1-git-send-email-zhenzhang.zhang@huawei.com>

In ext4_xattr_set_handle() we have checked the xattr name's length. So we should
also check it in ext4_xattr_get() to avoid unneeded lookup caused by invalid name.

In addition, we deleted the check of NULL in ext4_xattr_set_handle(), because in all
the callers of the ext4_xattr_set_handle(), the name can't be NULL.

Signed-off-by: Zhang Zhen <zhenzhang.zhang@huawei.com>
---
 fs/ext4/xattr.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
index 1f5cf58..340bdfa 100644
--- a/fs/ext4/xattr.c
+++ b/fs/ext4/xattr.c
@@ -369,6 +369,9 @@ ext4_xattr_get(struct inode *inode, int name_index, const char *name,
 {
 	int error;

+	if (strlen(name) > 255)
+		return -ERANGE;
+
 	down_read(&EXT4_I(inode)->xattr_sem);
 	error = ext4_xattr_ibody_get(inode, name_index, name, buffer,
 				     buffer_size);
@@ -1073,8 +1076,6 @@ ext4_xattr_set_handle(handle_t *handle, struct inode *inode, int name_index,
 	unsigned long no_expand;
 	int error;

-	if (!name)
-		return -EINVAL;
 	if (strlen(name) > 255)
 		return -ERANGE;
 	down_write(&EXT4_I(inode)->xattr_sem);
-- 
1.8.5.5


.





       reply	other threads:[~2014-04-11  7:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1397199813-71623-1-git-send-email-zhenzhang.zhang@huawei.com>
2014-04-11  7:15 ` Zhang Zhen [this message]
2014-05-12 14:00   ` [PATCH] ext4: avoid unneeded lookup when xattr name is invalid Theodore Ts'o

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5347967B.5090401@huawei.com \
    --to=zhenzhang.zhang@huawei.com \
    --cc=hch@infradead.org \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.