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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3C97EC4332F for ; Fri, 16 Dec 2022 16:04:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D21AE8E0007; Fri, 16 Dec 2022 11:04:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CD1E48E0002; Fri, 16 Dec 2022 11:04:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B99FE8E0007; Fri, 16 Dec 2022 11:04:14 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id AB3C08E0002 for ; Fri, 16 Dec 2022 11:04:14 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 732538114F for ; Fri, 16 Dec 2022 16:04:14 +0000 (UTC) X-FDA: 80248641228.16.6A4C46D Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf29.hostedemail.com (Postfix) with ESMTP id 03A1612002A for ; Fri, 16 Dec 2022 16:04:11 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Q7Pa2dYm; spf=pass (imf29.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1671206652; h=from:from:sender: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:dkim-signature; bh=qQVNpA1uebmeJDop3AawgUtcYkrEx880mhk59ps+M7g=; b=XlegJJVJcnjt7NnXqDbGG7/5XjmeDrslaq6u21RP7emJTVk1p3hxodKLkrxFgFXwa+Wnil h/U5UVEAkYRz9s3inqTCzIqif6gziqdqXBr6KD0H4S/2nV/PETMxYkcUMuuuHbosYfEoxW V/RqwW09JqTuKc0Gdx6jDWsXECDFKKI= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Q7Pa2dYm; spf=pass (imf29.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1671206652; a=rsa-sha256; cv=none; b=zXT9cCxRifqbO1eYwG9XFJXCe4Vtx7FzAPXwgpx4vlVvaZMFatfpJa0LJnAIEEbqNZiZR0 hQIgmUPu+/HE93o0kz9CDYVsEPPYYT53rN8rf6XaDnO896q/+Ezw4dLWjIA47oQoDHjff/ 29LQJbHNQiNjZSAkyp7IMtE7Zu/SUW8= 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-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-250-WFu1J-PdNTG8caWAkDUjAQ-1; Fri, 16 Dec 2022 11:04:10 -0500 X-MC-Unique: WFu1J-PdNTG8caWAkDUjAQ-1 Received: by mail-wm1-f71.google.com with SMTP id c187-20020a1c35c4000000b003cfee3c91cdso1377527wma.6 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=LdednuPXKXEYYx35e3mQ5fsqBltQuXlBTuTpO7+d0/cG5jZU7JRmkvJg2BHAfhj+hx i9S0Ts5CERhZNbzh/j3tBbCpW31j1dB2LO6gCWeKrE+nMJAaqzvBx7iZfwjVviV/OmhO 5B58gTI1gE3Tb9bkBrsGN9fG0Kfgz59QkJ9+ydS+PlpLG/9P3MRCg1GvNNP/rmJAE6PU Tx8SVCqfVQrha7xtAUNWQDq6umlokVLPHHLNKpV4oplOZOdUUqLX/a5bdoNCz9zW8co5 puWX6t6xAtaDmVehP8DLMhZKAtNpAH9kYlQQ8P6NAmZjX28nmmclVpfOsoL85pC2hY93 RvEw== X-Gm-Message-State: ANoB5plUNSEphd7UwCwTMNSKa8CfkEe0R0o14KADJIMNKNjgKxwBuPnQ cC6yDhGlgSSdEVCWpzYqPIUmvPdRIBblhyu6GGpMd6R9lVupUGSA1OC/67II+8+0cKaJM3xkqqb /Vz/6eC1Yxj8= X-Received: by 2002:a05:600c:1da9:b0:3c7:a5:610e with SMTP id p41-20020a05600c1da900b003c700a5610emr26397884wms.27.1671206648941; Fri, 16 Dec 2022 08:04:08 -0800 (PST) X-Google-Smtp-Source: AA0mqf5FXoyyoojkPA8DSBV7JMHnDUCdo6rCxiGpo8VsADBIE2hqSMxjc7E22yI7uL5rmmTlLo5q6w== 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 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> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Stat-Signature: iomkddo6a3qo586pzsxdz3cte9kgs56z X-Rspam-User: X-Rspamd-Queue-Id: 03A1612002A X-Rspamd-Server: rspam06 X-HE-Tag: 1671206651-343681 X-HE-Meta: U2FsdGVkX19KIHBb6cClrMXidMDKmMG1cH1sVfpq4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bJfA01iX93DG0W/0HVr4xwwXauG4euciKZUJ9AR7CtZ41YeVyKalmXbFHmjMJ15QGcQl/rVTfPg1ypZ8ChkHwBEsbqQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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