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 X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 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 9C96CC43461 for ; Fri, 4 Sep 2020 18:20:19 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0F296208CA for ; Fri, 4 Sep 2020 18:20:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="epilMlIR" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0F296208CA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 2A9846B005D; Fri, 4 Sep 2020 13:55:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2597A6B0062; Fri, 4 Sep 2020 13:55:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1491C6B0068; Fri, 4 Sep 2020 13:55:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0135.hostedemail.com [216.40.44.135]) by kanga.kvack.org (Postfix) with ESMTP id F38C56B005D for ; Fri, 4 Sep 2020 13:55:18 -0400 (EDT) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id B137E2484 for ; Fri, 4 Sep 2020 17:55:18 +0000 (UTC) X-FDA: 77226130716.13.money52_0002d74270b4 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin13.hostedemail.com (Postfix) with ESMTP id 7FA9B18140B67 for ; Fri, 4 Sep 2020 17:55:18 +0000 (UTC) X-HE-Tag: money52_0002d74270b4 X-Filterd-Recvd-Size: 4244 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by imf22.hostedemail.com (Postfix) with ESMTP for ; Fri, 4 Sep 2020 17:55:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1599242117; 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=6xZGtz6AqO5FwybZw0tM4AMKqTLxgkhwTmRA2SACMi8=; b=epilMlIRMQAUqlDzA+BZzVR4CDum9IluqYkCntlOqsT04DRHL6MsGaFQ+4ce2V4+aiRw4H Abt3h+mNXHkcUFe9FQ7QReWVGvKeon9dfFi6ZdZtY36OAukv1uQidBtLb9zd/3hKKhHhed liAuijVG0WesXJXfZxIhJcTdXrqESJE= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-303-Lh8-13ZoPIq-CVdzHV9TKg-1; Fri, 04 Sep 2020 13:55:15 -0400 X-MC-Unique: Lh8-13ZoPIq-CVdzHV9TKg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BF2C7801AB8; Fri, 4 Sep 2020 17:55:12 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.40.192.114]) by smtp.corp.redhat.com (Postfix) with SMTP id E2F145C1D0; Fri, 4 Sep 2020 17:55:04 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Fri, 4 Sep 2020 19:55:12 +0200 (CEST) Date: Fri, 4 Sep 2020 19:55:03 +0200 From: Oleg Nesterov To: Adalbert =?utf-8?B?TGF6xINy?= Cc: linux-mm@kvack.org, linux-api@vger.kernel.org, Andrew Morton , Alexander Graf , Stefan Hajnoczi , Jerome Glisse , Paolo Bonzini , Mihai =?utf-8?B?RG9uyJt1?= , Mircea Cirjaliu , Andy Lutomirski , Arnd Bergmann , Sargun Dhillon , Aleksa Sarai , Jann Horn , Kees Cook , Matthew Wilcox , Christian Brauner Subject: Re: [RESEND RFC PATCH 4/5] mm/remote_mapping: use a pidfd to access memory belonging to unrelated process Message-ID: <20200904175503.GO4386@redhat.com> References: <20200904113116.20648-1-alazar@bitdefender.com> <20200904113116.20648-5-alazar@bitdefender.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200904113116.20648-5-alazar@bitdefender.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Rspamd-Queue-Id: 7FA9B18140B67 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 Content-Transfer-Encoding: quoted-printable 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: I didn't read this series. This is not my area and to be honest even the API doesn't fit my head. I leave this to other reviewers. Just a couple of nits after very quick glance. On 09/04, Adalbert Laz=C4=83r wrote: > > +static vm_fault_t mirror_vm_fault(struct vm_fault *vmf) > +{ ... > + up_read(¤t->mm->mmap_sem); ... > + down_read(¤t->mm->mmap_sem); > + > + /* expedite retry */ > + if (mmu_interval_check_retry(&view->mmin, seq)) { > + put_page(req_page); > + > + srcu_read_unlock(&fctx->fault_srcu, idx); > + > + goto fault_retry; > + } > + > + /* make sure the VMA hasn't gone away */ > + vma =3D find_vma(current->mm, vmf->address); > + if (vma =3D=3D vmf->vma) { vmf->vma can go away, its memory can be freed and re-allocated as another vma returned by find_vma() above. > +int task_remote_map(struct task_struct *task, int fds[]) > +{ ... > + fds[1] =3D anon_inode_getfd("[pidfd_mem.map]", &pidfd_mem_map_fops, f= ctx, > + O_RDWR | O_CLOEXEC | O_LARGEFILE); > + if (fds[1] < 0) { > + ret =3D fds[1]; > + goto out; > + } > + remote_file_context_get(fctx); > + > + map =3D fget(fds[1]); Another thread can close this file right after fd_install(). fget() can r= eturn NULL or another unrelated file. Oleg.