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: 71361 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp455016wrt; Fri, 17 Mar 2023 10:06:32 -0700 (PDT) X-Google-Smtp-Source: AK7set/EWPuULvykOUQ103GJRdnXyfDMo9tqYpA7y9zhoAcqoHC/h/WjRjDSqQmITYVyS5HI35Sk X-Received: by 2002:a05:6a20:3d24:b0:c0:2875:9e8c with SMTP id y36-20020a056a203d2400b000c028759e8cmr9775099pzi.1.1679072792275; Fri, 17 Mar 2023 10:06:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679072792; cv=none; d=google.com; s=arc-20160816; b=MUvG9queCUVBnXur+rLky9RYMdVctGBmXz4pmWX1sZd1wqDG9vqP1l4l9Z6hofLXvb KZNOAeXnZw+guo1f9s3kCmKtY/dMJWKz0IUFcNbt60VhH1Rg+Rel0DRdUw77DKxqjUAz kIOYI/7KKzUwN95s8BnDTJCr8Rqm+83nftlvIGI3NKCShfx9Gy3PYyM7xoMWstIZMnj8 SoRn0TszwbCtotTgYIj6hSCdVbW0gOoDxC08tOxkxgXDLsowIVqEHFFQNqAOW3nHsrqk FB09zsoL2DZ5NSfP2U4lzHNlIA+y7TGg1GQbTSB32XHOZ9hepbU+mZH54PYXxsFTbMHj zQZg== 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=WbeBE40EXAlX1Sx72HPct1vSPenQzxMy1eQbJATq5SE=; b=Sx2crwlVRXjTWPihPjK/Xf4Qb/QNYca7cTgeqoabrlR4CLednGYVdMbdL5ZrEAmLYb /U4EjJm7vIhDN/Wdk6Jr9DmnaEipvRHmhgjGzzxl11R0iSM+0hzQLWbGApILyPOUjNA3 uL7oDRD0QXHxoa0JN+Y0iy31itwfrQLx8zo/gXeibH3owfMmrZ4LNQMAOidHBgfqEY9e cSulY8ch/jvFR+JhAwrM4t9Npdbvs7j1GfqEyCdqDuEfxhA05DrtZB4sqrQOktIBxadl wqSVaDQpT6ha9y6UfEdzcYiNyc8yf4GWiAwPjJ2b8SHoXJ189lTalqWQIa6iMVfxkcQM HmrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XniyUM26; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u23-20020a62d457000000b006257ed5354bsi2836908pfl.195.2023.03.17.10.06.19; Fri, 17 Mar 2023 10:06:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XniyUM26; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S229690AbjCQQ72 (ORCPT + 99 others); Fri, 17 Mar 2023 12:59:28 -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 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760635432439708495?= X-GMAIL-MSGID: =?utf-8?q?1760635432439708495?= 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;