xf86drm: fallback to normal path when realpath fails
PATCH 1/1 xf86drm: fallback to normal path when realpath fails
From: Emil Velikov <[email protected]>
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.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107516
---
Gents, this should bring things back to normal. Can you please give it a try?
Would be great to see Firefox roll out updates which make this workaround unnessesary ;-)
--- xf86drm.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
xf86drm.c +14 -3
@@ -3014,6 +3014,14 @@ get_real_pci_path(int maj, int min, char *real_path)return real_path; } +static char * +get_normal_pci_path (int maj,int min,char *normal_path) +{ +snprintf (normal_path,PATH_MAX ,"/sys/dev/char/%d:%d/device" , maj, min); + +return normal_path; +} +static int drmParsePciBusInfo (int maj,int min,drmPciBusInfoPtr info) {#ifdef __linux__
@@ -3021,7 +3029,8 @@ static int drmParsePciBusInfo(int maj, int min, drmPciBusInfoPtr info)char real_path[PATH_MAX +1 ], *value;int num; -if (get_real_pci_path (maj, min, real_path) ==NULL ) +if (get_real_pci_path (maj, min, real_path) ==NULL && +get_normal_pci_path (maj, min, real_path) ==NULL )return -ENOENT ; value =sysfs_uevent_get (real_path,"PCI_SLOT_NAME" );
@@ -3142,7 +3151,8 @@ static int parse_separate_sysfs_files(int maj, int min,FILE *fp;int ret; -if (get_real_pci_path (maj, min, real_path) ==NULL ) +if (get_real_pci_path (maj, min, real_path) ==NULL && +get_normal_pci_path (maj, min, real_path) ==NULL )return -ENOENT ;for (unsigned i = ignore_revision ?1 :0 ; i <ARRAY_SIZE (attrs); i++) {
@@ -3174,7 +3184,8 @@ static int parse_config_sysfs_file(int maj, int min,unsigned char config[64 ];int fd, ret; -if (get_real_pci_path (maj, min, real_path) ==NULL ) +if (get_real_pci_path (maj, min, real_path) ==NULL && +get_normal_pci_path (maj, min, real_path) ==NULL )return -ENOENT ;snprintf (path,PATH_MAX ,"%s/config" , real_path);
Signature · 6 lines
2.18.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 6 lines · Emil Velikov
From: Emil Velikov <[email protected]>
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.
From the Firefox bug report, the problem was stat on the top-level /sys directory.
Quoted 6 lines
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.
Quoted 7 lines
Sadly, this won't work for virgl.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107516
Cc Michel Dänzer <[email protected]>Cc Mike <[email protected]>Fixes a02900133b3 ("xf86drm: introduce a get_real_pci_path() helper")Signed-off-by Emil Velikov <[email protected]>
Thanks Emil!
Signature · 6 lines
Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 4 lines · Michel Dänzer
Quoted 2 lines · Emil Velikov
From: Emil Velikov <[email protected]>
Quoted 8 lines
Quoted 4 lines
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.
From the Firefox bug report, the problem was stat on the top-level /sys directory.
That's the part I didn't quite get. I don't see anything in libdrm that would do that.
We do have fstat(open("/dev/dri/foo"), stat("/dev/dri/foo").
I guess the C runtime (compiler?) might be doing that one? Like the realpath call being translated to a series of stat() calls.
Quoted 15 lines
Quoted 7 lines
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.
Quoted 7 lines
Sadly, this won't work for virgl.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107516
Cc Michel Dänzer <[email protected]>Cc Mike <[email protected]>Fixes a02900133b3 ("xf86drm: introduce a get_real_pci_path() helper")Signed-off-by Emil Velikov <[email protected]>
Quoted 6 lines
Reviewed-by Michel Dänzer <[email protected]>Tested-by Michel Dänzer <[email protected]>Thanks Emil!
Sorry for these experiences. I should really test things with Firefox, saying "it works with Chromium" doesn't quite cut it.
Thanks
Emil
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 12 lines · Emil Velikov
Quoted 11 lines · Michel Dänzer
Quoted 6 lines · Emil Velikov
From: Emil Velikov <[email protected]>
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.
From the Firefox bug report, the problem was stat on the top-level /sys directory.
Quoted 6 lines
That's the part I didn't quite get. I don't see anything in libdrm that would do that.
We do have fstat(open("/dev/dri/foo"),stat("/dev/dri/foo").I guess the C runtime (compiler?) might be doing that one? Like the realpath call being translated to a series of
stat()calls.
Yeah, probably something like that.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
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.
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107516
Cc Michel Dänzer <[email protected]>Cc Mike <[email protected]>Fixes a02900133b3 ("xf86drm: introduce a get_real_pci_path() helper")Signed-off-by Emil Velikov <[email protected]>Reviewed-by Michel Dänzer <[email protected]>Tested-by Michel Dänzer <[email protected]>
These are now also valid for v2, thanks again!
Signature · 6 lines
Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 1/1 xf86drm: fallback to normal path when realpath fails
In reply to Emil VelikovFrom: Emil Velikov <[email protected]>
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
--- xf86drm.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
xf86drm.c +9 -3
@@ -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 );
Signature · 6 lines
2.18.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 17 lines · Emil Velikov
From: Emil Velikov <[email protected]>
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)
Quoted 7 lines
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107516
Cc Michel Dänzer <[email protected]>Cc Mike <[email protected]>Fixes a02900133b3 ("xf86drm: introduce a get_real_pci_path() helper")Signed-off-by Emil Velikov <[email protected]>Reviewed-by Michel Dänzer <[email protected]> (v1)Tested-by Michel Dänzer <[email protected]> (v1)
Quoted 55 lines
--- xf86drm.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)xf86drm.c +9
-3@@ -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 );Signature · 6 lines
2.18.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel