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.8 required=3.0 tests=BAYES_00, 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 3078FC41604 for ; Tue, 20 Oct 2020 20:20:23 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7AA6F2225F for ; Tue, 20 Oct 2020 20:20:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7AA6F2225F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=canonical.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B7B236B005C; Tue, 20 Oct 2020 16:20:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B2AAF6B0062; Tue, 20 Oct 2020 16:20:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A6A986B0068; Tue, 20 Oct 2020 16:20:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0007.hostedemail.com [216.40.44.7]) by kanga.kvack.org (Postfix) with ESMTP id 7A7A36B005C for ; Tue, 20 Oct 2020 16:20:21 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 19B6E82F3BEF for ; Tue, 20 Oct 2020 20:20:21 +0000 (UTC) X-FDA: 77393421042.18.turn28_1606fbf27242 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin18.hostedemail.com (Postfix) with ESMTP id EC3F11028C476 for ; Tue, 20 Oct 2020 20:20:20 +0000 (UTC) X-HE-Tag: turn28_1606fbf27242 X-Filterd-Recvd-Size: 4013 Received: from youngberry.canonical.com (youngberry.canonical.com [91.189.89.112]) by imf18.hostedemail.com (Postfix) with ESMTP for ; Tue, 20 Oct 2020 20:20:20 +0000 (UTC) Received: from mail-ed1-f70.google.com ([209.85.208.70]) by youngberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1kUy7G-0000NH-S0 for linux-mm@kvack.org; Tue, 20 Oct 2020 20:20:18 +0000 Received: by mail-ed1-f70.google.com with SMTP id h6so1051567edt.12 for ; Tue, 20 Oct 2020 13:20:18 -0700 (PDT) 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=WvOvrqIowXTqWbDC3SiYk9DLPVZO2oaMjHYKa1wNVGk=; b=EcxfcgnnTr1eoWgOkXEx9SzgqKPSerd77BnkrePuVlr25+OKT1v+d5rPHtF+Kwqjpn XzGj06MMa+0kL9zd+PlFqScZzbM2pPkWxgwjtKVdgrHnIBsOnYqPR90SIsv97JcyvF/p HNDGGMf+iI8nQTdVDwLZnqR1WWe5fSIA2+jDdYR7pYIDIBpEZBk6PnYnizHAPiniTdFI 1ClsK4162s7CfnvokUfEbejGVA90XQLsfavqjxkb7cB4x4qFUhxqSTn8IHLNPgiHVL70 PxvLNibYb8RyCQ9QphlH1ekSBc0r3rp7GuDhJoyz5us2n/F55k7R3nP+GB1xjaWrXuRq sKTA== X-Gm-Message-State: AOAM533Z7j2EFskBTvWigEpG8IAsskwqtMcYkYiRb0SKSxy17bQKj+QL TdyP1YSNNhX8h89bXJ2n0bx0EeSfR277aKbt4oK5/glRSCfGeVutmI0eIDgBusErPq5SgMpOecd 3flg1t97fBTSPnxXp37PItok+ZAkrvx8pQErAs7z9IztJ X-Received: by 2002:a17:907:2079:: with SMTP id qp25mr5120231ejb.347.1603225218451; Tue, 20 Oct 2020 13:20:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyqbbW8pMrleDlOJd1KePFqq+CJbaQMJ+psyTG1mR8nQ4SwdBtFh6Yuwue0V+iAwXeGPL4ShGlaEgzeY9wHMIY= X-Received: by 2002:a17:907:2079:: with SMTP id qp25mr5120206ejb.347.1603225218228; Tue, 20 Oct 2020 13:20:18 -0700 (PDT) MIME-Version: 1.0 References: <20201019182853.7467-1-gpiccoli@canonical.com> <20201020082022.GL27114@dhcp22.suse.cz> <9cecd9d9-e25c-4495-50e2-8f7cb7497429@canonical.com> <5650dc95-4ae2-05d3-c71a-3828d35bd49b@redhat.com> In-Reply-To: <5650dc95-4ae2-05d3-c71a-3828d35bd49b@redhat.com> From: Guilherme Piccoli Date: Tue, 20 Oct 2020 17:19:42 -0300 Message-ID: Subject: Re: [PATCH] mm, hugetlb: Avoid double clearing for hugetlb pages To: David Hildenbrand Cc: Michal Hocko , Mike Kravetz , linux-mm@kvack.org, kernel-hardening@lists.openwall.com, linux-hardening@vger.kernel.org, linux-security-module@vger.kernel.org, "Guilherme G. Piccoli" , Thadeu Lima de Souza Cascardo , Alexander Potapenko , James Morris , Kees Cook Content-Type: text/plain; charset="UTF-8" X-Bogosity: Ham, tests=bogofilter, spamicity=0.000015, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: When I first wrote that, the design was a bit different, the flag was called __GFP_HTLB_PAGE or something like that. The design was to signal/mark the composing pages of hugetlb as exactly this: they are pages composing a huge page of hugetlb "type". Then, I skipped the "init_on_alloc" thing for such pages. If your concern is more about semantics (or giving multiple users, like drivers, the power to try "optimize" their code and skip this security feature), I think my first approach was better! This way, the flag would be restricted to hugetlb usage only. I've changed my mind about that approach before submitting for 2 reasons: (a) It feels a waste of resources having a GFP flag *only* to signal regular pages composing hugetlb pages, it's a single user only, forever! (b) Having 2 conditional settings on __GFP_BITS_SHIFT (LOCKDEP and HUGETLB) started to make this define a bit tricky to code, since we'd have 2 Kconfig-conditional bits to be set. So, I've moved to this other approach, hereby submitted. Cheers, Guilherme