Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4387239pxj; Wed, 12 May 2021 04:41:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzwHw9Qp7EGAFrSyhMuolto7PefODpXOoUNI9PjrNA3iSm0eyPFTS7QGZLo1xSZ34pGv6Al X-Received: by 2002:a17:906:c297:: with SMTP id r23mr37142505ejz.144.1620819683350; Wed, 12 May 2021 04:41:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620819683; cv=none; d=google.com; s=arc-20160816; b=VwC0QaaoyE4AOrQVRgYqX8GiXFEWOT8VvI21EmT9682e3MB/Hi8kjqumiwpRagL745 77vUoUFgTFIvhbELYriZlU4ET87oUTI1cAJlXSmMxsGe6FFYjAT1duLy1UEzlZPmn5hX UnerlZTFZBo+yINTAvleFQi572vXIHhchIyVxlQpAlX0JSGD8rpDMY86930pKDSJ0U8Y P98Ief/9wSANVFWqZK1Yzll9Gy0lY0DKpptP9EU54HvXpODpavdqNJ3gn4czzEoIxP3U uDsypnGdyDMLq94NeSldzdyEHsH72xiHTZ5zP6DU1Rl+BTRQy5la5RSm3Jg2TNHvTUyx mxQg== 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=/4hxdcbxEg+Gvm/uEtZiedODpWJAxy3rdveR0HoL0Nw=; b=iF0VZut6cNHQp7Ok8WJbJEAcJo7Wc7QpFgMTNxwTgK3Hm75WrZKemT/Kg+QCFbeJUa 8hvRp5cYg/A+rZT6vnti6xWzMFUzC0OiOArDvaU5UiTyZZqdv51HfLJQ38UrMh9ywKcO odSQQNNEC2t57UmOkPMHSpVvx3//4Sj9djrxbP3peZB0RtwNOzgqu3BLcSKXY7BdoFSp vVjHvCV1kx3kQrdmRGILnsyagmiVcSu6NgBM2XWeY4qDSqd4SjwRR4HKBw6YAzHSgFlB VQ3//sN2J/8ZtdoegHNe3psCz4a7mpFICBwu7FftG/96v7XsawdU4DPqVz3ZGf8HaIFw jixA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="w7NB/ViQ"; 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 bo20si21967745edb.481.2021.05.12.04.40.58; Wed, 12 May 2021 04:41:23 -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="w7NB/ViQ"; 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 S230178AbhELLlH (ORCPT + 99 others); Wed, 12 May 2021 07:41:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230037AbhELLlG (ORCPT ); Wed, 12 May 2021 07:41:06 -0400 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 778E0C06174A for ; Wed, 12 May 2021 04:39:58 -0700 (PDT) Received: by mail-ej1-x631.google.com with SMTP id n2so34488636ejy.7 for ; Wed, 12 May 2021 04:39:58 -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=/4hxdcbxEg+Gvm/uEtZiedODpWJAxy3rdveR0HoL0Nw=; b=w7NB/ViQ3y4V4xJCR4F4VoktRzv8QQfDbni4mqcpgpWmVJZ16G2VZmfAuKMCUgCO62 zA5sF7C/DNM8IpImQj42qfKda8tSi6ihBky/SsbT/NgOqH7orLANlNXAqUTj+bD9cMtN tSD9RZQgY17b3Vrv3pcLDl8ojPHBIIcQiAstjkV2lQIUQoQo2w+DkUqDAnDKQDBUaMey 23pe5ANPB1wB35GSl0vJx7EcH/7lDk+aZR0JzPBtl5akqoDhtJvS2QfaQ+1VEfDPMNBt qQPrLkr3CpumgvcH/1c1POpTV7pF2sHN5PU4MRH7bkf5hv++HE1J58jYepRcuV1dOCCa M2sQ== 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=/4hxdcbxEg+Gvm/uEtZiedODpWJAxy3rdveR0HoL0Nw=; b=JkXpb3xAdeFzc7VI/6Cj/7zQIxl1DLDHcnEsxXKt+yraNKyToX09G4QNx9Ws6qoyZm nabSkR6ESGqwT2X87L9w7cLqd+oEpud8th3BKEPiI6btF5yy+cv/71W3RIWkxxThn1FO ai1vG9VzuDAkYlrMK4nlmtFWvJhyi5C8M3b/0HzmWgr/XD+SVqptzPm8bHO5zrK6Gjgg lCn/eOsM5aR4Odi7JtUct8ghz35eiA2K3X6G73Qw6+iQCXUvKgyYiQMid1nzdm3Eh2la NNewBO/XN0A7yz0g+fC0FWRPUjEukXSIy20G5Wmax2qOUQ2CDJP56heXg5zc2sEezk3E YsAQ== X-Gm-Message-State: AOAM531BovXzsvYLWSPe3H8YbKJgaeKtc14SWDocuN7ndVIG8jKeaOdo 0GcLBFBsIRkVX9zjwbsXj7SsHw== X-Received: by 2002:a17:906:9141:: with SMTP id y1mr38725036ejw.111.1620819597231; Wed, 12 May 2021 04:39:57 -0700 (PDT) Received: from [192.168.1.14] ([195.24.90.54]) by smtp.googlemail.com with ESMTPSA id y2sm13775670ejg.123.2021.05.12.04.39.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 12 May 2021 04:39:56 -0700 (PDT) Subject: Re: [PATCH][next] media: venus: hfi_msgs.h: Replace one-element arrays with flexible-array members To: "Gustavo A. R. Silva" , "Gustavo A. R. Silva" , Stanimir Varbanov , 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: Date: Wed, 12 May 2021 14:39:55 +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/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. > > 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