From: "Darrick J. Wong" <djwong@kernel.org>
To: Andrey Albershteyn <aalbersh@redhat.com>
Cc: xfs <linux-xfs@vger.kernel.org>
Subject: [PATCH 2/2] libfrog: pass mode to xfrog_file_setattr
Date: Tue, 23 Sep 2025 10:10:27 -0700 [thread overview]
Message-ID: <20250923171027.GU8096@frogsfrogsfrogs> (raw)
In-Reply-To: <20250923170857.GS8096@frogsfrogsfrogs>
From: Darrick J. Wong <djwong@kernel.org>
xfs/633 crashes rdump_fileattrs_path passes a NULL struct stat pointer
and then the fallback code dereferences it to get the file mode.
Instead, let's just pass the stat mode directly to it, because that's
the only piece of information that it needs.
Fixes: 128ac4dadbd633 ("xfs_db: use file_setattr to copy attributes on special files with rdump")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
---
libfrog/file_attr.h | 9 ++-------
db/rdump.c | 4 ++--
io/attr.c | 4 ++--
libfrog/file_attr.c | 4 ++--
quota/project.c | 6 ++++--
5 files changed, 12 insertions(+), 15 deletions(-)
diff --git a/libfrog/file_attr.h b/libfrog/file_attr.h
index df9b6181d52cf9..2a1c0d42d0a771 100644
--- a/libfrog/file_attr.h
+++ b/libfrog/file_attr.h
@@ -24,12 +24,7 @@ xfrog_file_getattr(
struct file_attr *fa,
const unsigned int at_flags);
-int
-xfrog_file_setattr(
- const int dfd,
- const char *path,
- const struct stat *stat,
- struct file_attr *fa,
- const unsigned int at_flags);
+int xfrog_file_setattr(const int dfd, const char *path, const mode_t mode,
+ struct file_attr *fa, const unsigned int at_flags);
#endif /* __LIBFROG_FILE_ATTR_H__ */
diff --git a/db/rdump.c b/db/rdump.c
index 84ca3156d60598..26f9babad62be1 100644
--- a/db/rdump.c
+++ b/db/rdump.c
@@ -188,8 +188,8 @@ rdump_fileattrs_path(
return 1;
}
- ret = xfrog_file_setattr(destdir->fd, pbuf->path, NULL, &fa,
- AT_SYMLINK_NOFOLLOW);
+ ret = xfrog_file_setattr(destdir->fd, pbuf->path, VFS_I(ip)->i_mode,
+ &fa, AT_SYMLINK_NOFOLLOW);
if (ret) {
if (errno == EOPNOTSUPP || errno == EPERM || errno == ENOTTY)
lost_mask |= LOST_FSXATTR;
diff --git a/io/attr.c b/io/attr.c
index 022ca5f1df1b7c..9563ff74e44777 100644
--- a/io/attr.c
+++ b/io/attr.c
@@ -261,7 +261,7 @@ chattr_callback(
attr.fa_xflags |= orflags;
attr.fa_xflags &= ~andflags;
- error = xfrog_file_setattr(AT_FDCWD, path, stat, &attr,
+ error = xfrog_file_setattr(AT_FDCWD, path, stat->st_mode, &attr,
AT_SYMLINK_NOFOLLOW);
if (error) {
fprintf(stderr, _("%s: cannot set flags on %s: %s\n"),
@@ -357,7 +357,7 @@ chattr_f(
attr.fa_xflags |= orflags;
attr.fa_xflags &= ~andflags;
- error = xfrog_file_setattr(AT_FDCWD, name, &st, &attr,
+ error = xfrog_file_setattr(AT_FDCWD, name, st.st_mode, &attr,
AT_SYMLINK_NOFOLLOW);
if (error) {
fprintf(stderr, _("%s: cannot set flags on %s: %s\n"),
diff --git a/libfrog/file_attr.c b/libfrog/file_attr.c
index bb51ac6eb2ef95..c2cbcb4e14659c 100644
--- a/libfrog/file_attr.c
+++ b/libfrog/file_attr.c
@@ -85,7 +85,7 @@ int
xfrog_file_setattr(
const int dfd,
const char *path,
- const struct stat *stat,
+ const mode_t mode,
struct file_attr *fa,
const unsigned int at_flags)
{
@@ -103,7 +103,7 @@ xfrog_file_setattr(
return error;
#endif
- if (SPECIAL_FILE(stat->st_mode)) {
+ if (SPECIAL_FILE(mode)) {
errno = EOPNOTSUPP;
return -1;
}
diff --git a/quota/project.c b/quota/project.c
index 5832e1474e2549..33449e01ef4dbb 100644
--- a/quota/project.c
+++ b/quota/project.c
@@ -157,7 +157,8 @@ clear_project(
fa.fa_projid = 0;
fa.fa_xflags &= ~FS_XFLAG_PROJINHERIT;
- error = xfrog_file_setattr(dfd, path, stat, &fa, AT_SYMLINK_NOFOLLOW);
+ error = xfrog_file_setattr(dfd, path, stat->st_mode, &fa,
+ AT_SYMLINK_NOFOLLOW);
if (error) {
fprintf(stderr, _("%s: cannot clear project on %s: %s\n"),
progname, path, strerror(errno));
@@ -205,7 +206,8 @@ setup_project(
if (S_ISDIR(stat->st_mode))
fa.fa_xflags |= FS_XFLAG_PROJINHERIT;
- error = xfrog_file_setattr(dfd, path, stat, &fa, AT_SYMLINK_NOFOLLOW);
+ error = xfrog_file_setattr(dfd, path, stat->st_mode, &fa,
+ AT_SYMLINK_NOFOLLOW);
if (error) {
fprintf(stderr, _("%s: cannot set project on %s: %s\n"),
progname, path, strerror(errno));
next prev parent reply other threads:[~2025-09-23 17:10 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-23 17:08 [PATCH 1/2] mkfs: fix libxfs_iget return value sign inversion Darrick J. Wong
2025-09-23 17:10 ` Darrick J. Wong [this message]
2025-09-24 13:18 ` [PATCH 2/2] libfrog: pass mode to xfrog_file_setattr Andrey Albershteyn
2025-09-24 21:52 ` Darrick J. Wong
2025-09-24 9:03 ` [PATCH 1/2] mkfs: fix libxfs_iget return value sign inversion Andrey Albershteyn
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=20250923171027.GU8096@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=aalbersh@redhat.com \
--cc=linux-xfs@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).