Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp2161154rwb; Sat, 24 Sep 2022 04:09:10 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4f9fzzl9dQQwnkWnVz9gHnMhhVhyWSOTRrcslD1qSZL+Woosi9B+l8oAJtY/JX/Ryw8ZsK X-Received: by 2002:a65:4bc1:0:b0:439:e6a5:122a with SMTP id p1-20020a654bc1000000b00439e6a5122amr11364406pgr.443.1664017750149; Sat, 24 Sep 2022 04:09:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664017750; cv=none; d=google.com; s=arc-20160816; b=NbOznSkTqtXbJ19XjKoA9XIgJxIQQ/KtW+iw6oL4QoPcFykVhnRFF7hu0D3bmZH0TX TZmghMK7uLF2Eu2ORzZznksiAm1iCqUEj16kZ2Fd7PT9pG8PODRlZaAt9WuA8TeKheo6 4N14BNNb5cUg1/ulw8wimaoth/lnERmoWGJ48zg/1emTRYwqqFfeh29+5jIDQYvPONds tTejnmBcwCAMGZDIsf+OEnNg/sXJ5VOsRZjZXRTGzORHdlm/SPp0OghasiPrM9+NYaHA fq1VkWwh0+jQtSsyy3HuA+TU9yUs/u6XFzSargXZ+6EgPP6kUpbTIdf1gM7tQYLk1QBp NQVQ== 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; bh=lWWSF5r7ARtTOClsK9sXEb7aJbRhNSyG93pnZwDgR5I=; b=aq+QsArOpfB2nFaSStqkk6spH7U+GcqESyY2vGoHYeDyA2UqzWY6IsQp3TB53UkPic 1z5aV4P9J/iYOcs+ZgI+5FcGd4F+fIQl23cEGhrYZXFzly3oLr4LJjvUXIVIyjn3/Y+N p1rgIICqrrQ3+yG6cu4Br9OesDIQ8BNJK5RAO+wt4ZBrKSF7wUGDf7UPk+FFZtOJ5Im9 QARU4dZ/0eAUuRfXjxeX4PcjdfToUeGX84jOms0XjBn5RZVXpHBuIC31alfdI11Xv7iG XwYOcsIg0bCSt3YYV1kbWdkz+57sci58Qa7OGvYYbyT/fxgPKusCMapYGQttPeTeIgW/ 6O7Q== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p10-20020a170902e74a00b0016bf245fbe1si7057146plf.296.2022.09.24.04.08.58; Sat, 24 Sep 2022 04:09:10 -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; 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 S229712AbiIXKeX (ORCPT + 99 others); Sat, 24 Sep 2022 06:34:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229447AbiIXKeW (ORCPT ); Sat, 24 Sep 2022 06:34:22 -0400 Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9E24128A31; Sat, 24 Sep 2022 03:34:16 -0700 (PDT) Received: by mail-wr1-f42.google.com with SMTP id cc5so3439433wrb.6; Sat, 24 Sep 2022 03:34:16 -0700 (PDT) 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=lWWSF5r7ARtTOClsK9sXEb7aJbRhNSyG93pnZwDgR5I=; b=KSyEDPTrERDbPHgI3yKjQwFOuoePdyYavdVYJm/tY+ThFTOwq8HOCNLpP89t/EYIBK tavLNvSlBhj9s5L4jrDB85fgqtLdE4Fstx/MZZIw4niSkjG7OKFraYC5KBarHHydAwcr 2apbgZDmNREUwKQ++sYU8ZyWG43oTIZ+D/z7NRvSdfu8rFV0wJrrlgsIXnS2UofV+DnK +MbLVv5WMRkB/JOpRBhdwmnD4CVcq1cr7yBnxFTt9gvzkboFsCKTO8nG5L5CIssPLK49 69U/B0Ke03Fdu33v0nZ56wlueeMJBdW6K/7zDIF0sutm2scnrGqu7lXViebI+8omHlv8 GWkQ== X-Gm-Message-State: ACrzQf0vxyCPkvz0qVKMuduANVNNgK7qLH/9Tk+YpbVGfruvdMbD7WYk xmQ2hFg0lF+oyGtl1/mcWhDEniv2rRI= X-Received: by 2002:a05:6000:912:b0:229:9bc1:27ed with SMTP id bz18-20020a056000091200b002299bc127edmr7554875wrb.546.1664015655105; Sat, 24 Sep 2022 03:34:15 -0700 (PDT) Received: from liuwe-devbox-debian-v2 ([51.145.34.42]) by smtp.gmail.com with ESMTPSA id o3-20020a05600c4fc300b003a5ca627333sm4961389wmq.8.2022.09.24.03.34.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Sep 2022 03:34:14 -0700 (PDT) Date: Sat, 24 Sep 2022 10:34:12 +0000 From: Wei Liu To: Kees Cook Cc: "K. Y. Srinivasan" , "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: References: <20220924030741.3345349-1-keescook@chromium.org> <202209232119.E32C14857@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202209232119.E32C14857@keescook> X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no 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 Hi Kees On Fri, Sep 23, 2022 at 09:22:55PM -0700, Kees Cook wrote: > 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. Can you provide an updated commit message? No need to resend. Thanks, Wei. > > > > > > > $ 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