From patchwork Tue Feb 7 21:59:43 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: 54098 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp3105673wrn; Tue, 7 Feb 2023 14:14:14 -0800 (PST) X-Google-Smtp-Source: AK7set8WyYWHW9wtOgDse8wzFs8NCp5NQlccRGu+cyTiIgwnFqfacrgdF0O0jl3r9gpQvrQXGHIf X-Received: by 2002:a05:6a20:144c:b0:bb:eea0:c877 with SMTP id a12-20020a056a20144c00b000bbeea0c877mr6050850pzi.59.1675808053561; Tue, 07 Feb 2023 14:14:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675808053; cv=none; d=google.com; s=arc-20160816; b=iRqzxJPy7aVx6yZbbgnxezxorf5B4eQu7E3qJ3tvyVuOLb2DULlhekK6raT05j8FHN LmiLPZjDBigrQDRD0Hka92tjoTAD3eOoTUR3fgUOPcfHzxOtzzs719jTYMVcoALf6Q4X zJfdtuP8vsEgMW6RuPtE2ctT0ipeG5rnJqixNJCTVOVGv/mUoVvcEDP3hHCDSS6o7esX S8ard3ZpUc8MYeCCq+dZ3vanGfbfLsTIGvGhXfxnO3er8nI+2ceGQndPPg7+58Qc3NhQ +f4NJ15aQwDy7WIHghMD5cUUMdvXL2X6nPMadQbDzxQNgj00DrXT5+Dtu91SCEr9D3O5 f8rg== 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=rHKtb+6jxRpGK85mpxY0MOgZMPH0g0PuEBkaTIIMwYE=; b=oFBo2lDdwK8fSa+DQtnfLZ+hQOuJFw1o9MYbOxVWFQ26WYdyiv4VsldQuBGEnSviGW gRHGmyK0gm9PwqAfG6aS9azb0iOBHzOGT42fl4n13A/89M4FgIC4aUEcZAoCNAP7nknO XW9ar2Q2zAQNViEFg9/DDi2jCSTq8UhJVvg6tKrtm/sxyE124/6To3qYPVFgbSVvqo7u nEoeynHNePXcCdzVWGsqS8W+SnNrBzeXG15f4rq1r07cf+kak2kPaOQqQCtVJJX8HoJP 69gVDHBEGWrVUTLKoW8Te97H6+FQr2kGkG+dW7X8h9u9CGhaeMILK8MpoX3ERn5f4MYS 7PWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mDv+mckU; 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 e3-20020a633703000000b004ec52fa1524si15996576pga.105.2023.02.07.14.14.00; Tue, 07 Feb 2023 14:14:13 -0800 (PST) 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=mDv+mckU; 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 S229777AbjBGV7c (ORCPT + 99 others); Tue, 7 Feb 2023 16:59:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229517AbjBGV7b (ORCPT ); Tue, 7 Feb 2023 16:59:31 -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 A82B5E384; Tue, 7 Feb 2023 13:59:30 -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 438E961300; Tue, 7 Feb 2023 21:59:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 44DB0C433EF; Tue, 7 Feb 2023 21:59:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675807169; bh=2+uIJL7a04k5IP8kjsAfJlykmzdA/z7j0xIh6qAmfQQ=; h=Date:From:To:Cc:Subject:From; b=mDv+mckUu4WGUseKZhRfbTuak+Y/9Xb3qWYXMwj6RibBZrw4xfkq/R5tCLGDw8ebB kKF9rPQQA9Uy6wRpWCn8KW4kbqhnxe01Lg+cXPIs3tWn+zTpqjcz+N2U5XlM48Q91l g2awmj3ww1qo8ZsnG3okQSYq35kNY5Go3ByokLcUg/gcwUUGeq1m6HjVhkScK9zlml kxoKGR67rR4LC0RVPPoYambWbxBzimeeJNUttmWfKCdzblnTj4DM7RRZXlkQGTZCFH QwO3a60J/Z91kpcX/cMKWa1KlVL2xVC7idrS0hyfrahQzQan23m150uyAEmgDtmF4I U3BvIuyq/5xkQ== Date: Tue, 7 Feb 2023 15:59:43 -0600 From: "Gustavo A. R. Silva" To: Don Brace , "James E.J. Bottomley" , "Martin K. Petersen" Cc: storagedev@microchip.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" , linux-hardening@vger.kernel.org, Kees Cook Subject: [PATCH v3][next] scsi: smartpqi: Replace one-element 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 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?1757212105651200439?= X-GMAIL-MSGID: =?utf-8?q?1757212105651200439?= One-element arrays are deprecated, and we are replacing them with flexible array members instead. So, replace one-element array with flexible-array member in struct report_log_lun_list. This helps with the ongoing efforts to tighten the FORTIFY_SOURCE routines on memcpy(). Link: https://github.com/KSPP/linux/issues/79 Link: https://github.com/KSPP/linux/issues/204 Acked-by: Don Brace Signed-off-by: Gustavo A. R. Silva Reviewed-by: Kees Cook --- Changes in v3: - Amplify the existing comment instead of adding a new one. By Don Brace[1]. - Add Don's Acked-by tag to the changelog. Link: https://lore.kernel.org/linux-hardening/d881ad98-a291-1c9b-53dc-199f23f1625e@embeddedor.com/ [1] Changes in v2: - In v1 we thought that the original code was allocating one too-many entries for the list. However, Don Brace commented that the allocation was actually intentional[2]. So, I added a code comment with his feedback. Link: https://lore.kernel.org/linux-hardening/16e6c434-44af-2efb-d4bc-a253e93e5590@embeddedor.com/ [2] v1: - Link: https://lore.kernel.org/linux-hardening/c80c0979933e0c05e80d95792ef167a28640a14b.1663816572.git.gustavoars@kernel.org/ drivers/scsi/smartpqi/smartpqi.h | 2 +- drivers/scsi/smartpqi/smartpqi_init.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/smartpqi/smartpqi.h b/drivers/scsi/smartpqi/smartpqi.h index af27bb0f3133..228838eb3686 100644 --- a/drivers/scsi/smartpqi/smartpqi.h +++ b/drivers/scsi/smartpqi/smartpqi.h @@ -954,7 +954,7 @@ struct report_log_lun { struct report_log_lun_list { struct report_lun_header header; - struct report_log_lun lun_entries[1]; + struct report_log_lun lun_entries[]; }; struct report_phys_lun_8byte_wwid { diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c index d0446d4d4465..49a8f91810b6 100644 --- a/drivers/scsi/smartpqi/smartpqi_init.c +++ b/drivers/scsi/smartpqi/smartpqi_init.c @@ -1259,7 +1259,8 @@ static int pqi_get_device_lists(struct pqi_ctrl_info *ctrl_info, "report logical LUNs failed\n"); /* - * Tack the controller itself onto the end of the logical device list. + * Tack the controller itself onto the end of the logical device list + * by adding a list entry that is all zeros. */ logdev_data = *logdev_list;