From sa2c@sa2c.net  Fri Dec  1 04:12:00 2006
Return-Path: <sa2c@sa2c.net>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id 3133616A415
	for <FreeBSD-gnats-submit@freebsd.org>; Fri,  1 Dec 2006 04:12:00 +0000 (UTC)
	(envelope-from sa2c@sa2c.net)
Received: from wx-out-0506.google.com (wx-out-0506.google.com [66.249.82.231])
	by mx1.FreeBSD.org (Postfix) with ESMTP id E21F443C9D
	for <FreeBSD-gnats-submit@freebsd.org>; Fri,  1 Dec 2006 04:11:47 +0000 (GMT)
	(envelope-from sa2c@sa2c.net)
Received: by wx-out-0506.google.com with SMTP id s18so2635987wxc
        for <FreeBSD-gnats-submit@freebsd.org>; Thu, 30 Nov 2006 20:11:58 -0800 (PST)
Received: by 10.70.65.8 with SMTP id n8mr7791230wxa.1164946317848;
        Thu, 30 Nov 2006 20:11:57 -0800 (PST)
Received: from berkeley.l.sa2c.net ( [125.192.101.90])
        by mx.google.com with ESMTP id h13sm6347758wxd.2006.11.30.20.11.56;
        Thu, 30 Nov 2006 20:11:57 -0800 (PST)
Received: by berkeley.l.sa2c.net (Postfix, from userid 3104)
	id 6D32C42A1; Fri,  1 Dec 2006 13:11:53 +0900 (JST)
Message-Id: <20061201041153.6D32C42A1@berkeley.l.sa2c.net>
Date: Fri,  1 Dec 2006 13:11:53 +0900 (JST)
From: NIIMI Satoshi <sa2c@sa2c.net>
Reply-To: NIIMI Satoshi <sa2c@sa2c.net>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: amd64: si_addr is not set when sending a signal
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>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:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Dec 01 04:20:03 GMT 2006
>Closed-Date:    Sun May 06 03:43:23 GMT 2007
>Last-Modified:  Sun May 06 03:43:23 GMT 2007
>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@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 ---


>Release-Note:
>Audit-Trail:

From: David Xu <davidxu@freebsd.org>
To: freebsd-amd64@freebsd.org,
 NIIMI Satoshi <sa2c@sa2c.net>
Cc: FreeBSD-gnats-submit@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@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
 
  
State-Changed-From-To: open->patched  
State-Changed-By: davidxu 
State-Changed-When: Fri Dec 1 08:35:19 UTC 2006 
State-Changed-Why:  
Patch is applied. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=106109 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: amd64/106109: commit references a PR
Date: Fri,  1 Dec 2006 08:34:54 +0000 (UTC)

 davidxu     2006-12-01 08:34:39 UTC
 
   FreeBSD src repository
 
   Modified files:        (Branch: RELENG_6)
     sys/amd64/amd64      machdep.c 
   Log:
   MFC: Store fault address into POSIX siginfo.
   
   PR: amd64/106109
   
   Revision    Changes    Path
   1.638.2.11  +1 -0      src/sys/amd64/amd64/machdep.c
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 

From: NIIMI Satoshi <sa2c@sa2c.net>
To: bug-followup@FreeBSD.org,  davidxu@FreeBSD.org
Cc:  
Subject: Re: amd64/106109: amd64: si_addr is not set when sending a signal
Date: Sun, 06 May 2007 11:14:22 +0900

 It seems that my mail on 2006-12-02 was missed.
 
 I confirmed that the problem was fixed.  Please close this PR.
 
 Thanks,
 -- 
 NIIMI Satoshi
State-Changed-From-To: patched->closed 
State-Changed-By: linimon 
State-Changed-When: Sun May 6 03:42:59 UTC 2007 
State-Changed-Why:  
Submitter notes that this problem is now solved. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=106109 
>Unformatted:
