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.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 629C1C43463 for ; Fri, 18 Sep 2020 20:03:06 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A032022208 for ; Fri, 18 Sep 2020 20:03:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="JWTlVyai" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A032022208 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 14AF8900005; Fri, 18 Sep 2020 16:03:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0FC018E0001; Fri, 18 Sep 2020 16:03:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F2B89900005; Fri, 18 Sep 2020 16:03:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0080.hostedemail.com [216.40.44.80]) by kanga.kvack.org (Postfix) with ESMTP id D3DDA8E0001 for ; Fri, 18 Sep 2020 16:03:04 -0400 (EDT) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 93B46181AEF21 for ; Fri, 18 Sep 2020 20:03:04 +0000 (UTC) X-FDA: 77277255888.13.quiet72_41137702712d Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin13.hostedemail.com (Postfix) with ESMTP id 24A7418140B75 for ; Fri, 18 Sep 2020 20:03:04 +0000 (UTC) X-HE-Tag: quiet72_41137702712d X-Filterd-Recvd-Size: 3034 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf13.hostedemail.com (Postfix) with ESMTP for ; Fri, 18 Sep 2020 20:03:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=xGwao8W6Uh+2rz99Rk5ZogOss14+f87cMDqltiuFbyA=; b=JWTlVyai9cSyuWGzgCK8U0WxG7 YewTIiBUM+pKgO7t0SZ8C2yxUmESMFGW7ofkYIjBweRXZkz3D8NfQwCKQ0smVPmY+DrQuVuLLgewr WMzxjNADRLMMIdNXElEP9kij2vxKlAiEED8IhRFcJIWD7H6ewh5RrOoB+YrjwDJpc/eeRa/zRMMhZ DhzXA9bLNVgejnciV2+5lo4EnigrQzg/Ntxm91q62rpBjVemhDca6xzmLlgb76aI7CoOeQF1fMjqZ tbqZ7Sq/k1VR4WrNjlWAaFbmGy4XA8LUgWhkAw6ysFryVk4EblRNuKWOzejr2ovjhA73QKtca7bJt OxFSyOvQ==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kJMaq-0003h2-GQ; Fri, 18 Sep 2020 20:02:52 +0000 Date: Fri, 18 Sep 2020 21:02:52 +0100 From: Matthew Wilcox To: Linus Torvalds Cc: "Gustavo A. R. Silva" , 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: <20200918200252.GH32101@casper.infradead.org> 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: 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: > > 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. Hmm. We actually do that in our implementation of struct_size() #define struct_size(p, member, count) \ __ab_c_size(count, \ sizeof(*(p)->member) + __must_be_array((p)->member),\ sizeof(*(p))) I suppose it's not really necessary, we could do offsetof here, right? #define struct_size(p, member, count) \ __ab_c_size(count, \ sizeof(*(p)->member) + __must_be_array((p)->member),\ offsetof(typeof(*(p)), member))