From patchwork Tue Jun 6 23:22:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gustavo A. R. Silva" X-Patchwork-Id: 104151 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp3743558vqr; Tue, 6 Jun 2023 16:55:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ696yxW/7v2hFi4xD+0VZ0a136vJkYEQrXjYlO/xTQqv91rp9Ud160Ng/nWUXs+FWOJ6jtf X-Received: by 2002:a05:6808:7c4:b0:398:1047:9e3a with SMTP id f4-20020a05680807c400b0039810479e3amr2150278oij.25.1686095755321; Tue, 06 Jun 2023 16:55:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686095755; cv=none; d=google.com; s=arc-20160816; b=oKQUveG1BW3m7l1PhsCZuPYiX04yQ6uGFPa7ilreU5S7pVXJCnWP84ufAjB8XVExKL FZB8AGzqWuEhpzgJvPskav+dwbMbYzk51NEnNj7tynjSslZmzTlD5Fvo3Mtmlc52wEVg spHk7bpSZZGRIaNnpBN6SudjlHnfNrI5hPKwXiBDOrvUZSfpOwgClRUWtcNVbu2mFPnt 2/xVib0B4JJ99Scf8CkhpIfLCfvFgBLbTqW0yblUyWt+OFY9bUeGSt26zQR1tK9ZgAWm aeR475Z07ek0UAAyHMBMJIcJmC/IWavozGfGYTLpCkQM2lGOT0g+4MXPRY9BnPOcBea0 VxmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=PMsGBqu3SLcZ55Jomno4vzS5Oqw7WNHc25TsbxbcI38=; b=YVNd2aI9RBpW9ep3Q/W4h6wVeyKM9wNr6N8bDrR3cWhtbfpxCPnVpvR1g5zkUEWXvd 5gXVQ6Ktf6W4LliN/m91buDotKm8bjdzSSX7oIr1nM/+USlMQ+snEWYqJvLAYOrlEVEm 1UhBoRqo8k55bO5sxs2b/STDhq5xi72sGAEgKTYfVM7fV8Zs3SNgP1PfSs+zZ5dPCGaK ap+w95wluaTHvgCIiYLb8wQCTi27CUmS9bi7PJ0sRzqtP3My399YSxX+OTWa6LlHnDQv aWlrp/4ilIE4Ov8bNeSKR2AUnZl+RLxnY0pqaCwxrJdSFaPe3TwhEw1Mb6sjLQQnDOVZ tAYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="mdy5/Q9U"; 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 l6-20020a17090aaa8600b0024e29c5c06dsi185699pjq.12.2023.06.06.16.55.36; Tue, 06 Jun 2023 16:55:55 -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="mdy5/Q9U"; 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 S239821AbjFFXVl (ORCPT + 99 others); Tue, 6 Jun 2023 19:21:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238262AbjFFXVd (ORCPT ); Tue, 6 Jun 2023 19:21:33 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C32B410C6; Tue, 6 Jun 2023 16:21:31 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 4F7A063903; Tue, 6 Jun 2023 23:21:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E641FC433D2; Tue, 6 Jun 2023 23:21:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686093690; bh=QLiV6Xl+X+ABZIsh3W9Glykjhx+2zH3dlEFevPn4GlE=; h=Date:From:To:Cc:Subject:From; b=mdy5/Q9UkOwGl/WyHJDdRLVVVKRXQkYQuKc/tfyTjUmReMC9esW2Y6QbZtAVgcVfc ymPAHmww9bdTqrF+hs4R8+PABccA4gvKrOXzz+CM2fs4p/OCQvsfSGQ7cCL1QBNwde Iwb2BLzElh0v/Ka9zpoq62zFuPAEEgRkRH73xpGdVQDcqYEZygoFpyNRHoMSqr6J6u 9A+U1iy7x4UsSpwrg82QUKEYK+LV9eAaoMdRFQLldXMgzBYEfvCcxXx1hax5Trg9Ck lZCq2eOiVmirXEZHMXYIYeyY4785/VkFs5No2pEQhw+WT5VlBVcI8NX3SSv0T4kFhk DgzxnaWV5XGUg== Date: Tue, 6 Jun 2023 17:22:21 -0600 From: "Gustavo A. R. Silva" To: Nilesh Javali , "James E.J. Bottomley" , "Martin K. Petersen" Cc: GR-QLogic-Storage-Upstream@marvell.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" , linux-hardening@vger.kernel.org Subject: [RESEND][PATCH][next] Replace one-element array with DECLARE_FLEX_ARRAY() helper 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,T_SCC_BODY_TEXT_LINE 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?1767999542910139393?= X-GMAIL-MSGID: =?utf-8?q?1767999542910139393?= One-element arrays as fake flex arrays are deprecated and we are moving towards adopting C99 flexible-array members, instead. So, replace one-element array declaration in struct ct_sns_gpnft_rsp, which is ultimately being used inside a union: drivers/scsi/qla2xxx/qla_def.h: 3240 struct ct_sns_gpnft_pkt { 3241 union { 3242 struct ct_sns_req req; 3243 struct ct_sns_gpnft_rsp rsp; 3244 } p; 3245 }; Refactor the rest of the code, accordingly. This issue was found with the help of Coccinelle. Link: https://github.com/KSPP/linux/issues/245 Link: https://github.com/KSPP/linux/issues/193 Reviewed-by: Kees Cook Signed-off-by: Gustavo A. R. Silva --- drivers/scsi/qla2xxx/qla_def.h | 4 ++-- drivers/scsi/qla2xxx/qla_gs.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h index 35009ce5246a..a9acdec003a3 100644 --- a/drivers/scsi/qla2xxx/qla_def.h +++ b/drivers/scsi/qla2xxx/qla_def.h @@ -3174,12 +3174,12 @@ struct ct_sns_gpnft_rsp { uint8_t vendor_unique; }; /* Assume the largest number of targets for the union */ - struct ct_sns_gpn_ft_data { + DECLARE_FLEX_ARRAY(struct ct_sns_gpn_ft_data { u8 control_byte; u8 port_id[3]; u32 reserved; u8 port_name[8]; - } entries[1]; + }, entries); }; /* CT command response */ diff --git a/drivers/scsi/qla2xxx/qla_gs.c b/drivers/scsi/qla2xxx/qla_gs.c index 4738f8935f7f..1cf9d200d563 100644 --- a/drivers/scsi/qla2xxx/qla_gs.c +++ b/drivers/scsi/qla2xxx/qla_gs.c @@ -3776,8 +3776,8 @@ int qla24xx_async_gpnft(scsi_qla_host_t *vha, u8 fc4_type, srb_t *sp) sp->u.iocb_cmd.u.ctarg.req_size = GPN_FT_REQ_SIZE; rspsz = sizeof(struct ct_sns_gpnft_rsp) + - ((vha->hw->max_fibre_devices - 1) * - sizeof(struct ct_sns_gpn_ft_data)); + vha->hw->max_fibre_devices * + sizeof(struct ct_sns_gpn_ft_data); sp->u.iocb_cmd.u.ctarg.rsp = dma_alloc_coherent(&vha->hw->pdev->dev, rspsz,