9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Jason Catena <jason.catena@gmail.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: Re: [9fans] remedial sources auth, connect, and mount in plan9port
Date: Thu,  1 Oct 2009 22:03:21 -0500	[thread overview]
Message-ID: <d50d7d460910012003h6aec0d3bj40ebdadac3358b6a@mail.gmail.com> (raw)
In-Reply-To: <dd6bcde962f47a2d6b1450158a66262c@ladd.quanstro.net>

On Thu, Oct 1, 2009 at 11:22, erik quanstrom <quanstro@quanstro.net> wrote:
>> Every time I do so, either with touch or  chmod for example, I get
>> errors like this:
>>
>> Oct  1 08:52:39.288 read bad packet from 5
>
> add some debugging to 9pserve.c around 'read bad packet'.
> i'm gonna guess (since i don't have time to get p9p auth
> working) that this test has failed src/lib9/convM2S.c:216,217
>
> - erik

I instrumented the code as you suggested.

/usr/local/plan9/src/cmd/9pserve.c:
Msg*
mread9p(Ioproc *io, int fd, int dotu)
{
	int n, nn;
	uchar *pkt;
	Msg *m;

	if((pkt = read9ppkt(io, fd)) == nil)
		return nil;

	m = msgnew(0);
	m->tpkt = pkt;
	n = GBIT32(pkt);
	nn = convM2Su(pkt, n, &m->tx, dotu);
	if(nn != n){
		fprint(2, "%T read bad packet from %d\n", fd);
		fprint(2, "n=%d nn=%d\n", n, nn);
		return nil;
	}
	return m;
}

/usr/local/plan9/src/lib9/convM2S.c:
uint
convM2Su(uchar *ap, uint nap, Fcall *f, int dotu)
{
/* snip */
	case Twstat:
		if(p+BIT32SZ+BIT16SZ > ep)
			return 0;
		f->fid = GBIT32(p);
		p += BIT32SZ;
		f->nstat = GBIT16(p);
		p += BIT16SZ;
		if(p+f->nstat > ep) {
			fprint(2, "erik is the man! p(%x)+f->nstat(%x) > ep(%x)", p, f->nstat, ep);
			return 0;
		}
		f->stat = p;
		p += f->nstat;
		break;
/* snip */
}

My test case tries to copy a file over top of one that already exists.
 In this case, the bug decided to flit right by the check at
convM2S.c:216,217.

jdc@jdc-desktop:~$ 9 factotum
jdc@jdc-desktop:~$ srv -a sources.cs.bell-labs.com

!adding key: role=client proto=p9sk1 dom=outside.plan9.bell-labs.com
user[jdc]: catenate
password:
!
jdc@jdc-desktop:~$ sudo 9mount -i
'unix!/tmp/ns.jdc.192.168.1.101:0/sources.cs.bell-labs.com' /n/sources
[sudo] password for jdc:
9mount: mount: Not a directory
jdc@jdc-desktop:~$ ls /n/sources
/n/sources
jdc@jdc-desktop:~$ sudo 9umount /n/sources
jdc@jdc-desktop:~$ sudo 9mount -i
'unix!/tmp/ns.jdc.192.168.1.101:0/sources.cs.bell-labs.com' /n/sources
jdc@jdc-desktop:~$ ps ax|grep 9ps
10426 pts/3    Sl     0:00 9pserve -u unix!/tmp/ns.jdc.192.168.1.101:0/factotum
10586 pts/3    Sl     0:00 9pserve -u -M 8192 -A  0
unix!/tmp/ns.jdc.192.168.1.101:0/sources.cs.bell-labs.com
10603 pts/3    R+     0:00 grep 9ps
jdc@jdc-desktop:~$ cd /n/sources/contrib/catenate
jdc@jdc-desktop:/n/sources/contrib/catenate$ cd times
jdc@jdc-desktop:/n/sources/contrib/catenate/times$ ls
latin1.7a.font
jdc@jdc-desktop:/n/sources/contrib/catenate/times$ ls ~/contrib
acme  guide  latin1.7a.font
jdc@jdc-desktop:/n/sources/contrib/catenate/times$ sudo cp
/home/jdc/contrib/latin1.7a.font .
Oct  1 21:52:45.219 read bad packet from 6
n=62 nn=0
cp: cannot create regular file `./latin1.7a.font': Connection reset by peer

Jason Catena



  reply	other threads:[~2009-10-02  3:03 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <<d50d7d460910010834r40c926barbc3dedd5828f3bd1@mail.gmail.com>
2009-10-01 16:22 ` erik quanstrom
2009-10-02  3:03   ` Jason Catena [this message]
     [not found] <<d50d7d460910012003h6aec0d3bj40ebdadac3358b6a@mail.gmail.com>
2009-10-02  3:11 ` erik quanstrom
2009-10-02 16:52   ` Jason Catena
2009-10-01  5:06 Jason Catena
2009-10-01  7:44 ` Venkatesh Srinivas
2009-10-01  9:50   ` Jason Catena
2009-10-01 10:04     ` Ethan Grammatikidis
2009-10-01 10:31       ` sqweek
2009-10-01 12:38         ` Abhishek Kulkarni
2009-10-01 15:34         ` Jason Catena

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=d50d7d460910012003h6aec0d3bj40ebdadac3358b6a@mail.gmail.com \
    --to=jason.catena@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).