Thread (20 messages) 20 messages, 3 authors, 2023-07-31
STALE1071d
Revisions (11)
  1. v2 current
  2. v3 [diff vs current]
  3. v4 [diff vs current]
  4. v5 [diff vs current]
  5. v6 [diff vs current]
  6. v7 [diff vs current]
  7. v8 [diff vs current]
  8. v10 [diff vs current]
  9. v11 [diff vs current]
  10. v12 [diff vs current]
  11. v14 [diff vs current]

[PATCH v2 4/6] selftests/landlock: Test ioctl with memfds

From: "Günther Noack" <gnoack@google.com>
Date: 2023-06-23 14:44:52
Also in: linux-fsdevel
Subsystem: kernel selftest framework, landlock security module, the rest · Maintainers: Shuah Khan, Mickaël Salaün, Linus Torvalds

Because the ioctl right is associated with the opened file,
we expect that it will work with files which are opened by means
other than open(2).

Signed-off-by: Günther Noack <gnoack@google.com>
---
 tools/testing/selftests/landlock/fs_test.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/tools/testing/selftests/landlock/fs_test.c b/tools/testing/selftests/landlock/fs_test.c
index 0f0899768fe7..ebd93e895775 100644
--- a/tools/testing/selftests/landlock/fs_test.c
+++ b/tools/testing/selftests/landlock/fs_test.c
@@ -3716,18 +3716,20 @@ TEST_F_FORK(ftruncate, open_and_ftruncate_in_different_processes)
 	ASSERT_EQ(0, close(socket_fds[1]));
 }
 
-TEST(memfd_ftruncate)
+TEST(memfd_ftruncate_and_ioctl)
 {
-	int fd;
+	int fd, n;
 
 	fd = memfd_create("name", MFD_CLOEXEC);
 	ASSERT_LE(0, fd);
 
 	/*
-	 * Checks that ftruncate is permitted on file descriptors that are
-	 * created in ways other than open(2).
+	 * Checks that operations associated with the opened file
+	 * (ftruncate, ioctl) are permitted on file descriptors that
+	 * are created in ways other than open(2).
 	 */
 	EXPECT_EQ(0, test_ftruncate(fd));
+	EXPECT_EQ(0, ioctl(fd, FIONREAD, &n));
 
 	ASSERT_EQ(0, close(fd));
 }
-- 
2.41.0.162.gfafddb0af9-goog
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help