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] [day] [month] [year] [list]
Message-ID: <25b5fb44-fc33-cc2d-5a36-64e780015824@arm.com>
Date:   Mon, 20 Mar 2023 10:03:06 +0000
From:   James Clark <james.clark@....com>
To:     Jonathan Cameron <jic23@...nel.org>
Cc:     Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>,
        linux-kernel@...r.kernel.org, linux@...ck-us.net,
        michal.simek@....com, Jonathan Corbet <corbet@....net>,
        Jean Delvare <jdelvare@...e.com>,
        Anand Ashok Dumbre <anand.ashok.dumbre@...inx.com>,
        Lars-Peter Clausen <lars@...afoo.de>,
        Michal Simek <michal.simek@...inx.com>,
        Andy Gross <agross@...nel.org>,
        Bjorn Andersson <andersson@...nel.org>,
        Konrad Dybcio <konrad.dybcio@...aro.org>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Jiri Slaby <jirislaby@...nel.org>, linux-doc@...r.kernel.org,
        linux-hwmon@...r.kernel.org, linux-iio@...r.kernel.org,
        linux-arm-kernel@...ts.infradead.org,
        linux-arm-msm@...r.kernel.org, linux-serial@...r.kernel.org
Subject: Re: [PATCH v2 4/4] serial: qcom_geni: Use devm_krealloc_array



On 18/03/2023 17:34, Jonathan Cameron wrote:
> On Fri, 17 Mar 2023 11:34:49 +0000
> James Clark <james.clark@....com> wrote:
> 
>> On 11/03/2023 19:18, Jonathan Cameron wrote:
>>> On Thu,  9 Mar 2023 15:03:33 +0000
>>> James Clark <james.clark@....com> wrote:
>>>   
>>>> Now that it exists, use it instead of doing the multiplication manually.
>>>>
>>>> Signed-off-by: James Clark <james.clark@....com>  
>>>
>>> Hmm. I've stared at the users of this for a bit, and it's not actually obvious
>>> that it's being used as an array of u32.  The only typed user of this is as
>>> the 2nd parameter of  
>>> tty_insert_flip_string() which is an unsigned char *
>>>
>>> I wonder if that sizeof(u32) isn't a 'correct' description of where the 4 is coming
>>> from even if it has the right value?  Perhaps the fifo depth is just a multiple of 4?
>>>
>>> Jonathan
>>>   
>>
>> The commit that added it (b8caf69a6946) seems to hint that something
>> reads from it in words. And I see this:
>>
>>   /* We always configure 4 bytes per FIFO word */
>>   #define BYTES_PER_FIFO_WORD		4U
>>
>> Perhaps sizeof(u32) isn't as accurate of a description as using
>> BYTES_PER_FIFO_WORD but I'd be reluctant to make a change because I
>> don't really understand the implications.
> 
> Agreed with your analysis.  + fully understand why you don't want to change
> it. 
> 
> I'd be tempted to take the view that whilst it's allocated in 4 byte chunks
> because it's accessed elsewhere as a set of 1 byte entries, krealloc_array
> isn't appropriate and so just leave it with devm_krealloc()
> 
> Risk is that a steady stream of patches will turn up 'fixing' this as
> it will be easy for people to find with a script.  Maybe better to just add
> a comment (either with or without your patch).

Ok that makes sense to me. I can add a comment instead this patch to
change this one.

>>
>> There is also this in handle_rx_console():
>>
>>   unsigned char buf[sizeof(u32)];
>>
>> James
>>
>>>
>>>   
>>>> ---
>>>>  drivers/tty/serial/qcom_geni_serial.c | 6 +++---
>>>>  1 file changed, 3 insertions(+), 3 deletions(-)
>>>>
>>>> diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qcom_geni_serial.c
>>>> index d69592e5e2ec..23fc33d182ac 100644
>>>> --- a/drivers/tty/serial/qcom_geni_serial.c
>>>> +++ b/drivers/tty/serial/qcom_geni_serial.c
>>>> @@ -1056,9 +1056,9 @@ static int setup_fifos(struct qcom_geni_serial_port *port)
>>>>  		(port->tx_fifo_depth * port->tx_fifo_width) / BITS_PER_BYTE;
>>>>  
>>>>  	if (port->rx_buf && (old_rx_fifo_depth != port->rx_fifo_depth) && port->rx_fifo_depth) {
>>>> -		port->rx_buf = devm_krealloc(uport->dev, port->rx_buf,
>>>> -					     port->rx_fifo_depth * sizeof(u32),
>>>> -					     GFP_KERNEL);
>>>> +		port->rx_buf = devm_krealloc_array(uport->dev, port->rx_buf,
>>>> +						   port->rx_fifo_depth, sizeof(u32),
>>>> +						   GFP_KERNEL);
>>>>  		if (!port->rx_buf)
>>>>  			return -ENOMEM;
>>>>  	}  
>>>   
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