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: <20250419091140.GC31874@1wt.eu>
Date: Sat, 19 Apr 2025 11:11:40 +0200
From: Willy Tarreau <w@....eu>
To: Thomas Weißschuh <linux@...ssschuh.net>
Cc: "Paul E. McKenney" <paulmck@...nel.org>, Shuah Khan <shuah@...nel.org>,
        linux-kernel@...r.kernel.org, linux-kselftest@...r.kernel.org
Subject: Re: [PATCH 3/6] tools/nolibc: properly align dirent buffer

On Wed, Apr 16, 2025 at 08:40:18PM +0200, Thomas Weißschuh wrote:
> As byte buffer is overlaid with a 'struct dirent64'.
> it has to satisfy the structs alignment requirements.
> 
> Fixes: 665fa8dea90d ("tools/nolibc: add support for directory access")
> Signed-off-by: Thomas Weißschuh <linux@...ssschuh.net>

Oh good catch! I already faced crashes in other programs due to AVX
memcpy when doing similar casts without thinking about alignment.

> @@ -58,6 +58,7 @@ int closedir(DIR *dirp)
>  static __attribute__((unused))
>  int readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result)
>  {
> +	__attribute__((aligned(__alignof__(struct linux_dirent64))))
>  	char buf[sizeof(struct linux_dirent64) + NAME_MAX + 1];

I tend to find it more readable when the attribute is on the same line as
the type on variables declaration, often at the end of the line, to keep
declarations alignes, even if that makes longer lines. If alignment concerns
come back often, we could maybe have __nolibc_align(<align>) and maybe even
__nolibc_align_as(<type>) to slightly shorten the lines. Just an idea.

In any case: Acked-by: Willy Tarreau <w@....eu>

Willy

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