libunwind-devel
[Top][All Lists]
Advanced

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

Re: [Libunwind-devel] mincore_validate fails sometimes


From: Dave Watson
Subject: Re: [Libunwind-devel] mincore_validate fails sometimes
Date: Mon, 5 Feb 2018 08:18:21 -0800
User-agent: Mutt/1.6.0 (2016-04-01)

On 02/05/18 08:59 AM, Daniel Vassdal wrote:
> Sorry for the late reply.
> 
> > Yes, it's meant to check that the pages are mapped in.  Do you think the 
> > above code is incorrect?
> Yes, I think that it is incorrect, as the mincore() result array doesn't 
> indicate if the page is mapped or not, the return code does.
> 
> ...
> 
> > I think this means ENOMEM is returned only if *all* pages are unmapped, but 
> > the vector must be checked if only some of the pages are unmapped.
> This is wrong. If we consult the kernel source code, we see that for each 
> page do_mincore() is called.
> https://github.com/torvalds/linux/blob/master/mm/mincore.c#L251-L270
> 
> Here it is checked that the page is indeed mapped. If any page in the range 
> isn't, ENOMEM is returned.
> https://github.com/torvalds/linux/blob/master/mm/mincore.c#L189-L196
> 
> And thus, if the point is to check that the pages are mapped and valid, 
> checking only the return value of mincore() is sufficient.
> Checking the result array is wrong unless we really care if the memory is 
> currently in core or not.
> And even then it is dubious, as, according to the documentation, the result 
> may be stale even before the function has returned, unless the memory is 
> mlocked into place. And if we know it is, why are we checking?
> https://github.com/torvalds/linux/blob/master/mm/mincore.c#L209-L212

Indeed it does look like you are correct, and we should only check the
return value, not the array.  Have you verified this fixes your issue?
Would you like to send a patch?

Thanks!



reply via email to

[Prev in Thread] Current Thread [Next in Thread]