From: Andi Kleen <ak@muc.de>
To: Linus Torvalds <torvalds@osdl.org>
Cc: Paul Jackson <pj@sgi.com>, akpm@osdl.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Fix argument checking in sched_setaffinity
Date: 7 Sep 2004 10:07:10 +0200
Date: Tue, 7 Sep 2004 10:07:10 +0200 [thread overview]
Message-ID: <20040907080710.GA22895@muc.de> (raw)
In-Reply-To: <Pine.LNX.4.58.0409061147220.28608@ppc970.osdl.org>
On Mon, Sep 06, 2004 at 11:48:46AM -0700, Linus Torvalds wrote:
>
>
> On Mon, 6 Sep 2004, Andi Kleen wrote:
> >
> > The only change I would like to have is to check the excess bytes
> > to make sure they don't contain some random value. They should
> > be either all 0 or all 0xff.
>
> I hate the "byte at a time" interface.
I looked at doing it, but it would be far too complicated
for such a single operation with the two necessary alignment and
fix up left over bytes at the end loops and other fixup code.
And this should not really be performance critical in any ways.
long handling would be easy if the interface had been designed in longs,
but it wasn't.
> That said, I think the "long at a time" interface we have now for bitmaps
> ends up being a compatibility problem, where the compat layer has to worry
> about big-endian 32-bit "long" lookign different from big-endian 64-bit
> "long".
>
> So there are other issues here.
In this special case not - big endian and little endian 0 and -1 are both
identical :-)
-Andi
Here's the byte at a time code again in case you change your mind.
--------------------------------------------------------------
Check that excess bytes passed by the user process to
sched_setaffinity contain all 0 (no cpus) or all ones (all cpus)
diff -u linux-2.6.8/kernel/sched.c-o linux-2.6.8/kernel/sched.c
--- linux-2.6.8/kernel/sched.c-o 2004-09-06 20:06:58.000000000 +0200
+++ linux-2.6.8/kernel/sched.c 2004-09-06 20:16:33.940579241 +0200
@@ -3368,6 +3368,19 @@
if (len < sizeof(cpumask_t)) {
memset(new_mask, 0, sizeof(cpumask_t));
} else if (len > sizeof(cpumask_t)) {
+ unsigned i;
+ unsigned char val, initval;
+ if (len > PAGE_SIZE)
+ return -EINVAL;
+ /* excess bytes must be all 0 or all 0xff */
+ for (i = sizeof(cpumask_t); i < len; i++) {
+ if (get_user(val, (char *)new_mask + i))
+ return -EFAULT;
+ if (i == sizeof(cpumask_t))
+ initval = val;
+ if (!(val == 0 || val == 0xff) || val != initval)
+ return -EINVAL;
+ }
len = sizeof(cpumask_t);
}
return copy_from_user(new_mask, user_mask_ptr, len) ? -EFAULT : 0;
next prev parent reply other threads:[~2004-09-07 8:11 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-08-31 14:30 [PATCH] Fix argument checking in sched_setaffinity Andi Kleen
2004-09-01 1:36 ` Paul Jackson
2004-09-01 1:59 ` Anton Blanchard
2004-09-02 9:33 ` Paul Jackson
2004-09-04 13:40 ` Andi Kleen
2004-09-05 14:27 ` Anton Blanchard
2004-09-04 13:37 ` Andi Kleen
[not found] ` <20040904171417.67649169.pj@sgi.com>
2004-09-05 0:18 ` Linus Torvalds
2004-09-05 1:05 ` Paul Jackson
2004-09-05 1:38 ` Linus Torvalds
2004-09-05 3:48 ` Paul Jackson
2004-09-05 3:57 ` Linus Torvalds
2004-09-05 4:17 ` Paul Jackson
2004-09-05 4:52 ` Paul Jackson
2004-09-06 18:23 ` Andi Kleen
2004-09-06 18:48 ` Linus Torvalds
2004-09-06 21:11 ` Paul Jackson
2004-09-07 14:40 ` Linus Torvalds
2004-09-07 14:48 ` Geert Uytterhoeven
2004-09-07 14:49 ` Andi Kleen
2004-09-07 21:44 ` Ralf Baechle
2004-09-07 22:55 ` Paul Jackson
2004-09-08 6:58 ` Andi Kleen
2004-09-08 7:26 ` Paul Jackson
2004-09-08 0:26 ` Anton Blanchard
2004-09-07 14:50 ` Matthew Wilcox
2004-09-08 0:24 ` Anton Blanchard
2004-09-08 0:33 ` [PATCH] [ppc64] compat_get_bitmap/compat_put_bitmap Anton Blanchard
2004-09-08 0:40 ` [PATCH] [ppc64] Fix compat cpu affinity on big endian 64bit Anton Blanchard
2004-09-08 0:43 ` [PATCH] [ppc64] Fix compat NUMA API " Anton Blanchard
2004-09-08 5:22 ` [PATCH] [ppc64] Fix compat cpu affinity " Andrew Morton
2004-09-08 5:34 ` Anton Blanchard
2004-09-08 5:43 ` Andrew Morton
2004-09-07 8:07 ` Andi Kleen [this message]
2004-09-06 13:16 ` [PATCH] Fix argument checking in sched_setaffinity Andi Kleen
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=20040907080710.GA22895@muc.de \
--to=ak@muc.de \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pj@sgi.com \
--cc=torvalds@osdl.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.