From patchwork Mon Nov 26 17:34:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Arcangeli X-Patchwork-Id: 10698857 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 428F715A8 for ; Mon, 26 Nov 2018 17:35:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C93472973E for ; Mon, 26 Nov 2018 17:34:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BBACF29BE8; Mon, 26 Nov 2018 17:34:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5588B2973E for ; Mon, 26 Nov 2018 17:34:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5B6416B42C9; Mon, 26 Nov 2018 12:34:58 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 562F86B42CB; Mon, 26 Nov 2018 12:34:58 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 467E86B42CD; Mon, 26 Nov 2018 12:34:58 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by kanga.kvack.org (Postfix) with ESMTP id 1B2636B42C9 for ; Mon, 26 Nov 2018 12:34:58 -0500 (EST) Received: by mail-qk1-f198.google.com with SMTP id c7so19848287qkg.16 for ; Mon, 26 Nov 2018 09:34:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=YQAHc8DLHINDXrumhdLVCSgt1dBz0dqfcFclwEqvHIY=; b=g19qrPtK/XGYrLTcAAndbTvhtzKoUGYa3vaKBEOhmMoOTa3cucYXHVRghxD4omQ74x 4qmzqkO6rpsiyts2xHnnqCeNTEYDyxnScPsoXoRiHJBEQPDRu2U5mTrKYUWfeZJeT7tJ 7gjTKIqGv1xi56ruOC3INikZEQoIASO4eXWWpdBMeN4rwTTdGBbxmCSEfcUkicYQBgRb 2w+cFRvDCrc1II16lPGz8i6ztY+1UQh47Bk8XVDSPloq+j+2ihziRnPzyOaGBYrwUJic voMmo5NO7TrntrlgrO4m0thOpNf85jeWmexbqsCmgARUrTOQRJ1BrAg9c+2v8cQysF3t NfIw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of aarcange@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=aarcange@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: AA+aEWYSG1Ru2r4vY/X9nNiOijOrq2icTwNWWPtr6nzo7w2TbwykvtoC W7PMnz+Tj7wZub1Im8c8GetR+PbVZ9OzcArinS4aGqQQiEpQGHaPbjZATc284V3K8MF1813AYzb ZUahCRXrc9CTttFdfqRu4y5PUOoY48ajHD6xMPv9xJN0EoFgXzW9WaJ3MnjgBtPx7Zw== X-Received: by 2002:a37:7d05:: with SMTP id y5mr24876333qkc.310.1543253697858; Mon, 26 Nov 2018 09:34:57 -0800 (PST) X-Google-Smtp-Source: AFSGD/X1CRXnw6MO98Bvhg7G5e5fonfTX0a+AM4COyQFb7hw7Sir1nL5rH5ng/q6zAZ+D77S4RJ5 X-Received: by 2002:a37:7d05:: with SMTP id y5mr24876276qkc.310.1543253697040; Mon, 26 Nov 2018 09:34:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543253697; cv=none; d=google.com; s=arc-20160816; b=G7H9RcghMC0NxX4e2FM6zJzeeXfac8jzL7BX6fJCafeLAxmAT0/N/zQ6nLA7nRYp2h HOy3bBx9q2ha/HIzFgzCkxHrZtQwutyDtvgAjoJv4+Pf7vWlt7gdfPshg/lOwOYn2WSu l5zJllMvVfp/XAJARceNlnMVZ8gzSF7VtH48VF9TpsFKJdX1VwGpl9vKuuE3sIcAg67P 4TvhilNxSGPaSeyd2J5Jzxci+t1mLR0VP4/9yedT6IgSmbn8mbqUCoftIbGEtcB9Qj0P SZgjLMV3MrHKfWKVVUDOgAt0JHG+7Fv6rq8V6H5rqBcD9MssKaBJkRCicPoVu4fjInRz TSRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=YQAHc8DLHINDXrumhdLVCSgt1dBz0dqfcFclwEqvHIY=; b=sFIC7t+X7EAjBdPY7fozQY6O1vSbmOT2XI8J7CA1vFX4vLRK2zFAxG028me2gfbJj2 g35a7MdAf06mYXv6eqSelQavihNgU+HaBC6NKfbtAXu/095QnQoZvdYTnQsoxESn13Mu Uw8fj5cinHdEkDIX1Sga+NKTIAKuihx6aR+s+oNfEovYXd+S2rQTut5611x/94R6nI8y GSBG/XReUgrvewtelpMFGbhRHSQW4kDSgdO3SiJrBPcRKUGO6BWpr+ds/4z14HekDUXc JY53QtDeyu+urEB5x0WOOA5s6QiqVYaT+jj7190yxBLCyiDP6kCNuXRZNzGMULncfyz8 4QDg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of aarcange@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=aarcange@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id s80si776260qka.18.2018.11.26.09.34.56 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Nov 2018 09:34:56 -0800 (PST) Received-SPF: pass (google.com: domain of aarcange@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of aarcange@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=aarcange@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1D9593084298; Mon, 26 Nov 2018 17:34:56 +0000 (UTC) Received: from sky.random (ovpn-120-160.rdu2.redhat.com [10.10.120.160]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 45B22604CE; Mon, 26 Nov 2018 17:34:53 +0000 (UTC) From: Andrea Arcangeli To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Hugh Dickins , Mike Rapoport , Mike Kravetz , Jann Horn , Peter Xu , "Dr. David Alan Gilbert" Subject: [PATCH 1/5] userfaultfd: use ENOENT instead of EFAULT if the atomic copy user fails Date: Mon, 26 Nov 2018 12:34:48 -0500 Message-Id: <20181126173452.26955-2-aarcange@redhat.com> In-Reply-To: <20181126173452.26955-1-aarcange@redhat.com> References: <20181126173452.26955-1-aarcange@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Mon, 26 Nov 2018 17:34:56 +0000 (UTC) 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: X-Virus-Scanned: ClamAV using ClamSMTP We internally used EFAULT to communicate with the caller, switch to ENOENT, so EFAULT can be used as a non internal retval. Reviewed-by: Mike Rapoport Reviewed-by: Hugh Dickins Cc: stable@vger.kernel.org Fixes: 4c27fe4c4c84 ("userfaultfd: shmem: add shmem_mcopy_atomic_pte for userfaultfd support") Signed-off-by: Andrea Arcangeli --- mm/hugetlb.c | 2 +- mm/shmem.c | 2 +- mm/userfaultfd.c | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 7f2a28ab46d5..705a3e9cc910 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -4080,7 +4080,7 @@ int hugetlb_mcopy_atomic_pte(struct mm_struct *dst_mm, /* fallback to copy_from_user outside mmap_sem */ if (unlikely(ret)) { - ret = -EFAULT; + ret = -ENOENT; *pagep = page; /* don't free the page */ goto out; diff --git a/mm/shmem.c b/mm/shmem.c index d44991ea5ed4..353287412c25 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -2236,7 +2236,7 @@ static int shmem_mfill_atomic_pte(struct mm_struct *dst_mm, *pagep = page; shmem_inode_unacct_blocks(inode, 1); /* don't free the page */ - return -EFAULT; + return -ENOENT; } } else { /* mfill_zeropage_atomic */ clear_highpage(page); diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c index 5029f241908f..46c8949e5f8f 100644 --- a/mm/userfaultfd.c +++ b/mm/userfaultfd.c @@ -48,7 +48,7 @@ static int mcopy_atomic_pte(struct mm_struct *dst_mm, /* fallback to copy_from_user outside mmap_sem */ if (unlikely(ret)) { - ret = -EFAULT; + ret = -ENOENT; *pagep = page; /* don't free the page */ goto out; @@ -274,7 +274,7 @@ static __always_inline ssize_t __mcopy_atomic_hugetlb(struct mm_struct *dst_mm, cond_resched(); - if (unlikely(err == -EFAULT)) { + if (unlikely(err == -ENOENT)) { up_read(&dst_mm->mmap_sem); BUG_ON(!page); @@ -530,7 +530,7 @@ static __always_inline ssize_t __mcopy_atomic(struct mm_struct *dst_mm, src_addr, &page, zeropage); cond_resched(); - if (unlikely(err == -EFAULT)) { + if (unlikely(err == -ENOENT)) { void *page_kaddr; up_read(&dst_mm->mmap_sem);