Skip to content

Commit 4db2bd2

Browse files
mjbommarwesteri
authored andcommitted
thunderbolt: Limit XDomain response copy to actual frame size
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: cdae7c0 ("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>
1 parent a504b9f commit 4db2bd2

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

drivers/thunderbolt/xdomain.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,9 @@ static bool tb_xdomain_match(const struct tb_cfg_request *req,
123123
static bool tb_xdomain_copy(struct tb_cfg_request *req,
124124
const struct ctl_pkg *pkg)
125125
{
126-
memcpy(req->response, pkg->buffer, req->response_size);
126+
size_t len = min_t(size_t, pkg->frame.size, req->response_size);
127+
128+
memcpy(req->response, pkg->buffer, len);
127129
req->result.err = 0;
128130
return true;
129131
}

0 commit comments

Comments
 (0)