Re: [PATCH 3/3] compat: copy missing fields in compat_statfs64 to user

Previous thread: Return value of generic xattr operations by Marco Stornelli on Sunday, December 26, 2010 - 6:53 am. (3 messages)

Next thread: Re: [PATCH 1/1] mct_u232: IOCTL implementation by Tsozik on Sunday, December 26, 2010 - 12:41 pm. (1 message)
From: Namhyung Kim
Date: Sunday, December 26, 2010 - 9:41 am

*@ret_pointer is initialized to @fast_pointer thus the assignment is
redundant.

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Cc: Jeff Moyer <jmoyer@redhat.com>
---
 fs/compat.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/fs/compat.c b/fs/compat.c
index b074e9f79148..0a22f973f4b5 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -597,10 +597,8 @@ ssize_t compat_rw_copy_check_uvector(int type,
 	if (nr_segs > fast_segs) {
 		ret = -ENOMEM;
 		iov = kmalloc(nr_segs*sizeof(struct iovec), GFP_KERNEL);
-		if (iov == NULL) {
-			*ret_pointer = fast_pointer;
+		if (iov == NULL)
 			goto out;
-		}
 	}
 	*ret_pointer = iov;
 
-- 
1.7.3.4.600.g982838b0

--

From: Namhyung Kim
Date: Sunday, December 26, 2010 - 9:41 am

The commit 7ed1ee6118ae ("Take statfs variants to fs/statfs.c")
separates out statfs syscalls from fs/open.c. Thus the comment
should be changed also.

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Cc: Jiri Kosina <trivial@kernel.org>
---
 fs/compat.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/compat.c b/fs/compat.c
index 0a22f973f4b5..037df434b038 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -257,7 +257,7 @@ static int put_compat_statfs(struct compat_statfs __user *ubuf, struct kstatfs *
 }
 
 /*
- * The following statfs calls are copies of code from fs/open.c and
+ * The following statfs calls are copies of code from fs/statfs.c and
  * should be checked against those from time to time
  */
 asmlinkage long compat_sys_statfs(const char __user *pathname, struct compat_statfs __user *buf)
-- 
1.7.3.4.600.g982838b0

--

From: Namhyung Kim
Date: Sunday, December 26, 2010 - 9:41 am

f_flags and f_spare fields were not copied to userspace when
compat_sys_[f]statfs64 called.

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Cc: Christoph Hellwig <hch@lst.de>
---
It seems struct compat_statfs lacks the f_flags field in it but I'm not
sure whether it is intended or not. Is it useful if I make a patch for
it too?

 fs/compat.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/fs/compat.c b/fs/compat.c
index 037df434b038..2524511518e7 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -320,7 +320,9 @@ static int put_compat_statfs64(struct compat_statfs64 __user *ubuf, struct kstat
 	    __put_user(kbuf->f_namelen, &ubuf->f_namelen) ||
 	    __put_user(kbuf->f_fsid.val[0], &ubuf->f_fsid.val[0]) ||
 	    __put_user(kbuf->f_fsid.val[1], &ubuf->f_fsid.val[1]) ||
-	    __put_user(kbuf->f_frsize, &ubuf->f_frsize))
+	    __put_user(kbuf->f_frsize, &ubuf->f_frsize) ||
+	    __put_user(kbuf->f_flags, &ubuf->f_flags) ||
+	    __clear_user(ubuf->f_spare, sizeof(ubuf->f_spare)))
 		return -EFAULT;
 	return 0;
 }
-- 
1.7.3.4.600.g982838b0

--

From: Christoph Hellwig
Date: Monday, December 27, 2010 - 8:36 am

Looks good.  We discussed this a while back before it fell under the
table again.

Reviewed-by: Christoph Hellwig <hch@lst.de>
--

Previous thread: Return value of generic xattr operations by Marco Stornelli on Sunday, December 26, 2010 - 6:53 am. (3 messages)

Next thread: Re: [PATCH 1/1] mct_u232: IOCTL implementation by Tsozik on Sunday, December 26, 2010 - 12:41 pm. (1 message)