Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp899404pxp; Wed, 16 Mar 2022 20:36:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyvRwHU4xrRyeqNiyXoR1IdOpQ55DcZi6osccTsG7b54bIt0kzB8ZlbJyww5d29fDgpIhFE X-Received: by 2002:a17:902:f701:b0:14d:7cea:82af with SMTP id h1-20020a170902f70100b0014d7cea82afmr3017996plo.71.1647488194066; Wed, 16 Mar 2022 20:36:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647488194; cv=none; d=google.com; s=arc-20160816; b=nbZ3smT/2NR4M7YRbmXG15H6liFx6NNlWZ6KB+brByxEuvnfrGWPHj/ndm5iCcuVFa RyjyMvACGJ9j0QQ/ctDvZbntdBPtA4C2oJlgPWMAvid9c9ocJlSSs0sMgjn6jBiaCw8Z CXtHIV9FzOyF9SAS3C/pVOsGdKi5UadgeODn5AKYnLj+5Ip4EFyPGc/gRu7hig5E5RoU OX6PAyvu8RxMsnnslnpf7dK143ZtpacZtTy8lmi0hZEmzc1N3WnF+ZCJuKz3W5lG42q+ l/XHKUcD4JYnpFZq9tm2h+XI3mvSaZjSGpA1MiT+bG5VntXyPIppd/XI39DMlLjU3i9W 2Z3A== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=LNo2l7N+Fsg40rQR+hYE8A/uPOC83k3C0HNY6qs4qNQ=; b=QLOdn0wFhJtTI3ugizBH7YXry0zq0GOBwsvhXvTKVDQJaBm+BD8wNPadNNuDqlvEdo nbkdBrYyv3Voe3n2PNlz7Y2XNryi/Y2MzvbACulF9xSGAV8vntIRGYFPBulI1gkU6w3u 9g3rzYsClLREIdyhCYboAc9/J64KakldZ8OyVZXFVqYGwf5magL8euJCud5A+evvINOJ HFQsz2azO2LMneiTJIQy3iboEcAvhxckWAP/CxVVTV4ubVL7iaPjlB7oMr9uBGynOvKs Gi3UWwoGHXa+9jcH7V4JV5SHdq9SBnF1lY+fNYWAzbJC9aS9/n9LeCgq1aqzLshsapzs aeTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=x+zKJuqo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id m5-20020a654c85000000b003816043ef61si889442pgt.342.2022.03.16.20.36.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Mar 2022 20:36:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=x+zKJuqo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 196563700E; Wed, 16 Mar 2022 20:32:02 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242453AbiCNMTD (ORCPT + 99 others); Mon, 14 Mar 2022 08:19:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242506AbiCNMKF (ORCPT ); Mon, 14 Mar 2022 08:10:05 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 667491CFEB; Mon, 14 Mar 2022 05:08:49 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 50D1F61360; Mon, 14 Mar 2022 12:08:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3FAB2C340E9; Mon, 14 Mar 2022 12:08:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1647259724; bh=uA4gcJaE2bU5YxD5ld1ATwcGw0Tnkliw/0hlS/zVgeE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=x+zKJuqowQl8xaz+Nof0XGUq0AO0WHdURfcaQeO6EyJEVpAQL2PyoetaqKDLnvJcl rwOvc+yzRh3xKlancSKRWL71PPahMG4gnpq2RKkuNnoSZce/J81tBRBTsMDSwEf3HT sbzQEVAWw1Sit4hB3PmzgkT2f3h9l28ugDqcFsYc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mike Kravetz , Joel Fernandes , Shuah Khan , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 5.15 073/110] selftests/memfd: clean up mapping in mfd_fail_write Date: Mon, 14 Mar 2022 12:54:15 +0100 Message-Id: <20220314112745.071963713@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220314112743.029192918@linuxfoundation.org> References: <20220314112743.029192918@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 From: Mike Kravetz [ Upstream commit fda153c89af344d21df281009a9d046cf587ea0f ] Running the memfd script ./run_hugetlbfs_test.sh will often end in error as follows: memfd-hugetlb: CREATE memfd-hugetlb: BASIC memfd-hugetlb: SEAL-WRITE memfd-hugetlb: SEAL-FUTURE-WRITE memfd-hugetlb: SEAL-SHRINK fallocate(ALLOC) failed: No space left on device ./run_hugetlbfs_test.sh: line 60: 166855 Aborted (core dumped) ./memfd_test hugetlbfs opening: ./mnt/memfd fuse: DONE If no hugetlb pages have been preallocated, run_hugetlbfs_test.sh will allocate 'just enough' pages to run the test. In the SEAL-FUTURE-WRITE test the mfd_fail_write routine maps the file, but does not unmap. As a result, two hugetlb pages remain reserved for the mapping. When the fallocate call in the SEAL-SHRINK test attempts allocate all hugetlb pages, it is short by the two reserved pages. Fix by making sure to unmap in mfd_fail_write. Link: https://lkml.kernel.org/r/20220219004340.56478-1-mike.kravetz@oracle.com Signed-off-by: Mike Kravetz Cc: Joel Fernandes Cc: Shuah Khan Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- tools/testing/selftests/memfd/memfd_test.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/testing/selftests/memfd/memfd_test.c b/tools/testing/selftests/memfd/memfd_test.c index 192a2899bae8..94df2692e6e4 100644 --- a/tools/testing/selftests/memfd/memfd_test.c +++ b/tools/testing/selftests/memfd/memfd_test.c @@ -455,6 +455,7 @@ static void mfd_fail_write(int fd) printf("mmap()+mprotect() didn't fail as expected\n"); abort(); } + munmap(p, mfd_def_size); } /* verify PUNCH_HOLE fails */ -- 2.34.1