Bug 2301919 - __NR_newfstatat no longer defined on aarch64
Summary: __NR_newfstatat no longer defined on aarch64
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: kernel
Version: rawhide
Hardware: Unspecified
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Kernel Maintainer List
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
: 2302461 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2024-07-31 08:20 UTC by Nikita Popov
Modified: 2024-08-14 14:02 UTC (History)
21 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2024-08-14 14:02:26 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github llvm llvm-project issues 100098 0 None open [sanitizer] __NR_newfstatat not defined in linux kernel headers in aarch64 2024-08-01 10:54:55 UTC

Description Nikita Popov 2024-07-31 08:20:04 UTC
1. Please describe the problem:

We've started seeing "error: use of undeclared identifier '__NR_newfstatat'" when building sanitizers on aarch64. The /usr/include/asm/unistd_64.h file indeed no longer defines this syscall, but I believe it should, as it was previously available.

I suspect this was introduced when arm64 was recently migrated to use a generated syscall table: https://github.com/torvalds/linux/commit/e632bca07c8eef1de9dc50f4e4066c56e9d68b07

See https://download.copr.fedorainfracloud.org/results/@fedora-llvm-team/llvm-snapshots-big-merge-20240731/fedora-rawhide-aarch64/07807104-llvm/builder-live.log.gz for the full build log.

2. What is the Version-Release number of the kernel:

6.11.0-0.rc1.dc1c8034e31b.16.fc41

3. Did it work previously in Fedora? If so, what kernel version did the issue
   *first* appear?  Old kernels are available for download at
   https://koji.fedoraproject.org/koji/packageinfo?packageID=8 :

6.10.0-64.fc41

4. Can you reproduce this issue? If so, please provide the steps to reproduce
   the issue below:

Compile this file:

#include <asm/unistd.h>
int main() {
        return __NR_newfstatat;
}

Reproducible: Always

Comment 1 Nikita Popov 2024-07-31 08:48:24 UTC
> 6.10.0-64.fc41

Sorry, I misread the question. This was the last working version, rather than the first broken one. (6.11.0-0.rc1.dc1c8034e31b.16.fc41 is both the current version of kernel-headers, and the first with the issue.)

Comment 2 Florian Weimer 2024-08-01 11:30:23 UTC
Raised on the kernel lists:

syscall.tbl refactoring seems to have dropped definition of __NR_newfstatat on arm64 and riscv (64-bit) at least
<https://lore.kernel.org/all/87sevoqy7v.fsf@oldenburg.str.redhat.com/>

Comment 3 Jakub Jelinek 2024-08-02 07:34:24 UTC
*** Bug 2302461 has been marked as a duplicate of this bug. ***

Comment 4 Marcin Juszkiewicz 2024-08-05 19:17:58 UTC
Problem should be fixed with Linux 6.11-rc2 version.

Comment 5 Jakub Jelinek 2024-08-05 19:24:06 UTC
Are you sure?
Given https://lkml.org/lkml/2024/8/3/112 and that I don't see newer commits from Arnd than 3 days old ones.

Comment 6 Marcin Juszkiewicz 2024-08-05 19:36:26 UTC
Arnd wrote to me on Mastodon few days ago:

> Linus just merged a fixup that unbreaks the newfstatat/newfstat syscalls on a couple of architectures and the uretprobe syscall number, so you should probably regenerate your table from that.

https://society.oftrolls.com/@arnd/112893914563741569

And I did that. My table shows newfstatat as 79 on arm64.

https://gpages.juszkiewicz.com.pl/syscalls-table/syscalls.html

