* [PATCH] rmap: validate pointer in anon_vma_clone
@ 2014-05-07 2:32 Leon Ma
2014-05-07 2:58 ` Ma, Xindong
2014-05-07 4:28 ` Jianyu Zhan
0 siblings, 2 replies; 3+ messages in thread
From: Leon Ma @ 2014-05-07 2:32 UTC (permalink / raw)
To: akpm, iamjoonsoo.kim, n-horiguchi, kirill.shutemov, gorcunov,
linux-mm, linux-kernel
Cc: Leon Ma
If memory allocation failed in first loop, root will be NULL and
will lead to kernel panic.
Signed-off-by: Leon Ma <xindong.ma@intel.com>
---
mm/rmap.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/mm/rmap.c b/mm/rmap.c
index 9c3e773..6e53aed 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -246,8 +246,10 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
avc = anon_vma_chain_alloc(GFP_NOWAIT | __GFP_NOWARN);
if (unlikely(!avc)) {
- unlock_anon_vma_root(root);
- root = NULL;
+ if (!root) {
+ unlock_anon_vma_root(root);
+ root = NULL;
+ }
avc = anon_vma_chain_alloc(GFP_KERNEL);
if (!avc)
goto enomem_failure;
--
1.7.9.5
--
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>
^ permalink raw reply [flat|nested] 3+ messages in thread* RE: [PATCH] rmap: validate pointer in anon_vma_clone
2014-05-07 2:32 [PATCH] rmap: validate pointer in anon_vma_clone Leon Ma
@ 2014-05-07 2:58 ` Ma, Xindong
2014-05-07 4:28 ` Jianyu Zhan
1 sibling, 0 replies; 3+ messages in thread
From: Ma, Xindong @ 2014-05-07 2:58 UTC (permalink / raw)
To: akpm, iamjoonsoo.kim, n-horiguchi, kirill.shutemov, gorcunov,
linux-mm, linux-kernel
Sorry, my fault. It's already validated in unlock_anon_vma_root().
BR
Leon
-----Original Message-----
From: Ma, Xindong
Sent: Wednesday, May 07, 2014 10:32 AM
To: akpm@linux-foundation.org; iamjoonsoo.kim@lge.com; n-horiguchi@ah.jp.nec.com; kirill.shutemov@linux.intel.com; gorcunov@gmail.com; linux-mm@kvack.org; linux-kernel@vger.kernel.org
Cc: Ma, Xindong
Subject: [PATCH] rmap: validate pointer in anon_vma_clone
If memory allocation failed in first loop, root will be NULL and will lead to kernel panic.
Signed-off-by: Leon Ma <xindong.ma@intel.com>
---
mm/rmap.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/mm/rmap.c b/mm/rmap.c
index 9c3e773..6e53aed 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -246,8 +246,10 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
avc = anon_vma_chain_alloc(GFP_NOWAIT | __GFP_NOWARN);
if (unlikely(!avc)) {
- unlock_anon_vma_root(root);
- root = NULL;
+ if (!root) {
+ unlock_anon_vma_root(root);
+ root = NULL;
+ }
avc = anon_vma_chain_alloc(GFP_KERNEL);
if (!avc)
goto enomem_failure;
--
1.7.9.5
--
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>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] rmap: validate pointer in anon_vma_clone
2014-05-07 2:32 [PATCH] rmap: validate pointer in anon_vma_clone Leon Ma
2014-05-07 2:58 ` Ma, Xindong
@ 2014-05-07 4:28 ` Jianyu Zhan
1 sibling, 0 replies; 3+ messages in thread
From: Jianyu Zhan @ 2014-05-07 4:28 UTC (permalink / raw)
To: Leon Ma
Cc: Andrew Morton, iamjoonsoo.kim, Naoya Horiguchi, kirill.shutemov,
gorcunov, linux-mm, LKML
On Wed, May 7, 2014 at 10:32 AM, Leon Ma <xindong.ma@intel.com> wrote:
> If memory allocation failed in first loop, root will be NULL and
> will lead to kernel panic.
Hello, Leon,
I am afraid not. unlock_anon_vma_root() has a sanity check NULLness of root,
so it is impossible to panic for a dangling root pointer.
Thanks,
Jianyu Zhan
--
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>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-05-07 4:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-07 2:32 [PATCH] rmap: validate pointer in anon_vma_clone Leon Ma
2014-05-07 2:58 ` Ma, Xindong
2014-05-07 4:28 ` Jianyu Zhan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox