From: Christoph Hellwig <hch@infradead.org>
To: Justin Stitt <justinstitt@google.com>
Cc: Chandan Babu R <chandan.babu@oracle.com>,
"Darrick J. Wong" <djwong@kernel.org>,
linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-hardening@vger.kernel.org
Subject: Re: [PATCH] xfs: xattr: replace strncpy and check for truncation
Date: Tue, 9 Apr 2024 06:32:49 -0700 [thread overview]
Message-ID: <ZhVDgbRoF9X7JSdt@infradead.org> (raw)
In-Reply-To: <20240405-strncpy-xattr-split2-v1-1-90ab18232407@google.com>
On Fri, Apr 05, 2024 at 07:45:08PM +0000, Justin Stitt wrote:
> - memcpy(offset, prefix, prefix_len);
> - offset += prefix_len;
> - strncpy(offset, (char *)name, namelen); /* real name */
> - offset += namelen;
> - *offset = '\0';
> +
> + combined_len = prefix_len + namelen;
> +
> + /* plus one byte for \0 */
> + actual_len = scnprintf(offset, combined_len + 1, "%s%s", prefix, name);
> +
> + if (actual_len < combined_len)
Shouldn't this be a != ?
That being said I think this is actually wrong - the attr names are
not NULL-terminated on disk, which is why we have the explicit
zero terminataion above.
How was this tested?
next prev parent reply other threads:[~2024-04-09 13:32 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-05 19:45 [PATCH] xfs: xattr: replace strncpy and check for truncation Justin Stitt
2024-04-09 13:32 ` Christoph Hellwig [this message]
2024-04-10 0:23 ` Justin Stitt
2024-04-10 0:27 ` Justin Stitt
2024-04-10 0:40 ` Darrick J. Wong
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=ZhVDgbRoF9X7JSdt@infradead.org \
--to=hch@infradead.org \
--cc=chandan.babu@oracle.com \
--cc=djwong@kernel.org \
--cc=justinstitt@google.com \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox