From patchwork Wed Dec 14 08:42:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paulo Miguel Almeida X-Patchwork-Id: 33108 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp90634wrn; Wed, 14 Dec 2022 00:49:15 -0800 (PST) X-Google-Smtp-Source: AA0mqf5jMsQwnEOq/rVKQF/L3Nx5lvevlnBb0fQH3lsF/ZBJPC5zBke6zLktTuGmrPcJPmiJEt7S X-Received: by 2002:a05:6a00:a93:b0:56b:6c05:3da6 with SMTP id b19-20020a056a000a9300b0056b6c053da6mr30439374pfl.8.1671007755441; Wed, 14 Dec 2022 00:49:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671007755; cv=none; d=google.com; s=arc-20160816; b=puaL49v47v0S5WPoZM4KYUiM6N9y3RkVRqtzDA8XtYVLSDd0PG5Y9BCGnzMx6GI5TF 5I77oOqumi6qVuejaNecHRo9Pyx3aStjJJa0+pxHPpyHQjLdzKY4TC7tGWwClyYlHgon XVvvZY9xs79pXQN1o4crp9HZQLBLC8pzFW19LJgtP6wUgDp0yw/SOOBl7zn39pMabOXU FndE5s8fm8CTOUKt+AALpNcaBafPskRBhR4syCBwszfSDVEHHH+M+argyZwx/IeOGvCr /2XkqOHc5S0VxcOd8JS7Kh03Kg1WqOSxCxYGQoZdAttGSqk4CuUGBd8fzIh+HQVbBfX6 tbIA== 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=mKIXxnGp5Qeh1H1kOjUA7WrQEgWAzUUtfWKKqj9aC5A=; b=XfErqkBxBCZCijCF+5C5Sjoc8LZ3BefosG2DDN2LVOjNCwSTHze9dLFcCRx9PsNLnA BkNeVEMGYHxcKrFdI9VH2wDbieXi1Wlxx1moQwtp7jpDn8JexCIpARTdKCXD52+yDLJV OYWIZHsDRE2sgBd2AzhewAD/3IUkNHFFEFVJOSq98dam/8s0Ttv0Rxb/Xa1xKPMwpvR4 4E1rWsn7OECLI88+safKHLWScFZrrRP5tKrhuAJy/s6H47sSoPnRuv1iLT8mMOfDAars f1Y3d2y04iEX4vVi24URWZajhwyZs+Ka39kxfcusF3+ii7akI9dURQMCl07z6YlfdFl4 AwrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="RUKS8+/p"; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 190-20020a6217c7000000b00535fa14ffaasi14619710pfx.116.2022.12.14.00.49.01; Wed, 14 Dec 2022 00:49:15 -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=@gmail.com header.s=20210112 header.b="RUKS8+/p"; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237760AbiLNImL (ORCPT + 99 others); Wed, 14 Dec 2022 03:42:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237356AbiLNImI (ORCPT ); Wed, 14 Dec 2022 03:42:08 -0500 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A58116580; Wed, 14 Dec 2022 00:42:08 -0800 (PST) Received: by mail-pj1-x102c.google.com with SMTP id u15-20020a17090a3fcf00b002191825cf02so6339794pjm.2; Wed, 14 Dec 2022 00:42:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=mKIXxnGp5Qeh1H1kOjUA7WrQEgWAzUUtfWKKqj9aC5A=; b=RUKS8+/pkEoTD8k0JJKHv8nza/xwr2KJsRoJ713qLCRtM5TldRtS0CrAdQWHN15/T5 7ccfexgetApOumRV8EN13507YFLVeL2s8O9PjsVi2TS8qI8exUMro2LR/A2QzL4n8oii XEsXw+zgiiX54cwxIn7/n9O9xOs3pWxw4G38lW2bV4H3w/ymJ1MdIWUdS2IVvObxEjjy RLbqgR0Uj30QoSQH0A8y75S29JO6e1cXEpjsFy8Jh3rhsqqC2dp34FcaWoMMrxLTKAUz +qjdg3exntCjFNlOAIWjZQr40KeOkJ6I6RNgEtcmkcyPxzouYG8ydU1G8gz0wb9Zox+b kOzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=mKIXxnGp5Qeh1H1kOjUA7WrQEgWAzUUtfWKKqj9aC5A=; b=lDn9mgjptMrHFIRf9xsLH5iU+KsTPdFoJ+6UkrPmasY1qW1JDQVjsVMjjy0lZkjD6F K/np1i7CUIYmLpJv2YQpcF5bQ2jYIWftKDfLhQdAlSYaRW4WgN1PfncD86SXpgr04bNz m79T1XfiNDn13c7GhmPuUP6gO7YKnn99JXer+MPndZxo/CzQhdjK+6jQBluREiojtQyX TEq+yZCWiD00xGIT5wC+XHokwWArsGG4XamHhjsrutQ/xR+JvcbeJtP28rov1tDczdf2 HQf5vhKc7M0OdbxB/4KZDE4qr9ITcOfGQN4YbmdllpPDdDxbsqjWneTcIvNOYBekT/65 aMwg== X-Gm-Message-State: ANoB5pl8qr5EHeyniwib+nDjMJtMwrW3W1MZEy2GIt0bj4heUG0C7XJp j6yIQ7y9WmDCTzIPyCd8Xug= X-Received: by 2002:a17:902:7fcb:b0:18b:cea3:645 with SMTP id t11-20020a1709027fcb00b0018bcea30645mr5353251plb.0.1671007327631; Wed, 14 Dec 2022 00:42:07 -0800 (PST) Received: from mail.google.com (125-237-37-88-fibre.sparkbb.co.nz. [125.237.37.88]) by smtp.gmail.com with ESMTPSA id d9-20020a170903230900b00189988a1a9esm1278650plh.135.2022.12.14.00.42.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Dec 2022 00:42:07 -0800 (PST) Date: Wed, 14 Dec 2022 21:42:00 +1300 From: Paulo Miguel Almeida To: Arnd Bergmann , Greg Kroah-Hartman , Ilpo =?utf-8?b?SsOkcnZp?= =?utf-8?b?bmVu?= , Jiri Slaby , Haowen Bai , Andy Shevchenko Cc: linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, paulo.miguel.almeida.rodenas@gmail.com Subject: [PATCH] [next] pcmcia: synclink_cs: replace 1-element array with flex-array member Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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?1752178628281291331?= X-GMAIL-MSGID: =?utf-8?q?1752178628281291331?= 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 RXBUF and refactor the rest of the code accordingly. It's worth mentioning that doing a build before/after this patch results in no binary output differences. 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/79 Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101836 [1] Signed-off-by: Paulo Miguel Almeida --- drivers/char/pcmcia/synclink_cs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c index b2735be81ab2..1ab2d552f498 100644 --- a/drivers/char/pcmcia/synclink_cs.c +++ b/drivers/char/pcmcia/synclink_cs.c @@ -105,7 +105,7 @@ static MGSL_PARAMS default_params = { typedef struct { int count; unsigned char status; - char data[1]; + char data[]; } RXBUF; /* The queue of BH actions to be performed */ @@ -2611,7 +2611,8 @@ static int mgslpc_proc_show(struct seq_file *m, void *v) static int rx_alloc_buffers(MGSLPC_INFO *info) { /* each buffer has header and data */ - info->rx_buf_size = sizeof(RXBUF) + info->max_frame_size; + info->rx_buf_size = max(offsetof(typeof(RXBUF), data) + 1, sizeof(RXBUF)) + + info->max_frame_size; /* calculate total allocation size for 8 buffers */ info->rx_buf_total_size = info->rx_buf_size * 8;