Skip to contentSkip to conversation

fs: allow no_seek_end_llseek to actually seek

PATCH In review Wouter van Kesteren 2 participants 2 messages Feb 5, 2016 – Feb 16, 2016 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fs: allow no_seek_end_llseek to actually seek

'~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(-)
fs/read_write.c +2 -1
index 324ec27..0c8782a 100644
@@ -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;
 	}
Signature · 1 line
2.7.0
Reviewed-by on v1 1/1
#1 lore raw

Re: [PATCH] allow no_seek_end_llseek to actually seek

Quoted 4 lines · Wouter van Kesteren

'~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:

Cheers, Andreas

Quoted 32 lines

---
fs/read_write.c | 3 ++-

1 file changed, 2 insertions(+), 1 deletion(-)
fs/read_write.c +2 -1
index 324ec27..0c8782a 100644
@@ -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;
 	}
Signature · 6 lines
2.7.0

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

Cheers, Andreas