Skip to content

Commit e753773

Browse files
Yeonba0918jgunthorpe
authored andcommitted
fwctl: pds: Validate RPC input size before parsing
The fwctl core allocates the device-specific RPC input buffer with fwctl_rpc.in_len and passes that buffer to the driver callback. pdsfc_fw_rpc() casts the buffer to struct fwctl_rpc_pds and then calls pdsfc_validate_rpc(), which reads fields from that structure before checking that the input buffer is large enough to contain it. A short in_len can make pds_fwctl read beyond the allocation. Reject pds RPC buffers that are smaller than struct fwctl_rpc_pds before parsing any pds-specific fields. Fixes: 92c66ee ("pds_fwctl: add rpc and query support") Link: https://patch.msgid.link/r/20260517062232.1858747-1-gganji11@naver.com Cc: stable@vger.kernel.org # v6.15+ Signed-off-by: Heechan Kang <gganji11@naver.com> Reviewed-by: Dave Jiang <dave.jiang@intel.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
1 parent 5200f5f commit e753773

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

drivers/fwctl/pds/main.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,9 @@ static void *pdsfc_fw_rpc(struct fwctl_uctx *uctx, enum fwctl_rpc_scope scope,
362362
void *out = NULL;
363363
int err;
364364

365+
if (in_len < sizeof(*rpc))
366+
return ERR_PTR(-EINVAL);
367+
365368
err = pdsfc_validate_rpc(pdsfc, rpc, scope);
366369
if (err)
367370
return ERR_PTR(err);

0 commit comments

Comments
 (0)