From: Gareth Hughes <gareth@valinux.com>
To: Andrea Arcangeli <andrea@suse.de>
Cc: Linus Torvalds <torvalds@transmeta.com>,
dledford@redhat.com, linux-kernel@vger.kernel.org
Subject: Re: SETFPXREGS fix
Date: Sat, 04 Nov 2000 10:50:00 +1100 [thread overview]
Message-ID: <3A034F28.5DB994F4@valinux.com> (raw)
In-Reply-To: <20001103174105.C857@athlon.random>
Andrea Arcangeli wrote:
>
> --- 2.4.0-test10/arch/i386/kernel/i387.c Thu Nov 2 20:58:58 2000
> +++ PIII/arch/i386/kernel/i387.c Thu Nov 2 18:44:36 2000
> @@ -440,8 +436,25 @@
> int set_fpxregs( struct task_struct *tsk, struct user_fxsr_struct *buf )
> {
> if ( HAVE_FXSR ) {
> - __copy_from_user( &tsk->thread.i387.fxsave, (void *)buf,
> - sizeof(struct user_fxsr_struct) );
> + long mxcsr;
> +
> + if (__copy_from_user(&tsk->thread.i387.fxsave, (void *)buf,
> + (long) &((struct user_fxsr_struct *)
> + 0)->mxcsr))
> + return -EFAULT;
> + if (__get_user(mxcsr,
> + &((struct user_fxsr_struct *) buf)->mxcsr))
> + return -EFAULT;
> + /* bit 6 and 31-16 must be zero for security reasons */
> + mxcsr &= 0xffbf;
> + tsk->thread.i387.fxsave.mxcsr = mxcsr;
> + if (__copy_from_user(&tsk->thread.i387.fxsave.reserved,
> + &((struct user_fxsr_struct *)
> + buf)->reserved,
> + sizeof(struct user_fxsr_struct)-
> + (long) &((struct user_fxsr_struct *)
> + 0)->reserved))
> + return -EFAULT;
> return 0;
> } else {
> return -EIO;
Why do all three copies? Why not copy it once and mask out the mxcsr
value when it's in tsk->thread.i387.fxsave.mxcsr? Seems to be an overly
complex fix.
if ( HAVE_FXSR ) {
if ( __copy_from_user( &tsk->thread.i387.fxsave, (void *)buf,
sizeof(struct user_fxsr_struct) ) )
return -EFAULT;
/* bit 6 and 31-16 must be zero for security reasons */
tsk->thread.i387.fxsave.mxcsr &= 0x0000ffbf;
return 0;
}
-- Gareth
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/
next prev parent reply other threads:[~2000-11-03 23:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-11-03 16:41 SETFPXREGS fix Andrea Arcangeli
2000-11-03 23:50 ` Gareth Hughes [this message]
2000-11-04 1:07 ` Andrea Arcangeli
2000-11-04 1:13 ` Gareth Hughes
2000-11-04 1:29 ` Andrea Arcangeli
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=3A034F28.5DB994F4@valinux.com \
--to=gareth@valinux.com \
--cc=andrea@suse.de \
--cc=dledford@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@transmeta.com \
/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