All of lore.kernel.org
 help / color / mirror / Atom feed
From: Timo Benk <t_benk@web.de>
To: linux-kernel <linux-kernel@vger.kernel.org>
Cc: Timo Benk <t_benk@web.de>
Subject: Re: allocate memory in userspace
Date: Tue, 2 Jul 2002 12:21:55 +0200	[thread overview]
Message-ID: <20020702102155.GA9965@toshiba> (raw)
In-Reply-To: <p73vg7ywk79.fsf@oldwotan.suse.de>

On Tue, Jul 02, 2002 at 11:30:34AM +0200, Andi Kleen wrote:
> Timo Benk <t_benk@web.de> writes:
> 
> > I am a kernel newbie and i am writing a module. I 
> > need to allocate some memory in userspace because
> > i want to access syscalls like open(), lstat() etc.
> > I need to call these methods in the kernel, and in
> > my special case there is no other way, but i 
> > do not want to reimplement all the syscalls.
> > 
> > I read that it should be possible, but i cannot
> > find any example or recipe on how to do it.
> 
> mm_segment_t oldfs = get_fs(); 
> set_fs(KERNEL_DS); 
> ret = sys_yoursyscall(kernelargs ...) 
> set_fs(oldfs); 
Thank you very much for that hint.

> Do not even think about using mmap or accessing sys_call_table for this.
> Your other post was so tasteless that it would be good if you retracted
> it with a followup because it would be very bad to have such an bad example 
> in the l-k archives open to innocent search machine users uncommented.
I will post a followup, but please tell me
a) a good doc for that topic where i can read why it is so bad
b) a reference for the do_mmap call

While searching through the ng archives i just found (lots of) hints
that this can be done with mmap, so that was my approach to solve
the problem.

Maybe it will be better that you (or any other) will comment what
is so bad, as i told in my first post i am a newbie, so please keep
that in mind.

-timo

-- 
gpg key fingerprint = 6832 C8EC D823 4059 0CD1  6FBF 9383 7DBD 109E 98DC


  reply	other threads:[~2002-07-02 10:20 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20020701172659.GA4431@toshiba.suse.lists.linux.kernel>
2002-07-02  9:30 ` allocate memory in userspace Andi Kleen
2002-07-02 10:21   ` Timo Benk [this message]
2002-07-01 17:26 Timo Benk
2002-07-01 17:49 ` Erik Andersen
2002-07-02  8:37   ` William Lee Irwin III
2002-07-02  8:44     ` William Lee Irwin III
2002-07-02  9:00       ` Erik Andersen
2002-07-01 18:39 ` Calin A. Culianu
2002-07-02 12:19 ` Brian Gerst

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=20020702102155.GA9965@toshiba \
    --to=t_benk@web.de \
    --cc=linux-kernel@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.