Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1454858pxk; Fri, 18 Sep 2020 13:00:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzAvrmhS1MrYwiuDtF5zITO+aKUnZDzemkQHGXTr69r/gHilWh8DboU6EwY+IfcOJ7idbpN X-Received: by 2002:a17:906:f1d5:: with SMTP id gx21mr35689457ejb.165.1600459224104; Fri, 18 Sep 2020 13:00:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600459224; cv=none; d=google.com; s=arc-20160816; b=GJUac/fkqC+zEhtB5hUvmVNnwbYb5ky+b249rjSjoK7flnGT+KkatcWV/k/GFpmvJV 0RCUR/VXF9j+taH4manFTLpa3+mBRUVzXqcM+ThPadr79GP7D9m2hyzDuEqDRuqdOwWt MRltMC9hzLIeGrEzjT1gQSM1rDpFL4HTtQHD26bCaGuzVcBrn64oySohQHNiDxyetr0z 1mBScm2f4QEqfSXyu37GhSN74i6PL1C2cwfGhIc4d4Ok4XSqi9nlq65xNkKoE4EIy7X/ 4BRY8CzPLzVocydgGWHykHd+FYHxUQPOnhszZ8FNiuqhPU3auQ+pEQ2/RwDoluTb6fWO DJYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=sVKxtxWfRjGmdiMY8XUqXNQqiYBM79x0FzwGrgJQirc=; b=inY9hMqFra237oaJHEWZrUIWubqvG9CK+J9OZxYFftnhTV/VeknFy+I0Gd7ubm5jZP 6p1D6xBLsyKisVV0FUQnAbPydFSLXEQgrV6NAFdYM9D890Vhdjo/YW2d/go7Emmlee1b 7u5phdzMIuwqAFj4I1bzlyGd2TsWBRS+d2uHzHNlPElCOkUb6cgsMHSuWzaQLyoxmAmT bmCF5JXjrdjldRIVb4UjeI3aNG7hmWvPf/MpDAoUsUx8vU3tomguWZCgkdshq8x1PRrO 7nQF0GjuYaS4GeR9505VYIJdtA+are954rXE8E+ZrQ+g/hpiBX2UGW2jx7iamY4I+xvF JV5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=SVFlfThz; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id rv15si2993473ejb.364.2020.09.18.13.00.00; Fri, 18 Sep 2020 13:00:24 -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=@kernel.org header.s=default header.b=SVFlfThz; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726205AbgIRT6J (ORCPT + 99 others); Fri, 18 Sep 2020 15:58:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:44794 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726118AbgIRT6J (ORCPT ); Fri, 18 Sep 2020 15:58:09 -0400 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) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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