Congratulations, this pattern is responsible for more security bugs than any other.
Security should not be an "if" but must. Presumably down to instruction level or preferably to hardware that does TLB.
This thing is a likely TOCTOU error. What happens if I pass the check and enter the function just not having the permissions? The only way this is acceptable is if the code is proven to never do that, preferably to the deepest level possible.