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,URIBL_BLOCKED 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 9EA25C43463 for ; Fri, 18 Sep 2020 22:40:03 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EB3EB21734 for ; Fri, 18 Sep 2020 22:40:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Cv+KobsW" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EB3EB21734 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=alum.mit.edu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 3511C8E0003; Fri, 18 Sep 2020 18:40:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 301938E0001; Fri, 18 Sep 2020 18:40:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 23DA58E0003; Fri, 18 Sep 2020 18:40:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0005.hostedemail.com [216.40.44.5]) by kanga.kvack.org (Postfix) with ESMTP id 0E39F8E0001 for ; Fri, 18 Sep 2020 18:40:02 -0400 (EDT) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id BC065181AEF1D for ; Fri, 18 Sep 2020 22:40:01 +0000 (UTC) X-FDA: 77277651402.15.goat76_3f0c7542712e Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin15.hostedemail.com (Postfix) with ESMTP id 969CD1814B0C7 for ; Fri, 18 Sep 2020 22:40:01 +0000 (UTC) X-HE-Tag: goat76_3f0c7542712e X-Filterd-Recvd-Size: 5306 Received: from mail-qt1-f193.google.com (mail-qt1-f193.google.com [209.85.160.193]) by imf41.hostedemail.com (Postfix) with ESMTP for ; Fri, 18 Sep 2020 22:40:01 +0000 (UTC) Received: by mail-qt1-f193.google.com with SMTP id k25so6528407qtu.4 for ; Fri, 18 Sep 2020 15:40:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=es6nlpMnUB0/QWXaKLyRiwxeJ49wlctuXlJpG4K6HaM=; b=Cv+KobsWzYG75r7cZiugx4mWU3cn+OCwM+12M5mVbeCY/pV2gRAV7BWtd5cthNJGiV qvCbPN6WJwrh9INuPDca4XD9h45s84N87p+cCbh+fVMfX1YMLhVaK7q9Xb20dkIwZ1ZL DtpdtLqqMjVmEs6PxzDz3nUCrVTIjzgM20D1KToiRaScrRH1VnYPN2aCu4G6f2dpkrn0 0lvKbB7KNdQkTHswv53i7n9aToY3gtdDOOlTjFG3H6hNZnyM9gYoRIN3rTQ67HIAlIf/ xjbLcyzBoduV8cRlL6i1zQ2MgAWagb0BXo0vI+g7h2KNdPsCBaNoTZToTIi7MocbWveW fveQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:date:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=es6nlpMnUB0/QWXaKLyRiwxeJ49wlctuXlJpG4K6HaM=; b=RTB8MwkMZ5is/UVaY7JZ73s5ADq12dx78b51gIWdsclaX1145ah/EtYOyYG3T+T5uR GpI9SDwLjEumqIOztWIFKtYs8LSzrJShP6PRQhoC7Habpy9bNaSiFSrJkBPf+d2qheMP Hk9k/+0NLpC+JONwsclQEmtgIkgNit3vAJ7BWA30m1Kf6hZK9w53bg91hvH4lFTQnuPs sMRzz7htZe2BZKSmtNHn11WwhZDMrGzK9vfMHmZSnAy9N1ze94nMT3e4tVhPHpvlz795 3tHG0uKgmv1bxksp0NYGJtCrN8RzRpMFqVZZBzYUWlUj6eH/AOizwSscGGqNeGoyOxO1 HXwQ== X-Gm-Message-State: AOAM532rZ8TkWYHSy4AkIbJLAGzn3p5tRaWF9guttltabpszorCrnXQO T6G2VG8lxx4GzRWz5Wd29So= X-Google-Smtp-Source: ABdhPJwA6lfuOUEZisRe5dar8OcYP03cG9uD7Vk9P3dwKhG/Em2LlaJceNq+u0nEcqObocyWkCZo2w== X-Received: by 2002:ac8:4d07:: with SMTP id w7mr35735943qtv.243.1600468800475; Fri, 18 Sep 2020 15:40:00 -0700 (PDT) Received: from rani.riverdale.lan ([2001:470:1f07:5f3::b55f]) by smtp.gmail.com with ESMTPSA id m64sm3038264qkd.80.2020.09.18.15.39.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Sep 2020 15:39:59 -0700 (PDT) From: Arvind Sankar X-Google-Original-From: Arvind Sankar Date: Fri, 18 Sep 2020 18:39:57 -0400 To: Linus Torvalds Cc: Arvind Sankar , Matthew Wilcox , "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: <20200918223957.GA2964553@rani.riverdale.lan> References: <20200918162305.GB25599@embeddedor> <20200918193426.GA15213@embeddedor> <20200918200252.GH32101@casper.infradead.org> <20200918202909.GA2946008@rani.riverdale.lan> <20200918210050.GA2953017@rani.riverdale.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 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 02:18:20PM -0700, Linus Torvalds wrote: > On Fri, Sep 18, 2020 at 2:00 PM Arvind Sankar wrote: > > > > You could just assert that offsetof(typeof(s),flex) == sizeof(s), no? > > No, because the whole point is that I want that "sizeof(s)" to *WARN*. > > It's a nonsensical thing to do. That 's' has no statically known size. > > The C standard is being very confused here, in that it tries to claim > that the flexible arrays are somehow fundamentally different from a > zero-sized one. But then it acts as if they are exactly the same wrt > sizeof() and structure copies. > > It should warn, exactly because right now it causes potential bugs > like the one that started this thread. > > You can't have both "zero-sized arrays are bad and shouldn't be used" > and "flexible arrays are good, and work exactly like zero-sized > arrays". > > Either zero-sized arrays are bad or they aren't. And if they are bad, > then flexible arrays shouldn't work *exactly* like them apart from > some UBSAN warnings. > > See my point? > > Linus Ouch, offsetof() and sizeof() will give different results in the presence of alignment padding. https://godbolt.org/z/rqnxTK I think, grepping at random, that at least struct scsi_vpd is like this, size is 24 but data[] starts at offset 20. struct scsi_vpd { struct rcu_head rcu; int len; unsigned char data[]; };