public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
From: dai.ngo@oracle.com
To: Olga Kornievskaia <aglo@umich.edu>
Cc: Al Viro <viro@zeniv.linux.org.uk>,
	Amir Goldstein <amir73il@gmail.com>,
	linux-nfs <linux-nfs@vger.kernel.org>,
	Olga Kornievskaia <kolga@netapp.com>,
	linux-fsdevel <linux-fsdevel@vger.kernel.org>
Subject: Re: [RFC] problems with alloc_file_pseudo() use in __nfs42_ssc_open()
Date: Fri, 19 Aug 2022 11:18:53 -0700	[thread overview]
Message-ID: <a9b9a68d-bf8f-2c89-eab5-ef1cbb5be135@oracle.com> (raw)
In-Reply-To: <CAN-5tyHdr_RXPcFpa7fsg=jpOyge0C4pB1waj=BdHHzmeaMdPw@mail.gmail.com>


On 8/19/22 10:37 AM, Olga Kornievskaia wrote:
> On Fri, Aug 19, 2022 at 11:42 AM <dai.ngo@oracle.com> wrote:
>>
>> On 8/19/22 7:22 AM, Olga Kornievskaia wrote:
>>> On Thu, Aug 18, 2022 at 10:52 PM <dai.ngo@oracle.com> wrote:
>>>> On 8/18/22 6:13 AM, Olga Kornievskaia wrote:
>>>>> On Thu, Aug 18, 2022 at 1:52 AM Al Viro <viro@zeniv.linux.org.uk> wrote:
>>>>>> On Thu, Aug 18, 2022 at 08:19:54AM +0300, Amir Goldstein wrote:
>>>>>>
>>>>>>> NFS spec does not guarantee the safety of the server.
>>>>>>> It's like saying that the Law makes Crime impossible.
>>>>>>> The law needs to be enforced, so if server gets a request
>>>>>>> to COPY from/to an fhandle that resolves as a non-regular file
>>>>>>> (from a rogue or buggy NFS client) the server should return an
>>>>>>> error and not continue to alloc_file_pseudo().
>>>>>> FWIW, my preference would be to have alloc_file_pseudo() reject
>>>>>> directory inodes if it ever gets such.
>>>>>>
>>>>>> I'm still not sure that my (and yours, apparently) interpretation
>>>>>> of what Olga said is correct, though.
>>>>> Would it be appropriate to do the following then:
>>>>>
>>>>> diff --git a/fs/nfs/nfs4file.c b/fs/nfs/nfs4file.c
>>>>> index e88f6b18445e..112134b6438d 100644
>>>>> --- a/fs/nfs/nfs4file.c
>>>>> +++ b/fs/nfs/nfs4file.c
>>>>> @@ -340,6 +340,11 @@ static struct file *__nfs42_ssc_open(struct
>>>>> vfsmount *ss_mnt,
>>>>>                    goto out;
>>>>>            }
>>>>>
>>>>> +       if (S_ISDIR(fattr->mode)) {
>>>>> +               res = ERR_PTR(-EBADF);
>>>>> +               goto out;
>>>>> +       }
>>>>> +
>>>> Can we also enhance nfsd4_do_async_copy to check for
>>>> -EBADF and returns nfserr_wrong_type? perhaps adding
>>>> an error mapping function to handle other errors also.
>>> On the server side, if the open fails that's already translated into
>>> the appropriate error -- err_off_load_denied.
>> Currently the server returns nfserr_offload_denied if the open
>> fails for any reasons. I'm wondering whether the server should
>> return more accurate error code such as if the source file handle
>> is a wrong type then the server should return nfserr_wrong_type,
>> instead of nfserr_offload_denied, to match the spec:
>>
>>      Both SAVED_FH and CURRENT_FH must be regular files.  If either
>>      SAVED_FH or CURRENT_FH is not a regular file, the operation MUST fail
>>      and return NFS4ERR_WRONG_TYPE.
> Ok sure. That's a relevant but a separate patch.

Thank you Olga!

-Dai

>
>> -Dai
>>
>>>> -Dai
>>>>
>>>>>            res = ERR_PTR(-ENOMEM);
>>>>>            len = strlen(SSC_READ_NAME_BODY) + 16;
>>>>>            read_name = kzalloc(len, GFP_KERNEL);
>>>>> @@ -357,6 +362,7 @@ static struct file *__nfs42_ssc_open(struct
>>>>> vfsmount *ss_mnt,
>>>>>                                         r_ino->i_fop);
>>>>>            if (IS_ERR(filep)) {
>>>>>                    res = ERR_CAST(filep);
>>>>> +               iput(r_ino);
>>>>>                    goto out_free_name;
>>>>>            }

      reply	other threads:[~2022-08-19 18:19 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-17 21:55 [RFC] problems with alloc_file_pseudo() use in __nfs42_ssc_open() Al Viro
2022-08-17 22:32 ` Olga Kornievskaia
2022-08-18  0:01   ` Al Viro
2022-08-18  0:12     ` Olga Kornievskaia
2022-08-18  0:20       ` Al Viro
2022-08-18  5:19       ` Amir Goldstein
2022-08-18  5:52         ` Al Viro
2022-08-18 13:13           ` Olga Kornievskaia
2022-08-18 14:38             ` Trond Myklebust
2022-08-19  2:51             ` dai.ngo
2022-08-19 14:22               ` Olga Kornievskaia
2022-08-19 15:42                 ` dai.ngo
2022-08-19 17:37                   ` Olga Kornievskaia
2022-08-19 18:18                     ` dai.ngo [this message]

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=a9b9a68d-bf8f-2c89-eab5-ef1cbb5be135@oracle.com \
    --to=dai.ngo@oracle.com \
    --cc=aglo@umich.edu \
    --cc=amir73il@gmail.com \
    --cc=kolga@netapp.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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