On Thu, Mar 04, 2021 at 09:12:31AM +0100, David Hildenbrand wrote:
> On 04.03.21 04:31, Anshuman Khandual wrote:
> > On 3/4/21 2:54 AM, Will Deacon wrote:
> > > On Wed, Mar 03, 2021 at 07:04:33PM +0000, Catalin Marinas wrote:
> > > > On Thu, Feb 11, 2021 at 01:35:56PM +0100, David Hildenbrand wrote:
> > > > > On 11.02.21 13:10, Anshuman Khandual wrote:
> > > > > > On 2/11/21 5:23 PM, Will Deacon wrote:
> > > > > > > ... and dropped. These patches appear to be responsible for a boot
> > > > > > > regression reported by CKI:
> > > > > > 
> > > > > > Ahh, boot regression ? These patches only change the behaviour
> > > > > > for non boot memory only.
> > > > > > 
> > > > > > > https://lore.kernel.org/r/cki.8d1cb60fec.k6njmef...@redhat.com
> > > > > > 
> > > > > > Will look into the logs and see if there is something pointing to
> > > > > > the problem.
> > > > > 
> > > > > It's strange. One thing I can imagine is a mis-detection of early 
> > > > > sections.
> > > > > However, I don't see that happening:
> > > > > 
> > > > > In sparse_init_nid(), we:
> > > > > 1. Initialize the memmap
> > > > > 2. Set SECTION_IS_EARLY | SECTION_HAS_MEM_MAP via
> > > > >     sparse_init_one_section()
> > > > > 
> > > > > Only hotplugged sections (DIMMs, dax/kmem) set SECTION_HAS_MEM_MAP 
> > > > > without
> > > > > SECTION_IS_EARLY - which is correct, because these are not early.
> > > > > 
> > > > > So once we know that we have valid_section() -- SECTION_HAS_MEM_MAP 
> > > > > is set
> > > > > -- early_section() should be correct.
> > > > > 
> > > > > Even if someone would be doing a pfn_valid() after
> > > > > memblocks_present()->memory_present() but before
> > > > > sparse_init_nid(), we should be fine (!valid_section() -> return 0).
> > > > 
> > > > I couldn't figure out how this could fail with Anshuman's patches.
> > > > Will's suspicion is that some invalid/null pointer gets dereferenced
> > > > before being initialised but the only case I see is somewhere in
> > > > pfn_section_valid() (ms->usage) if valid_section() && !early_section().
> > > > 
> > > > Assuming that we do get a valid_section(ms) && !early_section(ms), is
> > > > there a case where ms->usage is not initialised? I guess races with
> > > > section_deactivate() are not possible this early.
> > > > 
> > > > Another situation could be that pfn_valid() returns true when no memory
> > > > is mapped for that pfn.
> > > 
> > > The case I wondered about was __pfn_to_section() with a bogus pfn, since
> > > with patch 2/2 we call that *before* checking that pfn_to_section_nr() is
> > > sane.
> > 
> > Right, that is problematic. __pfn_to_section() should not be called without
> > first validating pfn_to_section_nr(), as it could cause out-of-bound access
> > on mem_section buffer. Will fix that order but as there is no test scenario
> > which is definitive for this reported regression, how should we ensure that
> > it fixes the problem ?
> 
> Oh, right, I missed that in patch #2. (and when comparing to generic
> pfn_valid()).
> 
> I thought bisecting pointed at patch #1, that's why I didn't even have
> another look at patch #2. Makes sense.

I don't think we ever bisected it beyond these two patches, so it could
be either of them. Anshuman -- please work with Veronika on this, as she
has access to the problematic machine and was really helpful in debugging
this last time.

Will

Reply via email to