Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1384946 > unrolled thread
| Started by | Yongji Xie <xyjxie@linux.vnet.ibm.com> |
|---|---|
| First post | 2016-04-22 12:40 +0200 |
| Last post | 2016-04-24 05:50 +0200 |
| Articles | 3 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH] mm: Fix incorrect pfn passed to untrack_pfn in remap_pfn_range Yongji Xie <xyjxie@linux.vnet.ibm.com> - 2016-04-22 12:40 +0200
Re: [PATCH] mm: Fix incorrect pfn passed to untrack_pfn in remap_pfn_range Andrew Morton <akpm@linux-foundation.org> - 2016-04-22 20:40 +0200
Re: [PATCH] mm: Fix incorrect pfn passed to untrack_pfn in remap_pfn_range Yongji Xie <xyjxie@linux.vnet.ibm.com> - 2016-04-24 05:50 +0200
| From | Yongji Xie <xyjxie@linux.vnet.ibm.com> |
|---|---|
| Date | 2016-04-22 12:40 +0200 |
| Subject | [PATCH] mm: Fix incorrect pfn passed to untrack_pfn in remap_pfn_range |
| Message-ID | <rqGFc-vG-5@gated-at.bofh.it> |
We used generic hooks in remap_pfn_range to help archs to
track pfnmap regions. The code is something like:
int remap_pfn_range()
{
...
track_pfn_remap(vma, &prot, pfn, addr, PAGE_ALIGN(size));
...
pfn -= addr >> PAGE_SHIFT;
...
untrack_pfn(vma, pfn, PAGE_ALIGN(size));
...
}
Here we can easily find the pfn is changed but not recovered
before untrack_pfn() is called. That's incorrect.
Signed-off-by: Yongji Xie <xyjxie@linux.vnet.ibm.com>
---
mm/memory.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/mm/memory.c b/mm/memory.c
index 098f00d..cb9e0c4 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -1755,6 +1755,7 @@ int remap_pfn_range(struct vm_area_struct *vma, unsigned long addr,
break;
} while (pgd++, addr = next, addr != end);
+ pfn += (end - PAGE_ALIGN(size)) >> PAGE_SHIFT;
if (err)
untrack_pfn(vma, pfn, PAGE_ALIGN(size));
--
1.7.9.5
[toc] | [next] | [standalone]
| From | Andrew Morton <akpm@linux-foundation.org> |
|---|---|
| Date | 2016-04-22 20:40 +0200 |
| Subject | Re: [PATCH] mm: Fix incorrect pfn passed to untrack_pfn in remap_pfn_range |
| Message-ID | <rqO9I-6yL-5@gated-at.bofh.it> |
| In reply to | #1384946 |
On Fri, 22 Apr 2016 18:31:28 +0800 Yongji Xie <xyjxie@linux.vnet.ibm.com> wrote:
> We used generic hooks in remap_pfn_range to help archs to
> track pfnmap regions. The code is something like:
>
> int remap_pfn_range()
> {
> ...
> track_pfn_remap(vma, &prot, pfn, addr, PAGE_ALIGN(size));
> ...
> pfn -= addr >> PAGE_SHIFT;
> ...
> untrack_pfn(vma, pfn, PAGE_ALIGN(size));
> ...
> }
>
> Here we can easily find the pfn is changed but not recovered
> before untrack_pfn() is called. That's incorrect.
What are the runtime effects of this bug?
> --- a/mm/memory.c
> +++ b/mm/memory.c
> @@ -1755,6 +1755,7 @@ int remap_pfn_range(struct vm_area_struct *vma, unsigned long addr,
> break;
> } while (pgd++, addr = next, addr != end);
>
> + pfn += (end - PAGE_ALIGN(size)) >> PAGE_SHIFT;
> if (err)
> untrack_pfn(vma, pfn, PAGE_ALIGN(size));
I'm having trouble understanding this. Wouldn't it be better to simply
save the track_pfn_remap() call's `pfn' arg in a new local variable?
[toc] | [prev] | [next] | [standalone]
| From | Yongji Xie <xyjxie@linux.vnet.ibm.com> |
|---|---|
| Date | 2016-04-24 05:50 +0200 |
| Subject | Re: [PATCH] mm: Fix incorrect pfn passed to untrack_pfn in remap_pfn_range |
| Message-ID | <rrjdw-6ed-3@gated-at.bofh.it> |
| In reply to | #1385428 |
On 2016/4/23 2:38, Andrew Morton wrote:
> On Fri, 22 Apr 2016 18:31:28 +0800 Yongji Xie <xyjxie@linux.vnet.ibm.com> wrote:
>
>> We used generic hooks in remap_pfn_range to help archs to
>> track pfnmap regions. The code is something like:
>>
>> int remap_pfn_range()
>> {
>> ...
>> track_pfn_remap(vma, &prot, pfn, addr, PAGE_ALIGN(size));
>> ...
>> pfn -= addr >> PAGE_SHIFT;
>> ...
>> untrack_pfn(vma, pfn, PAGE_ALIGN(size));
>> ...
>> }
>>
>> Here we can easily find the pfn is changed but not recovered
>> before untrack_pfn() is called. That's incorrect.
> What are the runtime effects of this bug?
No, this is just a fix in theory:-) .
>> --- a/mm/memory.c
>> +++ b/mm/memory.c
>> @@ -1755,6 +1755,7 @@ int remap_pfn_range(struct vm_area_struct *vma, unsigned long addr,
>> break;
>> } while (pgd++, addr = next, addr != end);
>>
>> + pfn += (end - PAGE_ALIGN(size)) >> PAGE_SHIFT;
>> if (err)
>> untrack_pfn(vma, pfn, PAGE_ALIGN(size));
> I'm having trouble understanding this. Wouldn't it be better to simply
> save the track_pfn_remap() call's `pfn' arg in a new local variable?
>
Yes, it's a little difficult to understand this. I will send a v2 soon.
Thanks,
Yongji
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web