diff options
author | kib <kib@FreeBSD.org> | 2008-10-04 19:23:30 +0000 |
---|---|---|
committer | kib <kib@FreeBSD.org> | 2008-10-04 19:23:30 +0000 |
commit | d7ec3f21ab8e145fd4d844789e72b0f45e958254 (patch) | |
tree | 93959782ec596fba89dd8592860ed2604d1b8163 | |
parent | d3e532c1da757bc3ac29a46a1996b63b712a74b3 (diff) | |
download | FreeBSD-src-d7ec3f21ab8e145fd4d844789e72b0f45e958254.zip FreeBSD-src-d7ec3f21ab8e145fd4d844789e72b0f45e958254.tar.gz |
Current linux_fooaffinity() emulation fails, as the FreeBSD affinity
syscalls expect the bitmap size in the range from 32 to 128. Old glibc
always assumed size 1024, while newer glibc searches for approriate
size, starting from 1024 and going up.
For now, use FreeBSD size of cpuset_t for bitmap size parameter and
return EINVAL if length of user space bitmap less than our size of
cpuset_t.
Submitted by: dchagin
MFC after: 1 week
[This requires MFC of the actual linux affinity syscalls]
-rw-r--r-- | sys/compat/linux/linux_misc.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c index 47d7d3f..1be8f92 100644 --- a/sys/compat/linux/linux_misc.c +++ b/sys/compat/linux/linux_misc.c @@ -1828,15 +1828,17 @@ linux_sched_getaffinity(struct thread *td, printf(ARGS(sched_getaffinity, "%d, %d, *"), args->pid, args->len); #endif + if (args->len < sizeof(cpuset_t)) + return (EINVAL); cga.level = CPU_LEVEL_WHICH; cga.which = CPU_WHICH_PID; cga.id = args->pid; - cga.cpusetsize = sizeof(cpumask_t); + cga.cpusetsize = sizeof(cpuset_t); cga.mask = (cpuset_t *) args->user_mask_ptr; - + if ((error = cpuset_getaffinity(td, &cga)) == 0) - td->td_retval[0] = sizeof(cpumask_t); + td->td_retval[0] = sizeof(cpuset_t); return (error); } @@ -1855,10 +1857,13 @@ linux_sched_setaffinity(struct thread *td, printf(ARGS(sched_setaffinity, "%d, %d, *"), args->pid, args->len); #endif + if (args->len < sizeof(cpuset_t)) + return (EINVAL); + csa.level = CPU_LEVEL_WHICH; csa.which = CPU_WHICH_PID; csa.id = args->pid; - csa.cpusetsize = args->len; + csa.cpusetsize = sizeof(cpuset_t); csa.mask = (cpuset_t *) args->user_mask_ptr; return (cpuset_setaffinity(td, &csa)); |