Patch "mm: prevent derefencing NULL ptr in pfn_section_valid()" has been added to the 6.9-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    mm: prevent derefencing NULL ptr in pfn_section_valid()

to the 6.9-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     mm-prevent-derefencing-null-ptr-in-pfn_section_valid.patch
and it can be found in the queue-6.9 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 889b6d9cba2f1874b9975769fcb01aebb1450832
Author: Waiman Long <longman@xxxxxxxxxx>
Date:   Tue Jun 25 20:16:39 2024 -0400

    mm: prevent derefencing NULL ptr in pfn_section_valid()
    
    [ Upstream commit 82f0b6f041fad768c28b4ad05a683065412c226e ]
    
    Commit 5ec8e8ea8b77 ("mm/sparsemem: fix race in accessing
    memory_section->usage") changed pfn_section_valid() to add a READ_ONCE()
    call around "ms->usage" to fix a race with section_deactivate() where
    ms->usage can be cleared.  The READ_ONCE() call, by itself, is not enough
    to prevent NULL pointer dereference.  We need to check its value before
    dereferencing it.
    
    Link: https://lkml.kernel.org/r/20240626001639.1350646-1-longman@xxxxxxxxxx
    Fixes: 5ec8e8ea8b77 ("mm/sparsemem: fix race in accessing memory_section->usage")
    Signed-off-by: Waiman Long <longman@xxxxxxxxxx>
    Cc: Charan Teja Kalla <quic_charante@xxxxxxxxxxx>
    Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index a4f6f1fecc6f3..f8d89a021abc9 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -1976,8 +1976,9 @@ static inline int subsection_map_index(unsigned long pfn)
 static inline int pfn_section_valid(struct mem_section *ms, unsigned long pfn)
 {
 	int idx = subsection_map_index(pfn);
+	struct mem_section_usage *usage = READ_ONCE(ms->usage);
 
-	return test_bit(idx, READ_ONCE(ms->usage)->subsection_map);
+	return usage ? test_bit(idx, usage->subsection_map) : 0;
 }
 #else
 static inline int pfn_section_valid(struct mem_section *ms, unsigned long pfn)




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux