All of lore.kernel.org
 help / color / mirror / Atom feed
* [igt-dev] [PATCH i-g-t v2] ts/core_setmaster: new test for drop/set master semantics
@ 2020-02-19 14:24 Emil Velikov
  2020-02-19 15:41 ` [igt-dev] ✗ GitLab.Pipeline: failure for ts/core_setmaster: new test for drop/set master semantics (rev2) Patchwork
                   ` (4 more replies)
  0 siblings, 5 replies; 12+ messages in thread
From: Emil Velikov @ 2020-02-19 14:24 UTC (permalink / raw)
  To: igt-dev

From: Emil Velikov <emil.velikov@collabora.com>

This test adds three distinct subtests:
 - drop/set master as root
 - drop/set master as non-root
 - drop/set master for a shared fd

Currently the second subtest will fail, with kernel patch to address
that has been submitted.

v2: Add to the autotools build

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
---
 tests/Makefile.sources |   1 +
 tests/core_setmaster.c | 182 +++++++++++++++++++++++++++++++++++++++++
 tests/meson.build      |   1 +
 3 files changed, 184 insertions(+)
 create mode 100644 tests/core_setmaster.c

diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index b87d6333..5da36a91 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -18,6 +18,7 @@ TESTS_progs = \
 	core_getclient \
 	core_getstats \
 	core_getversion \
+	core_setmaster \
 	core_setmaster_vs_auth \
 	debugfs_test \
 	dmabuf \
