ceph: check negative offsets in ceph_llseek()
authorLuis Henriques <lhenriques@suse.com>
Fri, 28 Jul 2017 10:56:40 +0000 (11:56 +0100)
committerIlya Dryomov <idryomov@gmail.com>
Wed, 6 Sep 2017 17:56:50 +0000 (19:56 +0200)
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.

Signed-off-by: Luis Henriques <lhenriques@suse.com>
Reviewed-by: Ilya Dryomov <idryomov@gmail.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
fs/ceph/file.c

index 2eb43a54e2d659b84c632c02376b2251be420a46..9634eb79b04148d04427067b7863b5b087ddbdbd 100644 (file)
@@ -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;
                }