All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: Andrew Cooper <andrew.cooper3@citrix.com>,
	"Daniel P. Smith" <dpsmith@apertussolutions.com>
Cc: Daniel De Graaf <dgdegra@tycho.nsa.gov>, xen-devel@lists.xenproject.org
Subject: Re: [PATCH v2 02/10] xsm: refactor xsm_ops handling
Date: Wed, 14 Jul 2021 17:54:27 +0200	[thread overview]
Message-ID: <386d3846-a4d8-5c40-498b-1b4adae68687@suse.com> (raw)
In-Reply-To: <1638ecbe-59a2-1ef1-f18e-dc63e1740168@citrix.com>

On 13.07.2021 01:39, Andrew Cooper wrote:
> On 12/07/2021 21:32, Daniel P. Smith wrote:
>> diff --git a/xen/include/xsm/xsm.h b/xen/include/xsm/xsm.h
>> index ad3cddbf7d..a8805f514b 100644
>> --- a/xen/include/xsm/xsm.h
>> +++ b/xen/include/xsm/xsm.h
>> @@ -747,16 +747,14 @@ extern int xsm_dt_policy_init(void **policy_buffer, size_t *policy_size);
>>  extern bool has_xsm_magic(paddr_t);
>>  #endif
>>  
>> -extern int register_xsm(struct xsm_operations *ops);
>> -
>> -extern struct xsm_operations dummy_xsm_ops;
>>  extern void xsm_fixup_ops(struct xsm_operations *ops);
>>  
>>  #ifdef CONFIG_XSM_FLASK
>> -extern void flask_init(const void *policy_buffer, size_t policy_size);
>> +extern struct xsm_operations *flask_init(const void *policy_buffer, size_t policy_size);
>>  #else
>> -static inline void flask_init(const void *policy_buffer, size_t policy_size)
>> +static inline struct xsm_operations *flask_init(const void *policy_buffer, size_t policy_size)
>>  {
>> +    return NULL;
>>  }
>>  #endif
> 
> As you touch almost every current user of xsm_operations and introduce
> quite a few more, can I recommend taking the opportunity to shorten the
> name to struct xsm_ops.

+1

