From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.53 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796418658; b=XFra0yCc2osfez0Se+YccB5/lt0KBo6k3kALJ0WT/bvp1elZNjPcjvxU8ock4bUsZSD6 0hfZ8kFeoPbUaD/jykLQDOFpjSm5w6WI8D8GU3Q/iLxBGow5/qOtWptdWboYyvMPbcW2k L85da5KKWdMv0vbhzkqH7z3hAiFeF8S76fl37NSJ9LAWywEnXjgLzQXd1m0V8euZtYA9S RXSKNjPcw/i9FpDy0KYbZCjPQcu4OBoRc+ngs21ZPmGa+9TJbt1gOkTziyNlfK/nxn7Lr plLSRcuBiAKR7mTbjQScME/lOJetbIqPv1w6PtAMYOufSjlmN3l/V1tHgib7+Ae+5Aw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796418658; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=wTZLeh05KuDwM98tN/i/yxMJOKRMnUQ8FJE37PxiOmA=; b=EFnRwL31K8ft7oUsgJmMvXrP17vBnLGHbbziDevvuHqw5GwE6djbMZ0Isvg3fhALQ3rP r0C5nDTaKeBrpcwwCTf5EnAuElk+/pz5fdRC9GGVL3a7a5vR+dTakBSNl9QdG4r1SWlxJ fFpawgowsoaMjGI+Ed6RcXAgWLNswtqIx7QBAtRXSDgHNRuWZDM5RClTNV0Y1Fuj30nZ1 uqmtWcMMn80qZmNrQ9MVEihiyUZK0XM9/TMKfMCPODQlMeSzVusqFrBbgGvaSZUlp5PGW U0BHW/uPQ+MydLzcFgshzmPb1GDtcJIg5wrDoWwswepWL3QWl+PgZ9LGQM8HSgEMt9A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=Vak8H2gO; arc=none smtp.remote-ip=91.218.175.53 Received: from mta0.migadu.com (out-53.mta0.migadu.com [91.218.175.53]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3BC94606A32C for ; Fri, 4 Dec 2026 21:10:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 3BC94606A32C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=Vak8H2gO X-Envelope-To: driver-core@lists.linux.dev DKIM-Signature: a=rsa-sha256; bh=qj/6hneNWsInoGW2mgznmJXSGdY9wE/c1nhUM5fG74w=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796418656; v=1; x=1797023456; b=Vak8H2gOXUnHTe8grj97mje1MRZkbZjtD8SSwbuXlc4zz6WuPH2ES0UopVoZ6qGEM3y7WAnw uVcQnxtW+ImwdZdBoNaTG0EaXXpN6FgvjSRdMUWpF9dKZRWWy2yv6aFxhB7jO8wwnZOxzrLOP3f X7vt9jfcZzZrIBRmMbQs3GUs= X-Envelope-To: driver-core@lists.linux.dev Received: by smtp.migadu.com with ESMTPS id 986d3277379ae4c1; Fri, 04 Dec 2026 21:10:53 +0000 X-Mizu-Trace-ID: 986d3277379ae4c1 X-Migadu-Flow: FLOW_OUT From: Shakeel Butt To: Christian Brauner Cc: Greg Kroah-Hartman , Tejun Heo , Andrew Morton , Ian Kent , Jori Koolstra , "T . J . Mercier" , Meta kernel team , cgroups@vger.kernel.org, linux-fsdevel@vger.kernel.org, driver-core@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] kernfs: don't look for open files of directories when draining Date: Fri, 4 Dec 2026 13:10:30 -0800 Message-ID: <20261204211034.3436390-2-shakeel.butt@linux.dev> X-Mailer: git-send-email 2.53.1 In-Reply-To: <20261204211034.3436390-1-shakeel.butt@linux.dev> References: <20261204211034.3436390-1-shakeel.butt@linux.dev> X-Mailing-List: driver-core@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit kernfs_drain() calls kernfs_should_drain_open_files() for every node it removes, directories and symlinks included, and that reads kn->attr.open from the node's union. For a directory, the field overlaps dir.children.rb_node, which is NULL by the time a directory is drained, as its children are removed first. So it works, but only because of how kernfs_elem_dir is laid out. The next patch adds a sequence count to it, and with lockdep, attr.open then overlaps data that is not zero. Only files have open nodes. Check the type first. Signed-off-by: Shakeel Butt --- fs/kernfs/file.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fs/kernfs/file.c b/fs/kernfs/file.c index 08c29eb3f435..b141c09aadbe 100644 --- a/fs/kernfs/file.c +++ b/fs/kernfs/file.c @@ -837,6 +837,13 @@ bool kernfs_should_drain_open_files(struct kernfs_node *kn) struct kernfs_open_node *on; bool ret; + /* + * Only files have open nodes. For a directory or a symlink, + * @kn->attr.open would read another member of the union. + */ + if (kernfs_type(kn) != KERNFS_FILE) + return false; + /* * @kn being deactivated guarantees that @kn->attr.open can't change * beneath us making the lockless test below safe. -- 2.53.1-Meta