From: "tip-bot2 for Binbin Wu" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Binbin Wu <binbin.wu@linux.intel.com>,
Ingo Molnar <mingo@kernel.org>,
"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: x86/mm] selftests/x86/lam: Zero out buffer for readlink()
Date: Mon, 16 Oct 2023 09:44:35 -0000 [thread overview]
Message-ID: <169744947512.3135.5098809828724848406.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20231016062446.695-1-binbin.wu@linux.intel.com>
The following commit has been merged into the x86/mm branch of tip:
Commit-ID: 29060633411a02f6f2dd9d5245919385d69d81f0
Gitweb: https://git.kernel.org/tip/29060633411a02f6f2dd9d5245919385d69d81f0
Author: Binbin Wu <binbin.wu@linux.intel.com>
AuthorDate: Mon, 16 Oct 2023 14:24:46 +08:00
Committer: Ingo Molnar <mingo@kernel.org>
CommitterDate: Mon, 16 Oct 2023 11:39:57 +02:00
selftests/x86/lam: Zero out buffer for readlink()
Zero out the buffer for readlink() since readlink() does not append a
terminating null byte to the buffer. Also change the buffer length
passed to readlink() to 'PATH_MAX - 1' to ensure the resulting string
is always null terminated.
Fixes: 833c12ce0f430 ("selftests/x86/lam: Add inherit test cases for linear-address masking")
Signed-off-by: Binbin Wu <binbin.wu@linux.intel.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Reviewed-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Link: https://lore.kernel.org/r/20231016062446.695-1-binbin.wu@linux.intel.com
---
tools/testing/selftests/x86/lam.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/x86/lam.c b/tools/testing/selftests/x86/lam.c
index eb0e469..8f9b06d 100644
--- a/tools/testing/selftests/x86/lam.c
+++ b/tools/testing/selftests/x86/lam.c
@@ -573,7 +573,7 @@ int do_uring(unsigned long lam)
char path[PATH_MAX] = {0};
/* get current process path */
- if (readlink("/proc/self/exe", path, PATH_MAX) <= 0)
+ if (readlink("/proc/self/exe", path, PATH_MAX - 1) <= 0)
return 1;
int file_fd = open(path, O_RDONLY);
@@ -680,14 +680,14 @@ static int handle_execve(struct testcases *test)
perror("Fork failed.");
ret = 1;
} else if (pid == 0) {
- char path[PATH_MAX];
+ char path[PATH_MAX] = {0};
/* Set LAM mode in parent process */
if (set_lam(lam) != 0)
return 1;
/* Get current binary's path and the binary was run by execve */
- if (readlink("/proc/self/exe", path, PATH_MAX) <= 0)
+ if (readlink("/proc/self/exe", path, PATH_MAX - 1) <= 0)
exit(-1);
/* run binary to get LAM mode and return to parent process */
prev parent reply other threads:[~2023-10-16 9:44 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-16 6:24 [PATCH v2] " Binbin Wu
2023-10-16 8:47 ` kirill.shutemov
2023-10-16 19:11 ` Shuah Khan
2023-10-16 9:44 ` tip-bot2 for Binbin Wu [this message]
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=169744947512.3135.5098809828724848406.tip-bot2@tip-bot2 \
--to=tip-bot2@linutronix.de \
--cc=binbin.wu@linux.intel.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=x86@kernel.org \
/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
all inboxes | Powered by JetHome®