* [igt-dev] [PATCH i-g-t] tests/core_unauth_vs_render: new test for the relaxed DRM_AUTH handling
@ 2019-02-08 18:03 Emil Velikov
2019-02-08 18:47 ` [igt-dev] ✗ Fi.CI.BAT: failure for tests/core_unauth_vs_render: new test for the relaxed DRM_AUTH handling (rev3) Patchwork
0 siblings, 1 reply; 2+ messages in thread
From: Emil Velikov @ 2019-02-08 18:03 UTC (permalink / raw)
To: igt-dev; +Cc: emil.l.velikov
From: Emil Velikov <emil.velikov@collabora.com>
As the inline comment says, this test checks that the kernel allows
unauthenticated master with render capable, RENDER_ALLOW ioctls.
The kernel commit has extra details why.
v2:
- drop RUN_AS_ROOT guard
- call check_auth() on the {,un}authenticated device
- check the device is PRIME (import) capable
- check the device has render node
- tweak expectations based on above three
- elaborate why we care only about -EACCES
v3:
- fold into existing core_auth.c
- move igt_assert within the subtest
- make has_prime_import() an igt_require()
- check for BADF before and after, as requested. Not strictly needed.
- swap igt_info+drm_open_driver with comment + __drm_open_driver
Former calls igt_skip() which is problematic with igt_fork().
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
---
Hope that covers everything Dan. Alternatively I would prefer to keep
polishing this, while the kernel fix is merged. This way existing users
would work :-)
---
tests/core_auth.c | 109 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 109 insertions(+)
diff --git a/tests/core_auth.c b/tests/core_auth.c
index 0c016a37..0b9073cb 100644
--- a/tests/core_auth.c
+++ b/tests/core_auth.c
@@ -1,5 +1,6 @@
/*
* Copyright 2015 David Herrmann <dh.herrmann@gmail.com>
+ * Copyright 2018 Collabora, Ltd
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -40,6 +41,7 @@
#include <sys/time.h>
#include <sys/poll.h>
#include <sys/resource.h>
+#include <sys/sysmacros.h>
#include "drm.h"
#ifdef __linux__
@@ -190,6 +192,98 @@ static void test_basic_auth(int master)
close(slave);
}
+static bool has_prime_import(int fd)
+{
+ uint64_t value;
+
+ if (drmGetCap(fd, DRM_CAP_PRIME, &value))
+ return false;
+
+ return value & DRM_PRIME_CAP_IMPORT;
+}
+
+static void check_auth_sanity(int master)
+{
+ uint32_t handle;
+
+ igt_assert(check_auth(master) == true);
+ igt_require(has_prime_import(master));
+
+ igt_assert(drmPrimeFDToHandle(master, -1, &handle) < 0);
+
+ /* IOCTL requires authenticated master as done in drm_permit.
+ * As we get past that, we'll fail due to the invalid FD.
+ *
+ * Note: strictly speaking this is unrelated to the goal of
+ * the test, although danvet requested it.
+ */
+ igt_assert(errno == EBADF);
+}
+
+static bool has_render_node(int fd)
+{
+ char node_name[80];
+ struct stat sbuf;
+
+ if (fstat(fd, &sbuf))
+ return false;
+
+ sprintf(node_name, "/dev/dri/renderD%d", minor(sbuf.st_rdev) | 0x80);
+ if (stat(node_name, &sbuf))
+ return false;
+
+ return true;
+}
+
+/*
+ * Testcase: Render capable, unauthenticated master doesn't throw -EACCES for
+ * DRM_RENDER_ALLOW ioctls.
+ */
+static void test_unauth_vs_render(int master)
+{
+ int slave;
+ uint32_t handle;
+
+ /*
+ * FIXME: when drm_open_driver() fails to open() a node (insufficient
+ * permissions or otherwise, it will igt_skip.
+ * As of today, igt_skip and igt_fork do not work together.
+ */
+ slave = __drm_open_driver(DRIVER_ANY);
+ /*
+ * FIXME: relate to the master fd passed with the above open and fix
+ * all of IGT.
+ */
+
+ igt_assert(slave >= 0);
+
+ /*
+ * The second open() happens without CAP_SYS_ADMIN, thus it will NOT
+ * be authenticated.
+ */
+ igt_assert(check_auth(slave) == false);
+
+ /* Issuing the following ioctl will fail, no doubt about it. */
+ igt_assert(drmPrimeFDToHandle(slave, -1, &handle) < 0);
+
+ /*
+ * Updated kernels allow render capable, unauthenticated master to
+ * issue DRM_AUTH ioctls (like FD2HANDLE above), as long as they are
+ * annotated as DRM_RENDER_ALLOW.
+ *
+ * Otherwise, errno is set to -EACCES
+ *
+ * Note: We are _not_ interested in the FD2HANDLE specific errno,
+ * yet the EBADF check is added on the explicit request by danvet.
+ */
+ if (has_render_node(slave))
+ igt_assert(errno == EBADF);
+ else
+ igt_assert(errno == EACCES);
+
+ close(slave);
+}
+
igt_main
{
int master;
@@ -228,4 +322,19 @@ igt_main
igt_subtest("many-magics")
test_many_magics(master);
}
+
+ igt_subtest_group {
+ igt_fixture
+ master = drm_open_driver(DRIVER_ANY);
+
+ igt_subtest("unauth-vs-render") {
+ check_auth_sanity(master);
+
+ igt_fork(child, 1) {
+ igt_drop_root();
+ test_unauth_vs_render(master);
+ }
+ igt_waitchildren();
+ }
+ }
}
--
2.20.1
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [igt-dev] ✗ Fi.CI.BAT: failure for tests/core_unauth_vs_render: new test for the relaxed DRM_AUTH handling (rev3)
2019-02-08 18:03 [igt-dev] [PATCH i-g-t] tests/core_unauth_vs_render: new test for the relaxed DRM_AUTH handling Emil Velikov
@ 2019-02-08 18:47 ` Patchwork
0 siblings, 0 replies; 2+ messages in thread
From: Patchwork @ 2019-02-08 18:47 UTC (permalink / raw)
To: Emil Velikov; +Cc: igt-dev
== Series Details ==
Series: tests/core_unauth_vs_render: new test for the relaxed DRM_AUTH handling (rev3)
URL : https://patchwork.freedesktop.org/series/55149/
State : failure
== Summary ==
CI Bug Log - changes from CI_DRM_5568 -> IGTPW_2367
====================================================
Summary
-------
**FAILURE**
Serious unknown changes coming with IGTPW_2367 absolutely need to be
verified manually.
If you think the reported changes have nothing to do with the changes
introduced in IGTPW_2367, please notify your bug team to allow them
to document this new failure mode, which will reduce false positives in CI.
External URL: https://patchwork.freedesktop.org/api/1.0/series/55149/revisions/3/mbox/
Possible new issues
-------------------
Here are the unknown changes that may have been introduced in IGTPW_2367:
### IGT changes ###
#### Possible regressions ####
* igt@kms_chamelium@hdmi-edid-read:
- fi-kbl-7567u: PASS -> FAIL +2
Known issues
------------
Here are the changes found in IGTPW_2367 that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@debugfs_test@read_all_entries:
- fi-kbl-7567u: PASS -> DMESG-WARN [fdo#103558] / [fdo#105602]
* igt@gem_exec_suspend@basic-s3:
- fi-kbl-7567u: PASS -> DMESG-WARN [fdo#103558] / [fdo#105079] / [fdo#105602]
* igt@i915_module_load@reload-with-fault-injection:
- fi-kbl-7567u: PASS -> DMESG-WARN [fdo#105602] / [fdo#108529] +1
* igt@kms_chamelium@dp-hpd-fast:
- fi-kbl-7500u: PASS -> DMESG-WARN [fdo#102505] / [fdo#103558] / [fdo#105602]
* igt@kms_chamelium@hdmi-hpd-fast:
- fi-kbl-7500u: PASS -> FAIL [fdo#109485]
* igt@kms_pipe_crc_basic@nonblocking-crc-pipe-b-frame-sequence:
- fi-byt-clapper: PASS -> FAIL [fdo#103191] / [fdo#107362] +1
* igt@kms_pipe_crc_basic@suspend-read-crc-pipe-a:
- fi-kbl-7567u: PASS -> DMESG-FAIL [fdo#105079]
* igt@pm_rpm@basic-rte:
- fi-byt-j1900: PASS -> FAIL [fdo#108800]
* igt@pm_rpm@module-reload:
- fi-kbl-7567u: PASS -> DMESG-WARN [fdo#108529]
#### Possible fixes ####
* igt@kms_busy@basic-flip-b:
- fi-gdg-551: FAIL [fdo#103182] -> PASS
* igt@kms_frontbuffer_tracking@basic:
- {fi-icl-u2}: FAIL [fdo#103167] -> PASS
* igt@pm_rpm@module-reload:
- {fi-whl-u}: DMESG-WARN [fdo#109513] -> PASS
* igt@prime_vgem@basic-fence-flip:
- fi-gdg-551: DMESG-FAIL [fdo#103182] -> PASS
{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).
[fdo#102505]: https://bugs.freedesktop.org/show_bug.cgi?id=102505
[fdo#103167]: https://bugs.freedesktop.org/show_bug.cgi?id=103167
[fdo#103182]: https://bugs.freedesktop.org/show_bug.cgi?id=103182
[fdo#103191]: https://bugs.freedesktop.org/show_bug.cgi?id=103191
[fdo#103558]: https://bugs.freedesktop.org/show_bug.cgi?id=103558
[fdo#105079]: https://bugs.freedesktop.org/show_bug.cgi?id=105079
[fdo#105602]: https://bugs.freedesktop.org/show_bug.cgi?id=105602
[fdo#107362]: https://bugs.freedesktop.org/show_bug.cgi?id=107362
[fdo#108529]: https://bugs.freedesktop.org/show_bug.cgi?id=108529
[fdo#108569]: https://bugs.freedesktop.org/show_bug.cgi?id=108569
[fdo#108800]: https://bugs.freedesktop.org/show_bug.cgi?id=108800
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#109276]: https://bugs.freedesktop.org/show_bug.cgi?id=109276
[fdo#109278]: https://bugs.freedesktop.org/show_bug.cgi?id=109278
[fdo#109284]: https://bugs.freedesktop.org/show_bug.cgi?id=109284
[fdo#109285]: https://bugs.freedesktop.org/show_bug.cgi?id=109285
[fdo#109289]: https://bugs.freedesktop.org/show_bug.cgi?id=109289
[fdo#109315]: https://bugs.freedesktop.org/show_bug.cgi?id=109315
[fdo#109485]: https://bugs.freedesktop.org/show_bug.cgi?id=109485
[fdo#109513]: https://bugs.freedesktop.org/show_bug.cgi?id=109513
Participating hosts (48 -> 43)
------------------------------
Additional (1): fi-icl-u3
Missing (6): fi-kbl-soraka fi-ilk-m540 fi-byt-squawks fi-bsw-cyan fi-icl-y fi-bdw-samus
Build changes
-------------
* IGT: IGT_4815 -> IGTPW_2367
CI_DRM_5568: d4794b009ccd1ef8816e15c833f07ab696911a8d @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_2367: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2367/
IGT_4815: 947301563259726b65ce47d3a3fe37931ed42efe @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
== Testlist changes ==
+igt@core_auth@unauth-vs-render
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2367/
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-02-08 18:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-08 18:03 [igt-dev] [PATCH i-g-t] tests/core_unauth_vs_render: new test for the relaxed DRM_AUTH handling Emil Velikov
2019-02-08 18:47 ` [igt-dev] ✗ Fi.CI.BAT: failure for tests/core_unauth_vs_render: new test for the relaxed DRM_AUTH handling (rev3) Patchwork
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox