Skip to content

Commit 085e987

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 upstream-diff | File path: upstream uses fs/smb/client/cifs_spnego.c, this branch uses fs/cifs/cifs_spnego.c. Code is identical. 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 cbdb778 commit 085e987

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

fs/cifs/cifs_spnego.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
*/
2121

2222
#include <linux/list.h>
23+
#include <linux/cred.h>
2324
#include <linux/slab.h>
2425
#include <linux/string.h>
2526
#include <keys/user-type.h>
@@ -58,12 +59,27 @@ cifs_spnego_key_destroy(struct key *key)
5859
kfree(key->payload.data[0]);
5960
}
6061

62+
static int
63+
cifs_spnego_key_vet_description(const char *description)
64+
{
65+
/*
66+
* cifs.spnego descriptions are authority-bearing inputs to cifs.upcall.
67+
* They are only valid when produced by CIFS while using the private
68+
* spnego_cred installed below. Do not let userspace create this type
69+
* of key through request_key(2)/add_key(2), since the helper treats
70+
* pid/uid/creduid/upcall_target as kernel-originating fields.
71+
*/
72+
if (current_cred() != spnego_cred)
73+
return -EPERM;
74+
return 0;
75+
}
6176

6277
/*
6378
* keytype for CIFS spnego keys
6479
*/
6580
struct key_type cifs_spnego_key_type = {
6681
.name = "cifs.spnego",
82+
.vet_description = cifs_spnego_key_vet_description,
6783
.instantiate = cifs_spnego_key_instantiate,
6884
.destroy = cifs_spnego_key_destroy,
6985
.describe = user_describe,

0 commit comments

Comments
 (0)