mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Wei Liu <wei.liu@kernel.org>
To: Nuno Das Neves <nunodasneves@linux.microsoft.com>
Cc: mhklinux@outlook.com, haiyangz@microsoft.com, wei.liu@kernel.org,
	decui@microsoft.com, kys@microsoft.com,
	linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org
Subject: Re: [PATCH 1/1] Drivers: hv: Fix bad ref to hv_synic_eventring_tail when CPU goes offline
Date: Fri, 25 Apr 2025 06:25:57 +0000	[thread overview]
Message-ID: <aAsq9RGFUbQUfQnl@liuwe-devbox-ubuntu-v2.tail21d00.ts.net> (raw)
In-Reply-To: <495d5444-b82e-4ec7-9095-d34f0ac8d40c@linux.microsoft.com>

On Wed, Apr 23, 2025 at 10:50:27AM -0700, Nuno Das Neves wrote:
> On 4/21/2025 9:31 AM, mhkelley58@gmail.com wrote:
> > From: Michael Kelley <mhklinux@outlook.com>
> > 
> > When a CPU goes offline, hv_common_cpu_die() frees the
> > hv_synic_eventring_tail memory for the CPU. But in a normal VM (i.e., not
> > running in the root partition) the per-CPU memory has not been allocated,
> > resulting in a bad memory reference and oops when computing the argument
> > to kfree().
> > 
> > Fix this by freeing the memory only when running in the root partition.
> > 
> > Fixes: 04df7ac39943 ("Drivers: hv: Introduce per-cpu event ring tail")
> > Signed-off-by: Michael Kelley <mhklinux@outlook.com>
> > ---
> >  drivers/hv/hv_common.c | 8 +++++---
> >  1 file changed, 5 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/hv/hv_common.c b/drivers/hv/hv_common.c
> > index b3b11be11650..8967010db86a 100644
> > --- a/drivers/hv/hv_common.c
> > +++ b/drivers/hv/hv_common.c
> > @@ -566,9 +566,11 @@ int hv_common_cpu_die(unsigned int cpu)
> >  	 * originally allocated memory is reused in hv_common_cpu_init().
> >  	 */
> >  
> > -	synic_eventring_tail = this_cpu_ptr(hv_synic_eventring_tail);
> > -	kfree(*synic_eventring_tail);
> > -	*synic_eventring_tail = NULL;
> > +	if (hv_root_partition()) {
> > +		synic_eventring_tail = this_cpu_ptr(hv_synic_eventring_tail);
> > +		kfree(*synic_eventring_tail);
> > +		*synic_eventring_tail = NULL;
> > +	}
> >  
> >  	return 0;
> >  }
> 
> Reviewed-by: Nuno Das Neves <nunodasneves@linux.microsoft.com>

Applied to hyperv-fixes.

      reply	other threads:[~2025-04-25  6:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-21 16:31 mhkelley58
2025-04-23 17:50 ` Nuno Das Neves
2025-04-25  6:25   ` Wei Liu [this message]

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=aAsq9RGFUbQUfQnl@liuwe-devbox-ubuntu-v2.tail21d00.ts.net \
    --to=wei.liu@kernel.org \
    --cc=decui@microsoft.com \
    --cc=haiyangz@microsoft.com \
    --cc=kys@microsoft.com \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhklinux@outlook.com \
    --cc=nunodasneves@linux.microsoft.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

all inboxes | Powered by JetHome®