Skip to content

Commit 9f123cf

Browse files
shreeya-patel98bmastbergen
authored andcommitted
smb: client: reject userspace cifs.spnego descriptions
cve CVE-Pending commit-author Asim Viladi Oglu Manizada <manizada@pm.me> commit 3da1fdf cifs.spnego key descriptions contain authority-bearing fields such as pid, uid, creduid, and upcall_target that cifs.upcall treats as kernel-originating inputs. However, userspace can also create keys of this type through request_key(2) or add_key(2), allowing those fields to be supplied without CIFS origin. Only accept cifs.spnego descriptions while CIFS is using its private spnego_cred to request the key. Fixes: f1d662a ("[CIFS] Add upcall files for cifs to use spnego/kerberos") Assisted-by: avom-custom-harness:gpt-5.5-qwen3.6-mod-mix Reviewed-by: David Howells <dhowells@redhat.com> Signed-off-by: Asim Viladi Oglu Manizada <manizada@pm.me> Signed-off-by: Steve French <stfrench@microsoft.com> Signed-off-by: Shreeya Patel <spatel@ciq.com>
1 parent 82b3762 commit 9f123cf

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

fs/smb/client/cifs_spnego.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
*/
99

1010
#include <linux/list.h>
11+
#include <linux/cred.h>
1112
#include <linux/slab.h>
1213
#include <linux/string.h>
1314
#include <keys/user-type.h>
@@ -46,12 +47,27 @@ cifs_spnego_key_destroy(struct key *key)
4647
kfree(key->payload.data[0]);
4748
}
4849

50+
static int
51+
cifs_spnego_key_vet_description(const char *description)
52+
{
53+
/*
54+
* cifs.spnego descriptions are authority-bearing inputs to cifs.upcall.
55+
* They are only valid when produced by CIFS while using the private
56+
* spnego_cred installed below. Do not let userspace create this type
57+
* of key through request_key(2)/add_key(2), since the helper treats
58+
* pid/uid/creduid/upcall_target as kernel-originating fields.
59+
*/
60+
if (current_cred() != spnego_cred)
61+
return -EPERM;
62+
return 0;
63+
}
4964

5065
/*
5166
* keytype for CIFS spnego keys
5267
*/
5368
struct key_type cifs_spnego_key_type = {
5469
.name = "cifs.spnego",
70+
.vet_description = cifs_spnego_key_vet_description,
5571
.instantiate = cifs_spnego_key_instantiate,
5672
.destroy = cifs_spnego_key_destroy,
5773
.describe = user_describe,

0 commit comments

Comments
 (0)