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 DB4701FBEA8 for ; Tue, 11 Aug 2026 15:46:29 +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=1786463191; cv=none; b=aFADkf3FArYwNpXsZ3HNIYOjalX3boyydPOCGDyLZGS3TCC9m8DXcg1OCq6xkx3WP9NoeAB8Zjir5bWK3Amh3M+3PfQXsB246qeuC7CZjd4GBw5n7NbpgTReIsrKmv4BDAg8lkZGzVvwdoY1KN8hLYTiYxCzRzIDjgVVdjH4bBU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786463191; c=relaxed/simple; bh=oP+NeYObdFj5583QUTOe2uVDKpFphwW+Vkei2NFLo08=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=ZQhTTad4Ul0AglSGXZxHYZFEPZem3IiJ5dla14zl96UyiIGTlaNt1zPAJYcoxk2aplHkOewg2zaJ/LueqVWn2q72SqN60gaZB9PmrNjTZtAEupiAwoBCTpCyw40bPbMCgCVmYwauq+0Yh7t/3Oq12x9RkFe/BUT9vWFK9RA/hhE= 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=AeAHC/tn; 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="AeAHC/tn" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1786463188; 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; bh=yRdwzRiYjigpURNM/k4wo+V+5VlxFJwIArfK8gSI9j0=; b=AeAHC/tnxEjZtoJAjah/QRRDhRfmQYld2qDPFzSjoBOloyfVTB277j1hVqU/kE36er+zcS auG0uo6bkm4lVuayn1MUTcp6nEJJAs/pKSxda+Rpf7tZc7jIuHf3cBrsvRaxtplrqOLIsC GPaLK7kCpEAGmif5XvFbk8VDF6nI3bk= 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-141-PD6PSsOrObqzGz9pKkSxLQ-1; Tue, 11 Aug 2026 11:46:25 -0400 X-MC-Unique: PD6PSsOrObqzGz9pKkSxLQ-1 X-Mimecast-MFC-AGG-ID: PD6PSsOrObqzGz9pKkSxLQ_1786463184 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 0254F18005B3; Tue, 11 Aug 2026 15:46:24 +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 B51023001DAF; Tue, 11 Aug 2026 15:46:21 +0000 (UTC) From: Thomas Huth To: Namjae Jeon , Steve French Cc: linux-kernel@vger.kernel.org, Sergey Senozhatsky , Tom Talpey Subject: [PATCH v2 0/5] smb: server: Clear sensitive data before freeing it Date: Tue, 11 Aug 2026 17:46:15 +0200 Message-ID: <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 Sensitive data like keys that are stored in stack-local arrays could be leaked via the stack to the calling functions, or via the heap when using only normal kfree() functions. It's good security practice to clear sensitive data on the stack first with memzero_explicit() before leaving the context, and to use kfree_sensitive() for data that is returned to the heap. Disclaimer: The spots that need clearing have been identified with AI, but the patches have been created manually (for double-checking whether the findings really make sense). Anyway, I'm not very familiar with the smb code, so please review carefully. Thanks! v2: - Calculate proper size for the kvfree_sensitive() in the first patch - Add "kfree_sensitive(target)" hunk to the connection.c patch - Add patch to clear Preauth_HashValue in smb2pdu.c Thomas Huth (5): smb: server: Clear sensitive stack and heap data in auth.c smb: server: Make sure that passkey is not leaked on the heap in user_config.c smb: server: Free session data in user_session.c with kfree_sensitive() smb: server: Free sensitive data in connection.c with kfree_sensitive() smb: server: Clear Preauth_HashValue in smb2pdu.c with kfree_sensitive() fs/smb/server/auth.c | 12 ++++++++++-- fs/smb/server/connection.c | 6 +++--- fs/smb/server/mgmt/user_config.c | 6 +++--- fs/smb/server/mgmt/user_session.c | 4 ++-- fs/smb/server/smb2pdu.c | 4 ++-- 5 files changed, 20 insertions(+), 12 deletions(-) -- 2.55.0