Linux NFS development
 help / color / mirror / Atom feed
From: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
To: Christian Brauner <brauner@kernel.org>,
	Chuck Lever III <chuck.lever@oracle.com>
Cc: Jeff Layton <jlayton@kernel.org>,
	Linux NFS Mailing List <linux-nfs@vger.kernel.org>,
	Sherry Yang <sherry.yang@oracle.com>,
	Darren Kenny <darren.kenny@oracle.com>
Subject: Re: [PATCH] nfsd: use vfs setgid helper
Date: Wed, 3 May 2023 16:23:38 +0530	[thread overview]
Message-ID: <ac5c9882-8cc7-8d64-5784-fd71b04dde3a@oracle.com> (raw)
In-Reply-To: <20230503-mehrverbrauch-spargel-258668d27f53@brauner>

Hi Christian,

On 03/05/23 12:30 pm, Christian Brauner wrote:
> On Tue, May 02, 2023 at 06:23:51PM +0000, Chuck Lever III wrote:
>>
>>
>>> On May 2, 2023, at 12:50 PM, Chuck Lever III <chuck.lever@oracle.com> wrote:
>>>
>>>
>>>
>>>> On May 2, 2023, at 9:49 AM, Chuck Lever III <chuck.lever@oracle.com> wrote:
>>>>
>>>>>
>>>>> On May 2, 2023, at 9:36 AM, Christian Brauner <brauner@kernel.org> wrote:
>>>>>
>>>>> We've aligned setgid behavior over multiple kernel releases. The details
>>>>> can be found in commit cf619f891971 ("Merge tag 'fs.ovl.setgid.v6.2' of
>>>>> git://git.kernel.org/pub/scm/linux/kernel/git/vfs/idmapping") and
>>>>> commit 426b4ca2d6a5 ("Merge tag 'fs.setgid.v6.0' of
>>>>> git://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux").
>>>>> Consistent setgid stripping behavior is now encapsulated in the
>>>>> setattr_should_drop_sgid() helper which is used by all filesystems that
>>>>> strip setgid bits outside of vfs proper. Usually ATTR_KILL_SGID is
>>>>> raised in e.g., chown_common() and is subject to the
>>>>> setattr_should_drop_sgid() check to determine whether the setgid bit can
>>>>> be retained. Since nfsd is raising ATTR_KILL_SGID unconditionally it
>>>>> will cause notify_change() to strip it even if the caller had the
>>>>> necessary privileges to retain it. Ensure that nfsd only raises
>>>>> ATR_KILL_SGID if the caller lacks the necessary privileges to retain the
>>>>> setgid bit.
>>>>>
>>>>> Without this patch the setgid stripping tests in LTP will fail:
>>>>>
>>>>>> As you can see, the problem is S_ISGID (0002000) was dropped on a
>>>>>> non-group-executable file while chown was invoked by super-user, while
>>>>>
>>>>> [...]
>>>>>
>>>>>> fchown02.c:66: TFAIL: testfile2: wrong mode permissions 0100700, expected 0102700
>>>>>
>>>>> [...]
>>>>>
>>>>>> chown02.c:57: TFAIL: testfile2: wrong mode permissions 0100700, expected 0102700
>>>>>
>>>>> With this patch all tests pass.
>>>>>
>>>>> Reported-by: Sherry Yang <sherry.yang@oracle.com>
>>>>> Signed-off-by: Christian Brauner <brauner@kernel.org>
>>>>

We had a very similar report from kernel-test-robot.

https://lore.kernel.org/all/202210091600.dbe52cbf-yujie.liu@intel.com/

Which points to commit: ed5a7047d201 ("attr: use consistent sgid 
stripping checks")

And the above commit is backported to LTS kernels -- 5.10.y,5.15.y and 
6.1.y

So would it be better to tag it to stable by adding "Cc: 
<stable@vger.kernel.org>" ?

Thanks,
Harshit

>>>> There are some similar fstests failures this fix might address.
>>>>
>>>> I've applied this patch to the nfsd-fixes tree for broader
>>>> testing.
>>>
>>> ERROR: modpost: "setattr_should_drop_sgid" [fs/nfsd/nfsd.ko] undefined!
>>>
>>> Did I apply this patch to the wrong kernel?
>>
>> setattr_should_drop_sgid() is not available to callers built as
>> modules. It needs an EXPORT_SYMBOL or _GPL.
> 
> Hey Chuck,
> 
> Thanks for taking a look!
> The required export is part of
> commit 4f704d9a835 ("nfs: use vfs setgid helper")
> which is in current mainline as of Monday this week which was part of my
> v6.4/vfs.misc PR that was merged.
> 
> So this should all work fine on mainline. Seems I didn't use --base
> which is why that info was missing.
> 
> Thanks!
> Christian
> 
> 

  reply	other threads:[~2023-05-03 10:53 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-02 13:36 [PATCH] nfsd: use vfs setgid helper Christian Brauner
2023-05-02 13:49 ` Chuck Lever III
2023-05-02 16:50   ` Chuck Lever III
2023-05-02 18:23     ` Chuck Lever III
2023-05-03  7:00       ` Christian Brauner
2023-05-03 10:53         ` Harshit Mogalapalli [this message]
2023-05-03 14:05           ` Chuck Lever III
2023-05-04  6:38             ` Christian Brauner
2023-05-15 16:34             ` Sherry Yang
2023-05-15 17:01               ` Chuck Lever III
2023-05-02 18:12 ` Jeff Layton

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=ac5c9882-8cc7-8d64-5784-fd71b04dde3a@oracle.com \
    --to=harshit.m.mogalapalli@oracle.com \
    --cc=brauner@kernel.org \
    --cc=chuck.lever@oracle.com \
    --cc=darren.kenny@oracle.com \
    --cc=jlayton@kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=sherry.yang@oracle.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