From patchwork Thu Aug 23 10:04:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Emil Velikov X-Patchwork-Id: 10573679 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ECAF0112E for ; Thu, 23 Aug 2018 10:08:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CEDFC2B954 for ; Thu, 23 Aug 2018 10:08:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C1D6C2B95E; Thu, 23 Aug 2018 10:08:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 59B882B954 for ; Thu, 23 Aug 2018 10:08:45 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C261E8987A; Thu, 23 Aug 2018 10:08:42 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by gabe.freedesktop.org (Postfix) with ESMTPS id 215BB8987A for ; Thu, 23 Aug 2018 10:08:41 +0000 (UTC) Received: by mail-wr1-x42b.google.com with SMTP id z96-v6so4127301wrb.8 for ; Thu, 23 Aug 2018 03:08:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=yw+y8NCIlU2z4tUnzvmyi856QDEt2FvY/xHGRNYDm8c=; b=d0KNe+vghDj4Ufyajr2npkPcBFqZEUK2zveHtNRXfzTVFe7dJYPXV12ePPYYF6lIOK p5ffAAw7+oQsgm78CPUg+MQnVDEGYiHwzG6hWCFuP3A61nISBhjayFWkttmqusVyjRLu 04opkCsxORC+BxIWu7RQlWm3k2HbK3mINkOoHxXuWTNMAHPY5cfueSXItew8W6ulii02 aqjJS6kifkxazftcinLO5Z6WlenNjt8lYP88PkgSSeBPDbMw9BMN0/0X+yU5zevjp/Ge Ft8fuZayVfUxHsIquL/tL5VyWpfnLuR3XTvSsil5dwteFn8vBlz3lLfr1lQlWcIWwIxc SLcw== X-Gm-Message-State: APzg51Abe2wguqWbpP0ihs/G1E5gATNG2NjiZ8LM91LtneX6Sh7V6QRd EUkPgd244wARbaEbiFoZ3/mBwlzV X-Google-Smtp-Source: ANB0VdYYea3ekVJ/szHf1wSNl99Bn0KNZPpbHhJX27LXAHE4zROn23rdZeeorn5B3353Cw2dcVMYrw== X-Received: by 2002:a5d:4783:: with SMTP id w3-v6mr8344107wrq.188.1535018919600; Thu, 23 Aug 2018 03:08:39 -0700 (PDT) Received: from arch-x1c3.cbg.collabora.co.uk ([2a00:5f00:102:0:9665:9cff:feee:aa4d]) by smtp.gmail.com with ESMTPSA id 66-v6sm4721925wmw.34.2018.08.23.03.08.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Aug 2018 03:08:38 -0700 (PDT) From: Emil Velikov To: dri-devel@lists.freedesktop.org Subject: [PATCH libdrm] xf86drm: fallback to normal path when realpath fails Date: Thu, 23 Aug 2018 11:04:37 +0100 Message-Id: <20180823100437.10127-1-emil.l.velikov@gmail.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Michel_D=C3=A4nzer?= , emil.l.velikov@gmail.com, Mike Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Emil Velikov 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 Cc: Michel Dänzer Cc: Mike Fixes: a02900133b3 ("xf86drm: introduce a get_real_pci_path() helper") Signed-off-by: Emil Velikov Reviewed-by: Michel Dänzer Tested-by: Michel Dänzer --- 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(-) diff --git a/xf86drm.c b/xf86drm.c index 336d64de..964bedf9 100644 --- a/xf86drm.c +++ b/xf86drm.c @@ -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);