From patchwork Fri Jun 22 21:18:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Goldwyn Rodrigues X-Patchwork-Id: 10483053 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1D60D6023A for ; Fri, 22 Jun 2018 21:19:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 01D9D28FD9 for ; Fri, 22 Jun 2018 21:19:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E91DB2903C; Fri, 22 Jun 2018 21:19:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 11C5528FD9 for ; Fri, 22 Jun 2018 21:19:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932973AbeFVVTR (ORCPT ); Fri, 22 Jun 2018 17:19:17 -0400 Received: from mx2.suse.de ([195.135.220.15]:39518 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932918AbeFVVTQ (ORCPT ); Fri, 22 Jun 2018 17:19:16 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext-too.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 991B6AE86; Fri, 22 Jun 2018 21:19:14 +0000 (UTC) From: Goldwyn Rodrigues To: linux-fsdevel@vger.kernel.org, viro@ZenIV.linux.org.uk Cc: hch@infradead.org, Goldwyn Rodrigues Subject: [PATCH 4/4] VFS: eliminate d_backing_inode() Date: Fri, 22 Jun 2018 16:18:58 -0500 Message-Id: <20180622211858.31436-5-rgoldwyn@suse.de> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180622211858.31436-1-rgoldwyn@suse.de> References: <20180622211858.31436-1-rgoldwyn@suse.de> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Goldwyn Rodrigues d_backing_inode() returns dentry->d_inode, just as d_inode() Convert all d_backing_inode() to d_inode(). Though this patch is big, it just changes all calls of d_backing_inode() to d_inode(). Let me know if this needs to be split. Signed-off-by: Goldwyn Rodrigues --- fs/block_dev.c | 2 +- fs/cachefiles/bind.c | 6 ++-- fs/cachefiles/interface.c | 4 +-- fs/cachefiles/namei.c | 56 +++++++++++++++++------------------ fs/cachefiles/rdwr.c | 14 ++++----- fs/cachefiles/security.c | 6 ++-- fs/cachefiles/xattr.c | 26 ++++++++-------- fs/namei.c | 14 ++++----- fs/open.c | 6 ++-- fs/posix_acl.c | 2 +- fs/stat.c | 4 +-- fs/udf/symlink.c | 2 +- include/linux/dcache.h | 19 +----------- kernel/audit_tree.c | 4 +-- kernel/audit_watch.c | 10 +++---- kernel/auditsc.c | 6 ++-- kernel/bpf/inode.c | 4 +-- net/unix/af_unix.c | 6 ++-- net/unix/diag.c | 2 +- security/apparmor/file.c | 6 ++-- security/apparmor/lsm.c | 10 +++---- security/commoncap.c | 8 ++--- security/integrity/evm/evm_crypto.c | 4 +-- security/integrity/evm/evm_main.c | 14 ++++----- security/integrity/ima/ima_appraise.c | 8 ++--- security/lsm_audit.c | 4 +-- security/security.c | 48 +++++++++++++++--------------- security/selinux/hooks.c | 18 +++++------ security/smack/smack_lsm.c | 46 ++++++++++++++-------------- security/tomoyo/condition.c | 2 +- security/tomoyo/realpath.c | 10 +++---- 31 files changed, 177 insertions(+), 194 deletions(-) diff --git a/fs/block_dev.c b/fs/block_dev.c index 0dd87aaeb39a..56a3a0ba4a03 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -2086,7 +2086,7 @@ struct block_device *lookup_bdev(const char *pathname) if (error) return ERR_PTR(error); - inode = d_backing_inode(path.dentry); + inode = d_inode(path.dentry); error = -ENOTBLK; if (!S_ISBLK(inode->i_mode)) goto fail; diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c index d9f001078e08..2e83f97b21d9 100644 --- a/fs/cachefiles/bind.c +++ b/fs/cachefiles/bind.c @@ -125,9 +125,9 @@ static int cachefiles_daemon_add_cache(struct cachefiles_cache *cache) /* check parameters */ ret = -EOPNOTSUPP; if (d_is_negative(root) || - !d_backing_inode(root)->i_op->lookup || - !d_backing_inode(root)->i_op->mkdir || - !(d_backing_inode(root)->i_opflags & IOP_XATTR) || + !d_inode(root)->i_op->lookup || + !d_inode(root)->i_op->mkdir || + !(d_inode(root)->i_opflags & IOP_XATTR) || !root->d_sb->s_op->statfs || !root->d_sb->s_op->sync_fs) goto error_unsupported; diff --git a/fs/cachefiles/interface.c b/fs/cachefiles/interface.c index 222bc5d8b62c..6e052db171f9 100644 --- a/fs/cachefiles/interface.c +++ b/fs/cachefiles/interface.c @@ -295,7 +295,7 @@ static void cachefiles_drop_object(struct fscache_object *_object) _object != cache->cache.fsdef ) { _debug("- retire object OBJ%x", object->fscache.debug_id); - inode = d_backing_inode(object->dentry); + inode = d_inode(object->dentry); if (inode) i_blocks = inode->i_blocks; @@ -460,7 +460,7 @@ static int cachefiles_attr_changed(struct fscache_object *_object) fscache_set_store_limit(&object->fscache, ni_size); - oi_size = i_size_read(d_backing_inode(object->backer)); + oi_size = i_size_read(d_inode(object->backer)); if (oi_size == ni_size) return 0; diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c index ab0bbe93b398..c9a6c5b7ccd5 100644 --- a/fs/cachefiles/namei.c +++ b/fs/cachefiles/namei.c @@ -262,7 +262,7 @@ void cachefiles_mark_object_inactive(struct cachefiles_cache *cache, blkcnt_t i_blocks) { struct dentry *dentry = object->dentry; - struct inode *inode = d_backing_inode(dentry); + struct inode *inode = d_inode(dentry); trace_cachefiles_mark_inactive(object, dentry, inode); @@ -445,7 +445,7 @@ int cachefiles_delete_object(struct cachefiles_cache *cache, _enter(",OBJ%x{%p}", object->fscache.debug_id, object->dentry); ASSERT(object->dentry); - ASSERT(d_backing_inode(object->dentry)); + ASSERT(d_inode(object->dentry)); ASSERT(object->dentry->d_parent); dir = dget_parent(object->dentry); @@ -505,7 +505,7 @@ int cachefiles_walk_to_object(struct cachefiles_object *parent, path.mnt = cache->mnt; ASSERT(parent->dentry); - ASSERT(d_backing_inode(parent->dentry)); + ASSERT(d_inode(parent->dentry)); if (!(d_is_dir(parent->dentry))) { // TODO: convert file to dir @@ -539,7 +539,7 @@ int cachefiles_walk_to_object(struct cachefiles_object *parent, goto lookup_error; } - inode = d_backing_inode(next); + inode = d_inode(next); trace_cachefiles_lookup(object, next, inode); _debug("next -> %p %s", next, inode ? "positive" : "negative"); @@ -577,14 +577,14 @@ int cachefiles_walk_to_object(struct cachefiles_object *parent, inode_unlock(d_inode(dir)); goto lookup_again; } - ASSERT(d_backing_inode(next)); + ASSERT(d_inode(next)); _debug("mkdir -> %p{%p{ino=%lu}}", - next, d_backing_inode(next), d_backing_inode(next)->i_ino); + next, d_inode(next), d_inode(next)->i_ino); } else if (!d_can_lookup(next)) { pr_err("inode %lu is not a directory\n", - d_backing_inode(next)->i_ino); + d_inode(next)->i_ino); ret = -ENOBUFS; goto error; } @@ -607,16 +607,16 @@ int cachefiles_walk_to_object(struct cachefiles_object *parent, if (ret < 0) goto create_error; - ASSERT(d_backing_inode(next)); + ASSERT(d_inode(next)); _debug("create -> %p{%p{ino=%lu}}", - next, d_backing_inode(next), d_backing_inode(next)->i_ino); + next, d_inode(next), d_inode(next)->i_ino); } else if (!d_can_lookup(next) && !d_is_reg(next) ) { pr_err("inode %lu is not a file or directory\n", - d_backing_inode(next)->i_ino); + d_inode(next)->i_ino); ret = -ENOBUFS; goto error; } @@ -693,7 +693,7 @@ int cachefiles_walk_to_object(struct cachefiles_object *parent, const struct address_space_operations *aops; ret = -EPERM; - aops = d_backing_inode(object->dentry)->i_mapping->a_ops; + aops = d_inode(object->dentry)->i_mapping->a_ops; if (!aops->bmap) goto check_error; if (object->dentry->d_sb->s_blocksize > PAGE_SIZE) @@ -708,7 +708,7 @@ int cachefiles_walk_to_object(struct cachefiles_object *parent, object->new = 0; fscache_obtained_object(&object->fscache); - _leave(" = 0 [%lu]", d_backing_inode(object->dentry)->i_ino); + _leave(" = 0 [%lu]", d_inode(object->dentry)->i_ino); return 0; no_space_error: @@ -726,7 +726,7 @@ int cachefiles_walk_to_object(struct cachefiles_object *parent, check_error: _debug("check error %d", ret); cachefiles_mark_object_inactive( - cache, object, d_backing_inode(object->dentry)->i_blocks); + cache, object, d_inode(object->dentry)->i_blocks); release_dentry: dput(object->dentry); object->dentry = NULL; @@ -780,7 +780,7 @@ struct dentry *cachefiles_get_directory(struct cachefiles_cache *cache, } _debug("subdir -> %p %s", - subdir, d_backing_inode(subdir) ? "positive" : "negative"); + subdir, d_inode(subdir) ? "positive" : "negative"); /* we need to create the subdir if it doesn't exist yet */ if (d_is_negative(subdir)) { @@ -803,18 +803,18 @@ struct dentry *cachefiles_get_directory(struct cachefiles_cache *cache, dput(subdir); goto retry; } - ASSERT(d_backing_inode(subdir)); + ASSERT(d_inode(subdir)); _debug("mkdir -> %p{%p{ino=%lu}}", subdir, - d_backing_inode(subdir), - d_backing_inode(subdir)->i_ino); + d_inode(subdir), + d_inode(subdir)->i_ino); } inode_unlock(d_inode(dir)); /* we need to make sure the subdir is a directory */ - ASSERT(d_backing_inode(subdir)); + ASSERT(d_inode(subdir)); if (!d_can_lookup(subdir)) { pr_err("%s is not a directory\n", dirname); @@ -823,16 +823,16 @@ struct dentry *cachefiles_get_directory(struct cachefiles_cache *cache, } ret = -EPERM; - if (!(d_backing_inode(subdir)->i_opflags & IOP_XATTR) || - !d_backing_inode(subdir)->i_op->lookup || - !d_backing_inode(subdir)->i_op->mkdir || - !d_backing_inode(subdir)->i_op->create || - !d_backing_inode(subdir)->i_op->rename || - !d_backing_inode(subdir)->i_op->rmdir || - !d_backing_inode(subdir)->i_op->unlink) + if (!(d_inode(subdir)->i_opflags & IOP_XATTR) || + !d_inode(subdir)->i_op->lookup || + !d_inode(subdir)->i_op->mkdir || + !d_inode(subdir)->i_op->create || + !d_inode(subdir)->i_op->rename || + !d_inode(subdir)->i_op->rmdir || + !d_inode(subdir)->i_op->unlink) goto check_error; - _leave(" = [%lu]", d_backing_inode(subdir)->i_ino); + _leave(" = [%lu]", d_inode(subdir)->i_ino); return subdir; check_error: @@ -887,7 +887,7 @@ static struct dentry *cachefiles_check_active(struct cachefiles_cache *cache, goto lookup_error; //_debug("victim -> %p %s", - // victim, d_backing_inode(victim) ? "positive" : "negative"); + // victim, d_inode(victim) ? "positive" : "negative"); /* if the object is no longer there then we probably retired the object * at the netfs's request whilst the cull was in progress @@ -964,7 +964,7 @@ int cachefiles_cull(struct cachefiles_cache *cache, struct dentry *dir, return PTR_ERR(victim); _debug("victim -> %p %s", - victim, d_backing_inode(victim) ? "positive" : "negative"); + victim, d_inode(victim) ? "positive" : "negative"); /* okay... the victim is not being used so we can cull it * - start by marking it as stale diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c index 5082c8a49686..67efcf60a38c 100644 --- a/fs/cachefiles/rdwr.c +++ b/fs/cachefiles/rdwr.c @@ -74,12 +74,12 @@ static int cachefiles_read_waiter(wait_queue_entry_t *wait, unsigned mode, static int cachefiles_read_reissue(struct cachefiles_object *object, struct cachefiles_one_read *monitor) { - struct address_space *bmapping = d_backing_inode(object->backer)->i_mapping; + struct address_space *bmapping = d_inode(object->backer)->i_mapping; struct page *backpage = monitor->back_page, *backpage2; int ret; _enter("{ino=%lx},{%lx,%lx}", - d_backing_inode(object->backer)->i_ino, + d_inode(object->backer)->i_ino, backpage->index, backpage->flags); /* skip if the page was truncated away completely */ @@ -157,7 +157,7 @@ static void cachefiles_read_copier(struct fscache_operation *_op) object = container_of(op->op.object, struct cachefiles_object, fscache); - _enter("{ino=%lu}", d_backing_inode(object->backer)->i_ino); + _enter("{ino=%lu}", d_inode(object->backer)->i_ino); max = 8; spin_lock_irq(&object->work_lock); @@ -247,7 +247,7 @@ static int cachefiles_read_backing_file_one(struct cachefiles_object *object, init_waitqueue_func_entry(&monitor->monitor, cachefiles_read_waiter); /* attempt to get hold of the backing page */ - bmapping = d_backing_inode(object->backer)->i_mapping; + bmapping = d_inode(object->backer)->i_mapping; newpage = NULL; for (;;) { @@ -407,7 +407,7 @@ int cachefiles_read_or_alloc_page(struct fscache_retrieval *op, if (!object->backer) goto enobufs; - inode = d_backing_inode(object->backer); + inode = d_inode(object->backer); ASSERT(S_ISREG(inode->i_mode)); ASSERT(inode->i_mapping->a_ops->bmap); ASSERT(inode->i_mapping->a_ops->readpages); @@ -464,7 +464,7 @@ static int cachefiles_read_backing_file(struct cachefiles_object *object, struct list_head *list) { struct cachefiles_one_read *monitor = NULL; - struct address_space *bmapping = d_backing_inode(object->backer)->i_mapping; + struct address_space *bmapping = d_inode(object->backer)->i_mapping; struct page *newpage = NULL, *netpage, *_n, *backpage = NULL; int ret = 0; @@ -700,7 +700,7 @@ int cachefiles_read_or_alloc_pages(struct fscache_retrieval *op, if (cachefiles_has_space(cache, 0, *nr_pages) < 0) space = 0; - inode = d_backing_inode(object->backer); + inode = d_inode(object->backer); ASSERT(S_ISREG(inode->i_mode)); ASSERT(inode->i_mapping->a_ops->bmap); ASSERT(inode->i_mapping->a_ops->readpages); diff --git a/fs/cachefiles/security.c b/fs/cachefiles/security.c index 31bbc0528b11..51d58e5d4b2f 100644 --- a/fs/cachefiles/security.c +++ b/fs/cachefiles/security.c @@ -55,14 +55,14 @@ static int cachefiles_check_cache_dir(struct cachefiles_cache *cache, { int ret; - ret = security_inode_mkdir(d_backing_inode(root), root, 0); + ret = security_inode_mkdir(d_inode(root), root, 0); if (ret < 0) { pr_err("Security denies permission to make dirs: error %d", ret); return ret; } - ret = security_inode_create(d_backing_inode(root), root, 0); + ret = security_inode_create(d_inode(root), root, 0); if (ret < 0) pr_err("Security denies permission to create files: error %d", ret); @@ -95,7 +95,7 @@ int cachefiles_determine_cache_security(struct cachefiles_cache *cache, /* use the cache root dir's security context as the basis with * which create files */ - ret = set_create_files_as(new, d_backing_inode(root)); + ret = set_create_files_as(new, d_inode(root)); if (ret < 0) { abort_creds(new); cachefiles_begin_secure(cache, _saved_cred); diff --git a/fs/cachefiles/xattr.c b/fs/cachefiles/xattr.c index 0a29a00aed2e..6a1abb1d9eec 100644 --- a/fs/cachefiles/xattr.c +++ b/fs/cachefiles/xattr.c @@ -33,7 +33,7 @@ int cachefiles_check_object_type(struct cachefiles_object *object) int ret; ASSERT(dentry); - ASSERT(d_backing_inode(dentry)); + ASSERT(d_inode(dentry)); if (!object->fscache.cookie) strcpy(type, "C3"); @@ -52,7 +52,7 @@ int cachefiles_check_object_type(struct cachefiles_object *object) if (ret != -EEXIST) { pr_err("Can't set xattr on %pd [%lu] (err %d)\n", - dentry, d_backing_inode(dentry)->i_ino, + dentry, d_inode(dentry)->i_ino, -ret); goto error; } @@ -64,7 +64,7 @@ int cachefiles_check_object_type(struct cachefiles_object *object) goto bad_type_length; pr_err("Can't read xattr on %pd [%lu] (err %d)\n", - dentry, d_backing_inode(dentry)->i_ino, + dentry, d_inode(dentry)->i_ino, -ret); goto error; } @@ -84,14 +84,14 @@ int cachefiles_check_object_type(struct cachefiles_object *object) bad_type_length: pr_err("Cache object %lu type xattr length incorrect\n", - d_backing_inode(dentry)->i_ino); + d_inode(dentry)->i_ino); ret = -EIO; goto error; bad_type: xtype[2] = 0; pr_err("Cache object %pd [%lu] type %s not %s\n", - dentry, d_backing_inode(dentry)->i_ino, + dentry, d_inode(dentry)->i_ino, xtype, type); ret = -EIO; goto error; @@ -167,7 +167,7 @@ int cachefiles_check_auxdata(struct cachefiles_object *object) int ret; ASSERT(dentry); - ASSERT(d_backing_inode(dentry)); + ASSERT(d_inode(dentry)); ASSERT(object->fscache.cookie->def->check_aux); auxbuf = kmalloc(sizeof(struct cachefiles_xattr) + 512, GFP_KERNEL); @@ -183,7 +183,7 @@ int cachefiles_check_auxdata(struct cachefiles_object *object) xlen--; validity = fscache_check_aux(&object->fscache, &auxbuf->data, xlen, - i_size_read(d_backing_inode(dentry))); + i_size_read(d_inode(dentry))); if (validity != FSCACHE_CHECKAUX_OKAY) goto error; @@ -207,7 +207,7 @@ int cachefiles_check_object_xattr(struct cachefiles_object *object, _enter("%p,#%d", object, auxdata->len); ASSERT(dentry); - ASSERT(d_backing_inode(dentry)); + ASSERT(d_inode(dentry)); auxbuf = kmalloc(sizeof(struct cachefiles_xattr) + 512, cachefiles_gfp); if (!auxbuf) { @@ -228,7 +228,7 @@ int cachefiles_check_object_xattr(struct cachefiles_object *object, cachefiles_io_error_obj(object, "Can't read xattr on %lu (err %d)", - d_backing_inode(dentry)->i_ino, -ret); + d_inode(dentry)->i_ino, -ret); goto error; } @@ -253,7 +253,7 @@ int cachefiles_check_object_xattr(struct cachefiles_object *object, result = fscache_check_aux(&object->fscache, &auxbuf->data, dlen, - i_size_read(d_backing_inode(dentry))); + i_size_read(d_inode(dentry))); switch (result) { /* entry okay as is */ @@ -280,7 +280,7 @@ int cachefiles_check_object_xattr(struct cachefiles_object *object, cachefiles_io_error_obj(object, "Can't update xattr on %lu" " (error %d)", - d_backing_inode(dentry)->i_ino, -ret); + d_inode(dentry)->i_ino, -ret); goto error; } } @@ -295,7 +295,7 @@ int cachefiles_check_object_xattr(struct cachefiles_object *object, bad_type_length: pr_err("Cache object %lu xattr length incorrect\n", - d_backing_inode(dentry)->i_ino); + d_inode(dentry)->i_ino); ret = -EIO; goto error; @@ -320,7 +320,7 @@ int cachefiles_remove_object_xattr(struct cachefiles_cache *cache, cachefiles_io_error(cache, "Can't remove xattr from %lu" " (error %d)", - d_backing_inode(dentry)->i_ino, -ret); + d_inode(dentry)->i_ino, -ret); } _leave(" = %d", ret); diff --git a/fs/namei.c b/fs/namei.c index 734cef54fdf8..4a8620dfdcae 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -1538,7 +1538,7 @@ static int lookup_fast(struct nameidata *nd, * This sequence count validates that the inode matches * the dentry name information from lookup. */ - *inode = d_backing_inode(dentry); + *inode = d_inode(dentry); negative = d_is_negative(dentry); if (unlikely(read_seqcount_retry(&dentry->d_seq, seq))) return -ECHILD; @@ -1593,7 +1593,7 @@ static int lookup_fast(struct nameidata *nd, path->dentry = dentry; err = follow_managed(path, nd); if (likely(err > 0)) - *inode = d_backing_inode(path->dentry); + *inode = d_inode(path->dentry); return err; } @@ -1782,7 +1782,7 @@ static int walk_component(struct nameidata *nd, int flags) } seq = 0; /* we are already out of RCU mode */ - inode = d_backing_inode(path.dentry); + inode = d_inode(path.dentry); } return step_into(nd, &path, flags, inode, seq); @@ -2257,7 +2257,7 @@ static int handle_lookup_down(struct nameidata *nd) err = follow_managed(&path, nd); if (unlikely(err < 0)) return err; - inode = d_backing_inode(path.dentry); + inode = d_inode(path.dentry); seq = 0; } path_to_nameidata(&path, nd); @@ -2649,7 +2649,7 @@ mountpoint_last(struct nameidata *nd) return -ENOENT; } path.mnt = nd->path.mnt; - return step_into(nd, &path, 0, d_backing_inode(path.dentry), 0); + return step_into(nd, &path, 0, d_inode(path.dentry), 0); } /** @@ -2770,7 +2770,7 @@ EXPORT_SYMBOL(__check_sticky); */ static int may_delete(struct inode *dir, struct dentry *victim, bool isdir) { - struct inode *inode = d_backing_inode(victim); + struct inode *inode = d_inode(victim); int error; if (d_is_negative(victim)) @@ -3365,7 +3365,7 @@ static int do_last(struct nameidata *nd, } seq = 0; /* out of RCU mode, so the value doesn't matter */ - inode = d_backing_inode(path.dentry); + inode = d_inode(path.dentry); finish_lookup: error = step_into(nd, &path, 0, inode, seq); if (unlikely(error)) diff --git a/fs/open.c b/fs/open.c index d0e955b558ad..216aa6c95987 100644 --- a/fs/open.c +++ b/fs/open.c @@ -390,7 +390,7 @@ long do_faccessat(int dfd, const char __user *filename, int mode) if (res) goto out; - inode = d_backing_inode(path.dentry); + inode = d_inode(path.dentry); if ((mode & MAY_EXEC) && S_ISREG(inode->i_mode)) { /* @@ -854,7 +854,7 @@ int finish_open(struct file *file, struct dentry *dentry, BUG_ON(*opened & FILE_OPENED); /* once it's opened, it's opened */ file->f_path.dentry = dentry; - error = do_dentry_open(file, d_backing_inode(dentry), open, + error = do_dentry_open(file, d_inode(dentry), open, current_cred()); if (!error) *opened |= FILE_OPENED; @@ -905,7 +905,7 @@ int vfs_open(const struct path *path, struct file *file, return PTR_ERR(dentry); file->f_path = *path; - return do_dentry_open(file, d_backing_inode(dentry), NULL, cred); + return do_dentry_open(file, d_inode(dentry), NULL, cred); } struct file *dentry_open(const struct path *path, int flags, diff --git a/fs/posix_acl.c b/fs/posix_acl.c index 2fd0fde16fe1..d4e5cfc52aae 100644 --- a/fs/posix_acl.c +++ b/fs/posix_acl.c @@ -897,7 +897,7 @@ posix_acl_xattr_set(const struct xattr_handler *handler, static bool posix_acl_xattr_list(struct dentry *dentry) { - return IS_POSIXACL(d_backing_inode(dentry)); + return IS_POSIXACL(d_inode(dentry)); } const struct xattr_handler posix_acl_access_xattr_handler = { diff --git a/fs/stat.c b/fs/stat.c index f8e6fb2c3657..dcdb7724c81c 100644 --- a/fs/stat.c +++ b/fs/stat.c @@ -69,7 +69,7 @@ EXPORT_SYMBOL(generic_fillattr); int vfs_getattr_nosec(const struct path *path, struct kstat *stat, u32 request_mask, unsigned int query_flags) { - struct inode *inode = d_backing_inode(path->dentry); + struct inode *inode = d_inode(path->dentry); memset(stat, 0, sizeof(*stat)); stat->result_mask |= STATX_BASIC_STATS; @@ -393,7 +393,7 @@ static int do_readlinkat(int dfd, const char __user *pathname, retry: error = user_path_at_empty(dfd, pathname, lookup_flags, &path, &empty); if (!error) { - struct inode *inode = d_backing_inode(path.dentry); + struct inode *inode = d_inode(path.dentry); error = empty ? -ENOENT : -EINVAL; /* diff --git a/fs/udf/symlink.c b/fs/udf/symlink.c index 6023c97c6da2..9834ddb17e0b 100644 --- a/fs/udf/symlink.c +++ b/fs/udf/symlink.c @@ -156,7 +156,7 @@ static int udf_symlink_getattr(const struct path *path, struct kstat *stat, u32 request_mask, unsigned int flags) { struct dentry *dentry = path->dentry; - struct inode *inode = d_backing_inode(dentry); + struct inode *inode = d_inode(dentry); struct page *page; generic_fillattr(inode, stat); diff --git a/include/linux/dcache.h b/include/linux/dcache.h index cf4b37b91a1b..1177b3b74558 100644 --- a/include/linux/dcache.h +++ b/include/linux/dcache.h @@ -512,23 +512,6 @@ static inline struct inode *d_inode_rcu(const struct dentry *dentry) return READ_ONCE(dentry->d_inode); } -/** - * d_backing_inode - Get upper or lower inode we should be using - * @upper: The upper layer - * - * This is the helper that should be used to get at the inode that will be used - * if this dentry were to be opened as a file. The inode may be on the upper - * dentry or it may be on a lower dentry pinned by the upper. - * - * Normal filesystems should not use this to access their own inodes. - */ -static inline struct inode *d_backing_inode(const struct dentry *upper) -{ - struct inode *inode = upper->d_inode; - - return inode; -} - /* d_real() flags */ #define D_REAL_UPPER 0x2 /* return upper dentry or NULL if non-upper */ @@ -564,7 +547,7 @@ static inline struct dentry *d_real(struct dentry *dentry, static inline struct inode *d_real_inode(const struct dentry *dentry) { /* This usage of d_real() results in const dentry */ - return d_backing_inode(d_real((struct dentry *) dentry, NULL, 0, 0)); + return d_inode(d_real((struct dentry *) dentry, NULL, 0, 0)); } struct name_snapshot { diff --git a/kernel/audit_tree.c b/kernel/audit_tree.c index c99ebaae5abc..1f82bb37e245 100644 --- a/kernel/audit_tree.c +++ b/kernel/audit_tree.c @@ -620,7 +620,7 @@ int audit_remove_tree_rule(struct audit_krule *rule) static int compare_root(struct vfsmount *mnt, void *arg) { - return inode_to_key(d_backing_inode(mnt->mnt_root)) == + return inode_to_key(d_inode(mnt->mnt_root)) == (unsigned long)arg; } @@ -694,7 +694,7 @@ void audit_put_tree(struct audit_tree *tree) static int tag_mount(struct vfsmount *mnt, void *arg) { - return tag_chunk(d_backing_inode(mnt->mnt_root), arg); + return tag_chunk(d_inode(mnt->mnt_root), arg); } /* diff --git a/kernel/audit_watch.c b/kernel/audit_watch.c index c17c0c268436..391eae401671 100644 --- a/kernel/audit_watch.c +++ b/kernel/audit_watch.c @@ -148,7 +148,7 @@ int audit_watch_compare(struct audit_watch *watch, unsigned long ino, dev_t dev) /* Initialize a parent watch entry. */ static struct audit_parent *audit_init_parent(struct path *path) { - struct inode *inode = d_backing_inode(path->dentry); + struct inode *inode = d_inode(path->dentry); struct audit_parent *parent; int ret; @@ -365,11 +365,11 @@ static int audit_get_nd(struct audit_watch *watch, struct path *parent) struct dentry *d = kern_path_locked(watch->path, parent); if (IS_ERR(d)) return PTR_ERR(d); - inode_unlock(d_backing_inode(parent->dentry)); + inode_unlock(d_inode(parent->dentry)); if (d_is_positive(d)) { /* update watch filter fields */ watch->dev = d->d_sb->s_dev; - watch->ino = d_backing_inode(d)->i_ino; + watch->ino = d_inode(d)->i_ino; } dput(d); return 0; @@ -431,7 +431,7 @@ int audit_add_watch(struct audit_krule *krule, struct list_head **list) return ret; /* either find an old parent or attach a new one */ - parent = audit_find_parent(d_backing_inode(parent_path.dentry)); + parent = audit_find_parent(d_inode(parent_path.dentry)); if (!parent) { parent = audit_init_parent(&parent_path); if (IS_ERR(parent)) { @@ -486,7 +486,7 @@ static int audit_watch_handle_event(struct fsnotify_group *group, switch (data_type) { case (FSNOTIFY_EVENT_PATH): - inode = d_backing_inode(((const struct path *)data)->dentry); + inode = d_inode(((const struct path *)data)->dentry); break; case (FSNOTIFY_EVENT_INODE): inode = (const struct inode *)data; diff --git a/kernel/auditsc.c b/kernel/auditsc.c index ceb1c4596c51..2bb30b105f0e 100644 --- a/kernel/auditsc.c +++ b/kernel/auditsc.c @@ -1645,7 +1645,7 @@ static void handle_path(const struct dentry *dentry) rcu_read_lock(); seq = read_seqbegin(&rename_lock); for(;;) { - struct inode *inode = d_backing_inode(d); + struct inode *inode = d_inode(d); if (inode && unlikely(inode->i_fsnotify_marks)) { struct audit_chunk *chunk; chunk = audit_tree_lookup(inode); @@ -1770,7 +1770,7 @@ void __audit_inode(struct filename *name, const struct dentry *dentry, unsigned int flags) { struct audit_context *context = audit_context(); - struct inode *inode = d_backing_inode(dentry); + struct inode *inode = d_inode(dentry); struct audit_names *n; bool parent = flags & AUDIT_INODE_PARENT; @@ -1869,7 +1869,7 @@ void __audit_inode_child(struct inode *parent, const unsigned char type) { struct audit_context *context = audit_context(); - struct inode *inode = d_backing_inode(dentry); + struct inode *inode = d_inode(dentry); const char *dname = dentry->d_name.name; struct audit_names *n, *found_parent = NULL, *found_child = NULL; struct audit_entry *e; diff --git a/kernel/bpf/inode.c b/kernel/bpf/inode.c index 76efe9a183f5..d21953281d9f 100644 --- a/kernel/bpf/inode.c +++ b/kernel/bpf/inode.c @@ -456,7 +456,7 @@ static void *bpf_obj_do_get(const struct filename *pathname, if (ret) return ERR_PTR(ret); - inode = d_backing_inode(path.dentry); + inode = d_inode(path.dentry); ret = inode_permission(inode, ACC_MODE(flags)); if (ret) goto out; @@ -543,7 +543,7 @@ struct bpf_prog *bpf_prog_get_type_path(const char *name, enum bpf_prog_type typ int ret = kern_path(name, LOOKUP_FOLLOW, &path); if (ret) return ERR_PTR(ret); - prog = __get_prog_inode(d_backing_inode(path.dentry), type); + prog = __get_prog_inode(d_inode(path.dentry), type); if (!IS_ERR(prog)) touch_atime(&path); path_put(&path); diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index 95b02a71fd47..5bfa4b1254cb 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c @@ -316,7 +316,7 @@ static struct sock *unix_find_socket_byinode(struct inode *i) &unix_socket_table[i->i_ino & (UNIX_HASH_SIZE - 1)]) { struct dentry *dentry = unix_sk(s)->path.dentry; - if (dentry && d_backing_inode(dentry) == i) { + if (dentry && d_inode(dentry) == i) { sock_hold(s); goto found; } @@ -904,7 +904,7 @@ static struct sock *unix_find_other(struct net *net, err = kern_path(sunname->sun_path, LOOKUP_FOLLOW, &path); if (err) goto fail; - inode = d_backing_inode(path.dentry); + inode = d_inode(path.dentry); err = inode_permission(inode, MAY_WRITE); if (err) goto put_fail; @@ -1034,7 +1034,7 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) if (sun_path[0]) { addr->hash = UNIX_HASH_SIZE; - hash = d_backing_inode(path.dentry)->i_ino & (UNIX_HASH_SIZE - 1); + hash = d_inode(path.dentry)->i_ino & (UNIX_HASH_SIZE - 1); spin_lock(&unix_table_lock); u->path = path; list = &unix_socket_table[hash]; diff --git a/net/unix/diag.c b/net/unix/diag.c index 384c84e83462..c53ae21e20c1 100644 --- a/net/unix/diag.c +++ b/net/unix/diag.c @@ -25,7 +25,7 @@ static int sk_diag_dump_vfs(struct sock *sk, struct sk_buff *nlskb) if (dentry) { struct unix_diag_vfs uv = { - .udiag_vfs_ino = d_backing_inode(dentry)->i_ino, + .udiag_vfs_ino = d_inode(dentry)->i_ino, .udiag_vfs_dev = dentry->d_sb->s_dev, }; diff --git a/security/apparmor/file.c b/security/apparmor/file.c index 224b2fef93ca..0ab6f914c109 100644 --- a/security/apparmor/file.c +++ b/security/apparmor/file.c @@ -161,7 +161,7 @@ int aa_audit_file(struct aa_profile *profile, struct aa_perms *perms, */ static inline bool is_deleted(struct dentry *dentry) { - if (d_unlinked(dentry) && d_backing_inode(dentry)->i_nlink == 0) + if (d_unlinked(dentry) && d_inode(dentry)->i_nlink == 0) return 1; return 0; } @@ -470,8 +470,8 @@ int aa_path_link(struct aa_label *label, struct dentry *old_dentry, struct path link = { .mnt = new_dir->mnt, .dentry = new_dentry }; struct path target = { .mnt = new_dir->mnt, .dentry = old_dentry }; struct path_cond cond = { - d_backing_inode(old_dentry)->i_uid, - d_backing_inode(old_dentry)->i_mode + d_inode(old_dentry)->i_uid, + d_inode(old_dentry)->i_mode }; char *buffer = NULL, *buffer2 = NULL; struct aa_profile *profile; diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c index 74f17376202b..26a8f380e565 100644 --- a/security/apparmor/lsm.c +++ b/security/apparmor/lsm.c @@ -220,8 +220,8 @@ static int common_perm(const char *op, const struct path *path, u32 mask, */ static int common_perm_cond(const char *op, const struct path *path, u32 mask) { - struct path_cond cond = { d_backing_inode(path->dentry)->i_uid, - d_backing_inode(path->dentry)->i_mode + struct path_cond cond = { d_inode(path->dentry)->i_uid, + d_inode(path->dentry)->i_mode }; if (!path_mediated_fs(path->dentry)) @@ -261,7 +261,7 @@ static int common_perm_dir_dentry(const char *op, const struct path *dir, static int common_perm_rm(const char *op, const struct path *dir, struct dentry *dentry, u32 mask) { - struct inode *inode = d_backing_inode(dentry); + struct inode *inode = d_inode(dentry); struct path_cond cond = { }; if (!inode || !path_mediated_fs(dentry)) @@ -361,8 +361,8 @@ static int apparmor_path_rename(const struct path *old_dir, struct dentry *old_d .dentry = old_dentry }; struct path new_path = { .mnt = new_dir->mnt, .dentry = new_dentry }; - struct path_cond cond = { d_backing_inode(old_dentry)->i_uid, - d_backing_inode(old_dentry)->i_mode + struct path_cond cond = { d_inode(old_dentry)->i_uid, + d_inode(old_dentry)->i_mode }; error = aa_path_perm(OP_RENAME_SRC, label, &old_path, 0, diff --git a/security/commoncap.c b/security/commoncap.c index f4c33abd9959..148629912737 100644 --- a/security/commoncap.c +++ b/security/commoncap.c @@ -301,7 +301,7 @@ int cap_capset(struct cred *new, */ int cap_inode_need_killpriv(struct dentry *dentry) { - struct inode *inode = d_backing_inode(dentry); + struct inode *inode = d_inode(dentry); int error; error = __vfs_getxattr(dentry, inode, XATTR_NAME_CAPS, NULL, 0); @@ -486,7 +486,7 @@ int cap_convert_nscap(struct dentry *dentry, void **ivalue, size_t size) uid_t nsrootid; const struct vfs_cap_data *cap = *ivalue; __u32 magic, nsmagic; - struct inode *inode = d_backing_inode(dentry); + struct inode *inode = d_inode(dentry); struct user_namespace *task_ns = current_user_ns(), *fs_ns = inode->i_sb->s_user_ns; kuid_t rootid; @@ -577,7 +577,7 @@ static inline int bprm_caps_from_vfs_caps(struct cpu_vfs_cap_data *caps, */ int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps) { - struct inode *inode = d_backing_inode(dentry); + struct inode *inode = d_inode(dentry); __u32 magic_etc; unsigned tocopy, i; int size; @@ -960,7 +960,7 @@ int cap_inode_removexattr(struct dentry *dentry, const char *name) if (strcmp(name, XATTR_NAME_CAPS) == 0) { /* security.capability gets namespaced */ - struct inode *inode = d_backing_inode(dentry); + struct inode *inode = d_inode(dentry); if (!inode) return -EINVAL; if (!capable_wrt_inode_uidgid(inode, CAP_SETFCAP)) diff --git a/security/integrity/evm/evm_crypto.c b/security/integrity/evm/evm_crypto.c index b60524310855..54d85ebf807c 100644 --- a/security/integrity/evm/evm_crypto.c +++ b/security/integrity/evm/evm_crypto.c @@ -191,7 +191,7 @@ static int evm_calc_hmac_or_hash(struct dentry *dentry, size_t req_xattr_value_len, char type, char *digest) { - struct inode *inode = d_backing_inode(dentry); + struct inode *inode = d_inode(dentry); struct xattr_list *xattr; struct shash_desc *desc; size_t xattr_size = 0; @@ -302,7 +302,7 @@ static int evm_is_immutable(struct dentry *dentry, struct inode *inode) int evm_update_evmxattr(struct dentry *dentry, const char *xattr_name, const char *xattr_value, size_t xattr_value_len) { - struct inode *inode = d_backing_inode(dentry); + struct inode *inode = d_inode(dentry); struct evm_ima_xattr_data xattr_data; int rc = 0; diff --git a/security/integrity/evm/evm_main.c b/security/integrity/evm/evm_main.c index f9eff5041e4c..a60ee3f8e053 100644 --- a/security/integrity/evm/evm_main.c +++ b/security/integrity/evm/evm_main.c @@ -93,7 +93,7 @@ static bool evm_key_loaded(void) static int evm_find_protected_xattrs(struct dentry *dentry) { - struct inode *inode = d_backing_inode(dentry); + struct inode *inode = d_inode(dentry); struct xattr_list *xattr; int error; int count = 0; @@ -191,7 +191,7 @@ static enum integrity_status evm_verify_hmac(struct dentry *dentry, (const char *)xattr_data, xattr_len, calc.digest, sizeof(calc.digest)); if (!rc) { - inode = d_backing_inode(dentry); + inode = d_inode(dentry); if (xattr_data->type == EVM_XATTR_PORTABLE_DIGSIG) { if (iint) @@ -270,7 +270,7 @@ enum integrity_status evm_verifyxattr(struct dentry *dentry, return INTEGRITY_UNKNOWN; if (!iint) { - iint = integrity_iint_find(d_backing_inode(dentry)); + iint = integrity_iint_find(d_inode(dentry)); if (!iint) return INTEGRITY_UNKNOWN; } @@ -288,7 +288,7 @@ EXPORT_SYMBOL_GPL(evm_verifyxattr); */ static enum integrity_status evm_verify_current_integrity(struct dentry *dentry) { - struct inode *inode = d_backing_inode(dentry); + struct inode *inode = d_inode(dentry); if (!evm_key_loaded() || !S_ISREG(inode->i_mode) || evm_fixmode) return 0; @@ -329,7 +329,7 @@ static int evm_protect_xattr(struct dentry *dentry, const char *xattr_name, if (evm_status == INTEGRITY_NOXATTRS) { struct integrity_iint_cache *iint; - iint = integrity_iint_find(d_backing_inode(dentry)); + iint = integrity_iint_find(d_inode(dentry)); if (iint && (iint->flags & IMA_NEW_FILE)) return 0; @@ -346,7 +346,7 @@ static int evm_protect_xattr(struct dentry *dentry, const char *xattr_name, } out: if (evm_status != INTEGRITY_PASS) - integrity_audit_msg(AUDIT_INTEGRITY_METADATA, d_backing_inode(dentry), + integrity_audit_msg(AUDIT_INTEGRITY_METADATA, d_inode(dentry), dentry->d_name.name, "appraise_metadata", integrity_status_msg[evm_status], -EPERM, 0); @@ -485,7 +485,7 @@ int evm_inode_setattr(struct dentry *dentry, struct iattr *attr) if ((evm_status == INTEGRITY_PASS) || (evm_status == INTEGRITY_NOXATTRS)) return 0; - integrity_audit_msg(AUDIT_INTEGRITY_METADATA, d_backing_inode(dentry), + integrity_audit_msg(AUDIT_INTEGRITY_METADATA, d_inode(dentry), dentry->d_name.name, "appraise_metadata", integrity_status_msg[evm_status], -EPERM, 0); return -EPERM; diff --git a/security/integrity/ima/ima_appraise.c b/security/integrity/ima/ima_appraise.c index 8bd7a0733e51..1e57acd61398 100644 --- a/security/integrity/ima/ima_appraise.c +++ b/security/integrity/ima/ima_appraise.c @@ -217,7 +217,7 @@ int ima_appraise_measurement(enum ima_hooks func, static const char op[] = "appraise_data"; const char *cause = "unknown"; struct dentry *dentry = file_dentry(file); - struct inode *inode = d_backing_inode(dentry); + struct inode *inode = d_inode(dentry); enum integrity_status status = INTEGRITY_UNKNOWN; int rc = xattr_len, hash_start = 0; @@ -382,7 +382,7 @@ void ima_update_xattr(struct integrity_iint_cache *iint, struct file *file) */ void ima_inode_post_setattr(struct dentry *dentry) { - struct inode *inode = d_backing_inode(dentry); + struct inode *inode = d_inode(dentry); struct integrity_iint_cache *iint; int action; @@ -446,7 +446,7 @@ int ima_inode_setxattr(struct dentry *dentry, const char *xattr_name, if (result == 1) { if (!xattr_value_len || (xvalue->type >= IMA_XATTR_LAST)) return -EINVAL; - ima_reset_appraise_flags(d_backing_inode(dentry), + ima_reset_appraise_flags(d_inode(dentry), xvalue->type == EVM_IMA_XATTR_DIGSIG); result = 0; } @@ -459,7 +459,7 @@ int ima_inode_removexattr(struct dentry *dentry, const char *xattr_name) result = ima_protect_xattr(dentry, xattr_name, NULL, 0); if (result == 1) { - ima_reset_appraise_flags(d_backing_inode(dentry), 0); + ima_reset_appraise_flags(d_inode(dentry), 0); result = 0; } return result; diff --git a/security/lsm_audit.c b/security/lsm_audit.c index f84001019356..3c67f4d192e9 100644 --- a/security/lsm_audit.c +++ b/security/lsm_audit.c @@ -237,7 +237,7 @@ static void dump_common_audit_data(struct audit_buffer *ab, audit_log_d_path(ab, " path=", &a->u.path); - inode = d_backing_inode(a->u.path.dentry); + inode = d_inode(a->u.path.dentry); if (inode) { audit_log_format(ab, " dev="); audit_log_untrustedstring(ab, inode->i_sb->s_id); @@ -279,7 +279,7 @@ static void dump_common_audit_data(struct audit_buffer *ab, audit_log_format(ab, " name="); audit_log_untrustedstring(ab, a->u.dentry->d_name.name); - inode = d_backing_inode(a->u.dentry); + inode = d_inode(a->u.dentry); if (inode) { audit_log_format(ab, " dev="); audit_log_untrustedstring(ab, inode->i_sb->s_id); diff --git a/security/security.c b/security/security.c index 68f46d849abe..d44eafb8a393 100644 --- a/security/security.c +++ b/security/security.c @@ -517,7 +517,7 @@ EXPORT_SYMBOL(security_old_inode_init_security); int security_path_mknod(const struct path *dir, struct dentry *dentry, umode_t mode, unsigned int dev) { - if (unlikely(IS_PRIVATE(d_backing_inode(dir->dentry)))) + if (unlikely(IS_PRIVATE(d_inode(dir->dentry)))) return 0; return call_int_hook(path_mknod, 0, dir, dentry, mode, dev); } @@ -525,7 +525,7 @@ EXPORT_SYMBOL(security_path_mknod); int security_path_mkdir(const struct path *dir, struct dentry *dentry, umode_t mode) { - if (unlikely(IS_PRIVATE(d_backing_inode(dir->dentry)))) + if (unlikely(IS_PRIVATE(d_inode(dir->dentry)))) return 0; return call_int_hook(path_mkdir, 0, dir, dentry, mode); } @@ -533,14 +533,14 @@ EXPORT_SYMBOL(security_path_mkdir); int security_path_rmdir(const struct path *dir, struct dentry *dentry) { - if (unlikely(IS_PRIVATE(d_backing_inode(dir->dentry)))) + if (unlikely(IS_PRIVATE(d_inode(dir->dentry)))) return 0; return call_int_hook(path_rmdir, 0, dir, dentry); } int security_path_unlink(const struct path *dir, struct dentry *dentry) { - if (unlikely(IS_PRIVATE(d_backing_inode(dir->dentry)))) + if (unlikely(IS_PRIVATE(d_inode(dir->dentry)))) return 0; return call_int_hook(path_unlink, 0, dir, dentry); } @@ -549,7 +549,7 @@ EXPORT_SYMBOL(security_path_unlink); int security_path_symlink(const struct path *dir, struct dentry *dentry, const char *old_name) { - if (unlikely(IS_PRIVATE(d_backing_inode(dir->dentry)))) + if (unlikely(IS_PRIVATE(d_inode(dir->dentry)))) return 0; return call_int_hook(path_symlink, 0, dir, dentry, old_name); } @@ -557,7 +557,7 @@ int security_path_symlink(const struct path *dir, struct dentry *dentry, int security_path_link(struct dentry *old_dentry, const struct path *new_dir, struct dentry *new_dentry) { - if (unlikely(IS_PRIVATE(d_backing_inode(old_dentry)))) + if (unlikely(IS_PRIVATE(d_inode(old_dentry)))) return 0; return call_int_hook(path_link, 0, old_dentry, new_dir, new_dentry); } @@ -566,8 +566,8 @@ int security_path_rename(const struct path *old_dir, struct dentry *old_dentry, const struct path *new_dir, struct dentry *new_dentry, unsigned int flags) { - if (unlikely(IS_PRIVATE(d_backing_inode(old_dentry)) || - (d_is_positive(new_dentry) && IS_PRIVATE(d_backing_inode(new_dentry))))) + if (unlikely(IS_PRIVATE(d_inode(old_dentry)) || + (d_is_positive(new_dentry) && IS_PRIVATE(d_inode(new_dentry))))) return 0; if (flags & RENAME_EXCHANGE) { @@ -584,21 +584,21 @@ EXPORT_SYMBOL(security_path_rename); int security_path_truncate(const struct path *path) { - if (unlikely(IS_PRIVATE(d_backing_inode(path->dentry)))) + if (unlikely(IS_PRIVATE(d_inode(path->dentry)))) return 0; return call_int_hook(path_truncate, 0, path); } int security_path_chmod(const struct path *path, umode_t mode) { - if (unlikely(IS_PRIVATE(d_backing_inode(path->dentry)))) + if (unlikely(IS_PRIVATE(d_inode(path->dentry)))) return 0; return call_int_hook(path_chmod, 0, path, mode); } int security_path_chown(const struct path *path, kuid_t uid, kgid_t gid) { - if (unlikely(IS_PRIVATE(d_backing_inode(path->dentry)))) + if (unlikely(IS_PRIVATE(d_inode(path->dentry)))) return 0; return call_int_hook(path_chown, 0, path, uid, gid); } @@ -620,14 +620,14 @@ EXPORT_SYMBOL_GPL(security_inode_create); int security_inode_link(struct dentry *old_dentry, struct inode *dir, struct dentry *new_dentry) { - if (unlikely(IS_PRIVATE(d_backing_inode(old_dentry)))) + if (unlikely(IS_PRIVATE(d_inode(old_dentry)))) return 0; return call_int_hook(inode_link, 0, old_dentry, dir, new_dentry); } int security_inode_unlink(struct inode *dir, struct dentry *dentry) { - if (unlikely(IS_PRIVATE(d_backing_inode(dentry)))) + if (unlikely(IS_PRIVATE(d_inode(dentry)))) return 0; return call_int_hook(inode_unlink, 0, dir, dentry); } @@ -650,7 +650,7 @@ EXPORT_SYMBOL_GPL(security_inode_mkdir); int security_inode_rmdir(struct inode *dir, struct dentry *dentry) { - if (unlikely(IS_PRIVATE(d_backing_inode(dentry)))) + if (unlikely(IS_PRIVATE(d_inode(dentry)))) return 0; return call_int_hook(inode_rmdir, 0, dir, dentry); } @@ -666,8 +666,8 @@ int security_inode_rename(struct inode *old_dir, struct dentry *old_dentry, struct inode *new_dir, struct dentry *new_dentry, unsigned int flags) { - if (unlikely(IS_PRIVATE(d_backing_inode(old_dentry)) || - (d_is_positive(new_dentry) && IS_PRIVATE(d_backing_inode(new_dentry))))) + if (unlikely(IS_PRIVATE(d_inode(old_dentry)) || + (d_is_positive(new_dentry) && IS_PRIVATE(d_inode(new_dentry))))) return 0; if (flags & RENAME_EXCHANGE) { @@ -683,7 +683,7 @@ int security_inode_rename(struct inode *old_dir, struct dentry *old_dentry, int security_inode_readlink(struct dentry *dentry) { - if (unlikely(IS_PRIVATE(d_backing_inode(dentry)))) + if (unlikely(IS_PRIVATE(d_inode(dentry)))) return 0; return call_int_hook(inode_readlink, 0, dentry); } @@ -707,7 +707,7 @@ int security_inode_setattr(struct dentry *dentry, struct iattr *attr) { int ret; - if (unlikely(IS_PRIVATE(d_backing_inode(dentry)))) + if (unlikely(IS_PRIVATE(d_inode(dentry)))) return 0; ret = call_int_hook(inode_setattr, 0, dentry, attr); if (ret) @@ -718,7 +718,7 @@ EXPORT_SYMBOL_GPL(security_inode_setattr); int security_inode_getattr(const struct path *path) { - if (unlikely(IS_PRIVATE(d_backing_inode(path->dentry)))) + if (unlikely(IS_PRIVATE(d_inode(path->dentry)))) return 0; return call_int_hook(inode_getattr, 0, path); } @@ -728,7 +728,7 @@ int security_inode_setxattr(struct dentry *dentry, const char *name, { int ret; - if (unlikely(IS_PRIVATE(d_backing_inode(dentry)))) + if (unlikely(IS_PRIVATE(d_inode(dentry)))) return 0; /* * SELinux and Smack integrate the cap call, @@ -750,7 +750,7 @@ int security_inode_setxattr(struct dentry *dentry, const char *name, void security_inode_post_setxattr(struct dentry *dentry, const char *name, const void *value, size_t size, int flags) { - if (unlikely(IS_PRIVATE(d_backing_inode(dentry)))) + if (unlikely(IS_PRIVATE(d_inode(dentry)))) return; call_void_hook(inode_post_setxattr, dentry, name, value, size, flags); evm_inode_post_setxattr(dentry, name, value, size); @@ -758,14 +758,14 @@ void security_inode_post_setxattr(struct dentry *dentry, const char *name, int security_inode_getxattr(struct dentry *dentry, const char *name) { - if (unlikely(IS_PRIVATE(d_backing_inode(dentry)))) + if (unlikely(IS_PRIVATE(d_inode(dentry)))) return 0; return call_int_hook(inode_getxattr, 0, dentry, name); } int security_inode_listxattr(struct dentry *dentry) { - if (unlikely(IS_PRIVATE(d_backing_inode(dentry)))) + if (unlikely(IS_PRIVATE(d_inode(dentry)))) return 0; return call_int_hook(inode_listxattr, 0, dentry); } @@ -774,7 +774,7 @@ int security_inode_removexattr(struct dentry *dentry, const char *name) { int ret; - if (unlikely(IS_PRIVATE(d_backing_inode(dentry)))) + if (unlikely(IS_PRIVATE(d_inode(dentry)))) return 0; /* * SELinux and Smack integrate the cap call, diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index 2b5ee5fbd652..678033b7b0a9 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -325,7 +325,7 @@ static struct inode_security_struct *inode_security(struct inode *inode) static struct inode_security_struct *backing_inode_security_novalidate(struct dentry *dentry) { - struct inode *inode = d_backing_inode(dentry); + struct inode *inode = d_inode(dentry); return inode->i_security; } @@ -335,7 +335,7 @@ static struct inode_security_struct *backing_inode_security_novalidate(struct de */ static struct inode_security_struct *backing_inode_security(struct dentry *dentry) { - struct inode *inode = d_backing_inode(dentry); + struct inode *inode = d_inode(dentry); __inode_security_revalidate(inode, dentry, true); return inode->i_security; @@ -520,7 +520,7 @@ static int sb_finish_set_opts(struct super_block *sb) { struct superblock_security_struct *sbsec = sb->s_security; struct dentry *root = sb->s_root; - struct inode *root_inode = d_backing_inode(root); + struct inode *root_inode = d_inode(root); int rc = 0; if (sbsec->behavior == SECURITY_FS_USE_XATTR) { @@ -1832,7 +1832,7 @@ static inline int dentry_has_perm(const struct cred *cred, struct dentry *dentry, u32 av) { - struct inode *inode = d_backing_inode(dentry); + struct inode *inode = d_inode(dentry); struct common_audit_data ad; ad.type = LSM_AUDIT_DATA_DENTRY; @@ -1848,7 +1848,7 @@ static inline int path_has_perm(const struct cred *cred, const struct path *path, u32 av) { - struct inode *inode = d_backing_inode(path->dentry); + struct inode *inode = d_inode(path->dentry); struct common_audit_data ad; ad.type = LSM_AUDIT_DATA_PATH; @@ -2254,7 +2254,7 @@ static int selinux_binder_transfer_file(struct task_struct *from, return rc; #endif - if (unlikely(IS_PRIVATE(d_backing_inode(dentry)))) + if (unlikely(IS_PRIVATE(d_inode(dentry)))) return 0; isec = backing_inode_security(dentry); @@ -3209,7 +3209,7 @@ static int selinux_inode_permission(struct inode *inode, int mask) static int selinux_inode_setattr(struct dentry *dentry, struct iattr *iattr) { const struct cred *cred = current_cred(); - struct inode *inode = d_backing_inode(dentry); + struct inode *inode = d_inode(dentry); unsigned int ia_valid = iattr->ia_valid; __u32 av = FILE__WRITE; @@ -3254,7 +3254,7 @@ static bool has_cap_mac_admin(bool audit) static int selinux_inode_setxattr(struct dentry *dentry, const char *name, const void *value, size_t size, int flags) { - struct inode *inode = d_backing_inode(dentry); + struct inode *inode = d_inode(dentry); struct inode_security_struct *isec; struct superblock_security_struct *sbsec; struct common_audit_data ad; @@ -3344,7 +3344,7 @@ static void selinux_inode_post_setxattr(struct dentry *dentry, const char *name, const void *value, size_t size, int flags) { - struct inode *inode = d_backing_inode(dentry); + struct inode *inode = d_inode(dentry); struct inode_security_struct *isec; u32 newsid; int rc; diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c index 7ad226018f51..0e95d281a085 100644 --- a/security/smack/smack_lsm.c +++ b/security/smack/smack_lsm.c @@ -753,7 +753,7 @@ static int smack_set_mnt_opts(struct super_block *sb, unsigned long *set_kern_flags) { struct dentry *root = sb->s_root; - struct inode *inode = d_backing_inode(root); + struct inode *inode = d_inode(root); struct superblock_smack *sp = sb->s_security; struct inode_smack *isp; struct smack_known *skp; @@ -1083,15 +1083,15 @@ static int smack_inode_link(struct dentry *old_dentry, struct inode *dir, smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_DENTRY); smk_ad_setfield_u_fs_path_dentry(&ad, old_dentry); - isp = smk_of_inode(d_backing_inode(old_dentry)); + isp = smk_of_inode(d_inode(old_dentry)); rc = smk_curacc(isp, MAY_WRITE, &ad); - rc = smk_bu_inode(d_backing_inode(old_dentry), MAY_WRITE, rc); + rc = smk_bu_inode(d_inode(old_dentry), MAY_WRITE, rc); if (rc == 0 && d_is_positive(new_dentry)) { - isp = smk_of_inode(d_backing_inode(new_dentry)); + isp = smk_of_inode(d_inode(new_dentry)); smk_ad_setfield_u_fs_path_dentry(&ad, new_dentry); rc = smk_curacc(isp, MAY_WRITE, &ad); - rc = smk_bu_inode(d_backing_inode(new_dentry), MAY_WRITE, rc); + rc = smk_bu_inode(d_inode(new_dentry), MAY_WRITE, rc); } return rc; @@ -1107,7 +1107,7 @@ static int smack_inode_link(struct dentry *old_dentry, struct inode *dir, */ static int smack_inode_unlink(struct inode *dir, struct dentry *dentry) { - struct inode *ip = d_backing_inode(dentry); + struct inode *ip = d_inode(dentry); struct smk_audit_info ad; int rc; @@ -1150,8 +1150,8 @@ static int smack_inode_rmdir(struct inode *dir, struct dentry *dentry) /* * You need write access to the thing you're removing */ - rc = smk_curacc(smk_of_inode(d_backing_inode(dentry)), MAY_WRITE, &ad); - rc = smk_bu_inode(d_backing_inode(dentry), MAY_WRITE, rc); + rc = smk_curacc(smk_of_inode(d_inode(dentry)), MAY_WRITE, &ad); + rc = smk_bu_inode(d_inode(dentry), MAY_WRITE, rc); if (rc == 0) { /* * You also need write access to the containing directory @@ -1189,15 +1189,15 @@ static int smack_inode_rename(struct inode *old_inode, smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_DENTRY); smk_ad_setfield_u_fs_path_dentry(&ad, old_dentry); - isp = smk_of_inode(d_backing_inode(old_dentry)); + isp = smk_of_inode(d_inode(old_dentry)); rc = smk_curacc(isp, MAY_READWRITE, &ad); - rc = smk_bu_inode(d_backing_inode(old_dentry), MAY_READWRITE, rc); + rc = smk_bu_inode(d_inode(old_dentry), MAY_READWRITE, rc); if (rc == 0 && d_is_positive(new_dentry)) { - isp = smk_of_inode(d_backing_inode(new_dentry)); + isp = smk_of_inode(d_inode(new_dentry)); smk_ad_setfield_u_fs_path_dentry(&ad, new_dentry); rc = smk_curacc(isp, MAY_READWRITE, &ad); - rc = smk_bu_inode(d_backing_inode(new_dentry), MAY_READWRITE, rc); + rc = smk_bu_inode(d_inode(new_dentry), MAY_READWRITE, rc); } return rc; } @@ -1260,8 +1260,8 @@ static int smack_inode_setattr(struct dentry *dentry, struct iattr *iattr) smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_DENTRY); smk_ad_setfield_u_fs_path_dentry(&ad, dentry); - rc = smk_curacc(smk_of_inode(d_backing_inode(dentry)), MAY_WRITE, &ad); - rc = smk_bu_inode(d_backing_inode(dentry), MAY_WRITE, rc); + rc = smk_curacc(smk_of_inode(d_inode(dentry)), MAY_WRITE, &ad); + rc = smk_bu_inode(d_inode(dentry), MAY_WRITE, rc); return rc; } @@ -1275,7 +1275,7 @@ static int smack_inode_setattr(struct dentry *dentry, struct iattr *iattr) static int smack_inode_getattr(const struct path *path) { struct smk_audit_info ad; - struct inode *inode = d_backing_inode(path->dentry); + struct inode *inode = d_inode(path->dentry); int rc; smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_PATH); @@ -1344,8 +1344,8 @@ static int smack_inode_setxattr(struct dentry *dentry, const char *name, smk_ad_setfield_u_fs_path_dentry(&ad, dentry); if (rc == 0) { - rc = smk_curacc(smk_of_inode(d_backing_inode(dentry)), MAY_WRITE, &ad); - rc = smk_bu_inode(d_backing_inode(dentry), MAY_WRITE, rc); + rc = smk_curacc(smk_of_inode(d_inode(dentry)), MAY_WRITE, &ad); + rc = smk_bu_inode(d_inode(dentry), MAY_WRITE, rc); } return rc; @@ -1366,7 +1366,7 @@ static void smack_inode_post_setxattr(struct dentry *dentry, const char *name, const void *value, size_t size, int flags) { struct smack_known *skp; - struct inode_smack *isp = d_backing_inode(dentry)->i_security; + struct inode_smack *isp = d_inode(dentry)->i_security; if (strcmp(name, XATTR_NAME_SMACKTRANSMUTE) == 0) { isp->smk_flags |= SMK_INODE_TRANSMUTE; @@ -1405,8 +1405,8 @@ static int smack_inode_getxattr(struct dentry *dentry, const char *name) smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_DENTRY); smk_ad_setfield_u_fs_path_dentry(&ad, dentry); - rc = smk_curacc(smk_of_inode(d_backing_inode(dentry)), MAY_READ, &ad); - rc = smk_bu_inode(d_backing_inode(dentry), MAY_READ, rc); + rc = smk_curacc(smk_of_inode(d_inode(dentry)), MAY_READ, &ad); + rc = smk_bu_inode(d_inode(dentry), MAY_READ, rc); return rc; } @@ -1442,12 +1442,12 @@ static int smack_inode_removexattr(struct dentry *dentry, const char *name) smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_DENTRY); smk_ad_setfield_u_fs_path_dentry(&ad, dentry); - rc = smk_curacc(smk_of_inode(d_backing_inode(dentry)), MAY_WRITE, &ad); - rc = smk_bu_inode(d_backing_inode(dentry), MAY_WRITE, rc); + rc = smk_curacc(smk_of_inode(d_inode(dentry)), MAY_WRITE, &ad); + rc = smk_bu_inode(d_inode(dentry), MAY_WRITE, rc); if (rc != 0) return rc; - isp = d_backing_inode(dentry)->i_security; + isp = d_inode(dentry)->i_security; /* * Don't do anything special for these. * XATTR_NAME_SMACKIPIN diff --git a/security/tomoyo/condition.c b/security/tomoyo/condition.c index 8d0e1b9c9c57..3145c07c4379 100644 --- a/security/tomoyo/condition.c +++ b/security/tomoyo/condition.c @@ -715,7 +715,7 @@ void tomoyo_get_attributes(struct tomoyo_obj_info *obj) dentry = dget_parent(dentry); break; } - inode = d_backing_inode(dentry); + inode = d_inode(dentry); if (inode) { struct tomoyo_mini_stat *stat = &obj->stat[i]; stat->uid = inode->i_uid; diff --git a/security/tomoyo/realpath.c b/security/tomoyo/realpath.c index 6ff8c21e4fff..cf07145b7e74 100644 --- a/security/tomoyo/realpath.c +++ b/security/tomoyo/realpath.c @@ -98,7 +98,7 @@ static char *tomoyo_get_absolute_path(const struct path *path, char * const buff /* go to whatever namespace root we are under */ pos = d_absolute_path(path, buffer, buflen - 1); if (!IS_ERR(pos) && *pos == '/' && pos[1]) { - struct inode *inode = d_backing_inode(path->dentry); + struct inode *inode = d_inode(path->dentry); if (inode && S_ISDIR(inode->i_mode)) { buffer[buflen - 2] = '/'; buffer[buflen - 1] = '\0'; @@ -126,7 +126,7 @@ static char *tomoyo_get_dentry_path(struct dentry *dentry, char * const buffer, if (buflen >= 256) { pos = dentry_path_raw(dentry, buffer, buflen - 1); if (!IS_ERR(pos) && *pos == '/' && pos[1]) { - struct inode *inode = d_backing_inode(dentry); + struct inode *inode = d_inode(dentry); if (inode && S_ISDIR(inode->i_mode)) { buffer[buflen - 2] = '/'; buffer[buflen - 1] = '\0'; @@ -169,7 +169,7 @@ static char *tomoyo_get_local_path(struct dentry *dentry, char * const buffer, if (!MAJOR(sb->s_dev)) goto prepend_filesystem_name; { - struct inode *inode = d_backing_inode(sb->s_root); + struct inode *inode = d_inode(sb->s_root); /* * Use filesystem name if filesystem does not support rename() * operation. @@ -220,7 +220,7 @@ static char *tomoyo_get_local_path(struct dentry *dentry, char * const buffer, static char *tomoyo_get_socket_name(const struct path *path, char * const buffer, const int buflen) { - struct inode *inode = d_backing_inode(path->dentry); + struct inode *inode = d_inode(path->dentry); struct socket *sock = inode ? SOCKET_I(inode) : NULL; struct sock *sk = sock ? sock->sk : NULL; if (sk) { @@ -278,7 +278,7 @@ char *tomoyo_realpath_from_path(const struct path *path) pos = dentry->d_op->d_dname(dentry, buf, buf_len - 1); goto encode; } - inode = d_backing_inode(sb->s_root); + inode = d_inode(sb->s_root); /* * Get local name for filesystems without rename() operation * or dentry without vfsmount.