diff --git a/tests/core_setmaster.c b/tests/core_setmaster.c
new file mode 100644
index 00000000..2447c077
--- /dev/null
+++ b/tests/core_setmaster.c
@@ -0,0 +1,182 @@
+/*
+ * Copyright © 2020 Collabora, Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ * Authors:
+ *    Emil Velikov <emil.l.velikov@gmail.com>
+ *
+ */
+
+/*
+ * Testcase: Check that drop/setMaster behaves correctly wrt root/user access
+ *
+ * Test checks if the ioctls succeed or fail, depending if the applications was
+ * run with root, user privileges or if we have separate privileged arbitrator.
+ */
+
+#include "igt.h"
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/stat.h>
+
+IGT_TEST_DESCRIPTION("Check that drop/setMaster behaves correctly wrt root/user"
+		     " access");
+
+static bool is_master(int fd)
+{
+	/* FIXME: replace with drmIsMaster once we bumped libdrm version */
+	return drmAuthMagic(fd, 0) != -EACCES;
+}
+
+static void check_drop_set(void)
+{
+	int master;
+
+	master = __drm_open_driver(DRIVER_ANY);
+
+	/* Double-check if open has failed */
+	igt_assert_neq(master, -1);
+
+	/* At this point we're master capable due to:
+	 * - being root - always
+	 * - normal user - as the only drm only drm client (on this VT)
+	 */
+	igt_assert_eq(is_master(master), true);
+
+	/* If we have SYS_CAP_ADMIN we're in the textbook best-case scenario.
+	 *
+	 * Otherwise newer kernels allow the application to drop/revoke its
+	 * master capability and request it again later.
+	 *
+	 * In this case, we address two types of issues:
+	 * - the application no longer need suid-root (or equivalent) which
+	 * was otherwise required _solely_ for these two ioctls
+	 * - plenty of applications ignore (or discard) the result of the
+	 * calls all together.
+	 */
+	igt_assert_eq(drmDropMaster(master), 0);
+	igt_assert_eq(drmSetMaster(master), 0);
+
+	close(master);
+}
+
+static unsigned tweak_perm(uint8_t *saved_perm, unsigned max_perm, bool save)
+{
+	char path[256];
+	struct stat st;
+	unsigned i;
+
+	for (i = 0; i < max_perm; i++) {
+		snprintf(path, sizeof(path), "/dev/dri/card%u", i);
+
+		/* Existing userspace assumes there's no gaps, do the same. */
+		if (stat(path, &st) != 0)
+			break;
+
+		if (save) {
+			/* Save and toggle */
+			saved_perm[i] = st.st_mode & (S_IROTH | S_IWOTH);
+			st.st_mode |= S_IROTH | S_IWOTH;
+		} else {
+			/* Clear and restore */
+			st.st_mode &= ~(S_IROTH | S_IWOTH);
+			st.st_mode |= saved_perm[i];
+		}
+
+		/* In the extremely unlikely case of this failing, there't not
+		 * much we can do.
+		 */
+		chmod(path, st.st_mode);
+	}
+	return i;
+}
+
+
+igt_main
+{
+	igt_subtest("master-drop-set-root") {
+		check_drop_set();
+	}
+
+
+	igt_subtest("master-drop-set-user") {
+		uint8_t saved_perm[255];
+		unsigned num;
+
+		/* Upon dropping root we end up as random user, which
+		 * a) is not in the video group, and
+		 * b) lacks logind ACL, thus
+		 * any open() fill fail.
+		 *
+		 * As such, save the state of original other rw permissions
+		 * and toggle them on.
+		 */
+		num = tweak_perm(saved_perm, ARRAY_SIZE(saved_perm), true);
+
+		igt_fork(child, 1) {
+			igt_drop_root();
+			check_drop_set();
+		}
+		igt_waitchildren();
+
+		/* Restore the orignal permissions */
+		tweak_perm(saved_perm, num, false);
+	}
+
+	igt_subtest("master-drop-set-shared-fd") {
+		int master;
+
+		master = __drm_open_driver(DRIVER_ANY);
+
+		/* Double-check if open has failed */
+		igt_assert_neq(master, -1);
+
+		igt_assert_eq(is_master(master), true);
+		igt_fork(child, 1) {
+			igt_drop_root();
+
+			/* Dropping root privileges should not alter the
+			 * master capability of the fd */
+			igt_assert_eq(is_master(master), true);
+
+			/* Even though we've got the master capable fd, we're
+			 * a different process (kernel struct pid *) than the
+			 * one which opened the device node.
+			 *
+			 * This ensures that existing workcases of separate
+			 * (privileged) arbitrator still work. For example:
+			 * - logind + X/Wayland compositor
+			 * - weston-launch + weston
+			 */
+			igt_assert_eq(drmDropMaster(master), -1);
+			igt_assert_eq(errno, EACCES);
+			igt_assert_eq(drmSetMaster(master), -1);
+			igt_assert_eq(errno, EACCES);
+
+			close(master);
+		}
+		igt_waitchildren();
+
+		close(master);
+	}
+}
diff --git a/tests/meson.build b/tests/meson.build
index fa0103e3..d8fb9f3e 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -3,6 +3,7 @@ test_progs = [
 	'core_getclient',
 	'core_getstats',
 	'core_getversion',
+	'core_setmaster',
 	'core_setmaster_vs_auth',
 	'debugfs_test',
 	'dmabuf',
-- 
2.25.0

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [igt-dev] ✗ GitLab.Pipeline: failure for ts/core_setmaster: new test for drop/set master semantics (rev2)
  2020-02-19 14:24 [igt-dev] [PATCH i-g-t v2] ts/core_setmaster: new test for drop/set master semantics Emil Velikov
@ 2020-02-19 15:41 ` Patchwork
  2020-02-19 15:59 ` [igt-dev] ✓ Fi.CI.BAT: success " Patchwork
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 12+ messages in thread
From: Patchwork @ 2020-02-19 15:41 UTC (permalink / raw)
  To: Emil Velikov; +Cc: igt-dev

== Series Details ==

Series: ts/core_setmaster: new test for drop/set master semantics (rev2)
URL   : https://patchwork.freedesktop.org/series/73650/
State : failure

== Summary ==

ERROR! This series introduces new undocumented tests:

core_setmaster@master-drop-set-root
core_setmaster@master-drop-set-shared-fd
core_setmaster@master-drop-set-user

Can you document them as per the requirement in the [CONTRIBUTING.md]?

[Documentation] has more details on how to do this.

Here are few examples:
https://gitlab.freedesktop.org/drm/igt-gpu-tools/commit/0316695d03aa46108296b27f3982ec93200c7a6e
https://gitlab.freedesktop.org/drm/igt-gpu-tools/commit/443cc658e1e6b492ee17bf4f4d891029eb7a205d

Thanks in advance!

[CONTRIBUTING.md]: https://gitlab.freedesktop.org/drm/igt-gpu-tools/blob/master/CONTRIBUTING.md#L19
[Documentation]: https://drm.pages.freedesktop.org/igt-gpu-tools/igt-gpu-tools-Core.html#igt-describe

Other than that, pipeline status: SUCCESS.

see https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/pipelines/110362 for the overview.

== Logs ==

For more details see: https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/pipelines/110362
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [igt-dev] ✓ Fi.CI.BAT: success for ts/core_setmaster: new test for drop/set master semantics (rev2)
  2020-02-19 14:24 [igt-dev] [PATCH i-g-t v2] ts/core_setmaster: new test for drop/set master semantics Emil Velikov
  2020-02-19 15:41 ` [igt-dev] ✗ GitLab.Pipeline: failure for ts/core_setmaster: new test for drop/set master semantics (rev2) Patchwork
@ 2020-02-19 15:59 ` Patchwork
  2020-02-19 16:20 ` [igt-dev] [PATCH i-g-t v2] ts/core_setmaster: new test for drop/set master semantics Emil Velikov
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 12+ messages in thread
From: Patchwork @ 2020-02-19 15:59 UTC (permalink / raw)
  To: Emil Velikov; +Cc: igt-dev

== Series Details ==

Series: ts/core_setmaster: new test for drop/set master semantics (rev2)
URL   : https://patchwork.freedesktop.org/series/73650/
State : success

== Summary ==

CI Bug Log - changes from IGT_5451 -> IGTPW_4186
====================================================

Summary
-------

  **SUCCESS**

  No regressions found.

  External URL: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4186/index.html

Known issues
------------

  Here are the changes found in IGTPW_4186 that come from known issues:

### IGT changes ###

#### Issues hit ####

  * igt@i915_selftest@live_gem_contexts:
    - fi-ivb-3770:        [PASS][1] -> [DMESG-FAIL][2] ([i915#722])
   [1]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5451/fi-ivb-3770/igt@i915_selftest@live_gem_contexts.html
   [2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4186/fi-ivb-3770/igt@i915_selftest@live_gem_contexts.html

  
#### Possible fixes ####

  * igt@gem_close_race@basic-threads:
    - fi-hsw-peppy:       [INCOMPLETE][3] ([i915#694] / [i915#816]) -> [PASS][4]
   [3]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5451/fi-hsw-peppy/igt@gem_close_race@basic-threads.html
   [4]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4186/fi-hsw-peppy/igt@gem_close_race@basic-threads.html

  * igt@i915_selftest@live_gtt:
    - fi-icl-guc:         [TIMEOUT][5] ([fdo#112271]) -> [PASS][6]
   [5]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5451/fi-icl-guc/igt@i915_selftest@live_gtt.html
   [6]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4186/fi-icl-guc/igt@i915_selftest@live_gtt.html

  
  {name}: This element is suppressed. This means it is ignored when computing
          the status of the difference (SUCCESS, WARNING, or FAILURE).

  [fdo#112126]: https://bugs.freedesktop.org/show_bug.cgi?id=112126
  [fdo#112271]: https://bugs.freedesktop.org/show_bug.cgi?id=112271
  [i915#694]: https://gitlab.freedesktop.org/drm/intel/issues/694
  [i915#722]: https://gitlab.freedesktop.org/drm/intel/issues/722
  [i915#816]: https://gitlab.freedesktop.org/drm/intel/issues/816


Participating hosts (52 -> 46)
------------------------------

  Additional (1): fi-kbl-7560u 
  Missing    (7): fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-ctg-p8600 fi-byt-clapper fi-bdw-samus 


Build changes
-------------

  * CI: CI-20190529 -> None
  * IGT: IGT_5451 -> IGTPW_4186

  CI-20190529: 20190529
  CI_DRM_7965: e2896d5957301e0411d7048e724d4dc5c96450ea @ git://anongit.freedesktop.org/gfx-ci/linux
  IGTPW_4186: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4186/index.html
  IGT_5451: 1c42f971d37a066da3e588783611ab08d5afbded @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools



== Testlist changes ==

+igt@core_setmaster@master-drop-set-root
+igt@core_setmaster@master-drop-set-shared-fd
+igt@core_setmaster@master-drop-set-user

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4186/index.html
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [igt-dev] [PATCH i-g-t v2] ts/core_setmaster: new test for drop/set master semantics
  2020-02-19 14:24 [igt-dev] [PATCH i-g-t v2] ts/core_setmaster: new test for drop/set master semantics Emil Velikov
  2020-02-19 15:41 ` [igt-dev] ✗ GitLab.Pipeline: failure for ts/core_setmaster: new test for drop/set master semantics (rev2) Patchwork
  2020-02-19 15:59 ` [igt-dev] ✓ Fi.CI.BAT: success " Patchwork
@ 2020-02-19 16:20 ` Emil Velikov
  2020-02-21  9:30 ` [igt-dev] ✓ Fi.CI.IGT: success for ts/core_setmaster: new test for drop/set master semantics (rev2) Patchwork
  2020-02-21 11:58 ` [igt-dev] [PATCH i-g-t v2] ts/core_setmaster: new test for drop/set master semantics Petri Latvala
  4 siblings, 0 replies; 12+ messages in thread
From: Emil Velikov @ 2020-02-19 16:20 UTC (permalink / raw)
  To: IGT development

HI all,

On Wed, 19 Feb 2020 at 14:24, Emil Velikov <emil.l.velikov@gmail.com> wrote:
>
> From: Emil Velikov <emil.velikov@collabora.com>
>
> This test adds three distinct subtests:
>  - drop/set master as root
>  - drop/set master as non-root
>  - drop/set master for a shared fd
>
> Currently the second subtest will fail, with kernel patch to address
> that has been submitted.
>
> v2: Add to the autotools build
>
I've addressed the "igt_describe" issues, but will postpone v3 until
there's feedback on the patch.
Not a huge fan of spamming the CI ;-)

Aside: from a quick grep about 10% of the existing subtests have a
igt_describe section.
Guess we should bribe someone to address that, otherwise people are
bound to skip igt_describe all the time.

Thanks
Emil
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [igt-dev] ✓ Fi.CI.IGT: success for ts/core_setmaster: new test for drop/set master semantics (rev2)
  2020-02-19 14:24 [igt-dev] [PATCH i-g-t v2] ts/core_setmaster: new test for drop/set master semantics Emil Velikov
                   ` (2 preceding siblings ...)
  2020-02-19 16:20 ` [igt-dev] [PATCH i-g-t v2] ts/core_setmaster: new test for drop/set master semantics Emil Velikov
