mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Davy Felipe <davyfelipe34@gmail.com>
To: Viacheslav Dubeyko <slava@dubeyko.com>,
	John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>,
	Yangtao Li <frank.li@vivo.com>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	Davy Felipe <davyfelipe34@gmail.com>
Subject: [PATCH] hfs: return -EPERM for unsupported setattr changes
Date: Wed, 16 Sep 2026 19:40:16 -0300	[thread overview]
Message-ID: <20260916224016.266800-1-davyfelipe34@gmail.com> (raw)

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


             reply	other threads:[~2026-09-16 22:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-16 22:40 Davy Felipe [this message]
2026-09-17 18:16 ` Viacheslav Dubeyko

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=20260916224016.266800-1-davyfelipe34@gmail.com \
    --to=davyfelipe34@gmail.com \
    --cc=frank.li@vivo.com \
    --cc=glaubitz@physik.fu-berlin.de \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=slava@dubeyko.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

all inboxes | Powered by JetHome®