amd64/106109: amd64: si_addr is not set when sending a signal
David Xu
davidxu at freebsd.org
Thu Nov 30 21:32:47 PST 2006
The following reply was made to PR amd64/106109; it has been noted by GNATS.
From: David Xu <davidxu at freebsd.org>
To: freebsd-amd64 at freebsd.org,
NIIMI Satoshi <sa2c at sa2c.net>
Cc: FreeBSD-gnats-submit at freebsd.org
Subject: Re: amd64/106109: amd64: si_addr is not set when sending a signal
Date: Fri, 1 Dec 2006 13:21:09 +0800
On Friday 01 December 2006 12:11, NIIMI Satoshi wrote:
> >Number: 106109
> >Category: amd64
> >Synopsis: amd64: si_addr is not set when sending a signal
> >Confidential: no
> >Severity: serious
> >Priority: low
> >Responsible: freebsd-amd64
> >State: open
> >Quarter:
> >Keywords:
> >Date-Required:
> >Class: sw-bug
> >Submitter-Id: current-users
> >Arrival-Date: Fri Dec 01 04:20:03 GMT 2006
> >Closed-Date:
> >Last-Modified:
> >Originator: NIIMI Satoshi
> >Release: FreeBSD 6.2-RC1 i386
> >Organization:
> >Environment:
>
> System: FreeBSD berkeley.l.sa2c.net 6.2-RC1 FreeBSD 6.2-RC1 #0: Thu Nov 30
> 10:03:58 JST 2006 root at berkeley.l.sa2c.net:/usr/obj/usr/src/sys/GENERIC
> i386
>
> >Description:
>
> POSIX style signal handers expect that the faulting address is stored
> in si_addr member of siginfo_t.
>
> But the address is passed to signal handler only as non-portable
> fourth argument on FreeBSD/amd64.
>
> >How-To-Repeat:
>
> Following program produces
> i386: &main=0x80485e8, si_addr=0x80485e8, fourth_arg=0x0
> amd64: &main=0x400780, si_addr=0x0, fourth_arg=0x400780
>
> #include <signal.h>
> #include <stdio.h>
> #include <stdlib.h>
>
> int main();
>
> void
> handler(int sig, siginfo_t *siginfo, void *context, void *addr)
> {
> fprintf(stderr, "&main=%p, si_addr=%p, fourth_arg=%p\n",
> &main, siginfo->si_addr, addr);
> exit(1);
> }
>
> int
> main()
> {
> struct sigaction sa;
>
> sa.sa_flags = SA_SIGINFO;
> sigemptyset(&sa.sa_mask);
> sa.sa_sigaction = (void (*)(int, siginfo_t *, void *))handler;
>
> sigaction(SIGBUS, &sa, NULL);
> sigaction(SIGSEGV, &sa, NULL);
> *(int *)main = 1;
>
> return 0;
> }
>
> >Fix:
>
> --- amd64-machdep.diff begins here ---
> Index: machdep.c
> ===================================================================
> RCS file: /home/ncvs/src/sys/amd64/amd64/machdep.c,v
> retrieving revision 1.664
> diff -u -r1.664 machdep.c
> --- machdep.c 19 Nov 2006 20:54:57 -0000 1.664
> +++ machdep.c 1 Dec 2006 03:36:54 -0000
> @@ -304,6 +304,7 @@
> /* Fill in POSIX parts */
> sf.sf_si = ksi->ksi_info;
> sf.sf_si.si_signo = sig; /* maybe a translated signal */
> + sf.sf_si.si_addr = ksi->ksi_addr;
> regs->tf_rcx = (register_t)ksi->ksi_addr; /* arg 4 in %rcx */
> } else {
> /* Old FreeBSD-style arguments. */
> --- amd64-machdep.diff ends here ---
I reviewed the sendsig() in RELENG_6 for AMD64, the si_addr is not set,
but is set in i386 version of sendsig(), the originator's patch is wrong,
it copied some code from HEAD which is not valid for RELENG_6, the
HEAD has fully working siginfo_t in kernel while RELENG_6 does not,
the patch should be changed to:
> + sf.sf_si.si_addr = regs->tf_addr;
David Xu
More information about the freebsd-amd64
mailing list