[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241121124113.66166-1-aha310510@gmail.com>
Date: Thu, 21 Nov 2024 21:41:13 +0900
From: Jeongjun Park <aha310510@...il.com>
To: akpm@...ux-foundation.org
Cc: dave@...olabs.net,
willy@...radead.org,
Liam.Howlett@...cle.com,
linux-mm@...ck.org,
linux-kernel@...r.kernel.org,
stable@...r.kernel.org,
Jeongjun Park <aha310510@...il.com>
Subject: [PATCH] mm/huge_memory: Fix to make vma_adjust_trans_huge() use find_vma() correctly
vma_adjust_trans_huge() uses find_vma() to get the VMA, but find_vma() uses
the returned pointer without any verification, even though it may return NULL.
In this case, NULL pointer dereference may occur, so to prevent this,
vma_adjust_trans_huge() should be fix to verify the return value of find_vma().
Cc: <stable@...r.kernel.org>
Fixes: 685405020b9f ("mm/khugepaged: stop using vma linked list")
Signed-off-by: Jeongjun Park <aha310510@...il.com>
---
mm/huge_memory.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 5734d5d5060f..db55b8abae2e 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -2941,9 +2941,12 @@ void vma_adjust_trans_huge(struct vm_area_struct *vma,
*/
if (adjust_next > 0) {
struct vm_area_struct *next = find_vma(vma->vm_mm, vma->vm_end);
- unsigned long nstart = next->vm_start;
- nstart += adjust_next;
- split_huge_pmd_if_needed(next, nstart);
+
+ if (likely(next)) {
+ unsigned long nstart = next->vm_start;
+ nstart += adjust_next;
+ split_huge_pmd_if_needed(next, nstart);
+ }
}
}
--
Powered by blists - more mailing lists