lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZhVDgbRoF9X7JSdt@infradead.org>
Date: Tue, 9 Apr 2024 06:32:49 -0700
From: Christoph Hellwig <hch@...radead.org>
To: Justin Stitt <justinstitt@...gle.com>
Cc: Chandan Babu R <chandan.babu@...cle.com>,
	"Darrick J. Wong" <djwong@...nel.org>, linux-xfs@...r.kernel.org,
	linux-kernel@...r.kernel.org, linux-hardening@...r.kernel.org
Subject: Re: [PATCH] xfs: xattr: replace strncpy and check for truncation

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?


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