In the Linux kernel, the following vulnerability has been resolved:
nitroenclaves: Use getuserpagesunlocked() call to handle mmap assert
After commit 5b78ed24e8ec ("mm/pagemap: add mmapassertlocked() annotations to findvma*()"), the call to getuser_pages() will trigger the mmap assert.
static inline void mmapassertlocked(struct mmstruct *mm) { lockdepassertheld(&mm->mmaplock); VMBUGONMM(!rwsemislocked(&mm->mmaplock), mm); }
[ 62.521410] kernel BUG at include/linux/mmaplock.h:156! ........................................................... [ 62.538938] RIP: 0010:findvma+0x32/0x80 ........................................................... [ 62.605889] Call Trace: [ 62.608502] <TASK> [ 62.610956] ? locktimerbase+0x61/0x80 [ 62.614106] findextendvma+0x19/0x80 [ 62.617195] _getuserpages+0x9b/0x6a0 [ 62.620356] _guplongtermlocked+0x42d/0x450 [ 62.623721] ? finishwait+0x41/0x80 [ 62.626748] ? _kmalloc+0x178/0x2f0 [ 62.629768] nesetusermemoryregionioctl.isra.0+0x225/0x6a0 [nitroenclaves] [ 62.635776] neenclaveioctl+0x1cf/0x6d7 [nitroenclaves] [ 62.639541] _x64sysioctl+0x82/0xb0 [ 62.642620] dosyscall64+0x3b/0x90 [ 62.645642] entrySYSCALL64afterhwframe+0x44/0xae
Use getuserpagesunlocked() when setting the enclave memory regions. That's a similar pattern as mmapreadlock() used together with getuser_pages().