Xen-Devel Archive mirror
 help / color / mirror / Atom feed
From: "Jürgen Groß" <jgross@suse.com>
To: Andrew Cooper <andrew.cooper3@citrix.com>,
	Xen-devel <xen-devel@lists.xenproject.org>
Cc: "Demi Marie Obenour" <demi@invisiblethingslab.com>,
	"Anthony PERARD" <anthony@xenproject.org>,
	"Marek Marczykowski-Górecki" <marmarek@invisiblethingslab.com>
Subject: Re: [PATCH] tools/libxs: Open /dev/xen/xenbus fds as O_CLOEXEC
Date: Sat, 4 May 2024 08:10:43 +0200	[thread overview]
Message-ID: <db1b1151-ab02-4fc0-b28d-2a28e5fcd78f@suse.com> (raw)
In-Reply-To: <20240504011614.1645851-1-andrew.cooper3@citrix.com>

On 04.05.24 03:16, Andrew Cooper wrote:
> 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.
> 
> Link: https://github.com/QubesOS/qubes-issues/issues/8292
> Reported-by: Demi Marie Obenour <demi@invisiblethingslab.com>
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>

With the style breakage below fixed:

Reviewed-by: Juergen Gross <jgross@suse.com>

> ---
> CC: Anthony PERARD <anthony@xenproject.org>
> CC: Juergen Gross <jgross@suse.com>
> CC: Demi Marie Obenour <demi@invisiblethingslab.com>
> CC: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
> 
> Entirely speculative patch based on a Matrix report
> ---
>   tools/libs/store/xs.c | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/libs/store/xs.c b/tools/libs/store/xs.c
> index 140b9a28395e..1f74fb3c44a2 100644
> --- a/tools/libs/store/xs.c
> +++ b/tools/libs/store/xs.c
> @@ -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);

Nit: spaces around the "|", please.


Juergen

>   }
>   
>   static int all_restrict_cb(Xentoolcore__Active_Handle *ah, domid_t domid) {
> 
> base-commit: feb9158a620040846d76981acbe8ea9e2255a07b



      reply	other threads:[~2024-05-04  6:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-04  1:16 [PATCH] tools/libxs: Open /dev/xen/xenbus fds as O_CLOEXEC Andrew Cooper
2024-05-04  6:10 ` Jürgen Groß [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=db1b1151-ab02-4fc0-b28d-2a28e5fcd78f@suse.com \
    --to=jgross@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=anthony@xenproject.org \
    --cc=demi@invisiblethingslab.com \
    --cc=marmarek@invisiblethingslab.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).