Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2534889pxj; Mon, 17 May 2021 04:04:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwDa/z6VAEMuy6Q22sjI+y2SB6AYPkOW/z2c/9hQngKO1z/pxaeqYw/ZUYO8KcznebKyD/j X-Received: by 2002:a17:906:60d6:: with SMTP id f22mr62326771ejk.177.1621249452079; Mon, 17 May 2021 04:04:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621249452; cv=none; d=google.com; s=arc-20160816; b=DLASuks0jZJP0fApJTIMgHCDNqxcYxkoLn8NN/JxE+0mHuK0nHNO7KAgIElX9nXG2E TeIZBySgCmCliTXaXnSJDuUNS3IngzCGMfulhmHSD1CgkwQ+8lkd/NOXF5+5MrSs5zzU O2Gc3U88+bo67bMSxRCXSzwu9eNYSnO8+5NGPSJZoHi97K8kgGuvDmCqWDKxFJYTcTHY y96OVGGgK1PfiHSkLgI++etqawFKEE4WOuhTZp0XvkM2Awn+azB01cNkZO0sfvWRhwRl Hv3aXYw/vzYAU1w1LyRnvdkOWQlvEu2fleqF801DTgNyLg8NpSFRp5GQld9Ti9Cgybqm nibA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=Lvflle3nqVohqWXQjoKXKJ9NFkulfQYE+SnrI7kL87A=; b=g7FAHGyLzz5BZMtTCafRHTG/aSmQJ3/J3VqYNTYec9qJAUfP31Zb/srbJjsk/uUrz1 7InZz5myS6JQqiVstw+ttZrJlz5QiwpwRja0TRyGgWlpBUBd3mz1B7iAlHoU1jUVNGOY 4y/JPLJCfSxQYkmkbz52/Dz0/sJPBVnHIwEyvlAV+83nkh8CtLk2HEUhekJcX5beTGSs W1EsOzVbcT5ai0TWJka0uUW+4bwcK264NXZhNgq4l8s4rnwWWu5XhfuxSh4PoSwQWGsS qrSnmM0L2vwz2wkiEpfuwMx0IBopbdCgDGdYHrNi/FtSVP4WB7g2ZJoUp30WzKI9ZCpO Gv2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MoVu+red; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o12si5585139edr.477.2021.05.17.04.03.48; Mon, 17 May 2021 04:04:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MoVu+red; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236620AbhEQLCm (ORCPT + 99 others); Mon, 17 May 2021 07:02:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236579AbhEQLCk (ORCPT ); Mon, 17 May 2021 07:02:40 -0400 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3003C06174A for ; Mon, 17 May 2021 04:01:24 -0700 (PDT) Received: by mail-ed1-x52d.google.com with SMTP id h16so6340579edr.6 for ; Mon, 17 May 2021 04:01:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=Lvflle3nqVohqWXQjoKXKJ9NFkulfQYE+SnrI7kL87A=; b=MoVu+reduWG5h6pq8tUmmTn9nel5GLj9nc2AA2INJyQkt984LNyYomhlVPZlvcWLZ0 lls8s5i9XYKig0wnrEIoUv6Xe6vt1lRX76z0LJdfoVjkMHeo1jhb1EwFTIU7gsXtkZrO oPGk9wGC3l9H4L3m1IqSjO5dAoh7xjw7RsCrvuOaM4saQTgbFEMeZkxwU3BVpMBEJaJa mfA85dJvkbUF6zQTJYCMAJlLJUbpIkGw0LRj/Ddo/Iwp81xX2gpnRhDA+gDLSjBlQH9s Cctu54Wk3VXhpCZbSGcnTaNnMGt9Xqgk+vIqNqDiEIJ9plOt1DnhYwuKBv4N2J6Bsb5L n0HQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Lvflle3nqVohqWXQjoKXKJ9NFkulfQYE+SnrI7kL87A=; b=oDdYOLRftP3worOAAiTeg4q4o2Q1GZ2zAVe09b+jQWCeb8Qs5gPcZ7tgYbWGh99Bgm qtnwx4F5BKUoJnhNAsZQQb/pPha24tl36IGrVXqofl7AUXr2dLCpjlmYg+y12E2iX1/I +dDaPIQrPEAUwfCl7SnnjAbEukCBzoQheiUqSfbFOpnaE1lk6TCuA1/3ySX0jN3jWdd7 ejZ7hNyl5U3MbFAEAc5S7u3UyifOPVXSzt8zS8ChtfnfAbRkLAl9HRUPBG6yTzJgmoLC /7WiCTbg7u2n1IBCbWvJ9BFM3/xHdfuDxgnrRChF8MAYSWTZCISXyx89kC07cjm2u5qc EZ1g== X-Gm-Message-State: AOAM530z0Nwt2rPKZ+5w4AugLwfQN0sad4ZNfT4Aj7Yw78K07EbKZujc /j0cOObZtCSAFQg6Kgf5kEZbUw== X-Received: by 2002:aa7:d952:: with SMTP id l18mr70191962eds.83.1621249283128; Mon, 17 May 2021 04:01:23 -0700 (PDT) Received: from [192.168.1.14] ([195.24.90.54]) by smtp.googlemail.com with ESMTPSA id g24sm10880568eds.41.2021.05.17.04.01.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 17 May 2021 04:01:22 -0700 (PDT) Subject: Re: [PATCH][next] media: venus: hfi_msgs.h: Replace one-element arrays with flexible-array members To: "Gustavo A. R. Silva" , Stanimir Varbanov , "Gustavo A. R. Silva" , Andy Gross , Bjorn Andersson , Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org References: <20210211001044.GA69612@embeddedor> From: Stanimir Varbanov Message-ID: <64aa38bc-62b2-79d9-156f-74a09f11f871@linaro.org> Date: Mon, 17 May 2021 14:01:20 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > > 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: >>>> Link: https://lore.kernel.org/lkml/6023dd80.MmTeFf8SzwX0iK7%2F%25lkp@intel.com/ >>>> Signed-off-by: Gustavo A. R. Silva >>>> --- >>>> 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 { >>>> >> -- regards, Stan