Skip to contentSkip to conversation

virtiofsd: Error on bad socket group name

PATCH In review Dr. David Alan Gilbert (git) 2 participants 4 messages Oct 14, 2021 – Oct 25, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 virtiofsd: Error on bad socket group name

From: "Dr. David Alan Gilbert" <[email protected]>

Make the '--socket-group=' option fail if the group name is unknown:

./tools/virtiofsd/virtiofsd .... --socket-group=zaphod vhost socket: unable to find group 'zaphod'

---
 tools/virtiofsd/fuse_virtio.c | 7 +++++++
 1 file changed, 7 insertions(+)
tools/virtiofsd/fuse_virtio.c +7 -0
index 8f4fd165b9..39eebffb62 100644
@@ -999,6 +999,13 @@ static int fv_create_listen_socket(struct fuse_session *se)
                          "vhost socket failed to set group to %s (%d): %m\n",
                          se->vu_socket_group, g->gr_gid);
             }
+        } else {
+            fuse_log(FUSE_LOG_ERR,
+                     "vhost socket: unable to find group '%s'\n",
+                     se->vu_socket_group);
+            close(listen_sock);
+            umask(old_umask);
+            return -1;
         }
     }
     umask(old_umask);
Signature · 1 line
2.31.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

Make the '--socket-group=' option fail if the group name is unknown:

./tools/virtiofsd/virtiofsd .... --socket-group=zaphod vhost socket: unable to find group 'zaphod'

Hi Dave,

This looks good to me. Just a minor nit for code cleanup. It could be done in a separate patch or sometime later as well.

Quoted 9 lines
---
 tools/virtiofsd/fuse_virtio.c | 7 +++++++
 1 file changed, 7 insertions(+)
tools/virtiofsd/fuse_virtio.c +0 -0
index 8f4fd165b9..39eebffb62 100644

tools/virtiofsd/fuse_virtio.c static int fv_create_listen_socket(struct fuse_session *se) · line 1007

Quoted 9 lines
tools/virtiofsd/fuse_virtio.c +6 -0
@@ -999,6 +999,13 @@ static int fv_create_listen_socket(struct fuse_session *se)
                          "vhost socket failed to set group to %s (%d): %m\n",
                          se->vu_socket_group, g->gr_gid);
             }
+        } else {
+            fuse_log(FUSE_LOG_ERR,
+                     "vhost socket: unable to find group '%s'\n",
+                     se->vu_socket_group);
+            close(listen_sock);
+            umask(old_umask);
		^^^

tools/virtiofsd/fuse_virtio.c static int fv_create_listen_socket(struct fuse_session *se) · line 1011

Quoted 4 lines
tools/virtiofsd/fuse_virtio.c +1 -0
+            return -1;
         }
     }
     umask(old_umask);

This umask() call could be moved little early right after bind() call and that way we don't have to take care of calling umask(old_umask) in error path if group name could not be found.

Vivek

Quoted 8 lines
Signature · 6 lines
2.31.1

_______________________________________________
Virtio-fs mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/virtio-fs
#2 lore raw
Quoted 11 lines · * Vivek Goyal ([email protected]) wrote:
Quoted 9 lines · Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

Make the '--socket-group=' option fail if the group name is unknown:

./tools/virtiofsd/virtiofsd .... --socket-group=zaphod vhost socket: unable to find group 'zaphod'

Quoted 6 lines

Hi Dave,

This looks good to me. Just a minor nit for code cleanup. It could be done in a separate patch or sometime later as well.

Thanks

Quoted 19 lines
Quoted 9 lines
---
 tools/virtiofsd/fuse_virtio.c | 7 +++++++
 1 file changed, 7 insertions(+)
tools/virtiofsd/fuse_virtio.c +0 -0
index 8f4fd165b9..39eebffb62 100644

tools/virtiofsd/fuse_virtio.c static int fv_create_listen_socket(struct fuse_session *se) · line 1007

Quoted 9 lines
tools/virtiofsd/fuse_virtio.c +6 -0
@@ -999,6 +999,13 @@ static int fv_create_listen_socket(struct fuse_session *se)
                          "vhost socket failed to set group to %s (%d): %m\n",
                          se->vu_socket_group, g->gr_gid);
             }
+        } else {
+            fuse_log(FUSE_LOG_ERR,
+                     "vhost socket: unable to find group '%s'\n",
+                     se->vu_socket_group);
+            close(listen_sock);
+            umask(old_umask);
		^^^
Quoted 8 lines

tools/virtiofsd/fuse_virtio.c static int fv_create_listen_socket(struct fuse_session *se) · line 1011

Quoted 4 lines
tools/virtiofsd/fuse_virtio.c +1 -0
+            return -1;
         }
     }
     umask(old_umask);

This umask() call could be moved little early right after bind() call and that way we don't have to take care of calling umask(old_umask) in error path if group name could not be found.

One to fight another day.

Quoted 11 lines

Vivek

Quoted 8 lines
Signature · 6 lines
2.31.1

_______________________________________________
Virtio-fs mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/virtio-fs
Signature · 1 line
Dr. David Alan Gilbert / [email protected] / Manchester, UK
#3 lore raw
In reply to Dr. David Alan Gilbert (git)
Quoted 9 lines · * Dr. David Alan Gilbert (git) ([email protected]) wrote:

From: "Dr. David Alan Gilbert" <[email protected]>

Make the '--socket-group=' option fail if the group name is unknown:

./tools/virtiofsd/virtiofsd .... --socket-group=zaphod vhost socket: unable to find group 'zaphod'

Queued

Quoted 26 lines
---
 tools/virtiofsd/fuse_virtio.c | 7 +++++++
 1 file changed, 7 insertions(+)
tools/virtiofsd/fuse_virtio.c +7 -0
index 8f4fd165b9..39eebffb62 100644
@@ -999,6 +999,13 @@ static int fv_create_listen_socket(struct fuse_session *se)
                          "vhost socket failed to set group to %s (%d): %m\n",
                          se->vu_socket_group, g->gr_gid);
             }
+        } else {
+            fuse_log(FUSE_LOG_ERR,
+                     "vhost socket: unable to find group '%s'\n",
+                     se->vu_socket_group);
+            close(listen_sock);
+            umask(old_umask);
+            return -1;
         }
     }
     umask(old_umask);
Signature · 1 line
2.31.1
Signature · 1 line
Dr. David Alan Gilbert / [email protected] / Manchester, UK