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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id F1810E81806 for ; Mon, 25 Sep 2023 23:56:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 814648D0059; Mon, 25 Sep 2023 19:56:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7C4DD8D0007; Mon, 25 Sep 2023 19:56:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 68DF08D0059; Mon, 25 Sep 2023 19:56:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 59ACE8D0007 for ; Mon, 25 Sep 2023 19:56:13 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 2ABEB1A07A0 for ; Mon, 25 Sep 2023 23:56:13 +0000 (UTC) X-FDA: 81276781026.08.3C9F259 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf18.hostedemail.com (Postfix) with ESMTP id 750B81C0008 for ; Mon, 25 Sep 2023 23:56:11 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=lFJAIlat; spf=pass (imf18.hostedemail.com: domain of alx@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=alx@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1695686171; 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=K6GQ7ukJl+jUEVvtFVZciFHPhCJ68mHuFz4TQTNjyGI=; b=Hg2i1gI/p11mcKm+tIO0lDRL7oA5tnkq8TMvXiQB96oTtzmp1PXrRhs0VDvm4rtfdsSFE2 a+4Pn6rf68zpZXGj9LVBMGY3X7ois7AtVOgP+0A5AZ3tBpyIQxgIbZUoLqvG83xQp7XVdu pDdV+ss10mxjqg8Q5q56n1DrO11lNaQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1695686171; a=rsa-sha256; cv=none; b=YuoTTVDfNgamjl+ZhtpbYDENJl/X8xh5vbopVAYhanYQrKHfSVECiSDOT+hZvtm0vdq9yp U9qAGvlDLg9hNkDl4QKjuFnsKNWmkP5y41cdU/HwnvJwI6bMWy2XNfeLpe6OzFo94+po6H KiNjTLjmSQzvE3M6wv+VmK+XDvJ8T8A= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=lFJAIlat; spf=pass (imf18.hostedemail.com: domain of alx@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=alx@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 9C84560C75; Mon, 25 Sep 2023 23:56:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1CCCFC433C8; Mon, 25 Sep 2023 23:56:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695686170; bh=BMrAGXuGExETbvl5OiPJxS7FFi7b70fqhN0uHMUVHQg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=lFJAIlatXeyOUDs74QXRdl2atE/vvik57PP8PsLPzOPzYJIHXS5PUkApsT9KW+SAh wj7wy/yd8YtQh2GK39lImhNCGiQ/eLstIImoKBLHE7RkWNcjhwhK80pXtnjc0loFtB D6JbzCOyLvnmKJwkmM0ld75rz9qJiMkJ51o4KQfNmuYZ6sn4LKf7KX8ri2Jfm2ZFcG xj+691RvxkWxKF89n+bbEogBf2JTBElhAy6TLaWyp6/IhDubLMirWgnLtjf37UeM/+ zLlOTYxjVjc/trSXzY9KXs/veAdh8btFXZRNwjvJMpO8ChX6FLwCz3dKF/gMBVUT7Z nImkyVzEws5/w== Date: Tue, 26 Sep 2023 01:56:06 +0200 From: Alejandro Colomar To: Axel Rasmussen Cc: Peter Xu , linux-man@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 08/10] ioctl_userfaultfd.2: clarify the state of the uffdio_api structure on error Message-ID: References: <20230919190206.388896-1-axelrasmussen@google.com> <20230919190206.388896-9-axelrasmussen@google.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="sywgjbkq4kcpxg35" Content-Disposition: inline In-Reply-To: <20230919190206.388896-9-axelrasmussen@google.com> X-Rspamd-Queue-Id: 750B81C0008 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 7cmgk7h8e8a7dyn9817yyqxx8xnhaqe9 X-HE-Tag: 1695686171-666330 X-HE-Meta: U2FsdGVkX1+JwhF7beEhgJxQl0Diz82ruxcthsz/spSfjshwrW4tguIALTns8ejogxlT8zudj04AZR0BSUx7A3EQlE/kvQUvf2fDZC7dhBoWhSYdCLrWIppFKshl43vzyPwwGnu76koMk/7i/HNjkFzsfESP0Q3mZT00SVTu0Yq9EmYRvSWvV3FwP7ozGMPgoAqpF2Z+jpTy0qfRjwSUG49HPMOpOqXfHJIo7ZqsghjZqNhKi3euZbRjBdcKuHVf2sj5ZY0NV66JbzeG3nfJXXQRJzpcMhUG5gjR2Q0mucFPAtZGRDX3JsVdZ89szAzan/vZlh2U6riya0TGaVerP64cza1T+QOF22m9Ul4FkkKnKwgwVD6dCf8dnX5QsdFbGt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ux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: --sywgjbkq4kcpxg35 Content-Type: text/plain; protected-headers=v1; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Subject: Re: [PATCH 08/10] ioctl_userfaultfd.2: clarify the state of the uffdio_api structure on error MIME-Version: 1.0 Hi Axel, On Tue, Sep 19, 2023 at 12:02:04PM -0700, Axel Rasmussen wrote: > 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. >=20 > 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. >=20 > Signed-off-by: Axel Rasmussen I can't apply this patch due to conflicts (due to not having applied two of the previous ones). Please resend all remaining patches in following revisions of the patch set. The applied ones are here: It's kind of like Linux's 'next' branch. Cheers, Alex > --- > man2/ioctl_userfaultfd.2 | 16 ++++++++-------- > 1 file changed, 8 insertions(+), 8 deletions(-) >=20 > diff --git a/man2/ioctl_userfaultfd.2 b/man2/ioctl_userfaultfd.2 > index 1aa9654be..29dca1f6b 100644 > --- a/man2/ioctl_userfaultfd.2 > +++ b/man2/ioctl_userfaultfd.2 > @@ -272,6 +272,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 > @@ -305,14 +313,6 @@ twice, > the first time with no features set, > is explicitly allowed > as per the two-step feature detection handshake. > -.\" 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. > --=20 > 2.42.0.459.ge4e396fd5e-goog >=20 --sywgjbkq4kcpxg35 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEE6jqH8KTroDDkXfJAnowa+77/2zIFAmUSHhYACgkQnowa+77/ 2zKnPw//YWI1d9zlIUx+sIQ+etTFDCgb9G1nFfGeE4qSWGNBDOFlK6D7cKCKBS9P mihPubSpiM1xaW281n2kDjxOolWeVwXTJFudUgeSoDPSp9895Pr3FImawj3EbnOp rnvn8jmihpy8MhgXMo9onszAC7fvY2vrzeb8e1ftDc6Y0We66Nhl2GtHHpzqtiuv G2SoAD7d1ZtK15iU/vYwaSGe/0NZ7HP19ROw2mx/WUDEu0HnzKaN0mgDP1XiMz8w Jk6Pxip6e10FeKRzawKps4znFFZP3SfoS6we7whdRkC/fXVTod7eTWMkmwdY+bN2 PnOQAxKQg7OT6FPcOcH0AgP8Dxgd+9OLiFwbsmYpkdKW4jy3FSq+I0dsCnX+luXd ILfApGDtwhhVwFniVq/KsRFkCnlFF/vU70WqUtF5ufpBfOgjcPsSK0PRdNYFojym vX+AZf5Gjc7nHysBGTkK3JRQNRTSYkvQY+ZjsWyMs5ATdgxbq5g/QkkS5iOL7ML3 Vv2AVbFCmcDX1Arx96nxntaaWI0nDixcRWd8QTgtbYdv5r0Bl4nevr+aRmCgGLST +XbKSLF4oT+eHAlOwUFNeUWZmhv97zTK3K5PIX6mk4vx8ETdvKQz8tn4d+vvKxJj 6qy3FiJc6w79ZIx5/zsx4jHMd9joKg39cgLxMhUVR5G6A8Canow= =Pua0 -----END PGP SIGNATURE----- --sywgjbkq4kcpxg35--