Re: [PATCH] cgroup/rdma: fix strncmp prefix match in parse_resource()

Michal Koutný
2026-04-17T09:53:31Z

[-- Attachment #1: Type: text/plain, Size: 947 bytes --]

On Fri, Apr 17, 2026 at 02:43:43PM +0800, 崔涛 <cuitao@kylinos.cn> wrote:
> Test 3: strncmp(value, RDMACG_MAX_STR, strlen(RDMACG_MAX_STR)) — your suggestion
>
> echo "... hca_handle=ma hca_object=20" → rejected
> echo "... hca_handle=maxaa hca_object=20" → accepted (BUG: "maxaa" matches "max")
> echo "... hca_handle=max hca_object=20" → rejected
>
> The suggested strncmp approach actually introduces a new bug: it would
> accept "maxaa" as "max" because it only compares the first
> strlen("max") = 3 characters.

True, I missed this.

> The extra spaces create empty sub-tokens that fail earlier in
> validation, regardless of which comparison method is used.

Yes, this is suckage too (also in your Test 2 third result).

As I look around (tg_set_limit, user_proactive_reclaim,
ioc_cost_model_write), this would be most cleanly tackled with a
match_table_t and match_token().

WDYT?

Thanks,
Michal

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 265 bytes --]