diff --git a/ipc/shm.c b/ipc/shm.c
index 1c2faf6..ed56723 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -170,6 +170,38 @@ static int shm_mmap(struct file * file, struct vm_area_struct * vma)
 	return ret;
 }
 
+#include <ksplice-patch.h>
+
+int ksplice_shm_check_apply(void)
+{
+	struct task_struct *g, *tsk;
+	do_each_thread(g, tsk) {
+		if (tsk->mm == NULL)
+			continue;
+		if (!down_write_trylock(&tsk->mm->mmap_sem))
+			return 1;
+		up_write(&tsk->mm->mmap_sem);
+	} while_each_thread(g, tsk);
+	return 0;
+}
+ksplice_check_apply(ksplice_shm_check_apply);
+
+void ksplice_shm_apply(void)
+{
+	struct task_struct *g, *tsk;
+	do_each_thread(g, tsk) {
+		struct vm_area_struct *vma;
+		if (tsk->mm == NULL)
+			continue;
+		for (vma = tsk->mm->mmap; vma != NULL; vma = vma->vm_next) {
+			if (vma->vm_ops == &shm_vm_ops &&
+			    !(vma->vm_flags & VM_WRITE))
+				vma->vm_flags &= ~VM_MAYWRITE;
+		}
+	} while_each_thread(g, tsk);
+}
+ksplice_apply(ksplice_shm_apply);
+
 static struct file_operations shm_file_operations = {
 	.mmap	= shm_mmap,
 #ifndef CONFIG_MMU
