From patchwork Tue Feb 22 07:28:54 2022 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: 12754615 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 00445C433EF for ; Tue, 22 Feb 2022 07:21:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230497AbiBVHV3 (ORCPT ); Tue, 22 Feb 2022 02:21:29 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:44080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230457AbiBVHV2 (ORCPT ); Tue, 22 Feb 2022 02:21:28 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CDCA2116283; Mon, 21 Feb 2022 23:21:03 -0800 (PST) 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 ams.source.kernel.org (Postfix) with ESMTPS id 82B20B81887; Tue, 22 Feb 2022 07:21:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8FF44C340E8; Tue, 22 Feb 2022 07:21:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1645514461; bh=SjGYmTvLuGxpF6c1ZqY3bkENDPqYxpdfVh3sFIBch68=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=nqWpOcW24adstDslnETNO2vFjjYqK4MMLH5y4UXr05HgLEF/7UexG/6E21GFxCJ+c 7Rj1MKB3vEfpTOyq/ndTSN60oawhXlg8W0y/OmNEpxfVmJJw1X0oUt7B5Pq2yFFKcH 8Yty02GN6JGPBmpxlWVmW0J3SB41uY/Ang3sghMOT5vUcPnYc/5K7GDRRsr96FD4vA yuJPHeNBuWedDSkRZVGVqKWkFgY/FoQkGVEh1QpD4c2bkqBF+Bb0LER8cfaoIa/C6h LlKaP89wCttGS+cbSnsd7z2soRM0qj66tIufI4UlJ+Mdesmx7UT6CRqCOuY530+aKT GugIgZOu4Gv6g== Date: Tue, 22 Feb 2022 01:28:54 -0600 From: "Gustavo A. R. Silva" To: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Adaptec OEM Raid Solutions , "James E.J. Bottomley" , "Martin K. Petersen" , linux-hardening@vger.kernel.org, "Gustavo A. R. Silva" Subject: [PATCH 1/8][next] scsi: aacraid: Replace one-element array with flexible-array member Message-ID: <1fb4b0263611e3a28d94c5aba4b7c3d7c7791675.1645513670.git.gustavoars@kernel.org> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Replace one-element array with flexible-array member in struct aac_ciss_phys_luns_resp. Also, use the struct_size() helper to properly calculate the total size for allocation. This issue was found with the help of Coccinelle and audited and fixed, manually. Link: https://www.kernel.org/doc/html/v5.16/process/deprecated.html#zero-length-and-one-element-arrays Link: https://github.com/KSPP/linux/issues/79 Signed-off-by: Gustavo A. R. Silva --- drivers/scsi/aacraid/aachba.c | 5 ++--- drivers/scsi/aacraid/aacraid.h | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c index b04d039da276..98100e28e95e 100644 --- a/drivers/scsi/aacraid/aachba.c +++ b/drivers/scsi/aacraid/aachba.c @@ -1823,13 +1823,12 @@ static inline void aac_free_safw_ciss_luns(struct aac_dev *dev) static int aac_get_safw_ciss_luns(struct aac_dev *dev) { int rcode = -ENOMEM; - int datasize; + size_t datasize; struct aac_srb *srbcmd; struct aac_srb_unit srbu; struct aac_ciss_phys_luns_resp *phys_luns; - datasize = sizeof(struct aac_ciss_phys_luns_resp) + - (AAC_MAX_TARGETS - 1) * sizeof(struct _ciss_lun); + datasize = struct_size(phys_luns, lun, AAC_MAX_TARGETS); phys_luns = kmalloc(datasize, GFP_KERNEL); if (phys_luns == NULL) goto out; diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h index 3733df77bc65..704440a96daa 100644 --- a/drivers/scsi/aacraid/aacraid.h +++ b/drivers/scsi/aacraid/aacraid.h @@ -321,7 +321,7 @@ struct aac_ciss_phys_luns_resp { u8 level3[2]; u8 level2[2]; u8 node_ident[16]; /* phys. node identifier */ - } lun[1]; /* List of phys. devices */ + } lun[]; /* List of phys. devices */ }; /* From patchwork Tue Feb 22 07:29:24 2022 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: 12754616 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 DA695C433FE for ; Tue, 22 Feb 2022 07:21:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230467AbiBVHV7 (ORCPT ); Tue, 22 Feb 2022 02:21:59 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:44868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230401AbiBVHV5 (ORCPT ); Tue, 22 Feb 2022 02:21:57 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85CD227151; Mon, 21 Feb 2022 23:21:32 -0800 (PST) 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 E9FF86119B; Tue, 22 Feb 2022 07:21:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B7F25C340E8; Tue, 22 Feb 2022 07:21:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1645514491; bh=vybhf/bdeS9thoWgfLwfs9BW8K9Pb0wuGlFfmM+53TI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=dOwA4S/URYy+qsOUf44pr0kTH4rLHx4hdeiwNhLQRU4VXHmRSLjeHtNvnvyFujTdP b3twbCFP7Piy/EhnYZmKHHcByel70bilekFv2laJoaPBLYa2PsfTdGnCO0fRoLvM4q wQes/2x7yeLi9R/REZYJ8AOu4TphjeO9f+mJP/csW1LXCrD36GhFxK0vUOumO5XMXF QZ5DSaOCiKQFI7kkHJtoGjQB21yld9zJEtEVjRuigZR8DeerMJE3ZmU+/rjSPui4Rm +YuARY5nwnzy4LQz9au2Xh1+Dun+Y45XbU0d9XcXhdRVHUTYcgLh0+3P2Hj65vemur fvodaiGnvlS1A== Date: Tue, 22 Feb 2022 01:29:24 -0600 From: "Gustavo A. R. Silva" To: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Adaptec OEM Raid Solutions , "James E.J. Bottomley" , "Martin K. Petersen" , linux-hardening@vger.kernel.org, "Gustavo A. R. Silva" Subject: [PATCH 2/8][next] scsi: aacraid: Replace one-element array with flexible-array member in struct sgmap Message-ID: <2262eb3384bbc71b9ed4fcbf04ab8a072bacd35f.1645513670.git.gustavoars@kernel.org> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Replace one-element array with flexible-array member in struct sgmap. Also, make use of the struct_size() helper and refactor the code according to the flexible array transformation. This issue was found with the help of Coccinelle and audited and fixed, manually. Link: https://www.kernel.org/doc/html/v5.16/process/deprecated.html#zero-length-and-one-element-arrays Link: https://github.com/KSPP/linux/issues/79 Signed-off-by: Gustavo A. R. Silva --- drivers/scsi/aacraid/aachba.c | 38 +++++++++++---------------------- drivers/scsi/aacraid/aacraid.h | 2 +- drivers/scsi/aacraid/commctrl.c | 3 +-- drivers/scsi/aacraid/comminit.c | 3 +-- 4 files changed, 16 insertions(+), 30 deletions(-) diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c index 98100e28e95e..5014d8374916 100644 --- a/drivers/scsi/aacraid/aachba.c +++ b/drivers/scsi/aacraid/aachba.c @@ -1316,7 +1316,7 @@ static int aac_read_block64(struct fib * fib, struct scsi_cmnd * cmd, u64 lba, u static int aac_read_block(struct fib * fib, struct scsi_cmnd * cmd, u64 lba, u32 count) { - u16 fibsize; + size_t fibsize; struct aac_read *readcmd; struct aac_dev *dev = fib->dev; long ret; @@ -1332,9 +1332,7 @@ static int aac_read_block(struct fib * fib, struct scsi_cmnd * cmd, u64 lba, u32 ret = aac_build_sg(cmd, &readcmd->sg); if (ret < 0) return ret; - fibsize = sizeof(struct aac_read) + - ((le32_to_cpu(readcmd->sg.count) - 1) * - sizeof (struct sgentry)); + fibsize = struct_size(readcmd, sg.sg, le32_to_cpu(readcmd->sg.count)); BUG_ON (fibsize > (fib->dev->max_fib_size - sizeof(struct aac_fibhdr))); /* @@ -1450,7 +1448,7 @@ static int aac_write_block64(struct fib * fib, struct scsi_cmnd * cmd, u64 lba, static int aac_write_block(struct fib * fib, struct scsi_cmnd * cmd, u64 lba, u32 count, int fua) { - u16 fibsize; + size_t fibsize; struct aac_write *writecmd; struct aac_dev *dev = fib->dev; long ret; @@ -1468,9 +1466,7 @@ static int aac_write_block(struct fib * fib, struct scsi_cmnd * cmd, u64 lba, u3 ret = aac_build_sg(cmd, &writecmd->sg); if (ret < 0) return ret; - fibsize = sizeof(struct aac_write) + - ((le32_to_cpu(writecmd->sg.count) - 1) * - sizeof (struct sgentry)); + fibsize = struct_size(writecmd, sg.sg, le32_to_cpu(writecmd->sg.count)); BUG_ON (fibsize > (fib->dev->max_fib_size - sizeof(struct aac_fibhdr))); /* @@ -1574,8 +1570,8 @@ static void aac_srb_callback(void *context, struct fib * fibptr); static int aac_scsi_64(struct fib * fib, struct scsi_cmnd * cmd) { - u16 fibsize; - struct aac_srb * srbcmd = aac_scsi_common(fib, cmd); + size_t fibsize; + struct aac_srb *srbcmd = aac_scsi_common(fib, cmd); long ret; ret = aac_build_sg64(cmd, (struct sgmap64 *) &srbcmd->sg); @@ -1588,9 +1584,7 @@ static int aac_scsi_64(struct fib * fib, struct scsi_cmnd * cmd) /* * Build Scatter/Gather list */ - fibsize = sizeof (struct aac_srb) - sizeof (struct sgentry) + - ((le32_to_cpu(srbcmd->sg.count) & 0xff) * - sizeof (struct sgentry64)); + fibsize = struct_size(srbcmd, sg.sg, le32_to_cpu(srbcmd->sg.count) & 0xff); BUG_ON (fibsize > (fib->dev->max_fib_size - sizeof(struct aac_fibhdr))); @@ -1605,8 +1599,8 @@ static int aac_scsi_64(struct fib * fib, struct scsi_cmnd * cmd) static int aac_scsi_32(struct fib * fib, struct scsi_cmnd * cmd) { - u16 fibsize; - struct aac_srb * srbcmd = aac_scsi_common(fib, cmd); + size_t fibsize; + struct aac_srb *srbcmd = aac_scsi_common(fib, cmd); long ret; ret = aac_build_sg(cmd, (struct sgmap *)&srbcmd->sg); @@ -1619,9 +1613,7 @@ static int aac_scsi_32(struct fib * fib, struct scsi_cmnd * cmd) /* * Build Scatter/Gather list */ - fibsize = sizeof (struct aac_srb) + - (((le32_to_cpu(srbcmd->sg.count) & 0xff) - 1) * - sizeof (struct sgentry)); + fibsize = struct_size(srbcmd, sg.sg, le32_to_cpu(srbcmd->sg.count) & 0xff); BUG_ON (fibsize > (fib->dev->max_fib_size - sizeof(struct aac_fibhdr))); @@ -1670,7 +1662,7 @@ static int aac_send_safw_bmic_cmd(struct aac_dev *dev, struct fib *fibptr; dma_addr_t addr; int rcode; - int fibsize; + size_t fibsize; struct aac_srb *srb; struct aac_srb_reply *srb_reply; struct sgmap64 *sg64; @@ -1689,8 +1681,7 @@ static int aac_send_safw_bmic_cmd(struct aac_dev *dev, fibptr->hw_fib_va->header.XferState &= ~cpu_to_le32(FastResponseCapable); - fibsize = sizeof(struct aac_srb) - sizeof(struct sgentry) + - sizeof(struct sgentry64); + fibsize = sizeof(struct aac_srb) + sizeof(struct sgentry64); /* allocate DMA buffer for response */ addr = dma_map_single(&dev->pdev->dev, xfer_buf, xfer_len, @@ -2261,8 +2252,7 @@ int aac_get_adapter_info(struct aac_dev* dev) } else { dev->a_ops.adapter_bounds = aac_bounds_32; dev->scsi_host_ptr->sg_tablesize = (dev->max_fib_size - - sizeof(struct aac_fibhdr) - - sizeof(struct aac_write) + sizeof(struct sgentry)) / + sizeof(struct aac_fibhdr) - sizeof(struct aac_write)) / sizeof(struct sgentry); if (dev->dac_support) { dev->a_ops.adapter_read = aac_read_block64; @@ -3795,8 +3785,6 @@ static long aac_build_sg(struct scsi_cmnd *scsicmd, struct sgmap *psg) // Get rid of old data psg->count = 0; - psg->sg[0].addr = 0; - psg->sg[0].count = 0; nseg = scsi_dma_map(scsicmd); if (nseg <= 0) diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h index 704440a96daa..320a30865d58 100644 --- a/drivers/scsi/aacraid/aacraid.h +++ b/drivers/scsi/aacraid/aacraid.h @@ -506,7 +506,7 @@ struct sge_ieee1212 { struct sgmap { __le32 count; - struct sgentry sg[1]; + struct sgentry sg[]; }; struct user_sgmap { diff --git a/drivers/scsi/aacraid/commctrl.c b/drivers/scsi/aacraid/commctrl.c index e7cc927ed952..5d6b0d9da0df 100644 --- a/drivers/scsi/aacraid/commctrl.c +++ b/drivers/scsi/aacraid/commctrl.c @@ -561,8 +561,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) rcode = -EINVAL; goto cleanup; } - actual_fibsize = sizeof(struct aac_srb) - sizeof(struct sgentry) + - ((user_srbcmd->sg.count & 0xff) * sizeof(struct sgentry)); + actual_fibsize = struct_size(srbcmd, sg.sg, user_srbcmd->sg.count & 0xff); actual_fibsize64 = actual_fibsize + (user_srbcmd->sg.count & 0xff) * (sizeof(struct sgentry64) - sizeof(struct sgentry)); /* User made a mistake - should not continue */ diff --git a/drivers/scsi/aacraid/comminit.c b/drivers/scsi/aacraid/comminit.c index 355b16f0b145..5f4a97f1f562 100644 --- a/drivers/scsi/aacraid/comminit.c +++ b/drivers/scsi/aacraid/comminit.c @@ -522,8 +522,7 @@ struct aac_dev *aac_init_adapter(struct aac_dev *dev) spin_lock_init(&dev->iq_lock); dev->max_fib_size = sizeof(struct hw_fib); dev->sg_tablesize = host->sg_tablesize = (dev->max_fib_size - - sizeof(struct aac_fibhdr) - - sizeof(struct aac_write) + sizeof(struct sgentry)) + - sizeof(struct aac_fibhdr) - sizeof(struct aac_write)) / sizeof(struct sgentry); dev->comm_interface = AAC_COMM_PRODUCER; dev->raw_io_interface = dev->raw_io_64 = 0; From patchwork Tue Feb 22 07:29:51 2022 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: 12754617 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 82311C433EF for ; Tue, 22 Feb 2022 07:22:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230477AbiBVHWY (ORCPT ); Tue, 22 Feb 2022 02:22:24 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:47242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230401AbiBVHWY (ORCPT ); Tue, 22 Feb 2022 02:22:24 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B89D56231; Mon, 21 Feb 2022 23:21:59 -0800 (PST) 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 3A7B860FA1; Tue, 22 Feb 2022 07:21:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 02B67C340E8; Tue, 22 Feb 2022 07:21:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1645514518; bh=rhZoSoXxf+nv0Ds+0tcSreaauczjofMiqiPbF6f9UGA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Kl57WGODDC/6V7Ch1oePdG/zAH9uZBffJIAmW0Islc1P6XoNvGoV0UOgPNMPv7a1r XnIpFJ+3Bmk6w1J+n8RSytdmSgI1AaW0RQUNMJlh3oG46NL25l1Yz3FARsE/Et67xy +oCOssDowHzYWfRChckrxVkvFfbc1yuZ7qegO+hIb0ztwJXEc1yHUbOuKJUTbjsdym HVNvWEWbrL1XuXfKjv6mnGZxbxX2oRFqCyNEncys2E7cCe8JeJqFcZeLW3mAMQyHJi 3c6wajvCMaUpZNiz1Y7c1xGnnxGIDQXn1rkHxr1IzjW+Nks0frxt1BcxBV7liXXRTm uK8VOmPqWOfew== Date: Tue, 22 Feb 2022 01:29:51 -0600 From: "Gustavo A. R. Silva" To: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Adaptec OEM Raid Solutions , "James E.J. Bottomley" , "Martin K. Petersen" , linux-hardening@vger.kernel.org, "Gustavo A. R. Silva" Subject: [PATCH 3/8][next] scsi: aacraid: Replace one-element array with flexible-array member in struct user_sgmap Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Replace one-element array with flexible-array member in struct user_sgmap. This issue was found with the help of Coccinelle and audited and fixed, manually. Link: https://www.kernel.org/doc/html/v5.16/process/deprecated.html#zero-length-and-one-element-arrays Link: https://github.com/KSPP/linux/issues/79 Signed-off-by: Gustavo A. R. Silva --- drivers/scsi/aacraid/aacraid.h | 2 +- drivers/scsi/aacraid/commctrl.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h index 320a30865d58..bcf97c1b8c0c 100644 --- a/drivers/scsi/aacraid/aacraid.h +++ b/drivers/scsi/aacraid/aacraid.h @@ -511,7 +511,7 @@ struct sgmap { struct user_sgmap { u32 count; - struct user_sgentry sg[1]; + struct user_sgentry sg[]; }; struct sgmap64 { diff --git a/drivers/scsi/aacraid/commctrl.c b/drivers/scsi/aacraid/commctrl.c index 5d6b0d9da0df..3206d9491fca 100644 --- a/drivers/scsi/aacraid/commctrl.c +++ b/drivers/scsi/aacraid/commctrl.c @@ -523,7 +523,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) goto cleanup; } - if ((fibsize < (sizeof(struct user_aac_srb) - sizeof(struct user_sgentry))) || + if ((fibsize < sizeof(*user_srbcmd)) || (fibsize > (dev->max_fib_size - sizeof(struct aac_fibhdr)))) { rcode = -EINVAL; goto cleanup; From patchwork Tue Feb 22 07:30:06 2022 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: 12754618 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 4CF17C433FE for ; Tue, 22 Feb 2022 07:22:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230484AbiBVHWm (ORCPT ); Tue, 22 Feb 2022 02:22:42 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:48784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230401AbiBVHWl (ORCPT ); Tue, 22 Feb 2022 02:22:41 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BB775E157; Mon, 21 Feb 2022 23:22:16 -0800 (PST) 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 ams.source.kernel.org (Postfix) with ESMTPS id D6EE7B81886; Tue, 22 Feb 2022 07:22:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D5C47C340E8; Tue, 22 Feb 2022 07:22:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1645514533; bh=N5OOodQM5orTfwFxfN2SOmhucLQF1RkDS9TqftjrLNg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=cMzj8NyG13mkouqjlCErqMXPMUgHZK2BPGgXvA0o1EAfLn5km3WFeOJYsiPsz0qzu dDNf631WPWQKnFxNDkgmfChwk1FTi9yLW4m4VSUSHSqMfqn9Y9DJxTOuCuc6wur+Io cd6QoATakgXTVY1vz4ryVo+13Fsrso3yrB+KZJPYg8uWwyjczm77R+x0JW2AvrU1SU atlBAmMvC4n637B+VhYLe9H6PxD2HSQwq9xlp8GVMvJejbfpBNjQfvImcP1X4H+TYQ 9+MwfW4su7gXri2U5UDug1SmYQWqiGNXYv7p0kZ+4J+ZpgUf7UZMgQ0VtBohgz0kmq 99BDSUeCFVWMQ== Date: Tue, 22 Feb 2022 01:30:06 -0600 From: "Gustavo A. R. Silva" To: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Adaptec OEM Raid Solutions , "James E.J. Bottomley" , "Martin K. Petersen" , linux-hardening@vger.kernel.org, "Gustavo A. R. Silva" Subject: [PATCH 4/8][next] scsi: aacraid: Replace one-element array with flexible-array member in struct sgmap64 Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Replace one-element array with flexible-array member in struct sgmap64. Also, make use of the struct_size() helper and refactor the code according to the flexible array transformation in struct sgmap64. This issue was found with the help of Coccinelle and audited and fixed, manually. Link: https://www.kernel.org/doc/html/v5.16/process/deprecated.html#zero-length-and-one-element-arrays Link: https://github.com/KSPP/linux/issues/79 Signed-off-by: Gustavo A. R. Silva --- drivers/scsi/aacraid/aachba.c | 15 +++++---------- drivers/scsi/aacraid/aacraid.h | 2 +- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c index 5014d8374916..02b75a2c3a88 100644 --- a/drivers/scsi/aacraid/aachba.c +++ b/drivers/scsi/aacraid/aachba.c @@ -1281,7 +1281,7 @@ static int aac_read_raw_io(struct fib * fib, struct scsi_cmnd * cmd, u64 lba, u3 static int aac_read_block64(struct fib * fib, struct scsi_cmnd * cmd, u64 lba, u32 count) { - u16 fibsize; + size_t fibsize; struct aac_read64 *readcmd; long ret; @@ -1297,9 +1297,7 @@ static int aac_read_block64(struct fib * fib, struct scsi_cmnd * cmd, u64 lba, u ret = aac_build_sg64(cmd, &readcmd->sg); if (ret < 0) return ret; - fibsize = sizeof(struct aac_read64) + - ((le32_to_cpu(readcmd->sg.count) - 1) * - sizeof (struct sgentry64)); + fibsize = struct_size(readcmd, sg.sg, le32_to_cpu(readcmd->sg.count)); BUG_ON (fibsize > (fib->dev->max_fib_size - sizeof(struct aac_fibhdr))); /* @@ -1413,7 +1411,7 @@ static int aac_write_raw_io(struct fib * fib, struct scsi_cmnd * cmd, u64 lba, u static int aac_write_block64(struct fib * fib, struct scsi_cmnd * cmd, u64 lba, u32 count, int fua) { - u16 fibsize; + size_t fibsize; struct aac_write64 *writecmd; long ret; @@ -1429,9 +1427,7 @@ static int aac_write_block64(struct fib * fib, struct scsi_cmnd * cmd, u64 lba, ret = aac_build_sg64(cmd, &writecmd->sg); if (ret < 0) return ret; - fibsize = sizeof(struct aac_write64) + - ((le32_to_cpu(writecmd->sg.count) - 1) * - sizeof (struct sgentry64)); + fibsize = struct_size(writecmd, sg.sg, le32_to_cpu(writecmd->sg.count)); BUG_ON (fibsize > (fib->dev->max_fib_size - sizeof(struct aac_fibhdr))); /* @@ -2263,8 +2259,7 @@ int aac_get_adapter_info(struct aac_dev* dev) dev->scsi_host_ptr->sg_tablesize = (dev->max_fib_size - sizeof(struct aac_fibhdr) - - sizeof(struct aac_write64) + - sizeof(struct sgentry64)) / + sizeof(struct aac_write64)) / sizeof(struct sgentry64); } else { dev->a_ops.adapter_read = aac_read_block; diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h index bcf97c1b8c0c..573cb36c2e15 100644 --- a/drivers/scsi/aacraid/aacraid.h +++ b/drivers/scsi/aacraid/aacraid.h @@ -516,7 +516,7 @@ struct user_sgmap { struct sgmap64 { __le32 count; - struct sgentry64 sg[1]; + struct sgentry64 sg[]; }; struct user_sgmap64 { From patchwork Tue Feb 22 07:30:21 2022 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: 12754619 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 AA9D4C433EF for ; Tue, 22 Feb 2022 07:22:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230496AbiBVHW4 (ORCPT ); Tue, 22 Feb 2022 02:22:56 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:50264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230401AbiBVHWz (ORCPT ); Tue, 22 Feb 2022 02:22:55 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 366D66AA6C; Mon, 21 Feb 2022 23:22:31 -0800 (PST) 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 ams.source.kernel.org (Postfix) with ESMTPS id E2794B81885; Tue, 22 Feb 2022 07:22:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1423DC340E8; Tue, 22 Feb 2022 07:22:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1645514548; bh=ezgVmmf9dc7akc/5R3CnDuRqJRES2HJJNtl0U5d8L4A=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=fQqo5QSPuK+gsUcyr7bIZEm2rFeVouAAExYvVzHylwvavt3vDD9uI/6nwuJweXMrI gYp+nXEZScqO5u7JpoApGBtPS9VHoug5vXW3PdvhdxcL4B01oW0WWlpSc2OTxxOxUz ACEbE/ZD+neHUdq4z3eYcyRSoG2YlQIFOn1l2BVIsz63Ut77KN0zHVvVpJMX15hrW8 9YmFPPrpvtVhfcoFbgOkSw3zQmbQ03lOe+WHyzICpdnCRwrCxZJGQpeLXdm3tqXJ9U 5d/HpcRC6Mv7B9KnQ3e6+14TAhVIGm60v5NWEOt4MekSWlccqJ/RPEdlqJbM0Gdbse XwFKGfeXBoEHw== Date: Tue, 22 Feb 2022 01:30:21 -0600 From: "Gustavo A. R. Silva" To: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Adaptec OEM Raid Solutions , "James E.J. Bottomley" , "Martin K. Petersen" , linux-hardening@vger.kernel.org, "Gustavo A. R. Silva" Subject: [PATCH 5/8][next] scsi: aacraid: Replace one-element array with flexible-array member in struct user_sgmap64 Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Replace one-element array with flexible-array member in struct user_sgmap64. This issue was found with the help of Coccinelle and audited and fixed, manually. Link: https://www.kernel.org/doc/html/v5.16/process/deprecated.html#zero-length-and-one-element-arrays Link: https://github.com/KSPP/linux/issues/79 Signed-off-by: Gustavo A. R. Silva --- drivers/scsi/aacraid/aacraid.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h index 573cb36c2e15..fa5a93b4dc7b 100644 --- a/drivers/scsi/aacraid/aacraid.h +++ b/drivers/scsi/aacraid/aacraid.h @@ -521,7 +521,7 @@ struct sgmap64 { struct user_sgmap64 { u32 count; - struct user_sgentry64 sg[1]; + struct user_sgentry64 sg[]; }; struct sgmapraw { From patchwork Tue Feb 22 07:30:35 2022 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: 12754620 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 5EF39C4332F for ; Tue, 22 Feb 2022 07:22:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230506AbiBVHXL (ORCPT ); Tue, 22 Feb 2022 02:23:11 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:51514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230503AbiBVHXJ (ORCPT ); Tue, 22 Feb 2022 02:23:09 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7FD338CDAF; Mon, 21 Feb 2022 23:22:43 -0800 (PST) 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 9ECB4611D6; Tue, 22 Feb 2022 07:22:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6174CC340E8; Tue, 22 Feb 2022 07:22:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1645514562; bh=cVN6s5q2QWyjNoZlX6Op8Vx2PlbO9x+lAycqiMMemRE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=B3cX1Dg48Hes+NYmcLo3vfSrP0WJGNcGPvWZ/JFeqZs8gytcG0O+2iFRETDmsxUxq PTMgVog7Si+u5B2AoMnFuyQy3hEofjlbKnQ/rW6ii8Q0i5CBm3unn/S+5/+Ce5fZs8 +Q9g6JiSc2y5M47R2UaFtupqYLTU9bYYzbY7IFZ+UG1uxG+zGkGAyJaKQPD2FQd0lT NI1CZHgbtSZhEjn6rOKE6/u3I+BgBCJrCCsHTT0eHRUWDY6gOkXqyIjrCha/Gv9Tiq od6ksIC+qov5oXTwObytin+/zeOPGv7GYPQ8IF9p7t8/O5vkED8hfP7L4IbxV5DhKD TpJ3hnA4RdFpw== Date: Tue, 22 Feb 2022 01:30:35 -0600 From: "Gustavo A. R. Silva" To: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Adaptec OEM Raid Solutions , "James E.J. Bottomley" , "Martin K. Petersen" , linux-hardening@vger.kernel.org, "Gustavo A. R. Silva" Subject: [PATCH 6/8][next] scsi: aacraid: Replace one-element array with flexible-array member in struct sgmapraw Message-ID: <141553000a3dcfcf01cc3de08e6be17bdfd9f80a.1645513670.git.gustavoars@kernel.org> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Replace one-element array with flexible-array member in struct sgmapraw. This issue was found with the help of Coccinelle and audited and fixed, manually. Link: https://www.kernel.org/doc/html/v5.16/process/deprecated.html#zero-length-and-one-element-arrays Link: https://github.com/KSPP/linux/issues/79 Signed-off-by: Gustavo A. R. Silva --- drivers/scsi/aacraid/aachba.c | 18 ++++++------------ drivers/scsi/aacraid/aacraid.h | 2 +- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c index 02b75a2c3a88..5c089993cf2a 100644 --- a/drivers/scsi/aacraid/aachba.c +++ b/drivers/scsi/aacraid/aachba.c @@ -1224,7 +1224,8 @@ static void io_callback(void *context, struct fib * fibptr); static int aac_read_raw_io(struct fib * fib, struct scsi_cmnd * cmd, u64 lba, u32 count) { struct aac_dev *dev = fib->dev; - u16 fibsize, command; + size_t fibsize; + u16 command; long ret; aac_fib_init(fib); @@ -1262,8 +1263,7 @@ static int aac_read_raw_io(struct fib * fib, struct scsi_cmnd * cmd, u64 lba, u3 if (ret < 0) return ret; command = ContainerRawIo; - fibsize = sizeof(struct aac_raw_io) + - ((le32_to_cpu(readcmd->sg.count)-1) * sizeof(struct sgentryraw)); + fibsize = struct_size(readcmd, sg.sg, le32_to_cpu(readcmd->sg.count)); } BUG_ON(fibsize > (fib->dev->max_fib_size - sizeof(struct aac_fibhdr))); @@ -1348,7 +1348,8 @@ static int aac_read_block(struct fib * fib, struct scsi_cmnd * cmd, u64 lba, u32 static int aac_write_raw_io(struct fib * fib, struct scsi_cmnd * cmd, u64 lba, u32 count, int fua) { struct aac_dev *dev = fib->dev; - u16 fibsize, command; + size_t fibsize; + u16 command; long ret; aac_fib_init(fib); @@ -1392,8 +1393,7 @@ static int aac_write_raw_io(struct fib * fib, struct scsi_cmnd * cmd, u64 lba, u if (ret < 0) return ret; command = ContainerRawIo; - fibsize = sizeof(struct aac_raw_io) + - ((le32_to_cpu(writecmd->sg.count)-1) * sizeof (struct sgentryraw)); + fibsize = struct_size(writecmd, sg.sg, le32_to_cpu(writecmd->sg.count)); } BUG_ON(fibsize > (fib->dev->max_fib_size - sizeof(struct aac_fibhdr))); @@ -3861,12 +3861,6 @@ static long aac_build_sgraw(struct scsi_cmnd *scsicmd, struct sgmapraw *psg) // Get rid of old data psg->count = 0; - psg->sg[0].next = 0; - psg->sg[0].prev = 0; - psg->sg[0].addr[0] = 0; - psg->sg[0].addr[1] = 0; - psg->sg[0].count = 0; - psg->sg[0].flags = 0; nseg = scsi_dma_map(scsicmd); if (nseg <= 0) diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h index fa5a93b4dc7b..511a58ec5c9d 100644 --- a/drivers/scsi/aacraid/aacraid.h +++ b/drivers/scsi/aacraid/aacraid.h @@ -526,7 +526,7 @@ struct user_sgmap64 { struct sgmapraw { __le32 count; - struct sgentryraw sg[1]; + struct sgentryraw sg[]; }; struct user_sgmapraw { From patchwork Tue Feb 22 07:30:49 2022 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: 12754621 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 4D2E6C433EF for ; Tue, 22 Feb 2022 07:23:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230522AbiBVHXX (ORCPT ); Tue, 22 Feb 2022 02:23:23 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:53050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230495AbiBVHXX (ORCPT ); Tue, 22 Feb 2022 02:23:23 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A722A93190; Mon, 21 Feb 2022 23:22:58 -0800 (PST) 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 ams.source.kernel.org (Postfix) with ESMTPS id 64BBFB81888; Tue, 22 Feb 2022 07:22:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 73791C340E8; Tue, 22 Feb 2022 07:22:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1645514576; bh=zpk+Nb7nHyNWqeLtH9QEPrEyNx4eo/TLDHWqFwjVBfA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=VzbxDaL0YuebwwwrWDfAooGCapvFt3j1HH3/541SJIxWFRojdxOHYsLGhEv73VDBC 6Z3CgUZ/j6F9s7zKfN2ktRENrmlfHQ3+BAfMWRLGQwapSgwApTRD03YaoSh+9m53TC rj1SAcbxJ7RRTZy5vFOyyws35h4pxuValpjbqERNF2BNqRX/KA/jgC5BAZsGkDrwAC gOs9THG+XHaAnCjB26BBkJYhgdo6P+6eKBZt4TA1isbAl0LXiVj9ThqwH7JujCScSN SsZCyEo+PD3bOVfVo5aULdr7I6UYoRpnos8OKRq+wk5o4WAp78axWhdWDFnWxZNDZF A6mICC+K0X6rg== Date: Tue, 22 Feb 2022 01:30:49 -0600 From: "Gustavo A. R. Silva" To: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Adaptec OEM Raid Solutions , "James E.J. Bottomley" , "Martin K. Petersen" , linux-hardening@vger.kernel.org, "Gustavo A. R. Silva" Subject: [PATCH 7/8][next] scsi: aacraid: Replace one-element array with flexible-array member in struct user_sgmapraw Message-ID: <79470e205f517aedd99f1d6f08428fbbe370d496.1645513670.git.gustavoars@kernel.org> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Replace one-element array with flexible-array member in struct user_sgmapraw. This issue was found with the help of Coccinelle and audited and fixed, manually. Link: https://www.kernel.org/doc/html/v5.16/process/deprecated.html#zero-length-and-one-element-arrays Link: https://github.com/KSPP/linux/issues/79 Signed-off-by: Gustavo A. R. Silva --- drivers/scsi/aacraid/aacraid.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h index 511a58ec5c9d..97948cd5f13c 100644 --- a/drivers/scsi/aacraid/aacraid.h +++ b/drivers/scsi/aacraid/aacraid.h @@ -531,7 +531,7 @@ struct sgmapraw { struct user_sgmapraw { u32 count; - struct user_sgentryraw sg[1]; + struct user_sgentryraw sg[]; }; struct creation_info From patchwork Tue Feb 22 07:31:07 2022 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: 12754622 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 C8E89C433EF for ; Tue, 22 Feb 2022 07:23:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231129AbiBVHXk (ORCPT ); Tue, 22 Feb 2022 02:23:40 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:54626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230495AbiBVHXj (ORCPT ); Tue, 22 Feb 2022 02:23:39 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5573EC4295; Mon, 21 Feb 2022 23:23:15 -0800 (PST) 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 E4D95611C8; Tue, 22 Feb 2022 07:23:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AA9E1C340E8; Tue, 22 Feb 2022 07:23:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1645514594; bh=lw9fy6EP1h2nUptSIDOirVphpvqPdsxFhmUtQZxs2B0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=sOGlSCAogaMh7NzeqJYs5YzeOcOA0uhY6Jy1te1KlgAs5DEvMt1L0aeXbCmGV7qjR /QCHBeqAye9mcbW0UGXVYL40S1W2UmB3lRacQVKCFduYQMhoQA5VQb43YvLA2BCJno IivFiSCoK10IkwdVNKQrvN7eh2xh1Pw4p0NY2W1/kqQTpQU124IHRpq4uQX3Srb/yv IGBT+7by5twipzM+hmklfKDGiI4hTVPtfXTjGtItjJ9Kn+ou7kpTsweqbHYgM4L3M4 ra5GgwfLaCX+Sef4H64BgmnMFaVsOBCdwqrY0zlugsqma1/7aD5jx4WF1WdzHVmYEF hawqnv6QKx37w== Date: Tue, 22 Feb 2022 01:31:07 -0600 From: "Gustavo A. R. Silva" To: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Adaptec OEM Raid Solutions , "James E.J. Bottomley" , "Martin K. Petersen" , linux-hardening@vger.kernel.org, "Gustavo A. R. Silva" Subject: [PATCH 8/8][next] scsi: aacraid: Replace one-element array with flexible-array member in struct aac_aifcmd Message-ID: <7d0571ef5dc87904008c325a942cfed24dbbf42e.1645513670.git.gustavoars@kernel.org> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Replace one-element array with flexible-array member in struct aac_aifcmd. This issue was found with the help of Coccinelle and audited and fixed, manually. Link: https://www.kernel.org/doc/html/v5.16/process/deprecated.html#zero-length-and-one-element-arrays Link: https://github.com/KSPP/linux/issues/79 Signed-off-by: Gustavo A. R. Silva --- drivers/scsi/aacraid/aacraid.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h index 97948cd5f13c..447feabf5360 100644 --- a/drivers/scsi/aacraid/aacraid.h +++ b/drivers/scsi/aacraid/aacraid.h @@ -2616,7 +2616,7 @@ struct aac_hba_info { struct aac_aifcmd { __le32 command; /* Tell host what type of notify this is */ __le32 seqnum; /* To allow ordering of reports (if necessary) */ - u8 data[1]; /* Undefined length (from kernel viewpoint) */ + u8 data[]; /* Undefined length (from kernel viewpoint) */ }; /**