summaryrefslogtreecommitdiffstats
path: root/kdbus-drop-kdbus_meta_attach_mask-modparam.patch
blob: 4768690370b00a3b5f0c89bd3bcd08e78ccac4c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
From: David Herrmann <dh.herrmann@gmail.com>
Date: Fri, 22 May 2015 10:25:08 +0200
Subject: [PATCH] kdbus: drop kdbus_meta_attach_mask modparam

This parameter was introduced to mask out experimental metadata items. As
the discussion on metadata items has shifted, plans changed: Enable all
metadata items and drop the controversial items entirely. Lets not work
around differences of opinions, but figure them out.

Also drop all the related kselftests infrastructure to make sure the tests
still run fine.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Acked-by: Daniel Mack <daniel@zonque.org>
---
 ipc/kdbus/main.c                                  |  12 -
 ipc/kdbus/metadata.c                              |   1 -
 ipc/kdbus/metadata.h                              |   2 -
 tools/testing/selftests/kdbus/Makefile            |   1 -
 tools/testing/selftests/kdbus/kdbus-test.c        |  25 +-
 tools/testing/selftests/kdbus/kdbus-test.h        |   2 -
 tools/testing/selftests/kdbus/test-attach-flags.c | 750 ----------------------
 tools/testing/selftests/kdbus/test-connection.c   |  34 +-
 8 files changed, 13 insertions(+), 814 deletions(-)
 delete mode 100644 tools/testing/selftests/kdbus/test-attach-flags.c

diff --git a/ipc/kdbus/main.c b/ipc/kdbus/main.c
index f8eac78cace6..1ad4dc8dafa1 100644
--- a/ipc/kdbus/main.c
+++ b/ipc/kdbus/main.c
@@ -15,7 +15,6 @@
 #include <linux/fs.h>
 #include <linux/init.h>
 #include <linux/module.h>
-#include <linux/moduleparam.h>
 
 #include "util.h"
 #include "fs.h"
@@ -79,17 +78,6 @@
 /* kdbus mount-point /sys/fs/kdbus */
 static struct kobject *kdbus_dir;
 
