amd64/106109: amd64: si_addr is not set when sending a signal

NIIMI Satoshi sa2c at sa2c.net
Thu Nov 30 20:20:05 PST 2006


>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 ---


>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-amd64 mailing list