From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 923CCC433F5 for ; Thu, 30 Sep 2021 22:49:06 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2C5FC61882 for ; Thu, 30 Sep 2021 22:49:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2C5FC61882 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id AF5629400E7; Thu, 30 Sep 2021 18:49:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A571A9400E4; Thu, 30 Sep 2021 18:49:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 91E9C9400E7; Thu, 30 Sep 2021 18:49:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0156.hostedemail.com [216.40.44.156]) by kanga.kvack.org (Postfix) with ESMTP id 7BEB49400E4 for ; Thu, 30 Sep 2021 18:49:05 -0400 (EDT) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 3D08B8249980 for ; Thu, 30 Sep 2021 22:49:05 +0000 (UTC) X-FDA: 78645731850.29.B6DDB6F Received: from mail-io1-f50.google.com (mail-io1-f50.google.com [209.85.166.50]) by imf03.hostedemail.com (Postfix) with ESMTP id F347230039A8 for ; Thu, 30 Sep 2021 22:49:04 +0000 (UTC) Received: by mail-io1-f50.google.com with SMTP id z184so9569460iof.5 for ; Thu, 30 Sep 2021 15:49:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=vOtIXIDfSsulhUrItDNQERb0f0g8vwOd+YpN2bOuFew=; b=UsJzLo6YvJ6tSS0UKfdSYQv/O1WCavAUERunvK+OOYqhIEDAS4Z2vFzdKFwqiPmuLh 6vevGTjNkpxP1BrrwxdpDz2QXThg/BpKbo9iEsLpomx0/HYd6wGw4n9/053N62i/+cHf n4LAKuTY+c5axHHMCsyZm//x8uVjd2ME65YOa5+awossXqI0wN2god8xyUEVnDXJ73ZC jS7ANVlJzya6Q4KBbze2jQP3/GRw6jUvGp2vouIqQzmoBozzSRo7M0RWaAeakNd++t0q aMjC0twctVpOeB4ubdeEjbMQKtIcVfwvvyJZwwgeC/I6SDYVC4oUQRqUxBN/itndGpes 6M3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=vOtIXIDfSsulhUrItDNQERb0f0g8vwOd+YpN2bOuFew=; b=GeaGxzwZ85ATi4Hi0rHl4SGgKOdF+65NYZoJagKxjtbf0LmiQ9zGlUSCPclqCyAOmS ztE0FYrolh2+3pOabrUUwW6QaPAfSf94MvCrlJWPasb+3tFtbP7mF5KwvIL/4yDrxF1w KUS7d3XdjDgexTOHxKkdXxietMviWh0GUCIxV6poZpHzCMwVpDUUMyKl+DaMDKFEbaD6 Gqfvg5o2Z31zXpkle8LZ/115A4kdFXJZU3w+tZbAzA/6h4SfGs01alm7P2e45QivCT9C sKsRFHVcPFUp6xbdIGTbL4jB6EgNCSGq74lrJKt4AqevRuERJ+pLUU+WPZ+kH5iRYu4B nVTA== X-Gm-Message-State: AOAM531FaHdCo1DwCdxkKZrNQVh6+IBmKCDMn+Pc6m5f0EYwSaLSz8Zs mdt8N/V9TtwFI/TrWiMTOYd7p1bH/f1Mx+o/QQM= X-Google-Smtp-Source: ABdhPJz/YDrixlOb9rMZRSF4thA+3ftj/kiegqmIwGTDbMhl4uZQjKdWFZPuzBzbjuKnzp2MGOcTIH4Lk3dZrekpXZ8= X-Received: by 2002:a02:a60a:: with SMTP id c10mr7053135jam.131.1633042144130; Thu, 30 Sep 2021 15:49:04 -0700 (PDT) MIME-Version: 1.0 References: <20210930222704.2631604-1-keescook@chromium.org> <20210930222704.2631604-3-keescook@chromium.org> In-Reply-To: <20210930222704.2631604-3-keescook@chromium.org> From: Miguel Ojeda Date: Fri, 1 Oct 2021 00:48:53 +0200 Message-ID: Subject: Re: [PATCH v3 2/8] Compiler Attributes: add __alloc_size() for better bounds checking To: Kees Cook Cc: Andrew Morton , Randy Dunlap , Andy Whitcroft , Christoph Lameter , Daniel Micay , David Rientjes , Dennis Zhou , Dwaipayan Ray , Joe Perches , Joonsoo Kim , Lukas Bulwahn , Pekka Enberg , Tejun Heo , Vlastimil Babka , Miguel Ojeda , Nathan Chancellor , Nick Desaulniers , Masahiro Yamada , Michal Marek , clang-built-linux , Linux-MM , linux-kernel , Linux Kbuild mailing list , linux-hardening@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: F347230039A8 X-Stat-Signature: d37g9tqqfkk9e8nhr7tnww6i98n8difg Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=UsJzLo6Y; spf=pass (imf03.hostedemail.com: domain of miguel.ojeda.sandonis@gmail.com designates 209.85.166.50 as permitted sender) smtp.mailfrom=miguel.ojeda.sandonis@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam06 X-HE-Tag: 1633042144-127071 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000114, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri, Oct 1, 2021 at 12:27 AM Kees Cook wrote: > > +ifdef CONFIG_CC_IS_GCC > +# The allocators already balk at large sizes, so silence the compiler > +# warnings for bounds checks involving those possible values. While > +# -Wno-alloc-size-larger-than would normally be used here, earlier versions > +# of gcc (<9.1) weirdly don't handle the option correctly when _other_ > +# warnings are produced (?!). Using -Walloc-size-larger-than=SIZE_MAX > +# doesn't work (as it is documented to), silently resolving to "0" prior to > +# version 9.1 (and producing an error more recently). Numeric values larger > +# than PTRDIFF_MAX also don't work prior to version 9.1, which are silently > +# ignored, continuing to default to PTRDIFF_MAX. So, left with no other > +# choice, we must perform a versioned check to disable this warning. > +# https://lore.kernel.org/lkml/20210824115859.187f272f@canb.auug.org.au > +KBUILD_CFLAGS += $(call cc-ifversion, -ge, 0901, -Wno-alloc-size-larger-than) > +endif An amazing journey! Reviewed-by: Miguel Ojeda Cheers, Miguel