-/* global module option to apply a mask to exported metadata */
-unsigned long long kdbus_meta_attach_mask = KDBUS_ATTACH_TIMESTAMP |
-					    KDBUS_ATTACH_CREDS |
-					    KDBUS_ATTACH_PIDS |
-					    KDBUS_ATTACH_AUXGROUPS |
-					    KDBUS_ATTACH_NAMES |
-					    KDBUS_ATTACH_SECLABEL |
-					    KDBUS_ATTACH_CONN_DESCRIPTION;
-MODULE_PARM_DESC(attach_flags_mask, "Attach-flags mask for exported metadata");
-module_param_named(attach_flags_mask, kdbus_meta_attach_mask, ullong, 0644);
-
 static int __init kdbus_init(void)
 {
 	int ret;
diff --git a/ipc/kdbus/metadata.c b/ipc/kdbus/metadata.c
index 174436f0aa01..b908b6314a00 100644
--- a/ipc/kdbus/metadata.c
+++ b/ipc/kdbus/metadata.c
@@ -835,7 +835,6 @@ int kdbus_meta_export_prepare(struct kdbus_meta_proc *mp,
 	}
 
 	*mask &= valid;
-	*mask &= kdbus_meta_attach_mask;
 
 	if (!*mask)
 		goto exit;
diff --git a/ipc/kdbus/metadata.h b/ipc/kdbus/metadata.h
index 42c942b34d2c..79b6ac31c8ad 100644
--- a/ipc/kdbus/metadata.h
+++ b/ipc/kdbus/metadata.h
@@ -24,8 +24,6 @@ struct kdbus_pool_slice;
 struct kdbus_meta_proc;
 struct kdbus_meta_conn;
 
-extern unsigned long long kdbus_meta_attach_mask;
-
 struct kdbus_meta_proc *kdbus_meta_proc_new(void);
 struct kdbus_meta_proc *kdbus_meta_proc_ref(struct kdbus_meta_proc *mp);
 struct kdbus_meta_proc *kdbus_meta_proc_unref(struct kdbus_meta_proc *mp);
diff --git a/tools/testing/selftests/kdbus/Makefile b/tools/testing/selftests/kdbus/Makefile
index de8242f9b00e..076f9f40566d 100644
--- a/tools/testing/selftests/kdbus/Makefile
+++ b/tools/testing/selftests/kdbus/Makefile
@@ -11,7 +11,6 @@ OBJS= \
 	kdbus-test.o		\
 	kdbus-test.o		\
 	test-activator.o	\
-	test-attach-flags.o	\
 	test-benchmark.o	\
 	test-bus.o		\
 	test-chat.o		\
diff --git a/tools/testing/selftests/kdbus/kdbus-test.c b/tools/testing/selftests/kdbus/kdbus-test.c
index a43674ccdeb0..294e82a83ab6 100644
--- a/tools/testing/selftests/kdbus/kdbus-test.c
+++ b/tools/testing/selftests/kdbus/kdbus-test.c
@@ -48,7 +48,6 @@ struct kdbus_test_args {
 	char *root;
 	char *test;
 	char *busname;
-	char *mask_param_path;
 };
 
 static const struct kdbus_test tests[] = {
@@ -274,13 +273,6 @@ static const struct kdbus_test tests[] = {
 		.func	= kdbus_test_benchmark_uds,
 		.flags	= TEST_CREATE_BUS,
 	},
-	{
-		/* Last test */
-		.name	= "attach-flags",
-		.desc	= "attach flags mask",
-		.func	= kdbus_test_attach_flags,
-		.flags	= 0,
-	},
 };
 
 #define N_TESTS ((int) (sizeof(tests) / sizeof(tests[0])))
@@ -323,7 +315,6 @@ static int test_prepare_env(const struct kdbus_test *t,
 
 	env->root = args->root;
 	env->module = args->module;
-	env->mask_param_path = args->mask_param_path;
 
 	return 0;
 }
@@ -754,8 +745,7 @@ int start_tests(struct kdbus_test_args *kdbus_args)
 {
 	int ret;
 	bool namespaces;
-	uint64_t kdbus_param_mask;
-	static char fspath[4096], parampath[4096];
+	static char fspath[4096];
 
 	namespaces = (kdbus_args->mntns || kdbus_args->pidns ||
 		      kdbus_args->userns);
@@ -791,19 +781,6 @@ int start_tests(struct kdbus_test_args *kdbus_args)
 		kdbus_args->root = fspath;
 	}
 
-	snprintf(parampath, sizeof(parampath),
-		 "/sys/module/%s/parameters/attach_flags_mask",
-		 kdbus_args->module);
-	kdbus_args->mask_param_path = parampath;
-
-	ret = kdbus_sysfs_get_parameter_mask(kdbus_args->mask_param_path,
-					     &kdbus_param_mask);
-	if (ret < 0)
-		return TEST_ERR;
-
-	printf("# Starting tests with an attach_flags_mask=0x%llx\n",
-		(unsigned long long)kdbus_param_mask);
-
 	/* Start tests */
 	if (namespaces)
 		ret = run_tests_in_namespaces(kdbus_args);
diff --git a/tools/testing/selftests/kdbus/kdbus-test.h b/tools/testing/selftests/kdbus/kdbus-test.h
index 647331883763..a5c6ae81b81b 100644
--- a/tools/testing/selftests/kdbus/kdbus-test.h
+++ b/tools/testing/selftests/kdbus/kdbus-test.h
@@ -5,7 +5,6 @@ struct kdbus_test_env {
 	char *buspath;
 	const char *root;
 	const char *module;
-	const char *mask_param_path;
 	int control_fd;
 	struct kdbus_conn *conn;
 };
@@ -44,7 +43,6 @@ enum {
 	ASSERT_EXIT_VAL(cond, EXIT_FAILURE)
 
 int kdbus_test_activator(struct kdbus_test_env *env);
-int kdbus_test_attach_flags(struct kdbus_test_env *env);
 int kdbus_test_benchmark(struct kdbus_test_env *env);
 int kdbus_test_benchmark_nomemfds(struct kdbus_test_env *env);
 int kdbus_test_benchmark_uds(struct kdbus_test_env *env);
diff --git a/tools/testing/selftests/kdbus/test-attach-flags.c b/tools/testing/selftests/kdbus/test-attach-flags.c
deleted file mode 100644
index deee7c332f25..000000000000
--- a/tools/testing/selftests/kdbus/test-attach-flags.c
+++ /dev/null
@@ -1,750 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdbool.h>
-#include <stddef.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <stdint.h>
-#include <errno.h>
-#include <assert.h>
-#include <sys/capability.h>
-#include <sys/mman.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <linux/unistd.h>
-
-#include "kdbus-api.h"
-#include "kdbus-test.h"
-#include "kdbus-util.h"
-#include "kdbus-enum.h"
-
-/*
- * Should be the sum of the currently supported and compiled-in
- * KDBUS_ITEMS_* that reflect KDBUS_ATTACH_* flags.
- */
-static unsigned int KDBUS_TEST_ITEMS_SUM = KDBUS_ATTACH_ITEMS_TYPE_SUM;
-
-static struct kdbus_conn *__kdbus_hello(const char *path, uint64_t flags,
-					uint64_t attach_flags_send,
-					uint64_t attach_flags_recv)
-{
-	struct kdbus_cmd_free cmd_free = {};
-	int ret, fd;
-	struct kdbus_conn *conn;
-	struct {
-		struct kdbus_cmd_hello hello;
-
-		struct {
-			uint64_t size;
-			uint64_t type;
-			char str[16];
-		} conn_name;
-
-		uint8_t extra_items[0];
-	} h;
-
-	memset(&h, 0, sizeof(h));
-
-	kdbus_printf("-- opening bus connection %s\n", path);
-	fd = open(path, O_RDWR|O_CLOEXEC);
-	if (fd < 0) {
-		kdbus_printf("--- error %d (%m)\n", fd);
-		return NULL;
-	}
-
-	h.hello.flags = flags | KDBUS_HELLO_ACCEPT_FD;
-	h.hello.attach_flags_send = attach_flags_send;
-	h.hello.attach_flags_recv = attach_flags_recv;
-	h.conn_name.type = KDBUS_ITEM_CONN_DESCRIPTION;
-	strcpy(h.conn_name.str, "this-is-my-name");
-	h.conn_name.size = KDBUS_ITEM_HEADER_SIZE + strlen(h.conn_name.str) + 1;
-
-	h.hello.size = sizeof(h);
-	h.hello.pool_size = POOL_SIZE;
-
-	ret = kdbus_cmd_hello(fd, (struct kdbus_cmd_hello *) &h.hello);
-	if (ret < 0) {
-		kdbus_printf("--- error when saying hello: %d (%m)\n", ret);
-		return NULL;
-	}
-
-	kdbus_printf("-- New connection ID : %llu\n",
-		     (unsigned long long)h.hello.id);
-
-	cmd_free.size = sizeof(cmd_free);
-	cmd_free.offset = h.hello.offset;
-	ret = kdbus_cmd_free(fd, &cmd_free);
-	if (ret < 0)
-		return NULL;
-
-	conn = malloc(sizeof(*conn));
-	if (!conn) {
-		kdbus_printf("unable to malloc()!?\n");
-		return NULL;
-	}
-
-	conn->buf = mmap(NULL, POOL_SIZE, PROT_READ, MAP_SHARED, fd, 0);
-	if (conn->buf == MAP_FAILED) {
-		ret = -errno;
-		free(conn);
-		close(fd);
-		kdbus_printf("--- error mmap: %d (%m)\n", ret);
-		return NULL;
-	}
-
-	conn->fd = fd;
-	conn->id = h.hello.id;
-	return conn;
-}
-
-static int kdbus_test_peers_creation(struct kdbus_test_env *env)
-{
-	int ret;
-	int control_fd;
-	char *path;
-	char *busname;
-	char buspath[2048];
-	char control_path[2048];
-	uint64_t attach_flags_mask;
-	struct kdbus_conn *conn;
-
-	snprintf(control_path, sizeof(control_path),
-		 "%s/control", env->root);
-
-	/*
-	 * Set kdbus system-wide mask to 0, this has nothing
-	 * to do with the following tests, bus and connection
-	 * creation nor connection update, but we do it so we are
-	 * sure that everything work as expected
-	 */
-
-	attach_flags_mask = 0;
-	ret = kdbus_sysfs_set_parameter_mask(env->mask_param_path,
-					     attach_flags_mask);
-	ASSERT_RETURN(ret == 0);
-
-
-	/*
-	 * Create bus with a full set of ATTACH flags
-	 */
-
-	control_fd = open(control_path, O_RDWR);
-	ASSERT_RETURN(control_fd >= 0);
-
-	busname = unique_name("test-peers-creation-bus");
-	ASSERT_RETURN(busname);
-
-	ret = kdbus_create_bus(control_fd, busname, _KDBUS_ATTACH_ALL,
-			       0, &path);
-	ASSERT_RETURN(ret == 0);
-
-	snprintf(buspath, sizeof(buspath), "%s/%s/bus", env->root, path);
-
-	/*
-	 * Create a connection with an empty send attach flags, or
-	 * with just KDBUS_ATTACH_CREDS, this should fail
-	 */
-	conn = __kdbus_hello(buspath, 0, 0, 0);
-	ASSERT_RETURN(conn == NULL);
-	ASSERT_RETURN(errno == ECONNREFUSED);
-
-	conn = __kdbus_hello(buspath, 0, KDBUS_ATTACH_CREDS,
-			     _KDBUS_ATTACH_ALL);
-	ASSERT_RETURN(conn == NULL);
-	ASSERT_RETURN(errno == ECONNREFUSED);
-
-	conn = __kdbus_hello(buspath, 0, _KDBUS_ATTACH_ALL, 0);
-	ASSERT_RETURN(conn);
-
-	/* Try to cut back some send attach flags */
-	ret = kdbus_conn_update_attach_flags(conn,
-					     KDBUS_ATTACH_CREDS|
-					     KDBUS_ATTACH_PIDS,
-					     _KDBUS_ATTACH_ALL);
-	ASSERT_RETURN(ret == -EINVAL);
-
-	ret = kdbus_conn_update_attach_flags(conn,
-					     _KDBUS_ATTACH_ALL, 0);
-	ASSERT_RETURN(ret == 0);
-
-	kdbus_conn_free(conn);
-	free(path);
-	free(busname);
-	close(control_fd);
-
-
-	/* Test a new bus with KDBUS_ATTACH_PIDS */
-
-	control_fd = open(control_path, O_RDWR);
-	ASSERT_RETURN(control_fd >= 0);
-
-	busname = unique_name("test-peer-flags-bus");
-	ASSERT_RETURN(busname);
-
-	ret = kdbus_create_bus(control_fd, busname, KDBUS_ATTACH_PIDS,
-			       0, &path);
-	ASSERT_RETURN(ret == 0);
-
-	snprintf(buspath, sizeof(buspath), "%s/%s/bus", env->root, path);
-
-	/*
-	 * Create a connection with an empty send attach flags, or
-	 * all flags except KDBUS_ATTACH_PIDS
-	 */
-	conn = __kdbus_hello(buspath, 0, 0, 0);
-	ASSERT_RETURN(conn == NULL);
-	ASSERT_RETURN(errno == ECONNREFUSED);
-
-	conn = __kdbus_hello(buspath, 0,
-			     _KDBUS_ATTACH_ALL & ~KDBUS_ATTACH_PIDS,
-			     _KDBUS_ATTACH_ALL);
-	ASSERT_RETURN(conn == NULL);
-	ASSERT_RETURN(errno == ECONNREFUSED);
-
-	/* The following should succeed */
-	conn = __kdbus_hello(buspath, 0, KDBUS_ATTACH_PIDS, 0);
-	ASSERT_RETURN(conn);
-	kdbus_conn_free(conn);
-
-	conn = __kdbus_hello(buspath, 0, _KDBUS_ATTACH_ALL, 0);
-	ASSERT_RETURN(conn);
-
-	ret = kdbus_conn_update_attach_flags(conn,
-					     _KDBUS_ATTACH_ALL &
-					     ~KDBUS_ATTACH_PIDS,
-					     _KDBUS_ATTACH_ALL);
-	ASSERT_RETURN(ret == -EINVAL);
-
-	ret = kdbus_conn_update_attach_flags(conn, 0,
-					     _KDBUS_ATTACH_ALL);
-	ASSERT_RETURN(ret == -EINVAL);
-
-	/* Now we want only KDBUS_ATTACH_PIDS */
-	ret = kdbus_conn_update_attach_flags(conn,
-					     KDBUS_ATTACH_PIDS, 0);
-	ASSERT_RETURN(ret == 0);
-
-	kdbus_conn_free(conn);
-	free(path);
-	free(busname);
-	close(control_fd);
-
-
-	/*
-	 * Create bus with 0 as ATTACH flags, the bus does not
-	 * require any attach flags
-	 */
-
-	control_fd = open(control_path, O_RDWR);
-	ASSERT_RETURN(control_fd >= 0);
-
-	busname = unique_name("test-peer-flags-bus");
-	ASSERT_RETURN(busname);
-
-	ret = kdbus_create_bus(control_fd, busname, 0, 0, &path);
-	ASSERT_RETURN(ret == 0);
-
-	snprintf(buspath, sizeof(buspath), "%s/%s/bus", env->root, path);
-
-	/* Bus is open it does not require any send attach flags */
-	conn = __kdbus_hello(buspath, 0, 0, 0);
-	ASSERT_RETURN(conn);
-	kdbus_conn_free(conn);
-
-	conn = __kdbus_hello(buspath, 0, _KDBUS_ATTACH_ALL, 0);
-	ASSERT_RETURN(conn);
-
-	ret = kdbus_conn_update_attach_flags(conn, 0, 0);
-	ASSERT_RETURN(ret == 0);
-
-	ret = kdbus_conn_update_attach_flags(conn, KDBUS_ATTACH_CREDS, 0);
-	ASSERT_RETURN(ret == 0);
-
-	kdbus_conn_free(conn);
-	free(path);
-	free(busname);
-	close(control_fd);
-
-	return 0;
-}
-
-static int kdbus_test_peers_info(struct kdbus_test_env *env)
-{
-	int ret;
-	int control_fd;
-	char *path;
-	char *busname;
-	unsigned int i = 0;
-	uint64_t offset = 0;
-	char buspath[2048];
-	char control_path[2048];
-	uint64_t attach_flags_mask;
-	struct kdbus_item *item;
-	struct kdbus_info *info;
-	struct kdbus_conn *conn;
-	struct kdbus_conn *reader;
-	unsigned long long attach_count = 0;
-
-	snprintf(control_path, sizeof(control_path),
-		 "%s/control", env->root);
-
-	attach_flags_mask = 0;
-	ret = kdbus_sysfs_set_parameter_mask(env->mask_param_path,
-					     attach_flags_mask);
-	ASSERT_RETURN(ret == 0);
-
-	control_fd = open(control_path, O_RDWR);
-	ASSERT_RETURN(control_fd >= 0);
-
-	busname = unique_name("test-peers-info-bus");
-	ASSERT_RETURN(busname);
-
-	ret = kdbus_create_bus(control_fd, busname, _KDBUS_ATTACH_ALL,
-			       0, &path);
-	ASSERT_RETURN(ret == 0);
-
-	snprintf(buspath, sizeof(buspath), "%s/%s/bus", env->root, path);
-
-	/* Create connections with the appropriate flags */
-	conn = __kdbus_hello(buspath, 0, _KDBUS_ATTACH_ALL, 0);
-	ASSERT_RETURN(conn);
-
-	reader = __kdbus_hello(buspath, 0, _KDBUS_ATTACH_ALL, 0);
-	ASSERT_RETURN(reader);
-
-	ret = kdbus_conn_info(reader, conn->id, NULL,
-			      _KDBUS_ATTACH_ALL, &offset);
-	ASSERT_RETURN(ret == 0);
-
-	info = (struct kdbus_info *)(reader->buf + offset);
-	ASSERT_RETURN(info->id == conn->id);
-
-	/* all attach flags are masked, no metadata */
-	KDBUS_ITEM_FOREACH(item, info, items)
-		i++;
-
-	ASSERT_RETURN(i == 0);
-
-	kdbus_free(reader, offset);
-
-	/* Set the mask to _KDBUS_ATTACH_ANY */
-	attach_flags_mask = _KDBUS_ATTACH_ANY;
-	ret = kdbus_sysfs_set_parameter_mask(env->mask_param_path,
-					     attach_flags_mask);
-	ASSERT_RETURN(ret == 0);
-
-	ret = kdbus_conn_info(reader, conn->id, NULL,
-			      _KDBUS_ATTACH_ALL, &offset);
-	ASSERT_RETURN(ret == 0);
-
-	info = (struct kdbus_info *)(reader->buf + offset);
-	ASSERT_RETURN(info->id == conn->id);
-
-	attach_count = 0;
-	KDBUS_ITEM_FOREACH(item, info, items)
-		    attach_count += item->type;
-
-	/*
-	 * All flags have been returned except for:
-	 * KDBUS_ITEM_TIMESTAMP and
-	 * KDBUS_ITEM_OWNED_NAME we do not own any name.
-	 */
-	ASSERT_RETURN(attach_count == (KDBUS_TEST_ITEMS_SUM -
-				       KDBUS_ITEM_OWNED_NAME -
-				       KDBUS_ITEM_TIMESTAMP));
-
-	kdbus_free(reader, offset);
-
-	/* Request only OWNED names */
-	ret = kdbus_conn_info(reader, conn->id, NULL,
-			      KDBUS_ATTACH_NAMES, &offset);
-	ASSERT_RETURN(ret == 0);
-
-	info = (struct kdbus_info *)(reader->buf + offset);
-	ASSERT_RETURN(info->id == conn->id);
-
-	attach_count = 0;
-	KDBUS_ITEM_FOREACH(item, info, items)
-		attach_count += item->type;
-
-	/* we should not get any metadata since we do not own names */
-	ASSERT_RETURN(attach_count == 0);
-
-	kdbus_free(reader, offset);
-
-	kdbus_conn_free(conn);
-	kdbus_conn_free(reader);
-
-	return 0;
-}
-
-/**
- * @kdbus_mask_param:	kdbus module mask parameter (system-wide)
- * @requested_meta:	The bus owner metadata that we want
- * @expected_items:	The returned KDBUS_ITEMS_* sum. Used to
- *			validate the returned metadata items
- */
-static int kdbus_cmp_bus_creator_metadata(struct kdbus_test_env *env,
-					  struct kdbus_conn *conn,
-					  uint64_t kdbus_mask_param,
-					  uint64_t requested_meta,
-					  unsigned long expected_items)
-{
-	int ret;
-	uint64_t offset = 0;
-	struct kdbus_info *info;
-	struct kdbus_item *item;
-	unsigned long attach_count = 0;
-
-	ret = kdbus_sysfs_set_parameter_mask(env->mask_param_path,
-					     kdbus_mask_param);
-	ASSERT_RETURN(ret == 0);
-
-	ret = kdbus_bus_creator_info(conn, requested_meta, &offset);
-	ASSERT_RETURN(ret == 0);
-
-	info = (struct kdbus_info *)(conn->buf + offset);
-
-	KDBUS_ITEM_FOREACH(item, info, items)
-		attach_count += item->type;
-
-	ASSERT_RETURN(attach_count == expected_items);
-
-	ret = kdbus_free(conn, offset);
-	ASSERT_RETURN(ret == 0);
-
-	return 0;
-}
-
-static int kdbus_test_bus_creator_info(struct kdbus_test_env *env)
-{
-	int ret;
-	int control_fd;
-	char *path;
-	char *busname;
-	char buspath[2048];
-	char control_path[2048];
-	uint64_t attach_flags_mask;
-	struct kdbus_conn *conn;
-	unsigned long expected_items = 0;
-
-	snprintf(control_path, sizeof(control_path),
-		 "%s/control", env->root);
-
-	control_fd = open(control_path, O_RDWR);
-	ASSERT_RETURN(control_fd >= 0);
-
-	busname = unique_name("test-peers-info-bus");
-	ASSERT_RETURN(busname);
-
-	/*
-	 * Now the bus allows us to see all its KDBUS_ATTACH_*
-	 * items
-	 */
-	ret = kdbus_create_bus(control_fd, busname, 0,
-			       _KDBUS_ATTACH_ALL, &path);
-	ASSERT_RETURN(ret == 0);
-
-	snprintf(buspath, sizeof(buspath), "%s/%s/bus", env->root, path);
-
-	conn = __kdbus_hello(buspath, 0, 0, 0);
-	ASSERT_RETURN(conn);
-
-	/*
-	 * Start with a kdbus module mask set to _KDBUS_ATTACH_ANY
-	 */
-	attach_flags_mask = _KDBUS_ATTACH_ANY;
-
-	/*
-	 * All flags will be returned except for:
-	 * KDBUS_ITEM_TIMESTAMP
-	 * KDBUS_ITEM_OWNED_NAME
-	 * KDBUS_ITEM_CONN_DESCRIPTION
-	 *
-	 * An extra flags is always returned KDBUS_ITEM_MAKE_NAME
-	 * which contains the bus name
-	 */
-	expected_items = KDBUS_TEST_ITEMS_SUM + KDBUS_ITEM_MAKE_NAME;
-	expected_items -= KDBUS_ITEM_TIMESTAMP +
-			  KDBUS_ITEM_OWNED_NAME +
-			  KDBUS_ITEM_CONN_DESCRIPTION;
-	ret = kdbus_cmp_bus_creator_metadata(env, conn,
-					     attach_flags_mask,
-					     _KDBUS_ATTACH_ALL,
-					     expected_items);
-	ASSERT_RETURN(ret == 0);
-
-	/*
-	 * We should have:
-	 * KDBUS_ITEM_PIDS + KDBUS_ITEM_CREDS + KDBUS_ITEM_MAKE_NAME
-	 */
-	expected_items = KDBUS_ITEM_PIDS + KDBUS_ITEM_CREDS +
-			 KDBUS_ITEM_MAKE_NAME;
-	ret = kdbus_cmp_bus_creator_metadata(env, conn,
-					     attach_flags_mask,
-					     KDBUS_ATTACH_PIDS |
-					     KDBUS_ATTACH_CREDS,
-					     expected_items);
-	ASSERT_RETURN(ret == 0);
-
-	/* KDBUS_ITEM_MAKE_NAME is always returned */
-	expected_items = KDBUS_ITEM_MAKE_NAME;
-	ret = kdbus_cmp_bus_creator_metadata(env, conn,
-					     attach_flags_mask,
-					     0, expected_items);
-	ASSERT_RETURN(ret == 0);
-
-	/*
-	 * Restrict kdbus system-wide mask to KDBUS_ATTACH_PIDS
-	 */
-
-	attach_flags_mask = KDBUS_ATTACH_PIDS;
-
-	/*
-	 * We should have:
-	 * KDBUS_ITEM_PIDS + KDBUS_ITEM_MAKE_NAME
-	 */
-	expected_items = KDBUS_ITEM_PIDS + KDBUS_ITEM_MAKE_NAME;
-	ret = kdbus_cmp_bus_creator_metadata(env, conn,
-					     attach_flags_mask,
-					     _KDBUS_ATTACH_ALL,
-					     expected_items);
-	ASSERT_RETURN(ret == 0);
-
-
-	/* system-wide mask to 0 */
-	attach_flags_mask = 0;
-
-	/* we should only see: KDBUS_ITEM_MAKE_NAME */
-	expected_items = KDBUS_ITEM_MAKE_NAME;
-	ret = kdbus_cmp_bus_creator_metadata(env, conn,
-					     attach_flags_mask,
-					     _KDBUS_ATTACH_ALL,
-					     expected_items);
-	ASSERT_RETURN(ret == 0);
-
-	kdbus_conn_free(conn);
-	free(path);
-	free(busname);
-	close(control_fd);
-
-
-	/*
-	 * A new bus that hides all its owner metadata
-	 */
-
-	control_fd = open(control_path, O_RDWR);
-	ASSERT_RETURN(control_fd >= 0);
-
-	busname = unique_name("test-peers-info-bus");
-	ASSERT_RETURN(busname);
-
-	ret = kdbus_create_bus(control_fd, busname, 0, 0, &path);
-	ASSERT_RETURN(ret == 0);
-
-	snprintf(buspath, sizeof(buspath), "%s/%s/bus", env->root, path);
-
-	conn = __kdbus_hello(buspath, 0, 0, 0);
-	ASSERT_RETURN(conn);
-
-	/*
-	 * Start with a kdbus module mask set to _KDBUS_ATTACH_ANY
-	 */
-	attach_flags_mask = _KDBUS_ATTACH_ANY;
-
-	/*
-	 * We only get the KDBUS_ITEM_MAKE_NAME
-	 */
-	expected_items = KDBUS_ITEM_MAKE_NAME;
-	ret = kdbus_cmp_bus_creator_metadata(env, conn,
-					     attach_flags_mask,
-					     _KDBUS_ATTACH_ALL,
-					     expected_items);
-	ASSERT_RETURN(ret == 0);
-
-	/*
-	 * We still get only kdbus_ITEM_MAKE_NAME
-	 */
-	attach_flags_mask = 0;
-	expected_items = KDBUS_ITEM_MAKE_NAME;
-	ret = kdbus_cmp_bus_creator_metadata(env, conn,
-					     attach_flags_mask,
-					     _KDBUS_ATTACH_ALL,
-					     expected_items);
-	ASSERT_RETURN(ret == 0);
-
-	kdbus_conn_free(conn);
-	free(path);
-	free(busname);
-	close(control_fd);
-
-
-	/*
-	 * A new bus that shows only the PID and CREDS metadata
-	 * of the bus owner.
-	 */
-	control_fd = open(control_path, O_RDWR);
-	ASSERT_RETURN(control_fd >= 0);
-
-	busname = unique_name("test-peers-info-bus");
-	ASSERT_RETURN(busname);
-
-	ret = kdbus_create_bus(control_fd, busname, 0,
-			       KDBUS_ATTACH_PIDS|
-			       KDBUS_ATTACH_CREDS, &path);
-	ASSERT_RETURN(ret == 0);
-
-	snprintf(buspath, sizeof(buspath), "%s/%s/bus", env->root, path);
-
-	conn = __kdbus_hello(buspath, 0, 0, 0);
-	ASSERT_RETURN(conn);
-
-	/*
-	 * Start with a kdbus module mask set to _KDBUS_ATTACH_ANY
-	 */
-	attach_flags_mask = _KDBUS_ATTACH_ANY;
-
-	/*
-	 * We should have:
-	 * KDBUS_ITEM_PIDS + KDBUS_ITEM_CREDS + KDBUS_ITEM_MAKE_NAME
-	 */
-	expected_items = KDBUS_ITEM_PIDS + KDBUS_ITEM_CREDS +
-			 KDBUS_ITEM_MAKE_NAME;
-	ret = kdbus_cmp_bus_creator_metadata(env, conn,
-					     attach_flags_mask,
-					     _KDBUS_ATTACH_ALL,
-					     expected_items);
-	ASSERT_RETURN(ret == 0);
-
-	expected_items = KDBUS_ITEM_CREDS + KDBUS_ITEM_MAKE_NAME;
-	ret = kdbus_cmp_bus_creator_metadata(env, conn,
-					     attach_flags_mask,
-					     KDBUS_ATTACH_CREDS,
-					     expected_items);
-	ASSERT_RETURN(ret == 0);
-
-	/* KDBUS_ITEM_MAKE_NAME is always returned */
-	expected_items = KDBUS_ITEM_MAKE_NAME;
-	ret = kdbus_cmp_bus_creator_metadata(env, conn,
-					     attach_flags_mask,
-					     0, expected_items);
-	ASSERT_RETURN(ret == 0);
-
-	/*
-	 * Restrict kdbus system-wide mask to KDBUS_ATTACH_PIDS
-	 */
-
-	attach_flags_mask = KDBUS_ATTACH_PIDS;
-	/*
-	 * We should have:
-	 * KDBUS_ITEM_PIDS + KDBUS_ITEM_MAKE_NAME
-	 */
-	expected_items = KDBUS_ITEM_PIDS + KDBUS_ITEM_MAKE_NAME;
-	ret = kdbus_cmp_bus_creator_metadata(env, conn,
-					     attach_flags_mask,
-					     _KDBUS_ATTACH_ALL,
-					     expected_items);
-	ASSERT_RETURN(ret == 0);
-
-	/* No KDBUS_ATTACH_CREDS */
-	expected_items = KDBUS_ITEM_MAKE_NAME;
-	ret = kdbus_cmp_bus_creator_metadata(env, conn,
-					     attach_flags_mask,
-					     KDBUS_ATTACH_CREDS,
-					     expected_items);
-	ASSERT_RETURN(ret == 0);
-
-	/* system-wide mask to 0 */
-	attach_flags_mask = 0;
-
-	/* we should only see: KDBUS_ITEM_MAKE_NAME */
-	expected_items = KDBUS_ITEM_MAKE_NAME;
-	ret = kdbus_cmp_bus_creator_metadata(env, conn,
-					     attach_flags_mask,
-					     _KDBUS_ATTACH_ALL,
-					     expected_items);
-	ASSERT_RETURN(ret == 0);
-
-
-	kdbus_conn_free(conn);
-	free(path);
-	free(busname);
-	close(control_fd);
-
-	return 0;
-}
-
-int kdbus_test_attach_flags(struct kdbus_test_env *env)
-{
-	int ret;
-	uint64_t flags_mask;
-	uint64_t old_kdbus_flags_mask;
-
-	/* We need CAP_DAC_OVERRIDE to overwrite the kdbus mask */
-	ret = test_is_capable(CAP_DAC_OVERRIDE, -1);
-	ASSERT_RETURN(ret >= 0);
-
-	/* no enough privileges, SKIP test */
-	if (!ret)
-		return TEST_SKIP;
-
-	/*
-	 * We need to be able to write to
-	 * "/sys/module/kdbus/parameters/attach_flags_mask"
-	 * perhaps we are unprvileged/privileged in its userns
-	 */
-	ret = access(env->mask_param_path, W_OK);
-	if (ret < 0) {
-		kdbus_printf("--- access() '%s' failed: %d (%m)\n",
-			     env->mask_param_path, -errno);
-		return TEST_SKIP;
-	}
-
-	ret = kdbus_sysfs_get_parameter_mask(env->mask_param_path,
-					     &old_kdbus_flags_mask);
-	ASSERT_RETURN(ret == 0);
-
-	/* setup the right KDBUS_TEST_ITEMS_SUM */
-	if (!config_auditsyscall_is_enabled())
-		KDBUS_TEST_ITEMS_SUM -= KDBUS_ITEM_AUDIT;
-
-	if (!config_cgroups_is_enabled())
-		KDBUS_TEST_ITEMS_SUM -= KDBUS_ITEM_CGROUP;
-
-	if (!config_security_is_enabled())
-		KDBUS_TEST_ITEMS_SUM -= KDBUS_ITEM_SECLABEL;
-
-	/*
-	 * Test the connection creation attach flags
-	 */
-	ret = kdbus_test_peers_creation(env);
-	/* Restore previous kdbus mask */
-	kdbus_sysfs_set_parameter_mask(env->mask_param_path,
-				       old_kdbus_flags_mask);
-	ASSERT_RETURN(ret == 0);
-
-	/*
-	 * Test the CONN_INFO attach flags
-	 */
-	ret = kdbus_test_peers_info(env);
-	/* Restore previous kdbus mask */
-	kdbus_sysfs_set_parameter_mask(env->mask_param_path,
-				       old_kdbus_flags_mask);
-	ASSERT_RETURN(ret == 0);
-
-	/*
-	 * Test the Bus creator info and its attach flags
-	 */
-	ret = kdbus_test_bus_creator_info(env);
-	/* Restore previous kdbus mask */
-	kdbus_sysfs_set_parameter_mask(env->mask_param_path,
-				       old_kdbus_flags_mask);
-	ASSERT_RETURN(ret == 0);
-
-	ret = kdbus_sysfs_get_parameter_mask(env->mask_param_path,
-					     &flags_mask);
-	ASSERT_RETURN(ret == 0 && old_kdbus_flags_mask == flags_mask);
-
-	return TEST_OK;
-}
diff --git a/tools/testing/selftests/kdbus/test-connection.c b/tools/testing/selftests/kdbus/test-connection.c
index 5c2bf3511daa..e7c486621b04 100644
--- a/tools/testing/selftests/kdbus/test-connection.c
+++ b/tools/testing/selftests/kdbus/test-connection.c
@@ -185,13 +185,10 @@ static int kdbus_fuzz_conn_info(struct kdbus_test_env *env, int capable)
 	int ret;
 	unsigned int cnt = 0;
 	uint64_t offset = 0;
-	uint64_t kdbus_flags_mask;
 	struct kdbus_info *info;
 	struct kdbus_conn *conn;
 	struct kdbus_conn *privileged;
 	const struct kdbus_item *item;
-	uint64_t valid_flags_set;
-	uint64_t invalid_flags_set;
 	uint64_t valid_flags = KDBUS_ATTACH_NAMES |
 			       KDBUS_ATTACH_CREDS |
 			       KDBUS_ATTACH_PIDS |
@@ -227,13 +224,6 @@ static int kdbus_fuzz_conn_info(struct kdbus_test_env *env, int capable)
 		.ppid	= getppid(),
 	};
 
-	ret = kdbus_sysfs_get_parameter_mask(env->mask_param_path,
-					     &kdbus_flags_mask);
-	ASSERT_RETURN(ret == 0);
-
-	valid_flags_set = valid_flags & kdbus_flags_mask;
-	invalid_flags_set = invalid_flags & kdbus_flags_mask;
-
 	ret = kdbus_conn_info(env->conn, env->conn->id, NULL,
 			      valid_flags, &offset);
 	ASSERT_RETURN(ret == 0);
@@ -246,7 +236,7 @@ static int kdbus_fuzz_conn_info(struct kdbus_test_env *env, int capable)
 	ASSERT_RETURN(item == NULL);
 
 	item = kdbus_get_item(info, KDBUS_ITEM_CONN_DESCRIPTION);
-	if (valid_flags_set & KDBUS_ATTACH_CONN_DESCRIPTION) {
+	if (valid_flags & KDBUS_ATTACH_CONN_DESCRIPTION) {
 		ASSERT_RETURN(item);
 	} else {
 		ASSERT_RETURN(item == NULL);
@@ -271,7 +261,7 @@ static int kdbus_fuzz_conn_info(struct kdbus_test_env *env, int capable)
 	ASSERT_RETURN(item == NULL);
 
 	cnt = kdbus_count_item(info, KDBUS_ITEM_CREDS);
-	if (valid_flags_set & KDBUS_ATTACH_CREDS) {
+	if (valid_flags & KDBUS_ATTACH_CREDS) {
 		ASSERT_RETURN(cnt == 1);
 
 		item = kdbus_get_item(info, KDBUS_ITEM_CREDS);
@@ -285,7 +275,7 @@ static int kdbus_fuzz_conn_info(struct kdbus_test_env *env, int capable)
 	}
 
 	item = kdbus_get_item(info, KDBUS_ITEM_PIDS);
-	if (valid_flags_set & KDBUS_ATTACH_PIDS) {
+	if (valid_flags & KDBUS_ATTACH_PIDS) {
 		ASSERT_RETURN(item);
 
 		/* Compare item->pids with cached PIDs */
@@ -312,7 +302,7 @@ static int kdbus_fuzz_conn_info(struct kdbus_test_env *env, int capable)
 	ASSERT_RETURN(info->id == conn->id);
 
 	item = kdbus_get_item(info, KDBUS_ITEM_OWNED_NAME);
-	if (valid_flags_set & KDBUS_ATTACH_NAMES) {
+	if (valid_flags & KDBUS_ATTACH_NAMES) {
 		ASSERT_RETURN(item && !strcmp(item->name.name, "com.example.a"));
 	} else {
 		ASSERT_RETURN(item == NULL);
@@ -340,14 +330,14 @@ static int kdbus_fuzz_conn_info(struct kdbus_test_env *env, int capable)
 		info = (struct kdbus_info *)(conn->buf + offset);
 		ASSERT_EXIT(info->id == conn->id);
 
-		if (valid_flags_set & KDBUS_ATTACH_NAMES) {
+		if (valid_flags & KDBUS_ATTACH_NAMES) {
 			item = kdbus_get_item(info, KDBUS_ITEM_OWNED_NAME);
 			ASSERT_EXIT(item &&
 				    strcmp(item->name.name,
 				           "com.example.a") == 0);
 		}
 
-		if (valid_flags_set & KDBUS_ATTACH_CREDS) {
+		if (valid_flags & KDBUS_ATTACH_CREDS) {
 			item = kdbus_get_item(info, KDBUS_ITEM_CREDS);
 			ASSERT_EXIT(item);
 
@@ -356,7 +346,7 @@ static int kdbus_fuzz_conn_info(struct kdbus_test_env *env, int capable)
 				    sizeof(struct kdbus_creds)) == 0);
 		}
 
-		if (valid_flags_set & KDBUS_ATTACH_PIDS) {
+		if (valid_flags & KDBUS_ATTACH_PIDS) {
 			item = kdbus_get_item(info, KDBUS_ITEM_PIDS);
 			ASSERT_EXIT(item);
 
@@ -385,7 +375,7 @@ static int kdbus_fuzz_conn_info(struct kdbus_test_env *env, int capable)
 		 * it points to the cached creds.
 		 */
 		cnt = kdbus_count_item(info, KDBUS_ITEM_CREDS);
-		if (invalid_flags_set & KDBUS_ATTACH_CREDS) {
+		if (invalid_flags & KDBUS_ATTACH_CREDS) {
 			ASSERT_EXIT(cnt == 1);
 
 			item = kdbus_get_item(info, KDBUS_ITEM_CREDS);
@@ -398,7 +388,7 @@ static int kdbus_fuzz_conn_info(struct kdbus_test_env *env, int capable)
 			ASSERT_EXIT(cnt == 0);
 		}
 
-		if (invalid_flags_set & KDBUS_ATTACH_PIDS) {
+		if (invalid_flags & KDBUS_ATTACH_PIDS) {
 			cnt = kdbus_count_item(info, KDBUS_ITEM_PIDS);
 			ASSERT_EXIT(cnt == 1);
 
@@ -411,14 +401,14 @@ static int kdbus_fuzz_conn_info(struct kdbus_test_env *env, int capable)
 		}
 
 		cnt = kdbus_count_item(info, KDBUS_ITEM_CGROUP);
-		if (invalid_flags_set & KDBUS_ATTACH_CGROUP) {
+		if (invalid_flags & KDBUS_ATTACH_CGROUP) {
 			ASSERT_EXIT(cnt == 1);
 		} else {
 			ASSERT_EXIT(cnt == 0);
 		}
 
 		cnt = kdbus_count_item(info, KDBUS_ITEM_CAPS);
-		if (invalid_flags_set & KDBUS_ATTACH_CAPS) {
+		if (invalid_flags & KDBUS_ATTACH_CAPS) {
 			ASSERT_EXIT(cnt == 1);
 		} else {
 			ASSERT_EXIT(cnt == 0);
@@ -442,7 +432,7 @@ continue_test:
 	ASSERT_RETURN(info->id == conn->id);
 
 	cnt = kdbus_count_item(info, KDBUS_ITEM_OWNED_NAME);
-	if (valid_flags_set & KDBUS_ATTACH_NAMES) {
+	if (valid_flags & KDBUS_ATTACH_NAMES) {
 		ASSERT_RETURN(cnt == 2);
 	} else {
 		ASSERT_RETURN(cnt == 0);