Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp856487ybm; Wed, 22 May 2019 12:44:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqxh8cOQ3NRrc7y02EG7cmI7wxRoo0lrQEWQNgkhhXTbmPZt8dqqGsBRkQ01J/9V6CLOLpf3 X-Received: by 2002:a63:5c45:: with SMTP id n5mr49300520pgm.172.1558554299046; Wed, 22 May 2019 12:44:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558554299; cv=none; d=google.com; s=arc-20160816; b=vK4YbAwXrE15BVdkHHJWZyJvmH0q0uo5fKYbKqeruopEHzVQZ/cANh6m1vuRlalWGU J0VLlIBl2NxEJvSUeuZ3oZqpSE+FMHNY87ZMWDJoZIhXjm4qgCbkrJRM7+n3SMVjyY4C sNHPOI0BND+SMEFbzqojBer6XlM2MAwu7K3HZPo5veEJ1WKNIhrlMDlgvaFbbT+DTcxc lfgtty+8WPxHK8C9/kuZyySxGSnz8HM0VsdNGTVC3Eyv8GRqjU9ig7rwSwajUDTFtvrv QbVeBysK4iKunznFzUhPAbyieL/ISZiHYDCsDHoz/BqcAZUi4UtEZaZVukm9pbtN8rx8 YFKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=Fmg2iGQ2QOU8aycVFt1PBF/LG/OCJFeJteK+WquArzs=; b=hq4UonvZafCOyES+GL0gfkZ7Ej1UdlMPT6BHp8SO7sqh8rcdkSTMz5J/xoEk8w7tDQ Cw/aoomfMFfuQaY7WXLgPJ2ga4nu1L2s/CPA5nggmVw0RBIeWKALWi60bPzi/r8Or4yW jiqQk/o8KzUAnueBfIo5SqQHqKf8dHE4WJuFqdxe3tX7nNGJvbpeM/GwXXl0qUAjCTp8 xllVl6sU1IR4Ey5B1kwPPnkU0T0sgdX730cYiy5fF09iqKulyf8MG7jgVZQLJt3cRo+x hw6eghjnpOXOtZ3+Kqq0bhz23cUtT/WwXkPeusXa4+evraIZ5o/qZ1ZkVEcg3yG6SJCC 4JKA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m1si28511281pgt.93.2019.05.22.12.44.44; Wed, 22 May 2019 12:44:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732762AbfEVTnm (ORCPT + 99 others); Wed, 22 May 2019 15:43:42 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:37834 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729616AbfEVTnc (ORCPT ); Wed, 22 May 2019 15:43:32 -0400 Received: from bigeasy by Galois.linutronix.de with local (Exim 4.80) (envelope-from ) id 1hTX93-00050n-IX; Wed, 22 May 2019 21:43:25 +0200 Date: Wed, 22 May 2019 21:43:24 +0200 From: Sebastian Andrzej Siewior To: Andrew Morton Cc: Mike Rapoport , Andrea Arcangeli , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Borislav Petkov Subject: Re: [PATCH] mm/gup: continue VM_FAULT_RETRY processing event for pre-faults Message-ID: <20190522194322.5k52docwgp5zkdcj@linutronix.de> References: <1557844195-18882-1-git-send-email-rppt@linux.ibm.com> <20190522122113.a2edc8aba32f0fad189bae21@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20190522122113.a2edc8aba32f0fad189bae21@linux-foundation.org> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019-05-22 12:21:13 [-0700], Andrew Morton wrote: > On Tue, 14 May 2019 17:29:55 +0300 Mike Rapoport wrote: > > > When get_user_pages*() is called with pages = NULL, the processing of > > VM_FAULT_RETRY terminates early without actually retrying to fault-in all > > the pages. > > > > If the pages in the requested range belong to a VMA that has userfaultfd > > registered, handle_userfault() returns VM_FAULT_RETRY *after* user space > > has populated the page, but for the gup pre-fault case there's no actual > > retry and the caller will get no pages although they are present. > > > > This issue was uncovered when running post-copy memory restore in CRIU > > after commit d9c9ce34ed5c ("x86/fpu: Fault-in user stack if > > copy_fpstate_to_sigframe() fails"). > > > > After this change, the copying of FPU state to the sigframe switched from > > copy_to_user() variants which caused a real page fault to get_user_pages() > > with pages parameter set to NULL. > > You're saying that argument buf_fx in copy_fpstate_to_sigframe() is NULL? buf_fx is user stack pointer and it should not be NULL. > If so was that expected by the (now cc'ed) developers of > d9c9ce34ed5c8923 ("x86/fpu: Fault-in user stack if > copy_fpstate_to_sigframe() fails")? > > It seems rather odd. copy_fpregs_to_sigframe() doesn't look like it's > expecting a NULL argument. exactly, this is not expected. > Also, I wonder if copy_fpstate_to_sigframe() would be better using > fault_in_pages_writeable() rather than get_user_pages_unlocked(). That > seems like it operates at a more suitable level and I guess it will fix > this issue also. It looks, like fault_in_pages_writeable() would work. If this is the recommendation from the MM department than I can switch to that. > > In post-copy mode of CRIU, the destination memory is managed with > > userfaultfd and lack of the retry for pre-fault case in get_user_pages() > > causes a crash of the restored process. > > > > Making the pre-fault behavior of get_user_pages() the same as the "normal" > > one fixes the issue. > > Should this be backported into -stable trees? Sebastian