linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: NeilBrown <neilb@ownmail.net>
To: "Amir Goldstein" <amir73il@gmail.com>
Cc: "Alexander Viro" <viro@zeniv.linux.org.uk>,
	"Christian Brauner" <brauner@kernel.org>,
	"Jeff Layton" <jlayton@kernel.org>, "Jan Kara" <jack@suse.cz>,
	linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH 11/11] ecryptfs: use new start_creaing/start_removing APIs
Date: Mon, 29 Sep 2025 15:26:27 +1000	[thread overview]
Message-ID: <175912358745.1696783.16384196748395150231@noble.neil.brown.name> (raw)
In-Reply-To: <CAOQ4uxjkJ4dvOkHHgSJV61ZGdCYOxc8JJ+C0EOZAG49XWKN3Pw@mail.gmail.com>

On Sun, 28 Sep 2025, Amir Goldstein wrote:
> On Fri, Sep 26, 2025 at 4:51 AM NeilBrown <neilb@ownmail.net> wrote:
> >
> > From: NeilBrown <neil@brown.name>
> >
> > This requires the addition of start_creating_dentry().
> >
...
> > @@ -186,10 +190,12 @@ ecryptfs_do_create(struct inode *directory_inode,
> >         struct inode *lower_dir;
> >         struct inode *inode;
> >
> > -       rc = lock_parent(ecryptfs_dentry, &lower_dentry, &lower_dir);
> > -       if (!rc)
> > -               rc = vfs_create(&nop_mnt_idmap, lower_dir,
> > -                               lower_dentry, mode, true);
> > +       lower_dentry = ecryptfs_start_creating_dentry(ecryptfs_dentry);
> > +       if (IS_ERR(lower_dentry))
> > +               return ERR_CAST(lower_dentry);
> > +       lower_dir = lower_dentry->d_parent->d_inode;
> > +       rc = vfs_create(&nop_mnt_idmap, lower_dir,
> > +                       lower_dentry, mode, true);
> >         if (rc) {
> >                 printk(KERN_ERR "%s: Failure to create dentry in lower fs; "
> >                        "rc = [%d]\n", __func__, rc);
> > @@ -205,7 +211,7 @@ ecryptfs_do_create(struct inode *directory_inode,
> >         fsstack_copy_attr_times(directory_inode, lower_dir);
> >         fsstack_copy_inode_size(directory_inode, lower_dir);
> >  out_lock:
> > -       inode_unlock(lower_dir);
> > +       end_creating(lower_dentry, NULL);
> 
> These calls were surprising to me.
> I did not recall any documentation that @parent could be NULL
> when calling end_creating(). In fact, the documentation specifically
> says that it should be the parent used for start_creating().

I've updated the documentation for end_creating() say that the parent is
not needed when vfs_mkdir() wasn't used.

> 
> So either introduce end_creating_dentry(), which makes it clear
> that it does not take an ERR_PTR child,

it would be end_creating_not_mkdir() :-)

> Or add WARN_ON to end_creating() in case it is called with NULL
> parent and an ERR_PTR child to avoid dereferencing parent->d_inode
> in that case.

I don't think a WARN_ON is particularly useful immediately before a
NULL-pointer dereference.

Thanks for highlighting this - clarification of the documentation is
needed.

NeilBrown


  reply	other threads:[~2025-09-29  5:26 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-26  2:49 [PATCH 00/11] Create APIs to centralise locking for directory ops NeilBrown
2025-09-26  2:49 ` [PATCH 01/11] debugfs: rename end_creating() to debugfs_end_creating() NeilBrown
2025-09-27  9:13   ` Amir Goldstein
2025-09-27 11:29   ` Jeff Layton
2025-09-26  2:49 ` [PATCH 02/11] VFS: introduce start_dirop() and end_dirop() NeilBrown
2025-09-26 16:41   ` Amir Goldstein
2025-09-27 11:32     ` NeilBrown
2025-09-26  2:49 ` [PATCH 03/11] VFS/nfsd/cachefiles/ovl: add start_creating() and end_creating() NeilBrown
2025-09-29 12:37   ` Jeff Layton
2025-09-30  5:37     ` NeilBrown
2025-09-30 10:19       ` Jeff Layton
2025-09-30  8:54   ` Amir Goldstein
2025-10-01  3:15     ` NeilBrown
2025-10-02 10:52       ` Amir Goldstein
2025-09-26  2:49 ` [PATCH 04/11] VFS/nfsd/cachefiles/ovl: introduce start_removing() and end_removing() NeilBrown
2025-09-27  9:12   ` Amir Goldstein
2025-10-02 17:02   ` Jeff Layton
2025-09-26  2:49 ` [PATCH 05/11] VFS: introduce start_creating_noperm() and start_removing_noperm() NeilBrown
2025-09-28 12:26   ` Amir Goldstein
2025-10-02 17:13   ` Jeff Layton
2025-09-26  2:49 ` [PATCH 06/11] VFS: introduce start_removing_dentry() NeilBrown
2025-09-27  9:32   ` Amir Goldstein
2025-09-27 11:55     ` NeilBrown
2025-10-02 17:19   ` Jeff Layton
2025-09-26  2:49 ` [PATCH 07/11] VFS: add start_creating_killable() and start_removing_killable() NeilBrown
2025-09-28 12:05   ` Amir Goldstein
2025-09-29  1:44     ` NeilBrown
2025-09-26  2:49 ` [PATCH 08/11] VFS/nfsd/ovl: introduce start_renaming() and end_renaming() NeilBrown
2025-09-29 11:23   ` Amir Goldstein
2025-09-26  2:49 ` [PATCH 09/11] VFS/ovl/smb: introduce start_renaming_dentry() NeilBrown
2025-09-26 15:43   ` kernel test robot
2025-09-26 17:17   ` kernel test robot
2025-09-30  7:08   ` Amir Goldstein
2025-10-01  1:45     ` NeilBrown
2025-10-02 10:56       ` Amir Goldstein
2025-10-01  4:35     ` NeilBrown
2025-09-26  2:49 ` [PATCH 10/11] Add start_renaming_two_dentrys() NeilBrown
2025-09-30  7:46   ` Amir Goldstein
2025-10-01  4:14     ` NeilBrown
2025-09-26  2:49 ` [PATCH 11/11] ecryptfs: use new start_creaing/start_removing APIs NeilBrown
2025-09-26 16:03   ` kernel test robot
2025-09-28 12:50   ` Amir Goldstein
2025-09-29  5:26     ` NeilBrown [this message]
2025-09-29  7:53       ` Amir Goldstein
2025-10-01  1:31         ` NeilBrown
2025-10-02 10:25           ` Amir Goldstein
2025-09-26 15:47 ` [PATCH 00/11] Create APIs to centralise locking for directory ops Amir Goldstein
2025-09-27 11:20   ` NeilBrown
2025-10-01  5:04     ` NeilBrown

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=175912358745.1696783.16384196748395150231@noble.neil.brown.name \
    --to=neilb@ownmail.net \
    --cc=amir73il@gmail.com \
    --cc=brauner@kernel.org \
    --cc=jack@suse.cz \
    --cc=jlayton@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=neil@brown.name \
    --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;
as well as URLs for NNTP newsgroup(s).