[lustre-devel] [PATCH 24/24] lustre: discard TCD_MAX_TYPES
NeilBrown
neilb at suse.com
Sun Jun 24 16:26:11 PDT 2018
On Sun, Jun 24 2018, James Simmons wrote:
>> As well as CFS_TCD_TYPE_CNT we have TCD_MAX_TYPES which has a larger
>> value but a similar meaning. Discard it and just use
>> CFS_TCD_TYPE_CNT.
>>
>> Two places relied on the fact that TCD_MAX_TYPES was larger and so
>> there would be NULLs at the end of the array. Change
>> them to check the array size properly.
>>
>> Signed-off-by: NeilBrown <neilb at suse.com>
>> ---
>>
>> Thanks for testing James!
>> I found two problems.
>> 1/ I had
>> - for (i = 0; cfs_trace_data[i] && i < CFS_TCD_TYPE_CNT; i++) {
>> instead of
>> + for (i = 0; i < CFS_TCD_TYPE_CNT && cfs_trace_data[i]; i++) {
>>
>> So it could dereference beyond the end of an array. I don't this was
>> the problem.
>>
>> 2/ I hadn't changed
>> - for (i = 0; cfs_trace_data[i]; i++) \
>> to
>> + for (i = 0; i < CFS_TCD_TYPE_CNT && cfs_trace_data[i]; i++) \
>>
>> so if cfs_trace_data[4] was non NULL, bad things could happen.
>> I suspect this is what happened to you.
>>
>> Thanks,
>> NeilBrown
>
> Much better :-)
Thanks for the confirmation!
NeilBrown
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20180625/499fd3ae/attachment.sig>
More information about the lustre-devel
mailing list