Currently arch_validate_flags() is written in a very non-extensible fashion, returning immediately if MTE is not supported and writing the MTE check as a direct return. Since we will want to add more checks for GCS refactor the existing code to be more extensible, no functional change intended.
Unified · Split
| @@ -62,11 +62,17 @@ static inline bool arch_validate_prot(unsigned long prot, · 61 unmodified lines | ||
| 62 | 62 | |
| 63 | 63 | static inline bool arch_validate_flags(unsigned long vm_flags) |
| 64 | 64 | { |
| 65 | − if (!system_supports_mte()) | |
| 66 | − return true; | |
| 65 | + if (system_supports_mte()) { | |
| 66 | + /* | |
| 67 | + * only allow VM_MTE if VM_MTE_ALLOWED has been set | |
| 68 | + * previously | |
| 69 | + */ | |
| 70 | + if ((vm_flags & VM_MTE) && !(vm_flags & VM_MTE_ALLOWED)) | |
| 71 | + return false; | |
| 72 | + } | |
| 73 | + | |
| 74 | + return true; | |
| 67 | 75 | |
| 68 | − /* only allow VM_MTE if VM_MTE_ALLOWED has been set previously */ | |
| 69 | − return !(vm_flags & VM_MTE) || (vm_flags & VM_MTE_ALLOWED); | |
| 70 | 76 | } |
| 71 | 77 | #define arch_validate_flags(vm_flags) arch_validate_flags(vm_flags) |
| 72 | 78 | |