From: Jinjie Ruan <ruanjinjie@huawei.com>
To: Paul Moore <paul@paul-moore.com>
Cc: <eparis@redhat.com>, <audit@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] audit: Use strscpy instead of memcpy when copying comm
Date: Thu, 1 Aug 2024 09:25:32 +0800 [thread overview]
Message-ID: <765b4384-ab4d-c202-9efd-1138bc42e9e7@huawei.com> (raw)
In-Reply-To: <CAHC9VhR9MC9GhGZi_1ftycfGyeuCQ=BXgAs+v+9D-nXWg+eu=A@mail.gmail.com>
On 2024/7/31 23:51, Paul Moore wrote:
> On Wed, Jul 31, 2024 at 3:46 AM Jinjie Ruan <ruanjinjie@huawei.com> wrote:
>>
>> There may be random garbage beyond a string's null terminator, memcpy might
>> use the entire comm array. so avoid that possibility by using strscpy
>> instead of memcpy.
>>
>> Link: https://github.com/KSPP/linux/issues/90
>> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
>> ---
>> kernel/auditsc.c | 6 +++---
>> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> If you look at audit_log_pid_context() you'll see that we don't record
> the entire task::comm field, we only record up the NUL byte, so any
> garbage present after the end of the string should not make it into
> the audit record. We use memcpy(), as opposed to any of the string
> based copy functions, as the task::comm field is relatively short and
> having to count the length of the string in addition to copying the
> string is likely more expensive than simply copying the full buffer.
Thank you very much, You're right, sorry I didn't read the code
carefully enough.
>
prev parent reply other threads:[~2024-08-01 1:25 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-31 7:52 Jinjie Ruan
2024-07-31 15:51 ` Paul Moore
2024-08-01 1:25 ` Jinjie Ruan [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=765b4384-ab4d-c202-9efd-1138bc42e9e7@huawei.com \
--to=ruanjinjie@huawei.com \
--cc=audit@vger.kernel.org \
--cc=eparis@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=paul@paul-moore.com \
/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®