Linux NFS development
 help / color / mirror / Atom feed
From: Chuck Lever <chuck.lever@oracle.com>
To: Jeff Layton <jlayton@kernel.org>,
	Shaul Tamari <shaul.tamari@vastdata.com>
Cc: Sagi Grimberg <sagi@grimberg.me>, linux-nfs@vger.kernel.org
Subject: Re: Write delegation stateid permission checks
Date: Thu, 2 Jan 2025 11:01:15 -0500	[thread overview]
Message-ID: <c65f85d0-c52a-45de-bc3f-d9bf827ce83c@oracle.com> (raw)
In-Reply-To: <e52500f98a7153822a6165d26dcf66c3d352129b.camel@kernel.org>

On 1/2/25 8:41 AM, Jeff Layton wrote:
> On Thu, 2025-01-02 at 11:08 +0200, Shaul Tamari wrote:
>> Hi,
>>
>> I have a question regarding NFS4.1 write delegation stateid permission checks.
>>
>> Is there a difference in how a server should check permissions for a
>> write delegation stateid that was given when the file was opened with:
>> 1. OPEN4_SHARE_ACCESS_BOTH
>> 2. OPEN4_SHARE_ACCESS_WRITE
>>
> 
> (cc'ing Sagi since he was looking at this recently)
> 
> A write delegation really should have been called a read-write
> delegation, because the server has to allow the client to do reads as
> well, if you hold one.

Another way to put it is the write delegation is equivalent to a RW
open. It permits the client to handle opens on this file locally without
having to send another OPEN on the wire (as long as certain conditions
hold true).

So, therefore, the client is permitted to use that write delegation
state ID for READ operations.


> The Linux kernel nfs server doesn't currently give out delegations to
> OPEN4_SHARE_ACCESS_WRITE-only opens for this reason. You have to
> request BOTH in order to get one, because a permission check for write
> is not sufficient to allow you to read as well.
> 
> 
>> Should the server check permissions for read access as well when
>> OPEN4_SHARE_ACCESS_WRITE is requested and DELEGATION_WRITE is granted
>> ?
>>
> 
> Possibly? When trying to grant a write delegation, the server should
> probably also do an opportunistic permission check for read as well,
> and only grant the delegation if that passes. If it fails, you could
> still allow the open and just not grant the delegation.
> 
> ISTR that Sagi may have tried this approach though and there was a
> problem with it?
> 
>> or there is an assumption that the client will query the server for
>> read access permissions ?
>>
> 
> The client should always do an ACCESS call to test permissions unless
> the user's access matches the ACE that gets sent along with the
> delegation.

NFSD currently doesn't return this ACE, so the ACCESS round trip is
still needed.

Basically the ACE tells the client what set of local open(2) calls
are allowed without having to return the write delegation.


-- 
Chuck Lever

  parent reply	other threads:[~2025-01-02 16:01 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-02  9:08 Write delegation stateid permission checks Shaul Tamari
2025-01-02 13:41 ` Jeff Layton
2025-01-02 15:40   ` Rick Macklem
2025-01-02 16:01   ` Chuck Lever [this message]
2025-01-02 16:17     ` Rick Macklem
2025-01-02 22:07   ` Sagi Grimberg
2025-01-02 22:42     ` Chuck Lever
2025-01-04 21:47       ` Sagi Grimberg
2025-01-03 20:58   ` Martin Wege

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=c65f85d0-c52a-45de-bc3f-d9bf827ce83c@oracle.com \
    --to=chuck.lever@oracle.com \
    --cc=jlayton@kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=sagi@grimberg.me \
    --cc=shaul.tamari@vastdata.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