Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6720552rwb; Mon, 5 Dec 2022 17:04:27 -0800 (PST) X-Google-Smtp-Source: AA0mqf7EKwtAuuTNfkv3Abl+5CYBADPHdGb4seLbbiF8yc+vtrhul5Q3cdu27FH84MOqHC728px4 X-Received: by 2002:a17:906:2e9a:b0:7c0:f911:28b3 with SMTP id o26-20020a1709062e9a00b007c0f91128b3mr4844397eji.303.1670288667154; Mon, 05 Dec 2022 17:04:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670288667; cv=none; d=google.com; s=arc-20160816; b=nkAHdvqbqexAFpt5fES/oOJqiTJHhC/pk/1jkoSfcEldiPj4KUPxT5DHuL35nMiZEV wRQJuY8LhTZLcle6QAUWJRLF+rgLeUBCrKhBaQ+who21DdYcANHj4JNKhNV/fHVwnRR0 /XE9U8jzUWY/HnlX1mOPHpxD+eE9XSur7KpDoEHXiWzl2PrWS8uzPU+u8vi2fWCmZarM /tX9ACpC2DNGAKrOXdJkyK6E1M4QBtBZ7dlmHqVcTuY1BXXYyACW81+K1Pp0Ubs1wHgq ce+yju61eGzo4V8mMt44zRMK+Klh01DC/OtF9CQby3BsQhMFTjlrFci0rbe1LFZBy93L sLcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:dkim-signature; bh=ne2kQ17Z3A3jdHPo12NzWN07bL28Bd+Tg02BrzT7QcM=; b=YZRTRwi0+YgxMZEjI7v03T7pKP+zDeRH48dcclSk42C7ceXBdyOFXs1asVcY2uqaDO m1IdHrpIeAUQIGhRWKsTtlm4QBpqlszfuBsrCEv42K6S2teVg7NsPtHmLVnyDtc3C0oy oshjH6bYd64FkSxEwIYHCUdPWab1Efhq9VAxHO5IAcuSFWD3DIkG2W9Gcu5XDgWwd2Iw gmlL6u671h124tYiWtVU7fU96S9jfAro2pHyOO8I80WJXuQtBU1WlN1Fome946RIyznq Ry1IhkAGMYyY4bKY+2gPMaIQRN+wh4WqpAHxAZqks4KllpVH3Nsr129nvMx8uDBGwu6R CpWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dubeyko-com.20210112.gappssmtp.com header.s=20210112 header.b=8B7MCsOb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id tz14-20020a170907c78e00b0078e1d213812si10869319ejc.184.2022.12.05.17.04.07; Mon, 05 Dec 2022 17:04:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@dubeyko-com.20210112.gappssmtp.com header.s=20210112 header.b=8B7MCsOb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232976AbiLFAhc (ORCPT + 79 others); Mon, 5 Dec 2022 19:37:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232604AbiLFAg7 (ORCPT ); Mon, 5 Dec 2022 19:36:59 -0500 Received: from mail-qt1-x835.google.com (mail-qt1-x835.google.com [IPv6:2607:f8b0:4864:20::835]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D7AE22B3D for ; Mon, 5 Dec 2022 16:35:44 -0800 (PST) Received: by mail-qt1-x835.google.com with SMTP id a27so12690741qtw.10 for ; Mon, 05 Dec 2022 16:35:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dubeyko-com.20210112.gappssmtp.com; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=ne2kQ17Z3A3jdHPo12NzWN07bL28Bd+Tg02BrzT7QcM=; b=8B7MCsObOOvSR6mCIokEm9+fr1yaDvUvjD7xLGijdBTs3173zrpzOBCSMq7GbxNBOM jlA32HML4qaWiA3bC6/MPSgXaUVCfDcNO6Eh0Y0wkVZv0g1YdCxC7+6gaO3SEVPZoGb5 HrrRV5vE7unUe9agoAJ8B1Pp8NbAhAYjBb9QhoDja4o0GsDM0tFW8pGusiEyqX4zxzkF CljQBwGY9gpwXG1kIXBI+qeSYEVIsVEySuVkFdkM0H9hKa0A4GvD1jan7GRU9WkJps92 YP/pq8joOPnl2SuuUW4hLh9dHzTeG3C8HOQaTrrE/uf+/pB8p30p04rCt3j/O4H92pqq BKMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ne2kQ17Z3A3jdHPo12NzWN07bL28Bd+Tg02BrzT7QcM=; b=yQObrtHsg1jmP/uL/XxMlPX4BdsM5qIZ5RRW1ntooNXWkh4LwGyc3GKEYmMPlR5COM S1rN20r82BTqh1CulBa0yuWyGQ7DHxRfcySvpy1IpYd3WoXPdpU6HKCP5kCD7M2KVRMi PMfvyGoyuF0LKRdIsqtF2Xdcq3ibwEOdZNfQwl+gsTc9SeoxSq1L4BACg8L7HNQy8orr pfoZ1VTSbfsBcMdR+sfJkxcVNbcjQLdhiteU570Tjxslz06IthqCWcyIRcxwwdmLIH4U Ut+IiYfUWqLXKoqn+aqe1wTsK44jqo/umX4JDW21IsvrB55NWDrL67OTCaC4AdBIwY9Q hP3Q== X-Gm-Message-State: ANoB5plaUTtoYF9cYNz/AeskNyaxatLOhZkKzud9AaifsRKmbA5H7kWk DmAhxds/CEGj0Avb3MVOGuw2hA== X-Received: by 2002:ac8:4d4f:0:b0:3a6:1dea:8c1c with SMTP id x15-20020ac84d4f000000b003a61dea8c1cmr68663245qtv.157.1670286942302; Mon, 05 Dec 2022 16:35:42 -0800 (PST) Received: from smtpclient.apple (172-125-78-211.lightspeed.sntcca.sbcglobal.net. [172.125.78.211]) by smtp.gmail.com with ESMTPSA id 134-20020a37088c000000b006ec771d8f89sm327312qki.112.2022.12.05.16.35.40 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Dec 2022 16:35:41 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) Subject: Re: [PATCH] hfsplus: Fix bug causing custom uid and gid being unable to be assigned with mount From: Viacheslav Dubeyko In-Reply-To: <1D7AAEE4-9603-43A4-B89D-6F791EDCB929@live.com> Date: Mon, 5 Dec 2022 16:35:36 -0800 Cc: "willy@infradead.org" , "ira.weiny@intel.com" , "axboe@kernel.dk" , "akpm@linux-foundation.org" , "bvanassche@acm.org" , "keescook@chromium.org" , "songmuchun@bytedance.com" , "torvalds@linux-foundation.org" , "linux-fsdevel@vger.kernel.org" , "linux-kernel@vger.kernel.org" Content-Transfer-Encoding: quoted-printable Message-Id: References: <93F5197D-2B61-4129-B5D4-771934F70577@live.com> <55A80630-60FB-44BE-9628-29104AB8A7D0@dubeyko.com> <1D7AAEE4-9603-43A4-B89D-6F791EDCB929@live.com> To: Aditya Garg X-Mailer: Apple Mail (2.3696.120.41.1.1) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Dec 2, 2022, at 11:56 PM, Aditya Garg = wrote: >=20 >=20 >> Also, what if we mounted >> file system without specifying the UID/GID, then what UID/GID will be = returned by >> your logic? >=20 > So this case is if I run =E2=80=9Csudo mount /dev/sda1 /mnt=E2=80=9D >=20 > Here the driver will not do any spoofing, and the real owners of the = files shall be displayed. Thus running =E2=80=9Cls -l=E2=80=9D 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. >=20 > 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 =3D 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 =3D 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 =3D 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 =E2=80=9Csudo mount /dev/sda1 /mnt=E2=80=9D= , 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.