>> --- a/xen/xsm/flask/flask_op.c
>> +++ b/xen/xsm/flask/flask_op.c
>> @@ -226,6 +226,7 @@ static int flask_security_sid(struct xen_flask_sid_context *arg)
>>  static int flask_disable(void)
>>  {
>>      static int flask_disabled = 0;
>> +    struct xsm_operations default_ops;
>>  
>>      if ( ss_initialized )
>>      {
>> @@ -244,7 +245,8 @@ static int flask_disable(void)
>>      flask_disabled = 1;
>>  
>>      /* Reset xsm_ops to the original module. */
>> -    xsm_ops = &dummy_xsm_ops;
>> +    xsm_fixup_ops(&default_ops);
>> +    xsm_ops = default_ops;
>>  
>>      return 0;
>>  }
> 
> These two hunks will disappear when patch 3 is reordered with respect to
> this one.
> 
> ... which is good because you've just pointed xsm_ops at a
> soon-to-be-out-of-scope local variable on the stack.

Not really, it's a structure copy now. What I'm concerned about is
the size of that on-stack variable and its lack of an initializer,
undermining the many set_to_dummy_if_null() that xsm_fixup_ops()
uses. Can't xsm_fixup_ops() act on xsm_ops directly, perhaps after
memset()-ing it here first (if nothing else then just to be on the
safe side)?

>> diff --git a/xen/xsm/flask/hooks.c b/xen/xsm/flask/hooks.c
>> index f1a1217c98..a3a88aa8ed 100644
>> --- a/xen/xsm/flask/hooks.c
>> +++ b/xen/xsm/flask/hooks.c
>> @@ -1883,7 +1883,8 @@ static struct xsm_operations flask_ops = {
>>  #endif
>>  };
> 
> flask and silo ops should become:
> 
> static const struct xsm_ops __initconst {flask,silo}_ops = {
> 
> as they're neither modified, nor needed after init, following this change.
> 
>>  
>> -void __init flask_init(const void *policy_buffer, size_t policy_size)
>> +struct xsm_operations __init *flask_init(const void *policy_buffer,
>> +					 size_t policy_size)
> 
> struct xsm_ops *__init flask_init(...)
> 
> Otherwise you've got the __init in the middle of the return type, and
> some compilers are more picky than others.

Also, even if {flask,silo}_ops couldn't be const for some reason,
these init functions now want to return a pointer-to-const, as
the caller isn't supposed to modify the struct-s any further.

Jan



  reply	other threads:[~2021-07-14 15:54 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-12 20:32 [PATCH v2 00/10] xsm: refactoring xsm hooks Daniel P. Smith
2021-07-12 20:32 ` [PATCH v2 01/10] xen: Implement xen/alternative-call.h for use in common code Daniel P. Smith
2021-07-12 23:48   ` Andrew Cooper
2021-07-13  6:28     ` Jan Beulich
2021-07-13  8:36       ` Andrew Cooper
2021-07-13  8:53         ` Jan Beulich
2021-07-14 15:35   ` Jan Beulich
2021-07-12 20:32 ` [PATCH v2 02/10] xsm: refactor xsm_ops handling Daniel P. Smith
2021-07-12 23:39   ` Andrew Cooper
2021-07-14 15:54     ` Jan Beulich [this message]
2021-07-15 17:16     ` Daniel P. Smith
2021-07-12 20:32 ` [PATCH v2 03/10] xsm: remove the ability to disable flask Daniel P. Smith
2021-07-12 23:22   ` Andrew Cooper
2021-07-15 17:17     ` Daniel P. Smith
2021-07-14 15:58   ` Jan Beulich
2021-07-15 17:19     ` Daniel P. Smith
2021-07-12 20:32 ` [PATCH v2 04/10] xsm: convert xsm_ops hook calls to alternative call Daniel P. Smith
2021-07-12 23:44   ` Andrew Cooper
2021-07-15 17:20     ` Daniel P. Smith
2021-07-12 20:32 ` [PATCH v2 05/10] xsm: decouple xsm header inclusion selection Daniel P. Smith
2021-07-12 20:32 ` [PATCH v2 06/10] xsm: enable xsm to always be included Daniel P. Smith
2021-07-19 10:24   ` Jan Beulich
2021-07-25 20:47     ` Daniel P. Smith
2021-08-03  7:08       ` Jan Beulich
2021-07-12 20:32 ` [PATCH v2 07/10] xsm: drop generic event channel labeling Daniel P. Smith
2021-07-12 23:52   ` Andrew Cooper
2021-07-15 17:26     ` Daniel P. Smith
2021-07-16  7:03   ` Jan Beulich
2021-07-12 20:32 ` [PATCH v2 08/10] xsm: remove xsm_default_t from hook definitions Daniel P. Smith
2021-07-16  7:23   ` Jan Beulich
2021-07-16 14:15     ` Andrew Cooper
2021-07-16 14:55       ` Jan Beulich
2021-07-16  7:37   ` Jan Beulich
2021-07-27 13:39   ` Ian Jackson
2021-08-06 21:41     ` Daniel P. Smith
2021-08-10  8:39       ` Jan Beulich
2021-08-26  9:42       ` Jan Beulich
2021-07-12 20:32 ` [PATCH v2 09/10] xsm: expand the function related macros in dummy.h Daniel P. Smith
2021-07-16  7:34   ` Jan Beulich
2021-07-24 20:07     ` Daniel P. Smith
2021-07-24 20:43       ` Daniel P. Smith
2021-08-03  7:23       ` Jan Beulich
2021-07-12 20:32 ` [PATCH v2 10/10] xsm: removing the XSM_ASSERT_ACTION macro Daniel P. Smith
2021-07-12 23:12 ` [PATCH v2 00/10] xsm: refactoring xsm hooks Andrew Cooper

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=386d3846-a4d8-5c40-498b-1b4adae68687@suse.com \
    --to=jbeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=dgdegra@tycho.nsa.gov \
    --cc=dpsmith@apertussolutions.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.