Skip to contentSkip to conversation

9p: Be robust against paths without FS_IOC_GETVERSION

PATCH In review Gabriel de Perthuis 2 participants 4 messages May 8, 2013 – May 10, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 9p: Be robust against paths without FS_IOC_GETVERSION

The current implementation checked for supported filesystems at mount time, but actual support depends on the path. Don't error out when finding unversioned paths.

This fix allows booting a linux kernel with the same / filesystem as the host; otherwise the boot fails when mounting devtmpfs.

---
 hw/9pfs/cofile.c | 4 ++++
 1 file changed, 4 insertions(+)
hw/9pfs/cofile.c +4 -0
index 2efebf3..194c130 100644
@@ -36,10 +36,14 @@ int v9fs_co_st_gen(V9fsPDU *pdu, V9fsPath *path, mode_t st_mode,
                     err = -errno;
                 }
             });
         v9fs_path_unlock(s);
     }
+    /* The ioctl may not be supported depending on the path */
+    if (err == -ENOTTY) {
+        err = 0;
+    }
     return err;
 }
 
 int v9fs_co_lstat(V9fsPDU *pdu, V9fsPath *path, struct stat *stbuf)
 {
Signature · 1 line
1.8.2.1.419.ga0b97c6
#1 lore raw
Quoted 3 lines · Gabriel de Perthuis

The current implementation checked for supported filesystems at mount time, but actual support depends on the path. Don't error out when finding unversioned paths.

Can you elaborate this a bit ?

Quoted 14 lines

This fix allows booting a linux kernel with the same / filesystem as the host; otherwise the boot fails when mounting devtmpfs.

---
 hw/9pfs/cofile.c | 4 ++++
 1 file changed, 4 insertions(+)
hw/9pfs/cofile.c +0 -0
index 2efebf3..194c130 100644

hw/9pfs/cofile.c int v9fs_co_st_gen(V9fsPDU *pdu, V9fsPath *path, mode_t st_mode, · line 44

Quoted 9 lines
hw/9pfs/cofile.c +4 -0
@@ -36,10 +36,14 @@ int v9fs_co_st_gen(V9fsPDU *pdu, V9fsPath *path, mode_t st_mode,
                     err = -errno;
                 }
             });
         v9fs_path_unlock(s);
     }
+    /* The ioctl may not be supported depending on the path */
+    if (err == -ENOTTY) {
+        err = 0;
+    }

So you don't want to consider -ENOTTY as an error ? why ?

hw/9pfs/cofile.c int v9fs_co_st_gen(V9fsPDU *pdu, V9fsPath *path, mode_t st_mode, · line 49

Quoted 6 lines
hw/9pfs/cofile.c +0 -0
     return err;
 }
 
 int v9fs_co_lstat(V9fsPDU *pdu, V9fsPath *path, struct stat *stbuf)
 {

-aneesh

#2 lore raw
Quoted 7 lines · Aneesh Kumar K.V
Quoted 3 lines · Gabriel de Perthuis

The current implementation checked for supported filesystems at mount time, but actual support depends on the path. Don't error out when finding unversioned paths.

Can you elaborate this a bit ?

ioctl support generally depends on the mount point.

You have a check that verifies the filesystem at the root of the source side is ext4 or something else whitelisted to have generation support, but that's not sufficient, the source may contain other mountpoints that don't support the getversion ioctl. When a path gives you ENOTTY, that means the ioctl is not supported.

Quoted 8 lines
Quoted 8 lines

This fix allows booting a linux kernel with the same / filesystem as the host; otherwise the boot fails when mounting devtmpfs.

---
 hw/9pfs/cofile.c | 4 ++++
 1 file changed, 4 insertions(+)
Quoted 16 lines
Quoted 5 lines
hw/9pfs/cofile.c +0 -0
index 2efebf3..194c130 100644

hw/9pfs/cofile.c int v9fs_co_st_gen(V9fsPDU *pdu, V9fsPath *path, mode_t st_mode, · line 44

Quoted 9 lines
hw/9pfs/cofile.c +4 -0
@@ -36,10 +36,14 @@ int v9fs_co_st_gen(V9fsPDU *pdu, V9fsPath *path, mode_t st_mode,
                     err = -errno;
                 }
             });
         v9fs_path_unlock(s);
     }
+    /* The ioctl may not be supported depending on the path */
+    if (err == -ENOTTY) {
+        err = 0;
+    }

So you don't want to consider -ENOTTY as an error ? why ?

ENOTTY means the ioctl is not supported.
That should be handled the same as if the source-side root didn't have a whitelisted filesystem. That means we need to return 0 in both cases.

Quoted 8 lines

hw/9pfs/cofile.c int v9fs_co_st_gen(V9fsPDU *pdu, V9fsPath *path, mode_t st_mode, · line 49

Quoted 6 lines
hw/9pfs/cofile.c +0 -0
     return err;
 }
 
 int v9fs_co_lstat(V9fsPDU *pdu, V9fsPath *path, struct stat *stbuf)
 {

-aneesh

Reviewed-by
#3 lore raw
Quoted 9 lines · Gabriel de Perthuis
Quoted 7 lines · Aneesh Kumar K.V
Quoted 3 lines · Gabriel de Perthuis

The current implementation checked for supported filesystems at mount time, but actual support depends on the path. Don't error out when finding unversioned paths.

Can you elaborate this a bit ?

Quoted 7 lines

ioctl support generally depends on the mount point.

You have a check that verifies the filesystem at the root of the source side is ext4 or something else whitelisted to have generation support, but that's not sufficient, the source may contain other mountpoints that don't support the getversion ioctl. When a path gives you ENOTTY, that means the ioctl is not supported.

May be we can update the commit message to be more clear. ie, currently the st_gen support is decided based on whether export file system support ioc_getversion ioctl. But we could have other file system mounted further down in the exported path that doesn't support ioc_getversion. So instead of failing stat request, we do the same we did for the export path. If we find the ioctl not supported we silently ignore the error. This results in us returning st_gen value 0 which should be ok

Quoted 38 lines
Quoted 9 lines
Quoted 9 lines

This fix allows booting a linux kernel with the same / filesystem as the host; otherwise the boot fails when mounting devtmpfs.

---
 hw/9pfs/cofile.c | 4 ++++
 1 file changed, 4 insertions(+)
Quoted 16 lines
Quoted 5 lines
hw/9pfs/cofile.c +0 -0
index 2efebf3..194c130 100644

hw/9pfs/cofile.c int v9fs_co_st_gen(V9fsPDU *pdu, V9fsPath *path, mode_t st_mode, · line 44

Quoted 9 lines
hw/9pfs/cofile.c +4 -0
@@ -36,10 +36,14 @@ int v9fs_co_st_gen(V9fsPDU *pdu, V9fsPath *path, mode_t st_mode,
                     err = -errno;
                 }
             });
         v9fs_path_unlock(s);
     }
+    /* The ioctl may not be supported depending on the path */
+    if (err == -ENOTTY) {
+        err = 0;
+    }

So you don't want to consider -ENOTTY as an error ? why ?

ENOTTY means the ioctl is not supported.
That should be handled the same as if the source-side root didn't have a whitelisted filesystem. That means we need to return 0 in both cases.

Quoted 8 lines

hw/9pfs/cofile.c int v9fs_co_st_gen(V9fsPDU *pdu, V9fsPath *path, mode_t st_mode, · line 49

Quoted 6 lines
hw/9pfs/cofile.c +0 -0
     return err;
 }
 
 int v9fs_co_lstat(V9fsPDU *pdu, V9fsPath *path, struct stat *stbuf)
 {

-aneesh