Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1538574pxk; Fri, 18 Sep 2020 15:42:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy8a51Zj8bCNWq7AWEcxlpKpes84KG2sdV9BTM8PUT6YgLcIGILCEjbR+RFeO2GPlB8G2zc X-Received: by 2002:aa7:d3da:: with SMTP id o26mr39712873edr.169.1600468957288; Fri, 18 Sep 2020 15:42:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600468957; cv=none; d=google.com; s=arc-20160816; b=aVCB208APdvoMjABGr+oI4nZJqP4u+Hd+O4EY4+HShVYyjw3o57k7ozpUojdO3zNP9 EQ1HeFmzxaddB4Zlv8bJ3AF50qy5odVLeb3egsIS/4zCIl5WMlZmg0VgjKRcZKsn3eUE /5jEqEA4YSwAsmboIK/2kPSxnocedkp+mzJgTAwQnRXkkV48AFWSrK6eFBnKNAmqX4p+ 4oXrK830rLXVE+4tpNgCssb0su/Jtte0bMIKTDPTZR1My6YNoYPsn1vEGD3ZYuo20e+v 0k2cHjiKWHBJtJFzvore8pT1sfcfByHbXU5GJBvJ7JEovbJ1qkqGeuQLJPPE8qBo0E1Y lnJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:date:from:sender:dkim-signature; bh=es6nlpMnUB0/QWXaKLyRiwxeJ49wlctuXlJpG4K6HaM=; b=hN8roPP8wE49dOg0oUTas2+71r8XHsNFyPjwL/vzY3lum1W9uxaUUf5Ae6AYNZge04 MR6W1z9Sg+/Nz6VWCa86F2sbBkJxWgrZgBLjnYEbJWM7iouIZn83R8FxfgFIlXhLItLS nsZUVg21fwyz+o1sIduHbT68NqVZwa5WCo86pA5dIw57SoKRvA8W8M129v4xR+bqp7qX TpAg1/WwbOx3EkpY1epPZaVXKHZURx5xQKGgtkIxuJX/YSb+n09XePXQUsZRXN0qZCkx ScHu0OenfOmvUiI+KhabvAL973S0WdKZnbdcN1aZQbCVj2eQXY5mwwlwozjnC+UV32so 2pfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Cv+KobsW; 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 a5si3206396edx.243.2020.09.18.15.42.12; Fri, 18 Sep 2020 15:42:37 -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=@gmail.com header.s=20161025 header.b=Cv+KobsW; 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 S1726134AbgIRWkB (ORCPT + 99 others); Fri, 18 Sep 2020 18:40:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726022AbgIRWkB (ORCPT ); Fri, 18 Sep 2020 18:40:01 -0400 Received: from mail-qt1-x844.google.com (mail-qt1-x844.google.com [IPv6:2607:f8b0:4864:20::844]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65A41C0613CE for ; Fri, 18 Sep 2020 15:40:01 -0700 (PDT) Received: by mail-qt1-x844.google.com with SMTP id n18so6545889qtw.0 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=OPyWVVJmhsfVmAxXue93FshJR5t53/K7qrdE+k9lDUeJkpadY617UT+mfz1tk+ywuI P/iaxlg0QWIn2ylCeU1ElRXr8I1aP/VhQHbOF/xZSm7FVVgedkdYW1bT0loIh3hbGDMe AOUK+3qCRWZbn1xRe4S/MUUk6ynScZzKCmPnru0MczBnLS/Vi4U1izc18+TQG+L9SJhj VYH6CLAumH+kAWCXHnNtmrhaI29Ge/uawENnCyjDB6vy4jktXxx34xqfCdwhGgXUDGDW T+VyIuRHXxhrXy9pxNX51c98hIJ0zevMftnZ8e6OBJh92ZN+wYuJ4C/g7Th3Lr1a+jIi JFJA== X-Gm-Message-State: AOAM532Zwh5grmbGZM3k23NfCUc3vWNsameA3XGyypBF8Gx0IJeFWs1P 9kICixnjVeLaYMf1ljjDDJc= 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) Sender: Arvind Sankar 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: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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[]; };