public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Vikas Kumar <vikas.kumar2@arm.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] syscalls/fork14: Fix Buffer overflow
Date: Tue,  9 Jun 2020 12:46:11 +0530	[thread overview]
Message-ID: <20200609071611.9467-1-vikas.kumar2@arm.com> (raw)

This change basically avoids the buffer overflow by keeping the check count
to allocation limit
The problem occurs when there is no failure and i == EXTENT, so
pointer_vec[EXTENT] goes beyond the allocated buffer.

Signed-off-by: Vikas Kumar <vikas.kumar2@arm.com>
Reported-by: Amit Kachhap <amit.kachhap@arm.com>
---
 testcases/kernel/syscalls/fork/fork14.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/testcases/kernel/syscalls/fork/fork14.c b/testcases/kernel/syscalls/fork/fork14.c
index a92aa46ad..2a20d9df8 100644
--- a/testcases/kernel/syscalls/fork/fork14.c
+++ b/testcases/kernel/syscalls/fork/fork14.c
@@ -132,6 +132,9 @@ static int fork_test(void)
 		}
 	}
 
+	if (i == EXTENT)
+		i--;
+
 clear_memory_map:
 	for (j = 0; j <= i; j++) {
 		if (pointer_vec[j])
-- 
2.17.1


             reply	other threads:[~2020-06-09  7:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-09  7:16 Vikas Kumar [this message]
2020-06-11 11:33 ` [LTP] [PATCH] syscalls/fork14: Fix Buffer overflow Jan Stancek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200609071611.9467-1-vikas.kumar2@arm.com \
    --to=vikas.kumar2@arm.com \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox