public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] syscalls/ioctl_ns05,6: Fix buffer overflow
@ 2021-07-15  1:39 Yang Xu
       [not found] ` <a0c00c11-1d50-2eed-131f-cc74798ebf03@linux.ibm.com>
  0 siblings, 1 reply; 2+ messages in thread
From: Yang Xu @ 2021-07-15  1:39 UTC (permalink / raw)
  To: ltp

Since pid's max value is 2147483647, the child_namespace maybe not
enough to store "/proc/%s/ns/user" string when using a large pid.
Fix it by improving the length to 30.

Fixes: #847
Reported-by: Marius Hillenbrand <mhillen@linux.ibm.com>
Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
---
 testcases/kernel/syscalls/ioctl/ioctl_ns05.c | 2 +-
 testcases/kernel/syscalls/ioctl/ioctl_ns06.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/testcases/kernel/syscalls/ioctl/ioctl_ns05.c b/testcases/kernel/syscalls/ioctl/ioctl_ns05.c
index a67ddbe2c..488c48d8e 100644
--- a/testcases/kernel/syscalls/ioctl/ioctl_ns05.c
+++ b/testcases/kernel/syscalls/ioctl/ioctl_ns05.c
@@ -59,7 +59,7 @@ static void run(void)
 	if (pid == -1)
 		tst_brk(TBROK | TERRNO, "ltp_clone failed");
 
-	char child_namespace[20];
+	char child_namespace[30];
 	int my_fd, child_fd, parent_fd;
 
 	sprintf(child_namespace, "/proc/%i/ns/pid", pid);
diff --git a/testcases/kernel/syscalls/ioctl/ioctl_ns06.c b/testcases/kernel/syscalls/ioctl/ioctl_ns06.c
index b6ac80208..77ec04edc 100644
--- a/testcases/kernel/syscalls/ioctl/ioctl_ns06.c
+++ b/testcases/kernel/syscalls/ioctl/ioctl_ns06.c
@@ -51,7 +51,7 @@ static int child(void *arg LTP_ATTRIBUTE_UNUSED)
 
 static void run(void)
 {
-	char child_namespace[20];
+	char child_namespace[30];
 
 	pid_t pid = ltp_clone(CLONE_NEWUSER | SIGCHLD, &child, 0,
 		STACK_SIZE, child_stack);
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [LTP] [PATCH] syscalls/ioctl_ns05,6: Fix buffer overflow
       [not found] ` <a0c00c11-1d50-2eed-131f-cc74798ebf03@linux.ibm.com>
@ 2021-07-16  8:26   ` xuyang2018.jy
  0 siblings, 0 replies; 2+ messages in thread
From: xuyang2018.jy @ 2021-07-16  8:26 UTC (permalink / raw)
  To: ltp

Hi  Marius

cc ltp list
> Hi Yang,
>
> Thanks for your patch! I had missed your email before submitting my PR.
It doesn't matter.
>
> What do you think about also turning the sprintf() into snprintf()?
I have no objection for using snprintf.
Also, ltp usually accepts patch from mailing list instead of pull request.

ps: cc ltp guys, so other maintainers will know I have no objection for 
your patch.

Best  Regards
Yang Xu
>
> Regards,
> Marius

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-07-16  8:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-07-15  1:39 [LTP] [PATCH] syscalls/ioctl_ns05,6: Fix buffer overflow Yang Xu
     [not found] ` <a0c00c11-1d50-2eed-131f-cc74798ebf03@linux.ibm.com>
2021-07-16  8:26   ` xuyang2018.jy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox