Skip to contentSkip to conversation

ceph: check negative offsets on ceph_llseek()

PATCH Applied Luis Henriques 2 participants 5 messages Jul 28, 2017 – Aug 18, 2017 Ceph client

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ceph: check negative offsets on ceph_llseek()

When a user requests SEEK_HOLE or SEEK_DATA with a negative offset ceph_llseek should return -ENXIO. Currently -EINVAL is being returned for SEEK_DATA and 0 for SEEK_HOLE.

---
 fs/ceph/file.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/ceph/file.c +2 -2
index 3d48c415f3cb..e1912e67843f 100644
@@ -1481,13 +1481,13 @@ static loff_t ceph_llseek(struct file *file, loff_t offset, int whence)
 		offset += file->f_pos;
 		break;
 	case SEEK_DATA:
-		if (offset >= i_size) {
+		if (offset < 0 || offset >= i_size) {
 			ret = -ENXIO;
 			goto out;
 		}
 		break;
 	case SEEK_HOLE:
-		if (offset >= i_size) {
+		if (offset < 0 || offset >= i_size) {
 			ret = -ENXIO;
 			goto out;
 		}
#1 lore raw
Quoted 3 lines · Luis Henriques

When a user requests SEEK_HOLE or SEEK_DATA with a negative offset ceph_llseek should return -ENXIO. Currently -EINVAL is being returned for SEEK_DATA and 0 for SEEK_HOLE.

Ping

This patch should make xfstest generic/448 happy.

Cheers,

Signature · 1 line
Luís
Quoted 27 lines
---
 fs/ceph/file.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/ceph/file.c +2 -2
index 3d48c415f3cb..e1912e67843f 100644
@@ -1481,13 +1481,13 @@ static loff_t ceph_llseek(struct file *file, loff_t offset, int whence)
 		offset += file->f_pos;
 		break;
 	case SEEK_DATA:
-		if (offset >= i_size) {
+		if (offset < 0 || offset >= i_size) {
 			ret = -ENXIO;
 			goto out;
 		}
 		break;
 	case SEEK_HOLE:
-		if (offset >= i_size) {
+		if (offset < 0 || offset >= i_size) {
 			ret = -ENXIO;
 			goto out;
 		}
maintainer
#2 lore raw
Quoted 9 lines · Luis Henriques
Quoted 3 lines · Luis Henriques

When a user requests SEEK_HOLE or SEEK_DATA with a negative offset ceph_llseek should return -ENXIO. Currently -EINVAL is being returned for SEEK_DATA and 0 for SEEK_HOLE.

Ping

This patch should make xfstest generic/448 happy.

It should or it does? ;)

I saw generic/448 failures on ext4 with Darrick's recent test change, haven't tried ceph yet.

Thanks,

Ilya

#3 lore raw
Quoted 7 lines · Ilya Dryomov
Quoted 6 lines · Luis Henriques
Quoted 3 lines · Luis Henriques

When a user requests SEEK_HOLE or SEEK_DATA with a negative offset ceph_llseek should return -ENXIO. Currently -EINVAL is being returned for SEEK_DATA and 0 for SEEK_HOLE.

Quoted 6 lines
Quoted 3 lines

Ping

This patch should make xfstest generic/448 happy.

It should or it does? ;)

Heh, it *does* make generic/448 happy.

Quoted 4 lines

I saw generic/448 failures on ext4 with Darrick's recent test change,
haven't tried ceph yet.

The generic/448 test currently fails with the error codes described in the commit log. I didn't found it useful to include in the commit log, but here's the full test output:

File system supports the default behavior. File system does not support unwritten extents. File system magic#: 0xc36400
Allocation size: 4194304
18. Test file with negative SEEK_{HOLE,DATA} offsets
18.01 SEEK_HOLE expected -1 or -1, got 0. FAIL
18.02 SEEK_DATA expected -1 with errno -6, got -22. FAIL

seek sanity check failed!

Cheers,

Signature · 1 line
Luís
maintainer Applied
#4 lore raw
Quoted 35 lines · Luis Henriques
Quoted 7 lines · Ilya Dryomov
Quoted 6 lines · Luis Henriques
Quoted 3 lines · Luis Henriques

When a user requests SEEK_HOLE or SEEK_DATA with a negative offset ceph_llseek should return -ENXIO. Currently -EINVAL is being returned for SEEK_DATA and 0 for SEEK_HOLE.

Quoted 6 lines
Quoted 3 lines

Ping

This patch should make xfstest generic/448 happy.

It should or it does? ;)

Heh, it *does* make generic/448 happy.

Quoted 4 lines

I saw generic/448 failures on ext4 with Darrick's recent test change,
haven't tried ceph yet.

The generic/448 test currently fails with the error codes described in the commit log. I didn't found it useful to include in the commit log, but here's the full test output:

File system supports the default behavior. File system does not support unwritten extents. File system magic#: 0xc36400
Allocation size: 4194304
18. Test file with negative SEEK_{HOLE,DATA} offsets
18.01 SEEK_HOLE expected -1 or -1, got 0. FAIL
18.02 SEEK_DATA expected -1 with errno -6, got -22. FAIL

Quoted 1 line

seek sanity check failed!

Applied.

Thanks,

Ilya