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

Tao Cui
2026-04-20T01:08:45Z

在 2026/4/17 17:53, Michal Koutný 写道:
> 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?
>
I’ve also gone through the relevant code of tg_set_limit, user_proactive_reclaim and ioc_cost_model_write. Let me have a go at implementing it this way.

Thanks,
cuitao
> Thanks,
> Michal