Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2987509rwb; Fri, 16 Dec 2022 08:47:37 -0800 (PST) X-Google-Smtp-Source: AMrXdXsCwSk3Igex1PMeyUN/+y1b/MAzvZeIg4J1AtO8fveHBAVsn1Kd4U1xVjbugqXmr9/TZutL X-Received: by 2002:a05:6a21:7897:b0:af:a276:2f94 with SMTP id bf23-20020a056a21789700b000afa2762f94mr10456538pzc.35.1671209257295; Fri, 16 Dec 2022 08:47:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671209257; cv=none; d=google.com; s=arc-20160816; b=tapPVMAZPu2W+MHgkGZkiQpTNGl3IrbB0CDpS7M6aBTSC0eFdG0V0P+FUwJQHuP+fZ sHoFrTzdzUguMFLs565hlWV1lt53ZanAnNKJAuxRAN0Nagq1Xaz3wwcBW2D5VAQ+pLBw qczoxMzCsenLgbmHN463WUAaJjbBGXp7S8aGby8BKpIX2qm1i8UPoNQ1ZSsDAaMRVspO f7BNlje3P4B5xXgIJyKh/xyHk2jTpCoLB5reIWzEIHwkh0jztUtCniaNEIhjJ+NRtNoL fDsYpt2TrDZg9LdDnjcvk6JrbdNLlw5AzLOme9VEtuTaFy9faCvtLCm52EbGYzNRuMjH wuQA== 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 :organization:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature; bh=qQVNpA1uebmeJDop3AawgUtcYkrEx880mhk59ps+M7g=; b=TTmPa8fqMM/AZbiyOZ2AcCgaJl3OH7rTN5C0xfzFaSq1QK0rrar5b4c17nIYyH1wUz 7bsTTl3Bvr4cTpmBR/W6IurOHJd2hRUVNzRPjz9q6ryRLJciyLjgimPdFc7EuwsdIlPd CDWyPuh5kPO5ohpXCU9WiDnO0TTQAWFFhGebEnZJWljNmsaV3UFik7vhkD7fFeGVuRWp B0955KWlp91ZFZgAgHhn1C4hZMTb/exCHI0D7ChDKn++4n09/4zh3Jb2AalRI0mWFg42 JcsHghRit2+m9Q08FT4KYNbxvCYhtlvsRiGaWFozYZIBAG5A+H6L1+IZO8tpKBzcXMFO F6Ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Q7Pa2dYm; 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=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e4-20020a635004000000b0046f583c8c4asi3034028pgb.315.2022.12.16.08.47.28; Fri, 16 Dec 2022 08:47:37 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Q7Pa2dYm; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231646AbiLPQHx (ORCPT + 68 others); Fri, 16 Dec 2022 11:07:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231277AbiLPQHK (ORCPT ); Fri, 16 Dec 2022 11:07:10 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4167B102F for ; Fri, 16 Dec 2022 08:04:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671206651; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qQVNpA1uebmeJDop3AawgUtcYkrEx880mhk59ps+M7g=; b=Q7Pa2dYmCQ4J6KzXbLRpRQBfgSqWxrTGP4r67SS4LpDemWyaI0D1u7+7c4ZUA2wTqZZOUj rxO58f4/44OiiNdp+1VgE13dfHaJa3Ra2PeE0NOB4d5aDp5/iobgPcEvsBECG8j2isLh8o 6gAozYdqwNX1g+cdQS346MDx9X3VfMk= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-232-9i42XGBuPCO_v7JKZFyOfw-1; Fri, 16 Dec 2022 11:04:10 -0500 X-MC-Unique: 9i42XGBuPCO_v7JKZFyOfw-1 Received: by mail-wm1-f69.google.com with SMTP id r129-20020a1c4487000000b003d153a83d27so1401053wma.0 for ; Fri, 16 Dec 2022 08:04:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=qQVNpA1uebmeJDop3AawgUtcYkrEx880mhk59ps+M7g=; b=KxeVNxzH98R/8cZXIEEgxCegry9a5hPXdfU9f1uNSJuebdy7E5SmGxbIWohQpGEH3H 5O6zO6YPEt9tJsfgwYyGTJmwrJuRZygJCgCoJ4cfykRzDsHcpxHItZ2Yf6dYQmxBSAuW uxYDPBYBV0C/qK1DO2gdIAozoXN8ctduyOgOAFpbSNB47Kcudhdkh95hhwkEL5ILPHtV NDYMWd6XZN/G3buemVHfULsEP8IzFTXaJVtjlxH2Q4v5kD0JWhC36p7+Z2hYpcAlxGQO vWZewhe01n4J8eYSs66jGGipqJtytO5JQm5AsmevYFTt9XTT5oTRPV1XStsUHNc2cFs/ T5HA== X-Gm-Message-State: ANoB5pnjPTm8BVWWNdXtXdDnMqUFE3R36gz43hrYa6PPrABzdqyMSJ6n vd9Wm2jeJouBXJTpkBzBhSkemgrCdHAFGIzTjkIw9tgVY9FLWXjQxe0N52MTs+15p8+lFd1LkV9 kDA3rQZ8c7GXWw7SUhHpH1oJi X-Received: by 2002:a05:600c:1da9:b0:3c7:a5:610e with SMTP id p41-20020a05600c1da900b003c700a5610emr26397879wms.27.1671206648940; Fri, 16 Dec 2022 08:04:08 -0800 (PST) X-Received: by 2002:a05:600c:1da9:b0:3c7:a5:610e with SMTP id p41-20020a05600c1da900b003c700a5610emr26397851wms.27.1671206648647; Fri, 16 Dec 2022 08:04:08 -0800 (PST) Received: from ?IPV6:2003:cb:c71c:3900:7211:d436:8d8b:531c? (p200300cbc71c39007211d4368d8b531c.dip0.t-ipconnect.de. [2003:cb:c71c:3900:7211:d436:8d8b:531c]) by smtp.gmail.com with ESMTPSA id u9-20020a05600c00c900b003cf37c5ddc0sm2914316wmm.22.2022.12.16.08.04.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 16 Dec 2022 08:04:08 -0800 (PST) Message-ID: <2eb1cc61-01ec-10c2-e81f-f4325ca7b03f@redhat.com> Date: Fri, 16 Dec 2022 17:04:06 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.1 Subject: Re: [PATCH 2/2] mm: Fix a few rare cases of using swapin error pte marker Content-Language: en-US To: Peter Xu , linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Andrea Arcangeli , Pengfei Xu , Nadav Amit , Andrew Morton , Miaohe Lin , Huang Ying References: <20221214200453.1772655-1-peterx@redhat.com> <20221214200453.1772655-3-peterx@redhat.com> From: David Hildenbrand Organization: Red Hat In-Reply-To: <20221214200453.1772655-3-peterx@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,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 14.12.22 21:04, Peter Xu wrote: > This patch should harden commit 15520a3f0469 ("mm: use pte markers for swap > errors") on using pte markers for swapin errors on a few corner cases. > > 1. Propagate swapin errors across fork()s: if there're swapin errors in > the parent mm, after fork()s the child should sigbus too when an error > page is accessed. > > 2. Fix a rare condition race in pte_marker_clear() where a uffd-wp pte > marker can be quickly switched to a swapin error. > > 3. Explicitly ignore swapin error pte markers in change_protection(). > > I mostly don't worry on (2) or (3) at all, but we should still have them. > Case (1) is special because it can potentially cause silent data corrupt on > child when parent has swapin error triggered with swapoff, but since swapin > error is rare itself already it's probably not easy to trigger either. > > Currently there is a priority difference between the uffd-wp bit and the > swapin error entry, in which the swapin error always has higher > priority (e.g. we don't need to wr-protect a swapin error pte marker). > > If there will be a 3rd bit introduced, we'll probably need to consider a > more involved approach so we may need to start operate on the bits. Let's > leave that for later. > > This patch is tested with case (1) explicitly where we'll get corrupted > data before in the child if there's existing swapin error pte markers, and > after patch applied the child can be rightfully killed. > > We don't need to copy stable for this one since 15520a3f0469 just landed as > part of v6.2-rc1, only "Fixes" applied. > > Fixes: 15520a3f0469 ("mm: use pte markers for swap errors") > Signed-off-by: Peter Xu Acked-by: David Hildenbrand -- Thanks, David / dhildenb