diff mbox series

safe_open: Add missing mode from some calls

Message ID 20230323160508.672397-1-teo.coupriediaz@arm.com
State Accepted
Headers show
Series safe_open: Add missing mode from some calls | expand

Commit Message

Teo Couprie Diaz March 23, 2023, 4:05 p.m. UTC
safe_open expects a mode when creating or using a temporary file, which is
read via a variadic argument.
Add the mode when it is missing for a few tests.

Signed-off-by: Teo Couprie Diaz <teo.coupriediaz@arm.com>
---
This was detected on Morello[0] as the missing mode triggered an access
outside of capability bounds when processing the variadic argument.

CI Build: https://github.com/Teo-CD/ltp/actions/runs/4502201455

[0]: https://www.morello-project.org/

 .../kernel/syscalls/name_to_handle_at/name_to_handle_at01.c     | 2 +-
 .../kernel/syscalls/open_by_handle_at/open_by_handle_at01.c     | 2 +-
 testcases/kernel/syscalls/utimensat/utimensat01.c               | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

Comments

Cyril Hrubis March 28, 2023, 8:26 a.m. UTC | #1
Hi!
Good catch, applied, thanks.
diff mbox series

Patch

diff --git a/testcases/kernel/syscalls/name_to_handle_at/name_to_handle_at01.c b/testcases/kernel/syscalls/name_to_handle_at/name_to_handle_at01.c
index 9677b06719e3..6535fdf5c0ed 100644
--- a/testcases/kernel/syscalls/name_to_handle_at/name_to_handle_at01.c
+++ b/testcases/kernel/syscalls/name_to_handle_at/name_to_handle_at01.c
@@ -72,7 +72,7 @@  static void setup(void)
 	dir_fd = SAFE_OPEN(TEST_DIR, O_DIRECTORY);
 	SAFE_CHDIR(TEST_DIR);
 	SAFE_TOUCH(TEST_FILE, 0600, NULL);
-	file_fd = SAFE_OPEN("foo_file", O_RDWR | O_CREAT);
+	file_fd = SAFE_OPEN("foo_file", O_RDWR | O_CREAT, 0600);
 	fhp = allocate_file_handle(AT_FDCWD, TEST_FILE);
 }
 
diff --git a/testcases/kernel/syscalls/open_by_handle_at/open_by_handle_at01.c b/testcases/kernel/syscalls/open_by_handle_at/open_by_handle_at01.c
index 76be720cad78..6171229f0b6f 100644
--- a/testcases/kernel/syscalls/open_by_handle_at/open_by_handle_at01.c
+++ b/testcases/kernel/syscalls/open_by_handle_at/open_by_handle_at01.c
@@ -55,7 +55,7 @@  static void setup(void)
 	dir_fd = SAFE_OPEN(TEST_DIR, O_DIRECTORY);
 	SAFE_CHDIR(TEST_DIR);
 	SAFE_TOUCH(TEST_FILE, 0600, NULL);
-	file_fd = SAFE_OPEN("foo_file", O_RDWR | O_CREAT);
+	file_fd = SAFE_OPEN("foo_file", O_RDWR | O_CREAT, 0600);
 
 	f_fhp = allocate_file_handle(AT_FDCWD, TEST_FILE);
 	d_fhp = allocate_file_handle(AT_FDCWD, TEST_FILE);
diff --git a/testcases/kernel/syscalls/utimensat/utimensat01.c b/testcases/kernel/syscalls/utimensat/utimensat01.c
index ac267e7d9f84..a2897b42288d 100644
--- a/testcases/kernel/syscalls/utimensat/utimensat01.c
+++ b/testcases/kernel/syscalls/utimensat/utimensat01.c
@@ -233,7 +233,7 @@  static void run(unsigned int i)
 		dfd = SAFE_OPEN(TEST_DIR, tc->oflags);
 
 	if (tc->pathname) {
-		fd = SAFE_OPEN(tc->pathname, O_WRONLY | O_CREAT);
+		fd = SAFE_OPEN(tc->pathname, O_WRONLY | O_CREAT, 0200);
 		pathname = tc->pathname;
 		SAFE_CHMOD(tc->pathname, tc->mode);
 		reset_time(pathname, dfd, tc->flags, i);