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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CDA1CD0BB7F for ; Thu, 24 Oct 2024 09:41:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: References:In-Reply-To:Subject:Cc:To:From:Message-ID:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=0qE5EMY0b9VvuP2GyyiL1MxtVqnnoZzYu8ao8xgikjo=; b=bS1GPGw7jMYyl8xWeZuwwOqG/P Rx6B04/rRDY2JnmFMGqgAO/PA3fA1ei+Lm7YZESalUgmkffpZqMbDrzluloTokxGuoRwxvL0cTIn7 YexEDsySTjJ0RfIrzDthdqXyeNZxoM7N2WqSjKupFB8Y2mGxiF5sTV/PUGknTyZkxa9jjkVVxKBYZ 9IyocOfDbnXRs84Qyu47Asfeyya+6VYycWZJH4BwGBNlkryIapm540bMuy7NFSv/VoKrmAVrc6ZE/ 9vTOrCl2cwjBNKST/22puTghGHuCrQPeYRUBCqxEopwQOg1GLIGowf+ZzghabdA/5ggbuSe8hqpMP eqjgMcvQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t3uKz-0000000HVzP-0gE8; Thu, 24 Oct 2024 09:41:01 +0000 Received: from nyc.source.kernel.org ([147.75.193.91]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t3u9z-0000000HT6p-3dcm for linux-arm-kernel@lists.infradead.org; Thu, 24 Oct 2024 09:29:41 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 87115A45167; Thu, 24 Oct 2024 09:29:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6144AC4CEC7; Thu, 24 Oct 2024 09:29:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729762178; bh=geudcH7yX/W/ZOpP6E9dcE7viAct/chywpGntfYcIkE=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=CGgbSkeUrmHIO5OJczLufZwvq7GiFh6rzSjgVFYP3UEcyK3K1uFdJuXE4iVQNu2pT lYy1QX4XH8QYIfjb74mXh7z8VIjoNNr1k8/dx1cBOnGeueOsenoBTu8UxvJpzzWwmB fbpks0bjuxUy9zaZD60+t208Gdqusm8P/HjG9A34Bi8/Eiroc0cktp3rnl9I18HqqC /fmcC71cySbl3DHhze731zTF37KLWmUyrlVevTssaVcoTLApauJAxdGF7R7MLgBrtL 2ZS6x646umBXNdkbH4g7QWI4+e/5hlbnqXbCpqbuGwk9dwzR6VyP29wbQIcuyTWuX1 9OTLgF+qx9VTg== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.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 1t3u9w-006ODj-74; Thu, 24 Oct 2024 10:29:36 +0100 Date: Thu, 24 Oct 2024 10:29:35 +0100 Message-ID: <86wmhx3l34.wl-maz@kernel.org> From: Marc Zyngier To: Gaosheng Cui Cc: , , , , , , , , , Subject: Re: [PATCH -next] KVM: arm64: Fix possible null-ptr-deref in idregs_debug_show In-Reply-To: <20241024083350.2828920-1-cuigaosheng1@huawei.com> References: <20241024083350.2828920-1-cuigaosheng1@huawei.com> 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/29.4 (aarch64-unknown-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.219.108.64 X-SA-Exim-Rcpt-To: cuigaosheng1@huawei.com, oliver.upton@linux.dev, joey.gouly@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, sebott@redhat.com, wangweiyang2@huawei.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241024_022940_137291_9CE14FD3 X-CRM114-Status: GOOD ( 20.89 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, 24 Oct 2024 09:33:50 +0100, Gaosheng Cui wrote: > > The idregs_debug_show() maybe return nullptr, we need to check desc > before dereference it to avoid possible null pointer dereferences. > > Fixes: 410db103f6eb ("KVM: arm64: Make idregs debugfs iterator search sysreg table directly") > Signed-off-by: Gaosheng Cui > --- > arch/arm64/kvm/sys_regs.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c > index ff8c4e1b847e..b1c59773b9c0 100644 > --- a/arch/arm64/kvm/sys_regs.c > +++ b/arch/arm64/kvm/sys_regs.c > @@ -4135,7 +4135,7 @@ static int idregs_debug_show(struct seq_file *s, void *v) > > desc = idregs_debug_find(kvm, kvm->arch.idreg_debugfs_iter); > > - if (!desc->name) > + if (!desc || !desc->name) > return 0; > > seq_printf(s, "%20s:\t%016llx\n", Can you show a case where this happens in practice? The check for NULL is already in idregs_debug_next(), and I don't see how this can actually be triggered. Thanks, M. -- Without deviation from the norm, progress is not possible.