On 10/15/18 3:36 PM, Daniel Borkmann wrote:
> On 10/12/2018 08:54 PM, Yonghong Song wrote:
> [...]
>> +static bool btf_name_valid_identifier(const struct btf *btf, u32 offset)
>> +{
>> +    /* offset must be valid */
>> +    const char *src = &btf->strings[offset];
>> +
>> +    if (!isalpha(*src) && *src != '_')
>> +            return false;
>> +
>> +    src++;
>> +    while (*src) {
>> +            if (!isalnum(*src) && *src != '_')
>> +                    return false;
>> +            src++;
>> +    }
>> +
>> +    return true;
>> +}
> 
> Should there be an upper name length limit like KSYM_NAME_LEN? (Is it implied
> by the kvmalloc() limit?)

KSYM_NAME_LEN is good choice. Here, we check function names and 
struct/union member names. In C, based on
https://stackoverflow.com/questions/2352209/max-identifier-length,
the identifier max length is 63. Some compiler implementation may vary.
KSYM_NAME_LEN is 128.

> 
>>   static const char *btf_name_by_offset(const struct btf *btf, u32 offset)
>>   {
>>      if (!offset)
>> @@ -747,7 +782,9 @@ static bool env_type_is_resolve_sink(const struct 
>> btf_verifier_env *env,
>>              /* int, enum or void is a sink */
>>              return !btf_type_needs_resolve(next_type);
>>      case RESOLVE_PTR:
>> -            /* int, enum, void, struct or array is a sink for ptr */
>> +            /* int, enum, void, struct, array or func_ptoto is a sink
>> +             * for ptr
>> +             */
>>              return !btf_type_is_modifier(next_type) &&
>>                      !btf_type_is_ptr(next_type);
>>      case RESOLVE_STRUCT_OR_ARRAY:

Reply via email to