[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v2 39/52] xen: check parameter validity when parsing command line



>>> On 14.08.17 at 15:31, <jgross@xxxxxxxx> wrote:
> On 14/08/17 14:46, Jan Beulich wrote:
>>>>> On 14.08.17 at 09:08, <jgross@xxxxxxxx> wrote:
>>> @@ -97,8 +102,9 @@ static void __init _cmdline_parse(const char *cmdline)
>>>                       !strncmp(param->name, opt, q + 1 - opt) )
>>>                  {
>>>                      optval[-1] = '=';
>>> -                    ((void (*)(const char *))param->var)(q);
>>> +                    rc = ((int (*)(const char *))param->var)(q);
>> 
>> Neither here nor in the earlier "let custom parameter parsing
>> routines return errno" nor in the overview you mention why this
>> is safe - it is not a given that caller and callee disagreeing on
>> return type is going to work. Just think of functions returning
>> aggregates or (on ix86) ones returning floating point values in
>> st(0).
> 
> I thought about using a union in struct kernel_param and removing
> above type cast. This would require modifying the initialization of
> the kernel_param struct via the *_param() macros, though.
> 
> The other possibility would be using __builtin_types_compatible_p()
> to check the function to be of proper type.
> 
> What would you like best?

I'd prefer the union approach; I was actually surprised to see
we still only have a void * there.

Jan


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.