RE: [PATCH 02/49] staging: comedi: have core check cmd->chanlist_len min

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

 



On Wednesday, April 16, 2014 8:57 AM, Ian Abbott wrote:
> On 2014-04-15 18:37, H Hartley Sweeten wrote:
>> The only time the chanlist can be NULL and chanlist_len < 1 is when a
>> COMEDI_CMDTEST ioctl is done, usually for the comedilib function
>> comedi_get_cmd_src_mask(). This comedilib function sets all the command
>> sources to TRIG_ANY and Step 1 of the (*do_cmdtest) will fail returning
>> a the mask of valid sources.
>>
>> For the rest of the (*do_cmdtest) and the (*do_cmd) functions a valid
>> chanlist and chanlist_len >= 1 is required.
>>
>> Modify the check in __comedi_get_user_chanlist() to allow a NULL
>> chanlist or chanlist_len < 1 only when all the command sources are
>> TRIG_ANY.
>>
>> Remove the checks in the comedi_driver (*do_cmdtest) functions that
>> don't result in to much diff noise. The remaining ones will be removed
>> in following patches.
>>
>> Signed-off-by: H Hartley Sweeten <hsweeten@xxxxxxxxxxxxxxxxxxx>
>> Cc: Ian Abbott <abbotti@xxxxxxxxx>
>> Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
>
> NAK.  This will break existing libcomedi library function 
> comedi_get_generic_timed(), which will call the COMEDI_CMDTEST ioctl 
> with a NULL chanlist (but with chanlist_len > 1) and with start_src etc. 
> set to values other than TRIG_ANY.
>
> For COMEDI_CMDTEST, chanlist is allowed to be NULL and chanlist_len is 
> allowed to be 0 (although some drivers' do_cmdtest handlers currently 
> check it is at least 1).  (However, the command structure might get 
> modified in strange ways if the command test gets as far as "step 3" 
> with a zero chanlist_len, so it's best for the user-level code to set a 
> proper chanlist_len if it's expecting the test to get as far as "step 3".)
>
> However, for the COMEDI_CMD ioctl, chanlist_len needs to be at least 1 
> and chanlist needs to be non-NULL, but its NULL-ness shouldn't be 
> checked until after s->do_cmdtest() has been called, as that can modify 
> the erroneous command before passing it back to the user.

Grrr... Missed that part in the comedilib __generic_timed() function.

Probably best to drop this series for now and I'll dig back into it.

Thanks,
Hartley

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux