Compare commits

...

2 Commits

Author SHA1 Message Date
Linus Torvalds 765e56e41a smb client mount fix
-----BEGIN PGP SIGNATURE-----
 
 iQGzBAABCgAdFiEE6fsu8pdIjtWE/DpLiiy9cAdyT1EFAmknmAUACgkQiiy9cAdy
 T1FamAv+NWPndWOfpABbaE8EIQLnrhV3WVzDGWZxfnNp451DSPl9IZmQC7vNq5GD
 1dtR8o1JBtRgpXqypZ88GFMku+iXMBFQN+2x0TPwXcDlPM9F9s9ORab2iovQ+cmc
 G53blZiHO7UpWznC8qZVmgT8aK7oEs8zE5tdARNqe/EjO7RRrF7fCZ8BwBKMNO1X
 rVZWceJ0l8ohX7/DzhsdAXly/tkH+Z1iARtxdQOH6FP1HGYMYun29dwxf69ezMTq
 yt/EE0bausWV/3XB+dnkKQSq8OHdQcFbA6GNqYsNqA+KJRS+GxcWqZwE7pT2N9V6
 fBYQgmGrtzmPC77W+HL43WEP1heQaYZuKIpy0bXY1pufarCoffYUI1zCvdDOoc5z
 nTJzFoWTQ+Wrgi/3Xe/9DgjT5jXXP4Nit+vsEzDgaCEgbxIQzLl6MeW2cU4SiHGX
 tNHIMeYzNxwNTmNGH28f6Y5Z/w6G0gmiOSHHPnNzcCp6Xh5kpOBogssOcdU2tdsT
 ttVs0qac
 =guGI
 -----END PGP SIGNATURE-----

Merge tag 'v6.18rc7-SMB-client-fix' of git://git.samba.org/sfrench/cifs-2.6

Pull smb client fix from Steve French:
 "smb client multiuser (with cifscreds) mount fix"

* tag 'v6.18rc7-SMB-client-fix' of git://git.samba.org/sfrench/cifs-2.6:
  smb: client: fix memory leak in cifs_construct_tcon()
2025-11-26 20:22:20 -08:00
Paulo Alcantara 3184b6a5a2 smb: client: fix memory leak in cifs_construct_tcon()
When having a multiuser mount with domain= specified and using
cifscreds, cifs_set_cifscreds() will end up setting @ctx->domainname,
so it needs to be freed before leaving cifs_construct_tcon().

This fixes the following memory leak reported by kmemleak:

  mount.cifs //srv/share /mnt -o domain=ZELDA,multiuser,...
  su - testuser
  cifscreds add -d ZELDA -u testuser
  ...
  ls /mnt/1
  ...
  umount /mnt
  echo scan > /sys/kernel/debug/kmemleak
  cat /sys/kernel/debug/kmemleak
  unreferenced object 0xffff8881203c3f08 (size 8):
    comm "ls", pid 5060, jiffies 4307222943
    hex dump (first 8 bytes):
      5a 45 4c 44 41 00 cc cc                          ZELDA...
    backtrace (crc d109a8cf):
      __kmalloc_node_track_caller_noprof+0x572/0x710
      kstrdup+0x3a/0x70
      cifs_sb_tlink+0x1209/0x1770 [cifs]
      cifs_get_fattr+0xe1/0xf50 [cifs]
      cifs_get_inode_info+0xb5/0x240 [cifs]
      cifs_revalidate_dentry_attr+0x2d1/0x470 [cifs]
      cifs_getattr+0x28e/0x450 [cifs]
      vfs_getattr_nosec+0x126/0x180
      vfs_statx+0xf6/0x220
      do_statx+0xab/0x110
      __x64_sys_statx+0xd5/0x130
      do_syscall_64+0xbb/0x380
      entry_SYSCALL_64_after_hwframe+0x77/0x7f

Fixes: f2aee329a6 ("cifs: set domainName when a domain-key is used in multiuser")
Signed-off-by: Paulo Alcantara (Red Hat) <pc@manguebit.org>
Reviewed-by: David Howells <dhowells@redhat.com>
Cc: Jay Shin <jaeshin@redhat.com>
Cc: stable@vger.kernel.org
Cc: linux-cifs@vger.kernel.org
Signed-off-by: Steve French <stfrench@microsoft.com>
2025-11-25 18:00:06 -06:00
1 changed files with 1 additions and 0 deletions

View File

@ -4451,6 +4451,7 @@ cifs_construct_tcon(struct cifs_sb_info *cifs_sb, kuid_t fsuid)
out:
kfree(ctx->username);
kfree(ctx->domainname);
kfree_sensitive(ctx->password);
kfree(origin_fullpath);
kfree(ctx);