* [PATCH v2] vhost-user-scsi: avoid unlink(NULL) with fd passing
@ 2022-05-16 15:57 Stefan Hajnoczi
2022-05-16 16:34 ` Peter Maydell
2022-05-16 17:31 ` Raphael Norwitz
0 siblings, 2 replies; 3+ messages in thread
From: Stefan Hajnoczi @ 2022-05-16 15:57 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Raphael Norwitz, Michael S. Tsirkin,
Stefan Hajnoczi
Commit 747421e949fc1eb3ba66b5fcccdb7ba051918241 ("Implements Backend
Program conventions for vhost-user-scsi") introduced fd-passing support
as part of implementing the vhost-user backend program conventions.
When fd passing is used the UNIX domain socket path is NULL and we must
not call unlink(2).
The unlink(2) call is necessary when the listen socket, lsock, was
created successfully since that means the UNIX domain socket is visible
in the file system.
Fixes: Coverity CID 1488353
Fixes: 747421e949fc1eb3ba66b5fcccdb7ba051918241 ("Implements Backend Program conventions for vhost-user-scsi")
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
contrib/vhost-user-scsi/vhost-user-scsi.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/contrib/vhost-user-scsi/vhost-user-scsi.c b/contrib/vhost-user-scsi/vhost-user-scsi.c
index b2c0f98253..9ef61cf5a7 100644
--- a/contrib/vhost-user-scsi/vhost-user-scsi.c
+++ b/contrib/vhost-user-scsi/vhost-user-scsi.c
@@ -433,13 +433,16 @@ out:
if (vdev_scsi) {
g_main_loop_unref(vdev_scsi->loop);
g_free(vdev_scsi);
- unlink(opt_socket_path);
}
if (csock >= 0) {
close(csock);
}
if (lsock >= 0) {
close(lsock);
+
+ if (opt_socket_path) {
+ unlink(opt_socket_path);
+ }
}
g_free(opt_socket_path);
g_free(iscsi_uri);
--
2.36.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] vhost-user-scsi: avoid unlink(NULL) with fd passing
2022-05-16 15:57 [PATCH v2] vhost-user-scsi: avoid unlink(NULL) with fd passing Stefan Hajnoczi
@ 2022-05-16 16:34 ` Peter Maydell
2022-05-16 17:31 ` Raphael Norwitz
1 sibling, 0 replies; 3+ messages in thread
From: Peter Maydell @ 2022-05-16 16:34 UTC (permalink / raw)
To: Stefan Hajnoczi; +Cc: qemu-devel, Raphael Norwitz, Michael S. Tsirkin
On Mon, 16 May 2022 at 16:57, Stefan Hajnoczi <stefanha@redhat.com> wrote:
>
> Commit 747421e949fc1eb3ba66b5fcccdb7ba051918241 ("Implements Backend
> Program conventions for vhost-user-scsi") introduced fd-passing support
> as part of implementing the vhost-user backend program conventions.
>
> When fd passing is used the UNIX domain socket path is NULL and we must
> not call unlink(2).
>
> The unlink(2) call is necessary when the listen socket, lsock, was
> created successfully since that means the UNIX domain socket is visible
> in the file system.
>
> Fixes: Coverity CID 1488353
> Fixes: 747421e949fc1eb3ba66b5fcccdb7ba051918241 ("Implements Backend Program conventions for vhost-user-scsi")
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
> contrib/vhost-user-scsi/vhost-user-scsi.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
thanks
-- PMM
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] vhost-user-scsi: avoid unlink(NULL) with fd passing
2022-05-16 15:57 [PATCH v2] vhost-user-scsi: avoid unlink(NULL) with fd passing Stefan Hajnoczi
2022-05-16 16:34 ` Peter Maydell
@ 2022-05-16 17:31 ` Raphael Norwitz
1 sibling, 0 replies; 3+ messages in thread
From: Raphael Norwitz @ 2022-05-16 17:31 UTC (permalink / raw)
To: Stefan Hajnoczi
Cc: qemu-devel@nongnu.org, Peter Maydell, Raphael Norwitz,
Michael S. Tsirkin
On Mon, May 16, 2022 at 04:57:01PM +0100, Stefan Hajnoczi wrote:
> Commit 747421e949fc1eb3ba66b5fcccdb7ba051918241 ("Implements Backend
> Program conventions for vhost-user-scsi") introduced fd-passing support
> as part of implementing the vhost-user backend program conventions.
>
> When fd passing is used the UNIX domain socket path is NULL and we must
> not call unlink(2).
>
> The unlink(2) call is necessary when the listen socket, lsock, was
> created successfully since that means the UNIX domain socket is visible
> in the file system.
>
> Fixes: Coverity CID 1488353
> Fixes: 747421e949fc1eb3ba66b5fcccdb7ba051918241 ("Implements Backend Program conventions for vhost-user-scsi")
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
Reviewed-by: Raphael Norwitz <raphael.norwitz@nutanix.com>
> contrib/vhost-user-scsi/vhost-user-scsi.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/contrib/vhost-user-scsi/vhost-user-scsi.c b/contrib/vhost-user-scsi/vhost-user-scsi.c
> index b2c0f98253..9ef61cf5a7 100644
> --- a/contrib/vhost-user-scsi/vhost-user-scsi.c
> +++ b/contrib/vhost-user-scsi/vhost-user-scsi.c
> @@ -433,13 +433,16 @@ out:
> if (vdev_scsi) {
> g_main_loop_unref(vdev_scsi->loop);
> g_free(vdev_scsi);
> - unlink(opt_socket_path);
> }
> if (csock >= 0) {
> close(csock);
> }
> if (lsock >= 0) {
> close(lsock);
> +
> + if (opt_socket_path) {
> + unlink(opt_socket_path);
> + }
> }
> g_free(opt_socket_path);
> g_free(iscsi_uri);
> --
> 2.36.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-05-16 17:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-16 15:57 [PATCH v2] vhost-user-scsi: avoid unlink(NULL) with fd passing Stefan Hajnoczi
2022-05-16 16:34 ` Peter Maydell
2022-05-16 17:31 ` Raphael Norwitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).