Bug 217676

Summary: [DRI3] x11/libxshmfence: switch to /tmp for named shared memory mappings
Product: Ports & Packages Reporter: Jan Beich <jbeich>
Component: Individual Port(s)Assignee: freebsd-x11 (Nobody) <x11>
Status: Closed FIXED    
Severity: Affects Only Me CC: rezny
Priority: --- Keywords: patch
Version: LatestFlags: bugzilla: maintainer-feedback? (x11)
Hardware: Any   
OS: Any   
Attachments:
Description Flags
v0 none

Description Jan Beich freebsd_committer freebsd_triage 2017-03-10 04:24:18 UTC
Created attachment 180684 [details]
v0

With DRI3 enabled Xserver may create a lot of temporary files under /var/tmp. Per hier(7) /var/tmp has to be persistent across reboots. However, Xserver fails to clean up temporary files on its own. On the other hand /tmp can use tmpfs(5) for faster access, mimicking /dev/shm on Linux.

$ ls -l /var/tmp/shm*
-rw-------  1 root  wheel     4B Mar 10 13:18 /var/tmp/shmfd-BguYGR
-rw-------  1 root  wheel     4B Mar 10 13:18 /var/tmp/shmfd-GB5BR6
-rw-------  1 root  wheel     4B Mar 10 13:18 /var/tmp/shmfd-Gn3rZg
-rw-------  1 root  wheel     4B Mar 10 13:18 /var/tmp/shmfd-HGV0zt
-rw-------  1 root  wheel     4B Mar 10 13:18 /var/tmp/shmfd-KRLyPk
-rw-------  1 root  wheel     4B Mar 10 13:18 /var/tmp/shmfd-YvGU8y
-rw-------  1 root  wheel     4B Mar 10 13:18 /var/tmp/shmfd-nLoJJ6
-rw-------  1 root  wheel     4B Mar 10 13:18 /var/tmp/shmfd-sUaud9
-rw-------  1 root  wheel     4B Mar 10 13:18 /var/tmp/shmfd-vTOEKK
-rw-------  1 root  wheel     4B Mar 10 13:18 /var/tmp/shmfd-yvrKri

$ fstat /var/tmp/shm*
USER     CMD          PID   FD MOUNT      INUM MODE         SZ|DV R/W NAME
root     Xorg       36979  512 /var/tmp   1087 -rw-------       4 rw  /var/tmp/shmfd-HGV0zt
root     Xorg       36979  513 /var/tmp   1088 -rw-------       4 rw  /var/tmp/shmfd-yvrKri
root     Xorg       36979  514 /var/tmp   1091 -rw-------       4 rw  /var/tmp/shmfd-GB5BR6
root     Xorg       36979  515 /var/tmp   1090 -rw-------       4 rw  /var/tmp/shmfd-Gn3rZg
Comment 1 Jan Beich freebsd_committer freebsd_triage 2017-03-10 04:31:30 UTC
Linuxulator already uses /tmp as /dev/shm per base r218497 and base r283461.
Comment 2 Matthew Rezny freebsd_committer freebsd_triage 2017-03-10 20:28:42 UTC
Good catch. I added --with-shared-memory-dir=/tmp to xorg-server during the 1.18.4 update for the same reason. I didn't notice libxshmfence had the same issue, but I'm not using using a kernel with DRI3 so it hasn't been making temp files.
Comment 3 commit-hook freebsd_committer freebsd_triage 2017-03-11 21:25:16 UTC
A commit references this bug:

Author: rezny
Date: Sat Mar 11 21:24:30 UTC 2017
New revision: 435962
URL: https://svnweb.freebsd.org/changeset/ports/435962

Log:
  - Set the shared memory directory to /tmp to prevent polluting /var/tmp [1]
  - Strip the installed library

  PR:		217676 [1]
  Submitted by:	jbeich [1]
  Approved by:	swills (mentor)
  Differential Revision:	https://reviews.freebsd.org/D9951

Changes:
  head/x11/libxshmfence/Makefile
Comment 4 commit-hook freebsd_committer freebsd_triage 2017-07-04 13:48:09 UTC
A commit references this bug:

Author: jbeich
Date: Tue Jul  4 13:47:46 UTC 2017
New revision: 445016
URL: https://svnweb.freebsd.org/changeset/ports/445016

Log:
  x11/libxshmfence: don't leak /tmp/shmfd* files with O_CLOEXEC

  - Both mkostemp() and mkstemp() need explicit call to unlink()
  - Unobfuscate fallback if both O_TMPFILE and mksotemp() are N/A
  - O_TMPFILE (Linux-only) appeared after O_CLOEXEC, no need to check

  PR:		217676 (for tracking)
  MFH:		2017Q3 2017Q2

Changes:
  head/x11/libxshmfence/Makefile
  head/x11/libxshmfence/files/patch-src__xshmfence_alloc.c
Comment 5 commit-hook freebsd_committer freebsd_triage 2017-07-06 03:01:36 UTC
A commit references this bug:

Author: jbeich
Date: Thu Jul  6 03:01:05 UTC 2017
New revision: 445124
URL: https://svnweb.freebsd.org/changeset/ports/445124

Log:
  MFH: r445016

  x11/libxshmfence: don't leak /tmp/shmfd* files with O_CLOEXEC

  - Both mkostemp() and mkstemp() need explicit call to unlink()
  - Unobfuscate fallback if both O_TMPFILE and mksotemp() are N/A
  - O_TMPFILE (Linux-only) appeared after O_CLOEXEC, no need to check

  PR:		217676 (for tracking)
  Approved by:	ports-secteam (junovitch)

Changes:
_U  branches/2017Q3/
  branches/2017Q3/x11/libxshmfence/Makefile
  branches/2017Q3/x11/libxshmfence/files/patch-src__xshmfence_alloc.c
Comment 6 commit-hook freebsd_committer freebsd_triage 2017-07-06 03:03:40 UTC
A commit references this bug:

Author: jbeich
Date: Thu Jul  6 03:02:59 UTC 2017
New revision: 445125
URL: https://svnweb.freebsd.org/changeset/ports/445125

Log:
  MFH: r445016

  x11/libxshmfence: don't leak /tmp/shmfd* files with O_CLOEXEC

  - Both mkostemp() and mkstemp() need explicit call to unlink()
  - Unobfuscate fallback if both O_TMPFILE and mksotemp() are N/A
  - O_TMPFILE (Linux-only) appeared after O_CLOEXEC, no need to check

  PR:		217676 (for tracking)
  Approved by:	ports-secteam (junovitch)

Changes:
_U  branches/2017Q2/
  branches/2017Q2/x11/libxshmfence/Makefile
  branches/2017Q2/x11/libxshmfence/files/patch-src__xshmfence_alloc.c