@ 2020-02-21  9:30 ` Patchwork
  2020-02-21 11:36   ` Emil Velikov
  2020-02-21 11:58 ` [igt-dev] [PATCH i-g-t v2] ts/core_setmaster: new test for drop/set master semantics Petri Latvala
  4 siblings, 1 reply; 12+ messages in thread
From: Patchwork @ 2020-02-21  9:30 UTC (permalink / raw)
  To: Emil Velikov; +Cc: igt-dev

== Series Details ==

Series: ts/core_setmaster: new test for drop/set master semantics (rev2)
URL   : https://patchwork.freedesktop.org/series/73650/
State : success

== Summary ==

CI Bug Log - changes from IGT_5451_full -> IGTPW_4186_full
====================================================

Summary
-------

  **SUCCESS**

  No regressions found.

  External URL: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4186/index.html

Possible new issues
-------------------

  Here are the unknown changes that may have been introduced in IGTPW_4186_full:

### IGT changes ###

#### Possible regressions ####

  * {igt@core_setmaster@master-drop-set-user} (NEW):
    - shard-iclb:         NOTRUN -> [FAIL][1]
   [1]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4186/shard-iclb1/igt@core_setmaster@master-drop-set-user.html
    - shard-kbl:          NOTRUN -> [FAIL][2]
   [2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4186/shard-kbl6/igt@core_setmaster@master-drop-set-user.html
    - shard-snb:          NOTRUN -> [FAIL][3]
   [3]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4186/shard-snb1/igt@core_setmaster@master-drop-set-user.html
    - shard-tglb:         NOTRUN -> [FAIL][4]
   [4]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4186/shard-tglb5/igt@core_setmaster@master-drop-set-user.html
    - shard-apl:          NOTRUN -> [FAIL][5]
   [5]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4186/shard-apl7/igt@core_setmaster@master-drop-set-user.html
    - shard-glk:          NOTRUN -> [FAIL][6]
   [6]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4186/shard-glk4/igt@core_setmaster@master-drop-set-user.html
    - shard-hsw:          NOTRUN -> [FAIL][7]
   [7]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4186/shard-hsw1/igt@core_setmaster@master-drop-set-user.html

  
New tests
---------

  New tests have been introduced between IGT_5451_full and IGTPW_4186_full:

### New IGT tests (3) ###

  * igt@core_setmaster@master-drop-set-root:
    - Statuses : 7 pass(s)
    - Exec time: [0.00, 0.01] s

  * igt@core_setmaster@master-drop-set-shared-fd:
    - Statuses : 7 pass(s)
    - Exec time: [0.01, 0.04] s

  * igt@core_setmaster@master-drop-set-user:
    - Statuses : 7 fail(s)
    - Exec time: [0.02, 0.04] s

  

Known issues
------------

  Here are the changes found in IGTPW_4186_full that come from known issues:

### IGT changes ###

#### Issues hit ####

  * igt@gem_ctx_isolation@rcs0-s3:
    - shard-kbl:          [PASS][8] -> [INCOMPLETE][9] ([fdo#103665])
   [8]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5451/shard-kbl2/igt@gem_ctx_isolation@rcs0-s3.html
   [9]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4186/shard-kbl2/igt@gem_ctx_isolation@rcs0-s3.html

  * igt@gem_exec_schedule@pi-distinct-iova-bsd:
    - shard-iclb:         [PASS][10] -> [SKIP][11] ([i915#677]) +1 similar issue
   [10]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5451/shard-iclb6/igt@gem_exec_schedule@pi-distinct-iova-bsd.html
   [11]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4186/shard-iclb4/igt@gem_exec_schedule@pi-distinct-iova-bsd.html

  * igt@gem_exec_schedule@pi-ringfull-bsd:
    - shard-iclb:         [PASS][12] -> [SKIP][13] ([fdo#112146]) +6 similar issues
   [12]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5451/shard-iclb8/igt@gem_exec_schedule@pi-ringfull-bsd.html
   [13]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4186/shard-iclb4/igt@gem_exec_schedule@pi-ringfull-bsd.html

  * igt@gem_partial_pwrite_pread@write-uncached:
    - shard-hsw:          [PASS][14] -> [FAIL][15] ([i915#694])
   [14]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5451/shard-hsw6/igt@gem_partial_pwrite_pread@write-uncached.html
   [15]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4186/shard-hsw2/igt@gem_partial_pwrite_pread@write-uncached.html

  * igt@gem_workarounds@suspend-resume-context:
    - shard-apl:          [PASS][16] -> [DMESG-WARN][17] ([i915#180]) +5 similar issues
   [16]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5451/shard-apl3/igt@gem_workarounds@suspend-resume-context.html
   [17]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4186/shard-apl1/igt@gem_workarounds@suspend-resume-context.html

  * igt@i915_suspend@sysfs-reader:
    - shard-kbl:          [PASS][18] -> [DMESG-WARN][19] ([i915#180]) +1 similar issue
   [18]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5451/shard-kbl6/igt@i915_suspend@sysfs-reader.html
   [19]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4186/shard-kbl7/igt@i915_suspend@sysfs-reader.html

  * igt@kms_cursor_crc@pipe-c-cursor-256x85-onscreen:
    - shard-apl:          [PASS][20] -> [FAIL][21] ([i915#54])
   [20]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5451/shard-apl7/igt@kms_cursor_crc@pipe-c-cursor-256x85-onscreen.html
   [21]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4186/shard-apl1/igt@kms_cursor_crc@pipe-c-cursor-256x85-onscreen.html

  * igt@kms_cursor_legacy@2x-flip-vs-cursor-atomic:
    - shard-glk:          [PASS][22] -> [FAIL][23] ([i915#72])
   [22]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5451/shard-glk5/igt@kms_cursor_legacy@2x-flip-vs-cursor-atomic.html
   [23]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4186/shard-glk2/igt@kms_cursor_legacy@2x-flip-vs-cursor-atomic.html

  * igt@kms_flip@dpms-vs-vblank-race:
    - shard-hsw:          [PASS][24] -> [INCOMPLETE][25] ([CI#80] / [i915#61])
   [24]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5451/shard-hsw8/igt@kms_flip@dpms-vs-vblank-race.html
   [25]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4186/shard-hsw5/igt@kms_flip@dpms-vs-vblank-race.html

  * igt@kms_frontbuffer_tracking@fbcpsr-rgb101010-draw-pwrite:
    - shard-tglb:         [PASS][26] -> [SKIP][27] ([i915#668])
   [26]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5451/shard-tglb6/igt@kms_frontbuffer_tracking@fbcpsr-rgb101010-draw-pwrite.html
   [27]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4186/shard-tglb1/igt@kms_frontbuffer_tracking@fbcpsr-rgb101010-draw-pwrite.html

  * igt@kms_psr@psr2_sprite_mmap_gtt:
    - shard-iclb:         [PASS][28] -> [SKIP][29] ([fdo#109441]) +1 similar issue
   [28]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5451/shard-iclb2/igt@kms_psr@psr2_sprite_mmap_gtt.html
   [29]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4186/shard-iclb8/igt@kms_psr@psr2_sprite_mmap_gtt.html

  * igt@perf_pmu@busy-no-semaphores-vcs1:
    - shard-iclb:         [PASS][30] -> [SKIP][31] ([fdo#112080]) +9 similar issues
   [30]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5451/shard-iclb4/igt@perf_pmu@busy-no-semaphores-vcs1.html
   [31]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4186/shard-iclb8/igt@perf_pmu@busy-no-semaphores-vcs1.html

  * igt@prime_vgem@fence-wait-bsd2:
    - shard-iclb:         [PASS][32] -> [SKIP][33] ([fdo#109276]) +21 similar issues
   [32]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5451/shard-iclb1/igt@prime_vgem@fence-wait-bsd2.html
   [33]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4186/shard-iclb3/igt@prime_vgem@fence-wait-bsd2.html

  
#### Possible fixes ####

  * igt@gem_busy@busy-vcs1:
    - shard-iclb:         [SKIP][34] ([fdo#112080]) -> [PASS][35] +18 similar issues
   [34]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5451/shard-iclb8/igt@gem_busy@busy-vcs1.html
   [35]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4186/shard-iclb4/igt@gem_busy@busy-vcs1.html

  * {igt@gem_ctx_persistence@close-replace-race}:
    - shard-tglb:         [INCOMPLETE][36] -> [PASS][37]
   [36]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5451/shard-tglb3/igt@gem_ctx_persistence@close-replace-race.html
   [37]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4186/shard-tglb3/igt@gem_ctx_persistence@close-replace-race.html
    - shard-iclb:         [INCOMPLETE][38] -> [PASS][39]
   [38]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5451/shard-iclb8/igt@gem_ctx_persistence@close-replace-race.html
   [39]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4186/shard-iclb1/igt@gem_ctx_persistence@close-replace-race.html

  * igt@gem_exec_balancer@bonded-slice:
    - shard-kbl:          [FAIL][40] -> [PASS][41]
   [40]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5451/shard-kbl4/igt@gem_exec_balancer@bonded-slice.html
   [41]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4186/shard-kbl4/igt@gem_exec_balancer@bonded-slice.html

  * igt@gem_exec_balancer@smoke:
    - shard-iclb:         [SKIP][42] ([fdo#110854]) -> [PASS][43]
   [42]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5451/shard-iclb6/igt@gem_exec_balancer@smoke.html
   [43]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4186/shard-iclb4/igt@gem_exec_balancer@smoke.html

  * {igt@gem_exec_schedule@implicit-read-write-bsd1}:
    - shard-iclb:         [SKIP][44] ([fdo#109276] / [i915#677]) -> [PASS][45] +1 similar issue
   [44]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5451/shard-iclb8/igt@gem_exec_schedule@implicit-read-write-bsd1.html
   [45]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4186/shard-iclb2/igt@gem_exec_schedule@implicit-read-write-bsd1.html

  * {igt@gem_exec_schedule@implicit-write-read-bsd}:
    - shard-iclb:         [SKIP][46] ([i915#677]) -> [PASS][47]
   [46]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5451/shard-iclb1/igt@gem_exec_schedule@implicit-write-read-bsd.html
   [47]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4186/shard-iclb7/igt@gem_exec_schedule@implicit-write-read-bsd.html

  * igt@gem_exec_schedule@in-order-bsd:
    - shard-iclb:         [SKIP][48] ([fdo#112146]) -> [PASS][49] +4 similar issues
   [48]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5451/shard-iclb4/igt@gem_exec_schedule@in-order-bsd.html
   [49]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4186/shard-iclb5/igt@gem_exec_schedule@in-order-bsd.html

  * igt@gem_exec_schedule@promotion-bsd1:
    - shard-iclb:         [SKIP][50] ([fdo#109276]) -> [PASS][51] +21 similar issues
   [50]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5451/shard-iclb5/igt@gem_exec_schedule@promotion-bsd1.html
   [51]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4186/shard-iclb4/igt@gem_exec_schedule@promotion-bsd1.html

  * igt@gem_tiled_blits@interruptible:
    - shard-hsw:          [FAIL][52] ([i915#694]) -> [PASS][53]
   [52]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5451/shard-hsw5/igt@gem_tiled_blits@interruptible.html
   [53]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4186/shard-hsw5/igt@gem_tiled_blits@interruptible.html

  * igt@kms_cursor_crc@pipe-b-cursor-suspend:
    - shard-apl:          [DMESG-WARN][54] ([i915#180]) -> [PASS][55] +2 similar issues
   [54]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5451/shard-apl4/igt@kms_cursor_crc@pipe-b-cursor-suspend.html
   [55]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4186/shard-apl3/igt@kms_cursor_crc@pipe-b-cursor-suspend.html

  * igt@kms_flip@flip-vs-expired-vblank:
    - shard-kbl:          [FAIL][56] ([i915#79]) -> [PASS][57]
   [56]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5451/shard-kbl2/igt@kms_flip@flip-vs-expired-vblank.html
   [57]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4186/shard-kbl6/igt@kms_flip@flip-vs-expired-vblank.html

  * igt@kms_plane@pixel-format-pipe-b-planes:
    - shard-snb:          [DMESG-WARN][58] ([i915#478]) -> [PASS][59]
   [58]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5451/shard-snb4/igt@kms_plane@pixel-format-pipe-b-planes.html
   [59]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4186/shard-snb1/igt@kms_plane@pixel-format-pipe-b-planes.html

  * igt@kms_plane_lowres@pipe-a-tiling-y:
    - shard-glk:          [FAIL][60] ([i915#899]) -> [PASS][61]
   [60]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5451/shard-glk9/igt@kms_plane_lowres@pipe-a-tiling-y.html
   [61]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4186/shard-glk6/igt@kms_plane_lowres@pipe-a-tiling-y.html

  * igt@kms_psr@psr2_sprite_plane_move:
    - shard-iclb:         [SKIP][62] ([fdo#109441]) -> [PASS][63] +2 similar issues
   [62]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5451/shard-iclb7/igt@kms_psr@psr2_sprite_plane_move.html
   [63]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4186/shard-iclb2/igt@kms_psr@psr2_sprite_plane_move.html

  * igt@kms_vblank@pipe-a-ts-continuation-suspend:
    - shard-kbl:          [DMESG-WARN][64] ([i915#180]) -> [PASS][65] +4 similar issues
   [64]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5451/shard-kbl6/igt@kms_vblank@pipe-a-ts-continuation-suspend.html
   [65]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4186/shard-kbl2/igt@kms_vblank@pipe-a-ts-continuation-suspend.html

  * igt@perf@gen12-mi-rpc:
    - shard-tglb:         [TIMEOUT][66] ([fdo#112271] / [i915#1085]) -> [PASS][67]
   [66]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5451/shard-tglb1/igt@perf@gen12-mi-rpc.html
   [67]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4186/shard-tglb7/igt@perf@gen12-mi-rpc.html

  * igt@prime_mmap_coherency@ioctl-errors:
    - shard-hsw:          [FAIL][68] ([i915#831]) -> [PASS][69]
   [68]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5451/shard-hsw7/igt@prime_mmap_coherency@ioctl-errors.html
   [69]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4186/shard-hsw7/igt@prime_mmap_coherency@ioctl-errors.html

  
#### Warnings ####

  * igt@gem_ctx_isolation@vcs1-nonpriv:
    - shard-iclb:         [SKIP][70] ([fdo#112080]) -> [FAIL][71] ([IGT#28])
   [70]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5451/shard-iclb3/igt@gem_ctx_isolation@vcs1-nonpriv.html
   [71]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4186/shard-iclb4/igt@gem_ctx_isolation@vcs1-nonpriv.html

  * igt@i915_pm_dc@dc6-dpms:
    - shard-tglb:         [FAIL][72] ([i915#454]) -> [SKIP][73] ([i915#468])
   [72]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5451/shard-tglb1/igt@i915_pm_dc@dc6-dpms.html
   [73]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4186/shard-tglb2/igt@i915_pm_dc@dc6-dpms.html

  * igt@i915_pm_dc@dc6-psr:
    - shard-tglb:         [SKIP][74] ([i915#468]) -> [FAIL][75] ([i915#454])
   [74]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5451/shard-tglb2/igt@i915_pm_dc@dc6-psr.html
   [75]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4186/shard-tglb7/igt@i915_pm_dc@dc6-psr.html

  * igt@i915_pm_rpm@fences-dpms:
    - shard-snb:          [SKIP][76] ([fdo#109271]) -> [INCOMPLETE][77] ([i915#82])
   [76]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5451/shard-snb2/igt@i915_pm_rpm@fences-dpms.html
   [77]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4186/shard-snb4/igt@i915_pm_rpm@fences-dpms.html

  
  {name}: This element is suppressed. This means it is ignored when computing
          the status of the difference (SUCCESS, WARNING, or FAILURE).

  [CI#80]: https://gitlab.freedesktop.org/gfx-ci/i915-infra/issues/80
  [IGT#28]: https://gitlab.freedesktop.org/drm/igt-gpu-tools/issues/28
  [fdo#103665]: https://bugs.freedesktop.org/show_bug.cgi?id=103665
  [fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
  [fdo#109276]: https://bugs.freedesktop.org/show_bug.cgi?id=109276
  [fdo#109441]: https://bugs.freedesktop.org/show_bug.cgi?id=109441
  [fdo#110854]: https://bugs.freedesktop.org/show_bug.cgi?id=110854
  [fdo#112080]: https://bugs.freedesktop.org/show_bug.cgi?id=112080
  [fdo#112146]: https://bugs.freedesktop.org/show_bug.cgi?id=112146
  [fdo#112271]: https://bugs.freedesktop.org/show_bug.cgi?id=112271
  [i915#1085]: https://gitlab.freedesktop.org/drm/intel/issues/1085
  [i915#180]: https://gitlab.freedesktop.org/drm/intel/issues/180
  [i915#454]: https://gitlab.freedesktop.org/drm/intel/issues/454
  [i915#468]: https://gitlab.freedesktop.org/drm/intel/issues/468
  [i915#478]: https://gitlab.freedesktop.org/drm/intel/issues/478
  [i915#54]: https://gitlab.freedesktop.org/drm/intel/issues/54
  [i915#58]: https://gitlab.freedesktop.org/drm/intel/issues/58
  [i915#61]: https://gitlab.freedesktop.org/drm/intel/issues/61
  [i915#668]: https://gitlab.freedesktop.org/drm/intel/issues/668
  [i915#677]: https://gitlab.freedesktop.org/drm/intel/issues/677
  [i915#694]: https://gitlab.freedesktop.org/drm/intel/issues/694
  [i915#72]: https://gitlab.freedesktop.org/drm/intel/issues/72
  [i915#79]: https://gitlab.freedesktop.org/drm/intel/issues/79
  [i915#82]: https://gitlab.freedesktop.org/drm/intel/issues/82
  [i915#831]: https://gitlab.freedesktop.org/drm/intel/issues/831
  [i915#899]: https://gitlab.freedesktop.org/drm/intel/issues/899
  [k.org#198133]: https://bugzilla.kernel.org/show_bug.cgi?id=198133


Participating hosts (8 -> 8)
------------------------------

  No changes in participating hosts


Build changes
-------------

  * CI: CI-20190529 -> None
  * IGT: IGT_5451 -> IGTPW_4186

  CI-20190529: 20190529
  CI_DRM_7965: e2896d5957301e0411d7048e724d4dc5c96450ea @ git://anongit.freedesktop.org/gfx-ci/linux
  IGTPW_4186: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4186/index.html
  IGT_5451: 1c42f971d37a066da3e588783611ab08d5afbded @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4186/index.html
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [igt-dev] ✓ Fi.CI.IGT: success for ts/core_setmaster: new test for drop/set master semantics (rev2)
  2020-02-21  9:30 ` [igt-dev] ✓ Fi.CI.IGT: success for ts/core_setmaster: new test for drop/set master semantics (rev2) Patchwork
