mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Viacheslav Dubeyko <slava@dubeyko.com>
To: Aditya Garg <gargaditya08@live.com>
Cc: "willy@infradead.org" <willy@infradead.org>,
	"ira.weiny@intel.com" <ira.weiny@intel.com>,
	"axboe@kernel.dk" <axboe@kernel.dk>,
	"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
	"bvanassche@acm.org" <bvanassche@acm.org>,
	"keescook@chromium.org" <keescook@chromium.org>,
	"songmuchun@bytedance.com" <songmuchun@bytedance.com>,
	"torvalds@linux-foundation.org" <torvalds@linux-foundation.org>,
	"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] hfsplus: Fix bug causing custom uid and gid being unable to be assigned with mount
Date: Mon, 5 Dec 2022 16:35:36 -0800	[thread overview]
Message-ID: <A2B962C1-AD33-413D-B64A-CD179AFBEA8D@dubeyko.com> (raw)
In-Reply-To: <1D7AAEE4-9603-43A4-B89D-6F791EDCB929@live.com>



> On Dec 2, 2022, at 11:56 PM, Aditya Garg <gargaditya08@live.com> wrote:
> 
> 
>> Also, what if we mounted
>> file system without specifying the UID/GID, then what UID/GID will be returned by
>> your logic?
> 
> So this case is if I run “sudo mount /dev/sda1 /mnt”
> 
> Here the driver will not do any spoofing, and the real owners of the files shall be displayed. Thus running “ls -l” on a mounted partition without specifying UID/GID, files written by macOS shall be shown as 99 as the owner, iPadOS as 501, and if any file was written on Linux, the user who wrote it will be the owner.
> 
> If the user/group of any file was changed using chown, then the new user/group of the file will be displayed.

My question is much more simple.

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;

Before this change, logic called i_uid_read(inode) and checked mode.
Now, we check only HFSPLUS_SB_UID/HFSPLUS_SB_GID flags.
So, if we mount HFS+ volume by “sudo mount /dev/sda1 /mnt”, then
HFSPLUS_SB_UID and HFSPLUS_SB_GID flags will be unset.
And current logic will do nothing. Is it correct logic? Maybe, we need
to use sbi->uid/gid if flag(s)HFSPLUS_SB_UID/HFSPLUS_SB_GID are set.
And if not, then to use old logic. Am I correct here? Or am I still missing
something here?

Thanks,
Slava.



  reply	other threads:[~2022-12-06  0:37 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-02 15:39 Aditya Garg
2022-12-02 20:52 ` Viacheslav Dubeyko
2022-12-03  7:56   ` Aditya Garg
2022-12-06  0:35     ` Viacheslav Dubeyko [this message]
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

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=A2B962C1-AD33-413D-B64A-CD179AFBEA8D@dubeyko.com \
    --to=slava@dubeyko.com \
    --cc=akpm@linux-foundation.org \
    --cc=axboe@kernel.dk \
    --cc=bvanassche@acm.org \
    --cc=gargaditya08@live.com \
    --cc=ira.weiny@intel.com \
    --cc=keescook@chromium.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=songmuchun@bytedance.com \
    --cc=torvalds@linux-foundation.org \
    --cc=willy@infradead.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

all inboxes | Powered by JetHome®