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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <fa73780d-b72b-6810-460e-5ed1057df093@arm.com>
Date:   Wed, 6 Jan 2021 16:32:23 +0000
From:   Alexandru Elisei <alexandru.elisei@....com>
To:     Eric Auger <eric.auger@...hat.com>, eric.auger.pro@...il.com,
        linux-kernel@...r.kernel.org, kvm@...r.kernel.org,
        kvmarm@...ts.cs.columbia.edu, maz@...nel.org, drjones@...hat.com
Cc:     james.morse@....com, julien.thierry.kdev@...il.com,
        suzuki.poulose@....com, shuah@...nel.org, pbonzini@...hat.com
Subject: Re: [PATCH 1/9] KVM: arm64: vgic-v3: Fix some error codes when
 setting RDIST base

Hi Eric,

On 12/12/20 6:50 PM, Eric Auger wrote:
> KVM_DEV_ARM_VGIC_GRP_ADDR group doc says we should return
> -EEXIST in case the base address of the redist is already set.
> We currently return -EINVAL.
>
> However we need to return -EINVAL in case a legacy REDIST address
> is attempted to be set while REDIST_REGIONS were set. This case
> is discriminated by looking at the count field.
>
> Signed-off-by: Eric Auger <eric.auger@...hat.com>
> ---
>  arch/arm64/kvm/vgic/vgic-mmio-v3.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm64/kvm/vgic/vgic-mmio-v3.c b/arch/arm64/kvm/vgic/vgic-mmio-v3.c
> index 15a6c98ee92f..8e8a862def76 100644
> --- a/arch/arm64/kvm/vgic/vgic-mmio-v3.c
> +++ b/arch/arm64/kvm/vgic/vgic-mmio-v3.c
> @@ -792,8 +792,13 @@ static int vgic_v3_insert_redist_region(struct kvm *kvm, uint32_t index,
>  	int ret;
>  
>  	/* single rdist region already set ?*/
> -	if (!count && !list_empty(rd_regions))
> -		return -EINVAL;
> +	if (!count && !list_empty(rd_regions)) {
> +		rdreg = list_last_entry(rd_regions,
> +				       struct vgic_redist_region, list);
> +		if (rdreg->count)
> +			return -EINVAL; /* Mixing REDIST and REDIST_REGION API */
> +		return -EEXIST;
> +	}

A few instructions below:

    if (list_empty(rd_regions)) {
        [..]
    } else {
        rdreg = list_last_entry(rd_regions,
                    struct vgic_redist_region, list);
        [..]

        /* Cannot add an explicitly sized regions after legacy region */
        if (!rdreg->count)
            return -EINVAL;
    }

Isn't this testing for the same thing, but using the opposite condition? Or am I
misunderstanding the code (quite likely)?

Looks to me like KVM_DEV_ARM_VGIC_GRP_ADDR(KVM_VGIC_V3_ADDR_TYPE_REDIST{,_REGION})
used to return -EEXIST (from vgic_check_ioaddr()) before commit ccc27bf5be7b7
("KVM: arm/arm64: Helper to register a new redistributor region") which added the
vgic_v3_insert_redist_region() function, so bringing back the -EEXIST return code
looks the right thing to me.

Thanks,
Alex
>  
>  	/* cross the end of memory ? */
>  	if (base + size < base)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