Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Daniel Paziyski" <danielpaziyski@gmail.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH] KVM: x86: Fix null pointer dereference in trace_kvm_inj_exception
Date: Fri, 10 Jul 2026 13:53:12 +0000	[thread overview]
Message-ID: <20260710135312.AD74F1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260710134055.16432-1-danielpaziyski@gmail.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] The proposed fix is based on a false premise. The commit message incorrectly claims the original code causes a kernel NULL pointer dereference, but the original code safely handled the empty struct.
- [Low] Removing the variadic argument from the `__print_symbolic` macro causes a syntax error during macro expansion, which unconditionally breaks the kernel build.
--

--- Patch [1]: [PATCH] KVM: x86: Fix null pointer dereference in trace_kvm_inj_exception ---
commit ed0cb139106d0eebc245569ae242561a63dc2bb7
Author: Daniel Paziyski <danielpaziyski@gmail.com>

KVM: x86: Fix null pointer dereference in trace_kvm_inj_exception

This patch modifies the kvm_inj_exception tracepoint to remove an empty
struct passed to __print_symbolic for formatting the exception error code.

> An empty struct is being passed, which makes the
> kernel derefence a NULL pointer when the error code is 0. Remove this
> stray struct in the invocation of __print_symbolic.

[Severity: Medium]
Is this description of a null pointer dereference accurate?

Looking at how __print_symbolic expands, the empty struct { } safely
initializes the first element's name pointer to NULL. When
trace_print_symbols_seq() is called, it handles this gracefully:

kernel/trace/trace_output.c:trace_print_symbols_seq() {
    ...
    for (i = 0;  symbol_array[i].name; i++) {
    ...
}

Since the name field is NULL for the first element, the loop is bypassed
entirely and the function safely falls back to printing the error code as a
hex string without dereferencing a NULL pointer.

> diff --git a/arch/x86/kvm/trace.h b/arch/x86/kvm/trace.h
> --- a/arch/x86/kvm/trace.h
> +++ b/arch/x86/kvm/trace.h
> @@ -490,7 +490,7 @@ TRACE_EVENT(kvm_inj_exception,
>  	TP_printk("%s%s%s%s%s",
>  		  __print_symbolic(__entry->exception, kvm_trace_sym_exc),
>  		  !__entry->has_error ? "" : " (",
> -		  !__entry->has_error ? "" : __print_symbolic(__entry->error_code, { }),
> +		  !__entry->has_error ? "" : __print_symbolic(__entry->error_code),

[Severity: Low]
Will this change break the kernel build?

The __print_symbolic macro expects a symbol_array as the second argument. By
omitting it, the preprocessor will expand the macro to something similar to:

static const struct trace_print_flags symbols[] = { , { -1, NULL }};

Does this result in a syntax error during macro expansion due to the missing
expression before the comma?

>  		  !__entry->has_error ? "" : ")",
>  		  __entry->reinjected ? " [reinjected]" : "")
>  );

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260710134055.16432-1-danielpaziyski@gmail.com?part=1

  reply	other threads:[~2026-07-10 13:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-10 13:40 [PATCH] KVM: x86: Fix null pointer dereference in trace_kvm_inj_exception Daniel Paziyski
2026-07-10 13:53 ` sashiko-bot [this message]
2026-07-10 18:35   ` Sean Christopherson
2026-07-10 18:42 ` Sean Christopherson
2026-07-10 19:34   ` Daniel Paziyski

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=20260710135312.AD74F1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=danielpaziyski@gmail.com \
    --cc=kvm@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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