]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
thunderbolt: Clamp XDomain response data copy to allocation size
authorMichael Bommarito <michael.bommarito@gmail.com>
Mon, 25 May 2026 09:28:27 +0000 (05:28 -0400)
committerMika Westerberg <mika.westerberg@linux.intel.com>
Tue, 26 May 2026 13:18:25 +0000 (15:18 +0200)
tb_xdp_properties_request() derives the per-packet copy length from
the response header without checking that it fits in the previously
allocated data buffer.  A malicious peer can set its length field
larger than the declared data_length, causing memcpy to write past
the kcalloc allocation.

Clamp the per-packet copy length so that the cumulative offset
never exceeds data_len.

Fixes: cdae7c07e3e3 ("thunderbolt: Add support for XDomain properties")
Cc: stable@vger.kernel.org
Assisted-by: Claude:claude-opus-4-7
Signed-off-by: Michael Bommarito <michael.bommarito@gmail.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
drivers/thunderbolt/xdomain.c

index 754808c43f0067bd45c74afed29e4817b336192a..4099419c747952e1f29bdc7073ee625c3c8f90fb 100644 (file)
@@ -393,6 +393,8 @@ static int tb_xdp_properties_request(struct tb_ctl *ctl, u64 route,
                        }
                }
 
+               if (req.offset + len > data_len)
+                       len = data_len - req.offset;
                memcpy(data + req.offset, res->data, len * 4);
                req.offset += len;
        } while (!data_len || req.offset < data_len);