From patchwork Fri Mar 17 16:59:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Gustavo A. R. Silva" X-Patchwork-Id: 13179304 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E10B2C74A5B for ; Fri, 17 Mar 2023 16:59:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229488AbjCQQ71 (ORCPT ); Fri, 17 Mar 2023 12:59:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229988AbjCQQ7Y (ORCPT ); Fri, 17 Mar 2023 12:59:24 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4418A20D25; Fri, 17 Mar 2023 09:59:22 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 0FBE7CE20FF; Fri, 17 Mar 2023 16:59:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B00E0C433EF; Fri, 17 Mar 2023 16:59:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679072358; bh=Yr+loVbWv0qK18b3WpWr9ZR4G6QuOAV94eNluGFAb18=; h=Date:From:To:Cc:Subject:From; b=XniyUM26LziXHrexP/d/DUVLjnjl4qsrffDi+ERWh6SmXsGgmg7VJxMQtVgwshxny dFvp0OpJhh/vfqa/cGeur5SEtghfBr9J8PS6x8rdr83Z7Jg2vnxLMEeyE9TQQsK9k7 7EyZpAMUKl0mpKAA3yBGWpDbAHZ/lKDCvl9dgxS3rljmW+AJt7BkR1YjB4s6tSDzHl sk9WX3evD6kjhJWmuXcjEuXv0dg0BRT/rZhwCXMgMMRhznb5ZkmA2GgzdfCJPufpnS /+KkNz7UZCe78TZKjBmBuqymn9RqBm3tnfT5q/gONOSHXhhcKMvGHhTCTTBOeDycaQ bAouUTD5ks0FQ== Date: Fri, 17 Mar 2023 10:59:48 -0600 From: "Gustavo A. R. Silva" To: Bodo Stroesser Cc: linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" , linux-hardening@vger.kernel.org Subject: [PATCH][next] uapi: target: Replace fake flex-array with flexible-array member Message-ID: MIME-Version: 1.0 Content-Disposition: inline Precedence: bulk List-ID: X-Mailing-List: linux-hardening@vger.kernel.org Zero-length arrays as fake flexible arrays are deprecated and we are moving towards adopting C99 flexible-array members instead. Address the following warning found with GCC-13 and -fstrict-flex-arrays=3 enabled: CC drivers/target/target_core_user.o drivers/target/target_core_user.c: In function ‘queue_cmd_ring’: drivers/target/target_core_user.c:1096:15: warning: array subscript 0 is outside array bounds of ‘struct iovec[0]’ [-Warray-bounds=] 1096 | iov = &entry->req.iov[0]; | ^~~~~~~~~~~~~~~~~~ In file included from drivers/target/target_core_user.c:31: ./include/uapi/linux/target_core_user.h:122:38: note: while referencing ‘iov’ 122 | struct iovec iov[0]; | ^~~ This helps with the ongoing efforts to tighten the FORTIFY_SOURCE routines on memcpy() and help us make progress towards globally enabling -fstrict-flex-arrays=3 [1]. Link: https://github.com/KSPP/linux/issues/21 Link: https://github.com/KSPP/linux/issues/270 Link: https://gcc.gnu.org/pipermail/gcc-patches/2022-October/602902.html [1] Signed-off-by: Gustavo A. R. Silva Reviewed-by: Bodo Stroesser Reviewed-by: Kees Cook --- include/uapi/linux/target_core_user.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/uapi/linux/target_core_user.h b/include/uapi/linux/target_core_user.h index fbd8ca67e107..f925a77f19ed 100644 --- a/include/uapi/linux/target_core_user.h +++ b/include/uapi/linux/target_core_user.h @@ -119,7 +119,7 @@ struct tcmu_cmd_entry { __u64 cdb_off; __u64 __pad1; __u64 __pad2; - struct iovec iov[0]; + __DECLARE_FLEX_ARRAY(struct iovec, iov); } req; struct { __u8 scsi_status;