[PATCH xserver] modesetting: Don't deref crtc->scrn in drmmode_output_dpms()

2018-03-30 Thread Mario Kleiner
crtc might be a NULL pointer. Use output->scrn instead.

Fixes crashes from some call paths of drmmode_output_dpms(),
e.g., when called from xf86DisableUnusedFunctions().

Fixes: ba0c75177239 ("modesetting: Fix up some XXX from removing 
GLAMOR_HAS_DRM_*")
Signed-off-by: Mario Kleiner 
Suggested-by: Daniel Stone 
---
 hw/xfree86/drivers/modesetting/drmmode_display.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c 
b/hw/xfree86/drivers/modesetting/drmmode_display.c
index a70b4c6..4a98301 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.c
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.c
@@ -2267,7 +2267,7 @@ drmmode_output_dpms(xf86OutputPtr output, int mode)
 {
 drmmode_output_private_ptr drmmode_output = output->driver_private;
 xf86CrtcPtr crtc = output->crtc;
-modesettingPtr ms = modesettingPTR(crtc->scrn);
+modesettingPtr ms = modesettingPTR(output->scrn);
 drmModeConnectorPtr koutput = drmmode_output->mode_output;
 drmmode_ptr drmmode = drmmode_output->drmmode;
 
-- 
2.7.4

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH] glamor: sanitze handling of "Debug" Option for "dmabuf_capable"

2018-03-30 Thread Tobias Klausmann
With the appearance of the this new Option the X Server would crash if the
option is not set.

Default dmabuf_capable to off/FALSE for now - a user without knowledge about
this option does not want to enable it until its save.

Fixes: d11d5bb80 ("glamor: Hide new DRI behind Option "Debug" "dmabuf_capable")
Signed-off-by: Tobias Klausmann 
---
 glamor/glamor_egl.c | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c
index 4a550932a..f82fa519b 100644
--- a/glamor/glamor_egl.c
+++ b/glamor/glamor_egl.c
@@ -960,9 +960,13 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd)
 if (epoxy_has_egl_extension(glamor_egl->display,
 "EGL_EXT_image_dma_buf_import") &&
 epoxy_has_egl_extension(glamor_egl->display,
-"EGL_EXT_image_dma_buf_import_modifiers"))
-glamor_egl->dmabuf_capable = !!strstr(xf86Info.debug,
-  "dmabuf_capable");
+"EGL_EXT_image_dma_buf_import_modifiers")) {
+   if (xf86Info.debug != NULL)
+   glamor_egl->dmabuf_capable = !!strstr(xf86Info.debug,
+"dmabuf_capable");
+else
+glamor_egl->dmabuf_capable = FALSE;
+}
 #endif
 
 glamor_egl->saved_free_screen = scrn->FreeScreen;
-- 
2.16.2

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH] modesetting/drmmode: add NULL pointer check in drmmode_output_dpms

2018-03-30 Thread Tobias Klausmann
drmmode_output_dpms is called especially with !output->crtc found in
xf86DisableUnusedFunctions so we have to guard for it, else the server
segfaults:

0  0x7fdc1706054b in drmmode_output_dpms (output=0x55e15243c210, mode=3) at
drmmode_display.c:2243
1  0x55e1500b6873 in xf86DisableUnusedFunctions (pScrn=0x55e152133f00) at
xf86Crtc.c:3021
2  0x55e1500be940 in xf86RandR12CrtcSet (pScreen=,
randr_crtc=0x55e1524b2b90, randr_mode=0x0, x=0, y=0, rotation=,
num_randr_outputs=0, randr_outputs=0x0) at xf86RandR12.c:1244
3  0x55e1500fa1c2 in RRCrtcSet (crtc=, mode=0x0, x=0, y=0,
rotation=rotation@entry=1, numOutputs=numOutputs@entry=0, outputs=0x0) at
rrcrtc.c:763
4  0x55e1500fba9e in ProcRRSetCrtcConfig (client=0x55e152bfae50) at
rrcrtc.c:1390
5  0x55e150044008 in Dispatch () at dispatch.c:478
6  0x55e150047ff8 in dix_main (argc=13, argv=0x7ffc68561038,
envp=) at main.c:276
7  0x7fdc1a0c6a87 in __libc_start_main () at /lib64/libc.so.6
8  0x55e150031d0a in _start () at ../sysdeps/x86_64/start.S:120

