public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Gabriel Goller <g.goller@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup] fix #4975: client: ignore E2BIG on `listxattr`
Date: Fri,  9 Feb 2024 15:05:52 +0100	[thread overview]
Message-ID: <20240209140554.123703-1-g.goller@proxmox.com> (raw)

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





             reply	other threads:[~2024-02-09 14:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-09 14:05 Gabriel Goller [this message]
2024-02-12 10:15 ` Dietmar Maurer
2024-02-13 14:14   ` Gabriel Goller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240209140554.123703-1-g.goller@proxmox.com \
    --to=g.goller@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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