xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Artem Mygaiev <Artem_Mygaiev@epam.com>
To: "julien.grall@arm.com" <julien.grall@arm.com>,
	"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Cc: "jgross@suse.com" <jgross@suse.com>,
	"dgdegra@tycho.nsa.gov" <dgdegra@tycho.nsa.gov>,
	"paul@xen.org" <paul@xen.org>
Subject: Re: [Xen-devel] [PATCH for-4.13] xen/xsm: flask: Prevent NULL deference in flask_assign_{, dt}device()
Date: Wed, 9 Oct 2019 11:57:54 +0000	[thread overview]
Message-ID: <f262a8aeb67c6aabde80b1e6cdae6f19c077ff11.camel@epam.com> (raw)
In-Reply-To: <20191004164243.30822-1-julien.grall@arm.com>

Hi Julien

On Fri, 2019-10-04 at 17:42 +0100, Julien Grall wrote:
> flask_assign_{, dt}device() may be used to check whether you can test
> if
> a device is assigned. In this case, the domain will be NULL.
> 
> However, flask_iommu_resource_use_perm() will be called and may end
> up
> to deference a NULL pointer. This can be prevented by moving the call
> after we check the validity for the domain pointer.
> 
> Coverity-ID: 1486741

The correct CID is 1486742

> Fixes: 71e617a6b8 ('use is_iommu_enabled() where appropriate...')
> Signed-off-by: Julien Grall <
> julien.grall@arm.com
> >
> ---
>  xen/xsm/flask/hooks.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/xen/xsm/flask/hooks.c b/xen/xsm/flask/hooks.c
> index 3b30827764..cf7f25cda2 100644
> --- a/xen/xsm/flask/hooks.c
> +++ b/xen/xsm/flask/hooks.c
> @@ -1296,11 +1296,13 @@ static int flask_assign_device(struct domain
> *d, uint32_t machine_bdf)
>      u32 dsid, rsid;
>      int rc = -EPERM;
>      struct avc_audit_data ad;
> -    u32 dperm = flask_iommu_resource_use_perm(d);
> +    u32 dperm;
>  
>      if ( !d )
>          return flask_test_assign_device(machine_bdf);
>  
> +    dperm = flask_iommu_resource_use_perm(d);
> +
>      rc = current_has_perm(d, SECCLASS_RESOURCE, RESOURCE__ADD);
>      if ( rc )
>          return rc;
> @@ -1355,11 +1357,13 @@ static int flask_assign_dtdevice(struct
> domain *d, const char *dtpath)
>      u32 dsid, rsid;
>      int rc = -EPERM;
>      struct avc_audit_data ad;
> -    u32 dperm = flask_iommu_resource_use_perm(d);
> +    u32 dperm;
>  
>      if ( !d )
>          return flask_test_assign_dtdevice(dtpath);
>  
> +    dperm = flask_iommu_resource_use_perm(d);
> +
>      rc = current_has_perm(d, SECCLASS_RESOURCE, RESOURCE__ADD);
>      if ( rc )
>          return rc;
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  parent reply	other threads:[~2019-10-09 11:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-04 16:42 [Xen-devel] [PATCH for-4.13] xen/xsm: flask: Prevent NULL deference in flask_assign_{, dt}device() Julien Grall
2019-10-04 17:58 ` Daniel De Graaf
2019-10-05 12:05 ` Paul Durrant
2019-10-07  6:52 ` Jürgen Groß
2019-10-09 11:57 ` Artem Mygaiev [this message]
2019-10-10 14:48   ` Julien Grall
2019-10-10 15:07     ` Artem Mygaiev

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=f262a8aeb67c6aabde80b1e6cdae6f19c077ff11.camel@epam.com \
    --to=artem_mygaiev@epam.com \
    --cc=dgdegra@tycho.nsa.gov \
    --cc=jgross@suse.com \
    --cc=julien.grall@arm.com \
    --cc=paul@xen.org \
    --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 NNTP newsgroup(s).