public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hfsplus: Fix bug causing custom uid and gid being unable to be assigned with mount
@ 2022-12-02 15:39 Aditya Garg
  2022-12-02 20:52 ` Viacheslav Dubeyko
  2022-12-07  3:05 ` [PATCH v2] " Aditya Garg
  0 siblings, 2 replies; 10+ messages in thread
From: Aditya Garg @ 2022-12-02 15:39 UTC (permalink / raw)
  To: willy@infradead.org, ira.weiny@intel.com, axboe@kernel.dk,
	akpm@linux-foundation.org, bvanassche@acm.org,
	keescook@chromium.org, songmuchun@bytedance.com,
	slava@dubeyko.com, torvalds@linux-foundation.org,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org

From: Aditya Garg <gargaditya08@live.com>

Inspite of specifying UID and GID in mount command, the specified UID and
GID was not being assigned. This patch fixes this issue.

Signed-off-by: Aditya Garg <gargaditya08@live.com>
---
 fs/hfsplus/hfsplus_fs.h | 2 ++
 fs/hfsplus/inode.c      | 4 ++--
 fs/hfsplus/options.c    | 2 ++
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/fs/hfsplus/hfsplus_fs.h b/fs/hfsplus/hfsplus_fs.h
index a5db2e3b2..6aa919e59 100644
--- a/fs/hfsplus/hfsplus_fs.h
+++ b/fs/hfsplus/hfsplus_fs.h
@@ -198,6 +198,8 @@ struct hfsplus_sb_info {
 #define HFSPLUS_SB_HFSX		3
 #define HFSPLUS_SB_CASEFOLD	4
 #define HFSPLUS_SB_NOBARRIER	5
+#define HFSPLUS_SB_UID		6
+#define HFSPLUS_SB_GID		7
 
 static inline struct hfsplus_sb_info *HFSPLUS_SB(struct super_block *sb)
 {
diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c
index aeab83ed1..4d1077db8 100644
--- a/fs/hfsplus/inode.c
+++ b/fs/hfsplus/inode.c
@@ -192,11 +192,11 @@ static void hfsplus_get_perms(struct inode *inode,
 	mode = be16_to_cpu(perms->mode);
 
 	i_uid_write(inode, be32_to_cpu(perms->owner));
-	if (!i_uid_read(inode) && !mode)
+	if (test_bit(HFSPLUS_SB_UID, &sbi->flags))
 		inode->i_uid = sbi->uid;
 
 	i_gid_write(inode, be32_to_cpu(perms->group));
-	if (!i_gid_read(inode) && !mode)
+	if (test_bit(HFSPLUS_SB_GID, &sbi->flags))
 		inode->i_gid = sbi->gid;
 
 	if (dir) {
diff --git a/fs/hfsplus/options.c b/fs/hfsplus/options.c
index 047e05c57..10a0bdacb 100644
--- a/fs/hfsplus/options.c
+++ b/fs/hfsplus/options.c
@@ -137,6 +137,7 @@ int hfsplus_parse_options(char *input, struct hfsplus_sb_info *sbi)
 				return 0;
 			}
 			sbi->uid = make_kuid(current_user_ns(), (uid_t)tmp);
+			set_bit(HFSPLUS_SB_UID, &sbi->flags);
 			if (!uid_valid(sbi->uid)) {
 				pr_err("invalid uid specified\n");
 				return 0;
@@ -148,6 +149,7 @@ int hfsplus_parse_options(char *input, struct hfsplus_sb_info *sbi)
 				return 0;
 			}
 			sbi->gid = make_kgid(current_user_ns(), (gid_t)tmp);
+			set_bit(HFSPLUS_SB_GID, &sbi->flags);
 			if (!gid_valid(sbi->gid)) {
 				pr_err("invalid gid specified\n");
 				return 0;
-- 
2.38.1


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

end of thread, other threads:[~2022-12-07 20:17 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-02 15:39 [PATCH] hfsplus: Fix bug causing custom uid and gid being unable to be assigned with mount Aditya Garg
2022-12-02 20:52 ` Viacheslav Dubeyko
2022-12-03  7:56   ` Aditya Garg
2022-12-06  0:35     ` Viacheslav Dubeyko
2022-12-06  8:12       ` Aditya Garg
2022-12-06  8:49         ` Aditya Garg
2022-12-06 18:56           ` Viacheslav Dubeyko
2022-12-07  3:04             ` Aditya Garg
2022-12-07  3:05 ` [PATCH v2] " Aditya Garg
2022-12-07 20:17   ` Viacheslav Dubeyko

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