lkml.org 
[lkml]   [2021]   [Oct]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Subject[PATCH 21/67] cachefiles: Prevent inode from going away when burying a dentry
    From
    Date
    When deleting a file, we want to make sure that the inode doesn't get
    detached from it (leading to ->d_inode being cleared) as we may still want
    to touch the inode afterwards (we want to clear the belongs-to-kernel flag
    and we may have the dentry referred to by a file struct).

    Do this by getting an extra ref on the dentry around the vfs_unlink() call
    so that d_delete() doesn't see the refcount == 1.

    Signed-off-by: David Howells <dhowells@redhat.com>
    ---

    fs/cachefiles/namei.c | 2 ++
    1 file changed, 2 insertions(+)

    diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
    index 4bd31be3be30..04c767624e3d 100644
    --- a/fs/cachefiles/namei.c
    +++ b/fs/cachefiles/namei.c
    @@ -106,7 +106,9 @@ static int cachefiles_bury_object(struct cachefiles_cache *cache,
    cachefiles_io_error(cache, "Unlink security error");
    } else {
    trace_cachefiles_unlink(object, rep, why);
    + dget(rep);
    ret = vfs_unlink(&init_user_ns, d_inode(dir), rep, NULL);
    + dput(rep);
    }

    inode_unlock(d_inode(dir));

    \
     
     \ /
      Last update: 2021-10-18 16:56    [W:4.155 / U:0.032 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site