Re: [patch 3/4] mempolicy: add MPOL_F_STATIC_NODES flag

From: David Rientjes
Date: Fri Feb 15 2008 - 15:24:26 EST


On Fri, 15 Feb 2008, Paul Jackson wrote:

> I don't think so. It's not possible to detemine if exactly the low
> eight bits of the 'policy' short are a valid mode, -however- that
> "eight" is a spurious detail. Remove it.
>

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.

> Instead of specifying that the 'policy' short consists of two bytes,
> one for mode and one for flags, rather specify that the policy fields
> consists of some high bits for flags, and the remaining low bits
> (however many remain) for the mode.
>

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;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/