9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: John Floren <slawmaster@gmail.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: Re: [9fans] Streaming 9P is out
Date: Sat,  8 Jan 2011 16:46:10 -0800	[thread overview]
Message-ID: <AANLkTi=y4W7OdBSOxBnmnfuE4FOYr4NUv7n2dEXiAJgS@mail.gmail.com> (raw)
In-Reply-To: <cf7dc7b2bfcb571d91e797d4956f0c01@gmx.de>

On Sat, Jan 8, 2011 at 4:31 PM,  <cinap_lenrek@gmx.de> wrote:
> the use of tcp to get flow control is an interesting idea.
>
> some remaks:
>
> the client only gets the dial string of a new tcp connection.  an
> attacker could guess the port numbers and take over the stream.  or
> the client might be delayed before it makes the dial() causing it to
> get the wrong stream or some other random tcp connection at the same
> port.
>
> the initial 9p channel might be encrypted (common when you use
> cpu), but the stream data excapes as cleartext... compromising security.
>

I had thought about the security problem. I acknowledge that it's
possible for an attacker to guess the port, but he has to guess in
that small time frame between when the server opens the port and the
client connects. I haven't heard of FTP having problems with that,
though.

And, of course, if you encrypt the streaming data, it doesn't matter
if an attacker guesses the port.


> on the implementation, the server might give the wrong ip address
> (because he is behind some nat gateway) causing the dial to fail. i think
> the stream() call should fallback to the original filedescriptor then.

I had considered this case (the server doesn't know which IP to give)
but managed to forget to include the simple check "did dial fail?"


> why do we pass the offset and mode in the pstream syscall?  devmnt
> should know the current offset and mode from the Chan structure right?
>
> i think you could simplify the userspace interface a little bit
> further.  for example, i see no use for the Stream structure and
> sread/swrite as they never fall back on the old filedescriptor and all
> the decisions are already made in the stream() call (except the
> isread check).
>
> what about this:
>
> newfd = stream(oldfd, ....);
>
> int
> stream(int fd, vlong offset, char isread)
> {
>        for(;;){
>                char addr[Maxstring];
>                int r;
>
>                if((r = pstream(fd, addr, offset, isread)) < 0)
>                        break;
>                if(addr[0] == 0)
>                        break;
>                if((r = dial(addr, 0, 0, 0)) < 0)
>                        break;
>
>                return r;
>        }
>
>        /* server doesnt support Tstream */
>        if((fd = dup(fd, -1)) >= 0)
>                seek(fd, offset, 0);
>        return fd;
> }
>

This ought to work, but I wanted to establish a difference between
regular fds, which you can read and write and seek and all that
goodness, and streams, which are for reading OR writing sequentially.
I also wanted to give an error if you tried to read from a write
stream and vice versa; your stream() doesn't seem to do that.


Like I said, it's not perfect, and there's probably a better way to do it.

John



  reply	other threads:[~2011-01-09  0:46 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-08  7:24 John Floren
2011-01-08 10:45 ` Seed
2011-01-08 13:11   ` Bruce Ellis
2011-01-08 15:16 ` David Leimbach
2011-01-09  0:31 ` cinap_lenrek
2011-01-09  0:46   ` John Floren [this message]
2011-01-09  1:05     ` erik quanstrom
2011-01-09  1:53     ` cinap_lenrek
2011-01-09  2:24       ` Lyndon Nerenberg (VE6BBM/VE7TFX)
2011-01-09  2:42         ` ron minnich
2011-01-09  1:58     ` cinap_lenrek

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='AANLkTi=y4W7OdBSOxBnmnfuE4FOYr4NUv7n2dEXiAJgS@mail.gmail.com' \
    --to=slawmaster@gmail.com \
    --cc=9fans@9fans.net \
    /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).