Re: glibc's hurd/fd-read.c

2008-07-22 Thread Thomas Schwinge
Hello!

On Mon, Jul 21, 2008 at 12:50:50PM -0700, Roland McGrath wrote:
 It's bogus, i.e. a violation of Hurd protocols, for an io server to send
 back more data than requested.  But it's possible with a buggy or malicious
 server.  So it is appropriate paranoia on the client side to check for this
 rather than turning it into a buffer overrun.
 
 If this occurs, it's a protocol violation and should not be papered over.

Correct.  Also, because the internal state of the server (current reading
offset) anyway wouldn't be correct anymore.

 So rather than just ignore the extra data, I made it return EGRATUITOUS.
 (This error code means, a Hurd server violated its protocol.)

Shouldn't we nevertheless `vm_deallocate' the memory region?


Regards,
 Thomas


PS: What's the needed make invocation magic to have glibc recreate the
`hurd/RPC*.c' files?  ``make hurd/subdir_lib'' doesn't work for me.


signature.asc
Description: Digital signature


hangs

2008-07-22 Thread Samuel Thibault
It looks like the hangs we're encountering on flubber/gnubber and which
I'm having on the buildd are due to syslog() blocking somewhere.

Samuel




syslog (was: hangs)

2008-07-22 Thread Thomas Schwinge
Hello!

On Tue, Jul 22, 2008 at 02:33:34PM +0100, Samuel Thibault wrote:
 It looks like the hangs we're encountering on flubber/gnubber and which
 I'm having on the buildd are due to syslog() blocking somewhere.

Interesting...


While being at syslog, I can again point to this issue,
http://lists.gnu.org/archive/html/bug-hurd/2007-02/msg00042.html, which
is probably unrelated, but in case someone is going to have a look at the
syslog code/other involved code nevertheless...


Regards,
 Thomas


signature.asc
Description: Digital signature


Gnumach cleanup 11

2008-07-22 Thread Barry deFreese

Hi folks,

Here is another patch that cleans up the makes foo from bar without a 
cast warnings.


I'm a little curious if using (void *)port cast is correct in the calls 
to tty_portdeath()?


I also could use some guidance on these warnings (they all come from 
basically the same call):


../kern/startup.c:297: warning: passing argument 1 of 'kvtophys' makes 
integer from pointer without a cast
../i386/i386/pcb.c:236: warning: passing argument 1 of 'kvtophys' makes 
integer from pointer without a cast
../i386/i386/pcb.c:311: warning: passing argument 1 of 'kvtophys' makes 
integer from pointer without a cast



Also, I am still not fixing anything under linux/*

I haven't included a changelog yet since this will probably need 
reviewed and/or fixed.


Thanks as always,

Barry


? INSTALL
? Makefile.in
? aclocal.m4
? autom4te.cache
? build-aux
? config.h.in
? configure
? doc/mach.info
? doc/mach.info-1
? doc/mach.info-2
? doc/stamp-vti
? doc/version.texi
Index: i386/i386at/com.c
===
RCS file: /sources/hurd/gnumach/i386/i386at/Attic/com.c,v
retrieving revision 1.3.2.6
diff -u -p -r1.3.2.6 com.c
--- i386/i386at/com.c   20 Jul 2008 17:05:37 -  1.3.2.6
+++ i386/i386at/com.c   22 Jul 2008 17:12:39 -
@@ -433,7 +433,7 @@ io_return_t comportdeath(dev, port)
 dev_t  dev;
 mach_port_tport;
 {
-   return (tty_portdeath(com_tty[minor(dev)], port));
+   return (tty_portdeath(com_tty[minor(dev)], (void *)port));
 }
 
 io_return_t
Index: i386/i386at/kd.c
===
RCS file: /sources/hurd/gnumach/i386/i386at/Attic/kd.c,v
retrieving revision 1.5.2.15
diff -u -p -r1.5.2.15 kd.c
--- i386/i386at/kd.c20 Jul 2008 17:05:38 -  1.5.2.15
+++ i386/i386at/kd.c22 Jul 2008 17:12:40 -
@@ -590,7 +590,7 @@ kdportdeath(dev, port)
dev_t   dev;
mach_port_t port;
 {
-   return (tty_portdeath(kd_tty, port));
+   return (tty_portdeath(kd_tty, (void *)port));
 }
 
 /*ARGSUSED*/
Index: i386/i386at/kd_mouse.c
===
RCS file: /sources/hurd/gnumach/i386/i386at/Attic/kd_mouse.c,v
retrieving revision 1.3.2.9
diff -u -p -r1.3.2.9 kd_mouse.c
--- i386/i386at/kd_mouse.c  20 Jul 2008 17:05:38 -  1.3.2.9
+++ i386/i386at/kd_mouse.c  22 Jul 2008 17:12:40 -
@@ -603,7 +603,7 @@ mouse_handle_byte(ch)
mousebuf[mousebufindex++] = ch;
if (mouse_char_wanted) {
mouse_char_wanted = FALSE;
-   wakeup(mousebuf);
+   wakeup((unsigned int)mousebuf);
}
return;
}
Index: i386/i386at/lpr.c
===
RCS file: /sources/hurd/gnumach/i386/i386at/Attic/lpr.c,v
retrieving revision 1.1.1.1.4.10
diff -u -p -r1.1.1.1.4.10 lpr.c
--- i386/i386at/lpr.c   20 Jul 2008 17:05:38 -  1.1.1.1.4.10
+++ i386/i386at/lpr.c   22 Jul 2008 17:12:40 -
@@ -202,7 +202,7 @@ lprportdeath(dev, port)
 dev_t  dev;
 mach_port_tport;
 {
-   return (tty_portdeath(lpr_tty[minor(dev)], port));
+   return (tty_portdeath(lpr_tty[minor(dev)], (void *)port));
 }
 
 io_return_t
Index: i386/intel/pmap.c
===
RCS file: /sources/hurd/gnumach/i386/intel/pmap.c,v
retrieving revision 1.4.2.19
diff -u -p -r1.4.2.19 pmap.c
--- i386/intel/pmap.c   18 Nov 2007 17:33:07 -  1.4.2.19
+++ i386/intel/pmap.c   22 Jul 2008 17:12:41 -
@@ -927,7 +927,7 @@ void pmap_destroy(p)
vm_object_unlock(pmap_object);
}
}
-   kmem_free(kernel_map, p-dirbase, INTEL_PGBYTES);
+   kmem_free(kernel_map, (vm_offset_t)p-dirbase, INTEL_PGBYTES);
zfree(pmap_zone, (vm_offset_t) p);
 }
 
Index: ipc/ipc_kmsg.c
===
RCS file: /sources/hurd/gnumach/ipc/ipc_kmsg.c,v
retrieving revision 1.2.2.11
diff -u -p -r1.2.2.11 ipc_kmsg.c
--- ipc/ipc_kmsg.c  16 Jul 2008 00:51:03 -  1.2.2.11
+++ ipc/ipc_kmsg.c  22 Jul 2008 17:12:41 -
@@ -531,7 +531,7 @@ ipc_kmsg_get(msg, size, kmsgp)
ikm_init(kmsg, size);
}
 
-   if (copyinmsg((char *) msg, (char *) kmsg-ikm_header, size)) {
+   if (copyinmsg((vm_offset_t) msg, (vm_offset_t) kmsg-ikm_header, 
size)) {
ikm_free(kmsg);
return MACH_SEND_INVALID_DATA;
}
@@ -601,7 +601,7 @@ ipc_kmsg_put(msg, kmsg, size)
 
ikm_check_initialized(kmsg, kmsg-ikm_size);
 
-   if (copyoutmsg((char *) kmsg-ikm_header, (char *) msg, size))
+   if (copyoutmsg((vm_offset_t) kmsg-ikm_header, (vm_offset_t) msg, 
size))
mr = MACH_RCV_INVALID_DATA;
else
mr = MACH_MSG_SUCCESS;
Index: ipc/mach_msg.c

Re: glibc's hurd/fd-read.c

2008-07-22 Thread Roland McGrath
 Shouldn't we nevertheless `vm_deallocate' the memory region?

