From patchwork Thu Aug 23 13:37:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Emil Velikov X-Patchwork-Id: 10573967 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 F3CBC5A4 for ; Thu, 23 Aug 2018 13:41:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E99902C125 for ; Thu, 23 Aug 2018 13:41:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E7E722C170; Thu, 23 Aug 2018 13:41:39 +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 7FDCE2C163 for ; Thu, 23 Aug 2018 13:41:39 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 20B2A6E05E; Thu, 23 Aug 2018 13:41:37 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by gabe.freedesktop.org (Postfix) with ESMTPS id D94BF6E05E for ; Thu, 23 Aug 2018 13:41:34 +0000 (UTC) Received: by mail-wr1-x430.google.com with SMTP id v90-v6so4706454wrc.0 for ; Thu, 23 Aug 2018 06:41:34 -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:in-reply-to :references:mime-version:content-transfer-encoding; bh=WFEnwHPof8r9dWhUMp+YxCP3mbPS+WcC0lpYFDTwTZU=; b=C2zUSIRf09KIbpUBTZVjBJgAdQv+m6fzIC5/yrho0AgUk3kiEBcFmunUeTNEa3270T vwSQgRY+PdEgmm6/97gYpFiGtOias6TwxhIf4agWbENsKW+WFgWmvrDhBmfjx6qEgK8J RqABfTlSOObz/OjgUlJbz5mssqg1bJH4i54mqHrPLZbq6ejSXQf/V5VxY6fW9SgL1Qt1 NgzQ9dijfiGGKR8J0Uj43L7yuKRFUYrLLyu7PstLI3OUNNfr1v7w+E3PPxLjyXMxp538 kx1gbQ5heeXYOQOX9LlhKza6vDL04j4fxp8YkSc5Fw21SHd3H8zuZSIf9/o1/35uC0R2 yxUg== X-Gm-Message-State: AOUpUlEMhDmNcAYsgq9oQX1qAdaVKmTILsK6Zh6cqxMs87NDwyJFUaoq A4sgzS/BcaUB9QuKZ1bYUX07qXRT X-Google-Smtp-Source: AA+uWPxkllc8rldZqUEBiDTUvYKi5bcaVNkermXCYZ6HqfMAUfQN7HkKYwhMVIdubrx/sg+OBL/TdQ== X-Received: by 2002:adf:9ccb:: with SMTP id h11-v6mr19308610wre.11.1535031693215; Thu, 23 Aug 2018 06:41:33 -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 m200-v6sm5694368wma.32.2018.08.23.06.41.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Aug 2018 06:41:32 -0700 (PDT) From: Emil Velikov To: dri-devel@lists.freedesktop.org Subject: [PATCH libdrm v2] xf86drm: fallback to normal path when realpath fails Date: Thu, 23 Aug 2018 14:37:28 +0100 Message-Id: <20180823133728.26505-1-emil.l.velikov@gmail.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180823100437.10127-1-emil.l.velikov@gmail.com> References: <20180823100437.10127-1-emil.l.velikov@gmail.com> 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. v2: drop return type - function cannot return NULL (Eric) 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 (v1) Tested-by: Michel Dänzer (v1) Reviewed-by: Eric Engestrom --- 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);