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 X-Spam-Level: X-Spam-Status: No, score=-6.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 64FCBC432BE for ; Wed, 18 Aug 2021 21:04:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3D554610E7 for ; Wed, 18 Aug 2021 21:04:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233915AbhHRVFK (ORCPT ); Wed, 18 Aug 2021 17:05:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233753AbhHRVFK (ORCPT ); Wed, 18 Aug 2021 17:05:10 -0400 Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC0E5C0613D9 for ; Wed, 18 Aug 2021 14:04:34 -0700 (PDT) Received: by mail-pg1-x52c.google.com with SMTP id n18so3630340pgm.12 for ; Wed, 18 Aug 2021 14:04:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=IABWnr1aCDsDwxBBopzlg3HkRiMd7COJyG2pUzXE8/s=; b=Zqem0CoZzHLfKbevjQtLba+oPmNjxfqaUhbg758CCWbVL3Wrgsd0LChYumYDgT8nHV qXI38/TU57+DVyPDVWoD9EBR93b3G6c4a+oZmh44MnpRWPQD3Y87jvx77ewvhtyv0Y9m 2cY4BXqC4SNIlGg0H/SqUG3+Xxrnmj9F9H2ss= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=IABWnr1aCDsDwxBBopzlg3HkRiMd7COJyG2pUzXE8/s=; b=gg3SQ/37hmCypitwjh4wbeorH6d5I0Q5FtjMgHgiqolYSfx+3X2BK9vuwdHJgrYvGZ 3MSeL0HMEZz/+GGr5Q4OMQbQi4fpxdaxZPfu4lJMN06GRx46TB4gmDB+/cpu4PExq4/d qW6FiVZMgBlje4x9+e8lsq9c1KaQbznM30t3z7nUWFrKnyMPr7cTGcwh4Ud0mA5uYBoB 5QnDvkyIAyqJ8oPpEJx/5+Q5SUu2Ngufp6K3Qk21pqcfnKpvmCE5gzi0kGUAzFpYzMeJ Z7rEJ0a+8UUeWdzid+a8F/S3RFHNm7Kc7h4kr5baGK2PmbqgK1g0XKlatS07emDSbILJ WLNQ== X-Gm-Message-State: AOAM533PjfLAEOw2+mcKHQ1efBLXf1Ix9Jqx6Ep1f7csvFJG1Rswtbro HifhmDPSWScasPWbO50f8S6qVA== X-Google-Smtp-Source: ABdhPJzPYdmt1qIf1rGmc2u4in8hFFk0iRvjXLJ/SLffXJm1J8kmYOU3/WVPFV9cKWaMBooTd5z2+Q== X-Received: by 2002:a63:f656:: with SMTP id u22mr10801321pgj.392.1629320674444; Wed, 18 Aug 2021 14:04:34 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id f5sm687890pjo.23.2021.08.18.14.04.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Aug 2021 14:04:33 -0700 (PDT) Date: Wed, 18 Aug 2021 14:04:31 -0700 From: Kees Cook To: Nathan Chancellor Cc: linux-kernel@vger.kernel.org, Miguel Ojeda , Nick Desaulniers , clang-built-linux@googlegroups.com, Andrew Morton , Daniel Micay , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Vlastimil Babka , Dennis Zhou , Tejun Heo , Masahiro Yamada , Michal Marek , linux-mm@kvack.org, linux-kbuild@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH 1/5] Compiler Attributes: Add __alloc_size() for better bounds checking Message-ID: <202108181404.B5E8739C3C@keescook> References: <20210818050841.2226600-1-keescook@chromium.org> <20210818050841.2226600-2-keescook@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-hardening@vger.kernel.org On Wed, Aug 18, 2021 at 11:04:32AM -0700, Nathan Chancellor wrote: > On 8/17/2021 10:08 PM, Kees Cook wrote: > > GCC and Clang can use the alloc_size attribute to better inform the > > results of __builtin_object_size() (for compile-time constant values). > > Clang can additionally use alloc_size to informt the results of > > __builtin_dynamic_object_size() (for run-time values). > > > > Additionally disables -Wno-alloc-size-larger-than since the allocators > > already reject SIZE_MAX, and the compile-time warnings aren't helpful. > > In addition to what Miguel said, it might be helpful to mention that this > warning is GCC specific, I was a little confused at first as to why it was > just being added in the GCC only block :) Yes, good point. I'll call it out in particular. > Otherwise, the attribute addition looks good to me. I will add my tag on v2. Thanks! -- Kees Cook