mirror of
https://github.com/torvalds/linux.git
synced 2026-09-23 22:14:03 +02:00
cxl/features: Reject Get Feature count larger than the output buffer
cxlctl_get_feature() sizes its output buffer from the user's
fwctl_rpc.out_len, but the device is told to write
cxl_mbox_get_feat_in.count bytes into rpc_out->payload, which is a
separate user-controlled value. Nothing bounds count against out_len, so
a small out_len with a large count overflows the kvzalloc()'d buffer.
A heap OOB write reachable from FWCTL_RPC.
Reject requests where count exceeds the available payload room, before
allocating.
Fixes: 5908f3ed6d ("cxl: Add support to handle user feature commands for get feature")
Reviewed-by: Kai-Heng Feng <kaihengf@nvidia.com>
Reviewed-by: Koba Ko <kobak@nvidia.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Richard Cheng <icheng@nvidia.com>
Reviewed-by: Alison Schofield <alison.schofield@intel.com>
Link: https://patch.msgid.link/20260626104102.53892-2-icheng@nvidia.com
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
This commit is contained in:
parent
a623128bc2
commit
4bf6bac375
|
|
@ -474,6 +474,10 @@ static void *cxlctl_get_feature(struct cxl_features_state *cxlfs,
|
|||
if (!count)
|
||||
return ERR_PTR(-EINVAL);
|
||||
|
||||
if (out_size < offsetof(struct fwctl_rpc_cxl_out, payload) ||
|
||||
count > out_size - offsetof(struct fwctl_rpc_cxl_out, payload))
|
||||
return ERR_PTR(-EINVAL);
|
||||
|
||||
struct fwctl_rpc_cxl_out *rpc_out __free(kvfree) =
|
||||
kvzalloc(out_size, GFP_KERNEL);
|
||||
if (!rpc_out)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user