diff options
| author | Kees Cook <kees@kernel.org> | 2024-12-16 14:45:15 -0800 |
|---|---|---|
| committer | Jan Kara <jack@suse.cz> | 2024-12-18 11:33:40 +0100 |
| commit | b8f2688258f886f0bc0c0cb3ebe51efaa12191ec (patch) | |
| tree | d0865144bb20468023a5a507f5d7c945f1823f7c /fs/notify | |
| parent | Linux 6.13-rc2 (diff) | |
| download | linux-b8f2688258f886f0bc0c0cb3ebe51efaa12191ec.tar.gz linux-b8f2688258f886f0bc0c0cb3ebe51efaa12191ec.zip | |
inotify: Use strscpy() for event->name copies
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.
Link: https://github.com/KSPP/linux/issues/88 [1]
Signed-off-by: Kees Cook <kees@kernel.org>
Signed-off-by: Jan Kara <jack@suse.cz>
Link: https://patch.msgid.link/20241216224507.work.859-kees@kernel.org
Diffstat (limited to 'fs/notify')
| -rw-r--r-- | fs/notify/inotify/inotify_fsnotify.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/notify/inotify/inotify_fsnotify.c b/fs/notify/inotify/inotify_fsnotify.c index 993375f0db67..cd7d11b0eb08 100644 --- a/fs/notify/inotify/inotify_fsnotify.c +++ b/fs/notify/inotify/inotify_fsnotify.c @@ -121,7 +121,7 @@ int inotify_handle_inode_event(struct fsnotify_mark *inode_mark, u32 mask, event->sync_cookie = cookie; event->name_len = len; if (len) - strcpy(event->name, name->name); + strscpy(event->name, name->name, event->name_len + 1); ret = fsnotify_add_event(group, fsn_event, inotify_merge); if (ret) { |