Yes, thanks.




Re: Gnumach cleanup 11

2008-07-22 Thread Samuel Thibault
Barry deFreese, le Tue 22 Jul 2008 13:33:07 -0400, a écrit :
 I'm a little curious if using (void *)port cast is correct in the calls 
 to tty_portdeath()?

Rather cast into the target type instaed, ipc_port_t.

 I also could use some guidance on these warnings (they all come from 
 basically the same call):
 
 ../kern/startup.c:297: warning: passing argument 1 of 'kvtophys' makes 
 integer from pointer without a cast

See inside the PMAP_ACTIVATE_USER macro.

 --- i386/i386at/kd.c  20 Jul 2008 17:05:38 -  1.5.2.15
 +++ i386/i386at/kd.c  22 Jul 2008 17:12:40 -
 @@ -590,7 +590,7 @@ kdportdeath(dev, port)
   dev_t   dev;
   mach_port_t port;
  {
 - return (tty_portdeath(kd_tty, port));
 + return (tty_portdeath(kd_tty, (void *)port));
  }

ditto, same for others.

 --- i386/i386at/kd_mouse.c20 Jul 2008 17:05:38 -  1.3.2.9
 +++ i386/i386at/kd_mouse.c22 Jul 2008 17:12:40 -
 @@ -603,7 +603,7 @@ mouse_handle_byte(ch)
   mousebuf[mousebufindex++] = ch;
   if (mouse_char_wanted) {
   mouse_char_wanted = FALSE;
 - wakeup(mousebuf);
 + wakeup((unsigned int)mousebuf);
   }
   return;
   }

