mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dave Hansen <dave.hansen@intel.com>
To: Yaohui Wang <yaohuiwang@linux.alibaba.com>, dave.hansen@linux.intel.com
Cc: luto@kernel.org, peterz@infradead.org,
	linux-kernel@vger.kernel.org, yaohuiwang@linux.alibaba-inc.com,
	luoben@linux.alibaba.com
Subject: Re: [PATCH] mm: fix pfn calculation mistake in __ioremap_check_ram
Date: Mon, 7 Jun 2021 06:55:39 -0700	[thread overview]
Message-ID: <b77d2374-56d5-4b97-1319-56e744b81303@intel.com> (raw)
In-Reply-To: <20210607091938.47960-1-yaohuiwang@linux.alibaba.com>

On 6/7/21 2:19 AM, Yaohui Wang wrote:
> According to the source code in function
> arch/x86/mm/ioremap.c:__ioremap_caller, after __ioremap_check_mem, if the
> mem range is IORES_MAP_SYSTEM_RAM, then __ioremap_caller should fail. But
> because of the pfn calculation problem, __ioremap_caller can success
> on IORES_MAP_SYSTEM_RAM region when the @size parameter is less than
> PAGE_SIZE. This may cause misuse of the ioremap function and raise the
> risk of performance issues. For example, ioremap(phys, PAGE_SIZE-1) may
> cause the direct memory mapping of @phys to be uncached, and iounmap won't
> revert this change. This patch fixes this issue.
> 
> In arch/x86/mm/ioremap.c:__ioremap_check_ram, start_pfn should wrap down
> the res->start address, and end_pfn should wrap up the res->end address.
> This makes the check more strict and should be more reasonable.

Was this found by inspection, or was there a real-world bug which this
patch addresses?

  reply	other threads:[~2021-06-07 13:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-07  9:19 Yaohui Wang
2021-06-07 13:55 ` Dave Hansen [this message]
2021-06-08  4:04   ` Yaohui Wang

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=b77d2374-56d5-4b97-1319-56e744b81303@intel.com \
    --to=dave.hansen@intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luoben@linux.alibaba.com \
    --cc=luto@kernel.org \
    --cc=peterz@infradead.org \
    --cc=yaohuiwang@linux.alibaba-inc.com \
    --cc=yaohuiwang@linux.alibaba.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®