public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug gdb/11842] New: compat_siginfo_from_siginfo and siginfo_from_compat_siginfo are wrong
@ 2010-07-26 9:37 jan dot kratochvil at redhat dot com
2010-07-26 9:39 ` [Bug gdb/11842] " jan dot kratochvil at redhat dot com
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: jan dot kratochvil at redhat dot com @ 2010-07-26 9:37 UTC (permalink / raw)
To: gdb-prs
Only biarch gdb is affected.
#include <unistd.h>
#include <sys/syscall.h>
#include <signal.h>
#define tgkill(tgid, tid, sig) syscall (__NR_tgkill, tgid, tid, sig)
int
main (void)
{
return tgkill (getpid (), getpid (), SIGUSR1);
}
gcc -o 1 1.c -Wall -g -m32
GNU gdb (GDB) 7.2.50.20100726-cvs
This GDB was configured as "x86_64-unknown-linux-gnu".
gcc-4.4.4-10.fc13.x86_64
kernel-2.6.33.6-147.fc13.x86_64
./gdb -nx -ex start -ex 'p getpid ()' -ex c -ex 'p
$_siginfo._sifields._kill.si_pid' ./1
[...]
$1 = 23172
Continuing.
Program received signal SIGUSR1, User defined signal 1.
0x00110430 in __kernel_vsyscall ()
$2 = 0
$1 and $2 are the same for native x86_64 and for native i686.
$1 and $2 SHOULD be the same even for i686 on x86_64 debugger.
compat_siginfo_from_siginfo and siginfo_from_compat_siginfo are wrong in:
gdb/gdbserver/linux-x86-low.c
gdb/amd64-linux-nat.c
--
Summary: compat_siginfo_from_siginfo and
siginfo_from_compat_siginfo are wrong
Product: gdb
Version: unknown
Status: UNCONFIRMED
Severity: minor
Priority: P2
Component: gdb
AssignedTo: unassigned at sourceware dot org
ReportedBy: jan dot kratochvil at redhat dot com
CC: gdb-prs at sourceware dot org
GCC target triplet: x86_64-fedora13-linux-gnu
http://sourceware.org/bugzilla/show_bug.cgi?id=11842
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug gdb/11842] compat_siginfo_from_siginfo and siginfo_from_compat_siginfo are wrong
2010-07-26 9:37 [Bug gdb/11842] New: compat_siginfo_from_siginfo and siginfo_from_compat_siginfo are wrong jan dot kratochvil at redhat dot com
@ 2010-07-26 9:39 ` jan dot kratochvil at redhat dot com
2010-08-06 12:28 ` pedro at codesourcery dot com
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: jan dot kratochvil at redhat dot com @ 2010-07-26 9:39 UTC (permalink / raw)
To: gdb-prs
--
What |Removed |Added
----------------------------------------------------------------------------
GCC host triplet| |x86_64-fedora13-linux-gnu
http://sourceware.org/bugzilla/show_bug.cgi?id=11842
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug gdb/11842] compat_siginfo_from_siginfo and siginfo_from_compat_siginfo are wrong
2010-07-26 9:37 [Bug gdb/11842] New: compat_siginfo_from_siginfo and siginfo_from_compat_siginfo are wrong jan dot kratochvil at redhat dot com
2010-07-26 9:39 ` [Bug gdb/11842] " jan dot kratochvil at redhat dot com
@ 2010-08-06 12:28 ` pedro at codesourcery dot com
2010-08-06 12:41 ` jan dot kratochvil at redhat dot com
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pedro at codesourcery dot com @ 2010-08-06 12:28 UTC (permalink / raw)
To: gdb-prs
------- Additional Comments From pedro at codesourcery dot com 2010-08-06 12:28 -------
This patch works for me. Did you spot anything else wrong?
gdb/
* amd64-linux-nat.c (compat_siginfo_from_siginfo)
(siginfo_from_compat_siginfo): Also copy si_pid and si_uid when
si_code is < 0.
gdb/gdbserver/
* linux-x86-low.c (compat_siginfo_from_siginfo)
(siginfo_from_compat_siginfo): Also copy si_pid and si_uid when
si_code is < 0.
---
gdb/amd64-linux-nat.c | 4 ++++
gdb/gdbserver/linux-x86-low.c | 4 ++++
2 files changed, 8 insertions(+)
Index: src/gdb/amd64-linux-nat.c
===================================================================
--- src.orig/gdb/amd64-linux-nat.c 2010-08-06 13:19:55.000000000 +0100
+++ src/gdb/amd64-linux-nat.c 2010-08-06 13:21:05.000000000 +0100
@@ -576,6 +576,8 @@ compat_siginfo_from_siginfo (compat_sigi
if (to->si_code < 0)
{
+ to->cpt_si_pid = from->si_pid;
+ to->cpt_si_uid = from->si_uid;
to->cpt_si_ptr = (intptr_t) from->si_ptr;
}
else if (to->si_code == SI_USER)
@@ -630,6 +632,8 @@ siginfo_from_compat_siginfo (siginfo_t *
if (to->si_code < 0)
{
+ to->si_pid = from->cpt_si_pid;
+ to->si_uid = from->cpt_si_uid;
to->si_ptr = (void *) (intptr_t) from->cpt_si_ptr;
}
else if (to->si_code == SI_USER)
Index: src/gdb/gdbserver/linux-x86-low.c
===================================================================
--- src.orig/gdb/gdbserver/linux-x86-low.c 2010-08-06 13:19:55.000000000 +0100
+++ src/gdb/gdbserver/linux-x86-low.c 2010-08-06 13:21:05.000000000 +0100
@@ -749,6 +749,8 @@ compat_siginfo_from_siginfo (compat_sigi
if (to->si_code < 0)
{
+ to->cpt_si_pid = from->si_pid;
+ to->cpt_si_uid = from->si_uid;
to->cpt_si_ptr = (intptr_t) from->si_ptr;
}
else if (to->si_code == SI_USER)
@@ -803,6 +805,8 @@ siginfo_from_compat_siginfo (siginfo_t *
if (to->si_code < 0)
{
+ to->si_pid = from->cpt_si_pid;
+ to->si_uid = from->cpt_si_uid;
to->si_ptr = (void *) (intptr_t) from->cpt_si_ptr;
}
else if (to->si_code == SI_USER)
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
http://sourceware.org/bugzilla/show_bug.cgi?id=11842
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug gdb/11842] compat_siginfo_from_siginfo and siginfo_from_compat_siginfo are wrong
2010-07-26 9:37 [Bug gdb/11842] New: compat_siginfo_from_siginfo and siginfo_from_compat_siginfo are wrong jan dot kratochvil at redhat dot com
2010-07-26 9:39 ` [Bug gdb/11842] " jan dot kratochvil at redhat dot com
2010-08-06 12:28 ` pedro at codesourcery dot com
@ 2010-08-06 12:41 ` jan dot kratochvil at redhat dot com
2010-08-06 13:31 ` pedro at codesourcery dot com
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: jan dot kratochvil at redhat dot com @ 2010-08-06 12:41 UTC (permalink / raw)
To: gdb-prs
------- Additional Comments From jan dot kratochvil at redhat dot com 2010-08-06 12:41 -------
I find the conditional `to->si_code < 0' wrong there.
See for example:
drivers/usb/core/devio.c
sinfo.si_code = SI_ASYNCIO;
sinfo.si_addr = as->userurb;
include/asm-generic/siginfo.h
#define SI_ASYNCIO -4 /* sent by AIO completion */
But you do not convert si_addr here.
Moreover when you start converting more fields you cannot - as they share the
same places in the union.
One has to probably investigate all the kernel points generating siginfo. :-/
--
http://sourceware.org/bugzilla/show_bug.cgi?id=11842
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug gdb/11842] compat_siginfo_from_siginfo and siginfo_from_compat_siginfo are wrong
2010-07-26 9:37 [Bug gdb/11842] New: compat_siginfo_from_siginfo and siginfo_from_compat_siginfo are wrong jan dot kratochvil at redhat dot com
` (2 preceding siblings ...)
2010-08-06 12:41 ` jan dot kratochvil at redhat dot com
@ 2010-08-06 13:31 ` pedro at codesourcery dot com
2010-08-06 13:35 ` jan dot kratochvil at redhat dot com
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pedro at codesourcery dot com @ 2010-08-06 13:31 UTC (permalink / raw)
To: gdb-prs
------- Additional Comments From pedro at codesourcery dot com 2010-08-06 13:31 -------
Yeah, though in practice si_addr ends up at the same address as si_pid to it is
already copied. Note that that's driver code. Who's to say what random drivers
do? I'm thinking that we only need to be as thorough/good as
arch/x86/ia32/ia32_signal.c:{copy_siginfo_to_user32,copy_siginfo_from_user32},
and that also has a catch-all si_code < 0 branch.
(I see that in our version, the "to->si_code == SI_TIMER" branch is
unreacheable, as SI_TIMER is < 0. whoops.)
--
http://sourceware.org/bugzilla/show_bug.cgi?id=11842
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug gdb/11842] compat_siginfo_from_siginfo and siginfo_from_compat_siginfo are wrong
2010-07-26 9:37 [Bug gdb/11842] New: compat_siginfo_from_siginfo and siginfo_from_compat_siginfo are wrong jan dot kratochvil at redhat dot com
` (3 preceding siblings ...)
2010-08-06 13:31 ` pedro at codesourcery dot com
@ 2010-08-06 13:35 ` jan dot kratochvil at redhat dot com
2010-08-30 8:47 ` jan dot kratochvil at redhat dot com
2010-09-29 9:03 ` pedro at codesourcery dot com
6 siblings, 0 replies; 8+ messages in thread
From: jan dot kratochvil at redhat dot com @ 2010-08-06 13:35 UTC (permalink / raw)
To: gdb-prs
------- Additional Comments From jan dot kratochvil at redhat dot com 2010-08-06 13:35 -------
(In reply to comment #3)
> I'm thinking that we only need to be as thorough/good as
> arch/x86/ia32/ia32_signal.c:{copy_siginfo_to_user32,copy_siginfo_from_user32},
OK, yes, I agree, thanks.
--
http://sourceware.org/bugzilla/show_bug.cgi?id=11842
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug gdb/11842] compat_siginfo_from_siginfo and siginfo_from_compat_siginfo are wrong
2010-07-26 9:37 [Bug gdb/11842] New: compat_siginfo_from_siginfo and siginfo_from_compat_siginfo are wrong jan dot kratochvil at redhat dot com
` (4 preceding siblings ...)
2010-08-06 13:35 ` jan dot kratochvil at redhat dot com
@ 2010-08-30 8:47 ` jan dot kratochvil at redhat dot com
2010-09-29 9:03 ` pedro at codesourcery dot com
6 siblings, 0 replies; 8+ messages in thread
From: jan dot kratochvil at redhat dot com @ 2010-08-30 8:47 UTC (permalink / raw)
To: gdb-prs
------- Additional Comments From jan dot kratochvil at redhat dot com 2010-08-30 08:47 -------
Post:
[patch 4/9]#2 Pedro's fix: compat_siginfo_from_siginfo (PR 11842)
http://sourceware.org/ml/gdb-patches/2010-08/msg00484.html
--
http://sourceware.org/bugzilla/show_bug.cgi?id=11842
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug gdb/11842] compat_siginfo_from_siginfo and siginfo_from_compat_siginfo are wrong
2010-07-26 9:37 [Bug gdb/11842] New: compat_siginfo_from_siginfo and siginfo_from_compat_siginfo are wrong jan dot kratochvil at redhat dot com
` (5 preceding siblings ...)
2010-08-30 8:47 ` jan dot kratochvil at redhat dot com
@ 2010-09-29 9:03 ` pedro at codesourcery dot com
6 siblings, 0 replies; 8+ messages in thread
From: pedro at codesourcery dot com @ 2010-09-29 9:03 UTC (permalink / raw)
To: gdb-prs
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2010-09-24 13:44 -------
Subject: Bug 11842
CVSROOT: /cvs/src
Module name: src
Changes by: palves@sourceware.org 2010-09-24 13:44:02
Modified files:
gdb : ChangeLog
gdb/gdbserver : ChangeLog
Log message:
PR gdb/11842
gdb/
* amd64-linux-nat.c (compat_siginfo_from_siginfo)
(siginfo_from_compat_siginfo): Also copy si_pid and si_uid when
si_code is < 0. Check for si_code == SI_TIMER before checking for
si_code < 0.
gdb/gdbserver/
* linux-x86-low.c (compat_siginfo_from_siginfo)
(siginfo_from_compat_siginfo): Also copy si_pid and si_uid when
si_code is < 0. Check for si_code == SI_TIMER before checking for
si_code < 0.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&r1=1.12200&r2=1.12201
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/gdbserver/ChangeLog.diff?cvsroot=src&r1=1.432&r2=1.433
------- Additional Comments From pedro at codesourcery dot com 2010-09-29 09:03 -------
Patch checked in.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
http://sourceware.org/bugzilla/show_bug.cgi?id=11842
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2010-09-29 9:03 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-26 9:37 [Bug gdb/11842] New: compat_siginfo_from_siginfo and siginfo_from_compat_siginfo are wrong jan dot kratochvil at redhat dot com
2010-07-26 9:39 ` [Bug gdb/11842] " jan dot kratochvil at redhat dot com
2010-08-06 12:28 ` pedro at codesourcery dot com
2010-08-06 12:41 ` jan dot kratochvil at redhat dot com
2010-08-06 13:31 ` pedro at codesourcery dot com
2010-08-06 13:35 ` jan dot kratochvil at redhat dot com
2010-08-30 8:47 ` jan dot kratochvil at redhat dot com
2010-09-29 9:03 ` pedro at codesourcery dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).