From: Matthew Wilcox <willy@infradead.org>
To: Kees Cook <kees@kernel.org>
Cc: Jan Kara <jack@suse.cz>, Amir Goldstein <amir73il@gmail.com>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-hardening@vger.kernel.org
Subject: Re: [PATCH] inotify: Use strscpy() for event->name copies
Date: Tue, 17 Dec 2024 04:12:07 +0000 [thread overview]
Message-ID: <Z2D6FzPgomC442vW@casper.infradead.org> (raw)
In-Reply-To: <20241216224507.work.859-kees@kernel.org>
On Mon, Dec 16, 2024 at 02:45:15PM -0800, Kees Cook wrote:
> Since we have already allocated "len + 1" space for event->name, make sure
> that name->name cannot ever accidentally cause a copy overflow by calling
> strscpy() instead of the unbounded strcpy() routine. This assists in
> the ongoing efforts to remove the unsafe strcpy() API[1] from the kernel.
Since a qstr can't contain a NUL before the length, why not just use
memcpy()?
> event->name_len = len;
> if (len)
> - strcpy(event->name, name->name);
> + strscpy(event->name, name->name, event->name_len + 1);
next prev parent reply other threads:[~2024-12-17 4:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-16 22:45 [PATCH] inotify: Use strscpy() for event->name copies Kees Cook
2024-12-17 4:12 ` Matthew Wilcox [this message]
2024-12-17 7:51 ` Kees Cook
2024-12-18 10:35 ` Jan Kara
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=Z2D6FzPgomC442vW@casper.infradead.org \
--to=willy@infradead.org \
--cc=amir73il@gmail.com \
--cc=jack@suse.cz \
--cc=kees@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.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