public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH proxmox-backup] fix #4975: client: ignore E2BIG on `listxattr`
@ 2024-02-09 14:05 Gabriel Goller
  2024-02-12 10:15 ` Dietmar Maurer
  0 siblings, 1 reply; 3+ messages in thread
From: Gabriel Goller @ 2024-02-09 14:05 UTC (permalink / raw)
  To: pbs-devel

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@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





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-02-13 14:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-09 14:05 [pbs-devel] [PATCH proxmox-backup] fix #4975: client: ignore E2BIG on `listxattr` Gabriel Goller
2024-02-12 10:15 ` Dietmar Maurer
2024-02-13 14:14   ` Gabriel Goller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal