cxl: fix return value in cxlctl_validate_set_features()
Subsystems (2)
PATCH 1/1 cxl: fix return value in cxlctl_validate_set_features()
The cxlctl_validate_set_features() function is type bool. It's supposed to return true for valid requests and false for invalid. However, this error path returns ERR_PTR(-EINVAL) which is true when it was intended to return false.
--- drivers/cxl/core/features.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cxl/core/features.c +1 -1
@@ -544,7 +544,7 @@ static bool cxlctl_validate_set_features(struct cxl_features_state *cxlfs,u32 flags;if (rpc_in->op_size <sizeof (uuid_t)) -return ERR_PTR (-EINVAL ); +return false; feat =cxl_feature_info (cxlfs, &rpc_in->set_feat_in.uuid);if (IS_ERR (feat))
Signature · 1 line
2.47.2
Alison Schofield
maintainerQuoted 4 lines · Dan Carpenter
The
cxlctl_validate_set_features()function is type bool. It's supposed to return true for valid requests and false for invalid. However, this error path returnsERR_PTR(-EINVAL)which is true when it was intended to return false.
Shiju - Can you trace this one through and add the impact statement? Wondering if this is going to fail gracefully, or badly, further down this path?
Quoted 23 lines
Fixes f76e0bbc8bc3 ("cxl: Update prototype of function get_support_feature_info()")Signed-off-by Dan Carpenter <[email protected]>--- drivers/cxl/core/features.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/cxl/core/features.c +1
-1@@ -544,7 +544,7 @@ static bool cxlctl_validate_set_features(struct cxl_features_state *cxlfs,u32 flags;if (rpc_in->op_size <sizeof (uuid_t)) -return ERR_PTR (-EINVAL ); +return false; feat =cxl_feature_info (cxlfs, &rpc_in->set_feat_in.uuid);if (IS_ERR (feat))Signature · 1 line
2.47.2
Quoted 10 lines · Alison Schofield
Quoted 4 lines · Dan Carpenter
The
cxlctl_validate_set_features()function is type bool. It's supposed to return true for valid requests and false for invalid. However, this error path returnsERR_PTR(-EINVAL)which is true when it was intended to return false.Shiju - Can you trace this one through and add the impact statement? Wondering if this is going to fail gracefully, or badly, further down this path?
Sorry, I would normally analyse this a bit more myself, but it's only in linux-next so I assumed no one was using it yet. It ends up being fine.
cxlctl_set_feature() has a check for:
if (rpc_in->op_size <= sizeof(feat_in->hdr))
at the start and sizeof(feat_in->hdr) is larger than sizeof(uuid_t).
regards,
dan carpenter
Quoted 13 lines
-----Original Message-----
From: Alison Schofield <[email protected]>
Sent: 28 May 2025 16:23
To: Shiju Jose <[email protected]>; Dan Carpenter <[email protected]>
Cc: Davidlohr Bueso <[email protected]>; Jonathan Cameron <[email protected]>; Dave Jiang <[email protected]>; Vishal Verma <[email protected]>; Ira Weiny <[email protected]>; Dan Williams <[email protected]>; Li Ming <[email protected]>; Fan Ni <[email protected]>; [email protected]; linux- [email protected]; [email protected]
Subject: Re: [PATCH next] cxl: fix return value incxlctl_validate_set_features()
Quoted 8 lines
Quoted 4 lines · Dan Carpenter
The
cxlctl_validate_set_features()function is type bool. It's supposed to return true for valid requests and false for invalid. However, this error path returnsERR_PTR(-EINVAL)which is true when it was intended to return false.Shiju - Can you trace this one through and add the impact statement? Wondering if this is going to fail gracefully, or badly, further down this path?
Hi Alison,
This is introduced when following fwctl specific code move out of common function (use both in fwctl and edac path) get_support_feature_info() to fwctl specific function cxlctl_validae_set_feature().
"if (rpc_in->op_size < sizeof(uuid_t))
return ERR_PTR(-EINVAL);"
This may have an impact on fwctl side if the above check pass.
Thanks,
Shiju
Quoted 26 lines
drivers/cxl/core/features.c static bool cxlctl_validate_set_features(struct
Quoted 14 lines
Fixes f76e0bbc8bc3 ("cxl: Update prototype of function
get_support_feature_info()")Signed-off-by Dan Carpenter <[email protected]>--- drivers/cxl/core/features.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/cxl/core/features.c +0
-0@@ -544,7 +544,7 @@ static bool cxlctl_validate_set_features(struct
cxl_features_state*cxlfs,Quoted 11 lines
drivers/cxl/core/features.c +1
-2u32 flags;if (rpc_in->op_size <sizeof (uuid_t)) -return ERR_PTR (-EINVAL ); +return false; feat =cxl_feature_info (cxlfs, &rpc_in->set_feat_in.uuid);if (IS_ERR (feat)) --2.47.2
Ira Weiny
Reviewed-byQuoted 24 lines · Shiju Jose
Quoted 13 lines
-----Original Message-----
From: Alison Schofield <[email protected]>
Sent: 28 May 2025 16:23
To: Shiju Jose <[email protected]>; Dan Carpenter <[email protected]>
Cc: Davidlohr Bueso <[email protected]>; Jonathan Cameron <[email protected]>; Dave Jiang <[email protected]>; Vishal Verma <[email protected]>; Ira Weiny <[email protected]>; Dan Williams <[email protected]>; Li Ming <[email protected]>; Fan Ni <[email protected]>; [email protected]; linux- [email protected]; [email protected]
Subject: Re: [PATCH next] cxl: fix return value incxlctl_validate_set_features()Quoted 8 lines
Quoted 4 lines · Dan Carpenter
The
cxlctl_validate_set_features()function is type bool. It's supposed to return true for valid requests and false for invalid. However, this error path returnsERR_PTR(-EINVAL)which is true when it was intended to return false.Shiju - Can you trace this one through and add the impact statement? Wondering if this is going to fail gracefully, or badly, further down this path?
Hi Alison,
Quoted 9 lines
This is introduced when following fwctl specific code move out of common function (use both in fwctl and edac path)
get_support_feature_info()to fwctl specific functioncxlctl_validae_set_feature().
"if (rpc_in->op_size<sizeof(uuid_t))
returnERR_PTR(-EINVAL);"This may have an impact on fwctl side if the above check pass.
I got a bit sidetracked by this conversation.
It seems the TLDR is:
This fix is not required. But should be fixed for long term correctness.
With that interpretation.
Quoted 7 lines · Dan Carpenter
The
cxlctl_validate_set_features()function is type bool. It's supposed to return true for valid requests and false for invalid. However, this error path returnsERR_PTR(-EINVAL)which is true when it was intended to return false.Fixes f76e0bbc8bc3 ("cxl: Update prototype of function get_support_feature_info()")Signed-off-by Dan Carpenter <[email protected]>
Applied to cxl/fixes
Quoted 17 lines
--- drivers/cxl/core/features.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/cxl/core/features.c +1
-1@@ -544,7 +544,7 @@ static bool cxlctl_validate_set_features(struct cxl_features_state *cxlfs,u32 flags;if (rpc_in->op_size <sizeof (uuid_t)) -return ERR_PTR (-EINVAL ); +return false; feat =cxl_feature_info (cxlfs, &rpc_in->set_feat_in.uuid);if (IS_ERR (feat))