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 3C5C0330B06; Wed, 3 Dec 2025 15:52:11 +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=1764777131; cv=none; b=bzGRtxaOTElZ3QrLDIOM3vGcwaLDcD3D7XLxTj8TPQgT2ZXubjJ0NgoEFGdy2Bn2/Tw52uHtJoDDMiWeVd1HFcBAzN8Th1tujGtBegLl7hX9cFEOVxRYf+HNL9fhrWCvDx+8WZmcAUFEmQuYo4rRtKY5QG9TCqZ7CU3BC9KU5HQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764777131; c=relaxed/simple; bh=Y5gCbpbOO1NVJZjVnlDdO+I1RMSVjrmG08ReE3F3c6A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TubC52mc6gsS1Zrk6QACC7H04tSs8BpI3Zf91bQCJFBkw/q6a/60zP/v2h6pMdcENY8CadViW3yfEZeQMCiW5hoUXQrVPsN0eg3FCIO6NCb6FfrybLeBVP2OE+FE7BJiduq6jlRsTqIkPs6huZcGWInOqqdc+jA/jrEFz5tirbs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=rqPKTQL1; 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="rqPKTQL1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A093CC116B1; Wed, 3 Dec 2025 15:52:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1764777131; bh=Y5gCbpbOO1NVJZjVnlDdO+I1RMSVjrmG08ReE3F3c6A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rqPKTQL1xqPmrruWynba7BVEjeV+TfA07c8yc7qLXGsDoecmkr6yqIu/6hbHqzyiJ 8HiQI/ZozWgQN5p5YgFZYa61XWEmF7h50bZwR6QcEGZzIWUg5ysvMJtanvzUVNeDRW R/TmIR3539c2zbNEU6KqqQCXTeo+aK1DwKk8eEm0= 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.17 091/146] smb: client: fix memory leak in cifs_construct_tcon() Date: Wed, 3 Dec 2025 16:27:49 +0100 Message-ID: <20251203152349.790977408@linuxfoundation.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251203152346.456176474@linuxfoundation.org> References: <20251203152346.456176474@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.17-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 @@ -4455,6 +4455,7 @@ cifs_construct_tcon(struct cifs_sb_info out: kfree(ctx->username); + kfree(ctx->domainname); kfree_sensitive(ctx->password); kfree(origin_fullpath); kfree(ctx);