Skip to content

Commit b8f2688

Browse files
keesjankara
authored andcommitted
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: KSPP#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
1 parent fac04ef commit b8f2688

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/notify/inotify/inotify_fsnotify.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ int inotify_handle_inode_event(struct fsnotify_mark *inode_mark, u32 mask,
121121
event->sync_cookie = cookie;
122122
event->name_len = len;
123123
if (len)
124-
strcpy(event->name, name->name);
124+
strscpy(event->name, name->name, event->name_len + 1);
125125

126126
ret = fsnotify_add_event(group, fsn_event, inotify_merge);
127127
if (ret) {

0 commit comments

Comments
 (0)