[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aAsq9RGFUbQUfQnl@liuwe-devbox-ubuntu-v2.tail21d00.ts.net>
Date: Fri, 25 Apr 2025 06:25:57 +0000
From: Wei Liu <wei.liu@...nel.org>
To: Nuno Das Neves <nunodasneves@...ux.microsoft.com>
Cc: mhklinux@...look.com, haiyangz@...rosoft.com, wei.liu@...nel.org,
decui@...rosoft.com, kys@...rosoft.com,
linux-kernel@...r.kernel.org, linux-hyperv@...r.kernel.org
Subject: Re: [PATCH 1/1] Drivers: hv: Fix bad ref to hv_synic_eventring_tail
when CPU goes offline
On Wed, Apr 23, 2025 at 10:50:27AM -0700, Nuno Das Neves wrote:
> On 4/21/2025 9:31 AM, mhkelley58@...il.com wrote:
> > From: Michael Kelley <mhklinux@...look.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@...look.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@...ux.microsoft.com>
Applied to hyperv-fixes.
Powered by blists - more mailing lists