Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3760753pxb; Tue, 17 Nov 2020 02:53:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJxHYozyt32V6lyTEweFeik7NLH3uVpdoLuSsU+jYx18N/zko/+gjNiV+g5SkxvUOGcGl9iC X-Received: by 2002:a50:c19a:: with SMTP id m26mr19293748edf.302.1605610387131; Tue, 17 Nov 2020 02:53:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605610387; cv=none; d=google.com; s=arc-20160816; b=EbRn7DhKstvhd2E+R952sKvtXCK5cm4EL3bmmYrYxPO3x1jTaYlbrGW6QZIutPxfwr O1c04BcQRDhtgI91TsHJA9YWuBzVp/bOM24Bv6ezw6H7sMyDDHyWFysOng7f/IhNA5eF SmFLOa9IGzy1XPpMRbEPNzXFcpqQH11UhQubz/YQKORuWY4WK2I2brYr//DHKlWwblEl wjjxU/1u5Fagkd6QjSvhJjTOt8QzBeGPQK9PUDhdbxg/vqx8zD1DsVAAKr0SHBqoEt6w Sk/Dpy36zhp17RshWOiBgTTo1cGDj8jd6WHB2gnbRG2BcHbmnndjhlDfjKnlxgd7yJLb YglA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:user-agent:references:in-reply-to :subject:cc:to:from:date:content-transfer-encoding:mime-version :dkim-signature; bh=G7SMZHux3o/PFfCe69NhVdw9OVpRXlZHx6wjA1/FqvI=; b=U8NExgkOHbC0ms6YOZu7zY7XdiE77BLUenlyzbEuPlzGQgXLuKXC2pNzyQDE5TNQ8/ 8DkRJC2b/d+RD4dMqctWXqpOeMT9CDEp+geg1nq3t7WG2O02tZ4+nTQgpddCkeTxR08e qYTF9DyRXunpSwyFSuBXPKJy9NVo0UZLqEoVJ6//esMaAemJ7FGepuSMUKWsWOECTV7T P1gF5EG+cmJscw3hvJnRu65eLhZrrfubxmzpvEHrz6DJEyw58t9eFOSavaPNBncPWVda 3CM/LeuzR3ckpjVySX2+jhTJaGrKAtqZSvpokiqCysnPGyqviKVRH3erhEhrzEIdNZMX fxRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hJb1EcqJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q26si14111786ejb.105.2020.11.17.02.52.44; Tue, 17 Nov 2020 02:53:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hJb1EcqJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727874AbgKQKvN (ORCPT + 99 others); Tue, 17 Nov 2020 05:51:13 -0500 Received: from mail.kernel.org ([198.145.29.99]:59332 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726310AbgKQKvM (ORCPT ); Tue, 17 Nov 2020 05:51:12 -0500 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DF07A22447; Tue, 17 Nov 2020 10:51:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605610272; bh=M9flKwRDRr9z64KmcbSgnOXXghPG2KQsLqY0zyac1Pc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=hJb1EcqJN7y1+EllTk1nrvx7ql2HD2xrFheKYg8a5Qe1xK4dx+bbBZuRQE43nJsgP cLIg109k/Xs+axWgm62EusuYdb1mhlnsy5YoJwfluMJ9qupSxhcu4yXO2J0KinRL6h 6YzGxnDuj0ANEfmFcJ7Quv/pVpImxgKmhNcqZMsc= Received: from disco-boy.misterjones.org ([51.254.78.96] helo=www.loen.fr) by disco-boy.misterjones.org with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94) (envelope-from ) id 1keyZp-00BIq8-MW; Tue, 17 Nov 2020 10:51:09 +0000 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Date: Tue, 17 Nov 2020 10:51:09 +0000 From: Marc Zyngier To: Auger Eric Cc: Zenghui Yu , suzuki.poulose@arm.com, linux-kernel@vger.kernel.org, james.morse@arm.com, linux-arm-kernel@lists.infradead.org, wanghaibin.wang@huawei.com, Keqian Zhu , kvmarm@lists.cs.columbia.edu, julien.thierry.kdev@gmail.com Subject: Re: [PATCH 1/2] KVM: arm64: vgic: Forbid invalid userspace Redistributor accesses In-Reply-To: <5ba4a98e-276b-2462-0580-fe0e007e9b38@redhat.com> References: <20201113142801.1659-1-yuzenghui@huawei.com> <20201113142801.1659-2-yuzenghui@huawei.com> <724c43702b52aac0d3c9beb9604d1bfb@kernel.org> <584b7ff1-ecf2-b0ec-cea3-ccc29902f43a@huawei.com> <7e58200c-814e-3598-155a-9a7e6cc24374@huawei.com> <5ba4a98e-276b-2462-0580-fe0e007e9b38@redhat.com> User-Agent: Roundcube Webmail/1.4.9 Message-ID: <6f4312dbedd6c1d8fa88dc0fc5adcb5d@kernel.org> X-Sender: maz@kernel.org X-SA-Exim-Connect-IP: 51.254.78.96 X-SA-Exim-Rcpt-To: eric.auger@redhat.com, yuzenghui@huawei.com, suzuki.poulose@arm.com, linux-kernel@vger.kernel.org, james.morse@arm.com, linux-arm-kernel@lists.infradead.org, wanghaibin.wang@huawei.com, zhukeqian1@huawei.com, kvmarm@lists.cs.columbia.edu, julien.thierry.kdev@gmail.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-11-17 09:59, Auger Eric wrote: > Hi Marc, > > On 11/17/20 9:49 AM, Marc Zyngier wrote: >> Hi Zenghui, >> >> On 2020-11-16 14:57, Zenghui Yu wrote: >>> Hi Marc, >>> >>> On 2020/11/16 22:10, Marc Zyngier wrote: >>>>> My take is that only if the "[Re]Distributor base address" is >>>>> specified >>>>> in the system memory map, will the user-provided >>>>> kvm_device_attr.offset >>>>> make sense. And we can then handle the access to the register which >>>>> is >>>>> defined by "base address + offset". >>>> >>>> I'd tend to agree, but it is just that this is a large change at >>>> -rc4. >>>> I'd rather have a quick fix for 5.10, and a more invasive change for >>>> 5.11, >>>> spanning all the possible vgic devices. >>> >>> So you prefer fixing it by "return a value that doesn't have the Last >>> bit set" for v5.10? I'm ok with it and can send v2 for it. >> >> Cool. Thanks for that. >> >>> Btw, looking again at the way we handle the user-reading of >>> GICR_TYPER >>> >>>     vgic_mmio_read_v3r_typer(vcpu, addr, len) >>> >>> it seems that @addr is actually the *offset* of GICR_TYPER (0x0008) >>> and >>> @addr is unlikely to be equal to last_rdist_typer, which is the *GPA* >>> of >>> the last RD. Looks like the user-reading of GICR_TYPER.Last is always >>> broken? >> >> I think you are right. Somehow, we don't seem to track the index of >> the RD in the region, so we can never compute the address of the RD >> even if the base address is set. >> >> Let's drop the reporting of Last for userspace for now, as it never >> worked. If you post a patch addressing that quickly, I'll get it to >> Paolo by the end of the week (there's another fix that needs merging). >> >> Eric: do we have any test covering the userspace API? > > So as this issue seems related to the changes made when implementing > the > multiple RDIST regions, I volunteer to write those KVM selftests :-) You're on! :D More seriously, there is scope for fuzzing the device save/restore API, as we find bugs every time someone change the "known good" ordering that is implemented in QEMU. Maybe it means getting rid of some unnecessary flexibility, as proposed by Zenghui, if we are confident that no userspace makes use of it. And in the future, making sure that new APIs are rigid enough to avoid such bugs. Thanks, M. -- Jazz is not dead. It just smells funny...