linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Gaosheng Cui <cuigaosheng1@huawei.com>
Cc: <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>
Subject: Re: [PATCH -next] KVM: arm64: Fix possible null-ptr-deref in idregs_debug_show
Date: Thu, 24 Oct 2024 10:29:35 +0100	[thread overview]
Message-ID: <86wmhx3l34.wl-maz@kernel.org> (raw)
In-Reply-To: <20241024083350.2828920-1-cuigaosheng1@huawei.com>

On Thu, 24 Oct 2024 09:33:50 +0100,
Gaosheng Cui <cuigaosheng1@huawei.com> 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 <cuigaosheng1@huawei.com>
> ---
>  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.


  reply	other threads:[~2024-10-24  9:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-24  8:33 [PATCH -next] KVM: arm64: Fix possible null-ptr-deref in idregs_debug_show Gaosheng Cui
2024-10-24  9:29 ` Marc Zyngier [this message]
2024-10-29  3:58   ` cuigaosheng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86wmhx3l34.wl-maz@kernel.org \
    --to=maz@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=cuigaosheng1@huawei.com \
    --cc=joey.gouly@arm.com \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=oliver.upton@linux.dev \
    --cc=sebott@redhat.com \
    --cc=suzuki.poulose@arm.com \
    --cc=wangweiyang2@huawei.com \
    --cc=will@kernel.org \
    --cc=yuzenghui@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).