Restrict the input domain set in cpuset_setdomain(2) to all_domains.
To permit larger values of MAXMEMDOM, which is currently 8 on amd64, cpuset_setdomain(2) accepts a mask of size 256. In the kernel, domain set masks are 64 bits wide, but can only represent a set of MAXMEMDOM domains due to the use of the ds_order table. Domain sets passed to cpuset_setdomain(2) are restricted to a subset of their parent set, which is typically the root set, but before this happens we modify the input set to exclude empty domains. domainset_empty_vm() and other code which manipulates domain sets expect the mask to be a subset of all_domains, so enforce that when performing validation of cpuset_setdomain(2) parameters. Reported and tested by: pho Reviewed by: kib MFC after: 3 days Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D21477
This commit is contained in:
parent
c993b95329
commit
63cdd18e40
@ -2156,6 +2156,14 @@ kern_cpuset_setdomain(struct thread *td, cpulevel_t level, cpuwhich_t which,
|
||||
DOMAINSET_COPY(mask, &domain.ds_mask);
|
||||
domain.ds_policy = policy;
|
||||
|
||||
/*
|
||||
* Sanitize the provided mask.
|
||||
*/
|
||||
if (!DOMAINSET_SUBSET(&all_domains, &domain.ds_mask)) {
|
||||
error = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Translate preferred policy into a mask and fallback. */
|
||||
if (policy == DOMAINSET_POLICY_PREFER) {
|
||||
/* Only support a single preferred domain. */
|
||||
@ -2165,12 +2173,12 @@ kern_cpuset_setdomain(struct thread *td, cpulevel_t level, cpuwhich_t which,
|
||||
}
|
||||
domain.ds_prefer = DOMAINSET_FFS(&domain.ds_mask) - 1;
|
||||
/* This will be constrained by domainset_shadow(). */
|
||||
DOMAINSET_FILL(&domain.ds_mask);
|
||||
DOMAINSET_COPY(&all_domains, &domain.ds_mask);
|
||||
}
|
||||
|
||||
/*
|
||||
* When given an impossible policy, fall back to interleaving
|
||||
* across all domains
|
||||
* When given an impossible policy, fall back to interleaving
|
||||
* across all domains.
|
||||
*/
|
||||
if (domainset_empty_vm(&domain))
|
||||
domainset_copy(&domainset2, &domain);
|
||||
|
Loading…
Reference in New Issue
Block a user