From: Ben Gras Date: Thu, 10 Aug 2006 11:51:11 +0000 (+0000) Subject: . fix for wild store at startup time by calling dev_io without fp X-Git-Tag: v3.1.3~210 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/verify-sign/tz-link.htm?a=commitdiff_plain;h=4539e54d8b27f1acdb4ee9052e03f45ecc7be48a;p=minix.git . fix for wild store at startup time by calling dev_io without fp initialized . fix for writing exactly PIPE_SIZE to a pipe with O_NONBLOCK blocking anyway because of incomplete logic in pipe_check --- diff --git a/servers/fs/device.c b/servers/fs/device.c index 81995c19e..e480eee2a 100644 --- a/servers/fs/device.c +++ b/servers/fs/device.c @@ -427,6 +427,7 @@ int flags; /* special flags, like O_NONBLOCK */ static cp_grant_id_t gids[NR_IOREQS]; int vec_grants = 0, orig_op, safe; void *buf_used; + endpoint_t ioproc; /* Determine task dmap. */ dp = &dmap[(dev >> MAJOR) & BYTE]; @@ -469,8 +470,8 @@ int flags; /* special flags, like O_NONBLOCK */ dev_mess.COUNT = bytes; dev_mess.HIGHPOS = 0; - /* This field will be used if the i/o is suspended. */ - fp->fp_ioproc = dev_mess.IO_ENDPT; + /* This will be used if the i/o is suspended. */ + ioproc = dev_mess.IO_ENDPT; /* Call the task. */ (*dp->dmap_io)(dp->dmap_driver, &dev_mess); @@ -487,10 +488,13 @@ int flags; /* special flags, like O_NONBLOCK */ if(vec_grants > 0) { panic(__FILE__,"SUSPEND on vectored i/o", NO_NUM); } + /* fp is uninitialized at init time. */ + if(!fp) + panic(__FILE__,"SUSPEND on NULL fp", NO_NUM); if (flags & O_NONBLOCK) { /* Not supposed to block. */ dev_mess.m_type = CANCEL; - dev_mess.IO_ENDPT = fp->fp_ioproc; + dev_mess.IO_ENDPT = ioproc; dev_mess.IO_GRANT = (char *) gid; /* This R_BIT/W_BIT check taken from suspend()/unpause() @@ -507,6 +511,7 @@ int flags; /* special flags, like O_NONBLOCK */ suspend(dp->dmap_driver); assert(!GRANT_VALID(fp->fp_grant)); fp->fp_grant = gid; /* revoke this when unsuspended. */ + fp->fp_ioproc = ioproc; return(SUSPEND); } } diff --git a/servers/fs/pipe.c b/servers/fs/pipe.c index 790e7c7c3..57a8ebb1c 100644 --- a/servers/fs/pipe.c +++ b/servers/fs/pipe.c @@ -139,7 +139,7 @@ int notouch; /* check only */ if (position + bytes > PIPE_SIZE(rip->i_sp->s_block_size)) { if ((oflags & O_NONBLOCK) - && bytes < PIPE_SIZE(rip->i_sp->s_block_size)) + && bytes <= PIPE_SIZE(rip->i_sp->s_block_size)) return(EAGAIN); else if ((oflags & O_NONBLOCK) && bytes > PIPE_SIZE(rip->i_sp->s_block_size)) {