linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@kernel.org>
To: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Dave Hansen <dave.hansen@intel.com>,
	Anton Altaparmakov <anton@tuxera.com>,
	Pavel Machek <pavel@ucw.cz>, Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	x86@kernel.org, "H . Peter Anvin" <hpa@zytor.com>,
	Chen Yu <yu.c.chen@intel.com>,
	Pawan Gupta <pawan.kumar.gupta@linux.intel.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	linux-mm@kvack.org,
	Matthieu Baerts <matthieu.baerts@tessares.net>,
	Mat Martineau <mathew.j.martineau@linux.intel.com>,
	"Rafael J . Wysocki" <rafael.j.wysocki@intel.com>,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH] x86/pm: Fix false positive kmemleak report in msr_build_context().
Date: Fri, 22 Mar 2024 10:58:06 +0100	[thread overview]
Message-ID: <Zf1WLscQHk9+w+Z+@gmail.com> (raw)
In-Reply-To: <CAJZ5v0hdA2PUc8cmJtCNxW-nzHdWV+pxnTEeVu_7YHsHZTmFLw@mail.gmail.com>


* Rafael J. Wysocki <rafael@kernel.org> wrote:

> On Thu, Mar 14, 2024 at 4:05 PM Dave Hansen <dave.hansen@intel.com> wrote:
> >
> > On 3/14/24 07:26, Anton Altaparmakov wrote:
> > >  /* image of the saved processor state */
> > >  struct saved_context {
> > > -     /*
> > > -      * On x86_32, all segment registers except gs are saved at kernel
> > > -      * entry in pt_regs.
> > > -      */
> > > -     u16 gs;
> > >       unsigned long cr0, cr2, cr3, cr4;
> > >       u64 misc_enable;
> > >       struct saved_msrs saved_msrs;
> > > @@ -27,6 +22,11 @@ struct saved_context {
> > >       unsigned long tr;
> > >       unsigned long safety;
> > >       unsigned long return_address;
> > > +     /*
> > > +      * On x86_32, all segment registers except gs are saved at kernel
> > > +      * entry in pt_regs.
> > > +      */
> > > +     u16 gs;
> > >       bool misc_enable_saved;
> > >  } __attribute__((packed));
> >
> > Isn't this just kinda poking at the symptoms?  This seems to be
> > basically the exact same bug as b0b592cf08, just with a different source
> > of unaligned structure members.
> >
> > There's nothing to keep folks from reintroducing these kinds of issues
> > and evidently no way to detect when they happen without lengthy reproducers.
> 
> This change is fine with me FWIW,

thx, I've added your:

    Acked-by: "Rafael J. Wysocki" <rafael@kernel.org>

> but I agree that making it for kmemleak reasons feels kind of misguided.

Yeah, so it's a workaround, but kmemleak is also a useful debugging 
facility that is finding memory leaks that static checkers are missing.

The fact that we don't have an easy way to prevent these problems from 
being introduced is I think properly counterbalanced by the facts that:

  1) Only kmemleak users are inconvenienced by the false positives.

  2) kmemleak users & maintainers have created the patch. There was no 
     pressure on us x86 maintainers other than to apply a root-cause 
     analyzed patch.

  2) Over a timespan of ~10 years only 2 such alignment problems were 
     introduced, and they were fixed by the kmemleak folks. I think that's 
     a fair price to pay for a useful facility.

Ie. I don't think there's any long-term maintenance burder concern.

So I've applied this workaround to x86/urgent, with a change to the title 
to make sure this isn't understood as a real bug in the PM code, but a 
workaround:

   37fb408c99af x86/pm: Work around false positive kmemleak report in msr_build_context()

... lemme know if you feel strongly about this. :-)

Thanks,

	Ingo


      reply	other threads:[~2024-03-22  9:58 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-14 14:26 Anton Altaparmakov
2024-03-14 15:05 ` Dave Hansen
2024-03-14 15:45   ` Anton Altaparmakov
2024-03-22 10:03     ` Ingo Molnar
2024-03-22 10:12       ` Anton Altaparmakov
2024-03-22 10:13       ` Anton Altaparmakov
2024-03-14 15:55   ` Rafael J. Wysocki
2024-03-22  9:58     ` Ingo Molnar [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=Zf1WLscQHk9+w+Z+@gmail.com \
    --to=mingo@kernel.org \
    --cc=anton@tuxera.com \
    --cc=bp@alien8.de \
    --cc=catalin.marinas@arm.com \
    --cc=dave.hansen@intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mathew.j.martineau@linux.intel.com \
    --cc=matthieu.baerts@tessares.net \
    --cc=mingo@redhat.com \
    --cc=pavel@ucw.cz \
    --cc=pawan.kumar.gupta@linux.intel.com \
    --cc=rafael.j.wysocki@intel.com \
    --cc=rafael@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    --cc=yu.c.chen@intel.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