Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp5512162rwb; Wed, 17 Aug 2022 20:07:58 -0700 (PDT) X-Google-Smtp-Source: AA6agR5A0mwBtrghQlKbohp7cyBsA7taICwijS22nL5BFolAo/6piG/Go3o6IpEDIbFDMzr7G+WF X-Received: by 2002:a17:90b:1d0b:b0:1f5:72f:652c with SMTP id on11-20020a17090b1d0b00b001f5072f652cmr1029930pjb.38.1660792078567; Wed, 17 Aug 2022 20:07:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660792078; cv=none; d=google.com; s=arc-20160816; b=sdsiRruZU5LUYz7YFfwR5/0mvTQfdrOXzc/FKlnRVqJc8ZadaGFFQV7LRsTxewMFmK 0Xu3Ld0OFwkdq/ZH+WjX/APzIWoUY+W21lYL70AKuM17WrqKyhne7WQST1O1MuTX/bEB 6YHIulI4zsnWFpChKUfX91tcEZaoXg/uTLAsh4jBC9wEenWO+owquLk30a4MW8SvIGzS Yfs1FCaBwHKCBmCqWUii9xkGDSwqXCy274uemdfT1Cin1YdXkK0/uB4Dx/+QFQkit9N/ 7HaKPT8/MS139kOP/MXLrNdALhasU7EsKrxHBGlmGUO5IvAYo0A+uMcX0c/srx9O8A9M LqlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:references:in-reply-to:subject :cc:to:from:mime-version:content-transfer-encoding:dkim-signature :dkim-signature; bh=SSSJqi9vFita0vstRwkfAQnmHXDnamYCySmvCOoAvsI=; b=Xerr2s2lv4d0KOawMBHgbd12F+hNWtnZq16iVFXDRZuTIg4I02IkjiQCL1yGmnJGWe P/YKogNfXBY471zQTJwUtqwNCR2fbhClAZjT6OT3Qp2MVK5SgbMkSNvQqmVasLyHKrML i7haQFogC+J/bA4MWNYtxKoSQxUItz9UtYcvG7G+MTWMIC8l8ATPGgIWxGNcSH2wcz+E rrTXnbomKx7iWPHBZqsYdteilSJuHWL/Cm6J9z0F1llaSFMSK2luzm2m+OKzcEILl16H KOBAp0DJ+VpozwjuDDLxztlgfcROVRlLPuteOejLNP8+V9/uJ7wy70KAlgwWG8mJfp99 /M3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=vZ6K9aux; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n14-20020a170902f60e00b00170cde7d287si271756plg.421.2022.08.17.20.07.35; Wed, 17 Aug 2022 20:07:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-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=@suse.de header.s=susede2_rsa header.b=vZ6K9aux; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242886AbiHRCzj (ORCPT + 99 others); Wed, 17 Aug 2022 22:55:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242883AbiHRCzj (ORCPT ); Wed, 17 Aug 2022 22:55:39 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC284A571E for ; Wed, 17 Aug 2022 19:55:37 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 4C9C620B6A; Thu, 18 Aug 2022 02:55:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1660791336; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SSSJqi9vFita0vstRwkfAQnmHXDnamYCySmvCOoAvsI=; b=vZ6K9auxlA0PXaXfOP9LNVCu4aJ3ADD+PQPssUTZqRP0dNQEKdaKZrN14XJWCpQ8GFZ5un eaDArfWSDZRHHg45rrIKzidtQiqMZ6YX4eH5WOQDgQfT6mXUss/GDyFXY6SSKT+JbBS5MX HYo1M5+/Z5zMqLksasRz6zKLov9XsdM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1660791336; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SSSJqi9vFita0vstRwkfAQnmHXDnamYCySmvCOoAvsI=; b=D5WeK5lmMWayuJp97sBeLrryzMX/C93a5ByHn2on6qyRroDAuGOC5b8nkZhPu5U9Yf04lO jgPVc3NzUTZ3d7AQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 2A2BF13440; Thu, 18 Aug 2022 02:55:34 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id fEIzNSaq/WLacgAAMHmgww (envelope-from ); Thu, 18 Aug 2022 02:55:34 +0000 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit MIME-Version: 1.0 From: "NeilBrown" To: "J. R. Okajima" Cc: trond.myklebust@hammerspace.com, linux-nfs@vger.kernel.org Subject: Re: NFS, two d_delete() calls in nfs_unlink() In-reply-to: <7634.1660728564@jrobl> References: <7634.1660728564@jrobl> Date: Thu, 18 Aug 2022 12:55:31 +1000 Message-id: <166079133167.5425.16635199337074058478@noble.neil.brown.name> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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-nfs@vger.kernel.org On Wed, 17 Aug 2022, J. R. Okajima wrote: > Hello NeilBrown and Trond Myklebust, > > By the commin in v6.0-rc1, > 3c59366c207e 2022-08-08 NFS: don't unhash dentry during unlink/rename > nfs_unlink() stopped calling __d_drop(). > And it MAY cause two d_delete() calls. If it happens, the second call > leads to NULL pointer access because d_inode is already cleared. > > Here is the detail. > > nfs_unlink() > + nfs_safe_remove() > + NFS_PROTO(dir)->remove() <-- returns ENOENT > + nfs_dentry_handle_enoent() > + if (simple_positive()) d_delete() <-- 1st call and d_inode is cleared > + nfs_dentry_remove_handle_error() > + if (ENOENT) d_delete() <-- second call and NULL d_inode is accessed > > How about adding a condition for d_delete() call in > nfs_dentry_remove_handle_error(), such like simple_positive()? > Thanks for the report. This possibility of calling d_delete() twice has been present since 9019fb391de0 in v5.16. It is possible that my patch made it more likely or more problematic, though I cannot see why. I posted a patch which Trond has applied to his linux-next branch. It is in linux-next as commit 9a31abb1c009c40 How did you discover this bug, and why do you think my patch caused it? Thanks, NeilBrown