Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1445523pxk; Fri, 18 Sep 2020 12:41:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw5Ojl4BWB+vXUlmCk1bgwxdFs8hi88kiYFePt1RFkYKyYdjE2+whCXJXF/CWkEkde/pGQ+ X-Received: by 2002:a17:906:9443:: with SMTP id z3mr39478614ejx.156.1600458105202; Fri, 18 Sep 2020 12:41:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600458105; cv=none; d=google.com; s=arc-20160816; b=s6rLBpIF+P87zreZ62+Xa9qslF9Q+o2s51eN/i85m0312TfxdPNxh1mQ9u/Wqt0gJo VrN950XsQcSBNB+G/dF0iboBsrOufuJ7SdJr8U1EDEf5AquO3t0qYXmeZ2Fd5PZ/7qnQ Bt2S4S1DNzcPnVDuv744cM5FU6Ogf8qmP0xAfpLvXURZlAu2T2jVdqZs8SDavjogV5dR EZ8WLZYe0jAEE0kRksiT+5kpvliJPSMO4DswWyf8pa//YCnL+psZrtEz+WxGJatD9grL T6hTrRzCOVIB7QR2aPzPMumfzlW9sV0bzmzi6BxcnKEqX/+q+vCVvzDxMxmwxjTyldDc YF5w== 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=LTYP9lzdMuEsLcEEbP3eG/Aqwvw5Aw1MDKs1S/KOj/E=; b=kWSXSyifu8zsGLb4it/3kj3laSSCB4CHPOCwbChn11BX46ARsf5q8mcSVVPusXbMik epupYOBJIUwEaLl+3uoEkpXMojzrF6aOb1sAbkL5u3y8O5r7crgpCoy4NlL8NjT+sRqn XJ2/qKugcfBrYJjLuBpzDZ94OWpCcJRQVienpaTPfPCZC5Q027eVqXhSghkl1em1znlD /lipvqFY/sGucr71WeeFrdZaZkddq0tULY5I4VkTEu9gj7Ad7/5//ngrlATC764Ku1JZ e3/83nuKjHwalCvn2Tx8TO/HPL9O/JohZstVsE2YZ+dbmz42cwxHq5WV7spQb/N2KIsd PLUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=MBCZU3Ou; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lr3si554102ejb.358.2020.09.18.12.41.21; Fri, 18 Sep 2020 12:41:45 -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=@linux-foundation.org header.s=google header.b=MBCZU3Ou; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726157AbgIRTiM (ORCPT + 99 others); Fri, 18 Sep 2020 15:38:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726115AbgIRTiL (ORCPT ); Fri, 18 Sep 2020 15:38:11 -0400 Received: from mail-lj1-x242.google.com (mail-lj1-x242.google.com [IPv6:2a00:1450:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3265FC0613CE for ; Fri, 18 Sep 2020 12:38:11 -0700 (PDT) Received: by mail-lj1-x242.google.com with SMTP id n25so6018833ljj.4 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=MPYttiZBXQMcPqU7L7oli6Zs2/REH/3Mp1j6ZCiYrFTiuVS2tkAiQlzbZUNCmjfRas RqMbwQDFbHN+qnpaLtDZIBr8FGBuXX6GKfYQHYUdzto7xJzeys+AlRO/5aCuewZjl4Vc Ch7URzyjVFZPh57BvVgq8+P23+jcV28Wwlb9QMCvny8CGSKAN9b4kQGJYeudLRTLbBBR dqb+X+EQ1PQhUZalVmZ7td63Z4uC6aKI8HfWdJTc1mt15e4RPPtSrPjj1HRyiN6YMC9d EynSuwmvcdxMG9Zgb/nSMuN2uFnC0SzVlXjdKkDyCOD2Wo1nAw2Ja50aXfhGxF2+iyk1 4c4A== X-Gm-Message-State: AOAM531/WsnhJKYZ6oHdc5Il7EP7UGcFA81F3t0cEshFOsbS7a3ePu40 QbwPKU17oHY2lRXWNcU0F4KUq/Nf8zNfww== X-Received: by 2002:a2e:9bc2:: with SMTP id w2mr11224362ljj.236.1600457889079; Fri, 18 Sep 2020 12:38:09 -0700 (PDT) Received: from mail-lj1-f181.google.com (mail-lj1-f181.google.com. [209.85.208.181]) by smtp.gmail.com with ESMTPSA id d6sm774125lfb.177.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-f181.google.com with SMTP id n25so6018672ljj.4 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" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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