Message ID | 20230504170942.822147-3-revest@chromium.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp483775vqo; Thu, 4 May 2023 10:16:52 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5oetT21WqkGX0LMTy7vFQBo1a8HDPo5V4al965QbuPXOjVsFMOVHjBYYnr1LR0Ls3FphGU X-Received: by 2002:a05:6a21:7895:b0:f0:5a5b:7bea with SMTP id bf21-20020a056a21789500b000f05a5b7beamr3395486pzc.61.1683220612588; Thu, 04 May 2023 10:16:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683220612; cv=none; d=google.com; s=arc-20160816; b=yK45ff8UWiuVLAQvtwbzFEjRBpe6AyuKYZYG53AkNIgPJk+yYfwL19guT/5YIqWtve oQ48affyq81IwB+Rxi6JovtJFDI8eQ5jFuGjO7T8G9Yq235P0TSaKkLNMLV7ALryCRyh dwpTRAPcsAJMUnk9rdV9cccZnVJFJwmAaf9Mi8Iuzf1OEnfrwoRI1HgKZkwh6bTzeGyI F+GeYqJWxLRpo6v/FSDKIKanYeBhmgLE+cm9J7VAmJBewFOowT6j6FIe1uVW7FWUpvmV gtK9e0sJGK6zZwGAs+PglAQqqG9fYfAinhrzPvNKfzsJGOgKovUOX+BYBwS4VSvU6LoW R23g== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=P3QYW4dMv2fssbqcmbr7kPwxf8O4yB5nA1oU7n1NpuI=; b=qlBoGg/j5OzQusTvZtJHJQk2e0AI0ai0Syqh10aeJ6NYr3EoeYnxtya4tdzcWqzuUB qQeni+yyfLFGr5g5+j2LAAjzg2YKt80J79vmBcOEz2JYkevcqWYZOHKa/HXEQLQ/RlBI dJbrvu258QGBAYWhhHjRlFRZUIj+69Y26x6yYScPZz2UkApQjyEdlzGYa6SOVyykRPWa K/qfEVjSjD4UeNn3YkY0DBlrRY9Da8CLRHP9CtJiH0xTchKHtrQdOCfbmNCxJGV5DgHn 4mI168LRhkVHGuYjqKZ07awPhrcH5ovO5cTVz4mgYx82LLgB1tk7/TA6vGwycXLBrEG/ yJ3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=D7x4fa+X; 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=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 33-20020a630d61000000b0052c6489dc91si3916519pgn.105.2023.05.04.10.16.36; Thu, 04 May 2023 10:16:52 -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=@chromium.org header.s=google header.b=D7x4fa+X; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229822AbjEDRKS (ORCPT <rfc822;b08248@gmail.com> + 99 others); Thu, 4 May 2023 13:10:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229714AbjEDRKO (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 4 May 2023 13:10:14 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0F8940F5 for <linux-kernel@vger.kernel.org>; Thu, 4 May 2023 10:10:12 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-3f4000ec71dso5859385e9.2 for <linux-kernel@vger.kernel.org>; Thu, 04 May 2023 10:10:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1683220211; x=1685812211; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=P3QYW4dMv2fssbqcmbr7kPwxf8O4yB5nA1oU7n1NpuI=; b=D7x4fa+X6qIEzk2IbZ+D0fz5GhTgakeCXE+E81V7L4crHzOUgGASrNmikW+8iJh6Lp M1n6L4lENTLNeOLhBvCOq7Kq+mXd93sRdO8S61OdMearQDPJkCAv7Q+7Bh7n2mXiDfYh UHQAZtPHV+bXdXq/fi6Bp3nU8BvBD8blOwy0E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683220211; x=1685812211; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=P3QYW4dMv2fssbqcmbr7kPwxf8O4yB5nA1oU7n1NpuI=; b=V/TMsV1WulG7aZDtECXvG5RR2zLZfUNPdYncgt8jIkZR447AxrGGsEaKKnb6KCSJFN vbIXWV9m0dw9FS09a7/O7R1EWkjVU7p5XlVrEKDfIGw2YOeW8cK810Bp1Xmfwn6l/jON bdq1NbcS5zxt6haTf1cRZ8PfQ/Hpyo+722NTrNGePU8EdJDNrF+VkUGyxOO0vzD1UGxW L6uE2JzCSoq0RHfewwq9Nh7DkNjNGZEJL9nxKZnTJTNPdAexCHWsG380htY92wfzeuL2 cGtDGJ1urnB8AYSOgb06JhFh3sptk/+12avnk0FjHiXA0+GTkq0TY1yllFpcVd+ILgoc BTiw== X-Gm-Message-State: AC+VfDwakvdgZ1KGCuEH8GMAdpSVU8RBV8zEHSByCR1dsqQGsoAeOWjA qB2TeoLrITT1Qwte+L3vtLRD+tuoRKkmZYwaY+s= X-Received: by 2002:a1c:740d:0:b0:3ef:6819:b2ad with SMTP id p13-20020a1c740d000000b003ef6819b2admr265910wmc.37.1683220210796; Thu, 04 May 2023 10:10:10 -0700 (PDT) Received: from revest.zrh.corp.google.com ([2a00:79e0:9d:6:c740:f74d:132c:ca99]) by smtp.gmail.com with ESMTPSA id q3-20020a1cf303000000b003f3157988f8sm5447895wmq.26.2023.05.04.10.10.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 May 2023 10:10:10 -0700 (PDT) From: Florent Revest <revest@chromium.org> To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: akpm@linux-foundation.org, catalin.marinas@arm.com, anshuman.khandual@arm.com, joey.gouly@arm.com, mhocko@suse.com, keescook@chromium.org, david@redhat.com, peterx@redhat.com, izbyshev@ispras.ru, nd@arm.com, broonie@kernel.org, szabolcs.nagy@arm.com, Florent Revest <revest@chromium.org> Subject: [PATCH 2/4] kselftest: vm: Fix mdwe's mmap_FIXED test case Date: Thu, 4 May 2023 19:09:40 +0200 Message-ID: <20230504170942.822147-3-revest@chromium.org> X-Mailer: git-send-email 2.40.1.495.gc816e09b53d-goog In-Reply-To: <20230504170942.822147-1-revest@chromium.org> References: <20230504170942.822147-1-revest@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764984736643404933?= X-GMAIL-MSGID: =?utf-8?q?1764984736643404933?= |
Series |
MDWE without inheritance
|
|
Commit Message
Florent Revest
May 4, 2023, 5:09 p.m. UTC
I checked with the original author, the mmap_FIXED test case wasn't
properly tested and fails. Currently, it maps two consecutive (non
overlapping) pages and expects the second mapping to be denied by MDWE
but these two pages have nothing to do with each other so MDWE is
actually out of the picture here.
What the test actually intended to do was to remap a virtual address
using MAP_FIXED. However, this operation unmaps the existing mapping and
creates a new one so the va is backed by a new page and MDWE is again
out of the picture, all remappings should succeed.
This patch keeps the test case to make it clear that this situation is
expected to work.
Signed-off-by: Florent Revest <revest@chromium.org>
---
tools/testing/selftests/mm/mdwe_test.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
Comments
On Thu, May 4, 2023 at 7:10 PM Florent Revest <revest@chromium.org> wrote: > > I checked with the original author, the mmap_FIXED test case wasn't > properly tested and fails. Currently, it maps two consecutive (non > overlapping) pages and expects the second mapping to be denied by MDWE > but these two pages have nothing to do with each other so MDWE is > actually out of the picture here. > > What the test actually intended to do was to remap a virtual address > using MAP_FIXED. However, this operation unmaps the existing mapping and > creates a new one so the va is backed by a new page and MDWE is again > out of the picture, all remappings should succeed. > > This patch keeps the test case to make it clear that this situation is > expected to work. > > Signed-off-by: Florent Revest <revest@chromium.org> Ah, snap, I hit send to fast and forgot to add: Fixes: 4cf1fe34fd18 ("kselftest: vm: add tests for memory-deny-write-execute") I will do it in the next iteration (surely there'll be other things to fix... :))
diff --git a/tools/testing/selftests/mm/mdwe_test.c b/tools/testing/selftests/mm/mdwe_test.c index d0954c657feb..91aa9c3099e7 100644 --- a/tools/testing/selftests/mm/mdwe_test.c +++ b/tools/testing/selftests/mm/mdwe_test.c @@ -168,13 +168,10 @@ TEST_F(mdwe, mmap_FIXED) self->p = mmap(NULL, self->size, PROT_READ, self->flags, 0, 0); ASSERT_NE(self->p, MAP_FAILED); - p = mmap(self->p + self->size, self->size, PROT_READ | PROT_EXEC, + /* MAP_FIXED unmaps the existing page before mapping which is allowed */ + p = mmap(self->p, self->size, PROT_READ | PROT_EXEC, self->flags | MAP_FIXED, 0, 0); - if (variant->enabled) { - EXPECT_EQ(p, MAP_FAILED); - } else { - EXPECT_EQ(p, self->p); - } + EXPECT_EQ(p, self->p); } TEST_F(mdwe, arm64_BTI)