From nobody Sat Apr 4 00:05:59 2026 Received: from out-171.mta1.migadu.com (out-171.mta1.migadu.com [95.215.58.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6FE1B363C47 for ; Sat, 21 Mar 2026 21:06:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774127216; cv=none; b=kqs+vtD3VPEO1q8QVnhi/jbgDNZzDGUoRufUitL8Nrk/9cgf8NZ41oDeQnUiWGVHny4ZMuR4F/Y0Wz7jsT949d+wMSmf8VqkjZlWw2AIMA2MJ30QV5a0+z+zl7i89VchQIR0DXs3PNTYsJ1b6aJV0bit7RBn1KjjQ3fV5RKvNy0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774127216; c=relaxed/simple; bh=PbDyHHg+NjQxGlO/CtdZmeUhNeGr3LmODkDDK/afMZU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=kPi0ZXem8h4lFD5f4TIvG99+0s76ofi+zGl/ofSM9Wg4wgjxIzODJxC19czs/g+DrcAE6Q/+NUh9eG7GtODqx9+ZPv+n/37/BGUMabD+U/vDulifvZoIi8m6fGfr1WIeEcWf1atz5rwsTjrma/CcNw4sDNI8j0/i3mlrwBaRP+Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=OE4hOH6X; arc=none smtp.client-ip=95.215.58.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="OE4hOH6X" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1774127203; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=xX545N/wPXYLjYwvH9ZvJG1Qb9H1COfqtEUVC4IauDM=; b=OE4hOH6XE2W0MjVivXs7Dti8Hs9MDOvm+PA1E68sBk8l0eZnm8n8nId0Wuihb/fAyaDIsB D9d3v119F/4X7dAhsOc8Tthn3w4ANAKwNYeYll8enVDClSoJWW+HyBX8opnL2kM6/h3o9K Jub9bt1TQzoc8ETtR5PyqMOv4eOS3yM= From: Thorsten Blum To: Jan Kara , Amir Goldstein , Matthew Bobrowski Cc: Thorsten Blum , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] fanotify: replace deprecated strcpy in fanotify_info_copy_{name,name2} Date: Sat, 21 Mar 2026 22:05:47 +0100 Message-ID: <20260321210544.519259-4-thorsten.blum@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1428; i=thorsten.blum@linux.dev; h=from:subject; bh=QCdh4GSg6Hu34nAaRCGxcKSwZBxZhtHGrZw7LDbhfFM=; b=owGbwMvMwCUWt7pQ4caZUj3G02pJDJn7OTR+cpZk2+sctVoobtvBtENFtrKcabeU1I1fuf9qw rrmfFnTUcrCIMbFICumyPJg1o8ZvqU1lZtMInbCzGFlAhnCwMUpABOZcZaR4Xll10n7y+cL9Nv2 G/XdW6b3db7p+x1dPi6X9uxWX/1s5SqGP7xL560K4wiwD3vg3hpQ25LfwDr3XPjaFS92rxQ8xLT wCSMA X-Developer-Key: i=thorsten.blum@linux.dev; a=openpgp; fpr=1D60735E8AEF3BE473B69D84733678FD8DFEEAD4 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" 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 --- fs/notify/fanotify/fanotify.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/notify/fanotify/fanotify.h b/fs/notify/fanotify/fanotify.h index 39e60218df7c..a0619e7694d5 100644 --- a/fs/notify/fanotify/fanotify.h +++ b/fs/notify/fanotify/fanotify.h @@ -2,6 +2,7 @@ #include #include #include +#include #include #include =20 @@ -218,7 +219,7 @@ static inline void fanotify_info_copy_name(struct fanot= ify_info *info, return; =20 info->name_len =3D name->len; - strcpy(fanotify_info_name(info), name->name); + strscpy(fanotify_info_name(info), name->name, name->len + 1); } =20 static inline void fanotify_info_copy_name2(struct fanotify_info *info, @@ -228,7 +229,7 @@ static inline void fanotify_info_copy_name2(struct fano= tify_info *info, return; =20 info->name2_len =3D name->len; - strcpy(fanotify_info_name2(info), name->name); + strscpy(fanotify_info_name2(info), name->name, name->len + 1); } =20 /*