|
 |
4423543 |
From 3ccf80b5626c06f12e8d0a5779d4f6b3721d518f Mon Sep 17 00:00:00 2001
|
|
 |
4423543 |
From: Jocelyn Falempe <jfalempe@redhat.com>
|
|
 |
4423543 |
Date: Thu, 14 Apr 2022 14:39:37 +0200
|
|
 |
4423543 |
Subject: [PATCH] Refuse to run if framebuffer or dri devices are present
|
|
 |
4423543 |
|
|
 |
4423543 |
The simpledrm driver, introduced in kernel 5.14,
|
|
 |
4423543 |
can replace efifb to provide the efi framebuffer.
|
|
 |
4423543 |
|
|
 |
4423543 |
This fixes a bug on Fedora 36 (first version to use simpledrm driver):
|
|
 |
4423543 |
https://bugzilla.redhat.com/show_bug.cgi?id=2074789
|
|
 |
4423543 |
|
|
 |
4423543 |
v2: check for framebuffer or dri devices instead of efi framebuffer interface.
|
|
 |
4423543 |
|
|
 |
4423543 |
Reviewed-by: Adam Jackson <ajax@redhat.com>
|
|
 |
4423543 |
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
|
|
 |
4423543 |
Signed-off-by: Jocelyn Falempe <jfalempe@redhat.com>
|
|
 |
4423543 |
---
|
|
 |
4423543 |
src/vesa.c | 39 ++++++++++++++++++++++++++++++++++-----
|
|
 |
4423543 |
1 file changed, 34 insertions(+), 5 deletions(-)
|
|
 |
4423543 |
|
|
 |
4423543 |
diff --git a/src/vesa.c b/src/vesa.c
|
|
 |
4423543 |
index b2a1922..ed2227d 100644
|
|
 |
4423543 |
--- a/src/vesa.c
|
|
 |
4423543 |
+++ b/src/vesa.c
|
|
 |
4423543 |
@@ -44,6 +44,7 @@
|
|
 |
4423543 |
|
|
 |
4423543 |
#include <string.h>
|
|
 |
4423543 |
#include <unistd.h>
|
|
 |
4423543 |
+#include <dirent.h>
|
|
 |
4423543 |
#include "vesa.h"
|
|
 |
4423543 |
|
|
 |
4423543 |
/* All drivers initialising the SW cursor need this */
|
|
 |
4423543 |
@@ -439,12 +440,40 @@ VESAInitScrn(ScrnInfoPtr pScrn)
|
|
 |
4423543 |
pScrn->FreeScreen = VESAFreeScreen;
|
|
 |
4423543 |
}
|
|
 |
4423543 |
|
|
 |
4423543 |
+#ifdef XSERVER_LIBPCIACCESS
|
|
 |
4423543 |
+#ifdef __linux__
|
|
 |
4423543 |
+/*
|
|
 |
4423543 |
+ * check if a file exist in directory
|
|
 |
4423543 |
+ * should be equivalent to a glob ${directory}/${prefix}*
|
|
 |
4423543 |
+ */
|
|
 |
4423543 |
+
|
|
 |
4423543 |
+static Bool
|
|
 |
4423543 |
+VESAFileExistsPrefix(const char *directory, const char *prefix) {
|
|
 |
4423543 |
+ DIR *dir;
|
|
 |
4423543 |
+ struct dirent *entry;
|
|
 |
4423543 |
+ Bool found = FALSE;
|
|
 |
4423543 |
+ int len = strlen(prefix);
|
|
 |
4423543 |
+
|
|
 |
4423543 |
+ dir = opendir(directory);
|
|
 |
4423543 |
+ if (!dir)
|
|
 |
4423543 |
+ return FALSE;
|
|
 |
4423543 |
+
|
|
 |
4423543 |
+ while ((entry = readdir(dir)) != NULL) {
|
|
 |
4423543 |
+ if (strlen(entry->d_name) > len &&
|
|
 |
4423543 |
+ !memcmp(entry->d_name, prefix, len)) {
|
|
 |
4423543 |
+ found = TRUE;
|
|
 |
4423543 |
+ break;
|
|
 |
4423543 |
+ }
|
|
 |
4423543 |
+ }
|
|
 |
4423543 |
+ closedir(dir);
|
|
 |
4423543 |
+ return found;
|
|
 |
4423543 |
+}
|
|
 |
4423543 |
+#endif
|
|
 |
4423543 |
+
|
|
 |
4423543 |
/*
|
|
 |
4423543 |
* This function is called once, at the start of the first server generation to
|
|
 |
4423543 |
* do a minimal probe for supported hardware.
|
|
 |
4423543 |
*/
|
|
 |
4423543 |
-
|
|
 |
4423543 |
-#ifdef XSERVER_LIBPCIACCESS
|
|
 |
4423543 |
static Bool
|
|
 |
4423543 |
VESAPciProbe(DriverPtr drv, int entity_num, struct pci_device *dev,
|
|
 |
4423543 |
intptr_t match_data)
|
|
 |
4423543 |
@@ -452,9 +481,9 @@ VESAPciProbe(DriverPtr drv, int entity_num, struct pci_device *dev,
|
|
 |
4423543 |
ScrnInfoPtr pScrn;
|
|
 |
4423543 |
|
|
 |
4423543 |
#ifdef __linux__
|
|
 |
4423543 |
- if (access("/sys/devices/platform/efi-framebuffer.0", F_OK) == 0 ||
|
|
 |
4423543 |
- access("/sys/devices/platform/efifb.0", F_OK) == 0) {
|
|
 |
4423543 |
- ErrorF("vesa: Refusing to run on UEFI\n");
|
|
 |
4423543 |
+ if (VESAFileExistsPrefix("/dev", "fb") ||
|
|
 |
4423543 |
+ VESAFileExistsPrefix("/dev/dri", "card")) {
|
|
 |
4423543 |
+ ErrorF("vesa: Refusing to run, Framebuffer or dri device present\n");
|
|
 |
4423543 |
return FALSE;
|
|
 |
4423543 |
}
|
|
 |
4423543 |
#endif
|
|
 |
4423543 |
--
|
|
 |
4423543 |
2.35.1
|
|
 |
4423543 |
|