@ 2020-02-21 11:36   ` Emil Velikov
  0 siblings, 0 replies; 12+ messages in thread
From: Emil Velikov @ 2020-02-21 11:36 UTC (permalink / raw)
  To: IGT development

Hi all

On Fri, 21 Feb 2020 at 09:30, Patchwork
<patchwork@emeril.freedesktop.org> wrote:
>
> == Series Details ==
>
> Series: ts/core_setmaster: new test for drop/set master semantics (rev2)
> URL   : https://patchwork.freedesktop.org/series/73650/
> State : success
>
> == Summary ==
>
> CI Bug Log - changes from IGT_5451_full -> IGTPW_4186_full
> ====================================================
>
> Summary
> -------
>
>   **SUCCESS**
>
>   No regressions found.
>
>   External URL: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4186/index.html
>
> Possible new issues
> -------------------
>
>   Here are the unknown changes that may have been introduced in IGTPW_4186_full:
>
> ### IGT changes ###
>
> #### Possible regressions ####
>
>   * {igt@core_setmaster@master-drop-set-user} (NEW):

For anyone wondering, the failure is expected as outlined in the commit message.
The patch to address the issue can be found on the dri-devel mailing list[1].

Feedback and review is highly appreciated. For both the IGT test and DRM patch.

Thanks
Emil

[1] https://lists.freedesktop.org/archives/dri-devel/2020-February/255718.html
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [igt-dev] [PATCH i-g-t v2] ts/core_setmaster: new test for drop/set master semantics
  2020-02-19 14:24 [igt-dev] [PATCH i-g-t v2] ts/core_setmaster: new test for drop/set master semantics Emil Velikov
                   ` (3 preceding siblings ...)
  2020-02-21  9:30 ` [igt-dev] ✓ Fi.CI.IGT: success for ts/core_setmaster: new test for drop/set master semantics (rev2) Patchwork
@ 2020-02-21 11:58 ` Petri Latvala
  2020-02-21 12:19   ` Petri Latvala
  2020-02-21 13:55   ` Emil Velikov
  4 siblings, 2 replies; 12+ messages in thread
