• Jiri Kosina's avatar
    mm/mincore.c: make mincore() more conservative · 134fca90
    Jiri Kosina authored
    The semantics of what mincore() considers to be resident is not
    completely clear, but Linux has always (since 2.3.52, which is when
    mincore() was initially done) treated it as "page is available in page
    cache".
    
    That's potentially a problem, as that [in]directly exposes
    meta-information about pagecache / memory mapping state even about
    memory not strictly belonging to the process executing the syscall,
    opening possibilities for sidechannel attacks.
    
    Change the semantics of mincore() so that it only reveals pagecache
    information for non-anonymous mappings that belog to files that the
    calling process could (if it tried to) successfully open for writing;
    otherwise we'd be including shared non-exclusive mappings, which
    
     - is the sidechannel
    
     - is not the usecase for mincore(), as that's primarily used for data,
       not (shared) text
    
    [jkosina@suse.cz: v2]
      Link: http://lkml.kernel.org/r/20190312141708.6652-2-vbabka@suse.cz
    [mhocko@suse.com: restructure can_do_m...
    134fca90
mincore.c 7.32 KB