All of lore.kernel.org
 help / color / mirror / Atom feed
From: Xiubo Li <xiubli@redhat.com>
To: Sebastian Hasler <sebastian.hasler@sec.uni-stuttgart.de>
Cc: ceph-devel@vger.kernel.org
Subject: Re: [PATCH] ceph: fail the open_by_handle_at() if the dentry is being unlinked
Date: Thu, 7 Sep 2023 10:05:15 +0800	[thread overview]
Message-ID: <3f6b622d-8513-f289-5146-546c1f747e10@redhat.com> (raw)
In-Reply-To: <e60ea973-d323-1d4d-c03b-0ee4779735c4@sec.uni-stuttgart.de>


On 9/7/23 00:58, Sebastian Hasler wrote:
> While reviewing the implementation of __fh_to_dentry (in the CephFS 
> client), I noticed a possible race condition.
>
> Linux has a syscall linkat(2) which allows, given an open file 
> descriptor, to create a link for the file. So an inode that is 
> unlinked can become linked.
>
> Now the problem: The line ((inode->i_nlink == 0) && 
> !__ceph_is_file_opened(ci)) performs two checks. If, in between those 
> checks, the file goes from the unlinked and open state to the linked 
> and closed state, then we return -ESTALE even though the inode is 
> linked. I don't think this is the intended behavior. I guess this 
> (going from unlinked and open to linked and closed) can happen when a 
> concurrent process calls linkat() and then close().
>
Hi Sebastian,

Thanks for your reporting.

int linkat(int olddirfd, const char *oldpath, int newdirfd, const char 
*newpath, int flags);

BTW, for "an open file descripter", do you mean "olddirfd" ? Because 
"olddirfd" is a dir's open file descripter, how is that possible it can 
become linked again ?

Correct me if I'm misreading it.

Thanks

- Xiubo


  reply	other threads:[~2023-09-07  2:06 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-04  8:06 [PATCH] ceph: fail the open_by_handle_at() if the dentry is being unlinked xiubli
2022-08-04 16:25 ` Jeff Layton
2023-09-06 16:58 ` Sebastian Hasler
2023-09-07  2:05   ` Xiubo Li [this message]
2023-09-07 11:57     ` Sebastian Hasler
2023-09-11  3:21       ` Xiubo Li
2023-09-11 10:07         ` Sebastian Hasler
2023-09-12 12:51           ` Xiubo Li

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=3f6b622d-8513-f289-5146-546c1f747e10@redhat.com \
    --to=xiubli@redhat.com \
    --cc=ceph-devel@vger.kernel.org \
    --cc=sebastian.hasler@sec.uni-stuttgart.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.