From: "H. Peter Anvin" <hpa@zytor.com>
To: Frantisek Hrbata <fhrbata@redhat.com>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
tglx@linutronix.de, mingo@redhat.com, x86@kernel.org,
oleg@redhat.com, kamaleshb@in.ibm.com, hechjie@cn.ibm.com,
akpm@linux-foundation.org, dave.hansen@intel.com
Subject: Re: [RESEND PATCH] x86: add phys addr validity check for /dev/mem mmap
Date: Wed, 02 Oct 2013 11:36:09 -0700 [thread overview]
Message-ID: <524C6799.9060800@zytor.com> (raw)
In-Reply-To: <20131002183155.GA2975@localhost.localdomain>
On 10/02/2013 11:31 AM, Frantisek Hrbata wrote:
> On Wed, Oct 02, 2013 at 10:46:35AM -0700, H. Peter Anvin wrote:
>> On 10/02/2013 09:05 AM, Frantisek Hrbata wrote:
>>> +
>>> +int valid_phys_addr_range(phys_addr_t addr, size_t count)
>>> +{
>>> + return addr + count <= __pa(high_memory);
>>> +}
>>> +
>>> +int valid_mmap_phys_addr_range(unsigned long pfn, size_t count)
>>> +{
>>> + resource_size_t addr = (pfn << PAGE_SHIFT) + count;
>>> + return phys_addr_valid(addr);
>>> +}
>>>
>>
>> The latter has overflow problems.
>
> Could you please specify what overflow problems do you mean?
Consider if pfn + count overflows and wraps around, or if (pfn <<
PAGE_SHIFT) pushes bits out to the left.
>> The former I realize matches the current /dev/mem, but it is still just
>> plain wrong in multiple ways.
>
> I guess that you are talking about /dev/mem implementation generelly, because
> this patch is exactly the same as the first one. All I'm trying to do here is to
> fix this simple problem, which was reported by a customer, using IMHO the least
> invasive way. Anyway is there any description what is wrong with /dev/mem
> implementation? Maybe I can try to take a look.
>
The bottom line is that read/write to /dev/mem should be able to access
the same memory that we can mmap(). Having two different tests is
ridiculous.
-hpa
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
WARNING: multiple messages have this Message-ID (diff)
From: "H. Peter Anvin" <hpa@zytor.com>
To: Frantisek Hrbata <fhrbata@redhat.com>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
tglx@linutronix.de, mingo@redhat.com, x86@kernel.org,
oleg@redhat.com, kamaleshb@in.ibm.com, hechjie@cn.ibm.com,
akpm@linux-foundation.org, dave.hansen@intel.com
Subject: Re: [RESEND PATCH] x86: add phys addr validity check for /dev/mem mmap
Date: Wed, 02 Oct 2013 11:36:09 -0700 [thread overview]
Message-ID: <524C6799.9060800@zytor.com> (raw)
In-Reply-To: <20131002183155.GA2975@localhost.localdomain>
On 10/02/2013 11:31 AM, Frantisek Hrbata wrote:
> On Wed, Oct 02, 2013 at 10:46:35AM -0700, H. Peter Anvin wrote:
>> On 10/02/2013 09:05 AM, Frantisek Hrbata wrote:
>>> +
>>> +int valid_phys_addr_range(phys_addr_t addr, size_t count)
>>> +{
>>> + return addr + count <= __pa(high_memory);
>>> +}
>>> +
>>> +int valid_mmap_phys_addr_range(unsigned long pfn, size_t count)
>>> +{
>>> + resource_size_t addr = (pfn << PAGE_SHIFT) + count;
>>> + return phys_addr_valid(addr);
>>> +}
>>>
>>
>> The latter has overflow problems.
>
> Could you please specify what overflow problems do you mean?
Consider if pfn + count overflows and wraps around, or if (pfn <<
PAGE_SHIFT) pushes bits out to the left.
>> The former I realize matches the current /dev/mem, but it is still just
>> plain wrong in multiple ways.
>
> I guess that you are talking about /dev/mem implementation generelly, because
> this patch is exactly the same as the first one. All I'm trying to do here is to
> fix this simple problem, which was reported by a customer, using IMHO the least
> invasive way. Anyway is there any description what is wrong with /dev/mem
> implementation? Maybe I can try to take a look.
>
The bottom line is that read/write to /dev/mem should be able to access
the same memory that we can mmap(). Having two different tests is
ridiculous.
-hpa
next prev parent reply other threads:[~2013-10-02 18:37 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-02 16:05 [RESEND PATCH] x86: add phys addr validity check for /dev/mem mmap Frantisek Hrbata
2013-10-02 16:05 ` Frantisek Hrbata
2013-10-02 17:46 ` H. Peter Anvin
2013-10-02 17:46 ` H. Peter Anvin
2013-10-02 18:31 ` Frantisek Hrbata
2013-10-02 18:31 ` Frantisek Hrbata
2013-10-02 18:36 ` H. Peter Anvin [this message]
2013-10-02 18:36 ` H. Peter Anvin
2013-10-02 18:48 ` Frantisek Hrbata
2013-10-02 18:48 ` Frantisek Hrbata
2013-10-02 18:54 ` H. Peter Anvin
2013-10-02 18:54 ` H. Peter Anvin
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=524C6799.9060800@zytor.com \
--to=hpa@zytor.com \
--cc=akpm@linux-foundation.org \
--cc=dave.hansen@intel.com \
--cc=fhrbata@redhat.com \
--cc=hechjie@cn.ibm.com \
--cc=kamaleshb@in.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mingo@redhat.com \
--cc=oleg@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.