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=-8.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=ham 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 849F0C43463 for ; Fri, 18 Sep 2020 19:58:11 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 15E2F22211 for ; Fri, 18 Sep 2020 19:58:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="SVFlfThz" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 15E2F22211 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 9E335900004; Fri, 18 Sep 2020 15:58:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 992B98E0001; Fri, 18 Sep 2020 15:58:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8A8D1900004; Fri, 18 Sep 2020 15:58:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0110.hostedemail.com [216.40.44.110]) by kanga.kvack.org (Postfix) with ESMTP id 755C38E0001 for ; Fri, 18 Sep 2020 15:58:10 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 39DF8181AEF21 for ; Fri, 18 Sep 2020 19:58:10 +0000 (UTC) X-FDA: 77277243540.03.beam07_040512d2712d Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin03.hostedemail.com (Postfix) with ESMTP id 1A37628A4E8 for ; Fri, 18 Sep 2020 19:58:10 +0000 (UTC) X-HE-Tag: beam07_040512d2712d X-Filterd-Recvd-Size: 3911 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf23.hostedemail.com (Postfix) with ESMTP for ; Fri, 18 Sep 2020 19:58:09 +0000 (UTC) Received: from embeddedor (187-162-31-110.static.axtel.net [187.162.31.110]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0C18121D42; Fri, 18 Sep 2020 19:58:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600459088; bh=rwunIzOqp6GWQdQipmI6M8Piyl6p7IBW3RuEHyxgW6s=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=SVFlfThzUqvTJ1tMe1VP9QD9P1S405SJAaylRtOEHoYox0XY4c1moEauPhDU2+yo/ koLGWU8VoLc+tg61ccvXJtL7Nc4obfYLLfraHJMQT4b9abE1wSohKu6c///CZ2dEjL hNG9o5seH2MwnzDYaEyVHayT7bjW/XB5zxBYlSXc= Date: Fri, 18 Sep 2020 15:03:45 -0500 From: "Gustavo A. R. Silva" To: Linus Torvalds Cc: Dennis Zhou , Tejun Heo , Christoph Lameter , Linux-MM , Linux Kernel Mailing List , Kees Cook Subject: Re: [GIT PULL] percpu fix for v5.9-rc6 Message-ID: <20200918200344.GB15213@embeddedor> References: <20200917204514.GA2880159@google.com> <20200918162305.GB25599@embeddedor> <20200918193426.GA15213@embeddedor> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) 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 Fri, Sep 18, 2020 at 12:37:48PM -0700, Linus Torvalds wrote: > 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)". I see now... > 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. > But you are missing the point about CONFIG_UBSAN_BOUNDS, which doesn't work with zero-lenght and one-element arrays. And we want to be able to use that configuration. That's the main reason why we are replacing those arrays with a flexible one. I should have made more emphasis on that point in my last response. Thanks -- Gustavo