From: Chuck Ebbert <76306.1226@compuserve.com>
To: Daniel fernandez <ergot86@gmail.com>
Cc: Linus Torvalds <torvalds@osdl.org>,
linux-kernel <linux-kernel@vger.kernel.org>,
Ingo Molnar <mingo@redhat.com>, Andrew Morton <akpm@osdl.org>
Subject: Re: [PATCH] i386 - sys_clone from vsyscall
Date: Thu, 26 Jan 2006 11:41:55 -0500 [thread overview]
Message-ID: <200601261144_MC3-1-B6C2-3A7B@compuserve.com> (raw)
In-Reply-To: <401b11ae0601260712w7cfe88abm638dc7a459b3bb3a@mail.gmail.com>
On Thu, 26 Jan 2006 at 15:12:08 +0000, Daniel fernandez wrote:
> > Your patch almost works but it copies the stack into the parent's address space.
> > Using access_process_vm() fixes it. However, that still leaves unfixed the case
> > where vsyscall-int80 is used.
>
> I copy the stack into the parent's address space becuase in this case
> the memory is shared, but access_process_vm() is more elegant :).
My test program (below) doesn't use CLONE_VM. With your patch the stack
data showed up only in the parent process, probably due to copy-on-write,
and the child gets SIGSEGV trying to transfer control to address 0.
> About vsyscall-int80, I don't know how to test that case in my
> computer but I think a solution could be:
I patched arch/i386/kernel/cpu/common.c to add a boot option "nox86sep"
similar to "nofxsr" and sure enough the test program dies when booting
with that option:
$ ./test_clone2.ex
SIGSEGV accessing 0x00000000 from EIP 0x00000000
cloned; ret = 621
Your fix for this should work fine.
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#ifdef INT80
# define SYSCALL_STR "int $0x80\n\t"
#else
# define SYSCALL_STR "call 0xffffe400\n\t"
#endif
#define CLONE 120
#define FLAGS 0
unsigned long child_stack[4096] __attribute__((__aligned__(4096)));
unsigned long *child_stack_ptr = &child_stack[2047];
struct sigaction sa;
int ret;
static void handler(int nr, siginfo_t *si, void *vuc)
{
struct ucontext *uc = (struct ucontext *)vuc;
struct sigcontext *sc = (struct sigcontext *)&uc->uc_mcontext;
printf("SIGSEGV accessing 0x%08x from EIP 0x%08x\n",
(unsigned long)si->si_addr, sc->eip);
sa.sa_handler = SIG_DFL;
sa.sa_flags = 0;
sigaction(SIGSEGV, &sa, NULL);
}
int main(int argc, char * const argv[])
{
sa.sa_sigaction = handler;
sa.sa_flags = SA_SIGINFO;
sigaction(SIGSEGV, &sa, NULL);
asm volatile(
SYSCALL_STR
: "=a"(ret)
: "a"(CLONE), "b"(FLAGS), "c"(child_stack_ptr)
: "memory"
);
printf("cloned; ret = %d\n", ret);
_exit(0);
}
--
Chuck
Currently reading: _The Atrocity Archives_ by Charles Stross
next reply other threads:[~2006-01-26 16:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-01-26 16:41 Chuck Ebbert [this message]
-- strict thread matches above, loose matches on Subject: below --
2006-01-26 3:43 Chuck Ebbert
2006-01-26 15:12 ` Daniel fernandez
2006-01-11 17:53 erg0t
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200601261144_MC3-1-B6C2-3A7B@compuserve.com \
--to=76306.1226@compuserve.com \
--cc=akpm@osdl.org \
--cc=ergot86@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=torvalds@osdl.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®