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 BBE77C19F2D for ; Tue, 9 Aug 2022 19:20:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1B7128E0002; Tue, 9 Aug 2022 15:20:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1663B8E0001; Tue, 9 Aug 2022 15:20:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 006AE8E0002; Tue, 9 Aug 2022 15:20:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id E1E4D8E0001 for ; Tue, 9 Aug 2022 15:20:49 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 9A8821211FB for ; Tue, 9 Aug 2022 19:20:49 +0000 (UTC) X-FDA: 79781021418.13.3AA810A Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf17.hostedemail.com (Postfix) with ESMTP id CCE0B4016F for ; Tue, 9 Aug 2022 19:20:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660072848; 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=H8h4Jng7BDnvUHW4yaisoTMe84LTGwEUPKezp1k3H30=; b=JQOf9kgUBA5S/VP0RAcXhgY1k7wvJISVgdmIo7z1Mt+vbKmJhtZg5iUBzgkFaNQZ+ArKGE OvLDdBM2eZ2yL8yUxhVzLTdiXdvSbJ6b910phwp314PiT8S1kE0z+VxQfzDhKmWeaXyocU axnMIDEY0kchh1LJboce7WbpSjA8JRY= 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-605-G7z5cldeNuicxCGs9IXwyQ-1; Tue, 09 Aug 2022 15:20:45 -0400 X-MC-Unique: G7z5cldeNuicxCGs9IXwyQ-1 Received: by mail-wm1-f71.google.com with SMTP id j22-20020a05600c485600b003a50fa6981bso8459836wmo.9 for ; Tue, 09 Aug 2022 12:20:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:subject:organization:from :references:cc:to:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc; bh=H8h4Jng7BDnvUHW4yaisoTMe84LTGwEUPKezp1k3H30=; b=aBhTNZx0sG4FXQqp5722JAxGorkSiYdsUTzO5rzeGqA/DkOr+APA17CgV854W2t7GC 1yhj3ZhV1MFUlFSvxs1O8v3S9sL4Plh11G7G1EI0GntiM7DWDQYzkqDgTxTRdFHZIlDw mVBtN/OfVWO7JDtQhVD4XRHOWBwbErserznmUHy6f7L3dueRK24dqCCUj5svhu52WVcZ gTevOLNvBlPbaF7KvpuYC0VQtNLX7Gi0SmRQuCLJu8F8EjaXiEXuS38+Mke48ZxlAuYF d5lWW3iB+sXYYJRdGxSW1Dz6WhbM+85muDpQLoDuWLopurjWF17bzQHR0WuTKZ1fjaek /IqA== X-Gm-Message-State: ACgBeo3NH+ahhBkSyn7X2UhnCkrTO+78uZmwsKQQyOkLXS3aJ1uhdHei UhQLIyGKW7vS4MZ89jVbO0X1talEWJelR4U17MiwSgVzJa0zkMRfNtugFuU2Nt7KrM449jj/XQU LhTHfAWTaILs= X-Received: by 2002:a1c:ed05:0:b0:3a2:ebae:c5e7 with SMTP id l5-20020a1ced05000000b003a2ebaec5e7mr15516wmh.78.1660072844098; Tue, 09 Aug 2022 12:20:44 -0700 (PDT) X-Google-Smtp-Source: AA6agR4LubkX0tuGA9aKXvqxL9u6Pg1ZLUrPaG3+BlBR8O2coLYRUWNXjx9DEti7PhyhEHYDH5631w== X-Received: by 2002:a1c:ed05:0:b0:3a2:ebae:c5e7 with SMTP id l5-20020a1ced05000000b003a2ebaec5e7mr15496wmh.78.1660072843868; Tue, 09 Aug 2022 12:20:43 -0700 (PDT) Received: from ?IPV6:2003:cb:c705:3700:aed2:a0f8:c270:7f30? (p200300cbc7053700aed2a0f8c2707f30.dip0.t-ipconnect.de. [2003:cb:c705:3700:aed2:a0f8:c270:7f30]) by smtp.gmail.com with ESMTPSA id q25-20020a1ce919000000b003a32251c3f0sm17052196wmc.33.2022.08.09.12.20.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 09 Aug 2022 12:20:43 -0700 (PDT) Message-ID: <5593cbb7-eb29-82f0-490e-dd72ceafff9b@redhat.com> Date: Tue, 9 Aug 2022 21:20:42 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 To: Linus Torvalds , Jason Gunthorpe Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, stable@vger.kernel.org, Andrew Morton , Greg Kroah-Hartman , Axel Rasmussen , Peter Xu , Hugh Dickins , Andrea Arcangeli , Matthew Wilcox , Vlastimil Babka , John Hubbard References: <20220808073232.8808-1-david@redhat.com> From: David Hildenbrand Organization: Red Hat Subject: Re: [PATCH v1] mm/gup: fix FOLL_FORCE COW security issue and remove FOLL_COW 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=1660072849; a=rsa-sha256; cv=none; b=yfecb860bFU0MDI/Ss6COu+9gYgW9QAQHa3QVUIbp3z2dKT9Mnia13QNbRds1Y3+PnrCBZ eYqnQaLso4Ta8eylXsQKrSXqYEwYPwfnU1UOSEL5FZSdnpll2Pu7NMqII5CTIRRO5qJZFu Y8I1pAKHfIzdwQ2qP00dGcD9P6hb2XA= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=JQOf9kgU; spf=pass (imf17.hostedemail.com: domain of david@redhat.com designates 170.10.129.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=1660072849; 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=H8h4Jng7BDnvUHW4yaisoTMe84LTGwEUPKezp1k3H30=; b=c6kDKbubS41J7zSPagC0ZiKT1nCjLDf78Iy9ed5sEmxIzT31/C50eHU86dHuaBCiTEihho VLk1W2SH3IUoqlbdGO477tX4iCemhqYrCWdvmDm4JitK50SQL9Fh1Uh+n/I8/V6c6rD91P SRbhLE4dW9KfzWejJ92U4O/cwsgfeP0= X-Rspamd-Queue-Id: CCE0B4016F X-Rspam-User: X-Rspamd-Server: rspam11 Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=JQOf9kgU; spf=pass (imf17.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Stat-Signature: 6yhcmw4wti78i77etwwj3xmfccubzthj X-HE-Tag: 1660072848-392810 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 09.08.22 21:07, Linus Torvalds wrote: > On Tue, Aug 9, 2022 at 11:48 AM Jason Gunthorpe wrote: >> >> It is because of all this madness with COW. > > Yes, yes, but we have the proper long-term pinning now with > PG_anon_exclusive, and it actually gets the pinning right not just > over COW, but even over a fork - which that early write never did. > > David, I thought all of that got properly merged? Is there something > still missing? The only thing to get R/O longterm pins in MAP_PRIVATE correct that's missing is that we have to break COW when taking a R/O longterm pin when *not* finding an anon page inside a private mapping. Regarding anon pages I am not aware of issues (due to PG_anon_exclusive). If anybody here wants to stare at a webpage, the following commit explains the rough idea for MAP_PRIVATE: https://github.com/davidhildenbrand/linux/commit/cd7989fb76d2513c86f01e6f7a74415eee5d3150 Once we have that in place, we can mostly get rid of FOLL_FORCE|FOLL_WRITE for R/O longterm pins. There are some corner cases though that need some additional thought which i am still working on. FS-handled COW in MAP_SHARED mappings is just nasty (hello DAX). (the wrong use of FOLL_GET instead of FOLL_PIN for O_DIRECT and friends still persists, but that's a different thing to handle and it's only problematic with concurrent fork() IIRC) -- Thanks, David / dhildenb