lkml.org 
[lkml]   [2013]   [Jul]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 41/48] staging/lustre/llite: error of listxattr when buffer is small
Date
From: Keith Mannthey <keith.mannthey@intel.com>

According to the standard, listxattr(2) should return -1
and errno should be set to ERANGE if the size of the list
buffer is too small to hold the result. However ll_listxattr()
will return a value bigger than the size of buffer in some cases.

Let's assume listxattr(2) returns SIZE when it is called with a
large enough list buffer. If it's called again with a list buffer
whose size is smaller than SIZE but bigger than (SIZE - 12), then
listxattr(2) will return SIZE too. This patch fixes the problem.
Original patch by Li Xi <pkuelelixi@gmail.com>

Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3403
Lustre-change: http://review.whamcloud.com/6463
Signed-off-by: Keith Mannthey <keith.mannthey@intel.com>
Reviewed-by: Li Xi <pkuelelixi@gmail.com>
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
Signed-off-by: Peng Tao <tao.peng@emc.com>
Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
---
drivers/staging/lustre/lustre/llite/xattr.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/lustre/lustre/llite/xattr.c b/drivers/staging/lustre/lustre/llite/xattr.c
index 0a11902..2e3ff6d 100644
--- a/drivers/staging/lustre/lustre/llite/xattr.c
+++ b/drivers/staging/lustre/lustre/llite/xattr.c
@@ -564,7 +564,12 @@ ssize_t ll_listxattr(struct dentry *dentry, char *buffer, size_t size)
const size_t name_len = sizeof("lov") - 1;
const size_t total_len = prefix_len + name_len + 1;

- if (buffer && (rc + total_len) <= size) {
+ if (((rc + total_len) > size) && (buffer != NULL)) {
+ ptlrpc_req_finished(request);
+ return -ERANGE;
+ }
+
+ if (buffer != NULL) {
buffer += rc;
memcpy(buffer, XATTR_LUSTRE_PREFIX, prefix_len);
memcpy(buffer + prefix_len, "lov", name_len);
--
1.7.9.5


\
 
 \ /
  Last update: 2013-07-22 20:41    [W:0.614 / U:0.316 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site