[SRU][B][PATCH 1/1] UBUNTU: SAUCE: selftests/memfd: fix build when F_SEAL_FUTURE_WRITE is not defined

Luke Nowakowski-Krijger luke.nowakowskikrijger at canonical.com
Mon Aug 30 18:50:39 UTC 2021


BugLink: https://bugs.launchpad.net/bugs/1926142

Fix build issue that seems to be affects all B/5.4 kernels due to 5.4
tests being built against headers from a previous release.

Conditionally define the entire test_seal_future_write() definition
as opposed to just the F_SEAL_FUTURE_WRITE operations, so that if any
calls to the test are added in the future outside of ifdef scope, it
should result in a more clear build failure, and not a confusing failure of
the test if just the F_SEAL_FUTURE_WRITE ops were ommited.

Signed-off-by: Luke Nowakowski-Krijger <luke.nowakowskikrijger at canonical.com>
---
 tools/testing/selftests/memfd/memfd_test.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tools/testing/selftests/memfd/memfd_test.c b/tools/testing/selftests/memfd/memfd_test.c
index bb3f8bf9b8de..8edff32c7188 100644
--- a/tools/testing/selftests/memfd/memfd_test.c
+++ b/tools/testing/selftests/memfd/memfd_test.c
@@ -731,6 +731,7 @@ static void test_seal_write(void)
  * Test SEAL_FUTURE_WRITE
  * Test whether SEAL_FUTURE_WRITE actually prevents modifications.
  */
+#ifdef F_SEAL_FUTURE_WRITE
 static void test_seal_future_write(void)
 {
 	int fd, fd2;
@@ -764,6 +765,7 @@ static void test_seal_future_write(void)
 	close(fd2);
 	close(fd);
 }
+#endif
 
 /*
  * Test SEAL_SHRINK
@@ -1018,7 +1020,9 @@ int main(int argc, char **argv)
 	test_basic();
 
 	test_seal_write();
+#ifdef F_SEAL_FUTURE_WRITE
 	test_seal_future_write();
+#endif
 	test_seal_shrink();
 	test_seal_grow();
 	test_seal_resize();
-- 
2.30.2




More information about the kernel-team mailing list