Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp58022rwl; Thu, 30 Mar 2023 12:06:26 -0700 (PDT) X-Google-Smtp-Source: AKy350aD+lTYU5dU4p5CkRxXKekh7aQw5peQRRmFnjI/AkqGILiGCpnGSqDvqe/F4FMadY+Q4tgp X-Received: by 2002:a05:6402:34c6:b0:502:1cf6:f52c with SMTP id w6-20020a05640234c600b005021cf6f52cmr4211367edc.4.1680203186225; Thu, 30 Mar 2023 12:06:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680203186; cv=none; d=google.com; s=arc-20160816; b=O0v+dFT1d6A7G8hKIVTfYSj8shmuQAd9pAPkH+fj4iDyxXXkm84p1Z1vyJkbRo6ce6 tUYl9HMEcFcyF484Sjy2cKomvBQwC0bS4tPOKf+yGQgRC4Wr+QBEgkj8AlvW5721LG4o AdlJM+XxEHxBEqLXmwL7Uob9pm3/JyljCC5WfCJ1KOcd9oJxtVpiSf6RtsAuPARjhfPH vRRg9XhluLs6YwOs+BUS6Er6Ocs7TQkuSkdQbEdjNg+If9rlI4SFq6AGiQTZhcAVeFGO ItJwVE6GdD1biwT8yxPTqMdPMYXkXQdBSS/DrQs+o4ZCy0/h5jFst4qVmeT/8myg+iJh U1hQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=ViRntU/RBw/t4ZG4j3zD5QSxaRXCjDm7pTbD6yzt3a8=; b=pkULvxKlg1euTbQILoDBul5WHAkp1zsqex78tQimFkaSXNu2P+ImeCvQ4csRQsxmd8 gsR8hyqfjDTAvWAp0NWS9f1BHTxFreGj7LH6SfGp2lGnrfhZ1lblnJmcLJxHwX1OCc4Z tJBouV0Q0G+3s6geFWVDFEy2kz6usO7AUzvA8Ep5jDghl1UxGJIlqy5Y0Kc9uY7LwuPc pslbiDhv4Mn6Jbl1jchZVdFHQs9EF45xmwoV6XJivxfd0TFHQN32gvJa1+bIgJ3W4KnW 3vDt/pTB3wbPSXGmylyVt4WbRlIhjBjH+pdUifGKJ9+vf1r+5sA7Z4+IhaHSYc4hdH2c qB3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=dV0eOrY6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r8-20020aa7da08000000b00501da04d094si390022eds.523.2023.03.30.12.06.00; Thu, 30 Mar 2023 12:06:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=dV0eOrY6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231892AbjC3TEu (ORCPT + 99 others); Thu, 30 Mar 2023 15:04:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231913AbjC3TEt (ORCPT ); Thu, 30 Mar 2023 15:04:49 -0400 Received: from mail-lj1-x22c.google.com (mail-lj1-x22c.google.com [IPv6:2a00:1450:4864:20::22c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C7501FC1 for ; Thu, 30 Mar 2023 12:04:48 -0700 (PDT) Received: by mail-lj1-x22c.google.com with SMTP id h9so20704542ljq.2 for ; Thu, 30 Mar 2023 12:04:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1680203086; x=1682795086; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=ViRntU/RBw/t4ZG4j3zD5QSxaRXCjDm7pTbD6yzt3a8=; b=dV0eOrY64A8f3Aifg1ktecdTLHjwppffuR9U+jgLkYvX5MPPYsv9GweFII+I3t3v0o 9jDUXsvJMrPGEHZdm2GTi65Hfmw3a4ibc8v8r1yPTfDacXDy2tuui059sb/LWhFr6H+H UP9us03F/CeqELxCEVFGNRLtAJxBsJVpPwkAky/qVzjej7ZzN8fa8tNm2d3W32e31tbu BtK/YWj1gJaR8aOw8FQ95nsRGqgYD9gg/k+zm6oxnRW5a1ko9Odd1OOYs48mxEoGd5eX c3+9Vum6jH3lt36eOSVGmAFLUpEM4wQoaph53BHMmdalSnMjSX5gQGgZ+DPtuMYw0KF/ Yx4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680203086; x=1682795086; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ViRntU/RBw/t4ZG4j3zD5QSxaRXCjDm7pTbD6yzt3a8=; b=oW6phQoGKWnU4zkQ+2Z//3MD/jDmEbNzeuIezdSgc0MLxm0LGwSW0tawVgAGnnhSmy B3DTT0bgM+ofot/cUN/nhIkEyPKsXteKkU9pKH0xb+qbRJDBz+Hq3D6HQ0pUrg1arK4W /QXTguoPkCwR+pr0jHWVLxr8ifZl5Z+8QjAyuRUdXysw4uIyYSaUsKNPQgtSnq66+fIj XAuf8JL74vptJG9Ohw+1rLi45j6pK7wqTVrT+dgwWbsh3oQzoYoMom6rqTPixKA5eMkY 2eTarKmpzmHaOVYa5dk9nf15pYncQ6hf9XiRDeZWjPaTKHm2c7REe9XLZZnHHivIlCj3 Mwrg== X-Gm-Message-State: AAQBX9dENkXRnnFpDcLj5BoFUnbDPy6kdGLZ6RrfERwVebRCm2KaM29J CCnIpx3gSTiT1T+mEyTvCgbeogPUiEnM9n8zXd500A== X-Received: by 2002:a2e:3203:0:b0:299:9de5:2f0c with SMTP id y3-20020a2e3203000000b002999de52f0cmr7643353ljy.6.1680203086265; Thu, 30 Mar 2023 12:04:46 -0700 (PDT) MIME-Version: 1.0 References: <20230330155707.3106228-1-peterx@redhat.com> <20230330155707.3106228-2-peterx@redhat.com> In-Reply-To: <20230330155707.3106228-2-peterx@redhat.com> From: Axel Rasmussen Date: Thu, 30 Mar 2023 12:04:09 -0700 Message-ID: Subject: Re: [PATCH 01/29] Revert "userfaultfd: don't fail on unrecognized features" To: Peter Xu Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Mike Kravetz , Andrew Morton , Andrea Arcangeli , Mike Rapoport , Nadav Amit , Leonardo Bras Soares Passos , David Hildenbrand , linux-stable Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-15.7 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,ENV_AND_HDR_SPF_MATCH, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL, USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 30, 2023 at 8:57=E2=80=AFAM Peter Xu wrote: > > This is a proposal to revert commit 914eedcb9ba0ff53c33808. > > I found this when writting a simple UFFDIO_API test to be the first unit > test in this set. Two things breaks with the commit: > > - UFFDIO_API check was lost and missing. According to man page, the > kernel should reject ioctl(UFFDIO_API) if uffdio_api.api !=3D 0xaa. Th= is > check is needed if the api version will be extended in the future, or > user app won't be able to identify which is a new kernel. 100% agreed, this was a mistake. > > - Feature flags checks were removed, which means UFFDIO_API with a > feature that does not exist will also succeed. According to the man > page, we should (and it makes sense) to reject ioctl(UFFDIO_API) if > unknown features passed in. I still strongly disagree with reverting this part, my feeling is still that doing so makes things more complicated for no reason. Re: David's point, it's clearly wrong to change semantics so a thing that used to work now fails. But this instead makes it more permissive - existing userspace programs continue to work as-is, but *also* one can achieve the same thing more simply (combine probing + configuration into one step). I don't see any problem with that, generally. But, if David and others don't find my argument convincing, it isn't the end of the world. It just means I have to go update my userspace code to be a bit more complicated. :) I also still think the man page is incorrect or at least incomplete no matter what we do here; we should be sure to update it as a follow-up. > > Link: https://lore.kernel.org/r/20220722201513.1624158-1-axelrasmussen@go= ogle.com > Cc: Axel Rasmussen > Cc: linux-stable > Signed-off-by: Peter Xu > --- > fs/userfaultfd.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c > index 8395605790f6..3b2a41c330e6 100644 > --- a/fs/userfaultfd.c > +++ b/fs/userfaultfd.c > @@ -1977,8 +1977,10 @@ static int userfaultfd_api(struct userfaultfd_ctx = *ctx, > ret =3D -EFAULT; > if (copy_from_user(&uffdio_api, buf, sizeof(uffdio_api))) > goto out; > - /* Ignore unsupported features (userspace built against newer ker= nel) */ > - features =3D uffdio_api.features & UFFD_API_FEATURES; > + features =3D uffdio_api.features; > + ret =3D -EINVAL; > + if (uffdio_api.api !=3D UFFD_API || (features & ~UFFD_API_FEATURE= S)) > + goto err_out; > ret =3D -EPERM; > if ((features & UFFD_FEATURE_EVENT_FORK) && !capable(CAP_SYS_PTRA= CE)) > goto err_out; > -- > 2.39.1 >