github-actions[bot] opened issue #15237:
xattr functions mark unwritten bytes as initialized when given a zero-length buffer
Details Status unsound Package rustixVersion 1.1.5URL https://github.com/bytecodealliance/rustix/commit/8e6aaa6713d2bb64b1fdd8c472e3a32a10a76d70 Date 2026-10-27 The extended-attribute functions in
rustix::fs(getxattr,lgetxattr,fgetxattr,listxattr,llistxattrandflistxattr) write into aBufferand then mark as many bytes initialized as the system call reported. When the buffer has zero length, the operating system treats the call as a size query: it writes nothing and returns the size of the attribute value or of the name list. rustix still marked that many bytes as initialized.Passing a
Vecwhose length equals its capacity throughspare_capacitygives such a zero-length buffer, and rustix then set the vector's length past its capacity over memory that was never written. This is undefined behavior reachable from safe code. With an empty&mut [MaybeUninit<u8>]the call panics instead.From 1.1.6 these functions return an empty result for a zero-length buffer, and new
getxattr_query,lgetxattr_query,fgetxattr_query,listxattr_query,llistxattr_queryandflistxattr_queryfunctions return the size. The 0.38 series did not have theBufferAPI and is not affected.See advisory page for additional details.
pchickey closed issue #15237:
xattr functions mark unwritten bytes as initialized when given a zero-length buffer
Details Status unsound Package rustixVersion 1.1.5URL https://github.com/bytecodealliance/rustix/commit/8e6aaa6713d2bb64b1fdd8c472e3a32a10a76d70 Date 2026-10-27 The extended-attribute functions in
rustix::fs(getxattr,lgetxattr,fgetxattr,listxattr,llistxattrandflistxattr) write into aBufferand then mark as many bytes initialized as the system call reported. When the buffer has zero length, the operating system treats the call as a size query: it writes nothing and returns the size of the attribute value or of the name list. rustix still marked that many bytes as initialized.Passing a
Vecwhose length equals its capacity throughspare_capacitygives such a zero-length buffer, and rustix then set the vector's length past its capacity over memory that was never written. This is undefined behavior reachable from safe code. With an empty&mut [MaybeUninit<u8>]the call panics instead.From 1.1.6 these functions return an empty result for a zero-length buffer, and new
getxattr_query,lgetxattr_query,fgetxattr_query,listxattr_query,llistxattr_queryandflistxattr_queryfunctions return the size. The 0.38 series did not have theBufferAPI and is not affected.See advisory page for additional details.
Last updated: Nov 19 2026 at 20:05 UTC