Linux CXL
 help / color / mirror / Atom feed
From: Alison Schofield <alison.schofield@intel.com>
To: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Davidlohr Bueso <dave@stgolabs.net>,
	Dave Jiang <dave.jiang@intel.com>,
	Vishal Verma <vishal.l.verma@intel.com>,
	Ira Weiny <ira.weiny@intel.com>,
	Dan Williams <dan.j.williams@intel.com>,
	linux-cxl@vger.kernel.org
Subject: Re: [PATCH v2] cxl/region: Fix null pointer dereference in region lookup
Date: Wed, 5 Jun 2024 08:31:37 -0700	[thread overview]
Message-ID: <ZmCE2Qn0h2FZwl6+@aschofie-mobl2> (raw)
In-Reply-To: <20240605131835.00000048@Huawei.com>

On Wed, Jun 05, 2024 at 01:18:35PM +0100, Jonathan Cameron wrote:
> On Tue,  4 Jun 2024 19:19:28 -0700
> alison.schofield@intel.com wrote:
> 
> > From: Alison Schofield <alison.schofield@intel.com>
> > 
> > cxl_dpa_to_region() looks up a region based on a memdev and DPA.
> > It wrongly assumes an endpoint found mapping the DPA is also of
> > a fully assembled region. When not true it leads to a null pointer
> > dereference looking up the region name.
> > 
> > BUG: kernel NULL pointer dereference, address: 0000000000000050
> > RIP: 0010:__cxl_dpa_to_region+0x8c/0xc0 [cxl_core]
> > Call Trace:
> >  <TASK>
> >  ? show_regs+0x5f/0x70
> >  ? __die+0x1f/0x70
> >  ? page_fault_oops+0x14b/0x430
> >  ? __cxl_dpa_to_region+0x8c/0xc0 [cxl_core]
> >  ? search_exception_tables+0x5b/0x60
> >  ? fixup_exception+0x22/0x300
> >  ? kernelmode_fixup_or_oops.constprop.0+0x5a/0x70
> >  ? __bad_area_nosemaphore+0x166/0x230
> >  ? up_read+0x43/0x90
> >  ? bad_area_nosemaphore+0x11/0x20
> >  ? do_user_addr_fault+0x2cb/0x6b0
> >  ? find_held_lock+0x31/0x90
> >  ? exc_page_fault+0x6e/0x220
> >  ? asm_exc_page_fault+0x27/0x30
> >  ? __cxl_dpa_to_region+0x8c/0xc0 [cxl_core]
> >  ? __cxl_dpa_to_region+0x35/0xc0 [cxl_core]
> >  ? __pfx___cxl_dpa_to_region+0x10/0x10 [cxl_core]
> >  device_for_each_child+0x4a/0x70
> >  cxl_dpa_to_region+0x61/0x70 [cxl_core]
> >  cxl_inject_poison+0xde/0x1e0 [cxl_core]
> >  cxl_debugfs_poison_inject+0x9/0x10 [cxl_mem]
> > 
> > This appears during testing of region lookup after a failure to
> > assemble a BIOS defined region or if the lookup raced with the
> > assembly of the BIOS defined region.
> > 
> > Failure to clean up BIOS defined regions that fail assembly is an
> > issue in itself and a fix to that problem will alleviate some of
> > the impact. It will not alleviate the race condition so let's harden
> > this path.
> > 
> > The behavior change is that the kernel oops due to a null pointer
> > dereference is replaced with a dev_dbg() message noting that an
> > endpoint was mapped.
> > 
> > Additional comments are added so that future users of this function
> > can more clearly understand what it provides.
> > 
> > Fixes: 0a105ab28a4d ("cxl/memdev: Warn of poison inject or clear to a mapped region")
> > Signed-off-by: Alison Schofield <alison.schofield@intel.com>
> > Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> This simplified version works for me so keep the tag... However given the spirit of
> the patch changed rather a lot would have been reasonable to drop the RB.

Understand, sorry for the oversight.
Thanks for the second review too.
-- Alison


      reply	other threads:[~2024-06-05 15:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-05  2:19 [PATCH v2] cxl/region: Fix null pointer dereference in region lookup alison.schofield
2024-06-05 12:18 ` Jonathan Cameron
2024-06-05 15:31   ` Alison Schofield [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=ZmCE2Qn0h2FZwl6+@aschofie-mobl2 \
    --to=alison.schofield@intel.com \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=dan.j.williams@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=dave@stgolabs.net \
    --cc=ira.weiny@intel.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=vishal.l.verma@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