NetBSD Problem Report #57005

From dholland@netbsd.org  Mon Sep 12 01:10:03 2022
Return-Path: <dholland@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 8811C1A923A
	for <gnats-bugs@gnats.NetBSD.org>; Mon, 12 Sep 2022 01:10:03 +0000 (UTC)
Message-Id: <20220912011002.8C46984DC1@mail.netbsd.org>
Date: Mon, 12 Sep 2022 01:10:02 +0000 (UTC)
From: dholland@NetBSD.org
Reply-To: dholland@NetBSD.org
To: gnats-bugs@NetBSD.org
Subject: excessive namecache purging in ufs_rmdir
X-Send-Pr-Version: 3.95

>Number:         57005
>Category:       kern
>Synopsis:       excessive namecache purging in ufs_rmdir
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Sep 12 01:15:00 +0000 2022
>Last-Modified:  Tue Sep 13 01:15:01 +0000 2022
>Originator:     David A. Holland
>Release:        NetBSD 9.99.96 (20220310)
>Organization:
>Environment:
System: NetBSD valkyrie 9.99.97 NetBSD 9.99.97 (VALKYRIE) #10: Thu Aug 18 04:09:11 EDT 2022  dholland@valkyrie:/usr/src/sys/arch/amd64/compile/VALKYRIE amd64
Architecture: x86_64
Machine: amd64
>Description:

ufs_rmdir calls cache_purge(dvp), where dvp is the directory the
removal is happening in.

cache_purge(dvp) expands to cache_purge1(dvp, NULL, 0,
PURGE_PARENTS|PURGE_CHILDREN) which...

(a) purges *all* namecache entries in the directory, not just the one
for the directory being removed; and, even worse,
(b) purges any entries for dvp in _its_ parent.

From mjg at freebsd.

>How-To-Repeat:

Code inspection.

>Fix:

Call cache_purge1(dvp, cnp->cn_name, cnp->cn_namelen, 0). Unless the
name has been trashed or something at this stage, in which case the
name needs to be copied.

Also merge the change into ulfs_vnops.c and look for additional
cutpaste in other filesystems.

XXX: this call should really be in the caller, not in every
XXX: filesystem, but that's a bigger deal to change.

>Audit-Trail:
From: David Holland <dholland-bugs@netbsd.org>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: kern/57005: excessive namecache purging in ufs_rmdir
Date: Tue, 13 Sep 2022 01:12:55 +0000

 On Mon, Sep 12, 2022 at 01:15:00AM +0000, dholland@NetBSD.org wrote:
  > Call cache_purge1(dvp, cnp->cn_name, cnp->cn_namelen, 0). Unless the
  > name has been trashed or something at this stage, in which case the
  > name needs to be copied.
  > 
  > Also merge the change into ulfs_vnops.c and look for additional
  > cutpaste in other filesystems.
  > 
  > XXX: this call should really be in the caller, not in every
  > XXX: filesystem, but that's a bigger deal to change.

 Note that rename also does similar rubbish. (These are already tagged
 'XXX WTF'.)

 -- 
 David A. Holland
 dholland@netbsd.org

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2022 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.