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=-7.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 A87A7C4320E for ; Thu, 19 Aug 2021 00:05:00 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 34607610CE for ; Thu, 19 Aug 2021 00:05:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 34607610CE 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 8B29E6B006C; Wed, 18 Aug 2021 20:04:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 83BE66B0071; Wed, 18 Aug 2021 20:04:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6DCFA8D0001; Wed, 18 Aug 2021 20:04:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0078.hostedemail.com [216.40.44.78]) by kanga.kvack.org (Postfix) with ESMTP id 512336B006C for ; Wed, 18 Aug 2021 20:04:59 -0400 (EDT) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 03C1E1B3E7 for ; Thu, 19 Aug 2021 00:04:59 +0000 (UTC) X-FDA: 78489884718.11.5D034E0 Received: from mail-il1-f169.google.com (mail-il1-f169.google.com [209.85.166.169]) by imf18.hostedemail.com (Postfix) with ESMTP id C03474009809 for ; Thu, 19 Aug 2021 00:04:58 +0000 (UTC) Received: by mail-il1-f169.google.com with SMTP id v16so4091229ilo.10 for ; 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=gOc2vmrKgxdPQ9DmxNJrNZDbbSMybqTsVtXL8RBphF8/KN3clcX6QruRxAzl8YCsbX xdoCY/g7um9MsNcSUr3nz/J7iIM6yPDXoiLLf9SgZxm280ObkP7a58rZIPBUfZjviYHv YSxmo9KWE0etajZUVfeZNQS1mDcuTw2HMyRPgH/Zle2jQYZpKZkQItPW5Z5uQ2b4YZzS TMe70z8ul5/kIM1CS/AOB2Bu2xeZ2avM3W4gTVmkIjT4yXRkRFsLAxznJxM6Ug0Bw5uP 8OQhGZzfkLEeYgYsuQCkzVLrUQSQ9N1zVNqERPpPhpf0rN8AP2goe1Ftfa421OGJPRiy qFFQ== X-Gm-Message-State: AOAM530/9FlWHccCqTieDoJG/bhpCtIoqqJSU5E1GkpcqFQjcQRIAJb7 PQ9Xs+5Ylz46TfJZM2HwYOn16le2vJUcrG3G3n8= X-Google-Smtp-Source: ABdhPJzs981tvNw4QbYs/FWQ28bLGWZcK6FUriao+c1cHCcwbhXdwJhHYjp/IVOkFYOsK9nqcg2y/T/TO2k+bBkQhTM= 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" Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=UKWjEQsS; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf18.hostedemail.com: domain of miguelojedasandonis@gmail.com designates 209.85.166.169 as permitted sender) smtp.mailfrom=miguelojedasandonis@gmail.com X-Stat-Signature: 5o19dd8owa4xfsrjb9fjk3cddac1wyqy X-Rspamd-Queue-Id: C03474009809 X-Rspamd-Server: rspam01 X-HE-Tag: 1629331498-927546 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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