On Wed, Jun 13, 2012 at 03:29:36PM -0400, Rik van Riel wrote:ARM& MIPS seem to share essentially the same page colouring code, with
these two bugs:
COLOUR_ALIGN_DOWN can use the pgoff % shm_align_mask either positively
or negatively, depending on the address initially found by
get_unmapped_area
static inline unsigned long COLOUR_ALIGN_DOWN(unsigned long addr,
unsigned long pgoff)
{
unsigned long base = addr& ~shm_align_mask;
unsigned long off = (pgoff<< PAGE_SHIFT)& shm_align_mask;
if (base + off<= addr)
return base + off;
return base - off;
}
The fix would be to return an address that is a whole shm_align_mask
lower: (((base - shm_align_mask)& ~shm_align_mask) + off
'addr' in this case is already adjusted by callers of COLOUR_ALIGN_DOWN(), so
this shouldn't be an issue, unless I'm missing something?
This fails to take into account that the same file might be mappedIf that combination is possible then defaulting to colour alignment seems
MAP_SHARED from some programs, and MAP_PRIVATE from another. The
fix could be a simple as always enforcing colour alignment when we
are mmapping a file (filp is non-zero).
reasonable. Whether that combination is reasonable or not is another matter.