Lines Matching +full:close +full:- +full:range
1 // SPDX-License-Identifier: GPL-2.0
178 return -1; in write_file()
181 close(fd); in write_file()
183 return -1; in write_file()
198 return -1; in create_and_enter_userns()
200 if (write_file("/proc/self/setgroups", "deny", sizeof("deny") - 1) && in create_and_enter_userns()
202 return -1; in create_and_enter_userns()
206 return -1; in create_and_enter_userns()
211 return -1; in create_and_enter_userns()
214 return -1; in create_and_enter_userns()
217 return -1; in create_and_enter_userns()
225 return -1; in prepare_unpriv_mountns()
228 return -1; in prepare_unpriv_mountns()
231 return -1; in prepare_unpriv_mountns()
248 return -EINVAL; in read_mnt_flags()
253 return -EINVAL; in read_mnt_flags()
315 while (getline(&line, &len, f) != -1) { in is_shared_mount()
350 if (sys_mount_setattr(-1, "/mnt/A", AT_RECURSIVE, &attr, sizeof(attr))) in mount_setattr_thread()
351 pthread_exit(int_to_ptr(-1)); in mount_setattr_thread()
356 /* Attempt to de-conflict with the selftests tree. */
365 ret = sys_mount_setattr(-EBADF, "", AT_EMPTY_PATH, NULL, 0); in mount_setattr_supported()
380 int fd = -EBADF; in FIXTURE_SETUP()
428 ASSERT_EQ(close(fd), 0); in FIXTURE_SETUP()
449 ASSERT_NE(sys_mount_setattr(-1, "/mnt/A", AT_RECURSIVE, &invalid_attr, in TEST_F()
454 ASSERT_NE(sys_mount_setattr(-1, "/mnt/A", AT_RECURSIVE, &invalid_attr, in TEST_F()
459 ASSERT_NE(sys_mount_setattr(-1, "/mnt/A", AT_RECURSIVE, &invalid_attr, in TEST_F()
465 ASSERT_NE(sys_mount_setattr(-1, "/mnt/A", AT_RECURSIVE, &invalid_attr, in TEST_F()
468 ASSERT_NE(sys_mount_setattr(-1, "mnt/A", AT_RECURSIVE, &invalid_attr, in TEST_F()
489 ASSERT_NE(sys_mount_setattr(-1, "/mnt/A", AT_RECURSIVE, NULL, in TEST_F()
493 ASSERT_NE(sys_mount_setattr(-1, "/mnt/A", AT_RECURSIVE, (void *)s, in TEST_F()
497 ASSERT_NE(sys_mount_setattr(-1, "/mnt/A", AT_RECURSIVE, &invalid_attr, 0), 0); in TEST_F()
500 ASSERT_NE(sys_mount_setattr(-1, "/mnt/A", AT_RECURSIVE, &invalid_attr, in TEST_F()
504 ASSERT_NE(sys_mount_setattr(-1, "/mnt/A", AT_RECURSIVE, &invalid_attr, in TEST_F()
508 ASSERT_EQ(sys_mount_setattr(-1, "/mnt/A", AT_RECURSIVE, in TEST_F()
512 ASSERT_NE(sys_mount_setattr(-1, "/mnt/A", AT_RECURSIVE, in TEST_F()
517 ASSERT_EQ(sys_mount_setattr(-1, "/mnt/A", AT_RECURSIVE, in TEST_F()
550 ASSERT_EQ(sys_mount_setattr(-1, "/mnt/A", 0, &attr, sizeof(attr)), 0); in TEST_F()
586 ASSERT_EQ(sys_mount_setattr(-1, "/mnt/A", AT_RECURSIVE, &attr, sizeof(attr)), 0); in TEST_F()
609 ASSERT_EQ(sys_mount_setattr(-1, "/mnt/A", AT_RECURSIVE, &attr, sizeof(attr)), 0); in TEST_F()
640 ASSERT_LT(sys_mount_setattr(-1, "/mnt/A", AT_RECURSIVE, &attr, sizeof(attr)), 0); in TEST_F()
662 EXPECT_EQ(close(fd), 0); in TEST_F()
689 ASSERT_LT(sys_mount_setattr(-1, "/mnt/A", AT_RECURSIVE, &attr, sizeof(attr)), 0); in TEST_F()
714 EXPECT_EQ(close(dfd), 0); in TEST_F()
717 EXPECT_EQ(close(fd), 0); in TEST_F()
720 ASSERT_EQ(sys_mount_setattr(-1, "/mnt/A", AT_RECURSIVE, &attr, sizeof(attr)), 0); in TEST_F()
740 ASSERT_EQ(sys_mount_setattr(-1, "/mnt/B", AT_RECURSIVE, &attr, sizeof(attr)), 0); in TEST_F()
767 ASSERT_NE(sys_mount_setattr(-1, "/mnt/A", AT_RECURSIVE, &attr, sizeof(attr)), 0); in TEST_F()
770 ASSERT_NE(sys_mount_setattr(-1, "/mnt/A", AT_RECURSIVE, &attr, sizeof(attr)), 0); in TEST_F()
773 ASSERT_NE(sys_mount_setattr(-1, "/mnt/A", AT_RECURSIVE, &attr, sizeof(attr)), 0); in TEST_F()
777 ASSERT_NE(sys_mount_setattr(-1, "/mnt/A", AT_RECURSIVE, &attr, sizeof(attr)), 0); in TEST_F()
781 ASSERT_NE(sys_mount_setattr(-1, "/mnt/A", AT_RECURSIVE, &attr, sizeof(attr)), 0); in TEST_F()
784 ASSERT_NE(sys_mount_setattr(-1, "/mnt/A", AT_RECURSIVE, &attr, sizeof(attr)), 0); in TEST_F()
791 ASSERT_EQ(sys_mount_setattr(-1, "/mnt/A", AT_RECURSIVE, &attr, sizeof(attr)), 0); in TEST_F()
813 ASSERT_EQ(sys_mount_setattr(-1, "/mnt/A", AT_RECURSIVE, &attr, sizeof(attr)), 0); in TEST_F()
834 ASSERT_EQ(sys_mount_setattr(-1, "/mnt/A", AT_RECURSIVE, &attr, sizeof(attr)), 0); in TEST_F()
854 ASSERT_EQ(sys_mount_setattr(-1, "/mnt/A", AT_RECURSIVE, &attr, sizeof(attr)), 0); in TEST_F()
870 ASSERT_EQ(sys_mount_setattr(-1, "/mnt/A", AT_RECURSIVE, &attr, sizeof(attr)), 0); in TEST_F()
886 ASSERT_EQ(sys_mount_setattr(-1, "/mnt/A", AT_RECURSIVE, &attr, sizeof(attr)), 0); in TEST_F()
972 ret = sys_mount_setattr(-1, "/mnt/A", AT_RECURSIVE, &attr, sizeof(attr)); in TEST_F()
1002 int img_fd = -EBADF; in FIXTURE_SETUP()
1015 ASSERT_EQ(mknodat(-EBADF, "/tmp/B/b", S_IFREG | 0644, 0), 0); in FIXTURE_SETUP()
1022 ASSERT_EQ(mknodat(-EBADF, "/tmp/B/BB/b", S_IFREG | 0644, 0), 0); in FIXTURE_SETUP()
1052 img_fd = openat(-EBADF, "/mnt/C/ext4.img", O_CREAT | O_WRONLY, 0600); in FIXTURE_SETUP()
1055 ASSERT_EQ(system("mkfs.ext4 -q /mnt/C/ext4.img"), 0); in FIXTURE_SETUP()
1056 ASSERT_EQ(system("mount -o loop -t ext4 /mnt/C/ext4.img /mnt/D/"), 0); in FIXTURE_SETUP()
1057 ASSERT_EQ(close(img_fd), 0); in FIXTURE_SETUP()
1073 .userns_fd = -EBADF, in TEST_F()
1079 ASSERT_NE(sys_mount_setattr(-1, "/", 0, &attr, sizeof(attr)), 0) { in TEST_F()
1097 ASSERT_NE(sys_mount_setattr(-1, "/", 0, &attr, sizeof(attr)), 0) { in TEST_F()
1117 ASSERT_GE(close(fd), 0); in TEST_F()
1120 ASSERT_NE(sys_mount_setattr(-1, "/", 0, &attr, sizeof(attr)), 0) { in TEST_F()
1130 int open_tree_fd = -EBADF; in TEST_F()
1138 open_tree_fd = sys_open_tree(-EBADF, "/mnt/D", in TEST_F()
1148 ASSERT_EQ(close(attr.userns_fd), 0); in TEST_F()
1149 ASSERT_EQ(close(open_tree_fd), 0); in TEST_F()
1153 unsigned long range) in map_ids() argument
1158 snprintf(map, sizeof(map), "%lu %lu %lu", nsid, hostid, range); in map_ids()
1160 return -1; in map_ids()
1164 snprintf(map, sizeof(map), "%lu %lu %lu", nsid, hostid, range); in map_ids()
1166 return -1; in map_ids()
1178 return -ENOMEM; in do_clone()
1198 if (ret == -1) { in wait_for_pid()
1202 return -1; in wait_for_pid()
1206 return -1; in wait_for_pid()
1211 static int get_userns_fd(unsigned long nsid, unsigned long hostid, unsigned long range) in get_userns_fd() argument
1219 return -errno; in get_userns_fd()
1221 ret = map_ids(pid, nsid, hostid, range); in get_userns_fd()
1239 int open_tree_fd = -EBADF; in TEST_F()
1247 open_tree_fd = sys_open_tree(-EBADF, "/mnt/D", in TEST_F()
1257 ASSERT_EQ(close(attr.userns_fd), 0); in TEST_F()
1258 ASSERT_EQ(close(open_tree_fd), 0); in TEST_F()
1269 int open_tree_fd = -EBADF; in TEST_F()
1277 open_tree_fd = sys_open_tree(-EBADF, "/mnt/D", in TEST_F()
1290 ASSERT_EQ(close(attr.userns_fd), 0); in TEST_F()
1291 ASSERT_EQ(close(open_tree_fd), 0); in TEST_F()
1299 int open_tree_fd = -EBADF; in TEST_F()
1307 open_tree_fd = sys_open_tree(-EBADF, "/mnt/D", in TEST_F()
1320 ASSERT_EQ(close(attr.userns_fd), 0); in TEST_F()
1321 ASSERT_EQ(close(open_tree_fd), 0); in TEST_F()
1329 int open_tree_fd = -EBADF; in TEST_F()
1337 open_tree_fd = sys_open_tree(-EBADF, "/mnt/D", in TEST_F()
1352 ASSERT_EQ(close(attr.userns_fd), 0); in TEST_F()
1353 ASSERT_EQ(close(open_tree_fd), 0); in TEST_F()
1361 int open_tree_fd = -EBADF; in TEST_F()
1369 open_tree_fd = sys_open_tree(-EBADF, "/mnt/D", in TEST_F()
1381 ASSERT_EQ(close(attr.userns_fd), 0); in TEST_F()
1387 ASSERT_EQ(close(attr.userns_fd), 0); in TEST_F()
1388 ASSERT_EQ(close(open_tree_fd), 0); in TEST_F()
1406 int open_tree_fd = -EBADF; in TEST_F()
1414 ASSERT_EQ(expected_uid_gid(-EBADF, "/tmp/B/b", 0, 0, 0), 0); in TEST_F()
1415 ASSERT_EQ(expected_uid_gid(-EBADF, "/tmp/B/BB/b", 0, 0, 0), 0); in TEST_F()
1424 open_tree_fd = sys_open_tree(-EBADF, "/mnt/A", in TEST_F()
1436 ASSERT_EQ(close(attr.userns_fd), 0); in TEST_F()
1437 ASSERT_EQ(close(open_tree_fd), 0); in TEST_F()
1439 ASSERT_EQ(expected_uid_gid(-EBADF, "/tmp/B/b", 0, 0, 0), 0); in TEST_F()
1440 ASSERT_EQ(expected_uid_gid(-EBADF, "/tmp/B/BB/b", 0, 0, 0), 0); in TEST_F()
1460 ASSERT_EQ(close(fd), 0); in TEST_F()
1465 ASSERT_EQ(sys_mount_setattr(-1, "/mnt/A", AT_RECURSIVE, &attr, sizeof(attr)), 0); in TEST_F()
1489 ASSERT_EQ(sys_mount_setattr(-1, "/mnt/A", AT_RECURSIVE, &attr, sizeof(attr)), 0); in TEST_F()
1506 ASSERT_EQ(close(fd), 0); in TEST_F()