From: Petri Latvala @ 2020-02-21 11:58 UTC (permalink / raw)
  To: Emil Velikov; +Cc: igt-dev

On Wed, Feb 19, 2020 at 02:24:45PM +0000, Emil Velikov wrote:
> From: Emil Velikov <emil.velikov@collabora.com>
> 
> This test adds three distinct subtests:
>  - drop/set master as root
>  - drop/set master as non-root
>  - drop/set master for a shared fd
> 
> Currently the second subtest will fail, with kernel patch to address
> that has been submitted.
> 
> v2: Add to the autotools build
> 
> Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
> ---
>  tests/Makefile.sources |   1 +
>  tests/core_setmaster.c | 182 +++++++++++++++++++++++++++++++++++++++++
>  tests/meson.build      |   1 +
>  3 files changed, 184 insertions(+)
>  create mode 100644 tests/core_setmaster.c
> 
> diff --git a/tests/Makefile.sources b/tests/Makefile.sources
> index b87d6333..5da36a91 100644
> --- a/tests/Makefile.sources
> +++ b/tests/Makefile.sources
> @@ -18,6 +18,7 @@ TESTS_progs = \
>  	core_getclient \
>  	core_getstats \
>  	core_getversion \
> +	core_setmaster \
>  	core_setmaster_vs_auth \
>  	debugfs_test \
>  	dmabuf \
> diff --git a/tests/core_setmaster.c b/tests/core_setmaster.c
> new file mode 100644
> index 00000000..2447c077
> --- /dev/null
> +++ b/tests/core_setmaster.c
> @@ -0,0 +1,182 @@
> +/*
> + * Copyright © 2020 Collabora, Ltd.
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the "Software"),
> + * to deal in the Software without restriction, including without limitation
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> + * and/or sell copies of the Software, and to permit persons to whom the
> + * Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice (including the next
> + * paragraph) shall be included in all copies or substantial portions of the
> + * Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
> + * IN THE SOFTWARE.
> + *
> + * Authors:
> + *    Emil Velikov <emil.l.velikov@gmail.com>
> + *
> + */
> +
> +/*
> + * Testcase: Check that drop/setMaster behaves correctly wrt root/user access
> + *
> + * Test checks if the ioctls succeed or fail, depending if the applications was
> + * run with root, user privileges or if we have separate privileged arbitrator.
> + */
> +
> +#include "igt.h"
> +#include <unistd.h>
> +#include <stdlib.h>
> +#include <stdio.h>
> +#include <string.h>
> +#include <sys/stat.h>
> +
> +IGT_TEST_DESCRIPTION("Check that drop/setMaster behaves correctly wrt root/user"
> +		     " access");
> +
> +static bool is_master(int fd)
> +{
> +	/* FIXME: replace with drmIsMaster once we bumped libdrm version */
> +	return drmAuthMagic(fd, 0) != -EACCES;
> +}
> +
> +static void check_drop_set(void)
> +{
> +	int master;
> +
> +	master = __drm_open_driver(DRIVER_ANY);
> +
> +	/* Double-check if open has failed */
> +	igt_assert_neq(master, -1);

Just use drm_open_driver(). For sure you don't want to produce a
'FAIL' when running on a system without GPU drivers. 'SKIP' is correct
for that case.

Same goes for the other __drm_open_driver() call.

> +
> +	/* At this point we're master capable due to:
> +	 * - being root - always
> +	 * - normal user - as the only drm only drm client (on this VT)
> +	 */
> +	igt_assert_eq(is_master(master), true);
> +
> +	/* If we have SYS_CAP_ADMIN we're in the textbook best-case scenario.
> +	 *
> +	 * Otherwise newer kernels allow the application to drop/revoke its
> +	 * master capability and request it again later.
> +	 *
> +	 * In this case, we address two types of issues:
> +	 * - the application no longer need suid-root (or equivalent) which
> +	 * was otherwise required _solely_ for these two ioctls
> +	 * - plenty of applications ignore (or discard) the result of the
> +	 * calls all together.
> +	 */
> +	igt_assert_eq(drmDropMaster(master), 0);
> +	igt_assert_eq(drmSetMaster(master), 0);
> +
> +	close(master);
> +}
> +
> +static unsigned tweak_perm(uint8_t *saved_perm, unsigned max_perm, bool save)
> +{
> +	char path[256];
> +	struct stat st;
> +	unsigned i;
> +
> +	for (i = 0; i < max_perm; i++) {
> +		snprintf(path, sizeof(path), "/dev/dri/card%u", i);
> +
> +		/* Existing userspace assumes there's no gaps, do the same. */
> +		if (stat(path, &st) != 0)
> +			break;
> +
> +		if (save) {
> +			/* Save and toggle */
> +			saved_perm[i] = st.st_mode & (S_IROTH | S_IWOTH);
> +			st.st_mode |= S_IROTH | S_IWOTH;
> +		} else {
> +			/* Clear and restore */
> +			st.st_mode &= ~(S_IROTH | S_IWOTH);
> +			st.st_mode |= saved_perm[i];
> +		}
> +
> +		/* In the extremely unlikely case of this failing, there't not
> +		 * much we can do.

We can igt_require that it works though. chmod failing means we get a
false 'FAIL' from the test.

Restoring failure leaves the system to a state that is going to scare
people with the extra perms...


> +		 */
> +		chmod(path, st.st_mode);
> +	}
> +	return i;
> +}
> +
> +
> +igt_main
> +{
> +	igt_subtest("master-drop-set-root") {
> +		check_drop_set();
> +	}
> +
> +
> +	igt_subtest("master-drop-set-user") {
> +		uint8_t saved_perm[255];
> +		unsigned num;
> +
> +		/* Upon dropping root we end up as random user, which
> +		 * a) is not in the video group, and
> +		 * b) lacks logind ACL, thus
> +		 * any open() fill fail.
> +		 *
> +		 * As such, save the state of original other rw permissions
> +		 * and toggle them on.
> +		 */
> +		num = tweak_perm(saved_perm, ARRAY_SIZE(saved_perm), true);
> +
> +		igt_fork(child, 1) {
> +			igt_drop_root();
> +			check_drop_set();
> +		}
> +		igt_waitchildren();
> +
> +		/* Restore the orignal permissions */
> +		tweak_perm(saved_perm, num, false);

If the test fails we never restore the permissions with this flow. I
suppose this would be the best (but still ugly) way to make that
happen:

igt_fixture {
   tweak_perm(...)
}

igt_subtest("master-drop-set-user") {
...
}

igt_fixture {
  tweak_perm(saved);
}

Wrapping all that in an igt_subtest_group not required but could be
used to communicate to human readers that this is the subtest these
two fixtures are for.



-- 
Petri Latvala
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [igt-dev] [PATCH i-g-t v2] ts/core_setmaster: new test for drop/set master semantics
  2020-02-21 11:58 ` [igt-dev] [PATCH i-g-t v2] ts/core_setmaster: new test for drop/set master semantics Petri Latvala
@ 2020-02-21 12:19   ` Petri Latvala
  2020-02-21 13:55   ` Emil Velikov
  1 sibling, 0 replies; 12+ messages in thread
From: Petri Latvala @ 2020-02-21 12:19 UTC (permalink / raw)
  To: Emil Velikov; +Cc: igt-dev

On Fri, Feb 21, 2020 at 01:58:25PM +0200, Petri Latvala wrote:
> Wrapping all that in an igt_subtest_group not required but could be
> used to communicate to human readers that this is the subtest these
> two fixtures are for.


Correction, it is required if you use igt_require with chmod().


-- 
Petri Latvala
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [igt-dev] [PATCH i-g-t v2] ts/core_setmaster: new test for drop/set master semantics
  2020-02-21 11:58 ` [igt-dev] [PATCH i-g-t v2] ts/core_setmaster: new test for drop/set master semantics Petri Latvala
  2020-02-21 12:19   ` Petri Latvala
@ 2020-02-21 13:55   ` Emil Velikov
  2020-02-24  8:49     ` Petri Latvala
  1 sibling, 1 reply; 12+ messages in thread
From: Emil Velikov @ 2020-02-21 13:55 UTC (permalink / raw)
  To: Petri Latvala; +Cc: IGT development

Hi Petri,

Thank you for having a look.

On Fri, 21 Feb 2020 at 11:58, Petri Latvala <petri.latvala@intel.com> wrote:

> > +static void check_drop_set(void)
> > +{
> > +     int master;
> > +
> > +     master = __drm_open_driver(DRIVER_ANY);
> > +
> > +     /* Double-check if open has failed */
> > +     igt_assert_neq(master, -1);
>
> Just use drm_open_driver(). For sure you don't want to produce a
> 'FAIL' when running on a system without GPU drivers. 'SKIP' is correct
> for that case.
>
This sounds very strange. Why would anyone run IGT if they lack _any_
GPU drivers.
If I'm running GPU tests and my GPU doesn't show up for any reason,
I'd expect a hard failure.

Even if we ignore that, a quick look around shows that there are
multiple tests that will happily pass -1 to forward.
If anything, the only way to trigger this is my dropping the chown() calls.

Hmm ... actually using an igt_skip with drop_root root-less case seems
to be broken.
How about we follow other tests and remove the check?


> > +static unsigned tweak_perm(uint8_t *saved_perm, unsigned max_perm, bool save)
> > +{
> > +     char path[256];
> > +     struct stat st;
> > +     unsigned i;
> > +
> > +     for (i = 0; i < max_perm; i++) {
> > +             snprintf(path, sizeof(path), "/dev/dri/card%u", i);
> > +
> > +             /* Existing userspace assumes there's no gaps, do the same. */
> > +             if (stat(path, &st) != 0)
> > +                     break;
> > +
> > +             if (save) {
> > +                     /* Save and toggle */
> > +                     saved_perm[i] = st.st_mode & (S_IROTH | S_IWOTH);
> > +                     st.st_mode |= S_IROTH | S_IWOTH;
> > +             } else {
> > +                     /* Clear and restore */
> > +                     st.st_mode &= ~(S_IROTH | S_IWOTH);
> > +                     st.st_mode |= saved_perm[i];
> > +             }
> > +
> > +             /* In the extremely unlikely case of this failing, there't not
> > +              * much we can do.
>
> We can igt_require that it works though. chmod failing means we get a
> false 'FAIL' from the test.
>
> Restoring failure leaves the system to a state that is going to scare
> people with the extra perms...
>
AFAICT igt_require will effectively become "igt_skip" on failure.

Thus if it triggers during restore we end up with partially restored attributes.
If it happens during the toggle state, even with the fixture approach
below, we will end up with garbage in saved_perm or the length
variable. And using that data for restore will be bad.

IMHO there isn't any reason this will ever fail... I was super
paranoid as I wrote the comment.
It makes more sense to drop the misleading comment.

What do you think?


> > +     igt_subtest("master-drop-set-user") {
> > +             uint8_t saved_perm[255];
> > +             unsigned num;
> > +
> > +             /* Upon dropping root we end up as random user, which
> > +              * a) is not in the video group, and
> > +              * b) lacks logind ACL, thus
> > +              * any open() fill fail.
> > +              *
> > +              * As such, save the state of original other rw permissions
> > +              * and toggle them on.
> > +              */
> > +             num = tweak_perm(saved_perm, ARRAY_SIZE(saved_perm), true);
> > +
> > +             igt_fork(child, 1) {
> > +                     igt_drop_root();
> > +                     check_drop_set();
> > +             }
> > +             igt_waitchildren();
> > +
> > +             /* Restore the orignal permissions */
> > +             tweak_perm(saved_perm, num, false);
>
> If the test fails we never restore the permissions with this flow. I
> suppose this would be the best (but still ugly) way to make that
> happen:
>
> igt_fixture {
>    tweak_perm(...)
> }
>
> igt_subtest("master-drop-set-user") {
> ...
> }
>
> igt_fixture {
>   tweak_perm(saved);
> }
>
> Wrapping all that in an igt_subtest_group not required but could be
> used to communicate to human readers that this is the subtest these
> two fixtures are for.
>
Indeed this way the permissions are restored on failure - how did I
miss that. Added the fixtures, small comment and a subtest_group.

Let me know how if you agree with my suggestions, and I'll send out v3.

Thanks
Emil
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [igt-dev] [PATCH i-g-t v2] ts/core_setmaster: new test for drop/set master semantics
  2020-02-21 13:55   ` Emil Velikov
@ 2020-02-24  8:49     ` Petri Latvala
  2020-02-24 11:57       ` Emil Velikov
  0 siblings, 1 reply; 12+ messages in thread
From: Petri Latvala @ 2020-02-24  8:49 UTC (permalink / raw)
  To: Emil Velikov; +Cc: IGT development

On Fri, Feb 21, 2020 at 01:55:18PM +0000, Emil Velikov wrote:
> Hi Petri,
> 
> Thank you for having a look.
> 
> On Fri, 21 Feb 2020 at 11:58, Petri Latvala <petri.latvala@intel.com> wrote:
> 
> > > +static void check_drop_set(void)
> > > +{
> > > +     int master;
> > > +
> > > +     master = __drm_open_driver(DRIVER_ANY);
> > > +
> > > +     /* Double-check if open has failed */
> > > +     igt_assert_neq(master, -1);
> >
> > Just use drm_open_driver(). For sure you don't want to produce a
> > 'FAIL' when running on a system without GPU drivers. 'SKIP' is correct
> > for that case.
> >
> This sounds very strange. Why would anyone run IGT if they lack _any_
> GPU drivers.

Accidentally, by breaking the driver module loading.

> If I'm running GPU tests and my GPU doesn't show up for any reason,
> I'd expect a hard failure.

Sure, some kind of a notification for that case is desired. However
the correct notification for that is a SKIP result. Granted, for
DRIVER_ANY open call the story is a bit more far-fetched, but consider
this:

If you get a FAIL from this test, you want to be able to say "I got
that because handling master in kernel is broken". If you can't open a
driver, you can't tell that kernel is broken. The only thing you can
tell is: You can't test the feature. SKIP is exactly that: Can't test
this.


> Even if we ignore that, a quick look around shows that there are
> multiple tests that will happily pass -1 to forward.
> If anything, the only way to trigger this is my dropping the chown()
> calls.

Which tests would those be? The only ones I can spot are ones that
want to test "can we still load the driver after doing $badthing".

Notice that drm_open_driver() stops testing if the open fails so it
cannot pass -1 along.


-- 
Petri Latvala
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [igt-dev] [PATCH i-g-t v2] ts/core_setmaster: new test for drop/set master semantics
  2020-02-24  8:49     ` Petri Latvala
@ 2020-02-24 11:57       ` Emil Velikov
  2020-02-25  9:10         ` Petri Latvala
  0 siblings, 1 reply; 12+ messages in thread
From: Emil Velikov @ 2020-02-24 11:57 UTC (permalink / raw)
  To: Petri Latvala; +Cc: IGT development

On Mon, 24 Feb 2020 at 08:50, Petri Latvala <petri.latvala@intel.com> wrote:
>
> On Fri, Feb 21, 2020 at 01:55:18PM +0000, Emil Velikov wrote:
> > Hi Petri,
> >
> > Thank you for having a look.
> >
> > On Fri, 21 Feb 2020 at 11:58, Petri Latvala <petri.latvala@intel.com> wrote:
> >
> > > > +static void check_drop_set(void)
> > > > +{
> > > > +     int master;
> > > > +
> > > > +     master = __drm_open_driver(DRIVER_ANY);
> > > > +
> > > > +     /* Double-check if open has failed */
> > > > +     igt_assert_neq(master, -1);
> > >
> > > Just use drm_open_driver(). For sure you don't want to produce a
> > > 'FAIL' when running on a system without GPU drivers. 'SKIP' is correct
> > > for that case.
> > >
> > This sounds very strange. Why would anyone run IGT if they lack _any_
> > GPU drivers.
>
> Accidentally, by breaking the driver module loading.
>
> > If I'm running GPU tests and my GPU doesn't show up for any reason,
> > I'd expect a hard failure.
>
> Sure, some kind of a notification for that case is desired. However
> the correct notification for that is a SKIP result. Granted, for
> DRIVER_ANY open call the story is a bit more far-fetched, but consider
> this:
>
> If you get a FAIL from this test, you want to be able to say "I got
> that because handling master in kernel is broken". If you can't open a
> driver, you can't tell that kernel is broken. The only thing you can
> tell is: You can't test the feature. SKIP is exactly that: Can't test
> this.
>
"If you can't open a driver, you can't tell that kernel is broken."
Pretty sure that failing to load a DRM driver classifies as broken ;-)

Although I see the goal here: Ensuring _only_ a particular corner-case
is reported [as broken] by the individual test.
IMHO this is valid yet, it only ensures the test summary isn't plagued
with FAIL but with SKIP instead.

Personally le coupe de grace against igt_require/igt_skip is that
ig_drop_root + igt_skip seems to be _busted_.
So in the case of this failing, we'll end up with a garbled state +
misleading trace.

While I appreciate the overall sentiment, with igt_assert() we are
left in more obvious and manageable stage.

>
> > Even if we ignore that, a quick look around shows that there are
> > multiple tests that will happily pass -1 to forward.
> > If anything, the only way to trigger this is my dropping the chown()
> > calls.
>
> Which tests would those be? The only ones I can spot are ones that
> want to test "can we still load the driver after doing $badthing".
>
Git grep shows ~20 hits, from which I cannot see anyone that does a "bad thing".

Looking at gem_sanitycheck() - it will result in mislabelled error.
While gem_exec_store() will report failure (due to
igt_fork_hang_detector) is the open fail. Others like
drm_open_driver_render() will barf misleading message about sysfs,
when attempting gem_quiescent_gpu().

As a Tl;Dr: the igt_require() isn't enforced everywhere - rightfully so IMHO.


Does this make sense or you'd prefer the igt_require() regardless?

Thanks
Emil
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [igt-dev] [PATCH i-g-t v2] ts/core_setmaster: new test for drop/set master semantics
  2020-02-24 11:57       ` Emil Velikov
@ 2020-02-25  9:10         ` Petri Latvala
  0 siblings, 0 replies; 12+ messages in thread
From: Petri Latvala @ 2020-02-25  9:10 UTC (permalink / raw)
  To: Emil Velikov; +Cc: IGT development

On Mon, Feb 24, 2020 at 11:57:01AM +0000, Emil Velikov wrote:
> On Mon, 24 Feb 2020 at 08:50, Petri Latvala <petri.latvala@intel.com> wrote:
> >
> > On Fri, Feb 21, 2020 at 01:55:18PM +0000, Emil Velikov wrote:
> > > Hi Petri,
> > >
> > > Thank you for having a look.
> > >
> > > On Fri, 21 Feb 2020 at 11:58, Petri Latvala <petri.latvala@intel.com> wrote:
> > >
> > > > > +static void check_drop_set(void)
> > > > > +{
> > > > > +     int master;
> > > > > +
> > > > > +     master = __drm_open_driver(DRIVER_ANY);
> > > > > +
> > > > > +     /* Double-check if open has failed */
> > > > > +     igt_assert_neq(master, -1);
> > > >
> > > > Just use drm_open_driver(). For sure you don't want to produce a
> > > > 'FAIL' when running on a system without GPU drivers. 'SKIP' is correct
> > > > for that case.
> > > >
> > > This sounds very strange. Why would anyone run IGT if they lack _any_
> > > GPU drivers.
> >
> > Accidentally, by breaking the driver module loading.
> >
> > > If I'm running GPU tests and my GPU doesn't show up for any reason,
> > > I'd expect a hard failure.
> >
> > Sure, some kind of a notification for that case is desired. However
> > the correct notification for that is a SKIP result. Granted, for
> > DRIVER_ANY open call the story is a bit more far-fetched, but consider
> > this:
> >
> > If you get a FAIL from this test, you want to be able to say "I got
> > that because handling master in kernel is broken". If you can't open a
> > driver, you can't tell that kernel is broken. The only thing you can
> > tell is: You can't test the feature. SKIP is exactly that: Can't test
> > this.
> >
> "If you can't open a driver, you can't tell that kernel is broken."
> Pretty sure that failing to load a DRM driver classifies as broken ;-)

Fair point, so let me rephrase that to "-- in the way tested". :P


> 
> Although I see the goal here: Ensuring _only_ a particular corner-case
> is reported [as broken] by the individual test.
> IMHO this is valid yet, it only ensures the test summary isn't plagued
> with FAIL but with SKIP instead.
> 
> Personally le coupe de grace against igt_require/igt_skip is that
> ig_drop_root + igt_skip seems to be _busted_.
> So in the case of this failing, we'll end up with a garbled state +
> misleading trace.
> 
> While I appreciate the overall sentiment, with igt_assert() we are
> left in more obvious and manageable stage.

Reading the code again, a good argument can be made that your
__drm_open_driver() is testing if you can still open the driver as
non-root. If that's the goal, igt_assert is proper. If on the other
hand __drm_open_driver() is "just setup to test the real goal", then
igt_require.

If the code is written with the chmod() calls being in igt_fixture
blocks around the subtest, I don't see how it can be busted either
way. The state is the same both ways, we stop testing. The only
difference is the subtest result.

> 
> >
> > > Even if we ignore that, a quick look around shows that there are
> > > multiple tests that will happily pass -1 to forward.
> > > If anything, the only way to trigger this is my dropping the chown()
> > > calls.
> >
> > Which tests would those be? The only ones I can spot are ones that
> > want to test "can we still load the driver after doing $badthing".
> >
> Git grep shows ~20 hits, from which I cannot see anyone that does a "bad thing".
> 
> Looking at gem_sanitycheck() - it will result in mislabelled error.
> While gem_exec_store() will report failure (due to
> igt_fork_hang_detector) is the open fail.

gem_sanitycheck() sure could use some extra help for human
readers. Currently it makes the tradeoff of checking for open failure
and misbehaving reloaded driver with the same code, forcing human log
reading to know that EBADF means open() failed.

gem_exec_store() is only called if gem_sanitycheck() succeeds. Sure, a
repeated __drm_open_driver() could fail there, but hey. At least
something complains then.

> Others like
> drm_open_driver_render() will barf misleading message about sysfs,
> when attempting gem_quiescent_gpu().

That cannot call gem_quiescent_gpu() if open failed.


-- 
Petri Latvala
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2020-02-25  9:10 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-19 14:24 [igt-dev] [PATCH i-g-t v2] ts/core_setmaster: new test for drop/set master semantics Emil Velikov
2020-02-19 15:41 ` [igt-dev] ✗ GitLab.Pipeline: failure for ts/core_setmaster: new test for drop/set master semantics (rev2) Patchwork
2020-02-19 15:59 ` [igt-dev] ✓ Fi.CI.BAT: success " Patchwork
2020-02-19 16:20 ` [igt-dev] [PATCH i-g-t v2] ts/core_setmaster: new test for drop/set master semantics Emil Velikov
2020-02-21  9:30 ` [igt-dev] ✓ Fi.CI.IGT: success for ts/core_setmaster: new test for drop/set master semantics (rev2) Patchwork
2020-02-21 11:36   ` Emil Velikov
2020-02-21 11:58 ` [igt-dev] [PATCH i-g-t v2] ts/core_setmaster: new test for drop/set master semantics Petri Latvala
2020-02-21 12:19   ` Petri Latvala
2020-02-21 13:55   ` Emil Velikov
2020-02-24  8:49     ` Petri Latvala
2020-02-24 11:57       ` Emil Velikov
2020-02-25  9:10         ` Petri Latvala

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.