Sure it is, you can determine if the low MPOL_FLAG_SHIFT bits are a valid
mode by masking off the upper bits and testing if the result is >=
MPOL_MAX.
Well, it's still an implementation detail that needs to be explicitly
defined, otherwise we have no way to separate mode from flags when the
user passes in their int formal as part of either syscall.
And given the recent requirements for a perfectly formed set_mempolicy()
or mbind() syscall (as a result of the discussion about allowing non-empty
nodemasks with MPOL_DEFAULT), we need to ensure that invalid flags are not
being passed.
We should make sure to return -EINVAL to a user specifying an invalid flag
if, for example, they are using an older kernel that doesn't support what
they're asking for.
It would be possible to do all of this in both sys_set_mempolicy() and
sys_mbind() by masking off the set of possible modes and checking the
result for being >= MPOL_MAX:
if ((mode & MPOL_MODE_FLAGS) >= MPOL_MAX)
return -EINVAL;
--