tools/libxs: Open /dev/xen/xenbus fds as O_CLOEXEC
PATCH 1/1 tools/libxs: Open /dev/xen/xenbus fds as O_CLOEXEC
The header description for xs_open() goes as far as to suggest that the fd is O_CLOEXEC, but it isn't actually.
xl devd has been observed leaking /dev/xen/xenbus into children.
---
CC: Anthony PERARD <[email protected]>
CC: Juergen Gross <[email protected]>
CC: Demi Marie Obenour <[email protected]>
CC: Marek Marczykowski-Górecki <[email protected]>
Entirely speculative patch based on a Matrix report
--- tools/libs/store/xs.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
tools/libs/store/xs.c +5 -1
@@ -54,6 +54,10 @@ struct xs_stored_msg {#include <dlfcn.h> #endif +#ifndef O_CLOEXEC +#define O_CLOEXEC 0 +#endif +struct xs_handle {/* Communications channel to xenstore daemon. */ int fd;
@@ -227,7 +231,7 @@ static int get_socket(const char *connect_to)static int get_dev (const char *connect_to) {/* We cannot open read-only because requests are writes */ -return open (connect_to,O_RDWR ); +return open (connect_to,O_RDWR |O_CLOEXEC ); }static int all_restrict_cb (Xentoolcore__Active_Handle *ah,domid_t domid) {
base-commit: feb9158a620040846d76981acbe8ea9e2255a07b
Signature · 1 line
2.30.2
Quoted 8 lines · Andrew Cooper
The header description for
xs_open()goes as far as to suggest that the fd isO_CLOEXEC, but it isn't actually.
xl devdhas been observed leaking/dev/xen/xenbusinto children.Reported-by Demi Marie Obenour <[email protected]>Signed-off-by Andrew Cooper <[email protected]>
With the style breakage below fixed:
Quoted 27 lines
---
CC: Anthony PERARD <[email protected]>
CC: Juergen Gross <[email protected]>
CC: Demi Marie Obenour <[email protected]>
CC: Marek Marczykowski-Górecki <[email protected]>Entirely speculative patch based on a Matrix report
--- tools/libs/store/xs.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)tools/libs/store/xs.c +4
-0@@ -54,6 +54,10 @@ struct xs_stored_msg {#include <dlfcn.h> #endif +#ifndef O_CLOEXEC +#define O_CLOEXEC 0 +#endif +struct xs_handle {/* Communications channel to xenstore daemon. */ int fd;
tools/libs/store/xs.c static int get_socket(const char *connect_to) · line 234
Quoted 5 lines
tools/libs/store/xs.c +1
-1@@ -227,7 +231,7 @@ static int get_socket(const char *connect_to)static int get_dev (const char *connect_to) {/* We cannot open read-only because requests are writes */ -return open (connect_to,O_RDWR ); +return open (connect_to,O_RDWR |O_CLOEXEC );
Nit: spaces around the "|", please.
Juergen
Quoted 5 lines
tools/libs/store/xs.c +0
-0}static int all_restrict_cb (Xentoolcore__Active_Handle *ah,domid_t domid) {base-commit:
feb9158a620040846d76981acbe8ea9e2255a07b