Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp563815imn; Thu, 28 Jul 2022 09:01:44 -0700 (PDT) X-Google-Smtp-Source: AGRyM1s6Ea+1Qg+r+8bPt/XDcpBg0sU3yUOu1pw+NBmyiGLuDi+jSWRWOgIOTsn7ecjTI8RzS2HT X-Received: by 2002:a05:6402:2681:b0:43c:fd90:10bd with SMTP id w1-20020a056402268100b0043cfd9010bdmr1942975edd.419.1659024104210; Thu, 28 Jul 2022 09:01:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659024104; cv=none; d=google.com; s=arc-20160816; b=iRxWM7ZPIUKoKP83QQ2HO0zu0ELvTM0Vbt208ZVkTUbtEovFB0uEGxLAKUj8llJjUT +/y+VCAUY+C+cL46YB+u7A14wzlB4p1twuk0X0PQKtFOqO4HH/wgeUCq6ba9ri9AU2ey /qARjiRZfJrm4iBopojKjHjYGt/Vw+GX4PPOe0IBbruh2rgsK/c1TIBzj0pLVFcWyJ4J yVNcUPJynhV5lEWL5+lP+lCoQG2/pcGLjuiid63NKtz6RGfxsxmlarxWIb1Drq62zkHE seLqAATA9UE1cqqwUOH7AiwQDPrqj9XZxGoppPKYNbpPZW8zlJNUW8zV7TejWQI9Rnqi NAVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=juoHghnTH32Kj8QlI0i1YTL6DmztcBwrLPBQKpcOZMI=; b=dEW4E6iSB8mfD2aWJFb+2wwnlc9BZr3rW9J2addoCjSlG65MYvHuLpcG0ftTfrZ6MW IynivpyTd8lhWRKXKDLhRIjn6GRvnrX14rsHV4AfHGhJvc/yYqUSfVIeg0zhHs9gJs4E cDe32bA7wR1eblQMAqSf8MR+IGPY/UCkmBZRpmmJQiRYzZ20ZiA9zlys/BDNPCJ3kd8B 5clNJ4DUEfdCS5gU1E4wn5AzwBB0eOg6u1zM7wAUZyrB6/UU9OyVmmtTBqf2La8JaYiL Cfc6iJa/7ME5jPvkzsHc9pLrnD+lPjD2VdCfQEDNIf1yEpT6U4t2pd5cv14LUb4vVRVZ RWbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=n0sSIBhN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m22-20020a17090607d600b0072b0f4f4b36si892948ejc.611.2022.07.28.09.01.18; Thu, 28 Jul 2022 09:01:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=n0sSIBhN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232437AbiG1Pu3 (ORCPT + 99 others); Thu, 28 Jul 2022 11:50:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231791AbiG1PuX (ORCPT ); Thu, 28 Jul 2022 11:50:23 -0400 Received: from mail-vs1-xe32.google.com (mail-vs1-xe32.google.com [IPv6:2607:f8b0:4864:20::e32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD35D2C659; Thu, 28 Jul 2022 08:50:21 -0700 (PDT) Received: by mail-vs1-xe32.google.com with SMTP id a63so1995634vsa.3; Thu, 28 Jul 2022 08:50:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=juoHghnTH32Kj8QlI0i1YTL6DmztcBwrLPBQKpcOZMI=; b=n0sSIBhNYa6kx90pgcTt7Lkyv45jX4qx/E8T3eJ/FoHc6a0frmm81j+MtOFijSl+N8 5alA/gnLJmptcpuLEsffjJqe0/W8jNqUkqHT65svJcl/y3WwY0ft/xsDRLBO14VgrfFo uDFqsP29P5axCTkpKsM7XoZiiVHxnO1qsc9Dw+7IFCylF8W0+UWdoP1TmTBqPD0Wyaez rHtEgXCmOK07tHwueeW5+watPJ+FBqcugOO9JjVIyyPd7PNQqW7IGvRgRGZq/+9SfnnO 65yqUww1/EnQk4Xf6ycVy0dCeBxf+Q6F7gmgAfb+y80JgXTTcQ2qfX1dRjHVocI6rLOL oZZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=juoHghnTH32Kj8QlI0i1YTL6DmztcBwrLPBQKpcOZMI=; b=I//IiI7ZTbb0Xo4+WmiHWM1C3Jjp2Hi6D6bHTyGOY0ntAko14QSqGJ8EfPEIYUrT9x 9yhcpvr9HytgThI38ueam5nzfHf8/ZqvG1XOchc7kjwehYDPRRuTSJeA6FX7tvOdZvl+ BitOgnsUnk7sVqdm0Ntl6jCrmlD54ytQDHwqn3O+m48vD3UJpQPcotnmacN9W2MK68Q8 LvNdQMErWsbd6pVGIrgbpej/j2/8SAqo1rlFiInK6c0nPpoixQhyvvoRDm+FAHHIx9+N rCiC13cL/XjN/UM/VPB6siy/HNdr7w3g9DeVuqFvBPIBBSDrHZ/+PD629GKmkPAl7gFq TuUw== X-Gm-Message-State: AJIora/bcT5GTjLYJpVkwAkRPqey7vj4XYxAvRYPuPQWAAV0qnH8i7Ed jUE/zkpLQDsXSuG/szTrqs+5dl48L0P8f/30SPCoWAn2Jx/Y2vTZ X-Received: by 2002:a67:eb98:0:b0:358:6274:71b3 with SMTP id e24-20020a67eb98000000b00358627471b3mr5972297vso.72.1659023420760; Thu, 28 Jul 2022 08:50:20 -0700 (PDT) MIME-Version: 1.0 References: <20220728114915.91021-1-zhangjiachen.jaycee@bytedance.com> In-Reply-To: From: Amir Goldstein Date: Thu, 28 Jul 2022 17:50:09 +0200 Message-ID: Subject: Re: [PATCH v2] ovl: drop WARN_ON() dentry is NULL in ovl_encode_fh() To: Miklos Szeredi Cc: Jiachen Zhang , overlayfs , linux-kernel , songmuchun@bytedance.com, Hongbo Yin , Tianci Zhang Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 28, 2022 at 3:06 PM Miklos Szeredi wrote: > > On Thu, 28 Jul 2022 at 13:49, Jiachen Zhang > wrote: > > > > Some code paths cannot guarantee the inode have any dentry alias. So > > WARN_ON() all !dentry may flood the kernel logs. > > > > For example, when an overlayfs inode is watched by inotifywait (1), and > > someone is trying to read the /proc/$(pidof inotifywait)/fdinfo/INOTIFY_FD, > > at that time if the dentry has been reclaimed by kernel (such as > > echo 2 > /proc/sys/vm/drop_caches), there will be a WARN_ON(). The > > printed call stack would be like: > > > > ? show_mark_fhandle+0xf0/0xf0 > > show_mark_fhandle+0x4a/0xf0 > > ? show_mark_fhandle+0xf0/0xf0 > > ? seq_vprintf+0x30/0x50 > > ? seq_printf+0x53/0x70 > > ? show_mark_fhandle+0xf0/0xf0 > > inotify_fdinfo+0x70/0x90 > > show_fdinfo.isra.4+0x53/0x70 > > seq_show+0x130/0x170 > > seq_read+0x153/0x440 > > vfs_read+0x94/0x150 > > ksys_read+0x5f/0xe0 > > do_syscall_64+0x59/0x1e0 > > entry_SYSCALL_64_after_hwframe+0x44/0xa9 > > > > So let's drop WARN_ON() to avoid kernel log flooding. > > > Applied, thanks. FWIW, no objection to this fix, but for the record, encode_fh is basically an inode operation, so it shouldn't require an alias. The only thing in the call chain down from ovl_encode_fh() that needs the ovl dentry is ovl_connect_layer(). The rest of the referenced to ovl dentry can use an ovl inode instead. In some cases (e.g. non-dir or pure upper dir), ovl_connect_layer() will not be called at all, but even if it would need to be called, it is better to skip it and encode the lower inode if there is no ovl dentry available. The possible eventual outcome of an fh changing after disconnected dir copy up is probably better than failing encode_fh out right. No need to make any of those changes for this corner case IMO. Just wanted to add this analysis to the thread. Thanks, Amir.