mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] hfs: return -EPERM for unsupported setattr changes
@ 2026-09-16 22:40 Davy Felipe
  0 siblings, 0 replies; only message in thread
From: Davy Felipe @ 2026-09-16 22:40 UTC (permalink / raw)
  To: Viacheslav Dubeyko, John Paul Adrian Glaubitz, Yangtao Li
  Cc: linux-fsdevel, linux-kernel, Davy Felipe

hfs_inode_setattr() rejects unsupported UID, GID and mode changes,
but returns the value stored in error when the filesystem is not
mounted with the quiet option.

At this point error is zero, as execution has already passed a
successful setattr_prepare() call. As a result, unsupported attribute
changes are incorrectly reported to userspace as successful even
though the inode remains unchanged.

Return -EPERM for these operations while preserving the existing
behavior for quiet mounts.

A chown test on an HFS image reproduces the problem. Without the fix,
chown 1234:1234 returns success while ownership remains 0:0. With the
fix, the same operation fails with EPERM and ownership remains
unchanged.

Signed-off-by: Davy Felipe <davyfelipe34@gmail.com>
---
 fs/hfs/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/hfs/inode.c b/fs/hfs/inode.c
index 2aef3c36a150..cce3a7bb95e9 100644
--- a/fs/hfs/inode.c
+++ b/fs/hfs/inode.c
@@ -663,7 +663,7 @@ int hfs_inode_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
 	     ((S_ISDIR(inode->i_mode) &&
 	       (attr->ia_mode != inode->i_mode)) ||
 	      (attr->ia_mode & ~HFS_VALID_MODE_BITS)))) {
-		return hsb->s_quiet ? 0 : error;
+		return hsb->s_quiet ? 0 : -EPERM;
 	}
 
 	/* map file permissions to the closest allowable permissions in HFS */
-- 
2.55.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-09-16 22:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-16 22:40 [PATCH] hfs: return -EPERM for unsupported setattr changes Davy Felipe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®