• J
    ext4: Do not iput inode under running transaction · d5684257
    Jan Kara 提交于
    mainline inclusion
    from mainline-5.5-rc1
    commit 9b88f9fb0d2fc8f7e71e75a42c5a064bc6cfffd2
    category: bugfix
    bugzilla: 25031
    CVE: NA
    ---------------------------
    
    When ext4_mkdir(), ext4_symlink(), ext4_create(), or ext4_mknod() fail
    to add entry into directory, it ends up dropping freshly created inode
    under the running transaction and thus inode truncation happens under
    that transaction. That breaks assumptions that evict() does not get
    called from a transaction context and at least in ext4_symlink() case it
    can result in inode eviction deadlocking in inode_wait_for_writeback()
    when flush worker finds symlink inode, starts to write it back and
    blocks on starting a transaction. So change the code in ext4_mkdir() and
    ext4_add_nondir() to drop inode reference only after the transaction is
    stopped. We also have to add inode to the orphan list in that case as
    otherwise the inode would get leaked in case we crash before inode
    deletion is committed.
    
    CC: stable@vger.kernel.org
    Signed-off-by: NJan Kara <jack@suse.cz>
    Link: https://lore.kernel.org/r/20191105164437.32602-5-jack@suse.czSigned-off-by: NTheodore Ts'o <tytso@mit.edu>
    Signed-off-by: Nzhangyi (F) <yi.zhang@huawei.com>
    Reviewed-by: NYang Erkun <yangerkun@huawei.com>
    Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
    d5684257
namei.c 103.3 KB