From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5F95D28DC7; Wed, 1 May 2024 08:05:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714550723; cv=none; b=NJLpnn+PWtbQpsLNhbJJc1BndKrtWoZiD1pM8dQCXJoZY0N6okw4Q8xLkUru1bXfnooT/PI4V9j0BdoKiuqPQiUAGcyxeIDS4oGpJ7hSWv86UMerEj1T8wc5dizDJbAhQg8ckTPAM5cTgCnDEJ7hwKlZ/IjPRPiQABXep3hcSic= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714550723; c=relaxed/simple; bh=2HevmY/Q4C4rLB+9s4SmfYOSFdV6Ae/J6fu9OaszjS0=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=CYCMtWxzQORBTLOn3rRuBoPWRL9i6Aj9qgHsMBmtL5qQs19PaS45F4/IiGOscT4lI/27kZ4SGBze57SDubf9UX+fvFeJTrK3LOZZ4q0d4RyCZze0nOti8MFVPUCohTpcUje+JJAnCBAnj4BsbBEY5/ehzwDBFKYGpb8N5YkBLaE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 74D8B2F4; Wed, 1 May 2024 01:05:46 -0700 (PDT) Received: from [10.57.65.146] (unknown [10.57.65.146]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B9D663F793; Wed, 1 May 2024 01:05:18 -0700 (PDT) Message-ID: Date: Wed, 1 May 2024 09:05:17 +0100 Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] arm64/mm: pmd_mkinvalid() must handle swap pmds Content-Language: en-GB To: Catalin Marinas , Will Deacon , Mark Rutland , Anshuman Khandual , Andrew Morton , Zi Yan , "Aneesh Kumar K.V" Cc: linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org References: <20240430133138.732088-1-ryan.roberts@arm.com> <171449974870.639201.3165060270571039049.b4-ty@arm.com> From: Ryan Roberts In-Reply-To: <171449974870.639201.3165060270571039049.b4-ty@arm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 30/04/2024 18:57, Catalin Marinas wrote: > On Tue, 30 Apr 2024 14:31:38 +0100, Ryan Roberts wrote: >> __split_huge_pmd_locked() can be called for a present THP, devmap or >> (non-present) migration entry. It calls pmdp_invalidate() >> unconditionally on the pmdp and only determines if it is present or not >> based on the returned old pmd. >> >> But arm64's pmd_mkinvalid(), called by pmdp_invalidate(), >> unconditionally sets the PMD_PRESENT_INVALID flag, which causes future >> pmd_present() calls to return true - even for a swap pmd. Therefore any >> lockless pgtable walker could see the migration entry pmd in this state >> and start interpretting the fields (e.g. pmd_pfn()) as if it were >> present, leading to BadThings (TM). GUP-fast appears to be one such >> lockless pgtable walker. >> >> [...] > > Applied to arm64 (for-next/fixes), thanks! It should land in 6.9-rc7. I > removed the debug/test code, please send it as a separate patch for > 6.10. Thanks Catalin! I'm guessing this will turn up in today's linux-next, so if I send the tests today and Andrew puts them straight in mm-unstable (which will goto linux-next) there is no risk that the tests are there without the fix? Or do I need to hold off until the fix is in v6.9-rc7? > > [1/1] arm64/mm: pmd_mkinvalid() must handle swap pmds > https://git.kernel.org/arm64/c/e783331c7720 > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AB9ADC4345F for ; Wed, 1 May 2024 08:05:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To: Subject:MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=xSb0K5d7Bc8shmvCiybSYoNLeYz5BoqtWwdRZ55oZHU=; b=ZvoGh86uhRM6zU nEuo3DwFqzoEcYeZLj93uo6wRMPqJeICG7lPZFJmCWEMGYfbibe9yeTRFjLuTauwoWruErAix5ejs /fT++OEJplbVDCTyXX6C4w3axUL1r9kegz1f0BCK1hnyAZQneuwsxuCKrGm7RtN4rjnWDqFOH7KtM M2hAvp5QnqlND9g5JQYc+26iHYV7HKHnmVHpowikxvBUmuB8rgw6AseCgnX6o/BkPxeQiCF0NmvIZ Esq3MH78bFMioQwGJGA1uvYuP8NLnnKwu2h8LpS6Pf1QskkWDm1jtNLEZyBPbl7EtZFeUeiXXVlHp 2BcKoy/9M8EP4wEO3IBQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s24y2-00000008p1c-0E4R; Wed, 01 May 2024 08:05:30 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s24xv-00000008p0C-1DCO for linux-arm-kernel@lists.infradead.org; Wed, 01 May 2024 08:05:28 +0000 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 74D8B2F4; Wed, 1 May 2024 01:05:46 -0700 (PDT) Received: from [10.57.65.146] (unknown [10.57.65.146]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B9D663F793; Wed, 1 May 2024 01:05:18 -0700 (PDT) Message-ID: Date: Wed, 1 May 2024 09:05:17 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] arm64/mm: pmd_mkinvalid() must handle swap pmds Content-Language: en-GB To: Catalin Marinas , Will Deacon , Mark Rutland , Anshuman Khandual , Andrew Morton , Zi Yan , "Aneesh Kumar K.V" Cc: linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org References: <20240430133138.732088-1-ryan.roberts@arm.com> <171449974870.639201.3165060270571039049.b4-ty@arm.com> From: Ryan Roberts In-Reply-To: <171449974870.639201.3165060270571039049.b4-ty@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240501_010523_474917_C2CC7F6D X-CRM114-Status: GOOD ( 12.72 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 30/04/2024 18:57, Catalin Marinas wrote: > On Tue, 30 Apr 2024 14:31:38 +0100, Ryan Roberts wrote: >> __split_huge_pmd_locked() can be called for a present THP, devmap or >> (non-present) migration entry. It calls pmdp_invalidate() >> unconditionally on the pmdp and only determines if it is present or not >> based on the returned old pmd. >> >> But arm64's pmd_mkinvalid(), called by pmdp_invalidate(), >> unconditionally sets the PMD_PRESENT_INVALID flag, which causes future >> pmd_present() calls to return true - even for a swap pmd. Therefore any >> lockless pgtable walker could see the migration entry pmd in this state >> and start interpretting the fields (e.g. pmd_pfn()) as if it were >> present, leading to BadThings (TM). GUP-fast appears to be one such >> lockless pgtable walker. >> >> [...] > > Applied to arm64 (for-next/fixes), thanks! It should land in 6.9-rc7. I > removed the debug/test code, please send it as a separate patch for > 6.10. Thanks Catalin! I'm guessing this will turn up in today's linux-next, so if I send the tests today and Andrew puts them straight in mm-unstable (which will goto linux-next) there is no risk that the tests are there without the fix? Or do I need to hold off until the fix is in v6.9-rc7? > > [1/1] arm64/mm: pmd_mkinvalid() must handle swap pmds > https://git.kernel.org/arm64/c/e783331c7720 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel