mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] cachefiles: fix incorrect dentry refcount in cachefiles_cull()
@ 2026-03-26 22:18 NeilBrown
  2026-03-26 23:16 ` Paulo Alcantara
  2026-03-31  9:52 ` Christian Brauner
  0 siblings, 2 replies; 3+ messages in thread
From: NeilBrown @ 2026-03-26 22:18 UTC (permalink / raw)
  To: Christian Brauner, David Howells
  Cc: Marc Dionne, Paulo Alcantara, netfs, linux-afs, linux-fsdevel,
	linux-kernel


The patch mentioned below changed cachefiles_bury_object() to expect 2
references to the 'rep' dentry.  Three of the callers were changed to
use start_removing_dentry() which takes an extra reference so in those
cases the call gets the expected references.

However there is another call to cachefiles_bury_object() in
cachefiles_cull() which did not need to be changed to use
start_removing_dentry() and so was not properly considered.
It still passed the dentry with just one reference so the net result is
that a reference is lost.

To meet the expectations of cachefiles_bury_object(), cachefiles_cull()
must take an extra reference before the call.  It will be dropped by
cachefiles_bury_object().

Reported-by: Marc Dionne <marc.dionne@auristor.com>
Fixes: 7bb1eb45e43c ("VFS: introduce start_removing_dentry()")
Signed-off-by: NeilBrown <neil@brown.name>
---
 fs/cachefiles/namei.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
index b498c210112b..1b83ed0e0a63 100644
--- a/fs/cachefiles/namei.c
+++ b/fs/cachefiles/namei.c
@@ -781,6 +781,11 @@ int cachefiles_cull(struct cachefiles_cache *cache, struct dentry *dir,
 	if (ret < 0)
 		goto error_unlock;
 
+	/*
+	 * cachefiles_bury_object() expects 2 references to 'victim',
+	 * and drops one.
+	 */
+	dget(victim);
 	ret = cachefiles_bury_object(cache, NULL, dir, victim,
 				     FSCACHE_OBJECT_WAS_CULLED);
 	dput(victim);

base-commit: 84f524dca4b8bc9e9aca8ea1dbbd2aa3a239d998
-- 
2.50.0.107.gf914562f5916.dirty


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] cachefiles: fix incorrect dentry refcount in cachefiles_cull()
  2026-03-26 22:18 [PATCH] cachefiles: fix incorrect dentry refcount in cachefiles_cull() NeilBrown
@ 2026-03-26 23:16 ` Paulo Alcantara
  2026-03-31  9:52 ` Christian Brauner
  1 sibling, 0 replies; 3+ messages in thread
From: Paulo Alcantara @ 2026-03-26 23:16 UTC (permalink / raw)
  To: NeilBrown, Christian Brauner, David Howells
  Cc: Marc Dionne, netfs, linux-afs, linux-fsdevel, linux-kernel

NeilBrown <neilb@ownmail.net> writes:

> The patch mentioned below changed cachefiles_bury_object() to expect 2
> references to the 'rep' dentry.  Three of the callers were changed to
> use start_removing_dentry() which takes an extra reference so in those
> cases the call gets the expected references.
>
> However there is another call to cachefiles_bury_object() in
> cachefiles_cull() which did not need to be changed to use
> start_removing_dentry() and so was not properly considered.
> It still passed the dentry with just one reference so the net result is
> that a reference is lost.
>
> To meet the expectations of cachefiles_bury_object(), cachefiles_cull()
> must take an extra reference before the call.  It will be dropped by
> cachefiles_bury_object().
>
> Reported-by: Marc Dionne <marc.dionne@auristor.com>
> Fixes: 7bb1eb45e43c ("VFS: introduce start_removing_dentry()")
> Signed-off-by: NeilBrown <neil@brown.name>
> ---
>  fs/cachefiles/namei.c | 5 +++++
>  1 file changed, 5 insertions(+)

Acked-by: Paulo Alcantara (Red Hat) <pc@manguebit.org>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] cachefiles: fix incorrect dentry refcount in cachefiles_cull()
  2026-03-26 22:18 [PATCH] cachefiles: fix incorrect dentry refcount in cachefiles_cull() NeilBrown
  2026-03-26 23:16 ` Paulo Alcantara
@ 2026-03-31  9:52 ` Christian Brauner
  1 sibling, 0 replies; 3+ messages in thread
From: Christian Brauner @ 2026-03-31  9:52 UTC (permalink / raw)
  To: David Howells, NeilBrown
  Cc: Christian Brauner, Marc Dionne, Paulo Alcantara, netfs,
	linux-afs, linux-fsdevel, linux-kernel

On Fri, 27 Mar 2026 09:18:21 +1100, NeilBrown wrote:
> The patch mentioned below changed cachefiles_bury_object() to expect 2
> references to the 'rep' dentry.  Three of the callers were changed to
> use start_removing_dentry() which takes an extra reference so in those
> cases the call gets the expected references.
> 
> However there is another call to cachefiles_bury_object() in
> cachefiles_cull() which did not need to be changed to use
> start_removing_dentry() and so was not properly considered.
> It still passed the dentry with just one reference so the net result is
> that a reference is lost.
> 
> [...]

Applied to the vfs.fixes branch of the vfs/vfs.git tree.
Patches in the vfs.fixes branch should appear in linux-next soon.

Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.

It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.

Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs.fixes

[1/1] cachefiles: fix incorrect dentry refcount in cachefiles_cull()
      https://git.kernel.org/vfs/vfs/c/1635c2acdde8

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-03-31  9:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-03-26 22:18 [PATCH] cachefiles: fix incorrect dentry refcount in cachefiles_cull() NeilBrown
2026-03-26 23:16 ` Paulo Alcantara
2026-03-31  9:52 ` Christian Brauner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®