From owner-freebsd-hackers@FreeBSD.ORG Sat Aug 18 10:26:39 2007 Return-Path: Delivered-To: hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4A2E816A421 for ; Sat, 18 Aug 2007 10:26:39 +0000 (UTC) (envelope-from yuriy.tsibizov@gmail.com) Received: from wx-out-0506.google.com (wx-out-0506.google.com [66.249.82.235]) by mx1.freebsd.org (Postfix) with ESMTP id 0AC8013C428 for ; Sat, 18 Aug 2007 10:26:38 +0000 (UTC) (envelope-from yuriy.tsibizov@gmail.com) Received: by wx-out-0506.google.com with SMTP id i29so669593wxd for ; Sat, 18 Aug 2007 03:26:38 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type; b=WZoZ8gzPUcFnIwZh3DxK42kAtGuGLcJB8nJxuJi7YtsZORCcqDHnE/0Tf51uwMU8g6wiEJiDgBFgW7EG0VU554ZrUfUK0JKJx5omkWccY2vhYg2K9PNNERgQk5AIuyxwmLtTCTEzICLQ0467d2XwDu+H4xf9B0Ph2DvZOFe5NN8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:mime-version:content-type; b=qqnPh0YghMh/CBjyOjA4v0jWQ+HiNGUtYOa33G/iTPmni5pRk+jYTOs2r7fU3H4N8MXWW+Lm0BWZI9IP2tv+3zlJQV6nqh8gOGnPL++dcAgr4/fl+8xc6kdT26lsUTTCCZh8VvoGPM4Q/x2tvE+ynlCG96d/eWwOrHfxGDtxz7Y= Received: by 10.90.81.14 with SMTP id e14mr5672001agb.1187431286248; Sat, 18 Aug 2007 03:01:26 -0700 (PDT) Received: by 10.90.84.15 with HTTP; Sat, 18 Aug 2007 03:01:26 -0700 (PDT) Message-ID: Date: Sat, 18 Aug 2007 14:01:26 +0400 From: "Yuriy Tsibizov" To: hackers@freebsd.org MIME-Version: 1.0 X-Mailman-Approved-At: Sat, 18 Aug 2007 11:31:30 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: Subject: modify syscall nr on-the-fly X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 18 Aug 2007 10:26:39 -0000 I'm trying to get user-mode Linux to run under FreeBSD Linux emulation (on i386). User-mode Linux in it's start-up tests tries to modify syscall number (to be called by kernel) on-the-fly (http://fxr.watson.org/fxr/source/arch/um/os-Linux/start_up.c?v=linux-2.6). It forks a child thread that stops (using SIGSTOP), calls getpid() (that will be intercepted by parent thread using PTRACE_SYSCALL) and return some value based on getpid() results. Main thread waits for SIGSTOP in child process and enables PTRACE_SYSCALL (I have some code that implements it. It makes some incompatible changes to PT_SYSCALL that will break FreeBSD applications, but works for Linux apps). When main thread catches SIGTRAP (generated by ptrace) it tries to modify EAX of child thread (with PTRACE_PEEKUSR and PTRACE_POKEUSR) to replace getpid syscall with getppid. is it possible to get updated EAX (and other registers as well) in syscall(...) after ptracestop(...) in PTRACESTOP_SC(...) returns? Hope for your help, Yuriy.