diff mbox series

[libdrm,v2] xf86drm: fallback to normal path when realpath fails

Message ID 20180823133728.26505-1-emil.l.velikov@gmail.com (mailing list archive)
State New, archived
Headers show
Series [libdrm,v2] xf86drm: fallback to normal path when realpath fails | expand

Commit Message

Emil Velikov Aug. 23, 2018, 1:37 p.m. UTC
From: Emil Velikov <emil.velikov@collabora.com>

Earlier commit reworked our sysfs handling to use realpath.
Sadly that backfired since the Firefox sandboxing mechanism rejects
that. Despite the files/folders being in the allowed list, of the
sandboxing mechanism.

Oddly enough, the Chromium sandboxing doesn't complain about any of
this.

Since there are no Firefox releases with the fix, add a temporary
solution which falls back to the original handling.

Sadly, this won't work for virgl.

v2: drop return type - function cannot return NULL (Eric)

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107516
Cc: Michel Dänzer <michel.daenzer@amd.com>
Cc: Mike <bugs.freedesktop.org@pm.port0.org>
Fixes: a02900133b3 ("xf86drm: introduce a get_real_pci_path() helper")
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com> (v1)
Tested-by: Michel Dänzer <michel.daenzer@amd.com> (v1)
---
 xf86drm.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

Comments

Eric Engestrom Aug. 23, 2018, 3 p.m. UTC | #1
On Thursday, 2018-08-23 14:37:28 +0100, Emil Velikov wrote:
> From: Emil Velikov <emil.velikov@collabora.com>
> 
> Earlier commit reworked our sysfs handling to use realpath.
> Sadly that backfired since the Firefox sandboxing mechanism rejects
> that. Despite the files/folders being in the allowed list, of the
> sandboxing mechanism.
> 
> Oddly enough, the Chromium sandboxing doesn't complain about any of
> this.
> 
> Since there are no Firefox releases with the fix, add a temporary
> solution which falls back to the original handling.
> 
> Sadly, this won't work for virgl.
> 
> v2: drop return type - function cannot return NULL (Eric)
> 
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107516
> Cc: Michel Dänzer <michel.daenzer@amd.com>
> Cc: Mike <bugs.freedesktop.org@pm.port0.org>
> Fixes: a02900133b3 ("xf86drm: introduce a get_real_pci_path() helper")
> Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
> Reviewed-by: Michel Dänzer <michel.daenzer@amd.com> (v1)
> Tested-by: Michel Dänzer <michel.daenzer@amd.com> (v1)

Reviewed-by: Eric Engestrom <eric.engestrom@intel.com>

> ---
>  xf86drm.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/xf86drm.c b/xf86drm.c
> index 336d64de..7807dce9 100644
> --- a/xf86drm.c
> +++ b/xf86drm.c
> @@ -3014,6 +3014,12 @@ get_real_pci_path(int maj, int min, char *real_path)
>      return real_path;
>  }
>  
> +static void
> +get_normal_pci_path(int maj, int min, char *normal_path)
> +{
> +    snprintf(normal_path, PATH_MAX, "/sys/dev/char/%d:%d/device", maj, min);
> +}
> +
>  static int drmParsePciBusInfo(int maj, int min, drmPciBusInfoPtr info)
>  {
>  #ifdef __linux__
> @@ -3022,7 +3028,7 @@ static int drmParsePciBusInfo(int maj, int min, drmPciBusInfoPtr info)
>      int num;
>  
>      if (get_real_pci_path(maj, min, real_path) == NULL)
> -        return -ENOENT;
> +        get_normal_pci_path(maj, min, real_path);
>  
>      value = sysfs_uevent_get(real_path, "PCI_SLOT_NAME");
>      if (!value)
> @@ -3143,7 +3149,7 @@ static int parse_separate_sysfs_files(int maj, int min,
>      int ret;
>  
>      if (get_real_pci_path(maj, min, real_path) == NULL)
> -        return -ENOENT;
> +        get_normal_pci_path(maj, min, real_path);
>  
>      for (unsigned i = ignore_revision ? 1 : 0; i < ARRAY_SIZE(attrs); i++) {
>          snprintf(path, PATH_MAX, "%s/%s", real_path, attrs[i]);
> @@ -3175,7 +3181,7 @@ static int parse_config_sysfs_file(int maj, int min,
>      int fd, ret;
>  
>      if (get_real_pci_path(maj, min, real_path) == NULL)
> -        return -ENOENT;
> +        get_normal_pci_path(maj, min, real_path);
>  
>      snprintf(path, PATH_MAX, "%s/config", real_path);
>      fd = open(path, O_RDONLY);
> -- 
> 2.18.0
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
diff mbox series

Patch

diff --git a/xf86drm.c b/xf86drm.c
index 336d64de..7807dce9 100644
--- a/xf86drm.c
+++ b/xf86drm.c
@@ -3014,6 +3014,12 @@  get_real_pci_path(int maj, int min, char *real_path)
     return real_path;
 }
 
+static void
+get_normal_pci_path(int maj, int min, char *normal_path)
+{
+    snprintf(normal_path, PATH_MAX, "/sys/dev/char/%d:%d/device", maj, min);
+}
+
 static int drmParsePciBusInfo(int maj, int min, drmPciBusInfoPtr info)
 {
 #ifdef __linux__
@@ -3022,7 +3028,7 @@  static int drmParsePciBusInfo(int maj, int min, drmPciBusInfoPtr info)
     int num;
 
     if (get_real_pci_path(maj, min, real_path) == NULL)
-        return -ENOENT;
+        get_normal_pci_path(maj, min, real_path);
 
     value = sysfs_uevent_get(real_path, "PCI_SLOT_NAME");
     if (!value)
@@ -3143,7 +3149,7 @@  static int parse_separate_sysfs_files(int maj, int min,
     int ret;
 
     if (get_real_pci_path(maj, min, real_path) == NULL)
-        return -ENOENT;
+        get_normal_pci_path(maj, min, real_path);
 
     for (unsigned i = ignore_revision ? 1 : 0; i < ARRAY_SIZE(attrs); i++) {
         snprintf(path, PATH_MAX, "%s/%s", real_path, attrs[i]);
@@ -3175,7 +3181,7 @@  static int parse_config_sysfs_file(int maj, int min,
     int fd, ret;
 
     if (get_real_pci_path(maj, min, real_path) == NULL)
-        return -ENOENT;
+        get_normal_pci_path(maj, min, real_path);
 
     snprintf(path, PATH_MAX, "%s/config", real_path);
     fd = open(path, O_RDONLY);