From: Danny Milosavljevic <dannym@scratchpost.org>
To: Marius Bakke <marius@gnu.org>
Cc: 43591@debbugs.gnu.org
Subject: [bug#43591] [PATCH core-updates] gnu: glibc-final: Catch all cases of a glibc user not requesting 64-bit offsets and then using readdir.
Date: Fri, 25 Sep 2020 15:36:46 +0200 [thread overview]
Message-ID: <20200925153646.6ef95908@scratchpost.org> (raw)
In-Reply-To: <20200925122004.38275411@scratchpost.org>
[-- Attachment #1: Type: text/plain, Size: 3070 bytes --]
> >Why is this not an issue with i686 on x86_64 kernels?
>
> I'm not sure. I'll check.
$ cat a00.c
#include <stdio.h>
#if defined( __ILP32__ )
#warning ILP32
#endif
int main() {
return sizeof(off_t);
}
$ LC_ALL=C guix environment -s i686-linux gcc-toolchain -- gcc -o a00 a00.c
a00.c:3:2: warning: #warning ILP32 [-Wcpp]
3 | #warning ILP32
| ^~~~~~~
$ ./a00
$ echo $?
4
That means they are using the Linux kernel's X86_32 ABI.
It has its own getdents64 system call that returns another value for d_off.
$ LC_ALL=C guix environment -s i686-linux gcc-toolchain -- gcc -o a00 -D_FILE_OFFSET_BITS=64 a00.c
a00.c:3:2: warning: #warning ILP32 [-Wcpp]
3 | #warning ILP32
| ^~~~~~~
$ ./a00
$ echo $?
8
That is why __i686__ is not affected--at the cost of the kernel lying to us
about the file system.
Note that I also tried printing the actual d_off values[1]--on ILP32, even with
_FILE_OFFSET_BITS=64, the VALUES are still 32 bits, and the same values as
without _FILE_OFFSET_BITS. The d_off SLOT gets bigger on _FILE_OFFSET_BITS=64.
(I also tried printing the actual d_off values[1] on x86_64 without any guix
environment -s, I get entirely different d_off values!!)
I also tried the former on native ARMHF--you get 32 bits d_off values. And d_off
is always the same size as off_t.
off_t size changes depending on _FILE_OFFSET_BITS.
I do not have access to a real aarch64 machine--so no idea how it is there.
That would be the most interesting case, because those don't have X86_32,
so ILP32 is either not present or implemented differently.
ppc64 would also be interesting...
Test result of [1]:
system _FILE_OFFSET_BITS off_t d_off-sizeof d_off-values
-------------------------------------------------------------
x86_64 - 8 Byte 8 Byte 8 Byte
i686 - 4 Byte 4 Byte 4 Byte
i686 64 8 Byte 8 Byte 4 Byte
i686 32 4 Byte 4 Byte 4 Byte
i686 7 4 Byte 4 Byte 4 Byte
armhf - 4 Byte 4 Byte 4 Byte
armhf 64 8 Byte 8 Byte 4 Byte
armhf 32 4 Byte 4 Byte 4 Byte
armhf 7 4 Byte 4 Byte 4 Byte
This is all without qemu--in order to simplify the test case.
So I take it ext4 has some special compilation mode for 32 bits...
Could someone please test [1] on (real!) aarch64 and ppc64 and ppc32
machines?
[1] $ cat a00.c
#include <stdio.h>
#include <errno.h>
#include <assert.h>
#include <dirent.h>
#if defined( __ILP32__ )
#warning ILP32
#endif
int main() {
DIR* d;
struct dirent* ent;
d = opendir("/tmp");
errno = 0;
assert(sizeof(ent->d_off) == sizeof(off_t));
while ((ent = readdir(d)) != NULL) {
printf("%llu\n", (unsigned long long) ent->d_off);
}
if (errno)
perror("readdir");
return sizeof(off_t);
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2020-09-25 13:38 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-24 14:12 [bug#43591] [PATCH core-updates] gnu: glibc-final: Catch all cases of a glibc user not requesting 64-bit offsets and then using readdir Danny Milosavljevic
2020-09-24 14:16 ` Danny Milosavljevic
2020-09-24 18:17 ` Marius Bakke
2020-09-24 20:27 ` Danny Milosavljevic
2020-09-24 23:11 ` Marius Bakke
2020-09-25 10:20 ` Danny Milosavljevic
2020-09-25 10:42 ` [bug#43591] [PATCH v2 core-updates] gnu: glibc-final: Catch all cases of a glibc user not requesting 64-bit offsets and then using readdir regardless Danny Milosavljevic
2020-09-25 13:36 ` Danny Milosavljevic [this message]
2020-09-25 15:33 ` [bug#43591] [PATCH core-updates] gnu: glibc-final: Catch all cases of a glibc user not requesting 64-bit offsets and then using readdir Danny Milosavljevic
2020-09-26 1:42 ` Danny Milosavljevic
2020-09-26 1:49 ` Danny Milosavljevic
2020-09-29 14:51 ` Danny Milosavljevic
2020-09-27 6:43 ` Efraim Flashner
2020-09-25 20:03 ` Andreas Enge
2020-09-26 10:50 ` Danny Milosavljevic
2020-09-29 20:52 ` Ludovic Courtès
2020-09-29 22:09 ` Danny Milosavljevic
2020-09-30 9:32 ` Ludovic Courtès
2020-09-30 10:28 ` Danny Milosavljevic
2020-10-01 7:14 ` Ludovic Courtès
2020-10-02 7:18 ` Danny Milosavljevic
2020-10-02 8:12 ` Danny Milosavljevic
2020-10-02 9:47 ` Danny Milosavljevic
2020-10-02 9:32 ` Danny Milosavljevic
2020-10-06 15:39 ` Danny Milosavljevic
2020-09-25 10:24 ` Danny Milosavljevic
2020-09-30 8:45 ` [bug#43591] [PATCH core-updates v2 0/5] " Danny Milosavljevic
2020-09-30 8:45 ` [bug#43591] [PATCH core-updates v2 1/5] gnu: glibc-final: Catch all cases of a glibc user not requesting 64-bit offsets and then using readdir regardless Danny Milosavljevic
2020-09-30 16:55 ` Danny Milosavljevic
2020-09-30 8:45 ` [bug#43591] [PATCH core-updates v2 2/5] build-system/gnu: Explicity declare the _FILE_OFFSET_BITS we want Danny Milosavljevic
2020-09-30 8:45 ` [bug#43591] [PATCH core-updates v2 3/5] gnu: glibc: Do not explicitly set _FILE_OFFSET_BITS Danny Milosavljevic
2020-09-30 8:45 ` [bug#43591] [PATCH core-updates v2 4/5] gnu: glibc-mesboot0: " Danny Milosavljevic
2020-09-30 8:45 ` [bug#43591] [PATCH core-updates v2 5/5] gnu: rhash: Explicity declare the _FILE_OFFSET_BITS we want Danny Milosavljevic
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
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200925153646.6ef95908@scratchpost.org \
--to=dannym@scratchpost.org \
--cc=43591@debbugs.gnu.org \
--cc=marius@gnu.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.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).