Bug 127228 - PTRACE_GETFPREGS reports bad x87 tag value
Summary: PTRACE_GETFPREGS reports bad x87 tag value
Keywords:
Status: CLOSED NEXTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: kernel
Version: 2
Hardware: i686
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Dave Jones
QA Contact: Brian Brock
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2004-07-04 21:52 UTC by Tom Horsley
Modified: 2015-01-04 22:07 UTC (History)
3 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2005-04-16 04:36:30 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
C test program to demonstrate bug (4.77 KB, text/plain)
2004-07-04 21:53 UTC, Tom Horsley
no flags Details
fix for fxsave->fnsave format bug (2.43 KB, patch)
2005-01-17 01:22 UTC, Roland McGrath
no flags Details | Diff

Description Tom Horsley 2004-07-04 21:52:02 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040510

Description of problem:
The tag word value reported by PTRACE_GETFPREGS is not the value
that would be saved by an fsave instruction. There is code in the
i386/ptrace.c file to attempt to emulate the fsave tag word from
the fxsave 1 byte tag info plus the register contents, but something
isn't right about the emulation code, as it does not come up with
the same value. (I suspect something about the 15 levels of operator
precedence in C together with the gigantic collections of ands
and ors in the source with no parens has something to do with it,
but it is beyond my ability to actually parse the emulation code
in the kernel, or I'd provide a patch :-).

I'll be attaching a small sample program tag.c to demonstrate the bug
to this bugzilla. Note that this has to run on a machine new enough
for the kernel to be using fxsave rather than fsave (which is just
about all of them, but I thought I'd mention it).

Version-Release number of selected component (if applicable):
kernel-2.6.6-1.435.2.3

How reproducible:
Always

Steps to Reproduce:
1. gcc -o tag tag.c && ./tag
    

Actual Results:  The PTRACE_GETFPREG function returns 0x505f for the
tag word.


Expected Results:  The actual value should be 0x05af

Additional info:

Comment 1 Tom Horsley 2004-07-04 21:53:47 UTC
Created attachment 101625 [details]
C test program to demonstrate bug

Comment 2 Dave Jones 2005-01-14 05:50:38 UTC
seems to do the right thing here on the latest 2.6.10 kernel.
closing.


Comment 3 Tom Horsley 2005-01-14 23:54:52 UTC
Hmmm... Maybe athlon versus 686 has something to do with it? On my system:

Linux spike 2.6.10-1.737_FC3 #1 Mon Jan 10 13:50:10 EST 2005 i686 athlon i386 
GNU/Linux

I just recompiled and ran the test and still get the wrong answer:

In child, about to send myself a SIGUSR1
Child fsave buffer looks like:
...
twd = 0x05af
...
Parent PTRACE_GETFPREGS buffer looks like:
...
twd = 0xffff505f
...

The same 05af versus 505f as always.


Comment 4 Dave Jones 2005-01-15 04:47:56 UTC
I must have misread the results last night.
Roland, any ideas ?


Comment 5 Roland McGrath 2005-01-17 01:22:42 UTC
Created attachment 109853 [details]
fix for fxsave->fnsave format bug

For the record, there was no earthly reason I should have been expected to have
a clue about this.  In fact, I didn't.	But I puzzled it out with the hardware
book and some experimentation.

Comment 6 Dave Jones 2005-04-16 04:36:30 UTC
Fedora Core 2 has now reached end of life, and no further updates will be
provided by Red Hat.  The Fedora legacy project will be producing further kernel
updates for security problems only.

If this bug has not been fixed in the latest Fedora Core 2 update kernel, please
try to reproduce it under Fedora Core 3, and reopen if necessary, changing the
product version accordingly.

Thank you.



Note You need to log in before you can comment on or make changes to this bug.