Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

fanotify: replace deprecated strcpy in fanotify_info_copy_{name,name2}

strcpy() has been deprecated [1] because it performs no bounds checking
on the destination buffer, which can lead to buffer overflows. Replace
it with the safer strscpy().

Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy [1]
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Link: https://patch.msgid.link/20260321210544.519259-4-thorsten.blum@linux.dev
Signed-off-by: Jan Kara <jack@suse.cz>

authored by

Thorsten Blum and committed by
Jan Kara
0fdbe845 4520b96b

+3 -2
+3 -2
fs/notify/fanotify/fanotify.h
··· 2 2 #include <linux/fsnotify_backend.h> 3 3 #include <linux/path.h> 4 4 #include <linux/slab.h> 5 + #include <linux/string.h> 5 6 #include <linux/exportfs.h> 6 7 #include <linux/hashtable.h> 7 8 ··· 219 218 return; 220 219 221 220 info->name_len = name->len; 222 - strcpy(fanotify_info_name(info), name->name); 221 + strscpy(fanotify_info_name(info), name->name, name->len + 1); 223 222 } 224 223 225 224 static inline void fanotify_info_copy_name2(struct fanotify_info *info, ··· 229 228 return; 230 229 231 230 info->name2_len = name->len; 232 - strcpy(fanotify_info_name2(info), name->name); 231 + strscpy(fanotify_info_name2(info), name->name, name->len + 1); 233 232 } 234 233 235 234 /*