netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Andy Lutomirski <luto@MIT.EDU>
Cc: Matt Helsley <matthltc@us.ibm.com>,
	Pavel Emelyanov <xemul@parallels.com>,
	Nathan Lynch <ntl@pobox.com>, Oren Laadan <orenl@cs.columbia.edu>,
	Daniel Lezcano <dlezcano@fr.ibm.com>,
	S@mit.edu, "James E.J. Bottomley" <JBottomley@parallels.com>,
	"David S. Miller" <davem@davemloft.net>,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [EXAMPLE CODE] Parasite thread injection and TCP connection hijacking
Date: Sat, 6 Aug 2011 15:00:37 +0200	[thread overview]
Message-ID: <20110806130037.GD23937@htj.dyndns.org> (raw)
In-Reply-To: <4E3D3768.3070108@mit.edu>

Hello,

On Sat, Aug 06, 2011 at 08:45:28AM -0400, Andy Lutomirski wrote:
> > 2. Decide where to inject the foreign code and save the original code
> >    with PTRACE_PEEKDATA.  Tracer can poke any mapped area regardless
> >    of protection flags but it can't add execution permission to the
> >    code, so it needs to choose memory area which already has X flag
> >    set.  The example code uses the page the %rip is in.
> 
> If the process is executing from the vsyscall page, then you'll
> probably fail.  (Admittedly, this is rather unlikely, given that the
> vsyscalls are now exactly one instruction.)  Presumably you also
> fail if executing from a read-only MAP_SHARED mapping.

Heh, yeah, I originally thought about scanning /proc/PID/maps to look
for the page to use but was lazy and just used %rip.  I think that
should work.  I'll note the problem in README.

> Windows has a facility to more-or-less call mmap on behalf of
> another process, and another one to directly inject a thread into a
> remote process.  It's traditional to use them for this type of
> manipulation. Perhaps Linux should get the same thing.  (Although
> you could accomplish much the same thing if you could create a task
> with your mm but the tracee's fs.)

Actually, the only thing we need on x86_64 is two bytes for the
syscall instruction because all params are passed through registers
anyway.  We can just set up parameters for mmap, turn on single step,
point %rip to syscall in the vsyscall page.  So, either way, I don't
think this would be too difficult to solve.

Thanks.

-- 
tejun

  reply	other threads:[~2011-08-06 13:00 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-06 12:12 [EXAMPLE CODE] Parasite thread injection and TCP connection hijacking Tejun Heo
2011-08-06 12:45 ` Andy Lutomirski
2011-08-06 13:00   ` Tejun Heo [this message]
2011-08-06 13:15     ` Andrew Lutomirski
2011-08-06 13:20       ` Tejun Heo
2011-08-08 10:20     ` Tejun Heo
2011-10-30  4:48 ` hiberante hangs TCP " David Fries
2011-10-30 20:16   ` Tejun Heo
2011-10-30 20:43     ` David Fries
2011-11-02  9:44     ` MyungJoo Ham
2011-11-02 15:10       ` Tejun Heo
2012-02-17 19:28         ` Pavel Machek

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=20110806130037.GD23937@htj.dyndns.org \
    --to=tj@kernel.org \
    --cc=JBottomley@parallels.com \
    --cc=S@mit.edu \
    --cc=davem@davemloft.net \
    --cc=dlezcano@fr.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@MIT.EDU \
    --cc=matthltc@us.ibm.com \
    --cc=netdev@vger.kernel.org \
    --cc=ntl@pobox.com \
    --cc=orenl@cs.columbia.edu \
    --cc=xemul@parallels.com \
    /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;
as well as URLs for NNTP newsgroup(s).