From: Andrew Morton <akpm@osdl.org>
To: linux-arch@vger.kernel.org
Subject: Re: compat_sys_sched_setaffinity()
Date: Thu, 18 Mar 2004 01:17:43 -0800 [thread overview]
Message-ID: <20040318011743.475153bf.akpm@osdl.org> (raw)
In-Reply-To: <20040318010531.1af5b0a9.akpm@osdl.org>
Andrew Morton <akpm@osdl.org> wrote:
>
>
> This is broken for NR_CPUS > 64, is it not?
>
> asmlinkage long compat_sys_sched_setaffinity(compat_pid_t pid,
> unsigned int len,
> compat_ulong_t *user_mask_ptr)
> {
> unsigned long kernel_mask;
> mm_segment_t old_fs;
> int ret;
>
> if (get_user(kernel_mask, user_mask_ptr))
> return -EFAULT;
>
> old_fs = get_fs();
> set_fs(KERNEL_DS);
> ret = sys_sched_setaffinity(pid,
> sizeof(kernel_mask),
> &kernel_mask);
> set_fs(old_fs);
>
> return ret;
> }
>
It also seems to be broken with NR_CPUS > 32. The syscall API says
(implies?) that CPU 0 is the LSB of *user_mask_ptr. On a big-endian 32-bit
app, an attempt to bind to CPU #0 will end up binding to CPU #33, methinks.
And it's potentially trying to copy more than `len' bytes from userspace so
it might incorrectly return -EFAULT.
And it's failing to check that len >= sizeof(cpumask_t). If the user
passes in len==1, he gets bound to garbage CPUs.
Needs work.
next prev parent reply other threads:[~2004-03-18 9:17 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-03-18 9:05 compat_sys_sched_setaffinity() Andrew Morton
2004-03-18 9:17 ` Andrew Morton [this message]
2004-03-18 9:46 ` compat_sys_sched_setaffinity() Anton Blanchard
2004-03-18 23:08 ` compat_sys_sched_setaffinity() David S. Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20040318011743.475153bf.akpm@osdl.org \
--to=akpm@osdl.org \
--cc=linux-arch@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox