+ if ((flags & MAP_RESILIENT_CODESIGN) ||
+ (flags & MAP_RESILIENT_MEDIA)) {
+ if ((flags & MAP_ANON) ||
+ (flags & MAP_JIT)) {
+ return EINVAL;
+ }
+ }
+ if (flags & MAP_RESILIENT_CODESIGN) {
+ int reject_prot = ((flags & MAP_PRIVATE) ? VM_PROT_EXECUTE : (VM_PROT_WRITE | VM_PROT_EXECUTE));
+ if (prot & reject_prot) {
+ /*
+ * Quick sanity check. maxprot is calculated below and
+ * we will test it again.
+ */
+ return EPERM;
+ }
+ }
+ if (flags & MAP_SHARED) {
+ /*
+ * MAP_RESILIENT_MEDIA is not valid with MAP_SHARED because
+ * there is no place to inject zero-filled pages without
+ * actually adding them to the file.
+ * Since we didn't reject that combination before, there might
+ * already be callers using it and getting a valid MAP_SHARED
+ * mapping but without the resilience.
+ * For backwards compatibility's sake, let's keep ignoring
+ * MAP_RESILIENT_MEDIA in that case.
+ */
+ flags &= ~MAP_RESILIENT_MEDIA;
+ }
+ if (flags & MAP_RESILIENT_MEDIA) {
+ if ((flags & MAP_ANON) ||
+ (flags & MAP_SHARED)) {
+ return EINVAL;
+ }
+ }