From sacadmin Wed Aug 29 13:48:26 2007
Received: from sac.sfbay.sun.com (localhost [127.0.0.1])
	by sac.sfbay.sun.com (8.13.8+Sun/8.13.8) with ESMTP id l7TKmPeb025055;
	Wed, 29 Aug 2007 13:48:25 -0700 (PDT)
Received: (from alanc@localhost)
	by sac.sfbay.sun.com (8.13.8+Sun/8.13.8/Submit) id l7TKmPga025051;
	Wed, 29 Aug 2007 13:48:25 -0700 (PDT)
Date: Wed, 29 Aug 2007 13:48:25 -0700 (PDT)
From: Alan Coopersmith <alanc@sac.sfbay.sun.com>
Message-Id: <200708292048.l7TKmPga025051@sac.sfbay.sun.com>
To: PSARC-record@sac.sfbay.sun.com
Cc: Alan.Coopersmith@Sun.COM
Subject: X11 MIT-SHM Extension across zones [PSARC/2007/500 FastTrack]
Status: RO
Content-Length: 572


Template Version: @(#)sac_nextcase 1.64 07/13/07 SMI
This information is Copyright 2007 Sun Microsystems
1. Introduction
    1.1. Project/Component Working Name:
	 X11 MIT-SHM Extension across zones
    1.2. Name of Document Author/Supplier:
	 Author:  Alan Coopersmith
    1.3  Date of This Document:
	29 August, 2007
4. Technical Description
    See the case directory for more detail

6. Resources and Schedule
    6.4. Steering Committee requested information
   	6.4.1. Consolidation C-team Name:
		X
    6.5. ARC review type: FastTrack
    6.6. ARC Exposure: open


From alan.coopersmith@sun.com Thu Sep  6 14:40:58 2007
Received: from sunmail4.Singapore.Sun.COM (sunmail4.Singapore.Sun.COM [129.158.71.19])
	by sac.sfbay.sun.com (8.13.8+Sun/8.13.8) with ESMTP id l86Lev7H008241
	for <psarc-ext@sac.sfbay.Sun.COM>; Thu, 6 Sep 2007 14:40:57 -0700 (PDT)
Received: from nwk-avmta-2.sfbay.sun.com (nwk-avmta-2.SFBay.Sun.COM [129.145.155.6])
	by sunmail4.Singapore.Sun.COM (8.13.4+Sun/8.13.3/ENSMAIL,v2.2) with ESMTP id l86Lc8j6012408;
	Fri, 7 Sep 2007 05:38:09 +0800 (SGT)
Received: from pmxchannel-daemon.nwk-avmta-2.sfbay.sun.com by
 nwk-avmta-2.sfbay.sun.com
 (Sun Java System Messaging Server 6.2-3.04 (built Jul 15 2005))
 id <0JNY00705URK0A00@nwk-avmta-2.sfbay.sun.com>; Thu,
 06 Sep 2007 14:38:08 -0700 (PDT)
Received: from jurassic.eng.sun.com ([129.146.104.45])
 by nwk-avmta-2.sfbay.sun.com
 (Sun Java System Messaging Server 6.2-3.04 (built Jul 15 2005))
 with ESMTP id <0JNY000UGURJ3B70@nwk-avmta-2.sfbay.sun.com>; Thu,
 06 Sep 2007 14:38:08 -0700 (PDT)
Received: from [129.146.108.211] (almas.SFBay.Sun.COM [129.146.108.211])
	by jurassic.eng.sun.com (8.13.8+Sun/8.13.8) with ESMTP id l86Lc7EF981623; Thu,
 06 Sep 2007 14:38:07 -0700 (PDT)
Date: Thu, 06 Sep 2007 14:38:07 -0700
From: Alan Coopersmith <alan.coopersmith@sun.com>
Subject: X11 MIT-SHM Extension across zones [PSARC 2007/500,
 fast-track timeout 9/13/07]
To: PSARC-EXT@sun.com
Cc: Glenn Faden <Glenn.Faden@sun.com>
Message-id: <46E0733F.7030209@sun.com>
MIME-version: 1.0
Content-type: text/plain; charset=ISO-8859-1
Content-transfer-encoding: 7BIT
X-PMX-Version: 5.2.0.264296
X-Enigmail-Version: 0.95.1
User-Agent: Thunderbird 2.0.0.4 (X11/20070731)
Status: RO
Content-Length: 3906

I am sponsoring this fasttrack for myself, and have set the timeout to
Thursday, Sept. 13.   It requests a patch release binding.

This project enhances the X server to allow the MIT-SHM extension to operate
between clients in non-global zones and the X server in the global zone.

The MIT-SHM extension uses SysV shared memory to transport pixmaps between X
clients and X servers without having to write them to the socket or pipe and
read them back out.   The current Solaris implementation contains two
impediments blocking use of this extension between different zones on the same
system.

1) access control check in X servers

   Since the X client tells the X server what shared memory segment it
   has created for the pixmap and the X server attachs to it with its
   privilege level/uid (which is usually higher than the client's and
   often at least different from the client), the X server first
   verifies the client isn't asking it to connect to a segment the client
   shouldn't have access to.  It uses getpeerucred() to get the client
   credentials, and shmctl() to get the ownership and permissions of
   the shared memory segment and compares to make sure the credentials
   returned by shmctl should be able to perform the requested access
   (depending on the operation, either read-only or read-write), If
   getpeerucred() fails, or if the zoneid returned by getpeerucred
   does not match the zone returned by getzoneid(), access will only
   be allowed if the shared memory segment may be read (and if needed,
   written) by "other".

   This project modifies the check so that instead of requiring the client
   zoneid to match the X server's, it uses the shmctl64() function to get the
   zoneid that created the shared memory segment and compares the client's
   zone to that zone.   If that matches, then the clients uid & gid may be
   used to verify access, otherwise the client will still be restricted to
   shared memory segments using the "other" access permissions.

   Since shmctl64() is a Project Private function in libc, this project
   includes a contract between the X team and the Zones team allowing
   cross-consolidation use of this interface.

2) XShmQueryExtension() in libXext

   To avoid telling clients they can use MIT-SHM when the connection to the
   Xserver is remote, XShmQueryExtension() in libXext returns False if it
   believes the X server is on another machine.   The current algorithm
   used is:
        if stat(display_connection) returns a mode of S_IFIFO
           connection is local
        else
           getpeername(display_connection)
           if socket_family is AF_UNIX
              connection is local
           else
              for each local interface returned by SIOCGLIFCONF ioctl
                  if address == peer socket address
                     connection is local
   and if none of those find the connection is local, the function reports
   that MIT-SHM is not connected.

   This project greatly simplifies the above algorithm to a single check:

        if getpeerucred(display_connection) == 0 && ucred_getzoneid() != -1
           connection is local
        else
           connection is remote


Interfaces Imported:
====================

Interface:              Stability:                      Definition/Comments:
------------------------------------------------------------------------------
shmctl64()              Contracted Project Private      [1], [2]
getpeerucred()          Evolving                        PSARC 2003/197,
                                                          PSARC 2004/336

Interfaces Exported:
====================

no new interfaces exported

References:
[1] shmctl64.txt in case materials directory
[2] contract-01.txt in case materials directory

-- 
	-Alan Coopersmith-           alan.coopersmith@sun.com
	 Sun Microsystems, Inc. - X Window System Engineering


