From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (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 682F934A791 for ; Tue, 16 Dec 2025 08:06:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765872385; cv=none; b=gT7pQoPDYomqOjECg0OB8AYmO6ah44ugBvOeP8Qv2RWZcGPZd9ZkXTMiHlVjnpAy6pqKAf2cj3JiXeyduGKvP7KaN9S8reZ0UM8AjrajVLpW0Y/WA306vCiiYON+M17s1PuKiVPeSg8ufcKCnqVhafDVTip3u8yD/KneJs0oAc8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765872385; c=relaxed/simple; bh=/hrjUDBbbuI6vOCBtbC+KchTw3oKYN4ZNb1kUjcOJb0=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=maFPmInIalH0P6vn3nQW6xCQZZ5iHk6eqIOMwR54cim0Y0spnrtabYbt7EAxCEng0i4yXE7FsBJjIMlLwjqkPSy4yFgythr/KGXYfWFdVmucfNwzNXr7cLeR+eL0+8+GQKpMPUTGLQdTODH1SMN1n3GFeY/p1rdbiCqKdi+OHAU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=HrcE/nms; arc=none smtp.client-ip=185.246.85.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="HrcE/nms" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id A39704E41B69; Tue, 16 Dec 2025 08:06:20 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 71CAA6071C; Tue, 16 Dec 2025 08:06:20 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id E92E511942F8B; Tue, 16 Dec 2025 09:06:16 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1765872379; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=mnPu3NaHdaqZPL8dQQmj9+t+nxocDNQkhh5BcD8Z/gI=; b=HrcE/nmsHuBxRg2BtHY9NPWXttK4ycNK2CvFdTGa2R3FroXElfzg5ZvWPL/4BiQekvC5zd bGT3OZI2CcuwwoexfBDYLj+nxU/QLg3zWYLKTFBqYyfH85uFF158xWpWMlxH9BQgnwT0ET aTZcvpeiV/BZlvvBpNsjwFNqbiE3xGCT6mlTNv7R0mmdWX+9zB7S80Q2cxDbVmYN6oOMSe ZeaISxFdLt4fuawXDCyfFiTuS0IyaqwhTTB2tRd3b0rZ78FJDMH2Qd0onE4wir9NlPlBvG 8LUZSbExXljzhDu3w69RenFt8KtvHJlATSxCEzTLHiYA0O1FkQ6DNI+triLHhg== From: Miquel Raynal To: Dharanitharan R Cc: Richard Weinberger , Vignesh Raghavendra , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v1] mtd: sm_ftl: use strscpy() in sm_attr_show() In-Reply-To: <20251206035313.10190-1-dharanitharan725@gmail.com> (Dharanitharan R.'s message of "Sat, 6 Dec 2025 03:53:13 +0000") References: <20251206035313.10190-1-dharanitharan725@gmail.com> User-Agent: mu4e 1.12.7; emacs 30.2 Date: Tue, 16 Dec 2025 09:06:16 +0100 Message-ID: <87ike6svev.fsf@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Hello, On 06/12/2025 at 03:53:13 GMT, Dharanitharan R = wrote: > In sm_ftl.c, the sm_attr_show() function currently copies > attribute data using: > > strncpy(buf, sm_attr->data, sm_attr->len); > return sm_attr->len; > > Using strncpy() can be unsafe because it does not guarantee > a NUL terminator if the source length equals the buffer size. > Although sm_attr->data comes from internal structures and > is NUL-terminated, it is cleaner and safer to use strscpy(), > which guarantees NUL termination and avoids zero-padding. > > The destination buffer is PAGE_SIZE bytes, which is sufficient > to hold sm_attr->data without truncation. The return value > of strscpy() matches the expected behavior of sm_attr_show(). > > Replace the strncpy() call with: > > return strscpy(buf, sm_attr->data, PAGE_SIZE); > > Signed-off-by: Dharanitharan R This commit won't apply, please resend based on v6.19-rc1. Thanks, Miqu=C3=A8l