From patchwork Tue Oct 3 19:45:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Rasmussen X-Patchwork-Id: 13407944 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id BF233E8FDAF for ; Tue, 3 Oct 2023 19:45:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 556FE8D0087; Tue, 3 Oct 2023 15:45:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4DFDF8D0003; Tue, 3 Oct 2023 15:45:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3815C8D0087; Tue, 3 Oct 2023 15:45:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 1F5408D0003 for ; Tue, 3 Oct 2023 15:45:59 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id D424E1A02DE for ; Tue, 3 Oct 2023 19:45:58 +0000 (UTC) X-FDA: 81305180796.08.AC13335 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) by imf10.hostedemail.com (Postfix) with ESMTP id 0BDC3C0024 for ; Tue, 3 Oct 2023 19:45:56 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="AxsxqF/m"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf10.hostedemail.com: domain of 3dG8cZQ0KCPMVsZgmVnhpnnZibjjbgZ.Xjhgdips-hhfqVXf.jmb@flex--axelrasmussen.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3dG8cZQ0KCPMVsZgmVnhpnnZibjjbgZ.Xjhgdips-hhfqVXf.jmb@flex--axelrasmussen.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1696362357; h=from:from:sender: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=LZEL2BMjxz1i5idDbV1660WVS0O86XmSCyt1X5bcmDM=; b=wfhLOibPAqRQdt6jRoYrBs3GnIpJnHtpybJ+8RK2lHc5Fd1B6eLOpHcLoFTerhxwGZXq40 LMYOlZklQBeFaf8mlFYZWytR7Beefts8n0Qq/pmYNPU1tqdvIIZRRw37QHSvjT75I6EKe+ HT4Zpz5sP2z2G5MWW2W/qrFpPYW5p5g= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="AxsxqF/m"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf10.hostedemail.com: domain of 3dG8cZQ0KCPMVsZgmVnhpnnZibjjbgZ.Xjhgdips-hhfqVXf.jmb@flex--axelrasmussen.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3dG8cZQ0KCPMVsZgmVnhpnnZibjjbgZ.Xjhgdips-hhfqVXf.jmb@flex--axelrasmussen.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1696362357; a=rsa-sha256; cv=none; b=vjdZPyYmKhhm5QXWj3DhXKM2gK8yFHPGYe8tosaQxRilzAbnJv2ptiET+db4vWF6RHvduU X7Y53QdjR+n7H/u0ezF7X1sALgMLT8DjHTMjwdypWs59/lMF00TVQ3jv4IlUBEvkDG7C4a 1qvJJ5v5UDXK/1UFZ16d8EwY7oGkSXU= Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-d8660e23801so1607731276.3 for ; Tue, 03 Oct 2023 12:45:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1696362356; x=1696967156; darn=kvack.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=LZEL2BMjxz1i5idDbV1660WVS0O86XmSCyt1X5bcmDM=; b=AxsxqF/m0cSiLwj15noVP/yHXahaNjPFFo+b27yZvchJJR3O390fLxsg86QTWFL3F9 tlY8XA4VkUUVD6MCA+4fmq6CS9fqkdfdcu4Jk7wFyLli4pK/6zKWbfpKm8Idy4ZnNuHs EpfEeTTqOPuGNPT3CB3zImnwLsBmdevBg+/7+JJFpcDoxpQw9r0G1vuA3blEORKfqv1A /R1DyL/1LE6NxVwNQzkeiJpCpkVhFVPYognVtKbWyDtmPbChK+cFoPLhMbZanqsSIv3b 8OK/ry1XqVIdw82mxZbQcaKoXDPn2b5MEbjzSektnBcpoaGvDYrqkDDUwNQSlwJpDXYX bavg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696362356; x=1696967156; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=LZEL2BMjxz1i5idDbV1660WVS0O86XmSCyt1X5bcmDM=; b=QDyUMTpO5ofD8d4lFRc+mN/YaDbtvC1kFzbnTjTCdu2rjnyH1B49xaHkdUYMyFkmmL l8m/l6xsEYgBurDzhU7qBcZzMHg99qDwTTVCDDOWf5mIE40P7JvuUsrJ6F01lj66Q/jR /y1X6VTBbqQtQj1QA8araRzH9VVgPvaFGaaEQpAJHW+Jk9poTf6P3Vu2s+DQMRI1awyJ z+Qad8wu/ZBV707QUGi4C1kQRmsB1iOp7E+EWtsDzuHDJogxFd9W6etGZ6SV8oAc36KA BKT0YWi2MN4V42kNL/fKwqMzCtqKycFs5HUG5WnRKRunDFMG0krXHo8tr5t5zaJtCFrC slOw== X-Gm-Message-State: AOJu0Yxo7kd8R3UD2lGez1XfoZ9rGsoVJrznvXggoMPh7qTZQzFCKo+Y CFwVpU2/FVZHAeUghY2jREnJv5K04aN9eq/oSHX5 X-Google-Smtp-Source: AGHT+IGkq/Yho3MXhu4mjlOqZnh1sbMKJRwQFyyu29+TZYNFidmM+AVkw+octliNf2IRJpTmHxGFJHSGs+YhAb5n0ehq X-Received: from axel.svl.corp.google.com ([2620:15c:2a3:200:6577:b8c1:dd2d:1c93]) (user=axelrasmussen job=sendgmr) by 2002:a25:d816:0:b0:d7b:9fad:6b9e with SMTP id p22-20020a25d816000000b00d7b9fad6b9emr3353ybg.1.1696362356219; Tue, 03 Oct 2023 12:45:56 -0700 (PDT) Date: Tue, 3 Oct 2023 12:45:43 -0700 In-Reply-To: <20231003194547.2237424-1-axelrasmussen@google.com> Mime-Version: 1.0 References: <20231003194547.2237424-1-axelrasmussen@google.com> X-Mailer: git-send-email 2.42.0.609.gbb76f46606-goog Message-ID: <20231003194547.2237424-2-axelrasmussen@google.com> Subject: [PATCH v2 1/5] ioctl_userfaultfd.2: describe two-step feature handshake From: Axel Rasmussen To: Alejandro Colomar , Peter Xu Cc: linux-man@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Axel Rasmussen X-Rspam-User: X-Stat-Signature: gk7nto8ypo1ttguu3g7sbgb96di8qkh5 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 0BDC3C0024 X-HE-Tag: 1696362356-479227 X-HE-Meta: U2FsdGVkX19LgNiVnn6wbI410ZqhC+V64Fzmu1boR+c1RnCyytHb3khiE9u83hreTvlmpzYOUUrRKvdv7KD3UrzvJLoDPP00VwbcwTA9/PpRfee+akH1kuZ7JC9dwUT5X2u2gm1tiMVu5p6jNHbp+PCkcLrOuuX0XN/tcS9WyIHekt22M3jDRIFIJxxPYJENXtLSD8L0wRq56IYTS9CfdhMt67M+qw08bUFNbh8UHXE7HMcBxKmMOYR5YPpKXhGbHEMQMSqxFiKHyq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x/Fn1rPjoSv5xh+CGPw0NbLTtv5lyp8R7uQns19d/QS8t0DoVIe1xNjQPsvms1qnWr25TjRhgiGvEjKIBcws9e+8MyQXFilu4gDfBkbuE9rbYLxxxLHb3N8EaTjLrzcZ1sCAc//6HnLvaoZ4GwaIpd1AzJkN0fPV0+Q2RgeYOXkp2qVzsigHAh+TTRM9+U1SJ/PT2nrJRuYwBmjOgx/123dQVAMtYzeAZGHwJzB0rKr08ze/xkG5Wtr0ltJU= X-Bogosity: Ham, tests=bogofilter, spamicity=0.006867, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Fully describe how UFFDIO_API can be used to perform a two-step feature handshake, and also note the case where this isn't necessary (programs which don't depend on any extra features). This lets us clean up an old FIXME asking for this to be described. Signed-off-by: Axel Rasmussen --- man2/ioctl_userfaultfd.2 | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/man2/ioctl_userfaultfd.2 b/man2/ioctl_userfaultfd.2 index b5281ec4c..ef352a69d 100644 --- a/man2/ioctl_userfaultfd.2 +++ b/man2/ioctl_userfaultfd.2 @@ -82,7 +82,6 @@ struct uffdio_api { The .I api field denotes the API version requested by the application. -.PP The kernel verifies that it can support the requested API version, and sets the .I features @@ -92,6 +91,25 @@ fields to bit masks representing all the available features and the generic .BR ioctl (2) operations available. .PP +Since Linux 4.11, +applications should use the +.I features +field to perform a two-step handshake. +First, +.BR UFFDIO_API +is called with the +.I features +field set to zero. +The kernel responsds by setting all supported feature bits. +.PP +Applications which do not require any specific features +can begin using the userfaultfd immediately. +Applications which do need specific features +should call +.BR UFFDIO_API +again with a subset of the reported feature bits set +to enable those features. +.PP Before Linux 4.11, the .I features field must be initialized to zero before the call to @@ -101,24 +119,11 @@ and zero (i.e., no feature bits) is placed in the field by the kernel upon return from .BR ioctl (2). .PP -Starting from Linux 4.11, the -.I features -field can be used to ask whether particular features are supported -and explicitly enable userfaultfd features that are disabled by default. -The kernel always reports all the available features in the -.I features -field. -.PP -To enable userfaultfd features the application should set -a bit corresponding to each feature it wants to enable in the -.I features -field. -If the kernel supports all the requested features it will enable them. -Otherwise it will zero out the returned +If the application sets unsupported feature bits, +the kernel will zero out the returned .I uffdio_api structure and return .BR EINVAL . -.\" FIXME add more details about feature negotiation and enablement .PP The following feature bits may be set: .TP From patchwork Tue Oct 3 19:45:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Rasmussen X-Patchwork-Id: 13407945 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C414CE8FDB1 for ; Tue, 3 Oct 2023 19:46:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 445D98D0088; Tue, 3 Oct 2023 15:46:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3CE428D0003; Tue, 3 Oct 2023 15:46:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 247858D0088; Tue, 3 Oct 2023 15:46:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 0BB998D0003 for ; Tue, 3 Oct 2023 15:46:02 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id DACBB1A0468 for ; Tue, 3 Oct 2023 19:46:01 +0000 (UTC) X-FDA: 81305180922.02.A746818 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) by imf10.hostedemail.com (Postfix) with ESMTP id 687FCC0020 for ; Tue, 3 Oct 2023 19:45:59 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=xCh2YIlm; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf10.hostedemail.com: domain of 3dm8cZQ0KCPUXubioXpjrppbkdlldib.Zljifkru-jjhsXZh.lod@flex--axelrasmussen.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3dm8cZQ0KCPUXubioXpjrppbkdlldib.Zljifkru-jjhsXZh.lod@flex--axelrasmussen.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1696362359; h=from:from:sender: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=saHgOnMA67n4gZwlJ4PpFPUXnm1EsnwqlouJFj0QSrA=; b=TbGUHAcyAtYzIS6h68SvHIbtRl8nDii1/wpSTsGNXWZOaqtVdo/hwzCqDSdAhGbdJ3j8RG oUTUc1mjOjFsowkY1b2z0wFm/J/GXNkbJTpmBS9KQHx4LC5MEqmOVaco4X9qBQgHDCPEs2 6UnNelFq7XIBbaGZaSLxrMuVlQUzl/M= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=xCh2YIlm; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf10.hostedemail.com: domain of 3dm8cZQ0KCPUXubioXpjrppbkdlldib.Zljifkru-jjhsXZh.lod@flex--axelrasmussen.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3dm8cZQ0KCPUXubioXpjrppbkdlldib.Zljifkru-jjhsXZh.lod@flex--axelrasmussen.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1696362359; a=rsa-sha256; cv=none; b=SfYkj46VeRNkRfSUvDzwI0rGPJ+mffXwGHYv+b0L7x9iUDpqFGoueZDN1i6eaoKaCvH2wL UQaAf3UsiqRqcJBBJM5t3CwlJFbAtg1B3JPa/1x0R21NRCVIDmo5oShosg0BjL3OkqCaHC A3wCb4ATbC4bFAYVsZeUO3i6J8E9xhU= Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-d8153284d6eso1589772276.3 for ; Tue, 03 Oct 2023 12:45:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1696362358; x=1696967158; darn=kvack.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=saHgOnMA67n4gZwlJ4PpFPUXnm1EsnwqlouJFj0QSrA=; b=xCh2YIlm9Y7UL8roIsCegN5wCafiuWxFjqW6RaDV6huRENgvyzHrItrwpzWLALgGbY MaBbPDu7cGaH9iFFV9m0U3iYw2+UjHHKbh41p1xCMwhVmtTMPrsBEjujnsmIqhgr0tgO 3h1I47or0GhRVLujbcSGXCiBBTEB7QVdQB+NDPVMA7dQA2RLciN5Fu9fdh0nQLgb8+b2 JRnxhZTS3rq/XU+ioZb4AvW48J6e+4Q3VrVdS9Hg6VYjkdNHlh6E148dv9h7CDjlZZHw nGuUSQAH8xCSVJMA8RpHOCCucHriMTsh+MfIaw2F5Dc2g86hfiCCtCMCts/uqBYUK5BA lp1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696362358; x=1696967158; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=saHgOnMA67n4gZwlJ4PpFPUXnm1EsnwqlouJFj0QSrA=; b=K7IUk/SOnp17dToc26ybt6I8/Kfi7nDtDkt1ArWNFwhNouADgBmuwGjluSVL7OiCFv giv3NdQsJfrWbtQhbp3aHZgCF7ogvcusBMlTptT5fgqPm8XAfVLOTsdJvY6yBwLizFBN 4SWQ5iwk78FLUhDLpfbjYODMd2xdoK0ihygSmn8C0CVDlrFe63sHh/Std0q1y46FsC8H aVomf05dib7zO8HsmaBwq0GELxiPn8c4Rla0RQMfEN5m0c802XzCuuB0jlJrocv3TW6/ KQLTe1oERsgw4r1t1PtlpikXqAR2Pxa+v0z8Zt7hn67MqwKmjcKWct+vcknoTwlrb/t7 kHTQ== X-Gm-Message-State: AOJu0YxLvvSG9z7cw/6SNYpnjhJrS5iasg8iQka1c3Iq4/Q+be1NoMI3 CnklF2GISh/xgv8DZn8dWEZWfJ8k5WPJB+zfomvg X-Google-Smtp-Source: AGHT+IE+GcDf+X27c5kJNc3oNmGJKigBdaixTtklNARXTwZm81BadP68GajItBX8aDtIKT3fxza5qJXIav70Sa2bVhk8 X-Received: from axel.svl.corp.google.com ([2620:15c:2a3:200:6577:b8c1:dd2d:1c93]) (user=axelrasmussen job=sendgmr) by 2002:a25:770f:0:b0:d35:bf85:5aa0 with SMTP id s15-20020a25770f000000b00d35bf855aa0mr4058ybc.4.1696362358605; Tue, 03 Oct 2023 12:45:58 -0700 (PDT) Date: Tue, 3 Oct 2023 12:45:44 -0700 In-Reply-To: <20231003194547.2237424-1-axelrasmussen@google.com> Mime-Version: 1.0 References: <20231003194547.2237424-1-axelrasmussen@google.com> X-Mailer: git-send-email 2.42.0.609.gbb76f46606-goog Message-ID: <20231003194547.2237424-3-axelrasmussen@google.com> Subject: [PATCH v2 2/5] ioctl_userfaultfd.2: correct and update UFFDIO_API ioctl error codes From: Axel Rasmussen To: Alejandro Colomar , Peter Xu Cc: linux-man@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Axel Rasmussen X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 687FCC0020 X-Stat-Signature: o39exrtfqg87pfisjktnjpxu1b431o4j X-HE-Tag: 1696362359-488575 X-HE-Meta: U2FsdGVkX1+JFeOXdYsgwMxKKoZ0Km1fTzowjHzOD2z7tTrZ6JHniaiaGxWoRAhPJtZcPsCJA69b2W4MUDCvCXaZlbr8iFuG7pya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CPIvIACEXcyRzDaj48d8LKpNhjm1U8crZWBnoSo/V9JmbwJLMxLY74W0y7X6YVWUOwIe+Cn9zAd7fWCwuzx3ISsxENDiy0JLIYVoOxse3NmbebE3y/Yk4dvvm7679uTegoA7ip3Z5n0rU6Hv9Sz16lSSSCr/nuI/u31iykBtKQi3gp9zm8GF+Q5M6pBxxWNOrVGG5afMJzyjJIN+yo9k4Kpr0gxmxFZUK3IRIc8eIqeFL+CLP6YgBIYRR9Uk1ihlMqIdLeIkW3oGpIEHjkUsSOL/W5tOzNG0iK8tiTvJ6OpIDsyB479viJnTPwjy4giMgu3XOH6gWZuQWpuU/zwKDU4Jz002Pjr1ccYu2CdXAmRrRBHVzfHRrL5oN6XJzQL8yilyRHT9x33v5jqHe7rlwhHYVBYiv8= X-Bogosity: Ham, tests=bogofilter, spamicity=0.018999, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: First, it is not correct that repeated UFFDIO_API calls result in EINVAL. This is true *if both calls enable features*, but in the case where we're doing a two-step feature detection handshake, the kernel explicitly expects 2 calls (one with no features set). So, correct this description. Then, some new error cases have been added to the kernel recently, and the man page wasn't updated to note these. So, add in descriptions of these new error cases. Signed-off-by: Axel Rasmussen --- man2/ioctl_userfaultfd.2 | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/man2/ioctl_userfaultfd.2 b/man2/ioctl_userfaultfd.2 index ef352a69d..28dd2fcdd 100644 --- a/man2/ioctl_userfaultfd.2 +++ b/man2/ioctl_userfaultfd.2 @@ -256,17 +256,31 @@ refers to an address that is outside the calling process's accessible address space. .TP .B EINVAL -The userfaultfd has already been enabled by a previous -.B UFFDIO_API -operation. -.TP -.B EINVAL The API version requested in the .I api field is not supported by this kernel, or the .I features field passed to the kernel includes feature bits that are not supported by the current kernel version. +.TP +.B EINVAL +A previous +.B UFFDIO_API +call already enabled one or more features for this userfaultfd. +Calling +.B UFFDIO_API +twice, +the first time with no features set, +is explicitly allowed +as per the two-step feature detection handshake. +.TP +.B EPERM +The +.B UFFD_FEATURE_EVENT_FORK +feature was enabled, +but the calling process doesn't have the +.B CAP_SYS_PTRACE +capability. .\" FIXME In the above error case, the returned 'uffdio_api' structure is .\" zeroed out. Why is this done? This should be explained in the manual page. .\" From patchwork Tue Oct 3 19:45:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Rasmussen X-Patchwork-Id: 13407946 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3BFD0E8FDB4 for ; Tue, 3 Oct 2023 19:46:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B4C3A8D0089; Tue, 3 Oct 2023 15:46:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AD3B78D0003; Tue, 3 Oct 2023 15:46:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8B0C88D0089; Tue, 3 Oct 2023 15:46:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 704D28D0003 for ; Tue, 3 Oct 2023 15:46:03 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 422C41CA3EA for ; Tue, 3 Oct 2023 19:46:03 +0000 (UTC) X-FDA: 81305181006.16.E27F578 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) by imf01.hostedemail.com (Postfix) with ESMTP id 8244E40014 for ; Tue, 3 Oct 2023 19:46:01 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=lRCJuJ6i; spf=pass (imf01.hostedemail.com: domain of 3eG8cZQ0KCPcZwdkqZrltrrdmfnnfkd.bnlkhmtw-lljuZbj.nqf@flex--axelrasmussen.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3eG8cZQ0KCPcZwdkqZrltrrdmfnnfkd.bnlkhmtw-lljuZbj.nqf@flex--axelrasmussen.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1696362361; a=rsa-sha256; cv=none; b=BRFHlLmlywa53hIxsqn4u0TMj6Eu7ZyjX4ZKecBbb1Kf+JMs210IMEfRfHFrOMvuKi++ZB qp1fAwToeOwyzTIN3BH9hLw9jKfZ5oYJHRUk28Gii4HFJoBBapx7rqpJeS+UtgQeBDeoz+ dZgRPSd0Q2jP9lGwHL8eGZyyt00p2s4= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=lRCJuJ6i; spf=pass (imf01.hostedemail.com: domain of 3eG8cZQ0KCPcZwdkqZrltrrdmfnnfkd.bnlkhmtw-lljuZbj.nqf@flex--axelrasmussen.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3eG8cZQ0KCPcZwdkqZrltrrdmfnnfkd.bnlkhmtw-lljuZbj.nqf@flex--axelrasmussen.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1696362361; h=from:from:sender: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=nSwsPxGjU1Rb9Mh5qgmhu8siiN6wKhSBap+YrmkGvmo=; b=RZg8SqsjXt9SazsL0JfazCbnKLx/AoB6R0JlCK6i6Yse6HIcI3mwVjiJ9E/c/6HSnvZxOL nK7sUXTPsje3f+dfhlDGFeyJYnN0KCpd7P0PaYVtzfwv4ZEcGm8GEopsEIp6dxD2hxQw9U AN7G1/QjczuU7YqhAeUKPKmqFEtD3XI= Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-59f6902dc8bso19974837b3.0 for ; Tue, 03 Oct 2023 12:46:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1696362360; x=1696967160; darn=kvack.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=nSwsPxGjU1Rb9Mh5qgmhu8siiN6wKhSBap+YrmkGvmo=; b=lRCJuJ6i93cWrkVuBgfEiPHvalwL5Tm4tFbLJt2I3AUUrk9w8oZnSb5bCE16wC3HCJ dYo/bV1i/eycMM6VlzzH/ROR8qtsGkyQfwVUioKdUKEzNXp2cuGs4GHsyB4YmTScwL3T SMmsvZbWdZLJl3JtFWQ6vrfKPz2JgrSut9V2pMEkotIisKOm+Yy3TMItTa4T2GFrMNXi WaKNEC7BOHHE9RoLt+s1pwVOKe41VKjlogKSsso2IELbZ9gtoQezsIog8LK2NetSOfB2 pfOvwgIn8I6gXW0kk4QU/cIayHoan+RTR9ndDaxR3V0BN8xbeHM+fHuGVUBcr+2oo2T3 IVEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696362360; x=1696967160; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=nSwsPxGjU1Rb9Mh5qgmhu8siiN6wKhSBap+YrmkGvmo=; b=cMyFi0KZg154FCTFkbddLDzuYlkFpA6zoDd9GzrrgrGvHB9CnXbXkFiPFNvq44pekx KqoX+GIybc5YSlPeYWPxaz9+SGhpMBpyGXdYAkttXENa5VVT//LAB2wUfeprWya13ZlL IMc2lCd5k32uPBn9GISsnko35mvs2fFt9mNblUZmRLStQOhzRnBh4+Z5gZ2+FGZrSwmh uapqzPpwFBVjDVUtNewUQXPxjPhI9plsPw9R6lNUzj5EKdH9kgbqDbCGYD2IBah3IW1/ ER+oTgMNkypmIBVONXP/MBA/FnElKY0H3VeGIf+Ex/4qIv0ntuTwil91L2eNp+wejVv7 czuQ== X-Gm-Message-State: AOJu0YxM2pWV7fntjifAKfCt0CVWCyxr04v3WCyjuQ7AGDoI8zsJgr+k gwvBxh4ETZmPfXa6a0JKzljs9ldqX5fPUUZ0qp5i X-Google-Smtp-Source: AGHT+IG3ycgZ1ANRvhM0b8aR3O2JnbWKMJw5/2E7Y5Hu+lkyPvKs0PdaMQEwpxKlWPfeoGQhQE8730YP86ImtOIxI0CZ X-Received: from axel.svl.corp.google.com ([2620:15c:2a3:200:6577:b8c1:dd2d:1c93]) (user=axelrasmussen job=sendgmr) by 2002:a81:ae53:0:b0:59b:f138:c843 with SMTP id g19-20020a81ae53000000b0059bf138c843mr9811ywk.3.1696362360670; Tue, 03 Oct 2023 12:46:00 -0700 (PDT) Date: Tue, 3 Oct 2023 12:45:45 -0700 In-Reply-To: <20231003194547.2237424-1-axelrasmussen@google.com> Mime-Version: 1.0 References: <20231003194547.2237424-1-axelrasmussen@google.com> X-Mailer: git-send-email 2.42.0.609.gbb76f46606-goog Message-ID: <20231003194547.2237424-4-axelrasmussen@google.com> Subject: [PATCH v2 3/5] ioctl_userfaultfd.2: clarify the state of the uffdio_api structure on error From: Axel Rasmussen To: Alejandro Colomar , Peter Xu Cc: linux-man@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Axel Rasmussen X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 8244E40014 X-Stat-Signature: xtop378i936ugbo5fw6fn5p1r6sazidi X-Rspam-User: X-HE-Tag: 1696362361-969752 X-HE-Meta: U2FsdGVkX1+1bRBSBSoz71E+LRoJuR4Bpy4eUPofz8zdhV0Z1Mnb9ZkYx/4M5Uvu4tzKCd7Qsv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SlIFV2DIjUg5jHAbDG8hOAvx4sgRta3sa/tJy79pHQLvFb8F3xi4PXCHiHro6ouCNVBjYvJBonnH3dTodlTWwhLqFDeICjqAmagBkvBiMlqBp8UbMXoFaY8vqcctilRvYFEXVmQfMixqqhKbbwkggQU3hfUHOeLjzlueTvDaWjVtrAvzmnyNS7y2spS3tg/noNxM/cYWQQvIYsWKNgeBteVJOoGpY4VfpSmn+NI5O4jHMOsUehWpUEB+cwpR2RBWKrIay3aTpk72pI5ixbTIe8z0HMG4hOJ2m36QR8UT7RgNF/c/k/U2Ca0JKpELYnHrlxAyakd8qxptpMZyWdMxdMbIHHOBv8PbRcGwAK3SYLGBkv9Z6mHEG681jlKFtz2LqUIou/Jl8gykJqdmYikkpIaf/uiv1aR/4ydzh31jfXaxqbHhB74k8taAbnAEphyepHc/FnQtB1CtF3ON2NjKwiYIZvAIyTQgAVLBFKOKVx0ZSdJTBLCtiYtM5LitQtJVafgtSoNb+uVh1eT/ukak0Lqy3DjQwpCzAIDAhVCg8gnznyvao= X-Bogosity: Ham, tests=bogofilter, spamicity=0.116676, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: The old FIXME noted that the zeroing was done to differentiate the two EINVAL cases. It's possible something like this was true historically, but in current Linux we zero it in *both* EINVAL cases, so this is at least no longer true. After reading the code, I can't determine any clear reason why we zero it in some cases but not in others. So, some simple advice we can give userspace is: if an error occurs, treat the contents of the structure as unspecified. Just re-initialize it before retrying UFFDIO_API again. Signed-off-by: Axel Rasmussen --- man2/ioctl_userfaultfd.2 | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/man2/ioctl_userfaultfd.2 b/man2/ioctl_userfaultfd.2 index 28dd2fcdd..2ee6a0532 100644 --- a/man2/ioctl_userfaultfd.2 +++ b/man2/ioctl_userfaultfd.2 @@ -248,6 +248,14 @@ operation returns 0 on success. On error, \-1 is returned and .I errno is set to indicate the error. +If an error occurs, +the kernel may zero the provided +.I uffdio_api +structure. +The caller should treat its contents as unspecified, +and reinitialize it before re-attempting another +.B UFFDIO_API +call. Possible errors include: .TP .B EFAULT @@ -281,14 +289,6 @@ feature was enabled, but the calling process doesn't have the .B CAP_SYS_PTRACE capability. -.\" FIXME In the above error case, the returned 'uffdio_api' structure is -.\" zeroed out. Why is this done? This should be explained in the manual page. -.\" -.\" Mike Rapoport: -.\" In my understanding the uffdio_api -.\" structure is zeroed to allow the caller -.\" to distinguish the reasons for -EINVAL. -.\" .SS UFFDIO_REGISTER (Since Linux 4.3.) Register a memory address range with the userfaultfd object. From patchwork Tue Oct 3 19:45:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Rasmussen X-Patchwork-Id: 13407947 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7591BE8FDB0 for ; Tue, 3 Oct 2023 19:46:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C0FC18D008A; Tue, 3 Oct 2023 15:46:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B70328D0003; Tue, 3 Oct 2023 15:46:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 976878D008A; Tue, 3 Oct 2023 15:46:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 754978D0003 for ; Tue, 3 Oct 2023 15:46:05 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 48D4C14042C for ; Tue, 3 Oct 2023 19:46:05 +0000 (UTC) X-FDA: 81305181090.19.1DAFE0D Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) by imf06.hostedemail.com (Postfix) with ESMTP id 97383180002 for ; Tue, 3 Oct 2023 19:46:03 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=E01ITjN+; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf06.hostedemail.com: domain of 3em8cZQ0KCPkbyfmsbtnvttfohpphmf.dpnmjovy-nnlwbdl.psh@flex--axelrasmussen.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3em8cZQ0KCPkbyfmsbtnvttfohpphmf.dpnmjovy-nnlwbdl.psh@flex--axelrasmussen.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1696362363; h=from:from:sender: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=KHojRgQcvHJlG3tNkbT5JYy4vaQ9RVgTVjOSA6AH+sQ=; b=WvOPshJFtMVZ++a1MIAo7tWqH6zf55zcD+49ihDee7H835O5fG6xakOSvACo3gjgBD4fpK 6iZuRxGbAzDpBgxoQh7WhPanmLVmPvR18VCyIKmVd6O1vCwSi/iCHbr23/YRStEDUHiGF3 5Sl8Cqv5lBD8LOQtlpa6PKz4RRgHmGU= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=E01ITjN+; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf06.hostedemail.com: domain of 3em8cZQ0KCPkbyfmsbtnvttfohpphmf.dpnmjovy-nnlwbdl.psh@flex--axelrasmussen.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3em8cZQ0KCPkbyfmsbtnvttfohpphmf.dpnmjovy-nnlwbdl.psh@flex--axelrasmussen.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1696362363; a=rsa-sha256; cv=none; b=ckQ1jnkKx2rCEG2EnXK/KzkzJjVMUKmjMUmY9IvUSwFNoS8wKxfzdNisAtO/8BO7B7bGC0 N4MloriOVUKtwAQ45v9SJj3bTZxsvCroSxDVjTOM9y0qI5REOzw2WCu6ZCOHmVXKz/NW1F yPttYS3ZYRAA/MEepL2xZVVWOx7jYNw= Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-d868842eda1so1720032276.0 for ; Tue, 03 Oct 2023 12:46:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1696362363; x=1696967163; darn=kvack.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=KHojRgQcvHJlG3tNkbT5JYy4vaQ9RVgTVjOSA6AH+sQ=; b=E01ITjN+ohmAq0nlSaiLcFZXh1XHPAI2gM76x2cstWeuC2km4A2Vazw412cuDPXPuI aiaDXYI6xNlJ56axvPxeAq0xOyex1ZrGLC6bIIfDr+6MbkxzPaY+nKhgOO07o4+z0Dq3 7bxOy7XraEvaeXsLFXl/Ju+6Nnji19Z9QjaS7RgnEk9aP3guNhXtauVSvU1FAkWOYMDY JclFYtfxlTOrB0BmBYXixZj4ROjmwG/O8XKZJSoXh865Xf/kQxwSQMY8uy65/dFYiXq4 8oyqWw8XRg+LaTYy3UdQe0uzgIJNd01DOQHgPAmfv8RIat7xxmWwlJHKKM0XrFJQ+VzZ zkXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696362363; x=1696967163; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=KHojRgQcvHJlG3tNkbT5JYy4vaQ9RVgTVjOSA6AH+sQ=; b=RbYAJLeFD/FhpJ+0vGlM/kZP3l9KJ7BYq1/Qkn7n3bx+HveRBYtRO/Ej899rsoRtT+ l/yFd5d+qQon3ebagWAqPHG2jzZi9vOn8us/+QgNlCzmSms8i+msP/x+NDZr7OoUKmaq VWc63SAgma5P3cTrFErY0fEAzv1bqBEaUfqodMwDGQQ/TrnHehrscty+3zUBncBeVdyY z4S2Co0Ea4k95+sQb7iWqMeApDbVXNf7qOu3tIx2ULDYH165a7dJL8cg0J0/3nM2YUBP gfaxMqiy8+YcI1+7AASK/1iryI2hdwbR7MD115ua7cG0qEnsKvlvuevK2mIM9kFdQyWR HuMw== X-Gm-Message-State: AOJu0YyP5hPqN/1fW33H6KmZnh9NgYcQUiN5qQcfOIDlNmd8WigMGkV3 1ZFigXdy5FX0SDB+JrHRNXIynaQDmiYVAcqT9YGH X-Google-Smtp-Source: AGHT+IEqhtFQcshbqUK4gTfwcaeBbR5gxWj6j2J6NdanzQb0K4203DhX5lB+56HhQWq3zs1Ah3+xDDFNYZ8+YYbf0JmL X-Received: from axel.svl.corp.google.com ([2620:15c:2a3:200:6577:b8c1:dd2d:1c93]) (user=axelrasmussen job=sendgmr) by 2002:a05:6902:212:b0:d89:b072:d06f with SMTP id j18-20020a056902021200b00d89b072d06fmr3912ybs.7.1696362362806; Tue, 03 Oct 2023 12:46:02 -0700 (PDT) Date: Tue, 3 Oct 2023 12:45:46 -0700 In-Reply-To: <20231003194547.2237424-1-axelrasmussen@google.com> Mime-Version: 1.0 References: <20231003194547.2237424-1-axelrasmussen@google.com> X-Mailer: git-send-email 2.42.0.609.gbb76f46606-goog Message-ID: <20231003194547.2237424-5-axelrasmussen@google.com> Subject: [PATCH v2 4/5] ioctl_userfaultfd.2: fix / update UFFDIO_REGISTER error code list From: Axel Rasmussen To: Alejandro Colomar , Peter Xu Cc: linux-man@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Axel Rasmussen X-Rspam-User: X-Stat-Signature: b1zn1s6ksqcnw5y71chco7a8b87n77f7 X-Rspamd-Server: rspam07 X-Rspamd-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y+ABYkdoXpuEGljINVCupvajSzns5XgE9pGmF6NmAtrq4kMHnFKrQLFiJS0hZZja9/1S6N91HGwSjVOxUn8H1fC6Ywp3Q7EToBG7EjdW9eMKGc9z5jlNQqjbypiA0sZEDVh6ATcKDarEjAUyL0rJAIfZTLj3K1HJa3FsKizvB/1f+q9yoCWOyyliSAQvuRayZk9QXIpZdLk1tEHwoBZzCjZP5cjeaLb+igWJqoo6n4SP7o9uXPDnaYpslENdgICLwX7qU7zz7sxD0cX36TJYloDulrk7zKsYOJu6lpXKABVjVhsKsyRynLm1XBw/dwSn1+TBQIE5Kns+4NZeU3fYq1s3kXBadLlnjiUCELwqRin9oRGCBcHqngH5KO0zvTUbgvwSzBh3TSvJHK74KCr3Gkd7vE+QzsmV2tmj2yP0FVU7CoVkdvcGhX8vj/BLsQR+uaBQIkJzpmhDYqTB2CLzV6TP30jXZLt9CL7aw68LBGutggZTjxLO0/5IwZDhlmBSOWmBcKL/6mLrLefv+j2krHEr8DpwG+ekYSxb2N6xRDzh0= X-Bogosity: Ham, tests=bogofilter, spamicity=0.005592, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: The list of error codes in the man page was out of date with respect to the current state of the kernel. Some errors were partially / incorrectly described. Update the error code listing, so it matches the current state of the kernel, and correctly describes all the errors. Signed-off-by: Axel Rasmussen --- man2/ioctl_userfaultfd.2 | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/man2/ioctl_userfaultfd.2 b/man2/ioctl_userfaultfd.2 index 2ee6a0532..95d69f773 100644 --- a/man2/ioctl_userfaultfd.2 +++ b/man2/ioctl_userfaultfd.2 @@ -388,12 +388,6 @@ On error, \-1 is returned and .I errno is set to indicate the error. Possible errors include: -.\" FIXME Is the following error list correct? -.\" -.TP -.B EBUSY -A mapping in the specified range is registered with another -userfaultfd object. .TP .B EFAULT .I argp @@ -408,21 +402,32 @@ field; or the field was zero. .TP .B EINVAL -There is no mapping in the specified address range. -.TP -.B EINVAL +The specified address range was invalid. +More specifically, +no mapping exists in the given range, +or the mapping that exists there is invalid +(e.g. unsupported type of memory), +or the range values ( .I range.start or .I range.len -is not a multiple of the system page size; or, +) are not multiples of the relevant page size, +or .I range.len -is zero; or these fields are otherwise invalid. +is zero. .TP -.B EINVAL -There as an incompatible mapping in the specified address range. -.\" Mike Rapoport: -.\" ENOMEM if the process is exiting and the -.\" mm_struct has gone by the time userfault grabs it. +.B ENOMEM +The process is exiting, +and its address space has already been torn down +when userfaultfd attempts to reference it. +.TP +.B EPERM +The userfaultfd would allow writing to a file backing the mapping, +but the calling process lacks such write permissions. +.TP +.B EBUSY +A mapping in the specified range is registered with another +userfaultfd object. .SS UFFDIO_UNREGISTER (Since Linux 4.3.) Unregister a memory address range from userfaultfd. From patchwork Tue Oct 3 19:45:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Rasmussen X-Patchwork-Id: 13407948 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 64C7BE8FDB2 for ; Tue, 3 Oct 2023 19:46:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AD8988D008B; Tue, 3 Oct 2023 15:46:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A63A48D0003; Tue, 3 Oct 2023 15:46:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8637F8D008B; Tue, 3 Oct 2023 15:46:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 6C77A8D0003 for ; Tue, 3 Oct 2023 15:46:07 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 3DF8340458 for ; Tue, 3 Oct 2023 19:46:07 +0000 (UTC) X-FDA: 81305181174.01.F0AB579 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) by imf24.hostedemail.com (Postfix) with ESMTP id 7844C180023 for ; Tue, 3 Oct 2023 19:46:05 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=AIjr10qh; spf=pass (imf24.hostedemail.com: domain of 3fG8cZQ0KCPsd0houdvpxvvhqjrrjoh.frpolqx0-ppnydfn.ruj@flex--axelrasmussen.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3fG8cZQ0KCPsd0houdvpxvvhqjrrjoh.frpolqx0-ppnydfn.ruj@flex--axelrasmussen.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1696362365; h=from:from:sender: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ocOKNhdUvGY6/aq7ieB9QOD0OYSMZQy4WsHc5CUE0HE=; b=OGxakpoWtgGt7n4VVKdKIfdRLmANE/OFBXr5b7Vp6jZHkIAaFk6/VGPKENCZqTfdHojndi lukUAEL7TVEQnicFgd5MqFq8++Ospl2PlMQ0m7OMy+VOxCADdFtqBwe+Nk8THr98ZtnuWC DPOI0ISr4dByVAgWnAyxrO5I3bi+l5I= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1696362365; a=rsa-sha256; cv=none; b=QP9z+E+/EyQ2rI66bpbmq9MbrX3Sd0ytc37UMTEJLDMq8wRDP1yHrg1vT0kC1us9d/plSV 8JLuDR2x5u5drgnrc4SctZ+vRxFpCcpZrq5FcfHQ6+5MtCdMeCoqt6XlPGXNVa7YHsetfm 2k6dcxWEkM/ueaVZSjmMSLZkAKNMfvI= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=AIjr10qh; spf=pass (imf24.hostedemail.com: domain of 3fG8cZQ0KCPsd0houdvpxvvhqjrrjoh.frpolqx0-ppnydfn.ruj@flex--axelrasmussen.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3fG8cZQ0KCPsd0houdvpxvvhqjrrjoh.frpolqx0-ppnydfn.ruj@flex--axelrasmussen.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-5a20c7295bbso1539167b3.0 for ; Tue, 03 Oct 2023 12:46:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1696362364; x=1696967164; darn=kvack.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=ocOKNhdUvGY6/aq7ieB9QOD0OYSMZQy4WsHc5CUE0HE=; b=AIjr10qhGCageKCrymw5d5TFtD03y0Uo8U2TDv/r1Bv579OJA2RKHBlBTpZVWHltTe g3CpKXsDCSyUxQ1flBxaFuk1WENhujk/bipmG0ZdN8Ammg4DhjhCOZT+ZxzEFonrvuz8 ShIYr2vobTGRZmfA38KhyFwDVYzEHB/RirC64Ta7afuGeDvx/Ne8eFPauMmMexGmGyoa hpNqLeOV5fQrAwxHbexetjK8lE8smcPyjNdjfcrY8DVhWMou7rx0rKkLu54KtHpHgu0J 0aW8dLfmgoC4QZVpA1eQWq7BqWDezQbaYsgigdyng9MMBApj4pAxP1WJSz9L4o3wjmV5 pYhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696362364; x=1696967164; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ocOKNhdUvGY6/aq7ieB9QOD0OYSMZQy4WsHc5CUE0HE=; b=UyF80zdR/qldVLjunlN7/DgyXtC/6DFoW1MnCZifBXRfNeeS294wwHLAPKGXIWS9QL eyQq8XgCBJ07pgh0gh5aOoN3phDZH4hND7CYszPlTLaa/QtkdVXCAMqMRhecZRR/2FHl AKGBaoPmojH+Ew5LlmRYJsCiYL20LcwLqhHel0SxVI64h6Y7UaAc6D1OIA1HTo2c+dk4 p8uSibuMPKNida17GHPlhQQHUZG8yS06HZ6fae7+0aGAFVZHJtfCl/As181GYhaBFE3o VR7cosZLTBocBv3yh9SikzBmKnXWSgMv/afUI3BSUobhexvL3tSxo4JarFQBwypgAZzK AgZg== X-Gm-Message-State: AOJu0Yy//F7Oq1SP0dMVYAJDvyhz887SyGagide4wA7TVjGhk7UIQnRk C4XA1gQtZREf7PqBeQnkX8rMqo5ddifkMEQ8XURK X-Google-Smtp-Source: AGHT+IGX6pNwu3ESq/UN3DQ8E4VR3aqp5GHkfoy0UspQ/ctrBmmE6u0DHXZ9fEYmIiF/O9MZkGLTajhNajMrNK//v5a7 X-Received: from axel.svl.corp.google.com ([2620:15c:2a3:200:6577:b8c1:dd2d:1c93]) (user=axelrasmussen job=sendgmr) by 2002:a81:d106:0:b0:595:8166:7be with SMTP id w6-20020a81d106000000b00595816607bemr6831ywi.0.1696362364727; Tue, 03 Oct 2023 12:46:04 -0700 (PDT) Date: Tue, 3 Oct 2023 12:45:47 -0700 In-Reply-To: <20231003194547.2237424-1-axelrasmussen@google.com> Mime-Version: 1.0 References: <20231003194547.2237424-1-axelrasmussen@google.com> X-Mailer: git-send-email 2.42.0.609.gbb76f46606-goog Message-ID: <20231003194547.2237424-6-axelrasmussen@google.com> Subject: [PATCH v2 5/5] ioctl_userfaultfd.2: document new UFFDIO_POISON ioctl From: Axel Rasmussen To: Alejandro Colomar , Peter Xu Cc: linux-man@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Axel Rasmussen X-Stat-Signature: zzmepjpiwu7axxisx8debfyi5ejx96tm X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 7844C180023 X-Rspam-User: X-HE-Tag: 1696362365-984302 X-HE-Meta: U2FsdGVkX18KYWZJ1ybTQSkauEnlMjRPyjStIFXv11MHYzReLRYU3xrqzhRF/DlB/4gp4IK5x/FihahXxHMSw74fJ+dzHYMsnwqG/tKmqCgn6ua1ohbzuB3/3eTsrVrCtu6LM+WL5b8H2tMdD9OdzHA0LWmx972BZjGtDR+01YgOia2OKGWqbfcA+bXsoxZWdiJUmr1AXoVaHdbctCmQn1mEqJg5OtmDTFGMmLsx2GbrjYpeVjcRZvFcsbhWp9pNj1zQ8FMYtJmpwkzdIchBIiFqx/MjvPaOi7foIB1ZSeLHQ6k8Cq+r2IGunuonqvZj74+mFNydRoJFsHz7rFVvOrHgeskTA5AtbL8c5v5evQ+4oIHm3YRDBSw2DKWb5a0maolp6bDsfbaTmW42JTXakXAwerOJFi+EsCRrQm8/2wk+MTeDEFHs/513dQJiGESUaUjK00fs4bi/I6zSJK4vIdctMD2VqMhG8Nybfi91E2kMsHM4dBxOfhOGKwz/yaC29pQQLJQvOr2TtT77Ch7rDE9lIkSLbSMmB+X10QR+lCecBMTCqnAd+f/Su5oo4u4U0SMW/O/4Dz/4GjlRhmD3OOzVEHZT0SIp/35uEbzpwCf28EekdEDKjQCPK7IbI0tRKTwMVwqhkIeopi68LgRphBmrV5Y8m2r2rOyBN7etHWn6/JJ+UD1IllTC9geIAftV3qZtdqofcbUvPqqb6IIUCseaKHwk1wBzU8x5ycU6q30bmMVDTlkn1g+BllP0k5KRDc7isQ9nNrTJgli+/oYB8KEmG5lfnNgDAaoB1qEOKNSM/ZnNVDMxxc1hkRIIOnCUmw9Set2/8/20C17DFtF5zHB+DFumYV2nhNnzBMOhEKY+Q0MxJBrLQ/FOxFYO2PNqFBwmUAK95iLtul+Xqj70q3vz6/7MDdw27Wr2v4dUn+rwUYoRVYhPZn21GZbGuMX4zYop+sL6thDfvsyX7iB 1dElTRPr 9kNp9s1+OAi1ElYXmin563p6V4NZKt0rmb71lPWlVjqpivrbUHqTAM29cudFXYBij11KFkDkuSD9ZK5QwK18vA9X19URrZiAV9nWvIfRtvGcsNNWyDTY3pws52M09flmHMRXk21gyMzSP33WDgcv6lyU+KzdbKRIUFsyqU1BxlpSZV7YA3WwpshgvCWtK3Zq7uQW/aBrXToXyQxpsOZ5+EMbAuoq0A9BcacnfXDNOzOhejXAE1uHkOPoflf24hC4lpI1vNY6qKifKNg/1t7tx4N3Ap5w9veuyrCynbwR7wyUfO5EQcN7XIiLWkrgKm4spzFMiQb80qhqREDQsYl2+QjATmA3zPNKQIPOFpbglqcUa0u8BoeEuDaPDLiV0PLrV9W3A4O21kHCvZgJPuC6dZ+HJVN70yGlMnjCCsNizA7AN6e2HfH0/KKtJPG3yyPXd4bfwwFbpQ5MisuCCEzUwYKeI/afkH1p6lhgX2D9W03J/onwRVCB7jxAWGe4017QI95Vic70DYyWbbuSKbtLZzzQTXFYRfJvIZK1bQ7fql7OEDkFPUgPOwK7t/pCHQu6GxNV9HmoPaGGNjpI9ExU8MdK49hrjvIALhKruaeMDXGHdXmUTklmwcYgnizy70OakB2YiKAGOSU1ZYd47j7VquJ+uu1EXOwEdMvmShXFNtpQjJF6XocJG4J5uzexM91wHb+hgZWlCT+5txzU= X-Bogosity: Ham, tests=bogofilter, spamicity=0.004466, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This is a new feature recently added to the kernel. So, document the new ioctl the same way we do other UFFDIO_* ioctls. Also note the corresponding new ioctl flag we can return in reponse to a UFFDIO_REGISTER call. Signed-off-by: Axel Rasmussen --- man2/ioctl_userfaultfd.2 | 112 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) diff --git a/man2/ioctl_userfaultfd.2 b/man2/ioctl_userfaultfd.2 index 95d69f773..6b6980d4a 100644 --- a/man2/ioctl_userfaultfd.2 +++ b/man2/ioctl_userfaultfd.2 @@ -380,6 +380,11 @@ operation is supported. The .B UFFDIO_CONTINUE operation is supported. +.TP +.B 1 << _UFFDIO_POISON +The +.B UFFDIO_POISON +operation is supported. .PP This .BR ioctl (2) @@ -890,6 +895,113 @@ The faulting process has exited at the time of a .B UFFDIO_CONTINUE operation. .\" +.SS UFFDIO_POISON +(Since Linux 6.6.) +Mark an address range as "poisoned". +Future accesses to these addresses will raise a +.B SIGBUS +signal. +Unlike +.B MADV_HWPOISON +this works by installing page table entries, +rather than "really" poisoning the underlying physical pages. +This means it only affects this particular address space. +.PP +The +.I argp +argument is a pointer to a +.I uffdio_continue +structure as shown below: +.PP +.in +4n +.EX +struct uffdio_poison { + struct uffdio_range range; + /* Range to install poison PTE markers in */ + __u64 mode; /* Flags controlling the behavior of poison */ + __s64 updated; /* Number of bytes poisoned, or negated error */ +}; +.EE +.in +.PP +The following value may be bitwise ORed in +.I mode +to change the behavior of the +.B UFFDIO_POISON +operation: +.TP +.B UFFDIO_POISON_MODE_DONTWAKE +Do not wake up the thread that waits for page-fault resolution. +.PP +The +.I updated +field is used by the kernel +to return the number of bytes that were actually poisoned, +or an error in the same manner as +.BR UFFDIO_COPY . +If the value returned in the +.I updated +field doesn't match the value that was specified in +.IR range.len , +the operation fails with the error +.BR EAGAIN . +The +.I updated +field is output-only; +it is not read by the +.B UFFDIO_POISON +operation. +.PP +This +.BR ioctl (2) +operation returns 0 on success. +In this case, +the entire area was poisoned. +On error, \-1 is returned and +.I errno +is set to indicate the error. +Possible errors include: +.TP +.B EAGAIN +The number of bytes mapped +(i.e., the value returned in the +.I updated +field) +does not equal the value that was specified in the +.I range.len +field. +.TP +.B EINVAL +Either +.I range.start +or +.I range.len +was not a multiple of the system page size; or +.I range.len +was zero; or the range specified was invalid. +.TP +.B EINVAL +An invalid bit was specified in the +.I mode +field. +.TP +.B EEXIST +One or more pages were already mapped in the given range. +.TP +.B ENOENT +The faulting process has changed its virtual memory layout simultaneously with +an outstanding +.B UFFDIO_POISON +operation. +.TP +.B ENOMEM +Allocating memory for page table entries failed. +.TP +.B ESRCH +The faulting process has exited at the time of a +.B UFFDIO_POISON +operation. +.\" .SH RETURN VALUE See descriptions of the individual operations, above. .SH ERRORS