lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e1322f35-af8b-8151-b560-0ba76775b237@mev.co.uk>
Date:   Fri, 26 Apr 2019 10:41:20 +0100
From:   Ian Abbott <abbotti@....co.uk>
To:     Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc:     devel@...verdev.osuosl.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] staging: comedi: comedi_isadma: Use a non-NULL device for
 DMA API

On 25/04/2019 18:13, Greg Kroah-Hartman wrote:
> On Thu, Apr 25, 2019 at 05:26:44PM +0100, Ian Abbott wrote:
>> The "comedi_isadma" module calls `dma_alloc_coherent()` and
>> `dma_free_coherent()` with a NULL device pointer which is no longer
>> allowed.  If the `hw_dev` member of the `struct comedi_device` has been
>> set to a valid device, that can be used instead.  Unfortunately, all the
>> current users of the "comedi_isadma" module leave the `hw_dev` member
>> set to NULL.  In that case, use a static dummy fallback device structure
>> with the coherent DMA mask set to the ISA bus limit of 16MB.
>>
>> Signed-off-by: Ian Abbott <abbotti@....co.uk>
>> ---
>>   drivers/staging/comedi/drivers/comedi_isadma.c | 15 +++++++++++++--
>>   drivers/staging/comedi/drivers/comedi_isadma.h |  3 +++
>>   2 files changed, 16 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/staging/comedi/drivers/comedi_isadma.c b/drivers/staging/comedi/drivers/comedi_isadma.c
>> index b77dc8d5d3ff..8929952516a1 100644
>> --- a/drivers/staging/comedi/drivers/comedi_isadma.c
>> +++ b/drivers/staging/comedi/drivers/comedi_isadma.c
>> @@ -14,6 +14,16 @@
>>   
>>   #include "comedi_isadma.h"
>>   
>> +/*
>> + * Fallback device used when hardware device is NULL.
>> + * This can be removed after drivers have been converted to use isa_driver.
>> + */
>> +static struct device fallback_dev = {
>> +	.init_name = "comedi_isadma fallback device",
>> +	.coherent_dma_mask = DMA_BIT_MASK(24),
>> +	.dma_mask = &fallback_dev.coherent_dma_mask,
>> +};
> 
> Ick, no, static struct device are a very bad idea as this is a reference
> counted structure and making it static can cause odd problems.

This was based on the use of `struct device x86_dma_fallback_dev` in 
"arch/x86/kernel/pci-dma.c", and `static struct device isa_dma_dev` in 
"arch/arm/kernel/dma-isa.c", but perhaps it is not appropriate in 
non-arch code.

> Why not just create a "real" one?  Or better yet, use the real device
> for the comedi device as all of these drivers should have one now.

I suppose I could use the comedi class device pointed to by the 
`class_dev` member of `struct comedi_device` (although that could also 
be NULL because the comedi core does not currently treat 
`device_create()` failures as fatal).

> 
> thanks,
> 
> greg k-h

Thanks for the review,

Ian Abbott.

-- 
-=( Ian Abbott <abbotti@....co.uk> || Web: www.mev.co.uk )=-
-=( MEV Ltd. is a company registered in England & Wales. )=-
-=( Registered number: 02862268.  Registered address:    )=-
-=( 15 West Park Road, Bramhall, STOCKPORT, SK7 3JZ, UK. )=-

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