From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7FCB3C43334 for ; Wed, 6 Jul 2022 07:12:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229984AbiGFHMs (ORCPT ); Wed, 6 Jul 2022 03:12:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229459AbiGFHMr (ORCPT ); Wed, 6 Jul 2022 03:12:47 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE8A321AC for ; Wed, 6 Jul 2022 00:12:46 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 75607B81AE7 for ; Wed, 6 Jul 2022 07:12:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0252FC3411C; Wed, 6 Jul 2022 07:12:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1657091564; bh=MKCelLRGo19jxP5YyzzSs6MDJt/u2Z/VZUjRwVgwoe4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=axxVzqO41y4qRoNIUf/mTmfLsicFzHjqLDXncKogvoPMRQOzBYkmYW6mvLSrOsYVQ QpHD9X6+hn5uJgzWaaLyDlkpZvF2gB6Z8QZoDTluWRvlDgv3VeKf/Bgc6fj2DgS9Vp MaoQHhsRQD242OMsoADmgvJdgLDahqMLL0vwjXNbLCCT7DednMdlaXJFSBa4oooAjq YhLEGBZkY6NRdctft1uUNxWvaRkbPMhp/tLzUFpaYqbYo4AeVlM+ESdtYcSIJWsHS3 cJCs2ABe9cqlS9ARTJgs+ZOY9Pe7HREj3vElhi5+i/q8KdyYcG6Fmqk4zexqU+yRkg IgmvUPuQ/B2EQ== Received: from ip-185-104-136-29.ptr.icomera.net ([185.104.136.29] helo=wait-a-minute.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1o8zDF-005YP1-Pa; Wed, 06 Jul 2022 08:12:41 +0100 Date: Wed, 06 Jul 2022 08:11:46 +0100 Message-ID: <87edyyn2a5.wl-maz@kernel.org> From: Marc Zyngier To: Schspa Shi Cc: james.morse@arm.com, alexandru.elisei@arm.com, suzuki.poulose@arm.com, catalin.marinas@arm.com, will@kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org Subject: Re: [PATCH] KVM: arm64: Fix 64 bit mmio handle In-Reply-To: References: <20220630161220.53449-1-schspa@gmail.com> <87mtdu15ok.wl-maz@kernel.org> <87letd0wqm.wl-maz@kernel.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.104.136.29 X-SA-Exim-Rcpt-To: schspa@gmail.com, james.morse@arm.com, alexandru.elisei@arm.com, suzuki.poulose@arm.com, catalin.marinas@arm.com, will@kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org 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 Fri, 01 Jul 2022 15:22:51 +0100, Schspa Shi wrote: > > > Marc Zyngier writes: > > >> > >> I have running some static code analysis software upon Kernel code. > >> Seeing there is possible overflow. > >> > >> maks << 1U << ((len * 8) -1); > >> > >> The AI don't know, len is only the value of 1, 2, 4, and make this > >> a warnings > >> > >> I tring to analysis this, but didn't realize the real scenario of > >> sign extension, and finally sent this problematic patch. > >> > >> I do see some uninitialized memory reads (the values are not used > >> in the end, just as temporary space for API execution), > >> do we need to fix these? > > > > You need to be more descriptive here. What uninitialised reads? In > > general, pointing at the code and providing a full description of > > what > > you think is incorrect would really help... > > > > M. > One example is > int vgic_v3_has_attr_regs(struct kvm_device *dev, struct > kvm_device_attr *attr) > { > ... > case KVM_DEV_ARM_VGIC_GRP_CPU_SYSREGS: { > u64 reg, id; > > id = (attr->attr & KVM_DEV_ARM_VGIC_SYSREG_INSTR_MASK); > return vgic_v3_has_cpu_sysregs_attr(vcpu, 0, id, ®); > } > > } > > The funcion vgic_v3_has_cpu_sysregs_attr will read reg's value to > params without initialization. There should have no problems, > because the register value never used. Thanks for pointing this out. I spent some time looking at this, and this is only the tip of the iceberg. The whole userspace interaction with the GIC sysregs is ugly (at best), and needs some love. I've written a small series[1] cleaning things up, which needs testing (I've just checked that it was compiling correctly). I'd appreciate you running your tool on it. M. [1] https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms.git/log/?h=kvm-arm64/sysreg-cleanup-5.20 -- Without deviation from the norm, progress is not possible.