mirror of
https://github.com/torvalds/linux.git
synced 2026-09-23 13:14:02 +02:00
cxl/features: Reject Set Features output buffer smaller than the header
cxlctl_set_feature() sizes its output buffer from the user's
fwctl_rpc.out_len but never checks it is large enough to hold even the
fwctl_rpc_cxl_out header. With out_len == 0 , kvzalloc() returns
ZERO_SIZE_PTR, which passes the !rpc_out check, the subsequent
rpc_out->size = 0 then writes through the poison pointer.
Reject requests whose output buffer can't hold the response header,
before allocating. The Set Feature reply carries no payload, so the
header is all that is required.
Fixes: eb5dfcb9e3 ("cxl: Add support to handle user feature commands for set feature")
Signed-off-by: Richard Cheng <icheng@nvidia.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Reviewed-by: Alison Schofield <alison.schofield@intel.com>
Link: https://patch.msgid.link/20260626104102.53892-3-icheng@nvidia.com
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
This commit is contained in:
parent
4bf6bac375
commit
cde18d6c1d
|
|
@ -523,6 +523,9 @@ static void *cxlctl_set_feature(struct cxl_features_state *cxlfs,
|
|||
flags = le32_to_cpu(feat_in->flags);
|
||||
out_size = *out_len;
|
||||
|
||||
if (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