From patchwork Mon Jan 21 07:57:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 10772801 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 77F8213BF for ; Mon, 21 Jan 2019 07:58:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 66CD429C15 for ; Mon, 21 Jan 2019 07:58:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 55DA129C18; Mon, 21 Jan 2019 07:58:51 +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 D6DC829C15 for ; Mon, 21 Jan 2019 07:58:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 069038E0003; Mon, 21 Jan 2019 02:58:50 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 040998E0001; Mon, 21 Jan 2019 02:58:50 -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 E9A878E0003; Mon, 21 Jan 2019 02:58:49 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by kanga.kvack.org (Postfix) with ESMTP id BDE358E0001 for ; Mon, 21 Jan 2019 02:58:49 -0500 (EST) Received: by mail-qt1-f198.google.com with SMTP id d31so20337613qtc.4 for ; Sun, 20 Jan 2019 23:58:49 -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=pZJ84L/ZbRdOY+WOUeg+9o36Qq7/uo9wYzCI16ljv34=; b=JivGQnnV2QtqvHhsDLg/dqTslOprrcF4ns39lnW6x/h+lnhHc2cYWrUgBXWTuljOf0 gH+KfRSp4+mxwyLWk3S3xy3f5WE34NGClAbpsNIz625wogTQVNQG43QlxDkfDuMsyXMi 1oqFP2o3msqCKCnMLlqCqZneUr4xeyLKCmHR3QHWxQMV7plALRjVHGk0hXCLSrGxZcfg RpUcBMUv+/gDUFYA0CCSzCl/LB8l88wy87OfrHWEqFEV2ifKc7cxOoZUC01B63YzUrq+ LdDLaRV1xDkFo0q4s4X1tU17TWBBxyZdkbgLAC4Tr38yC7jYLob07cizo4SHmdPDyBQu 6ibA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of peterx@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: AJcUukd34kyyrCcfSt+hW47FVU3/NwDv53gNCpdgjZOcsCrxUXU3hpG7 6m5Gig1vnIrLolmo41RQwFByDclgkNJrPK/+2ZoPEEbkUE2yQTE7Z+1THUt1QdI+J3md8pXr9h4 8WJ+yYTLEXUM8v/v86exyd6Dytl6YOui4ylPaFzzp1gtmbwpJd7vQ5x8UnWfJnWowhg== X-Received: by 2002:ac8:2585:: with SMTP id e5mr25978888qte.233.1548057529585; Sun, 20 Jan 2019 23:58:49 -0800 (PST) X-Google-Smtp-Source: ALg8bN7tOkSLYypoYNP2vcK8e0phyhnEIqA09GypoH0cw5vP8GEmnuhiayqMMTd6LJeQ8S476Q0m X-Received: by 2002:ac8:2585:: with SMTP id e5mr25978873qte.233.1548057529232; Sun, 20 Jan 2019 23:58:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548057529; cv=none; d=google.com; s=arc-20160816; b=ujznQ4O3OdagrBbK1DoKwAsH49i5rs844bmH7/daiU39ucA18PnLjmbBGg64wCmFDb usmXkp0Z1jkRqnApBWCAe1oIl13wgekeduK9QLHMtVWS7E2k3VmHaL1ugkshFsZC1egt vVGjLwfvJwGry9TOPudjO9swCN4yJFom0K/5pYLhpQEMfS4zgAbwAiRnXIuK3il1snE8 JPH9se0V+ZpPwjvq4WqZHvKQr75RHs3i44wa5j5pgig4lda8lSLL4/BdVftBKyvwvMFe OarZtrvSjre30kugdHAtxmK2DTJpfvrRBP66lSSQg4fsaiZagggZhj+b40rM6Za6UTMi zU5w== 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=pZJ84L/ZbRdOY+WOUeg+9o36Qq7/uo9wYzCI16ljv34=; b=yjRuRWVFTQNzX7ROpffW5l6EkUal5FUBzjOaNJIQlUhcCbqyXorSuQki1WIcBY7Sy9 MhY4WIcpLpSeyao/R4gyfEp5gvLFf3KFLjcmPVVUeko8dBOCOhwTJotFKL4O8+OfUdr6 WwePH79dsh9mav6fCEjzvrCQgYybPejlf4ec+08NoFVCO3cq8vAqolSQ7gxoqizTDMGN dKM0+2GwsfkmmI78r1Q0E9zF3E1/pwBkdu4BtQvc4SSpD51i82qPTHUoFgFfugKfCFP4 f8+xfd1UAVMwqzXypZaTJm6FoCkFCRq7XfgTLAkEjQWdAsk7KUFqBnFmp9X9ijYANkmQ bW+w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of peterx@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=peterx@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 x2si1888794qvp.94.2019.01.20.23.58.49 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 20 Jan 2019 23:58:49 -0800 (PST) Received-SPF: pass (google.com: domain of peterx@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 peterx@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4C7507E9CB; Mon, 21 Jan 2019 07:58:48 +0000 (UTC) Received: from xz-x1.nay.redhat.com (dhcp-14-116.nay.redhat.com [10.66.14.116]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0C3FE608E1; Mon, 21 Jan 2019 07:58:33 +0000 (UTC) From: Peter Xu To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Hugh Dickins , Maya Gokhale , Jerome Glisse , Johannes Weiner , peterx@redhat.com, Martin Cracauer , Denis Plotnikov , Shaohua Li , Andrea Arcangeli , Pavel Emelyanov , Mike Kravetz , Marty McFadden , Mike Rapoport , Mel Gorman , "Kirill A . Shutemov" , "Dr . David Alan Gilbert" , Rik van Riel Subject: [PATCH RFC 09/24] userfaultfd: wp: enabled write protection in userfaultfd API Date: Mon, 21 Jan 2019 15:57:07 +0800 Message-Id: <20190121075722.7945-10-peterx@redhat.com> In-Reply-To: <20190121075722.7945-1-peterx@redhat.com> References: <20190121075722.7945-1-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 21 Jan 2019 07:58:48 +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 From: Shaohua Li Now it's safe to enable write protection in userfaultfd API Cc: Andrea Arcangeli Cc: Pavel Emelyanov Cc: Rik van Riel Cc: Kirill A. Shutemov Cc: Mel Gorman Cc: Hugh Dickins Cc: Johannes Weiner Signed-off-by: Shaohua Li Signed-off-by: Andrea Arcangeli Signed-off-by: Peter Xu --- include/uapi/linux/userfaultfd.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/uapi/linux/userfaultfd.h b/include/uapi/linux/userfaultfd.h index 11517f796275..9de61cd8e228 100644 --- a/include/uapi/linux/userfaultfd.h +++ b/include/uapi/linux/userfaultfd.h @@ -19,7 +19,8 @@ * means the userland is reading). */ #define UFFD_API ((__u64)0xAA) -#define UFFD_API_FEATURES (UFFD_FEATURE_EVENT_FORK | \ +#define UFFD_API_FEATURES (UFFD_FEATURE_PAGEFAULT_FLAG_WP | \ + UFFD_FEATURE_EVENT_FORK | \ UFFD_FEATURE_EVENT_REMAP | \ UFFD_FEATURE_EVENT_REMOVE | \ UFFD_FEATURE_EVENT_UNMAP | \ @@ -34,7 +35,8 @@ #define UFFD_API_RANGE_IOCTLS \ ((__u64)1 << _UFFDIO_WAKE | \ (__u64)1 << _UFFDIO_COPY | \ - (__u64)1 << _UFFDIO_ZEROPAGE) + (__u64)1 << _UFFDIO_ZEROPAGE | \ + (__u64)1 << _UFFDIO_WRITEPROTECT) #define UFFD_API_RANGE_IOCTLS_BASIC \ ((__u64)1 << _UFFDIO_WAKE | \ (__u64)1 << _UFFDIO_COPY)