Bug 20065 - sigcontext mismatch?
Summary: sigcontext mismatch?
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: kernel
Version: 9
Hardware: i686
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Arjan van de Ven
QA Contact: Brian Brock
URL:
Whiteboard:
Keywords:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2000-10-30 21:17 UTC by Len Widra
Modified: 2008-08-01 16:22 UTC (History)
0 users

(edit)
Clone Of:
(edit)
Last Closed: 2004-09-30 15:38:51 UTC


Attachments (Terms of Use)

Description Len Widra 2000-10-30 21:17:53 UTC
For x86 platforms, it seems like there's a mismatch between
1) the sigcontext structure defined in RH 7.0 /usr/include/asm/sigcontext.h
and
2) the structure that is actually pushed as the third argument to a signal
handler.

As a result, the "offending PC" ends up in the "fpstate" member rather
than in "cr2", where it's presumably supposed to be.

I haven't found a man page description for the third arg passed to a signal
handler, so it's hard to be certain what's intended.  "man sigaction" just
shows this arg as a "void *" with no further explanation.

Below is illustrative test code.


#include <sys/ucontext.h>

#define SIGCONTEXTPC fpstate /* Actually, the PC! */

void
fatal_signal_error_handler(int signo, siginfo_t *sinfo, void *pcontext)
{
	char PCbuf[32];
	struct sigcontext *context = pcontext;

	printf("pid %d sees signal %d\n", getpid(), signo);
	printf("si_code is 0x%x\n", sinfo->si_code);
	printf("si_addr is 0x%x\n", (long)(sinfo->si_addr));
	sprintf(PCbuf, "0x%x", context->SIGCONTEXTPC);
	printf("offending PC is %s\n", PCbuf);
	sleep(100000); /* Allow gdb to be used on running process */
}


void set_signals()
{
	int sig;
	struct sigaction sigact;

	sigact.sa_sigaction = fatal_signal_error_handler;
	sigemptyset(&sigact.sa_mask);
	sigact.sa_flags = SA_SIGINFO;
	sigact.sa_restorer = 0;

	sigaction(SIGSEGV, &sigact, 0);
}

main()
{
	char *badaddr = (char *)0x37;
	int x;

	set_signals();

	x = *badaddr;
}

Comment 1 Alan Cox 2003-06-05 22:19:22 UTC
Example still works on RH9. Needs review to verify if it is in fact correct or not


Comment 2 Bugzilla owner 2004-09-30 15:38:51 UTC
Thanks for the bug report. However, Red Hat no longer maintains this version of
the product. Please upgrade to the latest version and open a new bug if the problem
persists.

The Fedora Legacy project (http://fedoralegacy.org/) maintains some older releases, 
and if you believe this bug is interesting to them, please report the problem in
the bug tracker at: http://bugzilla.fedora.us/



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