Bug 509069 - ptrace: ERESTARTSYS from calling a function from a debugger (trap case)
ptrace: ERESTARTSYS from calling a function from a debugger (trap case)
Product: Fedora
Classification: Fedora
Component: kernel (Show other bugs)
x86_64 Linux
low Severity medium
: ---
: ---
Assigned To: Roland McGrath
Fedora Extras Quality Assurance
: Triaged
Depends On:
  Show dependency treegraph
Reported: 2009-07-01 02:59 EDT by Jan Kratochvil
Modified: 2010-11-04 12:42 EDT (History)
5 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2010-11-04 12:42:23 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

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

  None (edit)
Description Jan Kratochvil 2009-07-01 02:59:34 EDT
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- (FAILs)
kernel-2.6.31-0.38.rc1.git7.fc12.x86_64 (FAILs)

How reproducible:

Steps to Reproduce:
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:

Expected results:

Additional info:
Comment 1 Jan Kratochvil 2009-07-01 03:23:18 EDT
PASS for  an i386 debugger on an i386 kernel (as the former Bug).
Tested only in KVM (on kernel-
Comment 3 Roland McGrath 2009-09-17 21:57:59 EDT
Reproduced on upstream v2.6.31-5510-gde55a89
Comment 4 Roland McGrath 2009-09-17 22:51:50 EDT
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-17 23:59:52 EDT
Created attachment 361587 [details]
proposed fix
Comment 6 Roland McGrath 2009-09-18 00:00:26 EDT
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 07:29:47 EDT
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 07:33:21 EDT
(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?  


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

This all looks correct to me, but my understanding of this magic is
very limited.
Comment 9 Jan Kratochvil 2009-09-18 12:02:51 EDT
No GDB testsuite regressions, gdb.base/interrupt.exp got fixed for crossarch runs, OK from me, thanks.
Comment 10 Bug Zapper 2009-11-16 05:35:07 EST
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:
Comment 11 Bug Zapper 2010-11-04 06:53:23 EDT
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: 
Comment 12 Jan Kratochvil 2010-11-04 12:42:23 EDT
Fixed in: kernel-

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