From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 26D7C313546; Wed, 3 Dec 2025 16:46:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764780407; cv=none; b=RGdEPO3PGG9Gt+F6VMboCIdLzbDodkHxG2qDXGllI9wTEsL4WN36HnvdqbK1UoFymLa53s2t4UbXUYNXrLVEF3TLkybqgjujPQ0nxowUNIrrse718aWV/OA6grBMChwHjDFiZlKUQAnPXBr5VOlmechb5ev7t2vR8W053NcG7yM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764780407; c=relaxed/simple; bh=aZxajvLlTNhyhqWAjX2pHYaSMfRqUwrVWiOlVbUV9pM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pxcCgcIbc6+QMtTM9V0z0FD1JBRnLPPZYWQIMysSGacBr+gLVNpWVve940gvubdsbCi7JFV9FJPj6bwB9zXcUjxYM4tDPYtXwcW/Dcitc67a20Iv5gPrUesCFO7pHdhsLADrrfbeTaXcTZJ8U7HFpiuQx9W53QxzchSZ3ey3mSM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=LdJP7m7w; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="LdJP7m7w" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5DA03C4CEF5; Wed, 3 Dec 2025 16:46:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1764780406; bh=aZxajvLlTNhyhqWAjX2pHYaSMfRqUwrVWiOlVbUV9pM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LdJP7m7wYAAQWWBq8Xl4toUX29YVakVfQOOkdfEcbt9Kp3Tq2s7DNMvcmx7qHgaLv 1f+2BR7rCl5tROTb1FdOK4KeFV1qOrUvg6uFHUjLEbBnaJYMH0BEa0BDToPLidR8rg 4PhiRyDxg4k2O3QNj2KClcOIsF/Q6A9WnNTjXKmY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, "Paulo Alcantara (Red Hat)" , David Howells , Jay Shin , linux-cifs@vger.kernel.org, Steve French Subject: [PATCH 6.1 530/568] smb: client: fix memory leak in cifs_construct_tcon() Date: Wed, 3 Dec 2025 16:28:52 +0100 Message-ID: <20251203152500.126902019@linuxfoundation.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251203152440.645416925@linuxfoundation.org> References: <20251203152440.645416925@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Paulo Alcantara commit 3184b6a5a24ec9ee74087b2a550476f386df7dc2 upstream. 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: f2aee329a68f ("cifs: set domainName when a domain-key is used in multiuser") Signed-off-by: Paulo Alcantara (Red Hat) Reviewed-by: David Howells Cc: Jay Shin Cc: stable@vger.kernel.org Cc: linux-cifs@vger.kernel.org Signed-off-by: Steve French Signed-off-by: Greg Kroah-Hartman --- fs/smb/client/connect.c | 1 + 1 file changed, 1 insertion(+) --- a/fs/smb/client/connect.c +++ b/fs/smb/client/connect.c @@ -4417,6 +4417,7 @@ cifs_construct_tcon(struct cifs_sb_info out: kfree(ctx->username); + kfree(ctx->domainname); kfree_sensitive(ctx->password); kfree(ctx);