here's a patch to 3.3p1 for Solaris 2.6 - it does not handle
mmap() with fd = -1. does it look okay?
itojun
--- work.i386/openssh-3.3p1/servconf.c- Tue Jun 25 23:43:22 2002
+++ work.i386/openssh-3.3p1/servconf.c Tue Jun 25 23:43:33 2002
@@ -257,7 +257,7 @@
if (use_privsep == -1)
use_privsep = 1;
-#if !defined(HAVE_MMAP) || !defined(MAP_ANON)
+#if !defined(HAVE_MMAP)
if (use_privsep && options->compression == 1) {
error("This platform does not support both privilege "
"separation and compression");
--- work.i386/openssh-3.3p1/monitor_mm.c- Tue Jun 25 23:42:02 2002
+++ work.i386/openssh-3.3p1/monitor_mm.c Tue Jun 25 23:43:11 2002
@@ -71,6 +71,9 @@
{
void *address;
struct mm_master *mm;
+#if defined(HAVE_MMAP) && !defined(MAP_ANON)
+ int fd;
+#endif
if (mmalloc == NULL)
mm = xmalloc(sizeof(struct mm_master));
@@ -87,6 +90,13 @@
#if defined(HAVE_MMAP) && defined(MAP_ANON)
address = mmap(NULL, size, PROT_WRITE|PROT_READ, MAP_ANON|MAP_SHARED,
-1, 0);
+ if (address == MAP_FAILED)
+ fatal("mmap(%lu): %s", (u_long)size, strerror(errno));
+#elif defined(HAVE_MMAP) && !defined(MAP_ANON)
+ fd = open("/dev/zero", O_RDWR);
+ address = mmap(NULL, size, PROT_WRITE|PROT_READ, MAP_ANON|MAP_SHARED,
+ fd, 0);
+ close(fd);
if (address == MAP_FAILED)
fatal("mmap(%lu): %s", (u_long)size, strerror(errno));
#else
On Tue, Jun 25, 2002 at 11:52:53PM +0900, Jun-ichiro itojun Hagino wrote:> here's a patch to 3.3p1 for Solaris 2.6 - it does not handle > mmap() with fd = -1. does it look okay?That looks good. Any reason why you do not check the open result, too. I mean I know mmap is going to fail with an invalid fd, but still. Niels.
At Tue, 25 Jun 2002 23:52:53 +0900, Jun-ichiro itojun Hagino wrote:> > here's a patch to 3.3p1 for Solaris 2.6 - it does not handle > mmap() with fd = -1. does it look okay?If open() fails, mmap() should fail because of an invalid file descriptor. So I think retval check of open() can be omitted. I'm not perfectly sure this usage of /dev/zero is correct, although comments in NetBSD's sys/uvm/uvm_mmap.c suggests so.> @@ -87,6 +90,13 @@ > #if defined(HAVE_MMAP) && defined(MAP_ANON) > address = mmap(NULL, size, PROT_WRITE|PROT_READ, MAP_ANON|MAP_SHARED, > -1, 0); > + if (address == MAP_FAILED) > + fatal("mmap(%lu): %s", (u_long)size, strerror(errno)); > +#elif defined(HAVE_MMAP) && !defined(MAP_ANON) > + fd = open("/dev/zero", O_RDWR); > + address = mmap(NULL, size, PROT_WRITE|PROT_READ, MAP_ANON|MAP_SHARED, > + fd, 0);This should be as follows, because MAP_ANON isn't defined. + address = mmap(NULL, size, PROT_WRITE|PROT_READ, MAP_SHARED, + fd, 0);> + close(fd); > if (address == MAP_FAILED) > fatal("mmap(%lu): %s", (u_long)size, strerror(errno)); > #else-- IWAMOTO Toshihiro
Hi! On Tue, Jun 25, 2002 at 11:52:53PM +0900, Jun-ichiro itojun Hagino wrote:> here's a patch to 3.3p1 for Solaris 2.6 - it does not handle > mmap() with fd = -1. does it look okay?Strange thing is that here 3.3p1 works out of the box on Solaris 2.6. What problems did you encounter? Ciao Thomas