[LTP] [PATCH v2] syscalls/statmount07: change "invalid buffer size" test

Jan Stancek jstancek@redhat.com
Tue Oct 15 13:48:14 CEST 2024


The manpage doesn't say that 'smbuf' needs to be valid
for entire range of 'bufsize'.

This check relies on access_ok() check, which can be skipped
on some arches/configs, for example on s390x with
CONFIG_ALTERNATE_USER_ADDRESS_SPACE=y. Test then fails with:
  statmount07.c:117: TFAIL: invalid buffer size succeeded

Change the test to use buffer that crosses partially
into PROT_NONE area.

Signed-off-by: Jan Stancek <jstancek@redhat.com>
---
 testcases/kernel/syscalls/statmount/statmount07.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/testcases/kernel/syscalls/statmount/statmount07.c b/testcases/kernel/syscalls/statmount/statmount07.c
index 0cc83429872f..58fcc20acce7 100644
--- a/testcases/kernel/syscalls/statmount/statmount07.c
+++ b/testcases/kernel/syscalls/statmount/statmount07.c
@@ -20,10 +20,10 @@
 static struct statmount *st_mount;
 static struct statmount *st_mount_null;
 static struct statmount *st_mount_small;
+static struct statmount *st_mount_bad;
 static uint64_t mnt_id;
 static uint64_t mnt_id_dont_exist = -1;
 static size_t buff_size;
-static size_t buff_size_invalid = -1;
 
 struct tcase {
 	int exp_errno;
@@ -90,12 +90,12 @@ struct tcase {
 	},
 	{
 		EFAULT,
-		"invalid buffer size",
+		"buffer crosses to PROT_NONE",
 		&mnt_id,
 		0,
 		0,
-		&buff_size_invalid,
-		&st_mount
+		&buff_size,
+		&st_mount_bad
 	},
 	{
 		EFAULT,
@@ -139,6 +139,7 @@ static struct tst_test test = {
 	.bufs = (struct tst_buffers []) {
 		{&st_mount, .size = sizeof(struct statmount)},
 		{&st_mount_small, .size = sizeof(struct statmount)},
+		{&st_mount_bad, .size = 1},
 		{}
 	}
 };
-- 
2.43.0



More information about the ltp mailing list