Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2868010rwb; Mon, 15 Aug 2022 12:58:15 -0700 (PDT) X-Google-Smtp-Source: AA6agR5s0aWNik3nSNssgtGup6/K41lYpgYwq2FDNuDn+Y50FrUO3q9anJhzcE1U+lKjErI0/Bpi X-Received: by 2002:a05:6402:2b98:b0:43e:107:183d with SMTP id fj24-20020a0564022b9800b0043e0107183dmr16029515edb.366.1660593495320; Mon, 15 Aug 2022 12:58:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660593495; cv=none; d=google.com; s=arc-20160816; b=hOWW46H3TAlaaJgFli2Wvl36n2zq7SUVkfJS56CrsuELi7v20LZFqVzoDBZLTiOqGV xA+bduY9IHEUIlsYqRL4CwI03IQjb+mRovMnPz4krMtOpTJ6tpGjNjvHz9jcR/AG5Lwd 6CP17xB2C99tY1Eh7juJS9Sgz4oS2EnGxYXiNWCdWXgD8e2XQ0B2fEL51osC/dGX1NlG yTwFVtxXx9VN8HRf6A42TGJfUQT2HiU0R4039Nj5KfjwvI6AaAYxs5p/vWDRyZNhecHn OUE+L/w8+O2UPdplR4LuH57euo86haih2zIcCue10/umtil8sQB5Zb4TcMZ0M2MMAI4r HSOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=7GNvvLskm1JRp+uKALW/iOcHWcZgQtIeaiPbRVOdYg0=; b=RO08AiWWsbDrT9TENrG+VcFJOGHUHf9la27Cg1vTF3R6DRKNmVF7YBx6exGLzxeUf3 Qhek56IXxpr8ZqtQfy2rt7b78sEqQFtK9I56j8wuc5hdBG9VWx4dt/CqCH1qUPAQbg8c xq1W2fhxvXlxmQXX+J/JyNT7WGAthly2Eia2137TwUDYPW/s7UREBoI9J/Ri5S70cjwy +c6Rj5ee+QxW1EgYrAFJATNZzeqagXul9Caa9R8y2njm6CczQMlEFXEacRCTkiI0/F8K nESqQWNx1DICiAyi3OcxvaC27Mm9wM6HGUcPHupJNIAH83PY0SFv8cdFUWiPA9ihQ5jf MilA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0pm2LJit; 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=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dz21-20020a0564021d5500b004419b8cac8fsi9799434edb.509.2022.08.15.12.57.49; Mon, 15 Aug 2022 12:58:15 -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=@linuxfoundation.org header.s=korg header.b=0pm2LJit; 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=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239988AbiHOSSk (ORCPT + 99 others); Mon, 15 Aug 2022 14:18:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237536AbiHOSSD (ORCPT ); Mon, 15 Aug 2022 14:18:03 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1424F17E04; Mon, 15 Aug 2022 11:15:28 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9D52361297; Mon, 15 Aug 2022 18:15:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 83640C433C1; Mon, 15 Aug 2022 18:15:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660587327; bh=pqBJ1NWS1RN2vBwc3PaPKuwfdOzMrRfU7YsQ6GivFJc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0pm2LJitC7LbG7Dn98PybIzqqShzGYmIjpG7vYP1KvrJJFGE4Vqdc18knIlgNlJf/ acoFONb9q+W8eDfmdpQbe5c4hGWl9UVEmsJNsubcm68Sn53aNt6ALCaQW87UW+3c3r WgfVVAvGdAehMTdCn6XqyShPWSTSGhhBpb/wdtg4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hongbo Yin , Jiachen Zhang , Tianci Zhang , Miklos Szeredi Subject: [PATCH 5.15 048/779] ovl: drop WARN_ON() dentry is NULL in ovl_encode_fh() Date: Mon, 15 Aug 2022 19:54:52 +0200 Message-Id: <20220815180339.315242744@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180337.130757997@linuxfoundation.org> References: <20220815180337.130757997@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 From: Jiachen Zhang commit dd524b7f317de8d31d638cbfdc7be4cf9b770e42 upstream. 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. Reported-by: Hongbo Yin Signed-off-by: Jiachen Zhang Signed-off-by: Tianci Zhang Fixes: 8ed5eec9d6c4 ("ovl: encode pure upper file handles") Cc: # v4.16 Signed-off-by: Miklos Szeredi Signed-off-by: Greg Kroah-Hartman --- fs/overlayfs/export.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/fs/overlayfs/export.c +++ b/fs/overlayfs/export.c @@ -259,7 +259,7 @@ static int ovl_encode_fh(struct inode *i return FILEID_INVALID; dentry = d_find_any_alias(inode); - if (WARN_ON(!dentry)) + if (!dentry) return FILEID_INVALID; bytes = ovl_dentry_to_fid(ofs, dentry, fid, buflen);