[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH for-4.13] xen/xsm: flask: Prevent NULL deference in flask_assign_{, dt}device()


  • To: "julien.grall@xxxxxxx" <julien.grall@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Artem Mygaiev <Artem_Mygaiev@xxxxxxxx>
  • Date: Wed, 9 Oct 2019 11:57:54 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nr7Vr/OvhGN99ZMQjcsTImRo9FJcks7G+HgxISGqHOo=; b=SWGm67xt7aMOM5Fk7dJg6VnM7os9pIxo1FGwf8Q18E5jTaQjru+mGJlgKIPV8/bFeDKSEiPBbNb8TE0FOMhygWnP6wusffouyKcjTbAuocDl3JCfGBHD2qkRP75/gUkJeimiYhEBG+DsVkEo/izAZ3FFsrNqtPTtF169s/oXlkUSIU5mzd87MCA7EAt6Bs8Ow+QAmME+T3wVnnTAVtjSHMuiyBisdIgFwRbOE1t1MCfWZ3KFkTdyJviLZO4bftENejelOL9ajEQwcCjGPA9oc6r8ioOSEX2ARHlFAxQHGKlrmTSP8l2oSx/rXcZ0OQwLmD/mwr8ypo8gO/iSTKISNw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=elQXraEM6I2AhEvQf4lwNGuEhNg9YHJqJ4FW5s5oKL9a0HvWhLRZAEaW1nxzDdN5DNEgJkryQXqlBKMHbd1qnAok6Z8sDvnHUqja6uYg14hJb83/oAJctoLgC/mA3R4SWqZacuZjr3/vc8HtdrOAgM7QRSYDR6o6daaDNucmQYF/ss+0AP9dwkm0ll0gsjqMpl3AtP4Ukj97sAmwdjFX1yAUyYQabje5pzm3NPJ+ZpJU1i0RSrFI//7vcDzn3kyqn/QsnrPtv6CzzEsy1DB/FsQ1H72ZfMaQk+4bGB4JdH3VIVFIApuQmNTvS4HW9dY9SelNREoOZe0Rkboopi0S4w==
  • Authentication-results: spf=none (sender IP is ) smtp.mailfrom=Artem_Mygaiev@xxxxxxxx;
  • Cc: "jgross@xxxxxxxx" <jgross@xxxxxxxx>, "dgdegra@xxxxxxxxxxxxx" <dgdegra@xxxxxxxxxxxxx>, "paul@xxxxxxx" <paul@xxxxxxx>
  • Delivery-date: Wed, 09 Oct 2019 11:58:03 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHVetLnOcgJQSH9KE+B1/k9VstXPKdSO+mA
  • Thread-topic: [Xen-devel] [PATCH for-4.13] xen/xsm: flask: Prevent NULL deference in flask_assign_{, dt}device()

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@xxxxxxx
> >
> ---
>  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@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.