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 1DBA83CA49D for ; Tue, 11 Aug 2026 15:46:42 +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=1786463203; cv=none; b=ctkdVbdWgkTYM+UfhEyOuDge7VL1x3203Zknw68S522BWhd+JiWiqlc0nEOBcJa2TSN+onXTFNPlXAaRmrLm+iz/jYFF5/PH+bi7McuA2ISaFD0apdLWP3fw4PrBVnrU0JeAGZa+x+L4GsX/AMM0TVthV2XVsAqs+erBEx2ewQs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786463203; c=relaxed/simple; bh=ex0ZLh6PKM9tufyYifIvVZQa8wH4ttTGPtURlhEQxuk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tZWg2VhZK37xEeCn9tqbZJcZpfroNmAx7w2ytEwzg0vVUj3PvAEuDcLbKdb7FMjyuDTpcIu/cI5CiQUvGfc/xQtSYl0/25yJY5MZbr/trGoMyVqEU436xHVVDWpc0HYqi0nj1X47lxO9QPE/9K1gKg34H6Fevbmwd5HsD8b28p4= 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=ea9o8jHx; 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="ea9o8jHx" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1786463201; 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=5a3EYPNVNlTBxGyC1VQCAo3aVVrthuP9CHEFYO6QRH8=; b=ea9o8jHxw5u/KIpi/0VS2GTtLD9AaxocxHMcpqON8rPqAvnFVxmnEilKfum+1E8HdL7FYq Os8DwcOujcftemuhoyx282L0hY7z9VpImuwCaA/6G4chIM82IAmOE/+i8ShbP1n4/GeBeI XNChZs0jbkK1qSlSb05NVwNuaX6KHTU= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-57-nNw22ZTIOWOZoqK6Az86pg-1; Tue, 11 Aug 2026 11:46:36 -0400 X-MC-Unique: nNw22ZTIOWOZoqK6Az86pg-1 X-Mimecast-MFC-AGG-ID: nNw22ZTIOWOZoqK6Az86pg_1786463195 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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id DE79D1800578; Tue, 11 Aug 2026 15:46:34 +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 B5FCA3002D29; Tue, 11 Aug 2026 15:46:32 +0000 (UTC) From: Thomas Huth To: Namjae Jeon , Steve French Cc: linux-kernel@vger.kernel.org, Sergey Senozhatsky , Tom Talpey Subject: [PATCH v2 4/5] smb: server: Free sensitive data in connection.c with kfree_sensitive() Date: Tue, 11 Aug 2026 17:46:19 +0200 Message-ID: <20260811154620.2425851-5-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 struct ksmbd_conn contains an embedded struct ntlmssp_auth with the ciphertext[] and cryptkey[] arrays, so to avoid leaking this information via the heap, it should be freed with kfree_sensitive(). While we're at it, also use kfree_sensitive() for freeing preauth_info in ksmbd_conn_free() to avoid that the Preauth_HashValue[] could leak via the heap here, too. Signed-off-by: Thomas Huth --- fs/smb/server/connection.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/smb/server/connection.c b/fs/smb/server/connection.c index ef6f202f4024c..68b9e698b1cb6 100644 --- a/fs/smb/server/connection.c +++ b/fs/smb/server/connection.c @@ -117,7 +117,7 @@ static void __ksmbd_conn_release_work(struct work_struct *work) ida_destroy(&conn->async_ida); conn->transport->ops->free_transport(conn->transport); - kfree(conn); + kfree_sensitive(conn); } /** @@ -183,7 +183,7 @@ void ksmbd_conn_free(struct ksmbd_conn *conn) */ xa_destroy(&conn->sessions); kvfree(conn->request_buf); - kfree(conn->preauth_info); + kfree_sensitive(conn->preauth_info); kfree(conn->mechToken); ksmbd_conn_put(conn); } @@ -671,7 +671,7 @@ static void stop_sessions(void) if (atomic_dec_and_test(&target->refcnt)) { ida_destroy(&target->async_ida); t->ops->free_transport(t); - kfree(target); + kfree_sensitive(target); } goto again; } -- 2.55.0