From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Dharanitharan R <dharanitharan725@gmail.com>
Cc: Richard Weinberger <richard@nod.at>,
Vignesh Raghavendra <vigneshr@ti.com>,
linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1] mtd: sm_ftl: use strscpy() in sm_attr_show()
Date: Tue, 16 Dec 2025 09:06:16 +0100 [thread overview]
Message-ID: <87ike6svev.fsf@bootlin.com> (raw)
In-Reply-To: <20251206035313.10190-1-dharanitharan725@gmail.com> (Dharanitharan R.'s message of "Sat, 6 Dec 2025 03:53:13 +0000")
Hello,
On 06/12/2025 at 03:53:13 GMT, Dharanitharan R <dharanitharan725@gmail.com> 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 <dharanitharan725@gmail.com>
This commit won't apply, please resend based on v6.19-rc1.
Thanks,
Miquèl
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
WARNING: multiple messages have this Message-ID (diff)
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Dharanitharan R <dharanitharan725@gmail.com>
Cc: Richard Weinberger <richard@nod.at>,
Vignesh Raghavendra <vigneshr@ti.com>,
linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1] mtd: sm_ftl: use strscpy() in sm_attr_show()
Date: Tue, 16 Dec 2025 09:06:16 +0100 [thread overview]
Message-ID: <87ike6svev.fsf@bootlin.com> (raw)
In-Reply-To: <20251206035313.10190-1-dharanitharan725@gmail.com> (Dharanitharan R.'s message of "Sat, 6 Dec 2025 03:53:13 +0000")
Hello,
On 06/12/2025 at 03:53:13 GMT, Dharanitharan R <dharanitharan725@gmail.com> 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 <dharanitharan725@gmail.com>
This commit won't apply, please resend based on v6.19-rc1.
Thanks,
Miquèl
next prev parent reply other threads:[~2025-12-16 8:06 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-06 3:53 [PATCH v1] mtd: sm_ftl: use strscpy() in sm_attr_show() Dharanitharan R
2025-12-06 3:53 ` Dharanitharan R
2025-12-16 8:06 ` Miquel Raynal [this message]
2025-12-16 8:06 ` Miquel Raynal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ike6svev.fsf@bootlin.com \
--to=miquel.raynal@bootlin.com \
--cc=dharanitharan725@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=richard@nod.at \
--cc=vigneshr@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.