All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: "H. Peter Anvin" <hpa@zytor.com>,
	Linus Torvalds <torvalds@linux-foundation.org>
Cc: Chuck Ebbert <chuckebbert.lk@gmail.com>,
	Jan Kratochvil <jan.kratochvil@redhat.com>,
	linux-kernel@vger.kernel.org
Subject: ptrace && fpu_lazy_restore
Date: Sun, 15 Apr 2012 01:52:38 +0200	[thread overview]
Message-ID: <20120414235238.GA11131@redhat.com> (raw)

Credits to Jan and Chuck, see

	https://bugzilla.redhat.com/show_bug.cgi?id=810668

with reproducer:

	https://bugzilla.redhat.com/attachment.cgi?id=577270

But afaics the root of the problem is clear. Once PTRACE_SETFPREGS
changes fpu.state->fxsave the task obviously needs restore_fpu_checking()
on context switch.

But I am not sure about the fix, and in any case I need more time
to read this new code.

Oleg.

--- x/arch/x86/kernel/i387.c~	2012-04-09 20:12:12.000000000 +0200
+++ x/arch/x86/kernel/i387.c	2012-04-15 01:34:09.000000000 +0200
@@ -301,6 +301,8 @@ int xfpregs_set(struct task_struct *targ
 
 	sanitize_i387_state(target);
 
+	target->thread.fpu.last_cpu = ~0;
+
 	ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
 				 &target->thread.fpu.state->fxsave, 0, -1);
 
@@ -563,6 +565,8 @@ int fpregs_set(struct task_struct *targe
 
 	sanitize_i387_state(target);
 
+	target->thread.fpu.last_cpu = ~0;
+
 	if (!HAVE_HWFP)
 		return fpregs_soft_set(target, regset, pos, count, kbuf, ubuf);
 


             reply	other threads:[~2012-04-14 23:53 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-14 23:52 Oleg Nesterov [this message]
2012-04-14 23:59 ` ptrace && fpu_lazy_restore Oleg Nesterov
2012-04-15  2:03 ` Linus Torvalds
2012-04-15 22:38   ` Oleg Nesterov
2012-04-15 23:42     ` Linus Torvalds
2012-04-15 23:46       ` Linus Torvalds
2012-04-16 20:47         ` [PATCH 0/1] i387: ptrace breaks the lazy-fpu-restore logic Oleg Nesterov
2012-04-16 20:48           ` [PATCH 1/1] " Oleg Nesterov
2012-04-16 22:09             ` Oleg Nesterov
2012-04-17  0:05             ` [tip:x86/urgent] " tip-bot for Oleg Nesterov

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=20120414235238.GA11131@redhat.com \
    --to=oleg@redhat.com \
    --cc=chuckebbert.lk@gmail.com \
    --cc=hpa@zytor.com \
    --cc=jan.kratochvil@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.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.