From: Binbin Wu <binbin.wu@linux.intel.com>
To: kirill.shutemov@linux.intel.com
Cc: dave.hansen@linux.intel.com, luto@kernel.org,
peterz@infradead.org, shuah@kernel.org,
linux-kselftest@vger.kernel.org, x86@kernel.org,
linux-kernel@vger.kernel.org, weihong.zhang@intel.com
Subject: Re: [PATCH] selftests/x86/lam: Zero out buffer for readlink()
Date: Tue, 10 Oct 2023 11:51:32 +0800 [thread overview]
Message-ID: <1793b780-cd15-b6a3-f951-c19a14a1310c@linux.intel.com> (raw)
In-Reply-To: <20230927110219.b5n3fbbwrxtcwtzp@box.shutemov.name>
On 9/27/2023 7:02 PM, kirill.shutemov@linux.intel.com wrote:
> On Sun, Sep 24, 2023 at 07:33:46AM +0800, Binbin Wu wrote:
>> Zero out the buffer for readlink() since readlink() does not append a
>> terminating null byte to the buffer.
>>
>> Fixes: 833c12ce0f430 ("selftests/x86/lam: Add inherit test cases for linear-address masking")
>>
>> Signed-off-by: Binbin Wu <binbin.wu@linux.intel.com>
>> ---
>> tools/testing/selftests/x86/lam.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/tools/testing/selftests/x86/lam.c b/tools/testing/selftests/x86/lam.c
>> index eb0e46905bf9..9f06942a8e25 100644
>> --- a/tools/testing/selftests/x86/lam.c
>> +++ b/tools/testing/selftests/x86/lam.c
>> @@ -680,7 +680,7 @@ 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};
> Shouldn't it be PATH_MAX+1 to handle the case when readlink(2) stores
> exactly PATH_MAX bytes into the buffer?
According to the definition of PATH_MAX in include/uapi/linux/limits.h
#define PATH_MAX 4096 /* # chars in a path name including nul */
IIUC, Linux limits the path length to 4095 and PATH_MAX includes the
terminating nul.
>
>>
>> /* Set LAM mode in parent process */
>> if (set_lam(lam) != 0)
>>
>> base-commit: ce9ecca0238b140b88f43859b211c9fdfd8e5b70
>> --
>> 2.25.1
>>
next prev parent reply other threads:[~2023-10-10 3:51 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-23 23:33 [PATCH] selftests/x86/lam: Zero out buffer for readlink() Binbin Wu
2023-09-27 11:02 ` kirill.shutemov
2023-10-10 3:51 ` Binbin Wu [this message]
2023-10-10 5:46 ` kirill.shutemov
2023-10-10 8:20 ` Binbin Wu
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=1793b780-cd15-b6a3-f951-c19a14a1310c@linux.intel.com \
--to=binbin.wu@linux.intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=luto@kernel.org \
--cc=peterz@infradead.org \
--cc=shuah@kernel.org \
--cc=weihong.zhang@intel.com \
--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