Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5524206rwb; Tue, 22 Nov 2022 00:55:11 -0800 (PST) X-Google-Smtp-Source: AA0mqf4Ja0kc5m1oHuIrCYL0odqaINzfxYQUBglRcu7jyjV2BMG3K9n32FgolN6WvlXVk4V57tAY X-Received: by 2002:a17:906:a107:b0:77f:9082:73c7 with SMTP id t7-20020a170906a10700b0077f908273c7mr3136863ejy.517.1669107311034; Tue, 22 Nov 2022 00:55:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669107311; cv=none; d=google.com; s=arc-20160816; b=kUH9Eufq/5ZOMNjE1gYHbFykmFgEGcd13LK0IyT65Nrlg1vZ2Yh27lMcvjzHv+MYIs nqGNiIKuE+5vHNAGGBCRi9K/kjwZtL2wh/rziFHjowTXr85wcjEpF8S2yrkqPREkuI8I Gtek43W0IDsl0uevx3SJHpnkbKG3TcC5rQBf8UZYD6uiMfGUm1GLqxK/GNI6CaABiSw5 vFFHhYxl0M/7sAqaj+YPd+VZ6JYQfXBMquSdoVoVqdjxQwz7WWUdFFzYg3CGGxcGH7OQ C96ZG7mpuuD+HlfUFKrmTuVBOaqrJsfjkRYV5F9JUMn15ZkmrOyJBXFI1KJVqrOTiAHB IIkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=dsRVmWtdSVFs2/ijaCSKTwrMLuPt+I6uXutHwLrG2wo=; b=iCg3RxlnAnAUT1mHqT9faTXsmsRDRKNmciOXh2c7siwtacVk8sx2ta/uUMzUMWt/wd GAR3scHK2b34aLJGb/HNnQBUicLWpPNCRHoqDGtexwcx6PY0hT6xxfGOxEWOaMew5Qi6 Y3dbpwpKGdG0M20tHoHlwHSFROMascTG1NEa+dQzQDb07VlERc2fqvehVBSEouHSHVYe WYsUfHGSz1e71LkP14wGr8jgdSOa/8UJ+KZQXagnyeVKE/uFlnPLnimJh6GWA8gS7qK2 rl+U3lRNmujtSlLE2ZVE/bLS0iTeAgvCuI3eGyQEecOOeySKLaJa83uh2FywAIjXIF6e f5+g== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id xi5-20020a170906dac500b0078db70cc9b8si12206884ejb.606.2022.11.22.00.54.41; Tue, 22 Nov 2022 00:55:11 -0800 (PST) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232429AbiKVIN0 (ORCPT + 91 others); Tue, 22 Nov 2022 03:13:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232371AbiKVINY (ORCPT ); Tue, 22 Nov 2022 03:13:24 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CBACE1B78C for ; Tue, 22 Nov 2022 00:13:22 -0800 (PST) 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 AC6F01FB; Tue, 22 Nov 2022 00:13:28 -0800 (PST) Received: from [10.162.40.16] (unknown [10.162.40.16]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 636BE3F73D; Tue, 22 Nov 2022 00:13:20 -0800 (PST) Message-ID: <879e561c-e834-196c-b9c5-6e44ac2c0296@arm.com> Date: Tue, 22 Nov 2022 13:43:17 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: [PATCH] arm64/mm: Intercept pfn changes in set_pte_at() Content-Language: en-US To: Will Deacon Cc: linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com, Mark Rutland , Andrew Morton , linux-kernel@vger.kernel.org References: <20221116031001.292236-1-anshuman.khandual@arm.com> <20221118141317.GF4046@willie-the-truck> From: Anshuman Khandual In-Reply-To: <20221118141317.GF4046@willie-the-truck> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE 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 11/18/22 19:43, Will Deacon wrote: > On Wed, Nov 16, 2022 at 08:40:01AM +0530, Anshuman Khandual wrote: >> Changing pfn on a user page table mapped entry, without first going through >> break-before-make (BBM) procedure is unsafe. This just updates set_pte_at() >> to intercept such changes, via an updated pgattr_change_is_safe(). This new >> check happens via __check_racy_pte_update(), which has now been renamed as >> __check_safe_pte_update(). >> >> Cc: Catalin Marinas >> Cc: Will Deacon >> Cc: Mark Rutland >> Cc: Andrew Morton >> Cc: linux-arm-kernel@lists.infradead.org >> Cc: linux-kernel@vger.kernel.org >> Signed-off-by: Anshuman Khandual >> --- >> This applies on v6.1-rc4 >> >> arch/arm64/include/asm/pgtable.h | 8 ++++++-- >> arch/arm64/mm/mmu.c | 8 +++++++- >> 2 files changed, 13 insertions(+), 3 deletions(-) > > I remember Mark saying that BBM is sometimes violated by the core code in > cases where the pte isn't actually part of a live pgtable (e.g. if it's on > the stack or part of a newly allocated table). Won't that cause false > positives here? Could you please elaborate ? If the pte is not on a live page table, then pte_valid() will return negative on such entries. So any update there will be safe. I am wondering, how this change will cause false positives which would not have been possible earlier.