[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <7ce6cd20-e20a-4bfa-b893-995ce6585d03@t-8ch.de>
Date: Sat, 19 Apr 2025 12:11:35 +0200
From: Thomas Weißschuh <linux@...ssschuh.net>
To: Willy Tarreau <w@....eu>
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 2025-04-19 11:11:40+0200, Willy Tarreau wrote:
> 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.
Sounds good, the attribute soup is annoying.
> In any case: Acked-by: Willy Tarreau <w@....eu>
Thanks!
Thomas
Powered by blists - more mailing lists