Same principle here, cast into the target type expected by the function,
vm_offset_t.

 --- i386/intel/pmap.c 18 Nov 2007 17:33:07 -  1.4.2.19
 +++ i386/intel/pmap.c 22 Jul 2008 17:12:41 -
 @@ -927,7 +927,7 @@ void pmap_destroy(p)
   vm_object_unlock(pmap_object);
   }
   }
 - kmem_free(kernel_map, p-dirbase, INTEL_PGBYTES);
 + kmem_free(kernel_map, (vm_offset_t)p-dirbase, INTEL_PGBYTES);
   zfree(pmap_zone, (vm_offset_t) p);
  }
  

That one is correct, for instance.

 --- ipc/ipc_kmsg.c16 Jul 2008 00:51:03 -  1.2.2.11
 +++ ipc/ipc_kmsg.c22 Jul 2008 17:12:41 -
 @@ -531,7 +531,7 @@ ipc_kmsg_get(msg, size, kmsgp)
   ikm_init(kmsg, size);
   }
  
 - if (copyinmsg((char *) msg, (char *) kmsg-ikm_header, size)) {
 + if (copyinmsg((vm_offset_t) msg, (vm_offset_t) kmsg-ikm_header, 
 size)) {
   ikm_free(kmsg);
   return MACH_SEND_INVALID_DATA;
   }

Mmm, it'd probably be better to fix the prototype into taking void *
(just like copyin/out), so that you won't need a cast at all., same thing
for copyoutmsg and in ipc/mach_msg.c

 --- kern/bootstrap.c  17 Jul 2008 01:02:01 -  1.12.2.11
 +++ kern/bootstrap.c  22 Jul 2008 17:12:42 -
 @@ -435,7 +435,7 @@ read_exec(void *handle, vm_offset_t file
   if (file_size  0)
   {
   err = copyout((char *)phystokv (mod-mod_start) + file_ofs,
 -   mem_addr, file_size);
 +   (char *)mem_addr, file_size);
   assert(err == 0);
   }
  

Better cast into void * instead.  Casting into char* is actually old C
style.

Samuel




Re: Gnumach cleanup 11

2008-07-22 Thread Barry deFreese
How about this one?

Not too sure about the syntax of the changelog.

Thanks!

Barry deFreese


2008-07-23  Barry deFreese  [EMAIL PROTECTED]

* i386/i386/locore.h (copyinmsg, copyoutmsg): 
Cast parameters as void* rather than vm_offset_t.
* i386/i386at/com.c (comportdeath): Cast port as ipc_port_t in 
tty_portdeath call.
* i386/i386at/kd.c (kdportdeath): Likewise.
* i386/i386at/lpr.c (lprportdeath): Likewise.
* i386/i386at/kd_mouse.c (mouse_handle_byte): Cast param to wakeup() as 
vm_offset_t.
* i386/intel/pmap.c (pmap_destroy): Cast arg 2 of kmem_free() to 
vm_offset_t.
* i386/intel/pmap.h: Cast all arg 1 params to kvtophy() to vm_offset_t.
* ipc/ipc_kmsg.c: Remove casts from params to copyinmsg and 
copyoutmsg calls.
* ipc/mach_msg.c: Likewise.
* kern/exceptions.c: Likewise.
* ipc/mach_msg.c: Remove casts from params to copyout calls.
* ipc/bootstrap.c: Likewise.
* kern/ipc_tt.c (mach_ports_register): Cast memory[i] as ipc_port_t in 
assignment.
? INSTALL
? Makefile.in
? aclocal.m4
? autom4te.cache
? build-aux
? config.h.in
? configure
? doc/mach.info
? doc/mach.info-1
? doc/mach.info-2
? doc/stamp-vti
? doc/version.texi
Index: i386/i386/locore.h
===
RCS file: /sources/hurd/gnumach/i386/i386/Attic/locore.h,v
retrieving revision 1.1.2.3
diff -u -p -r1.1.2.3 locore.h
--- i386/i386/locore.h	20 Dec 2006 21:57:55 -	1.1.2.3
+++ i386/i386/locore.h	23 Jul 2008 04:35:49 -
@@ -26,11 +26,11 @@
 
 extern int copyin (const void *userbuf, void *kernelbuf, size_t cn);
 
-extern int copyinmsg (vm_offset_t userbuf, vm_offset_t kernelbuf, size_t cn);
+extern int copyinmsg (const void *userbuf, void *kernelbuf, size_t cn);
 
 extern int copyout (const void *kernelbuf, void *userbuf, size_t cn);
 
-extern int copyoutmsg (vm_offset_t kernelbuf, vm_offset_t userbuf, size_t cn);
+extern int copyoutmsg (const void *kernelbuf, void *userbuf, size_t cn);
 
 extern int call_continuation (continuation_t continuation);
 
Index: i386/i386at/com.c
===
RCS file: /sources/hurd/gnumach/i386/i386at/Attic/com.c,v
retrieving revision 1.3.2.6
diff -u -p -r1.3.2.6 com.c
--- i386/i386at/com.c	20 Jul 2008 17:05:37 -	1.3.2.6
+++ i386/i386at/com.c	23 Jul 2008 04:35:49 -
@@ -433,7 +433,7 @@ io_return_t comportdeath(dev, port)
 dev_t		dev;
 mach_port_t	port;
 {
-	return (tty_portdeath(com_tty[minor(dev)], port));
+	return (tty_portdeath(com_tty[minor(dev)], (ipc_port_t)port));
 }
 
 io_return_t
Index: i386/i386at/kd.c
===
RCS file: /sources/hurd/gnumach/i386/i386at/Attic/kd.c,v
retrieving revision 1.5.2.15
diff -u -p -r1.5.2.15 kd.c
--- i386/i386at/kd.c	20 Jul 2008 17:05:38 -	1.5.2.15
+++ i386/i386at/kd.c	23 Jul 2008 04:35:50 -
@@ -590,7 +590,7 @@ kdportdeath(dev, port)
 	dev_t	dev;
 	mach_port_t	port;
 {
-	return (tty_portdeath(kd_tty, port));
+	return (tty_portdeath(kd_tty, (ipc_port_t)port));
 }
 
 /*ARGSUSED*/
Index: i386/i386at/kd_mouse.c
===
RCS file: /sources/hurd/gnumach/i386/i386at/Attic/kd_mouse.c,v
retrieving revision 1.3.2.9
diff -u -p -r1.3.2.9 kd_mouse.c
--- i386/i386at/kd_mouse.c	20 Jul 2008 17:05:38 -	1.3.2.9
+++ i386/i386at/kd_mouse.c	23 Jul 2008 04:35:50 -
@@ -603,7 +603,7 @@ mouse_handle_byte(ch)
 	mousebuf[mousebufindex++] = ch;
 	if (mouse_char_wanted) {
 		mouse_char_wanted = FALSE;
-		wakeup(mousebuf);
+		wakeup((vm_offset_t)mousebuf);
 	}
 	return;
 	}
