Skip to content

glibc: statvfs64 is missing __f_unused on riscv32-gnu #5512

Description

@valentynkit

Currently statvfs64 on riscv32 layout seems inconsistent with it neighboring statvfs, and the source in glibc. It creates different layout that may be expected, so may cause UB because of shifted bytes on the struct.

// Mirrors `_STATVFSBUF_F_UNUSED` in the header. x32 is excluded because
// its `__SYSCALL_WORDSIZE` is 64, aarch64 because glibc always sets
// `__WORDSIZE` to 64.
#[cfg(all(
target_pointer_width = "32",
not(any(target_arch = "x86_64", target_arch = "aarch64"))
))]
__f_unused: Padding<c_int>,

// FIXME(riscv32): glibc declares this field on riscv32 too, but we have
// never declared it here.
#[cfg(all(
target_pointer_width = "32",
not(any(
target_arch = "x86_64",
target_arch = "aarch64",
target_arch = "riscv32"
))
))]
__f_unused: Padding<c_int>,

In glibc, both of them have __f_unused for 32-bit targets.
https://github.com/bminor/glibc/blob/04e750e75b73957cf1c791535a3f4319534a52fc/sysdeps/unix/sysv/linux/bits/statvfs.h#L49-L51
https://github.com/bminor/glibc/blob/04e750e75b73957cf1c791535a3f4319534a52fc/sysdeps/unix/sysv/linux/bits/statvfs.h#L70-L72
https://github.com/bminor/glibc/blob/04e750e75b73957cf1c791535a3f4319534a52fc/sysdeps/unix/sysv/linux/bits/statvfs.h#L24-L27

It was found when working on #5434, during the migration and deduplication to new, the missing field of statvfs64 on riscv32 was deliberately left out as it was before to not change layout of it , but based on the source it should have that field, or are there any specific reason it didn't get that field?

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions