linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
To: Stanimir Varbanov <stanimir.varbanov@linaro.org>,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>,
	Andy Gross <agross@kernel.org>,
	Bjorn Andersson <bjorn.andersson@linaro.org>,
	Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org
Subject: Re: [PATCH][next] media: venus: hfi_msgs.h: Replace one-element arrays with flexible-array members
Date: Thu, 3 Jun 2021 19:47:02 -0500	[thread overview]
Message-ID: <0436d974-f17b-10f3-8b05-f8505524a6f5@embeddedor.com> (raw)
In-Reply-To: <64aa38bc-62b2-79d9-156f-74a09f11f871@linaro.org>

Hi Stanimir,

On 5/17/21 06:01, Stanimir Varbanov wrote:
> Hi,
> 
> On 5/12/21 7:37 PM, Gustavo A. R. Silva wrote:
>>
>>
>> On 5/12/21 06:39, Stanimir Varbanov wrote:
>>> Hi,
>>>
>>> On 5/11/21 6:46 PM, Gustavo A. R. Silva wrote:
>>>> Hi all,
>>>>
>>>> Friendly ping:
>>>>
>>>> We are about to be able to globally enable -Warray-bounds and, these are one of
>>>> the last out-of-bounds warnings in linux-next.
>>>>
>>>> Could someone take this, please?
>>>
>>> This one introduces regressions, so I cannot take it. It needs some more
>>> work.
>>
>> Please, share with me the errors or warnings you see with this. So, I can
>> have an idea of what is going on. Unfortunately, I don't have access to the
>> test suite or hardware to test this.
> 
> I guess it needs more debugging, but the simple answer is that the
> driver refuse to start streaming with this patch.

This patch should fix the problems you are seeing:

https://lore.kernel.org/linux-hardening/20210604004338.GA140710@embeddedor/

Could you please help me to test it?

Thanks!
--
Gustavo

> 
>>
>> Thanks!
>> --
>> Gustavo
>>
>>
>>
>>>>
>>>> Thanks
>>>> --
>>>> Gustavo
>>>>
>>>> On 2/10/21 18:10, Gustavo A. R. Silva wrote:
>>>>> There is a regular need in the kernel to provide a way to declare having
>>>>> a dynamically sized set of trailing elements in a structure. Kernel code
>>>>> should always use “flexible array members”[1] for these cases. The older
>>>>> style of one-element or zero-length arrays should no longer be used[2].
>>>>>
>>>>> Use flexible-array members in struct hfi_msg_sys_property_info_pkt and
>>>>> hfi_msg_session_property_info_pkt instead of one-element arrays.
>>>>>
>>>>> Also, this helps with the ongoing efforts to enable -Warray-bounds by
>>>>> fixing the following warnings:
>>>>>
>>>>>   CC [M]  drivers/media/platform/qcom/venus/hfi_msgs.o
>>>>> drivers/media/platform/qcom/venus/hfi_msgs.c: In function ‘hfi_sys_property_info’:
>>>>> drivers/media/platform/qcom/venus/hfi_msgs.c:246:35: warning: array subscript 1 is above array bounds of ‘u32[1]’ {aka ‘unsigned int[1]’} [-Warray-bounds]
>>>>>   246 |  if (req_bytes < 128 || !pkt->data[1] || pkt->num_properties > 1)
>>>>>       |                          ~~~~~~~~~^~~
>>>>> drivers/media/platform/qcom/venus/hfi_msgs.c: In function ‘hfi_session_prop_info’:
>>>>> drivers/media/platform/qcom/venus/hfi_msgs.c:342:62: warning: array subscript 1 is above array bounds of ‘u32[1]’ {aka ‘unsigned int[1]’} [-Warray-bounds]
>>>>>   342 |  if (!req_bytes || req_bytes % sizeof(*buf_req) || !pkt->data[1])
>>>>>       |                                                     ~~~~~~~~~^~~
>>>>>
>>>>> [1] https://en.wikipedia.org/wiki/Flexible_array_member
>>>>> [2] https://www.kernel.org/doc/html/v5.9/process/deprecated.html#zero-length-and-one-element-arrays
>>>>>
>>>>> Link: https://github.com/KSPP/linux/issues/79
>>>>> Link: https://github.com/KSPP/linux/issues/109
>>>>> Build-tested-by: <lkp@intel.com>
>>>>> Link: https://lore.kernel.org/lkml/6023dd80.MmTeFf8SzwX0iK7%2F%25lkp@intel.com/
>>>>> Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
>>>>> ---
>>>>>  drivers/media/platform/qcom/venus/hfi_msgs.h | 4 ++--
>>>>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>>>>
>>>>> diff --git a/drivers/media/platform/qcom/venus/hfi_msgs.h b/drivers/media/platform/qcom/venus/hfi_msgs.h
>>>>> index 526d9f5b487b..e2d2ccfbdd24 100644
>>>>> --- a/drivers/media/platform/qcom/venus/hfi_msgs.h
>>>>> +++ b/drivers/media/platform/qcom/venus/hfi_msgs.h
>>>>> @@ -113,7 +113,7 @@ struct hfi_msg_sys_ping_ack_pkt {
>>>>>  struct hfi_msg_sys_property_info_pkt {
>>>>>  	struct hfi_pkt_hdr hdr;
>>>>>  	u32 num_properties;
>>>>> -	u32 data[1];
>>>>> +	u32 data[];
>>>>>  };
>>>>>  
>>>>>  struct hfi_msg_session_load_resources_done_pkt {
>>>>> @@ -233,7 +233,7 @@ struct hfi_msg_session_parse_sequence_header_done_pkt {
>>>>>  struct hfi_msg_session_property_info_pkt {
>>>>>  	struct hfi_session_hdr_pkt shdr;
>>>>>  	u32 num_properties;
>>>>> -	u32 data[1];
>>>>> +	u32 data[];
>>>>>  };
>>>>>  
>>>>>  struct hfi_msg_session_release_resources_done_pkt {
>>>>>
>>>
> 

      parent reply	other threads:[~2021-06-04  1:07 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-11  0:10 [PATCH][next] media: venus: hfi_msgs.h: Replace one-element arrays with flexible-array members Gustavo A. R. Silva
2021-03-04  1:43 ` Gustavo A. R. Silva
2021-05-11 15:46 ` Gustavo A. R. Silva
2021-05-12 11:39   ` Stanimir Varbanov
2021-05-12 16:37     ` Gustavo A. R. Silva
2021-05-17 11:01       ` Stanimir Varbanov
2021-05-19 16:15         ` Gustavo A. R. Silva
2021-06-04  0:47         ` Gustavo A. R. Silva [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0436d974-f17b-10f3-8b05-f8505524a6f5@embeddedor.com \
    --to=gustavo@embeddedor.com \
    --cc=agross@kernel.org \
    --cc=bjorn.andersson@linaro.org \
    --cc=gustavoars@kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=stanimir.varbanov@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).