[pbs-devel] [PATCH proxmox-backup] fix #4975: client: ignore E2BIG on `listxattr`

Gabriel Goller g.goller at proxmox.com
Fri Feb 9 15:05:52 CET 2024


Regardless of the file system, the vfs layer imposes a 64kB limit to the
extended attributes of a file (and a maximum of 65536 entries) [0][1].
If a file has more than 65536 xattrs, the `listxattr` syscall returns
a E2BIG error.
To prevent the proxmox-backup-client from crashing, ignore this error
and print a warning. This includes the file content but ignores the
xattrs.

A user ran into this by moving a file from linux to windows to solaris
and onto a zfs dataset. This created xattrs in the magnitude of a MB,
which works on ZFS but cannot be read using listxattr.

[0]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/fs/xattr.c#n834
[1]: https://www.man7.org/linux/man-pages/man2/listxattr.2.html#BUGS

Signed-off-by: Gabriel Goller <g.goller at proxmox.com>
---
 pbs-client/src/pxar/create.rs | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/pbs-client/src/pxar/create.rs b/pbs-client/src/pxar/create.rs
index e7053d9e..2347af7b 100644
--- a/pbs-client/src/pxar/create.rs
+++ b/pbs-client/src/pxar/create.rs
@@ -1,6 +1,7 @@
 use std::collections::{HashMap, HashSet};
 use std::ffi::{CStr, CString, OsStr};
 use std::fmt;
+use std::fs::read_link;
 use std::io::{self, Read};
 use std::os::unix::ffi::OsStrExt;
 use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, OwnedFd, RawFd};
@@ -829,6 +830,13 @@ fn get_xattr_fcaps_acl(
             fs_feature_flags.remove(Flags::WITH_XATTRS);
             return Ok(());
         }
+        Err(Errno::E2BIG) => {
+            log::warn!(
+                "WARNING: {} - failed to read xattrs, too big (E2BIG)",
+                read_link(proc_path).map_or("".to_string(), |p| p.display().to_string())
+            );
+            return Ok(());
+        }
         Err(Errno::EBADF) => return Ok(()), // symlinks
         Err(err) => return Err(err).context("failed to read xattrs"),
     };
-- 
2.43.0





More information about the pbs-devel mailing list