Skip to contentSkip to conversation

Add MCL_ONFAULT to mlockall calls

PATCH Applied Eric B Munson 2 participants 2 messages Jan 20, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add MCL_ONFAULT to mlockall calls

The new mlock2 system call was added, but it looks like the MCL_ONFAULT flag was missed. This is now a valid flag to pass to mlockall(), but it must be used in conjunction with either MCL_CURRENT or MCL_FUTURE (or both). Also rework the way that the flags value for mlockall() is caclulated. It is valid to pass any combination of the MCL_* flags except for MCL_ONFAULT alone.

---
 syscalls/mlockall.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
syscalls/mlockall.c +8 -5
index 4485aa6..9c99424 100644
@@ -10,20 +10,23 @@
 
 #define MCL_CURRENT     1
 #define MCL_FUTURE      2
+#define MCL_ONFAULT	4
 
 static void sanitise_mlockall(struct syscallrecord *rec)
 {
 	if (rec->a1 != 0)
 		return;
 
-	if (RAND_BOOL())
-		rec->a1 = MCL_CURRENT;
-	else
-		rec->a1 = MCL_FUTURE;
+	/*
+	 * There are two invalid bit patterns for MCL flags, 0, and MCL_ONFAULT
+	 * alone.  All other combinations should be valid.
+	 */
+	while (rec->a1 == 0 || rec->a1 == MCL_ONFAULT)
+		rec->a1 = (RAND_BYTE() & 0x07);
 }
 
 static unsigned long mlockall_flags[] = {
-	MCL_CURRENT, MCL_FUTURE,
+	MCL_CURRENT, MCL_FUTURE, MCL_ONFAULT,
 };
 
 struct syscallentry syscall_mlockall = {
Signature · 1 line
1.9.1
Applied
#1 lore raw
Quoted 9 lines · Eric B Munson

The new mlock2 system call was added, but it looks like the MCL_ONFAULT flag was missed. This is now a valid flag to pass to mlockall(), but it must be used in conjunction with either MCL_CURRENT or MCL_FUTURE (or both). Also rework the way that the flags value for mlockall() is caclulated. It is valid to pass any combination of the MCL_* flags except for MCL_ONFAULT alone.

thanks, applied and pushed.

Dave