Fixes: ba0c75177 ("modesetting: Fix up some XXX from removing GLAMOR_HAS_DRM_*")
Signed-off-by: Tobias Klausmann 
---
 hw/xfree86/drivers/modesetting/drmmode_display.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c 
b/hw/xfree86/drivers/modesetting/drmmode_display.c
index 755a61def..03d2fa226 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.c
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.c
@@ -2240,14 +2240,17 @@ drmmode_output_dpms(xf86OutputPtr output, int mode)
 {
 drmmode_output_private_ptr drmmode_output = output->driver_private;
 xf86CrtcPtr crtc = output->crtc;
-modesettingPtr ms = modesettingPTR(crtc->scrn);
+modesettingPtr ms = NULL;
 drmModeConnectorPtr koutput = drmmode_output->mode_output;
 drmmode_ptr drmmode = drmmode_output->drmmode;
 
 if (!koutput)
 return;
 
-if (ms->atomic_modeset) {
+if (crtc)
+ms = modesettingPTR(crtc->scrn);
+
+if (ms && ms->atomic_modeset) {
 drmmode_output->dpms = mode;
 } else {
 drmModeConnectorSetProperty(drmmode->fd, koutput->connector_id,
-- 
2.16.2

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH xserver 2/3] meson: Distribute more SDK headers

2018-03-30 Thread Aaron Plattner
Thanks, Thierry! I started working on a change to do this, but didn't
get very far before you beat me to it.

On 03/29/2018 04:07 AM, Thierry Reding wrote:
> From: Thierry Reding 
> 
> Install missing headers to the SDK directory to allow external modules
> to properly build against the SDK. After this commit, the list of files
> installed in the SDK include directory is the same as the list of files
> installed by the autotools-based build.
> 
> Signed-off-by: Thierry Reding 
> ---
>  Xext/meson.build  | 12 
>  composite/meson.build |  6 ++
>  dbe/meson.build   |  6 ++
>  dri3/meson.build  |  6 ++
>  fb/meson.build| 10 ++
>  glx/meson.build   |  6 ++
>  hw/xfree86/os-support/meson.build |  9 -
>  include/meson.build   |  1 +
>  mi/meson.build| 15 +++
>  miext/damage/meson.build  |  7 +++
>  miext/shadow/meson.build  |  6 ++
>  miext/sync/meson.build|  9 +
>  present/meson.build   |  7 +++
>  randr/meson.build |  7 +++
>  render/meson.build|  9 +
>  15 files changed, 115 insertions(+), 1 deletion(-)
> 
> diff --git a/Xext/meson.build b/Xext/meson.build
> index 9968f2a9e312..a7217371871d 100644
> --- a/Xext/meson.build
> +++ b/Xext/meson.build
> @@ -8,12 +8,19 @@ srcs_xext = [
>  'xtest.c',
>  ]
>  
> +hdrs_xext = [
> +'geext.h',
> +'geint.h',
> +'syncsdk.h',
> +]
> +
>  if build_dpms
>  srcs_xext += 'dpms.c'
>  endif
>  
>  if build_mitshm
>  srcs_xext += 'shm.c'
> +hdrs_xext += ['shmint.h']
>  endif
>  
>  if build_res
> @@ -26,6 +33,7 @@ endif
>  
>  if build_xace
>  srcs_xext += 'xace.c'
> +hdrs_xext += ['xace.h', 'xacestr.h']
>  endif
>  
>  if build_xf86bigfont
> @@ -34,6 +42,7 @@ endif
>  
>  if build_xinerama
>  srcs_xext += ['panoramiX.c', 'panoramiXprocs.c', 'panoramiXSwap.c']
> +hdrs_xext += ['panoramiX.h', 'panoramiXsrv.h']
>  endif
>  
>  if build_xsecurity
> @@ -46,6 +55,7 @@ endif
>  
>  if build_xv
>  srcs_xext += ['xvmain.c', 'xvdisp.c', 'xvmc.c']
> +hdrs_xext += ['xvdix.h', 'xvmcext.h']
>  endif
>  
>  libxserver_xext = static_library('libxserver_xext',
> @@ -59,3 +69,5 @@ libxserver_xext_vidmode = 
> static_library('libxserver_xext_vidmode',
>  include_directories: inc,
>  dependencies: common_dep,
>  )
> +
> +install_data(hdrs_xext, install_dir: xorgsdkdir)

Do these new install_data() directives need to be behind an 'if
build_xorg'? It looks like the other two instances of this that weren't
behind the build_xorg check that guards subdir('xfree86') in
hw/meson.build had their own build_xorg checks.

Prior to this change, building with "meson configure -Dxorg=false" only
installs xorg-server.h to $prefix/include/xorg.

> diff --git a/composite/meson.build b/composite/meson.build
> index 6c4a03fb80c2..7547f0e7edce 100644
> --- a/composite/meson.build
> +++ b/composite/meson.build
> @@ -6,8 +6,14 @@ srcs_composite = [
>   'compwindow.c',
>  ]
>  
> +hdrs_composite = [
> + 'compositeext.h',
> +]
> +
>  libxserver_composite = static_library('libxserver_composite',
>   srcs_composite,
>   include_directories: inc,
>   dependencies: common_dep,
>  )
> +
> +install_data(hdrs_composite, install_dir: xorgsdkdir)
> diff --git a/dbe/meson.build b/dbe/meson.build
> index e10bde19913d..76a2d3f85d2b 100644
> --- a/dbe/meson.build
> +++ b/dbe/meson.build
> @@ -3,8 +3,14 @@ srcs_dbe = [
>   'midbe.c',
>  ]
>  
> +hdrs_dbe = [
> + 'dbestruct.h',
> +]
> +
>  libxserver_dbe = static_library('libxserver_dbe',
>   srcs_dbe,
>   include_directories: inc,
>   dependencies: common_dep,
>  )
> +
> +install_data(hdrs_dbe, install_dir: xorgsdkdir)
> diff --git a/dri3/meson.build b/dri3/meson.build
> index 0deec32aafbe..48ce0d9d6aa1 100644
> --- a/dri3/meson.build
> +++ b/dri3/meson.build
> @@ -4,6 +4,10 @@ srcs_dri3 = [
>   'dri3_screen.c',
>  ]
>  
> +hdrs_dri3 = [
> + 'dri3.h',
> +]
> +
>  libxserver_dri3 = []
>  if build_dri3
>  libxserver_dri3 = static_library('libxserver_dri3',
> @@ -13,3 +17,5 @@ if build_dri3
>  c_args: '-DHAVE_XORG_CONFIG_H'
>  )
>  endif
> +
> +install_data(hdrs_dri3, install_dir: xorgsdkdir)
> diff --git a/fb/meson.build b/fb/meson.build
> index bf85141f980f..477ab047dfd6 100644
> --- a/fb/meson.build
> +++ b/fb/meson.build
> @@ -28,6 +28,14 @@ srcs_fb = [
>   'fbwindow.c',
>  ]
>  
> +hdrs_fb = [
> + 'fb.h',
> + 'fboverlay.h',
> + 'fbpict.h',
> + 'fbrop.h',
> + 'wfbrename.h'
> +]
> +
>  libxserver_fb = static_library('libxserver_fb',
>   srcs_fb,
>   include_directories: inc,
> @@ -45,3 +53,5 @@ libxserver_wfb = static_library('libxserver_wfb',
>   pic: true,
>   build_by_default: false,
>  )
> +
> +install_data(hdrs_fb, install_dir: xorgsd

[PATCH xserver] os: Call FlushClient() before sending FD-passing messages

2018-03-30 Thread Alexander Volkov
Otherwise a client may receive data with an unrelated file
descriptor after calling recvmsg() if its input buffer is not
big enough. In libxcb it may lead to a situation when all
received messages fit the buffer while a message related to
the attached fd is not received yet. libxcb can't find the
corresponding message and fails with XCB_CONN_CLOSED_FDPASSING_FAILED
error.
---
 os/io.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/os/io.c b/os/io.c
index b099f0967..f4e80557d 100644
--- a/os/io.c
+++ b/os/io.c
@@ -488,6 +488,9 @@ WriteFdToClient(ClientPtr client, int fd, Bool do_close)
 #if XTRANS_SEND_FDS
 OsCommPtr oc = (OsCommPtr) client->osPrivate;
 
+if (oc->output && oc->output->count > 0)
+(void) FlushClient(client, oc, (char *) NULL, 0);
+
 return _XSERVTransSendFd(oc->trans_conn, fd, do_close);
 #else
 return -1;
-- 
2.11.0

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel