* [PATCH] smb: client: reject userspace cifs.idmap descriptions
@ 2026-09-02 12:52 henrymei
2026-09-02 18:30 ` Paulo Alcantara
0 siblings, 1 reply; 2+ messages in thread
From: henrymei @ 2026-09-02 12:52 UTC (permalink / raw)
To: sfrench
Cc: pc, ronniesahlberg, sprasad, tom, bharathsm, linux-cifs,
samba-technical, Aohan Mei, TencentOS Corvus AI, stable
From: Aohan Mei <henrymei@tencent.com>
cifs.idmap key descriptions carry authority-bearing fields (owner and
group SIDs and uid/gid values in "os:"/"gs:"/"oi:"/"gi:" form) that the
cifs.idmap upcall helper treats as kernel-originating inputs. Unlike
its sibling cifs.spnego, the cifs.idmap key type has no vet_description
hook, so userspace can create keys of this type through
request_key(2)/add_key(2) and supply those fields without CIFS origin.
A request_key(2) call with a non-NULL callout then drives a root
usermodehelper upcall (/sbin/request-key -> cifs.idmap) that consumes
the unvetted description in root context.
Only accept cifs.idmap descriptions while CIFS is using its private
root_cred to request the key. id_to_sid()/sid_to_id() already run
under override_creds(root_cred), so the kernel-originated path is
unaffected.
This mirrors commit 3da1fdf4efbc ("smb: client: reject userspace
cifs.spnego descriptions"), which applied the same restriction to
cifs.spnego.
Fixes: 4d79dba0e007 ("cifs: Add idmap key and related data structures and functions (try #17 repost)")
Reported-by: TencentOS Corvus AI <corvus@tencent.com>
Cc: stable@vger.kernel.org
Assisted-by: CodeBuddy:Kimi-K3
Signed-off-by: Aohan Mei <henrymei@tencent.com>
---
fs/smb/client/cifsacl.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/fs/smb/client/cifsacl.c b/fs/smb/client/cifsacl.c
index 12005f46307d..213a421bf8e9 100644
--- a/fs/smb/client/cifsacl.c
+++ b/fs/smb/client/cifsacl.c
@@ -100,8 +100,23 @@ cifs_idmap_key_destroy(struct key *key)
kfree(key->payload.data[0]);
}
+static int
+cifs_idmap_key_vet_description(const char *description)
+{
+ /*
+ * cifs.idmap descriptions are authority-bearing inputs to the
+ * cifs.idmap upcall helper. Only allow the kernel to create this
+ * type of key using the private root_cred installed in
+ * init_cifs_idmap; reject userspace request_key(2)/add_key(2).
+ */
+ if (current_cred() != root_cred)
+ return -EPERM;
+ return 0;
+}
+
static struct key_type cifs_idmap_key_type = {
.name = "cifs.idmap",
+ .vet_description = cifs_idmap_key_vet_description,
.instantiate = cifs_idmap_key_instantiate,
.destroy = cifs_idmap_key_destroy,
.describe = user_describe,
--
2.43.7
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] smb: client: reject userspace cifs.idmap descriptions
2026-09-02 12:52 [PATCH] smb: client: reject userspace cifs.idmap descriptions henrymei
@ 2026-09-02 18:30 ` Paulo Alcantara
0 siblings, 0 replies; 2+ messages in thread
From: Paulo Alcantara @ 2026-09-02 18:30 UTC (permalink / raw)
To: henrymei, sfrench
Cc: ronniesahlberg, sprasad, tom, bharathsm, linux-cifs,
samba-technical, Aohan Mei, TencentOS Corvus AI, stable
henrymei <ljp1205831794@gmail.com> writes:
> From: Aohan Mei <henrymei@tencent.com>
>
> cifs.idmap key descriptions carry authority-bearing fields (owner and
> group SIDs and uid/gid values in "os:"/"gs:"/"oi:"/"gi:" form) that the
> cifs.idmap upcall helper treats as kernel-originating inputs. Unlike
> its sibling cifs.spnego, the cifs.idmap key type has no vet_description
> hook, so userspace can create keys of this type through
> request_key(2)/add_key(2) and supply those fields without CIFS origin.
> A request_key(2) call with a non-NULL callout then drives a root
> usermodehelper upcall (/sbin/request-key -> cifs.idmap) that consumes
> the unvetted description in root context.
>
> Only accept cifs.idmap descriptions while CIFS is using its private
> root_cred to request the key. id_to_sid()/sid_to_id() already run
> under override_creds(root_cred), so the kernel-originated path is
> unaffected.
> ...
Applied.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-02 18:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-02 12:52 [PATCH] smb: client: reject userspace cifs.idmap descriptions henrymei
2026-09-02 18:30 ` Paulo Alcantara
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.