diff mbox

fs: allow no_seek_end_llseek to actually seek

Message ID 1454688514-230665-1-git-send-email-woutershep@gmail.com
State New
Headers show

Commit Message

Wouter van Kesteren Feb. 5, 2016, 4:08 p.m. UTC
'~0ULL' is a 'unsigned long long' that when converted to a loff_t,
which is signed, gets turned into -1. later in vfs_setpos we have
'if (offset > maxsize)', which makes it always return EINVAL.
---
 fs/read_write.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Andreas Dilger Feb. 16, 2016, 8:35 p.m. UTC | #1
On Feb 5, 2016, at 9:08 AM, Wouter van Kesteren <woutershep@gmail.com> wrote:
> 
> '~0ULL' is a 'unsigned long long' that when converted to a loff_t,
> which is signed, gets turned into -1. later in vfs_setpos we have
> 'if (offset > maxsize)', which makes it always return EINVAL.

Patch itself looks reasonable, and the bug was introduced in commit
b25472f9b "new helpers: no_seek_end_llseek{,_size}()".

Wouter, you need to resubmit this with your "Signed-off-by:" line,
see linux/Documentation/SubmittingPatches for details, and the patch
should be sent "To: Al Viro" and "CC: linux-fsdevel" so it isn't lost.

When you resubmit you can add my:

Reviewed-by: Andreas Dilger <adilger@dilger.ca>

Cheers, Andreas

> ---
> fs/read_write.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/read_write.c b/fs/read_write.c
> index 324ec27..0c8782a 100644
> --- a/fs/read_write.c
> +++ b/fs/read_write.c
> @@ -17,6 +17,7 @@
> #include <linux/splice.h>
> #include <linux/compat.h>
> #include <linux/mount.h>
> +#include <linux/fs.h>
> #include "internal.h"
> 
> #include <asm/uaccess.h>
> @@ -183,7 +184,7 @@ loff_t no_seek_end_llseek(struct file *file, loff_t offset, int whence)
> 	switch (whence) {
> 	case SEEK_SET: case SEEK_CUR:
> 		return generic_file_llseek_size(file, offset, whence,
> -						~0ULL, 0);
> +						OFFSET_MAX, 0);
> 	default:
> 		return -EINVAL;
> 	}
> -- 
> 2.7.0
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


Cheers, Andreas





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

Patch

diff --git a/fs/read_write.c b/fs/read_write.c
index 324ec27..0c8782a 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -17,6 +17,7 @@ 
 #include <linux/splice.h>
 #include <linux/compat.h>
 #include <linux/mount.h>
+#include <linux/fs.h>
 #include "internal.h"
 
 #include <asm/uaccess.h>
@@ -183,7 +184,7 @@  loff_t no_seek_end_llseek(struct file *file, loff_t offset, int whence)
 	switch (whence) {
 	case SEEK_SET: case SEEK_CUR:
 		return generic_file_llseek_size(file, offset, whence,
-						~0ULL, 0);
+						OFFSET_MAX, 0);
 	default:
 		return -EINVAL;
 	}