From patchwork Mon May 3 23:43:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 12237235 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=-14.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 71C00C433B4 for ; Mon, 3 May 2021 23:44:04 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E655D61165 for ; Mon, 3 May 2021 23:44:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E655D61165 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 61CD26B0036; Mon, 3 May 2021 19:44:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5CD126B006E; Mon, 3 May 2021 19:44:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 446406B0070; Mon, 3 May 2021 19:44:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0156.hostedemail.com [216.40.44.156]) by kanga.kvack.org (Postfix) with ESMTP id 28AA86B0036 for ; Mon, 3 May 2021 19:44:03 -0400 (EDT) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id CA6DE181AEF39 for ; Mon, 3 May 2021 23:44:02 +0000 (UTC) X-FDA: 78101550324.20.80BB978 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf23.hostedemail.com (Postfix) with ESMTP id 9517BA0002C0 for ; Mon, 3 May 2021 23:43:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620085441; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=jCf7MedEAQFBYIkaSpiF9v4fltCeMBeyAmGFjrdwI0I=; b=e8vr020dWh0X1+xanRnXG7PsfpeEcjq0fzAUTtuaLGGNqmXVjmq80qIR19pUpFYcGKFhsV QWCFA6IQS6XVUjfr4EqjjEyPdZw2WXdmlCb/b7CaqzFqT4KiBDi3IJHUaL8CTkNrcxCQW+ sogT4zQSEprpex31Q9Q06j8y7mIO7ZY= Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-263-CcDLWECXP-yIcK59UHVy8g-1; Mon, 03 May 2021 19:44:00 -0400 X-MC-Unique: CcDLWECXP-yIcK59UHVy8g-1 Received: by mail-qt1-f199.google.com with SMTP id g21-20020ac86f150000b02901c94e794dd7so1983138qtv.7 for ; Mon, 03 May 2021 16:44:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=3fYq5mzdiVLYR3uQAPzvtmbf3ClYTT9NmMwFA9WuD6A=; b=MOpfbDH113sXfokkm3yiK77REQUzrlCTj0AvCpUKdrK6YwYTJFsEdQ1JwNTOoTuVNZ U+0HYrEWyvDxRV9u/QwytIQrxk1mGRnkIFhU1373baYYX5x4oeV5hDDSin/3sLw0KtNA 11eoTPTiJiw3fuPNGsq4CkdE0ISGVFTTrgp/QYFm4GA0ucGF9QtETsRXe/Z3uCyco/ap whMkZM2SsvIRYAXTQvWVA6ICn6Gt0uXdd3+OQ3Ijzzn6gE/AcYw4hjWREg8qAA+8gTx+ whvQsPT803II6oiw4Zn2kaGRZX4QtFKJgn8x4RakTNuYKmhG6TyYxGmi5CR6qTp8nhQd ogPw== X-Gm-Message-State: AOAM532HzH5p2jU+DLHxKdBtH2ryhCrc4gcg4rM515Prn8V4o1bcdsjd 79/9e7s1cBwhSENompvcTSNlRaD/MV45mW0CVgobvi+DEDgOfJCO0loo5OTYeBgq04zzo5IUJxL l1MKIudPkrx4o0UJV9kGP53tJ8nAgorbEfyq9NsiqWql7obS8QOhyTP1cecac X-Received: by 2002:a05:622a:1353:: with SMTP id w19mr19450490qtk.220.1620085439509; Mon, 03 May 2021 16:43:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzxTyuLUzDxfS+UClhTwGlq0AuDhUV/Ozzsq4b3IVfnQWYBAv7mJo9VQwKl+d/SYCj1EIDB4w== X-Received: by 2002:a05:622a:1353:: with SMTP id w19mr19450461qtk.220.1620085439211; Mon, 03 May 2021 16:43:59 -0700 (PDT) Received: from t490s.redhat.com (bras-base-toroon474qw-grc-72-184-145-4-219.dsl.bell.ca. [184.145.4.219]) by smtp.gmail.com with ESMTPSA id 189sm7126903qkh.99.2021.05.03.16.43.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 May 2021 16:43:58 -0700 (PDT) From: Peter Xu To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Axel Rasmussen , Andrea Arcangeli , Andrew Morton , peterx@redhat.com, Mike Kravetz , Hugh Dickins Subject: [PATCH v2 0/2] mm/hugetlb: Fix issues on file sealing and fork Date: Mon, 3 May 2021 19:43:54 -0400 Message-Id: <20210503234356.9097-1-peterx@redhat.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 9517BA0002C0 X-Stat-Signature: xpxond7bs87b9pos17t1hm6rhxp1mont Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=e8vr020d; spf=none (imf23.hostedemail.com: domain of peterx@redhat.com has no SPF policy when checking 216.205.24.124) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com Received-SPF: none (redhat.com>: No applicable sender policy available) receiver=imf23; identity=mailfrom; envelope-from=""; helo=us-smtp-delivery-124.mimecast.com; client-ip=216.205.24.124 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1620085435-822370 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: v2: - Move seal check to be after setting VM_HUGETLB [Mike] - Rewrite commit message for patch 2, explaining more on why it got broken - Add r-bs for Mike Hugh reported issue with F_SEAL_FUTURE_WRITE not applied correctly to hugetlbfs, which I can easily verify using the memfd_test program, which seems that the program is hardly run with hugetlbfs pages (as by default shmem). Meanwhile I found another probably even more severe issue on that hugetlb fork won't wr-protect child cow pages, so child can potentially write to parent private pages. Patch 2 addresses that. After this series applied, "memfd_test hugetlbfs" should start to pass. Please review, thanks. Peter Xu (2): mm/hugetlb: Fix F_SEAL_FUTURE_WRITE mm/hugetlb: Fix cow where page writtable in child fs/hugetlbfs/inode.c | 5 +++++ include/linux/mm.h | 32 ++++++++++++++++++++++++++++++++ mm/hugetlb.c | 1 + mm/shmem.c | 22 ++++------------------ 4 files changed, 42 insertions(+), 18 deletions(-)