Index: i386/i386at/lpr.c
===
RCS file: /sources/hurd/gnumach/i386/i386at/Attic/lpr.c,v
retrieving revision 1.1.1.1.4.10
diff -u -p -r1.1.1.1.4.10 lpr.c
--- i386/i386at/lpr.c	20 Jul 2008 17:05:38 -	1.1.1.1.4.10
+++ i386/i386at/lpr.c	23 Jul 2008 04:35:50 -
@@ -202,7 +202,7 @@ lprportdeath(dev, port)
 dev_t		dev;
 mach_port_t	port;
 {
-	return (tty_portdeath(lpr_tty[minor(dev)], port));
+	return (tty_portdeath(lpr_tty[minor(dev)], (ipc_port_t)port));
 }
 
 io_return_t
Index: i386/intel/pmap.c
===
RCS file: /sources/hurd/gnumach/i386/intel/pmap.c,v
retrieving revision 1.4.2.19
diff -u -p -r1.4.2.19 pmap.c
--- i386/intel/pmap.c	18 Nov 2007 17:33:07 -	1.4.2.19
+++ i386/intel/pmap.c	23 Jul 2008 04:35:50 -
@@ -927,7 +927,7 @@ void pmap_destroy(p)
 		vm_object_unlock(pmap_object);
 	}
 	}
-	kmem_free(kernel_map, p-dirbase, INTEL_PGBYTES);
+	kmem_free(kernel_map, (vm_offset_t)p-dirbase, INTEL_PGBYTES);
 	zfree(pmap_zone, (vm_offset_t) p);
 }
 
Index: i386/intel/pmap.h
===
RCS file: /sources/hurd/gnumach/i386/intel/pmap.h,v