linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: superlibj8301@gmail.com (Richard Lee)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCHv2] ARM: ioremap: Fix static vm area boundary checking.
Date: Fri, 16 May 2014 15:45:36 +0800	[thread overview]
Message-ID: <CAHPCO9FuuRY1eyKpXr4OpHpeS8ZW4BroMOkUPYEhLNu4xdDcSA@mail.gmail.com> (raw)
In-Reply-To: <308e7a7eeaf04ae8a90b8db39697009b@BY2PR03MB505.namprd03.prod.outlook.com>

On Fri, May 16, 2014 at 3:17 PM, Li.Xiubo at freescale.com
<Li.Xiubo@freescale.com> wrote:
>> Subject: Re: [PATCHv2] ARM: ioremap: Fix static vm area boundary checking.
>>
>> On Fri, May 16, 2014 at 1:28 AM, Nicolas Pitre <nicolas.pitre@linaro.org>
>> wrote:
>> > On Thu, 15 May 2014, Richard Lee wrote:
>> >
>> >> Static vm area boundary check:
>> >>
>> >>       paddr1 --->|       |
>> >>                  |       |
>> >>                  |-------| <-\--- svm->vm->addr(is page aligned)
>> >>       paddr2 --->|       |    |
>> >>                  |     --| <--|-- svm->vm->phys_addr
>> >>                  |       |    |
>> >>       paddr3 --->|       |    |
>> >>                  |       |    |
>> >>                  |-------| <--|-- next page boundary
>> >>                  |       |    |
>> >>       paddr4 --->|       |    | <----- svm->vm->size(including guard page)
>> >>                  |       |    |
>> >>                  |       |    |
>> >> max paddr_end -->|-------| <--|-- svm->vm's phys_addr_end
>> >>                  | ///// |    |
>> >>       paddr5 --->| guard |    |
>> >>                  | page  |    |
>> >>                  | ///// |    |
>> >>                   -------  <-/--- svm->vm->addr + svm->vm_size
>> >>
>> >> <1> If the paddr == paddr1, then continue;
>> >> <2> If the paddr == paddr2~paddr4 and paddr_end > phys_addr_end,
>> >>     then continue;
>> >> <3> if the paddr >= paddr5 then continue;
>> >>
>> >> Signed-off-by: Richard Lee <superlibj8301@gmail.com>
>> >
>> > instead of doing this repeatedly, why not simply ensure the recorded
>> > static vm information is already page aligned in the first place?
>> >
>>
>> Sorry, I'm not very sure what vm information you meant here.
>>
>> And the 'svm->vm->addr' and 'svm->vm->size' are all page aligned
>> already, but we cannot make sure that the 'paddr' and
>> 'svm->vm->phys_addr' are page aligned.
>>
>
> The paddr and svm->vm->phys_addr are all already pfn aligned here.
> What we should fix about is the boundary of them.
>

Sorry, I'm a fresher and I'll be out of the opensource mail list for
changing jobs and then I have no chance to do this.
Could you help me fix this issue please ?

And thanks for your help about how to appoarch the opensource list.
Thanks very much,

   Richard,

>> >>
>> >>
>> >> Change in V2:
>> >>  - PAGE_SIZE --> PAGE_MASK
>> >>  - remove the 'size' page size align operation.
>> >>
>> >>
>> >>
>> >>
>> >>
>> >>
>> >>  arch/arm/mm/ioremap.c | 40 ++++++++++++++++++++++++++++++++++++++--
>> >>  1 file changed, 38 insertions(+), 2 deletions(-)
>> >>
>> >> diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
>> >> index be69333..f235ab7 100644
>> >> --- a/arch/arm/mm/ioremap.c
>> >> +++ b/arch/arm/mm/ioremap.c
>> >> @@ -47,16 +47,52 @@ static struct static_vm
>> *find_static_vm_paddr(phys_addr_t paddr,
>> >>  {
>> >>       struct static_vm *svm;
>> >>       struct vm_struct *vm;
>> >> +     size_t offset;
>> >> +
>> >> +     offset = paddr & ~PAGE_MASK;
>> >>
>> >>       list_for_each_entry(svm, &static_vmlist, list) {
>> >> +             phys_addr_t paddr_end, phys_addr_end;
>> >> +             size_t vmoff;
>> >> +
>> >>               vm = &svm->vm;
>> >>               if (!(vm->flags & VM_ARM_STATIC_MAPPING))
>> >>                       continue;
>> >>               if ((vm->flags & VM_ARM_MTYPE_MASK) != VM_ARM_MTYPE(mtype))
>> >>                       continue;
>> >>
>> >> -             if (vm->phys_addr > paddr ||
>> >> -                     paddr + size - 1 > vm->phys_addr + vm->size - 1)
>> >> +             /* Static vm area boundary check:
>> >> +              *
>> >> +              *       paddr1 --->|       |
>> >> +              *                  |       |
>> >> +              *                  |-------| <-\--- svm->vm->addr(page
>> aligned)
>> >> +              *       paddr2 --->|       |    |
>> >> +              *                  |     --| <--|-- svm->vm->phys_addr
>> >> +              *                  |       |    |
>> >> +              *       paddr3 --->|       |    |
>> >> +              *                  |       |    |
>> >> +              *                  |-------| <--|-- next page boundary
>> >> +              *                  |       |    |
>> >> +              *       paddr4 --->|       |    | <----- svm->vm->size,
>> >> +              *                  |       |    |         including guard
>> page
>> >> +              *                  |       |    |
>> >> +              * max paddr_end -->|-------| <--|-- svm->vm's phys_addr_end
>> >> +              *                  | ///// |    |
>> >> +              *       paddr5 --->| guard |    |
>> >> +              *                  | page  |    |
>> >> +              *                  | ///// |    |
>> >> +              *                   -------  <-/-- svm->vm->addr + svm-
>> >vm_size
>> >> +              *
>> >> +              * <1> If paddr == paddr1, then continue;
>> >> +              * <2> If paddr == paddr2~paddr4 and paddr_end >
>> phys_addr_end,
>> >> +              *     then continue;
>> >> +              * <3> if paddr >= paddr5 then continue;
>> >> +              */
>> >> +             vmoff = vm->phys_addr & ~PAGE_MASK;
>> >> +             phys_addr_end = vm->phys_addr + vm->size - PAGE_SIZE - vmoff;
>> >> +             paddr_end = paddr + size - offset;
>> >> +             if (__phys_to_pfn(vm->phys_addr) > __phys_to_pfn(paddr) ||
>> >> +                     paddr_end - 1 > phys_addr_end - 1)
>> >>                       continue;
>> >>
>> >>               return svm;
>> >> --
>> >> 1.8.4
>> >>

  reply	other threads:[~2014-05-16  7:45 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-15  8:29 [PATCHv2] ARM: ioremap: Fix static vm area boundary checking Richard Lee
2014-05-15 17:28 ` Nicolas Pitre
2014-05-16  1:45   ` Richard Lee
2014-05-16  7:17     ` Li.Xiubo at freescale.com
2014-05-16  7:45       ` Richard Lee [this message]
2014-05-16 13:16     ` Nicolas Pitre

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=CAHPCO9FuuRY1eyKpXr4OpHpeS8ZW4BroMOkUPYEhLNu4xdDcSA@mail.gmail.com \
    --to=superlibj8301@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).