]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
cifs: validate idmap key payload length
authorLi Qiang <liqiang01@kylinos.cn>
Sat, 18 Jul 2026 16:22:27 +0000 (00:22 +0800)
committerSteve French <stfrench@microsoft.com>
Sun, 26 Jul 2026 22:40:20 +0000 (17:40 -0500)
The cifs.idmap key type stores its payload length in key->datalen, which
is limited to U16_MAX.  Accepting a larger key payload truncates the
recorded length and can make later users interpret the payload using
inconsistent bounds.

Reject oversized preparsed payloads before allocating or copying them.
This keeps key->datalen consistent with the stored data for both inline
and separately allocated idmap payloads.

Signed-off-by: Li Qiang <liqiang01@kylinos.cn>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/client/cifsacl.c

index 9424281a7674cbd3239c16bfcc936d2057ae07ec..12005f46307dea8b307c95b38de94d9429b64a53 100644 (file)
@@ -68,6 +68,9 @@ cifs_idmap_key_instantiate(struct key *key, struct key_preparsed_payload *prep)
 {
        char *payload;
 
+       if (prep->datalen > U16_MAX)
+               return -EINVAL;
+
        /*
         * If the payload is less than or equal to the size of a pointer, then
         * an allocation here is wasteful. Just copy the data directly to the