From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 D0ACA1FBEA8 for ; Tue, 11 Aug 2026 15:46:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786463196; cv=none; b=GsivNGmSf8El4ysTNp/hqig5j2d4xrJWPibCpaF5/T+OpCC8SX1xHIm8K2TetwC7+/TSSyW5epUIbbXW2a8jlJhLkb5M/pYULvN4f0NaTdBRpqENewqQuFth4JEyO/nIXSq71WaYh7uRGW92gbbqG9LNXa69JbQeAk+B/j/II1A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786463196; c=relaxed/simple; bh=alkQrT/mp6qBDWwuI/IMtkXcvcIMzyUeSo16FQJCm5o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Hn8sRmPxSuL1ylc/D2jkpz/GQGdcb56yV/V5vztjukgHIGEOsQnspMY4N5GN/4lTJ0SkviA/FT4RPUAzyZo+8KX+cG64MdWk/g2d48T9x7laPr+eDZ1LTzWFuUL10shoRk4LkdLXkQ1r93kK7bV+tVd6GEQQm/zaHXf9jrxglus= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=cxS99fOK; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="cxS99fOK" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1786463193; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gh+3eC2KDdxNiPOue5nNMywvzbbZjC53wM5BXCY+I2U=; b=cxS99fOKDce22aSGaTYx1oGpJKOC9nDTkXrWHbQmf0Ps0t/OE41Ef4vL5yWVucjxhW8jJz sXKzXOfC9XRZxzLxX9On09G1H9bW0FawKbOqJBCgz9e14ZRSh1JQLiJbOWD0hF9bEE7Hu8 W/yceVa2x0cPYalLPSgs+zOXaU0D5n8= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-193-37Mocu0lMt6yymDuv66_QQ-1; Tue, 11 Aug 2026 11:46:30 -0400 X-MC-Unique: 37Mocu0lMt6yymDuv66_QQ-1 X-Mimecast-MFC-AGG-ID: 37Mocu0lMt6yymDuv66_QQ_1786463189 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 46128195604A; Tue, 11 Aug 2026 15:46:29 +0000 (UTC) Received: from thuth-p1g4.redhat.corp (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 18A893001DAF; Tue, 11 Aug 2026 15:46:26 +0000 (UTC) From: Thomas Huth To: Namjae Jeon , Steve French Cc: linux-kernel@vger.kernel.org, Sergey Senozhatsky , Tom Talpey Subject: [PATCH v2 2/5] smb: server: Make sure that passkey is not leaked on the heap in user_config.c Date: Tue, 11 Aug 2026 17:46:17 +0200 Message-ID: <20260811154620.2425851-3-thuth@redhat.com> In-Reply-To: <20260811154620.2425851-1-thuth@redhat.com> References: <20260811154620.2425851-1-thuth@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 From: Thomas Huth Use kfree_sensitive() to free the user->passkey (and the struct ksmbd_login_response in ksmbd_login_user() that contains the same information) to avoid that this information could leak somewhere else via the heap. Signed-off-by: Thomas Huth --- fs/smb/server/mgmt/user_config.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/smb/server/mgmt/user_config.c b/fs/smb/server/mgmt/user_config.c index cf45841d9d1b9..76b74d68369d8 100644 --- a/fs/smb/server/mgmt/user_config.c +++ b/fs/smb/server/mgmt/user_config.c @@ -27,7 +27,7 @@ struct ksmbd_user *ksmbd_login_user(const char *account) user = ksmbd_alloc_user(resp, resp_ext); out: - kvfree(resp); + kvfree_sensitive(resp, sizeof(*resp)); return user; } @@ -70,7 +70,7 @@ struct ksmbd_user *ksmbd_alloc_user(struct ksmbd_login_response *resp, err_free: kfree(user->name); - kfree(user->passkey); + kfree_sensitive(user->passkey); kfree(user); return NULL; } @@ -80,7 +80,7 @@ void ksmbd_free_user(struct ksmbd_user *user) ksmbd_ipc_logout_request(user->name, user->flags); kfree(user->sgid); kfree(user->name); - kfree(user->passkey); + kfree_sensitive(user->passkey); kfree(user); } -- 2.55.0