IRIX 6.5 patch for Compression with UsePrivilegeSeparation
David Kaelbling
drk at sgi.com
Thu Jun 27 08:21:26 EST 2002
Simon Cooper already mailed in a patch to get the effects of MAP_ANON on
IRIX systems, but it was against openssh/3.3p1. I've reapplied his
patach to openssh/3.4p1 and include it as an attachment.
Here's his explanation:
> I noticed that the recent release requires the existence of MAP_ANON to get
> an anonymous memory region. In Irix the equivalent functionality can be
> obtained by mapping the file /dev/zero. This feature is rather obliquely
> documented in the "zero(7)" man page...
>
> Mapping a zero special file creates a zero-initialized unnamed memory
> object of a length equal to the length of the mapping and rounded up to
> the nearest page size as returned by getpagesize(2). Multiple processes
> can share such a zero special file object provided a common ancestor
> mapped the object MAP_SHARED.
>
> I will be fixing our "mmap" documentation to include this useful bit of
> information.
>
> So,
>
> address = mmap(NULL, size, PROT_WRITE|PROT_READ, MAP_ANON|MAP_SHARED,-1,0);
>
> becomes,
>
> fd_zero = open ("/dev/zero", O_RDRW); /* Check missing */
> address = mmap(NULL, size, PROT_WRITE|PROT_READ, MAP_SHARED, fd_zero, 0);
> close (fd_zero)
>
> With this in mind the following diffs will permit openssh-3.3p1 with
> compression and UsePrivilegeSeparation to work on all Irix 6.5 sub versions
> and likely anything since Irix 5.3 (ie 10 years ago!).
David
--
David KAELBLING <drk at sgi.com> Silicon Graphics Computer Systems
1 Cabot Rd, suite 250; Hudson, MA 01749 781.839.2157, fax ...2357
-------------- next part --------------
--- ./config.h.in Wed Jun 26 10:08:19 2002
+++ ../openssh-3.4p1/./config.h.in Wed Jun 26 17:46:01 2002
@@ -358,6 +358,9 @@
/* Define if you have the `mmap' function that supports MAP_ANON|SHARED */
#undef HAVE_MMAP_ANON_SHARED
+/* Define if mmap of /dev/zero gives an anonymous memory region. */
+#undef HAVE_MMAP_DEV_ZERO
+
/* Define if sendmsg()/recvmsg() has problems passing file descriptors */
#undef BROKEN_FD_PASSING
--- ./servconf.c Mon Jun 24 23:22:04 2002
+++ ../openssh-3.4p1/./servconf.c Wed Jun 26 17:54:55 2002
@@ -257,7 +257,7 @@
if (use_privsep == -1)
use_privsep = 1;
-#if !defined(HAVE_MMAP_ANON_SHARED)
+#if !defined(HAVE_MMAP_ANON_SHARED) && !defined(HAVE_MMAP_DEV_ZERO)
if (use_privsep && options->compression == 1) {
error("This platform does not support both privilege "
"separation and compression");
--- ./configure.ac Tue Jun 25 18:35:16 2002
+++ ../openssh-3.4p1/./configure.ac Wed Jun 26 18:18:32 2002
@@ -154,6 +154,7 @@
AC_CHECK_FUNC(jlimit_startjob, [AC_DEFINE(WITH_IRIX_JOBS)])
AC_DEFINE(BROKEN_INET_NTOA)
AC_DEFINE(WITH_ABBREV_NO_TTY)
+ AC_DEFINE(HAVE_MMAP_DEV_ZERO)
;;
*-*-linux*)
no_dev_ptmx=1
--- ./monitor_mm.c Tue Jun 25 20:29:03 2002
+++ ../openssh-3.4p1/./monitor_mm.c Wed Jun 26 17:54:29 2002
@@ -71,6 +71,9 @@
{
void *address;
struct mm_master *mm;
+#if defined(HAVE_MMAP_DEV_ZERO)
+ int fd_zero;
+#endif
if (mmalloc == NULL)
mm = xmalloc(sizeof(struct mm_master));
@@ -84,7 +87,16 @@
*/
mm->mmalloc = mmalloc;
-#ifdef HAVE_MMAP_ANON_SHARED
+#if defined(HAVE_MMAP_DEV_ZERO)
+ fd_zero = open ("/dev/zero", O_RDWR);
+ if (!fd_zero)
+ fatal("open(/dev/zero): %s", strerror(errno));
+ address = mmap(NULL, size, PROT_WRITE|PROT_READ, MAP_SHARED,
+ fd_zero, 0);
+ if (address == MAP_FAILED)
+ fatal("mmap(%lu): %s", (u_long)size, strerror(errno));
+ close (fd_zero);
+#elif defined(HAVE_MMAP_ANON_SHARED)
address = mmap(NULL, size, PROT_WRITE|PROT_READ, MAP_ANON|MAP_SHARED,
-1, 0);
if (address == MAP_FAILED)
@@ -130,7 +142,7 @@
mm_freelist(mm->mmalloc, &mm->rb_free);
mm_freelist(mm->mmalloc, &mm->rb_allocated);
-#ifdef HAVE_MMAP_ANON_SHARED
+#if defined(HAVE_MMAP_ANON_SHARED) || defined(HAVE_MMAP_DEV_ZERO)
if (munmap(mm->address, mm->size) == -1)
fatal("munmap(%p, %lu): %s", mm->address, (u_long)mm->size,
strerror(errno));
--- ./configure Wed Jun 26 10:08:18 2002
+++ ../openssh-3.4p1/./configure Wed Jun 26 18:19:05 2002
@@ -3898,6 +3898,10 @@
#define WITH_ABBREV_NO_TTY 1
_ACEOF
+ cat >>confdefs.h <<\_ACEOF
+#define HAVE_MMAP_DEV_ZERO 1
+_ACEOF
+
;;
*-*-linux*)
no_dev_ptmx=1
More information about the openssh-unix-dev
mailing list