Skip to content

update-tables: do not silently generate bogus tables - #153

Merged
hrw merged 3 commits into
hrw:masterfrom
kolyshkin:update-tables-errors
Oct 7, 2026
Merged

hrw merged 3 commits into
hrw:masterfrom
kolyshkin:update-tables-errors

Conversation

@kolyshkin

Copy link
Copy Markdown
Contributor

update-tables.sh silently generates wrong tables in a few cases, which I found while using it to build per-kernel-version tables for libseccomp (seccomp/libseccomp#502):

  1. make headers_install failure is ignored. Its exit status is discarded, so list-syscalls is compiled against the headers installed for the previous architecture, or against the host's system headers. This is common when processing old kernels with a modern toolchain, which can no longer build their host tools. For example, with GCC 16 the v3.0 tables are generated from the host's v7.x headers, so clone3 is listed for x86_64 and i386. It also happens regardless of the toolchain for cris in Linux v3.x, whose headers_install is broken.
    With this PR, such an architecture is skipped and its old table is kept, as is already done when list-syscalls fails to compile.

  2. x32 before Linux 3.4. For older kernels asm/unistd.h does not handle __ILP32__, so the generated x32 table is a copy of the x86_64 one.
    With this PR, the x32 table is only generated if asm/unistd_x32.h exists.

  3. The exit status is always 0. Callers can't tell the tables are incomplete.
    With this PR, all the architectures are still processed, but the script exits with 1 at the end if any table could not be generated. The CI workflow installs libc6-dev-x32, so it is not affected.

Tested with:

  • the host toolchain (Fedora, GCC 16): v3.0 fails to install the headers for all 23 architectures and leaves all the tables intact (previously they were generated from the host headers); v7.2 reports the x32 compile failure (no x32 glibc headers) and exits with 1;
  • an Ubuntu 20.04 container (GCC 9.4, libc6-dev-x32): v3.3 skips x32; v3.4 generates a proper x32 table (read is 1073741824); v3.3 and v3.4 report the cris headers failure; v7.2 exits with 0.

If list-syscalls fails to compile for an architecture (e.g. for x32
when the x32 glibc headers are not installed), the old table for that
architecture is kept, and a message is printed, but the script still
exits with 0, so the callers can not tell the tables are incomplete.

Keep processing the remaining architectures, but exit with 1 at the
end if any table failed to be generated.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
The output of "make headers_install" is discarded, and so is its exit
status. If it fails, list-syscalls is compiled against the headers
installed for the previous architecture, or the host's system headers,
silently generating a bogus table.

This is common when processing old kernels with a modern toolchain,
as these can not build their host tools any more; e.g. with GCC 16,
the tables for Linux v3.0 are generated from the host's (v7.x) kernel
headers, e.g. listing clone3 for x86_64 and i386.

Skip the architecture if its headers can not be installed, keeping its
old table as when list-syscalls fails to compile.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
The x32 ABI was added in Linux 3.4. For older kernels, asm/unistd.h
does not handle __ILP32__, and provides the x86_64 system calls, so
the generated x32 table is the same as the x86_64 one.

Only generate the x32 table if the kernel provides asm/unistd_x32.h.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
@hrw
hrw merged commit b019db6 into hrw:master Oct 7, 2026
3 checks passed
@hrw

hrw commented Oct 7, 2026

Copy link
Copy Markdown
Owner

Thanks @kolyshkin for fixes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants