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 D28DDC433EF for ; Fri, 22 Jul 2022 13:59:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 49DE66B0074; Fri, 22 Jul 2022 09:59:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 44C6A6B0075; Fri, 22 Jul 2022 09:59:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2EE1B8E0001; Fri, 22 Jul 2022 09:59:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 2208D6B0074 for ; Fri, 22 Jul 2022 09:59:08 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id EC21340CE3 for ; Fri, 22 Jul 2022 13:59:07 +0000 (UTC) X-FDA: 79714892334.24.215BBF3 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf19.hostedemail.com (Postfix) with ESMTP id 6BD261A0090 for ; Fri, 22 Jul 2022 13:59:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1658498347; 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=Lo6SGQXmx0XZ7ARbkws6vPSxZjv+F2D6pTsFATwYheI=; b=TtRiW2RTsFQDd8eB3nos88LAG0nqFP3JACuKsA65tASh+e2r/78E1UHE3ANmuTF9jvnAJ/ NicOlI+7+gVZuoISzYDxhOuR+JblxgefLsfGR3vGDZ184htC/6cZDAClGOY0dWPOoUx1Oa 0tqBWEhkXBa+7uRMN6nA6QQdaEVqnXw= 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.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-339-VW0gUdR3NDCs-FQQ_Sm2Dg-1; Fri, 22 Jul 2022 09:59:05 -0400 X-MC-Unique: VW0gUdR3NDCs-FQQ_Sm2Dg-1 Received: by mail-wm1-f71.google.com with SMTP id c62-20020a1c3541000000b003a30d86cb2dso4481985wma.5 for ; Fri, 22 Jul 2022 06:59:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:organization:in-reply-to :content-transfer-encoding; bh=Lo6SGQXmx0XZ7ARbkws6vPSxZjv+F2D6pTsFATwYheI=; b=RjjjjjPiz0xUd8YUpIAXgHLk+ODvUi23f/jM5SSPGbHFT1+bNJcn8CBCuPe3fXcPSp fye7WqTGKBwHiJ4vc5kSx9hhEvOor4dkGuyRq7V7kWzNf85EQP5nf20Uc+QnSZcbLpyG AwQwAT187xtVr8/Hv0XMqXIeT1J+ZEGGknN46W6OY+fbmOcDsrqBd5z48JLLYDeL+1LW 2iOG2Ka99eTXFXbVfCrt4GlI4oG4NCFUdV7njQSIrLGTre8btL8aDPPH84gYGdcRZlZm qolW/azix2mflV5Ntz1uIhcP4QtAVYnMcPOJvq8hK2+QrjLUMlLhYS3kkQ8iU5G4E0Cz Yr1A== X-Gm-Message-State: AJIora9b4wdp44TShJPjvhFvkg1fQ1QMYUHSlH/ow0fQnnb12EuBve3J MCANY8plqtNWjSpGKE+36ZLtTYWm86UYIvdIRgAn6Z1La00Y78cRtsIGzxH7UaD64AWFAEB8SQQ PF1/Lu4p2LqU= X-Received: by 2002:a05:600c:5120:b0:3a3:2ae4:fb20 with SMTP id o32-20020a05600c512000b003a32ae4fb20mr596063wms.81.1658498344669; Fri, 22 Jul 2022 06:59:04 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uhOwqaacXSfkLjD4scuuFNVK8E37fO4Ywor2Eut1iuhqnyL2BRE9K+6lyi6PeVntZPDETsMg== X-Received: by 2002:a05:600c:5120:b0:3a3:2ae4:fb20 with SMTP id o32-20020a05600c512000b003a32ae4fb20mr596048wms.81.1658498344325; Fri, 22 Jul 2022 06:59:04 -0700 (PDT) Received: from ?IPV6:2003:cb:c707:cb00:cd6b:7964:cc7d:b0e6? (p200300cbc707cb00cd6b7964cc7db0e6.dip0.t-ipconnect.de. [2003:cb:c707:cb00:cd6b:7964:cc7d:b0e6]) by smtp.gmail.com with ESMTPSA id f7-20020a1c3807000000b003a3080eacb9sm5196061wma.24.2022.07.22.06.59.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 22 Jul 2022 06:59:04 -0700 (PDT) Message-ID: Date: Fri, 22 Jul 2022 15:59:03 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH v3 1/3] mm/mprotect: Fix soft-dirty check in can_change_pte_writable() To: Peter Xu Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Nadav Amit , Andrew Morton , Andrea Arcangeli References: <20220721183338.27871-1-peterx@redhat.com> <20220721183338.27871-2-peterx@redhat.com> From: David Hildenbrand Organization: Red Hat In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1658498347; a=rsa-sha256; cv=none; b=PmRKABQavvkN+nJXmuNwT5+/hXFEHmd2Gk7NjDAKBb8Hj2fbajZ9DMIgRrBkUQ5HPeyLzZ cRZl27dxVlY6lOyPJFLoCBxjYCuc1My7eEzmiTubA0GUJiuvuJfW9qxtSbc7kWctbnalkm Ypj7rWAwFEB1tfsU60kOarpNALZvGWs= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=TtRiW2RT; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf19.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.129.124) smtp.mailfrom=david@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1658498347; 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=Lo6SGQXmx0XZ7ARbkws6vPSxZjv+F2D6pTsFATwYheI=; b=zIJW5tTJC1bo+7z/5n9Zx5kr4bsoGSqx84U2y8+aAesvfgIXx2N9p1OBWAYQ/p7IGoMJfg x4TsG15+PzdADKgn2hd7Rjm9D3gQvag2mjFPjudg7pC+jXEhOkGBXB5xPegm9JEK/2+qef Jp/a0Hoi/4c4BfxvU2wCumRm1H9RUfw= Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=TtRiW2RT; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf19.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.129.124) smtp.mailfrom=david@redhat.com X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 6BD261A0090 X-Stat-Signature: 5ii4bgqxzfyphrybf6p6udjfja6dccez X-Rspam-User: X-HE-Tag: 1658498347-995274 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 22.07.22 15:51, Peter Xu wrote: > On Fri, Jul 22, 2022 at 09:08:59AM +0200, David Hildenbrand wrote: >> On 21.07.22 20:33, Peter Xu wrote: >>> The check wanted to make sure when soft-dirty tracking is enabled we won't >>> grant write bit by accident, as a page fault is needed for dirty tracking. >>> The intention is correct but we didn't check it right because VM_SOFTDIRTY >>> set actually means soft-dirty tracking disabled. Fix it. >>> >>> There's another thing tricky about soft-dirty is that, we can't check the >>> vma flag !(vma_flags & VM_SOFTDIRTY) directly but only check it after we >>> checked CONFIG_MEM_SOFT_DIRTY because otherwise VM_SOFTDIRTY will be >>> defined as zero, and !(vma_flags & VM_SOFTDIRTY) will constantly return >>> true. To avoid misuse, introduce a helper for checking whether vma has >>> soft-dirty tracking enabled. >>> >> >> >> [...] >> >>> >>> Here we attach a Fixes to commit 64fe24a3e05e only for easy tracking, as >>> this patch won't apply to a tree before that point. However the commit >>> wasn't the source of problem, it's just that then anonymous memory will >>> also suffer from this problem with mprotect(). >> >> I'd remove that paragraph and also add >> >> Fixes: 64e455079e1b ("mm: softdirty: enable write notifications on VMAs after VM_SOFTDIRTY cleared") >> >> That introduced this wrong check for pagecache pages AFAIKS. >> >> We don't care if the patch applies before 64fe24a3e05e, if someone wants to >> backport the fix, they can just adjust it accordingly. > > IMO besides marking the culprit commit, Fixes can also provide input to > stable trees to see whether we should try pick some patch up. What I > wanted to express here is we don't need to try pick this patch up before > kernel that doesn't have 64fe24a3e05e because it won't apply. > > I can attach both Fixes with the hope that it'll help in both cases if > you're fine with it, with slight explanations. Makes sense. Thanks! -- Thanks, David / dhildenb