Message ID | 20230704153630.1591122-3-revest@chromium.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp1313349vqx; Tue, 4 Jul 2023 08:52:40 -0700 (PDT) X-Google-Smtp-Source: APBJJlEf4wBITcrW7zzeNJUYAilwLChzafYiqpewoDSoU1w8t52D7tMTsiYjTFFg4mykj/ONyDSe X-Received: by 2002:a37:f706:0:b0:767:4d81:469 with SMTP id q6-20020a37f706000000b007674d810469mr9366486qkj.52.1688485960156; Tue, 04 Jul 2023 08:52:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688485960; cv=none; d=google.com; s=arc-20160816; b=jesNlbj9IO8XoOj5W6gXwyvGmBsnfboqv/Uf47nUwc85tsfAKn17mB0XS6s0SHBuEK TmXKv20HQIGtzd/5rqMjYUE960AJs8YZgJiFpMuC1xK9KHbm189tuTMok/23YDLEp6QJ wHL1kuw1EBV01GxQTkliJ1kEDDxlFnaW32a8DQywbtIgoT1MV2rAdlhVlEBv83eAcXNA MWq+tSGxSf40a8g9OFrpeuVY2SSTxv7thMMudVwiEQHtncHJONbcR2L+92s6q2jlYOho m3NM1n23EUutJEZ9BwuUa33sgYrTjVN/kToQ8e81EvGK7CdkMlFa8Aw2uAiL2jvoAur2 NpBA== 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=beswSwVGAkwwt+hvsxKunV4bjZ5oFhW4HtgFlCfoMD8=; fh=qt+3dfk+I7w4O6ICPehLV2qOV3K4oyIze2E4W9KFR+E=; b=HA9+26r5FwkGRJ5SnYoGakDYIY97Crr9YK23K2dAAfcBUtEvPhGqz9wVh18vMWc4Tp yuehMqw+rswtNWk6iyy5GkD2m3HSQFODD3j7GkSR3dCub8qTMXiP6vN6153b6kRIXJLy QTvDNkui7NFNvouNZNDnrhboFf2USL3XNJKa2UyxN1nNcMs+hnaE7F8zc83wUwZKZAXs aFvgxMbThYmidJGARkWp5zNYP1D6mPFVJ1/T/wo9E8fbeVqO4MWW4XkT/4p6VlBlOSzz 1P2Ok1KLecMhjtW9zxpzaxka9F6uLKGSY+zXmLHJG+aZ8grxriU4ATTc8oZ4G20x5DNw v15Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=im9v3tz+; 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 y27-20020a056a00181b00b0068273fe79fdsi8203770pfa.163.2023.07.04.08.52.27; Tue, 04 Jul 2023 08:52:40 -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=im9v3tz+; 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 S230255AbjGDPhP (ORCPT <rfc822;tebrre53rla2o@gmail.com> + 99 others); Tue, 4 Jul 2023 11:37:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230300AbjGDPhM (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 4 Jul 2023 11:37:12 -0400 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B216F1B2 for <linux-kernel@vger.kernel.org>; Tue, 4 Jul 2023 08:37:10 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-314313f127fso3214290f8f.1 for <linux-kernel@vger.kernel.org>; Tue, 04 Jul 2023 08:37:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1688485029; x=1691077029; 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=beswSwVGAkwwt+hvsxKunV4bjZ5oFhW4HtgFlCfoMD8=; b=im9v3tz+dDQKllRZMfAl2CXof/kWuglwbcaU6I+/SM3taNN9W0TM7sI67nnkl3lDSX 9evAJPoxo2Tv50rEz5lihIj5frPU3Hxo1Et5ixkKvTNtQhQyTA6xiirfJK5+I7SVGHC2 vJhjhWvhzJTSHRPd/yK9QTQbknde3VwTLbMWE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688485029; x=1691077029; 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=beswSwVGAkwwt+hvsxKunV4bjZ5oFhW4HtgFlCfoMD8=; b=MpG+8JekEMy0pHYzBEZv+2XuIVtA/n0sm91DryhRltOz/JaIUifUDLq0lSi3CccjLd 7EwsoCsAcKyxl/m36SiyVz9UWyKUaEnjcmc7pS0i6bKiXgI1BPA4hVDJl56s6OKP7Vp4 xNAbvah6h3QDzb4xckM115a7WAtDUgqTg34yCutXbHct0u4RlUNkAJUmNVInZRtB7nLi U8djlMy2vH16JaBjDcorYbth385YLowGNqv4xOeOyn9VVRpki9tb8ZBCCKfwXjktWmZG zTcStHtqZuhG2q9l2UrC8WA5+BgyqcTfTRtMA1POhe3fsUg1T4amwBwKuagNV2Xz/QER fP9w== X-Gm-Message-State: ABy/qLY0bet3RijTbkuXboK2VQkt2DWkRiMZywCx+d69CQHx1qc2GmNR IKERAT2CrOV3uBdJnSWAC7Ppt+jRI/WTJy8A3vs= X-Received: by 2002:a5d:4950:0:b0:313:f7f1:e34c with SMTP id r16-20020a5d4950000000b00313f7f1e34cmr11728009wrs.60.1688485028942; Tue, 04 Jul 2023 08:37:08 -0700 (PDT) Received: from revest.zrh.corp.google.com ([2a00:79e0:9d:6:99b2:81bb:8407:5369]) by smtp.gmail.com with ESMTPSA id b2-20020adfde02000000b0030c4d8930b1sm28538709wrm.91.2023.07.04.08.37.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jul 2023 08:37:08 -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, broonie@kernel.org, szabolcs.nagy@arm.com, kpsingh@kernel.org, gthelen@google.com, toiwoton@gmail.com, Florent Revest <revest@chromium.org> Subject: [PATCH v3 2/5] kselftest: vm: Fix mdwe's mmap_FIXED test case Date: Tue, 4 Jul 2023 17:36:26 +0200 Message-ID: <20230704153630.1591122-3-revest@chromium.org> X-Mailer: git-send-email 2.41.0.255.g8b1d071c50-goog In-Reply-To: <20230704153630.1591122-1-revest@chromium.org> References: <20230704153630.1591122-1-revest@chromium.org> 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, 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?1770505854125919652?= X-GMAIL-MSGID: =?utf-8?q?1770505854125919652?= |
Series |
MDWE without inheritance
|
|
Commit Message
Florent Revest
July 4, 2023, 3:36 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> Reviewed-by: David Hildenbrand <david@redhat.com> Fixes: 4cf1fe34fd18 ("kselftest: vm: add tests for memory-deny-write-execute") --- tools/testing/selftests/mm/mdwe_test.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
Comments
On 04/07/2023 16:36, Florent Revest 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> > Reviewed-by: David Hildenbrand <david@redhat.com> > Fixes: 4cf1fe34fd18 ("kselftest: vm: add tests for memory-deny-write-execute") I'm currently working to get all the mm selftests running (and ideally passing!) on arm64 and saw these same spurious failures. Thanks for the patch! Reviewed-by: Ryan Roberts <ryan.roberts@arm.com> Tested-by: Ryan Roberts <ryan.roberts@arm.com> > --- > tools/testing/selftests/mm/mdwe_test.c | 9 +++------ > 1 file changed, 3 insertions(+), 6 deletions(-) > > 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)
On Tue, Jul 04, 2023 at 05:36:26PM +0200, Florent Revest 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> > Reviewed-by: David Hildenbrand <david@redhat.com> > Fixes: 4cf1fe34fd18 ("kselftest: vm: add tests for memory-deny-write-execute") Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
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)