Skip to contentSkip to conversation

syscalls/cma: write also null term. byte to address pipe

PATCH New Jan Stancek 2 participants 3 messages Dec 30, 2017 – Jan 3, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 syscalls/cma: write also null term. byte to address pipe

Problem is that first child doesn't write null term. byte and other child doesn't initialise buffer it reads into, so occasionally there's garbage that makes address longer and therefore invalid and test fails:

 process_vm_readv02    0  TINFO  :  child 1: reading string from same memory location.
 process_vm_readv02    1  TFAIL  :  process_vm_readv02.c:143: process_vm_readv: errno=EFAULT(14): Bad address
 process_vm_readv02    0  TINFO  :  child 0: memory allocated and initialized.
 process_vm_readv02    1  TFAIL  :  process_vm_readv02.c:86: child 1 returns 256
---
 testcases/kernel/syscalls/cma/process_vm_readv02.c  | 2 +-
 testcases/kernel/syscalls/cma/process_vm_readv03.c  | 2 +-
 testcases/kernel/syscalls/cma/process_vm_writev02.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
testcases/kernel/syscalls/cma/process_vm_readv02.c +1 -1
index aa81f17f7bd2..ef9b7e137d13 100644
@@ -107,7 +107,7 @@ static void child_alloc(void)
 	/* passing addr of string "foo" via pipe */
 	SAFE_CLOSE(tst_exit, pipe_fd[0]);
 	snprintf(buf, BUFSIZ, "%p", foo);
-	SAFE_WRITE(tst_exit, 1, pipe_fd[1], buf, strlen(buf));
+	SAFE_WRITE(tst_exit, 1, pipe_fd[1], buf, strlen(buf) + 1);
 	SAFE_CLOSE(tst_exit, pipe_fd[1]);
 
 	/* wait until child_invoke is done reading from our VM */
testcases/kernel/syscalls/cma/process_vm_readv03.c +1 -1
index d1ca87a14b4d..8b8dfc316193 100644
@@ -152,7 +152,7 @@ static void child_alloc(int *bufsz_arr)
 	/* passing addr via pipe */
 	SAFE_CLOSE(tst_exit, pipe_fd[0]);
 	snprintf(buf, BUFSIZ, "%p", (void *)foo);
-	SAFE_WRITE(tst_exit, 1, pipe_fd[1], buf, strlen(buf));
+	SAFE_WRITE(tst_exit, 1, pipe_fd[1], buf, strlen(buf) + 1);
 	SAFE_CLOSE(tst_exit, pipe_fd[1]);
 
 	/* wait until child_invoke is done reading from our VM */
testcases/kernel/syscalls/cma/process_vm_writev02.c +1 -1
index 544bda8d5361..b707760b1884 100644
@@ -121,7 +121,7 @@ static void child_init_and_verify(void)
 	/* passing addr of string "foo" via pipe */
 	SAFE_CLOSE(tst_exit, pipe_fd[0]);
 	snprintf(buf, bufsz, "%p", foo);
-	SAFE_WRITE(tst_exit, 1, pipe_fd[1], buf, strlen(buf));
+	SAFE_WRITE(tst_exit, 1, pipe_fd[1], buf, strlen(buf) + 1);
 	SAFE_CLOSE(tst_exit, pipe_fd[1]);
 
 	/* wait until child_write() is done writing to our VM */
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 1/1 syscalls/cma: write also null term. byte to address pipe

Hi!
Looks obviously correct to me.

Signature · 2 lines
Cyril Hrubis
[email protected]
#2 lore raw

PATCH 1/1 syscalls/cma: write also null term. byte to address pipe

----- Original Message -----

Quoted 2 lines

Hi!
Looks obviously correct to me.

Pushed.

Regards,
Jan