rmap: validate pointer in anon_vma_clone
Subsystems (2)
PATCH 1/1 rmap: validate pointer in anon_vma_clone
If memory allocation failed in first loop, root will be NULL and will lead to kernel panic.
--- mm/rmap.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
mm/rmap.c +4 -2
@@ -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;
Signature · 1 line
1.7.9.5
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: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
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.
--- mm/rmap.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
mm/rmap.c +4 -2
@@ -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
Quoted 2 lines · Leon Ma
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 [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>