All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wei Liu <wei.liu2@citrix.com>
To: Petre Eftime <epetre@amazon.com>
Cc: xen-devel@lists.xenproject.org, Wei Liu <wei.liu2@citrix.com>,
	Amit Shah <aams@amazon.com>,
	Ian Jackson <ian.jackson@eu.citrix.com>,
	David Woodhouse <dwmw@amazon.com>
Subject: Re: [PATCH] tools/xenstore: domain can sometimes disappear when destroying connection
Date: Thu, 29 Nov 2018 12:52:55 +0000	[thread overview]
Message-ID: <20181129125255.uesjk4cyoqzgp53e@zion.uk.xensource.com> (raw)
In-Reply-To: <20181126132204.16258-1-epetre@amazon.com>

On Mon, Nov 26, 2018 at 01:22:04PM +0000, Petre Eftime wrote:
> There is a circular link formed between domain and a connection. In certain
> circustances, when conn is freed, domain is also freed, which leads to use
> after free when trying to set the conn field in domain to null.

Actually, can you provide more context on this? When will the circular
link happen?

Wei.

> 
> Signed-off-by: Petre Eftime <epetre@amazon.com>
> ---
>  tools/xenstore/xenstored_domain.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/xenstore/xenstored_domain.c b/tools/xenstore/xenstored_domain.c
> index fa6655033a..f085d40476 100644
> --- a/tools/xenstore/xenstored_domain.c
> +++ b/tools/xenstore/xenstored_domain.c
> @@ -222,6 +222,7 @@ static void domain_cleanup(void)
>  {
>  	xc_dominfo_t dominfo;
>  	struct domain *domain;
> +	struct connection *tmp_conn;
>  	int notify = 0;
>  
>   again:
> @@ -238,8 +239,14 @@ static void domain_cleanup(void)
>  				continue;
>  		}
>  		if (domain->conn) {
> -			talloc_unlink(talloc_autofree_context(), domain->conn);
> +			/*
> +			 * In certain circumstances conn owns domain and
> +			 * domain will be freed when conn is unlinked.
> +			 */
> +			tmp_conn = domain->conn;
>  			domain->conn = NULL;
> +
> +			talloc_unlink(talloc_autofree_context(), tmp_conn);
>  			notify = 0; /* destroy_domain() fires the watch */
>  			goto again;
>  		}
> -- 
> 2.16.5
> 
> 
> 
> 
> Amazon Development Center (Romania) S.R.L. registered office: 27A Sf. Lazar Street, UBC5, floor 2, Iasi, Iasi County, 700045, Romania. Registered in Romania. Registration number J22/2621/2005.
> 

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  parent reply	other threads:[~2018-11-29 12:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-26 13:22 [PATCH] tools/xenstore: domain can sometimes disappear when destroying connection Petre Eftime
2018-11-29 12:03 ` Wei Liu
2018-11-29 12:52 ` Wei Liu [this message]
2018-11-29 13:10   ` Eftime, Petre
2018-11-29 13:38     ` Wei Liu
2018-11-29 13:55       ` Wei Liu

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=20181129125255.uesjk4cyoqzgp53e@zion.uk.xensource.com \
    --to=wei.liu2@citrix.com \
    --cc=aams@amazon.com \
    --cc=dwmw@amazon.com \
    --cc=epetre@amazon.com \
    --cc=ian.jackson@eu.citrix.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.