Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp3116942rwl; Thu, 13 Apr 2023 16:12:50 -0700 (PDT) X-Google-Smtp-Source: AKy350ahGRJr5zFnuuObITwJaSpj8TWfuXwBkemGPZILPot4nY5YuwvBQ++2d3nUqSHvMZIGQO9q X-Received: by 2002:a17:902:e80a:b0:1a2:1a5b:cc69 with SMTP id u10-20020a170902e80a00b001a21a5bcc69mr733466plg.32.1681427570486; Thu, 13 Apr 2023 16:12:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681427570; cv=none; d=google.com; s=arc-20160816; b=yRgrj7Kgonhtth35J+boAsGvY0whw2DZi7UOzsQrD0TLgBZARrB44PIIN92uS61kwV v6i378s6QvwfLfcbXD38XXa1PWfu1CgCrB2xmIX0vhrLe/ZFVV02wtI5/K7/tghenz0h WhE6XvkwbzG+kjY5r+lUGAthJm+sl/JNXFjnj9EdJBV25oce9l8enwDjEnp5GltwfTi/ ofSmjndQBNHcsTPFNqSfC2jZ6fCb+KNd5OnsMeOuQvX71kkLojtX/kpiIorXnRPvAE4s 64tF8TSRy/2+qpxRmD317/z21S1b+VU0/yHsNP21alX4a+rTNovt5bgMIZHpaT5Isij/ dtvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=Sy2ZMNXqMN2EgcAsVUaOWzVqOHhPBbCxJILj4M5ud0k=; b=RCuQzAuQU1g8g3NoxOk4ihRkrwkpRvmX7DSQbo6QJ/b0616f8AjuS3HuPhEPyJ6G/S EGEU704zgt4mBJpRZXIckLZQu3JOv0TC1NalUGa7xDj+h7T2uGweG2Js1N2yS4YAMLtN 5hG3ErmtIzmrVhbdnDmbs31l82DzKtoTweJxJTrdPAFhu91f8genHshcIfpQr6HCR6R3 PUD3CQSeRgqcE8Ie3x9pqq+qIgb5VJ4aXtXFK9lWsUJJV/iGOgdyDHDYHXxUOgwqIpQi SoZH1Eq6S4F+E4xuLjIup5tlZdKXslqnJJA75da3nMdYhfHHPX9him0A4AAfINLm0mEc 6vjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YYNKPc9W; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 192-20020a6301c9000000b0051b6c5e0fc7si322957pgb.860.2023.04.13.16.12.38; Thu, 13 Apr 2023 16:12:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YYNKPc9W; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230224AbjDMXMT (ORCPT + 99 others); Thu, 13 Apr 2023 19:12:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230231AbjDMXMS (ORCPT ); Thu, 13 Apr 2023 19:12:18 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3456849CE for ; Thu, 13 Apr 2023 16:11:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681427485; 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=Sy2ZMNXqMN2EgcAsVUaOWzVqOHhPBbCxJILj4M5ud0k=; b=YYNKPc9WORqOAu1hab8rlTQEQsUOeILIkIjilmAPno5Mc1fBMBXu4rCfDR2L2VNSEsHOUL 1BEwOfrc52s1gJGSMxZof3tYCXBEw8jFLHh2SXRKj1LyS7Sc5YpENXPggJq3bODzPdGWk3 hMNmlHq+pc0y/7qqqH0deImazXRP/Xs= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-505--50IN8n6OUiRHViocjYnyg-1; Thu, 13 Apr 2023 19:11:24 -0400 X-MC-Unique: -50IN8n6OUiRHViocjYnyg-1 Received: by mail-qt1-f200.google.com with SMTP id d75a77b69052e-3e947d81d7dso3391281cf.1 for ; Thu, 13 Apr 2023 16:11:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681427483; x=1684019483; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Sy2ZMNXqMN2EgcAsVUaOWzVqOHhPBbCxJILj4M5ud0k=; b=IhR57ynZr48BsYmve/A3ETMNHeiqo4Wa3Y/9r3C5DLcMVUBxCjAdVSfs3zp1oj0heY avT5paJm1qibnJDRcVy7a2Gb0cg1aVllLG/sIY20O9JQVYD4IJAkw9Nk6iDtUToQQJb2 +oUdCext6WLUXoQlDn06mrHVE4r293+YtGiRbRqXkj5qLTgSuGq51aP/l7nxls3jFEM0 +Uz8VnK90e0XUFi9Vkcm/cpP4d6NM1EBcvI7CHxZLx3tlEfE7rUwq4IU7wVFGaEReHz0 gB1dc5Ytl2pV+SBfqMyBLYsSThfrW9wz88oX/NDvqbo5sf1O6nmosqDGZGlCM0MZ2vEm 1Z9g== X-Gm-Message-State: AAQBX9ePl7mRrR6q7dtH/Z9c/PZlM4X3GF5SIbUG9X5JC1H+Fsa7T9iL HQD55C3/d5rJc8vpAOxwA9HYvnefKYHY4NOs5CkFwD6jRIWGRl8T711uH7hsxOy/FVK9DEaII0T jDbOf7kxEM7SMnhpJ2wKEaThT9zOH2aWZCR/g8NPNDXuP2vETM16JEE222YXseeNj1BQRCxb9cC KTCoksJw== X-Received: by 2002:ac8:4e43:0:b0:3bf:cf77:a861 with SMTP id e3-20020ac84e43000000b003bfcf77a861mr1053272qtw.4.1681427482732; Thu, 13 Apr 2023 16:11:22 -0700 (PDT) X-Received: by 2002:ac8:4e43:0:b0:3bf:cf77:a861 with SMTP id e3-20020ac84e43000000b003bfcf77a861mr1053215qtw.4.1681427482308; Thu, 13 Apr 2023 16:11:22 -0700 (PDT) Received: from x1n.redhat.com (bras-base-aurron9127w-grc-40-70-52-229-124.dsl.bell.ca. [70.52.229.124]) by smtp.gmail.com with ESMTPSA id g3-20020ac81243000000b003ea1b97acfasm612446qtj.49.2023.04.13.16.11.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Apr 2023 16:11:21 -0700 (PDT) From: Peter Xu To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Axel Rasmussen , Andrew Morton , David Hildenbrand , peterx@redhat.com, Mike Kravetz , Nadav Amit , Andrea Arcangeli Subject: [PATCH 0/6] mm/hugetlb: More fixes around uffd-wp vs fork() / RO pins Date: Thu, 13 Apr 2023 19:11:14 -0400 Message-Id: <20230413231120.544685-1-peterx@redhat.com> X-Mailer: git-send-email 2.39.1 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is a follow up of previous discussion here: https://lore.kernel.org/r/20230324222707.GA3046@monkey There, Mike correctly pointed out that uffd-wp bit can get lost too when Copy-On-Read triggers. Last time we didn't have a reproducer, I finally wrote a reproducer and attached as the last patch. When at it, I decided to also add some more uffd-wp tests against fork(), and I found more bugs. None of them were reported by anyone probably because none of us cares, but since they're still bugs and can be reproduced by the unit test I fixed them too in another patch. The initial patch 1-2 are fixes to bugs, copied stable. The rest patches 3-6 introduces unit tests to verify (based on the recent rework on uffd unit test). Note that not all the bugfixes in patch 1 is verified (e.g. on changes to hugetlb hwpoison / migration entries), but I assume they can be reviewed with careful eyes. Thanks, Peter Xu (6): mm/hugetlb: Fix uffd-wp during fork() mm/hugetlb: Fix uffd-wp bit lost when unsharing happens selftests/mm: Add a few options for uffd-unit-test selftests/mm: Extend and rename uffd pagemap test selftests/mm: Rename COW_EXTRA_LIBS to IOURING_EXTRA_LIBS selftests/mm: Add tests for RO pinning vs fork() mm/hugetlb.c | 33 +- tools/testing/selftests/mm/Makefile | 8 +- tools/testing/selftests/mm/check_config.sh | 4 +- tools/testing/selftests/mm/uffd-unit-tests.c | 318 +++++++++++++++++-- 4 files changed, 315 insertions(+), 48 deletions(-) -- 2.39.1