Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

configure.ac: enable 64-bit file API on 32-bit systems #941

Merged
merged 1 commit into from
Nov 4, 2024

Conversation

trofi
Copy link
Contributor

@trofi trofi commented Oct 31, 2024

My local filesystem is btrfs with a long life. It's inodes ecxeed 32-bit
space and that causes test failures in swtpm on i686-linux
containers:

FAIL: test_parameters
FAIL: test_swtpm_setup_file_backend
FAIL: test_swtpm_setup_overwrite
FAIL: test_tpm2_swtpm_setup_create_cert
FAIL: test_tpm2_swtpm_setup_overwrite
FAIL: test_swtpm_setup_create_cert
FAIL: test_tpm2_parameters

The example test failure log looks this way:

FAIL: test_migration_key
========================

Need to be root to run test with CUSE interface.
Need to be root to run test with CUSE interface.
==== Starting swtpm with interfaces socket+socket ====
Test 1: Ok
==== Starting swtpm with interfaces socket+socket ====
Test 2: Ok
==== Starting swtpm with interfaces socket+socket ====
swtpm: Missing migration key to decrypt volatilestate
Test 3: Ok
==== Starting swtpm with interfaces socket+socket ====
Could not stat file '/build/tests/data/migkey1/volatilestate.bin': Value too large for defined data type
Error: Could not load encrypted volatile state into TPM.
FAIL test_migration_key (exit status: 1)

The stat() fails because inode value exceeds 32-bit value:

$ stat /build/tests/data/migkey1/volatilestate.bin
  File: /build/tests/data/migkey1/volatilestate.bin
  Size: 1290            Blocks: 8          IO Block: 4096   regular file
Device: 0,30    Inode: 9639547569  Links: 1
...

The change fixes all the test failures. To fix
test_tpm2_swtpm_setup_create_cert I also had to include config.h
into swtpm_backend_dir.c to get 64-bit file open there as well.

Signed-off-by: Sergei Trofimovich slyich@gmail.com

configure.ac Outdated
@@ -48,6 +48,9 @@ AC_CANONICAL_HOST
AM_INIT_AUTOMAKE([foreign 1.6])
AM_SILENT_RULES([yes])

# allow 64-bit file API on 32-bit systems.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commit message: s/ilfe/life

Otherwise sounds and looks good.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated. Thank you!

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also explain a bit what the errors are related to and where they occur? We don't have any large files with swtpm, so this is not quite so obvious. Can you provide this detail, please?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated as:

--- a/configure.ac
+++ b/configure.ac
@@ -51 +51,2 @@ AM_SILENT_RULES([yes])
-# allow 64-bit file API on 32-bit systems.
+# Allow 64-bit file API on 32-bit systems. Without the change even small
+# files will fail to open any files on filesystems with 64-bit inodes.

Or should I expand the commit message itself with breakage specifics?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I think this is good.
Though I am trying to understand what is causing the issue. Do all applications have to use the 64bit file API on your type of system? What matters for swtpm are filenames, flags, and file descriptors. The 64bit inodes presumably are entirely handled in the kernel. So I fail to see the connection.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's the specific bit it fixes:
https://github.com/autotools-mirror/autoconf/blob/f8c82d292699fbce6d60abb46259a3781578f7fc/lib/autoconf/specific.m4#L343

I didn't check but swtpm probably issue a stat(2) and gets an error because the inode overflows.

I would guess this is a broader issue on @trofi's system and that every app needs this fix.
I don't think the macro hurts much as autotool will probe to check if the system supports it.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Owner

@stefanberger stefanberger Nov 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't check but swtpm probably issue a stat(2) and gets an error because the inode overflows.

swtpm use fstat and stat and I would expect that several more test should fail if these were to run into issues. Particularly those tests that use existing state and start swtpm with it and swtpm will do a fstat on it to determine file size.

Or should I expand the commit message itself with breakage specifics?

@trofi Actually if you could check the log of the failing tests and if there's something of interest in there, and there hopefully is, then copy and paste it into the commit message.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated PR description to contain example failure.

I would guess this is a broader issue on @trofi's system and that every app needs this fix.

Yes, newly created files on my system have inode values higher than 2^32. It's a good way to expose failures like this one.

but glibc has had a fix for that for a fairly long time

At a hazard of stating the obvious: the glibc fix is not automatic as it's a visible ABI change. Effectively every single 32-bit application has to be built with -D_FILE_OFFSET_BITS=64 to be able to work on the filesystems that can expose 64-bit values to userspace. Unfortunately it changes linkage symbols from stat() to stat64() and breaks some programs that don't expect the symbol change and is thus not enabled by default in glibc. Fun fact: meson does enable 64-bit file API by default: https://github.com/mesonbuild/meson/blob/4ac3e7d356cfc1a6a290cd6961f01c11510c0618/mesonbuild/compilers/compilers.py#L1121

@trofi trofi force-pushed the 64-bit-file-api branch 2 times, most recently from 1576151 to 6bcf70e Compare November 1, 2024 06:13
@trofi trofi requested a review from stefanberger November 1, 2024 06:14
@trofi trofi force-pushed the 64-bit-file-api branch 2 times, most recently from 8e23a5a to fc56ffd Compare November 1, 2024 22:02
My local filesystem is btrfs with a long life. It's inodes ecxeed 32-bit
space and that causes test failures in `swtpm` on `i686-linux`
containers:

    FAIL: test_parameters
    FAIL: test_swtpm_setup_file_backend
    FAIL: test_swtpm_setup_overwrite
    FAIL: test_tpm2_swtpm_setup_create_cert
    FAIL: test_tpm2_swtpm_setup_overwrite
    FAIL: test_swtpm_setup_create_cert
    FAIL: test_tpm2_parameters

The example test failure log looks this way:

    FAIL: test_migration_key
    ========================

    Need to be root to run test with CUSE interface.
    Need to be root to run test with CUSE interface.
    ==== Starting swtpm with interfaces socket+socket ====
    Test 1: Ok
    ==== Starting swtpm with interfaces socket+socket ====
    Test 2: Ok
    ==== Starting swtpm with interfaces socket+socket ====
    swtpm: Missing migration key to decrypt volatilestate
    Test 3: Ok
    ==== Starting swtpm with interfaces socket+socket ====
    Could not stat file '/build/tests/data/migkey1/volatilestate.bin': Value too large for defined data type
    Error: Could not load encrypted volatile state into TPM.
    FAIL test_migration_key (exit status: 1)

The `stat()` fails because inode value exceeds 32-bit value:

    $ stat /build/tests/data/migkey1/volatilestate.bin
      File: /build/tests/data/migkey1/volatilestate.bin
      Size: 1290            Blocks: 8          IO Block: 4096   regular file
    Device: 0,30    Inode: 9639547569  Links: 1
    ...

The change fixes all the test failures. To fix
`test_tpm2_swtpm_setup_create_cert` I also had to include `config.h`
into `swtpm_backend_dir.c` to get 64-bit file open there as well.

Signed-off-by: Sergei Trofimovich <slyich@gmail.com>
@stefanberger
Copy link
Owner

Thanks. I will merge it now.

@stefanberger stefanberger merged commit 599e243 into stefanberger:master Nov 4, 2024
5 checks passed
@trofi trofi deleted the 64-bit-file-api branch November 4, 2024 21:54
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.

3 participants