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.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 90B60C43464 for ; Fri, 18 Sep 2020 17:24:22 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EF73722208 for ; Fri, 18 Sep 2020 17:24:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="ZU2+5L8S" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EF73722208 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 10C8A6B0037; Fri, 18 Sep 2020 13:24:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0BD826B005C; Fri, 18 Sep 2020 13:24:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EEE226B005D; Fri, 18 Sep 2020 13:24:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0120.hostedemail.com [216.40.44.120]) by kanga.kvack.org (Postfix) with ESMTP id D64616B0037 for ; Fri, 18 Sep 2020 13:24:20 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 9199B1F1B for ; Fri, 18 Sep 2020 17:24:20 +0000 (UTC) X-FDA: 77276855880.17.mint32_02161d22712c Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin17.hostedemail.com (Postfix) with ESMTP id 48032180D0181 for ; Fri, 18 Sep 2020 17:24:20 +0000 (UTC) X-HE-Tag: mint32_02161d22712c X-Filterd-Recvd-Size: 4761 Received: from mail-lf1-f68.google.com (mail-lf1-f68.google.com [209.85.167.68]) by imf36.hostedemail.com (Postfix) with ESMTP for ; Fri, 18 Sep 2020 17:24:19 +0000 (UTC) Received: by mail-lf1-f68.google.com with SMTP id y11so6951633lfl.5 for ; Fri, 18 Sep 2020 10:24:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=e6vHhMkaPtX++PGx5jiUYCnfKpKOltu478EtiJp8yLA=; b=ZU2+5L8SZkXq9a5GNzvsy1XCOuVkPArF8Zqy936bPpKXMZldfada0mBjSt7MQx+6lc hYyTkDFpSYfmoKq4BrQNoWe8ScDPcMbZZLLS8RgckiPRICdnSxnbOytIyrECsy8fwWFD 7uim5Lw1FtAv+RIDbrGb0N9ZMJMlQ+VCnOjAs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=e6vHhMkaPtX++PGx5jiUYCnfKpKOltu478EtiJp8yLA=; b=sB4IBlmfsB3DVmKPwcbQFpSn/MTg7AWwQ79VlEfsRykIuD8TM/BeM3B9qx72d1uZfK nAN74N6S0RTPGRPzc592SbzfAzAszZ3xPzpdLH+HUKLMRz8elrJxnElADoPiX+jla7Ey 8+FdwfT+dbgRZS3VmvL/Oa01ZtDlcaAQMhRtyY7W/1jfsENryCbmpa6KLKEnhLCRhkFu R+sBhiHk/Lczuu3IWKpKhsQYmzIc9Uue81RoAul64GEJlXCJ/Z5MpRA3TgPQGu7PTs9P 0FN38+PdZkCLdT2tIOYYdhQGDV2Mvo/kCtXytnEkH9yo0jLgYdOaTeP2UKb+Y3En5tBF UJ/Q== X-Gm-Message-State: AOAM532kqjaU4IkZatJzPOTwsj3GAYG67GkfC8/gCfubEY2IY2sszqqu z4hf4j6Yt3ebB/2a+DVI8wkMk1HU/+C70A== X-Google-Smtp-Source: ABdhPJwKNPCOmucgi286yb7JUokp5BTJyeOIG162RvZy9GKUa38xArpQZM7r3isHpCjfuozBhBOPZQ== X-Received: by 2002:a19:942:: with SMTP id 63mr12535091lfj.23.1600449857823; Fri, 18 Sep 2020 10:24:17 -0700 (PDT) Received: from mail-lj1-f182.google.com (mail-lj1-f182.google.com. [209.85.208.182]) by smtp.gmail.com with ESMTPSA id i22sm718283ljb.53.2020.09.18.10.24.10 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 18 Sep 2020 10:24:11 -0700 (PDT) Received: by mail-lj1-f182.google.com with SMTP id k25so5705139ljg.9 for ; Fri, 18 Sep 2020 10:24:10 -0700 (PDT) X-Received: by 2002:a05:651c:32e:: with SMTP id b14mr11309516ljp.314.1600449850596; Fri, 18 Sep 2020 10:24:10 -0700 (PDT) MIME-Version: 1.0 References: <20200917204514.GA2880159@google.com> <20200918162305.GB25599@embeddedor> In-Reply-To: <20200918162305.GB25599@embeddedor> From: Linus Torvalds Date: Fri, 18 Sep 2020 10:23:54 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [GIT PULL] percpu fix for v5.9-rc6 To: "Gustavo A. R. Silva" Cc: Dennis Zhou , Tejun Heo , Christoph Lameter , Linux-MM , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" 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 9:17 AM Gustavo A. R. Silva wrote: > > This bug could have been prevented by either adopting better > coding practices or through the use[3] of the recent struct_size() helper. Well, my unspoken point was that coding practices are just theoretical. Coding practices don't help - actual *checking* of them helps. I realize that structures with flexible-array member are allowed to use sizeof() in standard C, but if we want to make sure this doesn't happen, we would need to have a stricter model than that. But a quick google didn't find any flag to enable such a stricter mode. I guess a sparse warning would work, but sparse already has too many warnings and as a result most people don't care - even if they were to run sparse in the first place. Is there some gcc option that I didn't find to help find any questionable cases? Because if we have a coding practice that you should use 'struct_size()', then we should also have a way to _verify_ that. The whole - and really ONLY - point of using flexible arrays was that it would protect against these things. And as things are now, it simply doesn't. It's not an actual improvement over just using a zero-sized array. (Slightly related: copying a struct has the exact same issue. A flexible array is no better than a zero-sized array, and generates the same code and the same lack of any warnings, afaik). Linus