Comment 8 Jakub Jelinek 2024-08-05 19:49:06 UTC
I've just tried:
(where /tmp/kh/old/ has kernel-headers-6.10.3-200.fc40 rpm2cpio | cpio -id unpacked for all Fedora arches and
/tmp/kh/new/ has kernel-headers-6.11.0-0.rc2.23.fc41.
If __NR_uretprobe addition on x86_64 is intentional,
I doubt that the removal of
#define __NR_nfsservctl 42
and replacement of
#define __NR_fstat 80
with
#define __NR_newfstat 80
and removal of
#define __NR_arch_specific_syscall 244
and perhaps removal of
#define __NR_syscalls 463
and maybe removal of all the __NR3264_* defines are intentional and __NR_fstat is certainly going to break building of gcc too.

echo '#include <asm/unistd.h>' | gcc -isystem /tmp/kh/old/x86_64/usr/include -xc - -E -dD | grep '#define __NR_' | sort > /tmp/1; echo '#include <asm/unistd.h>' | gcc -isystem /tmp/kh/new/x86_64/usr/include -xc - -E -dD | grep '#define __NR_' | sort > /tmp/2; echo ===x86_64===; diff -up /tmp/1 /tmp/2; echo '#include <asm/unistd.h>' | gcc -isystem /tmp/kh/old/i686/usr/include -m32 -xc - -E -dD | grep '#define __NR_' | sort > /tmp/1; echo '#include <asm/unistd.h>' | gcc -isystem /tmp/kh/new/i686/usr/include -m32 -xc - -E -dD | grep '#define __NR_' | sort > /tmp/2; echo ===i686===; diff -up /tmp/1 /tmp/2; for i in aarch64 powerpc64le s390x; do echo '#include <asm/unistd.h>' | $i-linux-gnu-gcc -isystem /tmp/kh/old/$i/usr/include -xc - -E -dD | grep '#define __NR_' | sort > /tmp/1; echo '#include <asm/unistd.h>' | $i-linux-gnu-gcc -isystem /tmp/kh/new/$i/usr/include -xc - -E -dD | grep '#define __NR_' | sort > /tmp/2; echo ===$i===; diff -up /tmp/1 /tmp/2; done
===x86_64===
--- /tmp/1	2024-08-05 21:37:21.784080015 +0200
+++ /tmp/2	2024-08-05 21:37:21.797079848 +0200
@@ -358,6 +358,7 @@
 #define __NR_unlink 87
 #define __NR_unlinkat 263
 #define __NR_unshare 272
+#define __NR_uretprobe 335
 #define __NR_uselib 134
 #define __NR_userfaultfd 323
 #define __NR_ustat 136
===i686===
===aarch64===
--- /tmp/1	2024-08-05 21:37:21.844079248 +0200
+++ /tmp/2	2024-08-05 21:37:21.860079043 +0200
@@ -3,7 +3,6 @@
 #define __NR_acct 89
 #define __NR_add_key 217
 #define __NR_adjtimex 171
-#define __NR_arch_specific_syscall 244
 #define __NR_bind 200
 #define __NR_bpf 280
 #define __NR_brk 214
@@ -37,7 +36,7 @@
 #define __NR_exit_group 94
 #define __NR_faccessat2 439
 #define __NR_faccessat 48
-#define __NR_fadvise64 __NR3264_fadvise64
+#define __NR_fadvise64 223
 #define __NR_fallocate 47
 #define __NR_fanotify_init 262
 #define __NR_fanotify_mark 263
@@ -47,7 +46,7 @@
 #define __NR_fchmodat 53
 #define __NR_fchown 55
 #define __NR_fchownat 54
-#define __NR_fcntl __NR3264_fcntl
+#define __NR_fcntl 25
 #define __NR_fdatasync 83
 #define __NR_fgetxattr 10
 #define __NR_finit_module 273
@@ -59,10 +58,9 @@
 #define __NR_fsmount 432
 #define __NR_fsopen 430
 #define __NR_fspick 433
-#define __NR_fstatfs __NR3264_fstatfs
-#define __NR_fstat __NR3264_fstat
+#define __NR_fstatfs 44
 #define __NR_fsync 82
-#define __NR_ftruncate __NR3264_ftruncate
+#define __NR_ftruncate 46
 #define __NR_futex 98
 #define __NR_futex_requeue 456
 #define __NR_futex_wait 455
@@ -127,7 +125,7 @@
 #define __NR_llistxattr 12
 #define __NR_lookup_dcookie 18
 #define __NR_lremovexattr 15
-#define __NR_lseek __NR3264_lseek
+#define __NR_lseek 62
 #define __NR_lsetxattr 6
 #define __NR_lsm_get_self_attr 459
 #define __NR_lsm_list_modules 461
@@ -145,7 +143,7 @@
 #define __NR_mlock 228
 #define __NR_mlock2 284
 #define __NR_mlockall 230
-#define __NR_mmap __NR3264_mmap
+#define __NR_mmap 222
 #define __NR_mount 40
 #define __NR_mount_setattr 442
 #define __NR_move_mount 429
@@ -169,8 +167,8 @@
 #define __NR_munmap 215
 #define __NR_name_to_handle_at 264
 #define __NR_nanosleep 101
-#define __NR_newfstatat __NR3264_fstatat
-#define __NR_nfsservctl 42
+#define __NR_newfstat 80
+#define __NR_newfstatat 79
 #define __NR_openat2 437
 #define __NR_openat 56
 #define __NR_open_by_handle_at 265
@@ -242,7 +240,7 @@
 #define __NR_semget 190
 #define __NR_semop 193
 #define __NR_semtimedop 192
-#define __NR_sendfile __NR3264_sendfile
+#define __NR_sendfile 71
 #define __NR_sendmmsg 269
 #define __NR_sendmsg 211
 #define __NR_sendto 206
@@ -280,7 +278,7 @@
 #define __NR_socket 198
 #define __NR_socketpair 199
 #define __NR_splice 76
-#define __NR_statfs __NR3264_statfs
+#define __NR_statfs 43
 #define __NR_statmount 457
 #define __NR_statx 291
 #define __NR_swapoff 225
@@ -289,7 +287,6 @@
 #define __NR_sync 81
 #define __NR_sync_file_range 84
 #define __NR_syncfs 267
-#define __NR_syscalls 463
 #define __NR_sysinfo 179
 #define __NR_syslog 116
 #define __NR_tee 77
@@ -304,7 +301,7 @@
 #define __NR_timer_settime 110
 #define __NR_times 153
 #define __NR_tkill 130
-#define __NR_truncate __NR3264_truncate
+#define __NR_truncate 45
 #define __NR_umask 166
 #define __NR_umount2 39
 #define __NR_uname 160
===powerpc64le===
===s390x===

Comment 9 Jakub Jelinek 2024-08-05 19:55:06 UTC
(In reply to Marcin Juszkiewicz from comment #7)
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/
> ?id=343416f0c11c42bed07f6db03ca599f4f1771b17 is a commit you are looking for.

It is not, that is just a partial fix, which fixes __NR_newfstatat, but keeps the rest broken.

Comment 10 Yaakov Selkowitz 2024-08-05 19:59:46 UTC
Packages are still FTBFS with rc2, e.g.:
compiler-rt: https://koji.fedoraproject.org/koji/taskinfo?taskID=121542883
strace: https://koji.fedoraproject.org/koji/taskinfo?taskID=121542885

Comment 11 Nikita Popov 2024-08-14 14:02:26 UTC
Confirmed fixed by https://bodhi.fedoraproject.org/updates/FEDORA-2024-ad7e44809a.


Note You need to log in before you can comment on or make changes to this bug.