Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp5265346rwr; Mon, 24 Apr 2023 01:09:23 -0700 (PDT) X-Google-Smtp-Source: AKy350bG+3nRVE2REXHENJwtHgRShqmiAXMg1wM43Y/NoRZFDzkt3TZnX0/fIJXJ4r4t2nikvbNT X-Received: by 2002:a05:6a00:1948:b0:63e:9e1f:6d06 with SMTP id s8-20020a056a00194800b0063e9e1f6d06mr16038793pfk.17.1682323762998; Mon, 24 Apr 2023 01:09:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682323762; cv=none; d=google.com; s=arc-20160816; b=AFysFbxzhGuikzl6vzLWi66Rw+uhIb1crVpiH2PQlmIZgYXa2ahC3cAk3RsxRYSt9/ 1cfE7ALdm1iE0ygzK/20YHkyPnWAtAZ09ZUinGZ7SL3eC7XFZFMZys0s7zndxpLxwKJL w0DxY6yRqF/eF2dKeT3/MXRPYD/AwiLZvptDE9Yjs6t/MsnVe6HZz50CUIFClIpkYSc4 f4hsH2xan8gUQkP9iYN3no1RubmVm/AhGv0qbvm72SvLhfOMDY93yQA2ybW0690uL2rF RTu0H+FgCGed1E1vgAvko5suCF9nVasck7qg4jmN6DYJ/S6sNg8dhnM0pI2L8vGjM29s N1aA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=NqY19vxQC/Z6cPgr3GJtyc0ATWeSmkq/1k9TGsj+P2M=; b=lmSydCpPn/Fha0TKzcV0ROEGnKGwWZrb+hsPvXn7XLWjLYNuKMC81gS0zfRp5SSfhE n9MpEtzl2K9fP5LYOa0Ri1ndZ1MjXllj4iQCu/cm0Tl8kjv88c8zLhDf5rsMMrBiCONx 0uzpTRfAfdYkHaoV4qepNLvGZRMcZ1qVDcjWigQvnm6b7v/JfdzIA9qE9bJ1QGSdgajc XsiPeaL9/8mQqI+9hlbTa/Z5xeHW0ALLm2ag4jbZpq+XdO6lnH8di5Ap6kwxbB3NmqQo tQHlqbEObTrhlb8oonC/2rOk9HBbfZrvTXuyZrniOq1LjMzQw/5qxmrHgKP1LzJmDGwS T/JQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w1-20020a63fb41000000b0051b83af33desi10229791pgj.246.2023.04.24.01.09.09; Mon, 24 Apr 2023 01:09:22 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231184AbjDXIBv (ORCPT + 99 others); Mon, 24 Apr 2023 04:01:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229625AbjDXIBt (ORCPT ); Mon, 24 Apr 2023 04:01:49 -0400 Received: from elvis.franken.de (elvis.franken.de [193.175.24.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 23F6F11B; Mon, 24 Apr 2023 01:01:48 -0700 (PDT) Received: from uucp (helo=alpha) by elvis.franken.de with local-bsmtp (Exim 3.36 #1) id 1pqr8r-0002pn-00; Mon, 24 Apr 2023 10:01:45 +0200 Received: by alpha.franken.de (Postfix, from userid 1000) id 3D49BC021A; Mon, 24 Apr 2023 10:01:24 +0200 (CEST) Date: Mon, 24 Apr 2023 10:01:24 +0200 From: Thomas Bogendoerfer To: Henry Willard Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/1] MIPS: Don't clear _PAGE_SPECIAL in _PAGE_CHG_MASK Message-ID: <20230424080124.GA4889@alpha.franken.de> References: <20230412212953.388185-1-henry.willard@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230412212953.388185-1-henry.willard@oracle.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE 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: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 12, 2023 at 03:29:53PM -0600, Henry Willard wrote: > In the special case where > > p = mmap(NULL, ALLOC_SIZE, PROT_READ, > MAP_PRIVATE | MAP_ANONYMOUS | MAP_POPULATE, -1, 0); > > is followed by > > rc = mprotect(p, ALLOC_SIZE, PROT_NONE); > > the _PAGE_SPECIAL bit in the page tables will be cleared by > mistake and the later unmapped operations will incorrectly > modify the struct page for the the zero page. This sequence > occurs in the madvise05 test of the Linux Test Project > suite of tests. > > This was discovered while testing an older version of the kernel > (5.4.17) on a MIPS device. Unfortunately, support for this device > is not available in newer kernels, so I can't test this with the > latest Linux kernel code. It looks like the problem exists in > newer kernels, but I can't verify it. Except for the LTP test, > this sequence of calls is probably not common. > > Passing it along in the hope it will be useful to someone. > > Signed-off-by: Henry Willard > --- > arch/mips/include/asm/pgtable-bits.h | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/arch/mips/include/asm/pgtable-bits.h b/arch/mips/include/asm/pgtable-bits.h > index 2362842ee2b5..1c576679aa87 100644 > --- a/arch/mips/include/asm/pgtable-bits.h > +++ b/arch/mips/include/asm/pgtable-bits.h > @@ -280,6 +280,7 @@ static inline uint64_t pte_to_entrylo(unsigned long pte_val) > #define __WRITEABLE (_PAGE_SILENT_WRITE | _PAGE_WRITE | _PAGE_MODIFIED) > > #define _PAGE_CHG_MASK (_PAGE_ACCESSED | _PAGE_MODIFIED | \ > - _PAGE_SOFT_DIRTY | _PFN_MASK | _CACHE_MASK) > + _PAGE_SOFT_DIRTY | _PFN_MASK | \ > + _CACHE_MASK | _PAGE_SPECIAL) > > #endif /* _ASM_PGTABLE_BITS_H */ > -- > 2.31.1 applied to mips-next. Thomas. -- Crap can work. Given enough thrust pigs will fly, but it's not necessarily a good idea. [ RFC1925, 2.3 ]