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=-3.9 required=3.0 tests=BAYES_00,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 737A1C43463 for ; Fri, 18 Sep 2020 19:38:13 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id F367323119 for ; Fri, 18 Sep 2020 19:38:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="MBCZU3Ou" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F367323119 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 57BFC8E0007; Fri, 18 Sep 2020 15:38:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 52CF78E0001; Fri, 18 Sep 2020 15:38:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3F5938E0007; Fri, 18 Sep 2020 15:38:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0139.hostedemail.com [216.40.44.139]) by kanga.kvack.org (Postfix) with ESMTP id 268228E0001 for ; Fri, 18 Sep 2020 15:38:12 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id DDD4A1F06 for ; Fri, 18 Sep 2020 19:38:11 +0000 (UTC) X-FDA: 77277193182.18.knot98_33051462712d Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin18.hostedemail.com (Postfix) with ESMTP id AF53010102BF7 for ; Fri, 18 Sep 2020 19:38:11 +0000 (UTC) X-HE-Tag: knot98_33051462712d X-Filterd-Recvd-Size: 5060 Received: from mail-lf1-f68.google.com (mail-lf1-f68.google.com [209.85.167.68]) by imf04.hostedemail.com (Postfix) with ESMTP for ; Fri, 18 Sep 2020 19:38:11 +0000 (UTC) Received: by mail-lf1-f68.google.com with SMTP id w11so7370503lfn.2 for ; Fri, 18 Sep 2020 12:38:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=LTYP9lzdMuEsLcEEbP3eG/Aqwvw5Aw1MDKs1S/KOj/E=; b=MBCZU3OumBM4Z82fuom8BcZty7G0Qz/ve7guNBZ43fQiGkU3tQxZTbLR7fpibI0fN4 Jzjl9OrRWaGrUL3pYQAoUPU810Wc72CuBIrtDSHOy9AhNIgCvMUyQZNjtQtuSLr8IBAR 0k6Xs/6k0pswS8TAgjPDJVo/r17WtkHexsKb8= 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=LTYP9lzdMuEsLcEEbP3eG/Aqwvw5Aw1MDKs1S/KOj/E=; b=t5tOy+Fk2+M8QVUZAAuF0nK7wLsiPvYLlGrWiMM/HQtyKTQN74p1kDmickE2Nmq8Rr xfIpTdLcNZ9VzZ1y2D4tCt1gPJh22diG2A1+VG35cLVdjyqnNI8XD6KxwuEK+gxlHnA7 +intuyG7FFQUyF/IIZa/NsDyJty52oBVW4kSmBbfu+Vty2ua1L6UgNYEIvBZanLCtqTS zjobND40RInjfUCezMJwyaiT3L0sXkSBHKiPsHMhTPkVecqZkaSSNTRwtJHQw1BtI4eP u7Amr5pqUwUGq93YyVWT7dFVadVGVWJiov9aHzq0vqzOZPqUPpzjIeFmDISQGpgjpGHM XgbA== X-Gm-Message-State: AOAM531V4ooOxM2hK5noGQzQ6UA2OJJu3i/JPlKXcQtqMEx7tRw2UQmp c6ZBHbAr5VZfC7nXYQu8WZDPSXmyTlv/lg== X-Google-Smtp-Source: ABdhPJzHNWii0n2eq8uOBiLrFzxG9Rz1OOY7G8c4hZLs8pobawZK7nqNOjm65ryvWoKR5LL0L1RceA== X-Received: by 2002:ac2:4469:: with SMTP id y9mr10658293lfl.72.1600457888961; Fri, 18 Sep 2020 12:38:08 -0700 (PDT) Received: from mail-lj1-f169.google.com (mail-lj1-f169.google.com. [209.85.208.169]) by smtp.gmail.com with ESMTPSA id 5sm774415lfr.289.2020.09.18.12.38.04 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 18 Sep 2020 12:38:05 -0700 (PDT) Received: by mail-lj1-f169.google.com with SMTP id u21so6000559ljl.6 for ; Fri, 18 Sep 2020 12:38:04 -0700 (PDT) X-Received: by 2002:a2e:994a:: with SMTP id r10mr9828886ljj.102.1600457884550; Fri, 18 Sep 2020 12:38:04 -0700 (PDT) MIME-Version: 1.0 References: <20200917204514.GA2880159@google.com> <20200918162305.GB25599@embeddedor> <20200918193426.GA15213@embeddedor> In-Reply-To: <20200918193426.GA15213@embeddedor> From: Linus Torvalds Date: Fri, 18 Sep 2020 12:37:48 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [GIT PULL] percpu fix for v5.9-rc6 To: "Gustavo A. R. Silva" Cc: Dennis Zhou , Tejun Heo , Christoph Lameter , Linux-MM , Linux Kernel Mailing List , Kees Cook Content-Type: text/plain; charset="UTF-8" X-Bogosity: Ham, tests=bogofilter, spamicity=0.000024, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri, Sep 18, 2020 at 12:28 PM Gustavo A. R. Silva wrote: > > OK. It seems that we are talking about two different things here. One thing > is to apply sizeof() to a structure that contains a flexible-array member. > And the other thing is to apply sizeof() to a flexible array. The former > is allowed, the latter is wrong and we already get a build error when that > occurs. The latter I'm not even interested in, it's such a pointless thing to do. > Applying sizeof() to a structure containing a flex-array member is allowed, Yes, and that's wrong and inconsistent, but what else is new about the C standard. It's what allows these kinds of bugs to slip through. I sent Luc a couple of examples in the hope that maybe sparse could do better, but.. > > Is there some gcc option that I didn't find to help find any questionable cases? > > If the questionable case is the application of sizeof() to a flex-array > member or a flex-array member not occuring last in the containing structure, > then yes, GCC already generates a build error for both cases. And that's > what we want, see at the bottom... No. The questionable thing is to do "sizeof(struct-with-flex-array)". The point is, it's returning the same thing as if it was just a zero-sized array, which makes the whole flex array entirely pointless from a type safety standpoint. The *only* thing it protects against is the "must be at the end" case, which is almost entirely pointless and uninteresting. Yeah, we've had that bug too, but that doesn't make it very interesting. Linus