Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1900651rwb; Fri, 23 Sep 2022 22:24:25 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4LbVZ7gOWWoT/N8O9WEqxt25PIA3Hkfqih/Mp7Sts9fZpGXAdcWrKB4pGcLcgxnd9Ag7R6 X-Received: by 2002:a63:cc43:0:b0:43a:2f12:d326 with SMTP id q3-20020a63cc43000000b0043a2f12d326mr10613371pgi.320.1663997065578; Fri, 23 Sep 2022 22:24:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663997065; cv=none; d=google.com; s=arc-20160816; b=jbho08o97pdRgj50YEzqxmQmGBYP6ZufwxrrWNrrKt7RiZlQCGT6msjcu26iUBU2Hm bVZKY2WYjCOfAtrRSm5ZwmoP2kvp/vjmCdF6q47aXVNPY9diwUEoZQRQInlIwW7Cdycm L6E5tjrxAwe5WFXJcoa5rVumCCES/rcwDIDeGy7kojqga7a1gpUHQwWPOsSASqvayfdm RoVaHIeik9koSPl05gjbVhIG277LCVDg/TnC2S/EYhpJ67HNql+EXlhjQO5+fttTViYT y2nj0j6mCX5AfBjUeyLn3JYHdJKFgUsUKJPsBc6ffnGNQUMTxAY4fhr4y139fp6FsiuF f8Jw== 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=JwdiKuWAXIR8s1mqhbb5lF09zKLRfTe1ZSaNoLOpjDI=; b=0g4EqBbzzyH5XjJxNC4fGQe5Z1mXCTIi3kFWrsDQBQQwK7JK2LvMmwC8oaGzTcTjQF bSFQPep1B6QbDk/QUMHiZ2migXr2h2zXqwJMdwhDpybYiR8+xKT0UJvIZGfUr6QrQlE6 tiwwkCY25nvfzW9m2d4lAbg4WNQ00PVAfe3d46GreDKeblf13VnmbvBx6c7VkDjIg5Js nAKY1GrP9lhacW7mpFQF+iL9y4tVzc7zHiLbiQuZzGQGpsAVvLtK6P/eBRjOSYGgqHAZ xWqNqQaT5Gvg9+bmSGdmGx4C430gLGVRq10yyOxXrdcxSXhF5dbM8S2VH6aSypDLSic3 Nwng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=oWoq2NjH; 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 o28-20020a634e5c000000b00438d81d22a3si11986946pgl.112.2022.09.23.22.24.14; Fri, 23 Sep 2022 22:24:25 -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=oWoq2NjH; 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 S233110AbiIXEYN (ORCPT + 99 others); Sat, 24 Sep 2022 00:24:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231379AbiIXEYE (ORCPT ); Sat, 24 Sep 2022 00:24:04 -0400 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 21976155664 for ; Fri, 23 Sep 2022 21:23:12 -0700 (PDT) Received: by mail-pj1-x1030.google.com with SMTP id i15-20020a17090a4b8f00b0020073b4ac27so1945281pjh.3 for ; Fri, 23 Sep 2022 21:23:12 -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=JwdiKuWAXIR8s1mqhbb5lF09zKLRfTe1ZSaNoLOpjDI=; b=oWoq2NjHlI/t3Diujc7ttYvYtrCisBNDQUTDlFoLB8VPZgvUALrsFw/OoDClOBR291 AILumiFzf9WDEmol8HsZRTVubx6ntw1tPkflegrT3lFadCdSgeYJS+l5JmbMIxD+jXDy ndxSnBDjihGj9HljWl6R8G7MMPk8WgA/5phGI= 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=JwdiKuWAXIR8s1mqhbb5lF09zKLRfTe1ZSaNoLOpjDI=; b=5V3ovDgviYxlKjXhxVR0Ucutn5pLxi43JNNWQjMDWTn7EoVWFv2b8Tp3WC+srEKeOo pGqzw8QGv4/i10irEhynstEXjbku7spMRIq9JC50P7bdhlZEMQaOOkSK4ZRuzIBtt3zc IXjca8CDwXFqS35BBw9B8ZJiKs45xDX1504iAyZt0mhvygUxZE2pWKXF9ZgGdxppOx59 /GwQCgqoh0e8CzeaDJzG3nhkFTE9nykTRDab2C9ughV9aIKcZGM8voGYZGzajU43I+ju F9b26/mg787OI0FjDCnA4tCoVUK9nW7mTEOuBUNmLoFWwGeZb1ziZYtGqdQJnXMSDoc3 q82w== X-Gm-Message-State: ACrzQf1rAzv6RHbdWUxNYm0XxVzDs3ZKVLU7Xu7MrgNSB3QoWqRAne8u KZPbR+J6mnX2YKN7BK7CsCzpSQ== X-Received: by 2002:a17:902:bb88:b0:178:24f6:4dfc with SMTP id m8-20020a170902bb8800b0017824f64dfcmr11526773pls.169.1663993377361; Fri, 23 Sep 2022 21:22:57 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id q19-20020aa79833000000b00540c3b6f32fsm7227822pfl.49.2022.09.23.21.22.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Sep 2022 21:22:56 -0700 (PDT) Date: Fri, 23 Sep 2022 21:22:55 -0700 From: Kees Cook To: "K. Y. Srinivasan" Cc: "Gustavo A. R. Silva" , Haiyang Zhang , Stephen Hemminger , Wei Liu , Dexuan Cui , linux-hyperv@vger.kernel.org, Nathan Chancellor , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH] Drivers: hv: vmbus: Split memcpy of flex-array Message-ID: <202209232119.E32C14857@keescook> References: <20220924030741.3345349-1-keescook@chromium.org> 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 Fri, Sep 23, 2022 at 10:42:38PM -0500, Gustavo A. R. Silva wrote: > On Fri, Sep 23, 2022 at 08:07:41PM -0700, Kees Cook wrote: > > To work around a misbehavior of the compiler's ability to see into > > composite flexible array structs (as detailed in the coming memcpy() > > hardening series[1]), split the memcpy() of the header and the payload > > so no false positive run-time overflow warning will be generated. As it > > turns out, this appears to actually reduce the text size: Er, actually, I can't read/math. ;) It _does_ grow the text size. (That's 2_3_ not 22 at the start of the text size...) On examination, it appears to unroll the already inlined memcpy further. > > > > $ size drivers/hv/vmbus_drv.o.before drivers/hv/vmbus_drv.o > > text data bss dec hex filename > > 22968 5239 232 28439 6f17 drivers/hv/vmbus_drv.o.before > > 23032 5239 232 28503 6f57 drivers/hv/vmbus_drv.o ^ -Kees -- Kees Cook