lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f1a0b4f7-33df-f541-9df8-39dd282aef29@amd.com>
Date:   Fri, 11 Sep 2020 10:24:40 +0700
From:   Suravee Suthikulpanit <suravee.suthikulpanit@....com>
To:     Joao Martins <joao.m.martins@...cle.com>,
        iommu@...ts.linux-foundation.org, linux-kernel@...r.kernel.org
Cc:     Dan Carpenter <dan.carpenter@...cle.com>,
        Joerg Roedel <joro@...tes.org>
Subject: Re: [PATCH] iommu/amd: Fix potential @entry null deref

Thanks for catching this.

On 9/11/20 12:16 AM, Joao Martins wrote:
> After commit 26e495f34107 ("iommu/amd: Restore IRTE.RemapEn bit after
> programming IRTE"), smatch warns:
> 
> 	drivers/iommu/amd/iommu.c:3870 amd_iommu_deactivate_guest_mode()
>          warn: variable dereferenced before check 'entry' (see line 3867)
> 
> Fix this by moving the @valid assignment to after @entry has been checked
> for NULL.
> 
> Cc: Suravee Suthikulpanit <suravee.suthikulpanit@....com>
> Fixes: 26e495f34107 ("iommu/amd: Restore IRTE.RemapEn bit after programming IRTE")
> Reported-by: Dan Carpenter <dan.carpenter@...cle.com>
> Signed-off-by: Joao Martins <joao.m.martins@...cle.com>
> ---
>   drivers/iommu/amd/iommu.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
> index 07ae8b93887e..8abe1c7ad45b 100644
> --- a/drivers/iommu/amd/iommu.c
> +++ b/drivers/iommu/amd/iommu.c
> @@ -3864,12 +3864,14 @@ int amd_iommu_deactivate_guest_mode(void *data)
>   	struct amd_ir_data *ir_data = (struct amd_ir_data *)data;
>   	struct irte_ga *entry = (struct irte_ga *) ir_data->entry;
>   	struct irq_cfg *cfg = ir_data->cfg;
> -	u64 valid = entry->lo.fields_remap.valid;
> +	u64 valid;
>   
>   	if (!AMD_IOMMU_GUEST_IR_VAPIC(amd_iommu_guest_ir) ||
>   	    !entry || !entry->lo.fields_vapic.guest_mode)
>   		return 0;
>   
> +	valid = entry->lo.fields_remap.valid;
> +
>   	entry->lo.val = 0;
>   	entry->hi.val = 0;
>   
> 

Reviewed-by: Suravee Suthikulpanit <suravee.suthikulpanit@....com>

Suravee

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