Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp1636858lqm; Fri, 3 May 2024 01:30:44 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUPhEo6hGL6qb8rN3nvXpU2DkDL870jVVwnZLmJ5pAOngNOlXghAqfrWdN35kj1lfjGd1lt5UWl+WbXAZv2bbokIGfQrwnJ0PxwlVUjcw== X-Google-Smtp-Source: AGHT+IFF6wGP5rZYrLVj7kNmtlGE/gNN6StV9RrjaWNj2VmjDCvSSP4zlAD8h34XJHeHy3rxpbte X-Received: by 2002:a05:622a:c3:b0:43a:ea67:fe91 with SMTP id p3-20020a05622a00c300b0043aea67fe91mr1770018qtw.52.1714725043931; Fri, 03 May 2024 01:30:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714725043; cv=pass; d=google.com; s=arc-20160816; b=pDLNUxlk9K6ZEmA7rO6nPtM9P/CJ32J+eEg/bhCDv6EQewlm+7tUMiIRo6g3YSA3mw X+5Jnadw7zo1/sxb7zPYnHXzY4ENCs0NPfwA2CbBEMOrQTwf+2Vy7stRMwBmAPeF2hJI QsrNZxkjTh1O/F1AX3iWw8RoxScVFL25AcQsIEzZZJ9pRSzLd0w1FuMJxbegCdLW0zf8 zTpry6cUp5j6cPE7MQGZh+6NJAn4Dp38QJnNQjHnJUfe2wxSWsOs/lYkQQB/phKCTF9U k+mQLNnhgdTcXPCLjkdD+cX8YUQ7Cp467TopiMLpyTBrhyCjDGI3m7Rpcu6l55fHciV2 h8hQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=w/YjqP7VmB/l3GFTwIbZ3tS317MDLIQE3BFwOgM0Onw=; fh=m9Dk8QMZT7nRAxDB9cHLG4vqCJ6K2AM1luxaajg8eBg=; b=EhdMlY8oIfbR6dTYvlueJFmu+Kpv6AO/QCkM8woN1tEf1YTCRE+SrCehFnF2TZbAAu 9xIZgIKfgsTDsncf0oI07/pKugtNEfyCK7T6EnFe55kW0p2QdJ1tB/ii3x06+/KX8dP/ KN3A/5NnajnnFtmMnAN9ylRrmNRUZgvv/zKT/lSBAWH6RuFtwxl1DjFz3Y49fz2pN8oF 5Rbq9hjYF3m4N3a9gIU3ykNOjYROZt2OyopD10pmHDoBEtJznkDYggJTyil4UEk0THNQ dyVP327qbtGssiM9uz5vedqBh+0pdaJQWwgV6XOh+9ClKcHk181PWGQoutNfe7UACt4A cKpg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-167386-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-167386-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id f18-20020ac87f12000000b0043addb580a6si2870951qtk.360.2024.05.03.01.30.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 May 2024 01:30:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-167386-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-167386-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-167386-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id A50DB1C223A6 for ; Fri, 3 May 2024 08:30:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 55B6014A0A4; Fri, 3 May 2024 08:30:32 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6405314F62; Fri, 3 May 2024 08:30:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714725031; cv=none; b=NaG1gvC4ydnjmvHtUVvTrrhzdWQmLxe4S6s8fDX1UrgROrh7rBy7Ecu3hA9DEg+KQGvLcI4NspMp/fIwdv/qH8VjlOY/DdvpmN8n47UzkLsEJjD/rVuQszHPDjSUTraQe8++WGP9aDxz0H//p+MvOUA5Poi9dq+HX180l4ZUMW8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714725031; c=relaxed/simple; bh=gqwc2k3oZA5+RsTN0PhOwFlxF0pioPcwT29bhC8+fC8=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=UZzGbGNAlUrhjdymPyHMcw/kyigjzy043RZEcu02QHVQm+wXq39DC8FSXgscMeNVQZmQpzH86Mu/Qf9+FjeyEp5J088guVe4GiXAdCyyjN/fWLjkGVtlarWzpGg5b2JJQ2XvKCAcfmBSzhuJFcpaLv9TSfUfo+v5liL2FY2w7Xg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8118A2F4; Fri, 3 May 2024 01:30:53 -0700 (PDT) Received: from [10.57.67.51] (unknown [10.57.67.51]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 047DF3F73F; Fri, 3 May 2024 01:30:24 -0700 (PDT) Message-ID: <0afb3887-f72b-42d3-8809-e97353fae031@arm.com> Date: Fri, 3 May 2024 09:30:23 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v10 3/5] selftest mm/mseal memory sealing Content-Language: en-GB To: Jeff Xu Cc: akpm@linux-foundation.org, keescook@chromium.org, jannh@google.com, sroettger@google.com, willy@infradead.org, gregkh@linuxfoundation.org, torvalds@linux-foundation.org, usama.anjum@collabora.com, corbet@lwn.net, Liam.Howlett@oracle.com, surenb@google.com, merimus@google.com, rdunlap@infradead.org, jeffxu@google.com, jorgelo@chromium.org, groeck@chromium.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org, pedro.falcato@gmail.com, dave.hansen@intel.com, linux-hardening@vger.kernel.org, deraadt@openbsd.org References: <20240415163527.626541-1-jeffxu@chromium.org> <20240415163527.626541-4-jeffxu@chromium.org> From: Ryan Roberts In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 02/05/2024 23:39, Jeff Xu wrote: > On Thu, May 2, 2024 at 4:24 AM Ryan Roberts wrote: >> >> On 15/04/2024 17:35, jeffxu@chromium.org wrote: >>> From: Jeff Xu >>> >>> selftest for memory sealing change in mmap() and mseal(). >>> >>> Signed-off-by: Jeff Xu >>> --- >>> tools/testing/selftests/mm/.gitignore | 1 + >>> tools/testing/selftests/mm/Makefile | 1 + >>> tools/testing/selftests/mm/mseal_test.c | 1836 +++++++++++++++++++++++ >>> 3 files changed, 1838 insertions(+) >>> create mode 100644 tools/testing/selftests/mm/mseal_test.c >>> >>> diff --git a/tools/testing/selftests/mm/.gitignore b/tools/testing/selftests/mm/.gitignore >>> index d26e962f2ac4..98eaa4590f11 100644 >>> --- a/tools/testing/selftests/mm/.gitignore >>> +++ b/tools/testing/selftests/mm/.gitignore >>> @@ -47,3 +47,4 @@ mkdirty >>> va_high_addr_switch >>> hugetlb_fault_after_madv >>> hugetlb_madv_vs_map >>> +mseal_test >>> diff --git a/tools/testing/selftests/mm/Makefile b/tools/testing/selftests/mm/Makefile >>> index eb5f39a2668b..95d10fe1b3c1 100644 >>> --- a/tools/testing/selftests/mm/Makefile >>> +++ b/tools/testing/selftests/mm/Makefile >>> @@ -59,6 +59,7 @@ TEST_GEN_FILES += mlock2-tests >>> TEST_GEN_FILES += mrelease_test >>> TEST_GEN_FILES += mremap_dontunmap >>> TEST_GEN_FILES += mremap_test >>> +TEST_GEN_FILES += mseal_test >>> TEST_GEN_FILES += on-fault-limit >>> TEST_GEN_FILES += pagemap_ioctl >>> TEST_GEN_FILES += thuge-gen >>> diff --git a/tools/testing/selftests/mm/mseal_test.c b/tools/testing/selftests/mm/mseal_test.c >>> new file mode 100644 >>> index 000000000000..06c780d1d8e5 >>> --- /dev/null >>> +++ b/tools/testing/selftests/mm/mseal_test.c >>> @@ -0,0 +1,1836 @@ >>> +// SPDX-License-Identifier: GPL-2.0 >>> +#define _GNU_SOURCE >>> +#include >> >> I'm afraid this is causing a build error on our CI, and as a result we are not >> running any mm selftests currently. >> >> The error is here: >> >> CC mseal_test >> mseal_test.c: In function ‘test_seal_mremap_move_dontunmap’: >> mseal_test.c:1469:50: error: ‘MREMAP_DONTUNMAP’ undeclared (first use in this >> function) >> 1469 | ret2 = mremap(ptr, size, size, MREMAP_MAYMOVE | MREMAP_DONTUNMAP, 0); >> | ^~~~~~~~~~~~~~~~ >> mseal_test.c:1469:50: note: each undeclared identifier is reported only once for >> each function it appears in >> mseal_test.c: In function ‘test_seal_mremap_move_dontunmap_anyaddr’: >> mseal_test.c:1501:50: error: ‘MREMAP_DONTUNMAP’ undeclared (first use in this >> function) >> 1501 | ret2 = mremap(ptr, size, size, MREMAP_MAYMOVE | MREMAP_DONTUNMAP, >> | ^~~~~~~~~~~~~~~~ >> >> >> And I think the reason is due to our CI's toolchain's sys/mman.h not including >> linux/mman.h where MREMAP_DONTUNMAP is defined. >> >> I think the fix is to explicitly #include , as a number of other >> mm selftests do. >> > When I tried to build with aarch64-linux-gnu-gcc, this passed. > > aarch64-linux-gnu-gcc -I ../../../../usr/include -DDEBUG -O3 > -DDEBUG -O3 mseal_test.c -o mseal_test -lm -Wall Its the same on my local system; I'm told our CI is using GCC 10, which I suspect makes the difference. > > I don't have the exact environment to repro the issue and verify the fix. > I will send a patch with the linux/mman.h. > > I will probably need some help to verify the fix on arm build, Ryan, > could you help with this ? I'll pass this on to our CI folks, and hopefully get confirmation shortly. > > Thanks > -Jeff