From: Thorsten Blum Date: Sat, 21 Mar 2026 21:05:47 +0000 (+0100) Subject: fanotify: replace deprecated strcpy in fanotify_info_copy_{name,name2} X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0fdbe845534f4e0b7243b7a44562c4486ce25fb4;p=thirdparty%2Fkernel%2Flinux.git 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 Link: https://patch.msgid.link/20260321210544.519259-4-thorsten.blum@linux.dev Signed-off-by: Jan Kara --- diff --git a/fs/notify/fanotify/fanotify.h b/fs/notify/fanotify/fanotify.h index 39e60218df7ce..a0619e7694d57 100644 --- a/fs/notify/fanotify/fanotify.h +++ b/fs/notify/fanotify/fanotify.h @@ -2,6 +2,7 @@ #include #include #include +#include #include #include @@ -218,7 +219,7 @@ static inline void fanotify_info_copy_name(struct fanotify_info *info, return; info->name_len = name->len; - strcpy(fanotify_info_name(info), name->name); + strscpy(fanotify_info_name(info), name->name, name->len + 1); } static inline void fanotify_info_copy_name2(struct fanotify_info *info, @@ -228,7 +229,7 @@ static inline void fanotify_info_copy_name2(struct fanotify_info *info, return; info->name2_len = name->len; - strcpy(fanotify_info_name2(info), name->name); + strscpy(fanotify_info_name2(info), name->name, name->len + 1); } /*