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: <ebf0c9fd-9c45-4aa2-8cd7-fe8d5956ce52@t-8ch.de>
Date: Fri, 6 Feb 2026 22:55:34 +0100
From: Thomas Weißschuh <linux@...ssschuh.net>
To: Jordan Richards <jordanrichards@...gle.com>
Cc: Willy Tarreau <w@....eu>, Pasha Tatashin <pasha.tatashin@...een.com>, 
	Mike Rapoport <rppt@...nel.org>, Pratyush Yadav <pratyush@...nel.org>, 
	Shuah Khan <shuah@...nel.org>, Jason Miu <jasonmiu@...gle.com>, 
	David Matlack <dmatlack@...gle.com>, linux-mm@...ck.org, linux-kernel@...r.kernel.org, 
	linux-kselftest@...r.kernel.org
Subject: Re: [PATCH v2 1/2] tools/nolibc: add ftruncate()

Hi Jordan,

(please Cc nolibc maintainers on nolibc changes, I only saw this by
chance)

On 2026-02-05 22:23:28+0000, Jordan Richards wrote:
> ---
>  tools/include/nolibc/unistd.h | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/tools/include/nolibc/unistd.h b/tools/include/nolibc/unistd.h
> index bb5e80f3f05d..845d10f48fd0 100644
> --- a/tools/include/nolibc/unistd.h
> +++ b/tools/include/nolibc/unistd.h
> @@ -48,6 +48,17 @@ int access(const char *path, int amode)
>  	return faccessat(AT_FDCWD, path, amode, 0);
>  }
>  
> +static __attribute__((unused))
> +int sys_ftruncate(int fd, off_t length)
> +{
> +	return my_syscall2(__NR_ftruncate, fd, length);
> +}

off_t is now always 64bit on nolibc. On 32-bit architectures however
__NR_ftruncate only takes a 32bit value, leading to the wrong kind of
truncation. Use __NR_ftruncate64 instead where available.

Please also add a simple test to
tools/testing/selftests/nolibc/nolibc-test.c

> +
> +static __attribute__((unused))
> +int ftruncate(int fd, off_t length)
> +{
> +	return __sysret(sys_ftruncate(fd, length));
> +}
>  
>  static __attribute__((unused))
>  int msleep(unsigned int msecs)
> -- 
> 2.53.0.rc2.204.g2597b5adb4-goog
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