Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D2F22C433DB for ; Fri, 8 Jan 2021 13:36:54 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 356412399A for ; Fri, 8 Jan 2021 13:36:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 356412399A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 62FBC8D017F; Fri, 8 Jan 2021 08:36:53 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5E0118D0156; Fri, 8 Jan 2021 08:36:53 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4F5BC8D017F; Fri, 8 Jan 2021 08:36:53 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0101.hostedemail.com [216.40.44.101]) by kanga.kvack.org (Postfix) with ESMTP id 377268D0156 for ; Fri, 8 Jan 2021 08:36:53 -0500 (EST) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 03BCD40FB for ; Fri, 8 Jan 2021 13:36:53 +0000 (UTC) X-FDA: 77682708306.20.price33_4d015ef274f3 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin20.hostedemail.com (Postfix) with ESMTP id B95CC180C07A3 for ; Fri, 8 Jan 2021 13:36:52 +0000 (UTC) X-HE-Tag: price33_4d015ef274f3 X-Filterd-Recvd-Size: 6024 Received: from mail-il1-f179.google.com (mail-il1-f179.google.com [209.85.166.179]) by imf44.hostedemail.com (Postfix) with ESMTP for ; Fri, 8 Jan 2021 13:36:52 +0000 (UTC) Received: by mail-il1-f179.google.com with SMTP id w17so10217549ilj.8 for ; Fri, 08 Jan 2021 05:36:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=ehVJZhNwbv/+X0MqNJz70oUJLCNIbym2FZsQKK9qJjI=; b=oICYMf9NNsqqEXfxvdnVjhRU6h75pdbaXZDFqkKqkmskLgh/sYnVnxQQJaydrfPQHG VmLJViuGJPuqcbV5E2RwKQnpWqKF/GI6gnWpwIsM5SlKGVgSYPHCBJzdc1DFj81jPhSA n9hOwHJS267m3LqQyZR3AieB+dihA/BHt7LYbTDJzydcXgD5PADdq3ui4N6v79qQDdHl eM4y03Bwf7WRXSiNdAA2sKEeLY96l1sMbbL27obXorjW/Syv7SYtaaOOaecWq0Orqgh3 LLXm83tpodBY2Nh3mkOkdmUKB0g2eANzhTYuOsYpCGwNflGxP07RQHmeolcnoEJzMAtr l6Lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ehVJZhNwbv/+X0MqNJz70oUJLCNIbym2FZsQKK9qJjI=; b=eDJU6nhdRSLIWhl015aQUE/5ns/DS7RXMlEQijj0l2J6txzpf19bRNFQolG34IxCOQ y01CrIMfZyr7QvqlL17YR08nBHpEKizb6OLggi50jNRTYcvp70MWzmQcNr+c5X0a/iLP wrjIUWwoaqkfmMwkmT2gk7emoHsOjToqIiYiaE7vCOjWx5reEXXGY+ze7cCqTStcTtxL kWmw6P7JUb5zmn4Bqrkopxl8gEvQrvWQRecHxYEK7J5Phgg9Tk7tAFfMQTQmGFDTrehD Laz4R+60zF+3+i0us7tg4hYOxpg563a3oiNd2i9rvEI7sctefQtQHJhYGblHISOVU1Jg Xyeg== X-Gm-Message-State: AOAM5308v38NlL/geI1Bck5YM3giDkr5wg3ovfqyrlQ7397dabUlc0bt vGwqt8Jb3B0GQu35GAr/EeI6Dw== X-Google-Smtp-Source: ABdhPJwq/xJLILBlp2Vz6XBMrfMxKijk6BrFhljxHhVPGX05Fl7lTCdfWf4H3M5kvBLcH7kCaam0oA== X-Received: by 2002:a92:c052:: with SMTP id o18mr3832166ilf.245.1610113011579; Fri, 08 Jan 2021 05:36:51 -0800 (PST) Received: from ziepe.ca (hlfxns017vw-142-162-115-133.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.162.115.133]) by smtp.gmail.com with ESMTPSA id b82sm7680684ilg.44.2021.01.08.05.36.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jan 2021 05:36:51 -0800 (PST) Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1kxrwf-004Ccq-VY; Fri, 08 Jan 2021 09:36:49 -0400 Date: Fri, 8 Jan 2021 09:36:49 -0400 From: Jason Gunthorpe To: Andrea Arcangeli Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Yu Zhao , Andy Lutomirski , Peter Xu , Pavel Emelyanov , Mike Kravetz , Mike Rapoport , Minchan Kim , Will Deacon , Peter Zijlstra , Linus Torvalds , Hugh Dickins , "Kirill A. Shutemov" , Matthew Wilcox , Oleg Nesterov , Jann Horn , Kees Cook , John Hubbard , Leon Romanovsky , Jan Kara , Kirill Tkhai Subject: Re: [PATCH 0/2] page_count can't be used to decide when wp_page_copy Message-ID: <20210108133649.GE504133@ziepe.ca> References: <20210107200402.31095-1-aarcange@redhat.com> <20210107202525.GD504133@ziepe.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 Thu, Jan 07, 2021 at 04:45:33PM -0500, Andrea Arcangeli wrote: > On Thu, Jan 07, 2021 at 04:25:25PM -0400, Jason Gunthorpe wrote: > > On Thu, Jan 07, 2021 at 03:04:00PM -0500, Andrea Arcangeli wrote: > > > > > vmsplice syscall API is insecure allowing long term GUP PINs without > > > privilege. > > > > Lots of places are relying on pin_user_pages long term pins of memory, > > and cannot be converted to notifiers. > > > > I don't think it is reasonable to just declare that insecure and > > requires privileges, it is a huge ABI break. > > Where's that ABI? Are there specs or a code example in kernel besides > vmsplice itself? If I understand you right, you are trying to say that the 193 pin_user_pages() callers cannot exist as unpriv any more? The majority cannot be converted to notifiers because they are DMA based. Every one of those is an ABI for something, and does not expect extra privilege to function. It would be a major breaking change to have pin_user_pages require some cap. > The whole zygote issue wouldn't even register if the child had the > exact same credentials of the parent. Problem is the child dropped > privileges and went with a luser id, that clearly cannot ptrace the > parent, and so if long term unprivileged GUP pins are gone from the > equation, what remains that the child can do is purely theoretical > even before commit 17839856fd588f4ab6b789f482ed3ffd7c403e1f. Sorry, I'm not sure I've found a good explanation how ptrace and GUP are interacting to become a security problem. 17839 makes sense to me, and read-only GUP has been avoided by places like RDMA and others for a very long time because of these issues, adding the same idea to the core code looks OK. The semantics we discussed during the COW on fork thread for pin user pages were, more or less, that once pinned a page should not be silently removed from the mm it is currently in by COW or otherwise in the kernel. So maybe ptrace should not be COW'ing pinned pages at all, as that is exactly the same kind of silent corruption fork was causing. Jason