]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
thunderbolt: Limit XDomain response copy to actual frame size
authorMichael Bommarito <michael.bommarito@gmail.com>
Mon, 25 May 2026 09:28:29 +0000 (05:28 -0400)
committerMika Westerberg <mika.westerberg@linux.intel.com>
Tue, 26 May 2026 13:18:31 +0000 (15:18 +0200)
tb_xdomain_copy() copies req->response_size bytes from the received
packet buffer regardless of the actual frame size.  When a short
response arrives, this reads past the valid frame data in the DMA
pool buffer into stale contents from previous transactions.

Use the minimum of frame size and expected response size for the
copy length.

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 9d54e3ccc827899da43a4a395851feb76316187d..1fd1cf4295a2a58f307d2a6ed7d47899f962adc4 100644 (file)
@@ -123,7 +123,9 @@ static bool tb_xdomain_match(const struct tb_cfg_request *req,
 static bool tb_xdomain_copy(struct tb_cfg_request *req,
                            const struct ctl_pkg *pkg)
 {
-       memcpy(req->response, pkg->buffer, req->response_size);
+       size_t len = min_t(size_t, pkg->frame.size, req->response_size);
+
+       memcpy(req->response, pkg->buffer, len);
        req->result.err = 0;
        return true;
 }