Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1338515rwb; Tue, 4 Oct 2022 20:25:23 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6pt8mO7exEMaeugOAhtM8fjkBrExJ43xRjtiZquPT6ke/Iv6Xsw31a7SJ87cpintHnCUAd X-Received: by 2002:a05:6402:2789:b0:451:a578:74dd with SMTP id b9-20020a056402278900b00451a57874ddmr26365050ede.72.1664940323419; Tue, 04 Oct 2022 20:25:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664940323; cv=none; d=google.com; s=arc-20160816; b=GHWExDS3A5gq7VNqY1yPaCyhdrXgJWdRktTZ36TMJtq53EGTzfl/kmi2AILSi2/E8D G75Ky30q6pfnhoH5dT/BS+fp7KAx3WDlE6vGAcsULsqNC3FquAbyKGTgTdBgVq1lQxJG PH0CGdpdQojbl8X8DpyOzJUmMDuaCTEfGtaEDvCsgh7ZCC4ZwRyObq/9l7q8+lfqzb08 507kh3HekAsRBlWJ3+w4hxXL3Hi+9vtdQ5anOrTvhoWAGA0cweWo/kDHYbrSJMqu48uu 6Q9FrDz07DsESB7H4BGRH1FbkzzOfa2l1doo7GtIQgrJgjcX/R3hJKSR7od0/WxRjPQr 0V+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=q/zGlhb/6/D5Xkd4KCi7Y207Q24GuRcEqCbd/ccpKzo=; b=IjWdLe3e6uT6ZkL7dlmVN+sTEJ0Cu7ppQ9yG7eXGlzPbONBV+NVmQer2DxhN7bJy8o RWkw06Sm4CItRjE5et/t9BDSNgrtO7Ps7IBW9NKxFGFQkAVB1JS8haoDkayKru3oC/Mf Jzyc0br2m9sZfDil4uNCnD10myrFhiEdkVwCG9YWJu55qY/L/az7HLbRysIsMUjPHUXV CB2mNvmbbItgzH7GMa2kiBY3OKeB6GN9nDAm62XiSv18gojZ2OCUr58FmuENixldHVlu 6Bef976gnv5Iz/5UHjo4A7gn20l1ltkyECVoMCcLOfjd1dPileKJJbZ/WckyaJ7bkeXt gNRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=SKokA0th; 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=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id he30-20020a1709073d9e00b0077fc66b581esi13478245ejc.688.2022.10.04.20.24.58; Tue, 04 Oct 2022 20:25:23 -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=@chromium.org header.s=google header.b=SKokA0th; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229453AbiJEDGq (ORCPT + 99 others); Tue, 4 Oct 2022 23:06:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229516AbiJEDGo (ORCPT ); Tue, 4 Oct 2022 23:06:44 -0400 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E45D67169 for ; Tue, 4 Oct 2022 20:06:43 -0700 (PDT) Received: by mail-pl1-x62f.google.com with SMTP id l1so1490035pld.13 for ; Tue, 04 Oct 2022 20:06:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date; bh=q/zGlhb/6/D5Xkd4KCi7Y207Q24GuRcEqCbd/ccpKzo=; b=SKokA0th/dXHfDQS3nsb8z2Z2ppZDeuiQhw1p/wBd32fJemgyvsCAt3bgQrTsKKYqm sYvv8mev2CZGsmAPDpcwakRg7aVXj6WJcATx3M0Pj3y6yLACKmqpQ+31/GaGC+CA9SiP PihlLDYUcY3R+DZFe1vMFUA4jUZdXlBR6vW5w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date; bh=q/zGlhb/6/D5Xkd4KCi7Y207Q24GuRcEqCbd/ccpKzo=; b=Pz88B3eVB64jJRVvxOD2K4t7TtNOiUrQJLS1EYPN/TWNY4srvr++Ke3bznrEXuAdsK 9cD/c5pGi5YTXNykyuOL1z/0cZuro/LanQlrjsVmHS2bOWVzKS2q7VFv11lDQMOl6bKU /5qt0wmAd8fOWQIuzqZf08bVsC5gFMA2jYqr7q1KHL99UDcw2/wqDlJ7NI76p0V6f4TB Sycfl8GfWZnItaU9kqPRwifUKY5JavWVAawEXnKotSLyNyCwh+ZizkIH6N7hHGq5GOwL I8xfLgCVn+lw8X5sMdFwqD8vHrU6jFzIR0ozodUUHAuBJKTV4/2Bko//4yeBLrw5gs16 lIKw== X-Gm-Message-State: ACrzQf3O1EV/fUyjfPf/Afb7SujYJbfoUDyw0wRxgACrRV9UDKFBMHuz KV8GjyI+ZRjfgA3c4tnt+1hrsg== X-Received: by 2002:a17:902:e946:b0:179:d084:bbe1 with SMTP id b6-20020a170902e94600b00179d084bbe1mr30088816pll.97.1664939202905; Tue, 04 Oct 2022 20:06:42 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id n18-20020a170902e55200b0017ca9f4d22fsm8991473plf.209.2022.10.04.20.06.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Oct 2022 20:06:42 -0700 (PDT) Date: Tue, 4 Oct 2022 20:06:41 -0700 From: Kees Cook To: "Gustavo A. R. Silva" Cc: Steve French , Paulo Alcantara , Ronnie Sahlberg , Shyam Prasad N , Tom Talpey , linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH][next] cifs: Replace a couple of one-element arrays with flexible-array members Message-ID: <202210042006.9A12D208@keescook> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 On Tue, Oct 04, 2022 at 08:51:39PM -0500, Gustavo A. R. Silva wrote: > One-element arrays are deprecated, and we are replacing them with flexible > array members instead. So, replace one-element arrays with flexible-array > member in structs negotiate_req and extended_response, and refactor the > rest of the code, accordingly. > > Also, make use of the DECLARE_FLEX_ARRAY() helper to declare flexible > array member EncryptionKey in union u. This new helper allows for > flexible-array members in unions. > > Change pointer notation to proper array notation in a call to memcpy() > where flexible-array member DialectsArray is being used as destination > argument. > > Important to mention is 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://github.com/KSPP/linux/issues/229 > Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101836 [1] > Signed-off-by: Gustavo A. R. Silva Looks good to me; thanks! Reviewed-by: Kees Cook -- Kees Cook