From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6DDDDC12002 for ; Mon, 19 Jul 2021 09:03:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 54B046100C for ; Mon, 19 Jul 2021 09:03:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235566AbhGSIXK (ORCPT ); Mon, 19 Jul 2021 04:23:10 -0400 Received: from mail.synology.com ([211.23.38.101]:32806 "EHLO synology.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S235498AbhGSIXJ (ORCPT ); Mon, 19 Jul 2021 04:23:09 -0400 Subject: Re: [RESEND PATCH v2] hfsplus: prevent negative dentries when casefolded DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synology.com; s=123; t=1626685428; bh=nrLeIo3KdjKJ3knzH46N/b/L2z/5UVOq0EeQ1Fo8DU0=; h=Subject:To:Cc:References:From:Date:In-Reply-To; b=P/+x438MJ0hx/dzk6G6PB75DxBzAzn4P/QnJWOY1jTGjHRDDvcPxBC0B80YiZSuzL KiP/a3GgRsXI+BY3bryY1szsYl2nk5AwPcfaWZhXbE9HN1DJiInDlLHyPvZZDnq/19 WGggKzqDt5FvIreyh8/qvLLICGvyxhOAZ8L30QUE= To: Viacheslav Dubeyko Cc: Linux FS Devel , LKML , Al Viro , Andrew Morton , gustavoars@kernel.org, gregkh@linuxfoundation.org, keescook@chromium.org, mszeredi@redhat.com, shepjeng@gmail.com References: <20210716073635.1613671-1-cccheng@synology.com> <02B9566C-A78E-42FB-924B-A503E4BC6D2F@dubeyko.com> From: Chung-Chiang Cheng Message-ID: Date: Mon, 19 Jul 2021 17:03:45 +0800 MIME-Version: 1.0 In-Reply-To: <02B9566C-A78E-42FB-924B-A503E4BC6D2F@dubeyko.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Synology-MCP-Status: no X-Synology-Spam-Flag: no X-Synology-Spam-Status: score=0, required 6, WHITELIST_FROM_ADDRESS 0 X-Synology-Virus-Status: no Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org This function revalidates dentries without blocking and storing to the dentry. As the document mentioned [1], I think it's safe in rcu-walk mode. I also found jfs_ci_revalidate() takes the same approach.         d_revalidate may be called in rcu-walk mode (flags & LOOKUP_RCU).         If in rcu-walk mode, the filesystem must revalidate the dentry without         blocking or storing to the dentry, d_parent and d_inode should not be         used without care (because they can change and, in d_inode case, even         become NULL under us [1] https://www.kernel.org/doc/Documentation/filesystems/vfs.txt Thanks, C.C.Cheng >> + >> +int hfsplus_revalidate_dentry(struct dentry *dentry, unsigned int flags) >> +{ > What’s about this code? > > If (flags & LOOKUP_RCU) > return -ECHILD; > > Do we really need to miss it here? > > Thanks, > Slava. > > >> + /* >> + * dentries are always valid when disabling casefold. >> + */ >> + if (!test_bit(HFSPLUS_SB_CASEFOLD, &HFSPLUS_SB(dentry->d_sb)->flags)) >> + return 1; >> + >> + /* >> + * Positive dentries are valid when enabling casefold. >> + * >> + * Note, rename() to existing directory entry will have ->d_inode, and >> + * will use existing name which isn't specified name by user. >> + * >> + * We may be able to drop this positive dentry here. But dropping >> + * positive dentry isn't good idea. So it's unsupported like >> + * rename("filename", "FILENAME") for now. >> + */ >> + if (d_really_is_positive(dentry)) >> + return 1; >> + >> + /* >> + * Drop the negative dentry, in order to make sure to use the case >> + * sensitive name which is specified by user if this is for creation. >> + */ >> + if (flags & (LOOKUP_CREATE | LOOKUP_RENAME_TARGET)) >> + return 0; >> + >> + return 1; >> +} >> -- >> 2.25.1 >>