public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Nick Andrew <nick@nick-andrew.net>
To: Geoffrey McRae <geoff@rabidhost.com>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>, linux-kernel@vger.kernel.org
Subject: Re: New Security Features, Please Comment
Date: Wed, 3 Dec 2008 23:42:52 +1100	[thread overview]
Message-ID: <20081203124252.GD11807@mail.local.tull.net> (raw)
In-Reply-To: <1228268657.6679.4.camel@lappy.spacevs.com>

On Wed, Dec 03, 2008 at 12:44:17PM +1100, Geoffrey McRae wrote:
> On Wed, 2008-12-03 at 00:53 +0000, Alan Cox wrote:
> > > (such as PHP) as the user that owns the website we are forced to fork a
> > > new process per request, then call setuid/gid and then launch the script
> > > language. This ofcource is resource intensive, but at present there is
> > > no other solution.

[...]

> But once this set is introduced a HTTP server could be written that uses
> forked children to handle requests, that have their identity swtiched
> before doing any work, including parsing CGI scripts.

I think we can do that already, using FastCGI.

As I understand it, the traditional CGI server system call flow is:

   accept
   fork
    \ setuid(user)
      exec(cgi script)

And I don't see how your 4 extra system calls would improve that flow.

The FastCGI flow is:

   setuid(user)
   exec(fastcgi script)
   loop receiving requests over a pipe and processing

In this case the handling process has already been forked and exec'ed
so the time-consuming work is done once and the script can then get
on with the business of processing requests as quickly as possible.

I'm sure there are other execution models where the CGI processors
are pre-forked. Executing the CGI script (e.g. through a scripting
language) is presumably the most expensive operation, and doing that
in advance won't be useful if you have large numbers of distinct users
but they won't all be running CGIs all the time. In other words, if you
had 300,000 users and 1 CGI script being run, you won't want to pre-fork
300,000 processes each with a different uid. But if you had 300,000
users and 200,000 different CGI scripts, you also have no choice but
to fork and exec at request time, because there are too many different
scripts.

Nick.

  parent reply	other threads:[~2008-12-03 12:49 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-02 23:28 New Security Features, Please Comment Geoffrey McRae
2008-12-03  0:24 ` Geoffrey McRae
2008-12-03  0:53 ` Alan Cox
2008-12-03  1:44   ` Geoffrey McRae
2008-12-03  2:11     ` David Newall
2008-12-03  2:55     ` Valdis.Kletnieks
2008-12-03  4:02       ` Geoffrey McRae
2008-12-03  4:35         ` Peter Teoh
2008-12-03  5:02           ` Geoffrey McRae
2008-12-03  6:54             ` David Newall
2008-12-03 10:29     ` Alan Cox
2008-12-03 12:42     ` Nick Andrew [this message]
2008-12-03 12:46       ` Alan Cox
2008-12-03 22:44       ` Geoffrey McRae
2008-12-03 23:08         ` Alan Cox
2008-12-03 23:27           ` Peter Teoh
2008-12-03 23:40             ` Geoffrey McRae
2008-12-04 21:56               ` Valdis.Kletnieks
2008-12-04 22:30                 ` Geoffrey McRae
2008-12-05  3:35                   ` Valdis.Kletnieks
2008-12-05  3:44                     ` Nick Andrew
2008-12-05  3:50                     ` Geoffrey McRae
2008-12-05  4:03                       ` Valdis.Kletnieks
2008-12-03 23:39           ` Miquel van Smoorenburg
2008-12-04  0:00             ` Geoffrey McRae
2008-12-04  0:22               ` Peter Teoh
2008-12-04  0:08             ` Alan Cox

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=20081203124252.GD11807@mail.local.tull.net \
    --to=nick@nick-andrew.net \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=geoff@rabidhost.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox