Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp779439pxb; Wed, 18 Aug 2021 14:06:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx2em80oed49gKBWSga7UG33vL4ANhX4/y/Hn13R14nGjJ9/gg4l4FkTWoLaxeV2eoushZt X-Received: by 2002:a05:6e02:f91:: with SMTP id v17mr2598162ilo.0.1629320771177; Wed, 18 Aug 2021 14:06:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629320771; cv=none; d=google.com; s=arc-20160816; b=jnbE/X9CoMZSIVrU1waJVeuNhpIRxczzOJ2dbigmLAeboqQKjPy6D/BY0v1hn+MC4V bdfifiun33F8n6D4t+ckNixbiIFk/Fq8ntNN0XpnfbHBMCauQ33eoInKO2kXvrovf2PT 5IIUrAU280PUos7jwAcxN/WJ8GkGU17gLmrxYMxkNRyliMcXCzf+Rx7sbT8t+Wp7nqDR d0pjbfYKxSVzKRlQ+Jc9R38pQA0R6P/xvVQ8h3RSAstLwdM0v4oWNhFlsoviK3LhK9lN yuHJt4yIXpId0tDZ5TRFSgtD9OkYKGC/a73GC8BmwNk6YQ2cLOb1NU3NqgYsku0Gep9z zsZA== 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=IABWnr1aCDsDwxBBopzlg3HkRiMd7COJyG2pUzXE8/s=; b=NfLaQ+5TyMqgWIQVtx7hhebKGssQujMicQ692ARaAizMhJYNN+aRGFK6/mqZ+2uwiW vI3/ojSn8/MTSQ8EpDlMT5oRXU0LTUCUsAJVv0NsmaDaeI4N76rDD9WeOL9JKrRy+EvE J1HIVtaSfTaWSZ/s+tPH42BeQ1ITAFAnc3iUk2XCya+MtFsqa8AmENUWuqmlsCR4agSC zLi46rDC9SZuiUPxkD24unYQrUVoaVqsn8cWR9vT8WJVePkI6GoVLFXscSzuFRQTCnjr BDW64+7gIxvGcIGvOWKxbMIovwFcPBhvvXdgWq5B4bSbsHc34lEj89M3Vp22xUiyB7A/ KMWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Zqem0CoZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t7si985455ilf.11.2021.08.18.14.05.58; Wed, 18 Aug 2021 14:06:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Zqem0CoZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S233753AbhHRVFK (ORCPT + 99 others); Wed, 18 Aug 2021 17:05:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233378AbhHRVFK (ORCPT ); Wed, 18 Aug 2021 17:05:10 -0400 Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2B2EC061764 for ; Wed, 18 Aug 2021 14:04:34 -0700 (PDT) Received: by mail-pg1-x52f.google.com with SMTP id q2so3623764pgt.6 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=EFyGScLr31jrfESONm2F4upFwBlODH2JBgYguQ8t/9k2zlTdhFc2eq+Wl5NsV2/hMI r5ae+GlfReZBOB+4ALkqSHcwo7elIy6tcAdTBL8ht63V6RRwitrmoZmb7vNTUWprQd7S uM2VY/3S19wm8WoRY8rYbgmj0x/L0Vr6RHbBRBy2Z4DK41u8aVkXlh7E8hrrgUR6DfYZ EwjsGMVPxTdJ18Of8XFOwwQ1LNFe+ZTV74UhditOYDsj+5X72LOYhzbsUp1OOKA6u8xd WunAeBEf5vA+A1ZKpBH5gD82LRnY/rrvlt00ABXsNqMjN5z4/rAlyNwCuhy6zZ0lQuzY lA+w== X-Gm-Message-State: AOAM530UBKt28cZnBkYrv9aEtAhKcCR1iiDDu1mK1oAOQ0DoQGp4129R uxvkV+NnCUmLRW+zJcKu9StuYg== 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-kernel@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