Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1746955pxb; Wed, 10 Feb 2021 16:13:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJwbW18MO/qdnrXKs/bHdm/NeokdnmA/IlRu2bcfr7qcZk3DdK+15V4BaLGjd7jSxSYc1gko X-Received: by 2002:a17:907:20d6:: with SMTP id qq22mr5495896ejb.517.1613002404127; Wed, 10 Feb 2021 16:13:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613002404; cv=none; d=google.com; s=arc-20160816; b=wYgl2xA01aDFdWuK2MRZFRqXE334PhlgwUv8o3kKeONGbtqDupsLpxPlhuq376wfdB UGFGv6wisEJUiED0RF6buZ3E24DjGt+zCl1WWLXXbqoLpmEqfS9E/Vp0OqGpLSizXVLf QUVC99FdVhLuqE20c57aq3oKBTantAUrNXwWMiYIWT/uPJF7d1L7g0jN8lYIFuIlc4HX tXKSd5ck1IN2+ePmYWL7n0hrQEaStte1jDOf291v3PGUkJJRZlxY0wNXFHyka52CuQkN 05xmThlOzv7kfCml8Uw0JDI8nGclKrpzLL999ufoeKn/vcOxYJlVWPURtei9aEGDFnp1 AfYw== 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-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=HtcBUBNZ/r5JrevKOZ5MYAGh6AjR3RcuHanNt/G1t6U=; b=CNq0MFFUIp5dfcXNC9KBEW3TmJ4rYlublNhHqRGDGg27FpLPxHO05Tr7Vcyi1mdOGp vb7hxUv6et4deCjmlJLHST6SNyjm9BHqqUZFTbl89RwK3LRjPVaYFdqBPrNbVGyddI2v zm3F/Y9oFiC8ntpH6XpQ0GuO6cZ5EDyvGJonUIX8YBpFnYlErt3/56oQRohAzi6wSAfB x3xbIT4CaFx/OqQSwJOZ/7iygH3oUI5copTPsvVDJtJ39ZgjkM4p92H7hgjyaJAuMLHm H6pzIZz1Dk02jBXgHsr9RLrSgw9g3xX1btNGRR3ZZPVyi+FdORR0wAJC8+8bXXZTZ/Jw yzvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=vMCvIdhi; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t1si2384623ejd.359.2021.02.10.16.13.00; Wed, 10 Feb 2021 16:13:24 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=vMCvIdhi; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233847AbhBKALa (ORCPT + 99 others); Wed, 10 Feb 2021 19:11:30 -0500 Received: from mail.kernel.org ([198.145.29.99]:36000 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231897AbhBKAL2 (ORCPT ); Wed, 10 Feb 2021 19:11:28 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0039864E35; Thu, 11 Feb 2021 00:10:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1613002246; bh=dLQjzQ03EvB2ORG0nxF/JD98DWS+RIWvKrK0cmVR4go=; h=Date:From:To:Cc:Subject:From; b=vMCvIdhiah8EigDMgriHrVIOpclaHSQyulIqVyjcZP2jajqx/6bo0akMWs9DBCVJj g3J1/tuSVOjtlezAmPSUvnJUlsRRyxpziZZBSKKsZWC4EPgE3Id3XUqVagd7GYnl7b /ksCtNJYWyU0rAA0IgnOY/edm4mcuUKbpuLNiBSDWHh2usOGQT7dnxsUWs7hWKIbJA bgtgzd/UQv2lzXcYtIz4dRo1nOrFKjvgBjmlnMQc1C6ibWv1dQbqafVXPwoZTgX+sl DDDDV+KZOhOWoBhIU9V0M45pjtSgwDVA48PzMKTaECg+V1BLqDQhJnI3F+1kYqiMFr KRVftqitUlT6w== Date: Wed, 10 Feb 2021 18:10:44 -0600 From: "Gustavo A. R. Silva" To: 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, "Gustavo A. R. Silva" , linux-hardening@vger.kernel.org Subject: [PATCH][next] media: venus: hfi_msgs.h: Replace one-element arrays with flexible-array members Message-ID: <20210211001044.GA69612@embeddedor> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 { -- 2.27.0