Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp1449229lqm; Thu, 2 May 2024 15:39:37 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU+Z4JqbFbSFyRZRnHHjR2ZrkPdIRSFZyGZCAfW6YhmBs+Wnr1HkfRcEJMTrt4HmDIgivpOX9Ig7hanrjsSyOm5U7sxYTkfEfcNMDQcmg== X-Google-Smtp-Source: AGHT+IFIXZfBTRMMws7cuaNXQAAKRv3IB1j2NTaToIzEQC0aQMW+yrODk6YslnWumgSaBHbpv9CR X-Received: by 2002:a05:6871:3387:b0:23a:fb36:ffb3 with SMTP id ng7-20020a056871338700b0023afb36ffb3mr1469330oac.19.1714689577079; Thu, 02 May 2024 15:39:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714689577; cv=pass; d=google.com; s=arc-20160816; b=p+8ptBhsozqnBVjVxTrR3MowTvQVfhalq+hRuOtKLQLeSTF8rQVyrA4oMAxjGTBC1O Xjvq+PqKL87e30iQhsoydVY30C8nnLf5AXx4tiDm/TI4GiI1h59o5fsqAXe2b6Kn2YVP ffvNokgtjooj7e5Xkm0BeyZMNOrzR+S1g0wroqVsHcf0q/n5uy0v59tn4YIqtwviiuRQ vDOcodGTbENiCNSpX7R44OJ4PRkTa8rqvjaFzswBpCBBA6VHz4t7tRvstPQkTuYf4J4j NSKeC5IuH+hH8UPRQ7Oo+KvUokHkNEsT9dIC3vb5JxzTxmc/NHeeY5AAv2cxUVSPNlpD 7AKQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=qfrJLkNktZfuMB+SoJQ7DumtzHrpuMfMLiSMpOw3O3Y=; fh=nMDISRY2wgwspADgdp5WksNmDhiOm8+E6OVez8muIEE=; b=Kr8DYbdB2/pxclfUMWW8QWSdaC+JKyWiYxYpfmM3pVMM01N6BvqZ+HnLNp+5Csrzno +9pai8ViAsldql9OpQoJ11ir55/34ae+YD4UwSsR2ixDeXdfY2PVngdUymuoR66Tm8rO r794/vqeJheO4d/5svSFaoS0q+w4lLn/hK50q/PX1+/oVe5S2hsZ/QdIJG7KWhebm0jb 4DPoONbN+1nWgf4V8w3/ampbxv6oARWaFL0eWQL8OCwfpVu34YLB4O8h4jFd+Pw2flCk uvgy1srlx/Xser0bhSPr4hRqrr/fRqQxdZW1FfQVVs43myCBA4ZRSaY2Rj2ymI5XDC/u pnhQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="bv/a7IfM"; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-167010-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-167010-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id vu4-20020a05620a560400b0078ed77c0a24si1899478qkn.192.2024.05.02.15.39.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 May 2024 15:39:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-167010-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; dkim=pass header.i=@chromium.org header.s=google header.b="bv/a7IfM"; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-167010-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-167010-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org 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 9CC671C212A3 for ; Thu, 2 May 2024 22:39:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 524461B960; Thu, 2 May 2024 22:39:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="bv/a7IfM" Received: from mail-oa1-f52.google.com (mail-oa1-f52.google.com [209.85.160.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 26A0117BA0 for ; Thu, 2 May 2024 22:39:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714689570; cv=none; b=MOEm7OcfosYW6YthQ1qTD9gwdoHUUbyGHBHKAwn+aKyrrACxBlpIq84A2gh9FD6kYwZsSVA3Ob+gExOkeCv69OjRAcrJZ7y4IrCmMUAzR9ubPY2b9BxdLJYZ4u+Cb7lLTRaBc+8UN3b5+PlHjyCjX940mJpX6LhqHuXRtCXUM9M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714689570; c=relaxed/simple; bh=6kgJA6OklOrNUE2Q8TmR1v5wqycP1UenmSnwgIFFV3Y=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=SMMb7SyJIoXi/g2Eo09XqGivxghotb+rtL5A7Rwptxoi8W7xaBJPt5hx2ZM3JgiaToBPaRgULiAgs80vdxmvx20xem2jEt+O62tLxNLrbLHCyXPlYdq0qAydGnk1ZVh6JK23UBStRNnRPLNHoDqkzn8URsfTZGlT11Odv4xCaIY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=bv/a7IfM; arc=none smtp.client-ip=209.85.160.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-oa1-f52.google.com with SMTP id 586e51a60fabf-23db0b5dd28so1069335fac.2 for ; Thu, 02 May 2024 15:39:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1714689567; x=1715294367; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=qfrJLkNktZfuMB+SoJQ7DumtzHrpuMfMLiSMpOw3O3Y=; b=bv/a7IfMG/7RvZBf/kMwemhEE84GuBdI2TIfn4A57kihfsP7z5aVw059TZB8JGcGqD 809i/VUAvaawEZgD6qh3OKcAl4pAoE2foIsDeBRD5/1K+ZuGNWcwF47ciiqz9+bFIHhd PSj1bYMlSKXFVz65LyZrcJLA1QAEPahLK/3wk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714689567; x=1715294367; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qfrJLkNktZfuMB+SoJQ7DumtzHrpuMfMLiSMpOw3O3Y=; b=OD4rXJp182gSLsBMnwZf7RI3JWGWjK2/eM4V+3dhUbmaptoK9VJ6WCyn5zKNjlW8Nr FjDhv+1ZaI+YxO9j/BmbjHcO9ocdAnTc9IsRctYCEEU3wao9RuYYA5HWG0qXWa+T9ooi do0qqeM1fhepaFvKMJt6Bc6abLlRgFWkw9BuWltY/khk5tU+HrCpqczMgxn21WYfY7t7 /4+4O5SB9NEHhVxAs5YQGv6XGXbg7llxhNnLwwNiALCT3zaKhz0W8F20U6o2o5T2YOW0 Q+Q9NiQqXolLtw3sNN2lNpbhVi6ELXtBuLvbN/b6EbLX3sGznXF4evI50uj3uv9KKdvb lzcQ== X-Forwarded-Encrypted: i=1; AJvYcCWdSNQrkVIg8G5fQXX13wXeLeKje659RJAIYW6pfT3nF259PugFMBrMiVj7cMWa7xCf4CXOKryYkWXGswQyxh/c5ZwFCgyCdYRweS8l X-Gm-Message-State: AOJu0YwK4OdtHtcRkGKYlpSg0FFFivlqYwLO8Ozdk0bIUGQjhj6Fquoc VtnwDJWNiV8AACs02iFozhYWHgLVefSEwRR0cg4goNNXN8fAImpifcp9FtqBMnT7FPSjb6a6eit qE+uw/zI1RXMHfmxeJ2qFD/r66SxKv9qYy5jP X-Received: by 2002:a05:6870:911e:b0:23c:a6f8:9362 with SMTP id o30-20020a056870911e00b0023ca6f89362mr1552432oae.13.1714689567324; Thu, 02 May 2024 15:39:27 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240415163527.626541-1-jeffxu@chromium.org> <20240415163527.626541-4-jeffxu@chromium.org> In-Reply-To: From: Jeff Xu Date: Thu, 2 May 2024 15:39:15 -0700 Message-ID: Subject: Re: [PATCH v10 3/5] selftest mm/mseal memory sealing To: Ryan Roberts 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, May 2, 2024 at 4:24=E2=80=AFAM 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/self= tests/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/selfte= sts/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 +=3D mlock2-tests > > TEST_GEN_FILES +=3D mrelease_test > > TEST_GEN_FILES +=3D mremap_dontunmap > > TEST_GEN_FILES +=3D mremap_test > > +TEST_GEN_FILES +=3D mseal_test > > TEST_GEN_FILES +=3D on-fault-limit > > TEST_GEN_FILES +=3D pagemap_ioctl > > TEST_GEN_FILES +=3D thuge-gen > > diff --git a/tools/testing/selftests/mm/mseal_test.c b/tools/testing/se= lftests/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 ar= e not > running any mm selftests currently. > > The error is here: > > CC mseal_test > mseal_test.c: In function =E2=80=98test_seal_mremap_move_dontunmap=E2=80= =99: > mseal_test.c:1469:50: error: =E2=80=98MREMAP_DONTUNMAP=E2=80=99 undeclare= d (first use in this > function) > 1469 | ret2 =3D mremap(ptr, size, size, MREMAP_MAYMOVE | MREMAP_DONTUNM= AP, 0); > | ^~~~~~~~~~~~~~~~ > mseal_test.c:1469:50: note: each undeclared identifier is reported only o= nce for > each function it appears in > mseal_test.c: In function =E2=80=98test_seal_mremap_move_dontunmap_anyadd= r=E2=80=99: > mseal_test.c:1501:50: error: =E2=80=98MREMAP_DONTUNMAP=E2=80=99 undeclare= d (first use in this > function) > 1501 | ret2 =3D mremap(ptr, size, size, MREMAP_MAYMOVE | MREMAP_DONTUNM= AP, > | ^~~~~~~~~~~~~~~~ > > > And I think the reason is due to our CI's toolchain's sys/mman.h not incl= uding > 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 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 ? Thanks -Jeff