Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp99862pxb; Wed, 18 Aug 2021 17:06:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzHcepbco9X1/fZicR/qcaaBzHeLprR3qP4cOMgkotdf6VjWkgTjjKv60CV+OV/MZB3vnEh X-Received: by 2002:a05:6402:34c7:: with SMTP id w7mr13700936edc.175.1629331614678; Wed, 18 Aug 2021 17:06:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629331614; cv=none; d=google.com; s=arc-20160816; b=gJdZMIQaCQ6pIRuA1ntSS9tl0Utl0HB7Frf+bOrY7fGrvb3CKTvCPTphwarMslQbHF RklZs9PCwgBRbNjok5gGJ66QTBo2wt+RO8S2SenHhVaJnnmV3DcjmMVeGasrvPtqtBRw y7jqg1NM9ty+FOkztxeLdQGVFMvkmAXW9N4dAcY2jY64ULk6xPsyzL6H42ngn3pe0U35 DDPy6gw9gi10ITKVzbptJbohmuee74Xrtx9aznznQqpeKO39YUAGbf3g7NFiXTRpVDqL S7T+6zafzAfsiZfPSI1RizJrub2uah1kdcB1US860H9pQ8TfPkVn3pq7zwKj5G0jklTK Z0UA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=w17ydvcuCGlYzYZkPwnAY4ViNmy/ZwOBneYqz+ZoO9o=; b=TcCLDKvfcD7/1o3RPiY5peUeb9OXtRGFFpw466SOKLDZ2WHDsoGtG4jR14UMJafzeN rq74ra9FMaR1tfh/QhqtzdFGzicbD/pRf3NivwJ4DwvnEfsYZMrPdLhn55Cc6tgmsoI7 4SiKFY/74ZtCDg0Tn4s8cuuvujjlFrlUOOeNnan5AR4pKRU+Kb5pZOsi9opxOVbKeWo7 nHxexLLGvBE5LRANdNtRtJ0uNtwNlUwi1P5FtJ3kapD3XBJA85ZFA3bbNfb4LwYcsjyH 11QxTK/BU+AsXTVveWZtpORoo6Ggc+D0wlfcafUbf6na/g/KGQ1chZ7DRGiaNssBRe10 kJYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=UKWjEQsS; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id du15si1403957ejc.498.2021.08.18.17.06.28; Wed, 18 Aug 2021 17:06:54 -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=@gmail.com header.s=20161025 header.b=UKWjEQsS; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234778AbhHSAFe (ORCPT + 99 others); Wed, 18 Aug 2021 20:05:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233866AbhHSAFd (ORCPT ); Wed, 18 Aug 2021 20:05:33 -0400 Received: from mail-il1-x129.google.com (mail-il1-x129.google.com [IPv6:2607:f8b0:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8EDDFC061764; Wed, 18 Aug 2021 17:04:58 -0700 (PDT) Received: by mail-il1-x129.google.com with SMTP id h18so4110286ilc.5; Wed, 18 Aug 2021 17:04:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=w17ydvcuCGlYzYZkPwnAY4ViNmy/ZwOBneYqz+ZoO9o=; b=UKWjEQsSNw2BiJaPXnsaKyIU35+0H7oF+FRz1HAZHped4dWFoAoEswBymXyg9g+ZmR lLgZ584UzUxwkfkBhRxRVwwnaRHGg0jNtB1sY4a1jdAximJXprJ5gdG1sKPVuOFc9vzo Yl+iLuVLguWxYPC+XYuEB4jotG1psQpoebbH4erIe1/gG5+s+RdontydGlEHpJ5sHM8l 0lzF8oduiIWkTD+r1705FS43bUdOiRLER842LY6juo60h/3+4m7wWrfLhDmJMIgKupwh t3V3qeGsGKAKffUp5+ini0NDqGGV4RPbCmQaNPoZ6Gb202C50tNrMk5z7REcCFLmAZNi ppvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=w17ydvcuCGlYzYZkPwnAY4ViNmy/ZwOBneYqz+ZoO9o=; b=WivQBj5aZOcb4mwiDOjVzoHVn1Vr8uwlgf13+Ij93hLyjtZhIzpygR+S1h8xHD3AIq CuY+UnD4IFhhqIlkk+aI6zx8xwuc4IrHRj0acJa+Cphgmk1llkBvHnJLEtKuElE9Ic1c lBGUU77KjCa0K4wtjJjLYQfCPjgD90Zvy+8SUFPosvNsXEUyi//cMzDuN+ejhSJFBls9 IX2pE5FWusPfrQsMhrHGLI52T8ava9NWJn2eVP5K4E+cva1Q2mcf8taPdBeC630Vg3eh CAqve6it0LnpPKdm05q6ms5S/MhvuXgqPzAZhF+ofKRD6dCOA1weZ+pzLka4w0KXiKW6 05BA== X-Gm-Message-State: AOAM533WVLXPJA30gWzbb6Ok9cbwuSnhHaNK7FW70VvNNzd02A8yA17/ ZTqljZgJl30mLoGfCtUnmdHbn16z4XJr1t2XUZc= X-Received: by 2002:a92:da11:: with SMTP id z17mr7915420ilm.176.1629331497973; Wed, 18 Aug 2021 17:04:57 -0700 (PDT) MIME-Version: 1.0 References: <20210818214021.2476230-1-keescook@chromium.org> <20210818214021.2476230-2-keescook@chromium.org> In-Reply-To: <20210818214021.2476230-2-keescook@chromium.org> From: Miguel Ojeda Date: Thu, 19 Aug 2021 02:04:46 +0200 Message-ID: Subject: Re: [PATCH v2 1/7] Compiler Attributes: Add __alloc_size() for better bounds checking To: Kees Cook Cc: linux-kernel , Miguel Ojeda , Nathan Chancellor , Nick Desaulniers , clang-built-linux , Joe Perches , Andy Whitcroft , Dwaipayan Ray , Lukas Bulwahn , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Vlastimil Babka , Daniel Micay , Dennis Zhou , Tejun Heo , Masahiro Yamada , Michal Marek , Linux-MM , Linux Kbuild mailing list , linux-hardening@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 18, 2021 at 11:40 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 inform the results of > __builtin_dynamic_object_size() (for run-time values). > > Because GCC sees the frequent use of struct_size() as an allocator size > argument, and notices it can return SIZE_MAX (the overflow indication), > it complains about these call sites may overflow (since SIZE_MAX is > greater than the default -Walloc-size-larger-than=PTRDIFF_MAX). This > isn't helpful since we already know a SIZE_MAX will be caught at run-time > (this was an intentional design). Instead, just disable this check as > it is both a false positive and redundant. (Clang does not have this > warning option.) Thanks! Reviewed-by: Miguel Ojeda Cheers, Miguel