From: Keir Fraser Subject: Re: [PATCH] [XEN] [ACM] [2/2] Restructuring ACM-related code in do_domctl Date: Sun, 22 Apr 2007 19:34:00 +0100 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0172606881==" Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Mime-version: 1.0 Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Stefan Berger Cc: xen-devel List-Id: xen-devel@lists.xenproject.org > This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. --===============0172606881== Content-type: multipart/alternative; boundary="B_3260115259_10976835" > This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. --B_3260115259_10976835 Content-type: text/plain; charset="ISO-8859-1" Content-transfer-encoding: quoted-printable On 22/4/07 18:35, "Stefan Berger" wrote: > At the beginning of do_domctl() there's the call to acm_pre_domctl, which= ends > up in its callpath in chwall_pre_domain_create to check whether under the > current policy the domain is allowed to be created and it grabs the lock = to > the policy before doing that. > At the end of the do_domctl() there's the call to acm_post_domctl, in cas= e > everything went fine with creating the domain for example. Here it ends u= p in > its callpath in chwall_post_domain_create where it again grabs the lock t= o the > policy and under the assumption that the policy hasn't changed modifies a > counter array (running_types). > If the policy is changed in between those calls, i.e. the chinese wall pa= rt is > changed such that the domain would not be allowed to exist under the new > policy, the post-domain-create call would still go through. That's what I= want > to prevent with a continously-held lock that spans the evaluation at the > beginning and the modification of that counter array at the end. If you did this with a straightforward domain_create() hook, you could update state at the same time as doing the policy check. Your domain_destroy() hook would be called if the creation subsequently failed t= o commit. And if the policy changes at any time after the call to your domain_create() hook, you=B9ve already updated your ACM state so you can see the new domain via some internal structure you presumably maintains, and hence can re-evaluate the decision under the new policy. In general, keeping checks and state updates together is nice compared with pushing them to pre/post hooks with locks implicitly held across the two. That=B9s just plain gross imo. That is, an architecture where you have a =8Cpre-doing-stuff=B9 hook and a =8Cpre-destroying-stuff=B9 hook, where the latter is also called when the doing-stuff action turns out to fail, is nicer than pre/post hooks. -- Keir --B_3260115259_10976835 Content-type: text/html; charset="ISO-8859-1" Content-transfer-encoding: quoted-printable Re: [Xen-devel] [PATCH] [XEN] [ACM] [2/2] Restructuring ACM-related = code in do_domctl On 22= /4/07 18:35, "Stefan Berger" <stefanb@us.ibm.com> wrote:

At the beginning of do_domctl() there's the call to acm_pre_d= omctl, which ends up in its callpath in chwall_pre_domain_create to check wh= ether under the current policy the domain is allowed to be created and it gr= abs the lock to the policy before doing that.
At the end of the do_domctl() there's the call to acm_post_domctl, in case = everything went fine with creating the domain for example. Here it ends up i= n its callpath in chwall_post_domain_create where it again grabs the lock to= the policy and under the assumption that the policy hasn't changed modifies= a counter array (running_types).
If the policy is changed in between those calls, i.e. the chinese wall part= is changed such that the domain would not be allowed to exist under the new= policy, the post-domain-create call would still go through. That's what I w= ant to prevent with a continously-held lock that spans the evaluation at the= beginning and the modification of that counter array at the end.


If you did this with a straightforward domain_create() hook, you could upda= te state at the same time as doing the policy check. Your domain_destroy() h= ook would be called if the creation subsequently failed to commit. And if th= e policy changes at any time after the call to your domain_create() hook, yo= u’ve already updated your ACM state so you can see the new domain via = some internal structure you presumably maintains, and hence can re-evaluate = the decision under the new policy.

In general, keeping checks and state updates together is nice compared with= pushing them to pre/post hooks with locks implicitly held across the two. T= hat’s just plain gross imo.

That is, an architecture where you have a ‘pre-doing-stuff’ hoo= k and a ‘pre-destroying-stuff’ hook, where the latter is also ca= lled when the doing-stuff action turns out to fail, is nicer than pre/post h= ooks.

 -- Keir
--B_3260115259_10976835-- --===============0172606881== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --===============0172606881==--