kernel patch needed for wine?
Alexander Kabaev
kabaev at gmail.com
Wed Jun 30 23:24:05 UTC 2010
On Wed, 30 Jun 2010 14:42:47 -0700
Garrett Cooper <yanefbsd at gmail.com> wrote:
> On Wed, Jun 30, 2010 at 2:22 PM, Sam Fourman Jr. <sfourman at gmail.com>
> wrote:
> > On Wed, Jun 30, 2010 at 11:26 AM, Garrett Cooper
> > <yanefbsd at gmail.com> wrote:
> >> On Wed, Jun 30, 2010 at 8:43 AM, Sam Fourman Jr.
> >> <sfourman at gmail.com> wrote:
> >>>> Which patch ? icebp generates the SIGTRAP on latest 8-stable,
> >>>> verified by the following trivival assembler program:
> >>>> .text
> >>>> .globl main
> >>>> main:
> >>>> .byte 0xf1
> >>>> xorl %edi,%edi
> >>>> call exit
> >>>>
> >>>
> >
> > Here is the C program that the linux people used as a test case.
> >
> > ***************************************************************
> > #include <stdio.h>
> > #include <signal.h>
> >
> >
> >
> > void trap_handler(int sig)
> > {
> > printf("trapped\n");
> > }
> >
> >
> > /*
> > * icebp
> > * ret
> > */
> > char icebp_func[] = "\xf1\xc3";
> > typedef void (*icebp_call)(void);
> >
> > int main(int argc, char **argv)
> > {
> > icebp_call func = (icebp_call)icebp_func;
> >
> > signal(SIGTRAP, trap_handler);
> >
> > func();
> >
> > return 0;
> > }
> >
> > ***************************************************************
> >
> > My question is why doe the above code not print trapped on amd64?
> >
> > FreeBSD 8.1 i386 this code prints "Trapped" as intended
> > FreeBSD 8.1 amd64 this code prints "Segmentation fault: 11"
> > FreeBSD 8.1 amd64 chrooted to 32bit prints "Segmentation fault"
> >
> > I did verify that from Linux amd64 this works and prints "Trapped"
> > uname -a
> > Linux workstation 2.6.32-23-generic #37-Ubuntu SMP Fri Jun 11
> > 08:03:28 UTC 2010 x86_64 GNU/Linux
>
> Hmmm... I've seen similar whackiness with Linux and signals, but
> that's a different thing entirely (it was rt signals vs non-rt
> signals).
>
> Here's a modified version of the testcase (wanted to make sure that
> things were sane):
>
> $ cat test_sigtrap.c
> #include <err.h>
> #include <signal.h>
> #include <stdio.h>
>
> int trapped = 0;
>
> void trap_handler(int sig)
> {
> trapped = 1;
> }
>
>
> /*
> * icebp
> * ret
> */
> char icebp_func[] = "\xf1\xc3";
> typedef void (*icebp_call)(void);
>
> int main(int argc, char **argv)
> {
> icebp_call func = (icebp_call)icebp_func;
>
> if (signal(SIGTRAP, trap_handler) == SIG_ERR)
> err(1, "signal");
>
> func();
>
> if (trapped)
> printf("Admiral Ackbar: it's a trap!\n");
>
> return 0;
> }
>
> Ran it and it segfaulted on CURRENT:
>
Now make icebp_func const and observe the program start working. The
test case is broken as written, because icebp_func array is writable,
so in ends up in a non-const part of .bss, which is not marked as
executable and rightfully causes SIGSEGV when jumped to.
--
Alexander Kabaev
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 188 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20100630/715752dc/signature.pgp
More information about the freebsd-hackers
mailing list