smb: client: fix filename matching of deferred files
authorPaulo Alcantara <pc@manguebit.org>
Wed, 17 Sep 2025 19:03:22 +0000 (16:03 -0300)
committerSteve French <stfrench@microsoft.com>
Thu, 18 Sep 2025 01:33:44 +0000 (20:33 -0500)
commit93ed9a2951308db374cba4562533dde97bac70d3
tree792b78e41420e2b6bb9742599d49a69c4b52d58d
parentf57e53ea252363234f86674db475839e5b87102e
smb: client: fix filename matching of deferred files

Fix the following case where the client would end up closing both
deferred files (foo.tmp & foo) after unlink(foo) due to strstr() call
in cifs_close_deferred_file_under_dentry():

  fd1 = openat(AT_FDCWD, "foo", O_WRONLY|O_CREAT|O_TRUNC, 0666);
  fd2 = openat(AT_FDCWD, "foo.tmp", O_WRONLY|O_CREAT|O_TRUNC, 0666);
  close(fd1);
  close(fd2);
  unlink("foo");

Fixes: e3fc065682eb ("cifs: Deferred close performance improvements")
Signed-off-by: Paulo Alcantara (Red Hat) <pc@manguebit.org>
Reviewed-by: Enzo Matsumiya <ematsumiya@suse.de>
Cc: Frank Sorenson <sorenson@redhat.com>
Cc: David Howells <dhowells@redhat.com>
Cc: linux-cifs@vger.kernel.org
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/client/cifsproto.h
fs/smb/client/inode.c
fs/smb/client/misc.c