Bug 509069 - ptrace: ERESTARTSYS from calling a function from a debugger (trap case)
Summary: ptrace: ERESTARTSYS from calling a function from a debugger (trap case)
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: kernel
Version: 12
Hardware: x86_64
OS: Linux
low
medium
Target Milestone: ---
Assignee: Roland McGrath
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2009-07-01 06:59 UTC by Jan Kratochvil
Modified: 2010-11-04 16:42 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2010-11-04 16:42:23 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
proposed fix (4.16 KB, patch)
2009-09-18 03:59 UTC, Roland McGrath
no flags Details | Diff

Description Jan Kratochvil 2009-07-01 06:59:34 UTC
Description of problem:
On a GDB testcase was found i386 debugger running on x86_64 kernel accidentally
causes ERESTARTSYS to be returned in errno in the process being debugged.
FIXME: It is not reproducible on an i386 debugger on an i386 kernel.
It is not reproducible on an x86_64 debugger on an x86_64 kernel.

It is the same Bug as Bug 434995 but in that case a raise() in the called function was enough.  Now for the reproducibility one has to do some int3 (->SIGTRAP) or an invalid memory access (->SIGSEGV).

Version-Release number of selected component (if applicable):
kernel-2.6.29.5-191.fc11.x86_64 (FAILs)
kernel-2.6.31-0.38.rc1.git7.fc12.x86_64 (FAILs)

How reproducible:
Always.

Steps to Reproduce:
wget
http://sources.redhat.com/cgi-bin/cvsweb.cgi/~checkout~/tests/ptrace-tests/tests/erestartsys-trap.c?cvsroot=systemtap; gcc -o erestartsys-trap erestartsys-trap.c -Wall -ggdb2 -D_GNU_SOURCE -m32 -lutil; ./erestartsys-trap; echo $?

Actual results:
1

Expected results:
0

Additional info:

Comment 1 Jan Kratochvil 2009-07-01 07:23:18 UTC
PASS for  an i386 debugger on an i386 kernel (as the former Bug).
Tested only in KVM (on kernel-2.6.29.5-191.fc11.x86_64).

Comment 3 Roland McGrath 2009-09-18 01:57:59 UTC
Reproduced on upstream v2.6.31-5510-gde55a89

Comment 4 Roland McGrath 2009-09-18 02:51:50 UTC
The key issue is that in the "restored" state, the thread is not on the syscall-exit path in the kernel after a 32-bit syscall, but is later in the vanilla exception-signal path back to user mode.  This means TS_COMPAT is not set and so the kernel doesn't think orig_ax/ax refer to a 32-bit syscall where it would sign-extend 32-bit values.  I'll figure out the fix upstream.

Comment 5 Roland McGrath 2009-09-18 03:59:52 UTC
Created attachment 361587 [details]
proposed fix

Comment 6 Roland McGrath 2009-09-18 04:00:26 UTC
Please review the explanation and caveats in the log/comments of the patch before I submit it upstream.

Comment 7 Oleg Nesterov 2009-09-18 11:29:47 UTC
Stupid question. This patch simply removes R32(eax, ax), this means
the debugger can change orig_eax but not eax?

Comment 8 Oleg Nesterov 2009-09-18 11:33:21 UTC
(In reply to comment #7)
> Stupid question. This patch simply removes R32(eax, ax), this means
> the debugger can change orig_eax but not eax?  

Oops!

Please ignore, I didn't notice "case offsetof(struct user32, regs.eax):"
below.

This all looks correct to me, but my understanding of this magic is
very limited.

Comment 9 Jan Kratochvil 2009-09-18 16:02:51 UTC
No GDB testsuite regressions, gdb.base/interrupt.exp got fixed for crossarch runs, OK from me, thanks.

Comment 10 Bug Zapper 2009-11-16 10:35:07 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 12 development cycle.
Changing version to '12'.

More information and reason for this action is here:
http://fedoraproject.org/wiki/BugZappers/HouseKeeping

Comment 11 Bug Zapper 2010-11-04 10:53:23 UTC
This message is a reminder that Fedora 12 is nearing its end of life.
Approximately 30 (thirty) days from now Fedora will stop maintaining
and issuing updates for Fedora 12.  It is Fedora's policy to close all
bug reports from releases that are no longer maintained.  At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '12'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 12's end of life.

Bug Reporter: Thank you for reporting this issue and we are sorry that 
we may not be able to fix it before Fedora 12 is end of life.  If you 
would still like to see this bug fixed and are able to reproduce it 
against a later version of Fedora please change the 'version' of this 
bug to the applicable version.  If you are unable to change the version, 
please add a comment here and someone will do it for you.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events.  Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

The process we are following is described here: 
http://fedoraproject.org/wiki/BugZappers/HouseKeeping

Comment 12 Jan Kratochvil 2010-11-04 16:42:23 UTC
Fixed in: kernel-2.6.34.7-61.fc13.x86_64


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