[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#538248: child processes inherit the listening sockets opened by xsm



Could you discuss this with the upstream developers by opening a bug
report at bugzilla.freedesktop.org ?

Brice



Kalle Olavi Niemitalo wrote:
> Package: libice6
> Version: 2:1.0.5-1
> Severity: normal
> Tags: patch
>
> I'm using Debian sources but not Debian binaries.
>
> When I run xsm (x11-session-utils 7.3+1) from ~/.xsession,
> it creates several sockets and listens to them.  The file
> descriptors it opens for these sockets get pointlessly inherited
> by child processes, causing warnings from LVM2 utilities.
> xsm should make the file descriptors close on exec.
>
> $ ls -l /proc/$$/fd
> total 0
> lrwx------ 1 Kalle Kalle 64 Jul 24 13:38 0 -> /dev/pts/8
> lrwx------ 1 Kalle Kalle 64 Jul 24 13:38 1 -> /dev/pts/8
> lrwx------ 1 Kalle Kalle 64 Jul 24 13:38 10 -> /dev/tty
> lrwx------ 1 Kalle Kalle 64 Jul 24 13:38 2 -> /dev/pts/8
> lrwx------ 1 Kalle Kalle 64 Jul 24 13:38 4 -> socket:[201881]
> lrwx------ 1 Kalle Kalle 64 Jul 24 13:38 5 -> socket:[201882]
> lrwx------ 1 Kalle Kalle 64 Jul 24 13:38 6 -> socket:[201883]
> lrwx------ 1 Kalle Kalle 64 Jul 24 13:38 7 -> socket:[201884]
> $ echo $SESSION_MANAGER
> local/Astalo:@/tmp/.ICE-unix/22999,unix/Astalo:/tmp/.ICE-unix/22999,inet6/Astalo:49905,inet/Astalo:52368
> $ su
> Password: 
> # vgs
> File descriptor 4 (socket:[201881]) leaked on vgs invocation. Parent PID 23063: dash
> File descriptor 5 (socket:[201882]) leaked on vgs invocation. Parent PID 23063: dash
> File descriptor 6 (socket:[201883]) leaked on vgs invocation. Parent PID 23063: dash
> File descriptor 7 (socket:[201884]) leaked on vgs invocation. Parent PID 23063: dash
>   VG    #PV #LV #SN Attr   VSize   VFree  
>   vgr0a   2   1   0 wz--n- 204.44G 189.44G
>   vgr1a   2   1   0 wz--n-  18.62G  16.62G
>   vgr1b   2  15   0 wz--n- 185.81G  97.12G
> # netstat -ape | grep '20188[1234]'
> tcp        0      0 *:52368                 *:*                     LISTEN     Kalle      201882     22999/xsm           
> tcp6       0      0 *:49905                 *:*                     LISTEN     Kalle      201881     22999/xsm           
> unix  2      [ ACC ]     STREAM     LISTENING     201883   22999/xsm           @/tmp/.ICE-unix/22999
> unix  2      [ ACC ]     STREAM     LISTENING     201884   22999/xsm           /tmp/.ICE-unix/22999
> # 
>
> To create these sockets, xsm uses libICE, which in turn uses
> source code from xtrans.  In X11 Release 6 Public Patch #08
> <http://www.umich.edu/~archive/x11/r6-src/fixes/fix-08>,
> IceAcceptConnection() and IceOpenConnection() were changed to
> call _IceTransSetOption (newconn, TRANS_CLOSEONEXEC, 1); but
> IceListenForConnections() does no such thing.  Because libICE
> apparently expects callers to access the listening sockets only
> via the opaque typedef struct _IceListenObj *IceListenObj, and
> these structures do not survive the address-space change in exec,
> I don't think it makes sense to keep the file descriptors open
> across exec either.
>
> libice (2:1.0.5-1.kon.1) local; urgency=low
>
>   * Local version!
>   * Make the sockets opened by IceListenForConnections close on exec.
>     This stops xsm from leaking the $SESSION_MANAGER sockets to all the
>     processes in the session.
>
>  -- Kalle Olavi Niemitalo <kon@iki.fi>  Fri, 24 Jul 2009 13:05:04 +0300
>
> only in patch2:
> unchanged:
> --- libice-1.0.5.orig/src/listen.c
> +++ libice-1.0.5/src/listen.c
> @@ -76,6 +76,7 @@
>  
>      for (i = 0; i < transCount; i++)
>      {
> +	_IceTransSetOption (transConns[i], TRANS_CLOSEONEXEC, 1);
>  	networkId = _IceTransGetMyNetworkId (transConns[i]);
>  
>  	if (networkId)
>
> -- System Information:
> Debian Release: lenny/sid
>   APT prefers unstable
>   APT policy: (500, 'unstable'), (500, 'testing'), (500, 'stable'), (1, 'experimental')
> Architecture: i386 (i686)
> Shell:  /bin/sh linked to /bin/dash
> Kernel: Linux 2.6.26-1-686
> Locale: LANG=fi_FI.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
>
> Versions of packages x11-session-utils depends on:
> ii  cpp                           4:4.3.1-2  The GNU C preprocessor (cpp)
> ii  libc6                         2.7-16     GNU C Library: Shared libraries
> ii  libice6                       2:1.0.5-1  X11 Inter-Client Exchange library
> ii  libsm6                        2:1.1.0-2  X11 Session Management library
> ii  libx11-6                      2:1.0.0-6  X11 client-side library
> ii  libxaw7                       2:1.0.5-2  X11 Athena Widget library
> ii  libxmu6                       1:1.0.1-3  X11 miscellaneous utility library
> ii  libxt6                        1:1.0.0-4  X11 toolkit intrinsics library
> ii  x11-common                    1:7.3+8    X Window System (X.Org) infrastruc
>
> Other related packages:
> ii  xtrans-dev                    1.2.3-3    X transport library (development f
>   




Reply to: