Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp1321147ybx; Tue, 5 Nov 2019 14:12:08 -0800 (PST) X-Google-Smtp-Source: APXvYqxY6nr5gGp/lZ8PmyB1/Z6bTdv6Io4E1/j8mHC0Dwz7gi1XNgZBbj7zyPpVUF00RxCuqwLZ X-Received: by 2002:a17:906:1d45:: with SMTP id o5mr32038472ejh.250.1572991928322; Tue, 05 Nov 2019 14:12:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572991928; cv=none; d=google.com; s=arc-20160816; b=yD5b36pOcloRydOGMOjKT6oVlbwIWRuooMMo2NaKLyTyPqwcFOxnqNvk89x3UiPl43 mIkJyRSDLsybl3kuYOhkxZxzQwM/hhXW5XpB+ozl3m7GcsRvy/rycRVIrDPJefFlH73B T+n/tBSMupv56bblV5XJ5h/MIOI0RJ/XIMpMa8hQtVw1u06Uo2Ux3HbtyZldqu1lx0vL GphswwXNFpFg/p08U6L6+PKuykST/BmmloJYT7F3w7gkfVSoV/48W43LMSW+s7i+z8n2 xAAWmahouYsgx2tJroSWAONfH9IdPhjI68RrJgiv8s8YhGoUBNHCjp1OaMWpyTDblsHV XpZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=oHNoa42wrptLOIF/3dlMMyJwxrj4Pwhbf1WPBq8o3uM=; b=RjJhdkNBIu5KVW3EyjY8gCpa2nOSX9iFEGVJv2ecF+9EhDvHD2Mpy4rX4LzU0XZFOB bCReUTyhq4QYp9tnap8ZgYC4J20QdqfxE2QoR6Xq1n53dj9zv+AQlFNl0neBEIDqkZWe 9oT2pLQISrJchdbxA3llfTZ9WJ1rFCDR/G/bPrfmkY9AfTkrI2yui0Py/PXRI0Gc6jHW YFAqFbsxOf3BH7zXjyiYXSkv4uWyRVV6Yy79bnscIoJ9Djt61ddTcCgqlVkpKv/o7XjP aro31Jk5+30KoSSPMixf3cgg/twgSqyrawKWu9p0vQdcQKZLC+TTbmUnf7umvNT1bsub StJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=txaxdUHA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v6si13565763edi.308.2019.11.05.14.11.45; Tue, 05 Nov 2019 14:12:08 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=txaxdUHA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1730168AbfKEWK4 (ORCPT + 99 others); Tue, 5 Nov 2019 17:10:56 -0500 Received: from mail-lf1-f66.google.com ([209.85.167.66]:35849 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729895AbfKEWK4 (ORCPT ); Tue, 5 Nov 2019 17:10:56 -0500 Received: by mail-lf1-f66.google.com with SMTP id m6so206564lfl.3 for ; Tue, 05 Nov 2019 14:10:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=oHNoa42wrptLOIF/3dlMMyJwxrj4Pwhbf1WPBq8o3uM=; b=txaxdUHAhhP9SDZaT+2LCWEybyxTXeBjbSvIEpNO3NUlCNP11+juSvK4NTapgDIQsx bx4UA6EMOgVRpvfj9Ytg3Dbq2TH/brOOWOMH+2KBx/B/IHrQbQAjLifbp0FSTSQsO2Bd NiuZC+eFppZJoQE3ZUPlpHN1pT+rO6Z14hJeshOd2hCFXwk4GR///Yx4GRVniJ3VKONO Kt+mJci6Da3WvnYbEe8gDOsTV7j/2J9XBqJqDkJ51fvbH5UQdmpyyfw/VvxEU/blzMIM MaPDes1kjsPOjqDH4nLH7vZE3u4nXKFUCYPNkeargYEdaXpUvyyeDnNhBld+YwzcgZEF lFzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=oHNoa42wrptLOIF/3dlMMyJwxrj4Pwhbf1WPBq8o3uM=; b=sGZEAT4kC8nzWY/xhh2MQ6A6basdqGGOmeMJMNtwecWnG55feLqwG6JDs6VllTju6H ZQ0hy2I8e/fHNk4NABrUbByecYEkHiLxkaZx7nuzvvFJRpGq39EP+7FkjeWvHEprm0X6 KDuAW2Cp71kUPFtffGU/ii9gYgcV8KHXZZ6lTtTIEpGkKB789UCRMItjvpzggGRpjojl 80c5OZGgi4DPT4JhagnTECzvDQKCNAhdWb1KlqyvEtV8x41fzZf7xPfFmZC4Kg7HKBo3 Lfhgyq2bSUFodPXAtWWmhQrlVUzPt3PoQvHYQIK8ESW5oLxqc33qVYX0F2LHGL221Goz Hb6g== X-Gm-Message-State: APjAAAV5ifYkYID//pOeklOEgEx/Z0zCrr3mcjOftew7KK2HeZmgBR4l lX1JwkxWjVHlSO3mL3tjNOkSWofrP3UNc5sygM0nPg== X-Received: by 2002:ac2:5587:: with SMTP id v7mr135624lfg.79.1572991853663; Tue, 05 Nov 2019 14:10:53 -0800 (PST) MIME-Version: 1.0 References: <273986A1-A4BE-4FE5-B547-49CAA44C6FD3@amacapital.net> In-Reply-To: <273986A1-A4BE-4FE5-B547-49CAA44C6FD3@amacapital.net> From: Daniel Colascione Date: Tue, 5 Nov 2019 14:10:16 -0800 Message-ID: Subject: Re: [PATCH 1/1] userfaultfd: require CAP_SYS_PTRACE for UFFD_FEATURE_EVENT_FORK To: Andy Lutomirski Cc: Andrea Arcangeli , Andy Lutomirski , Mike Rapoport , linux-kernel , Andrew Morton , Jann Horn , Linus Torvalds , Lokesh Gidra , Nick Kralevich , Nosh Minwalla , Pavel Emelyanov , Tim Murray , Linux API , linux-mm Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 5, 2019 at 2:01 PM Andy Lutomirski wrote: > > On Nov 5, 2019, at 9:02 AM, Daniel Colascione wrote= : > > > > =EF=BB=BFOn Tue, Nov 5, 2019 at 8:56 AM Andrea Arcangeli wrote: > >> > >>> On Tue, Nov 05, 2019 at 08:39:26AM -0800, Daniel Colascione wrote: > >>> I'm not suggesting that we fail userfaultfd(2) without CAP_SYS_PTRACE= . > >>> That would, as you point out, break things. I'm talking about > >>> recording *whether* we had CAP_SYS_PTRACE in an internal flag in the > >>> uffd context when we create the thing --- and then, at ioctl time, > >>> checking that flag, not the caller's CAP_SYS_PTRACE, to see whether > >>> UFFD_FEATURE_EVENT_FORK should be made available. This way, the > >>> security check hinges on whether the caller *at create time* was > >>> privileged. > >> > >> Until now it wasn't clear to me you still wanted to do the permission > >> check in UFFDIO_API time, and you only intended to move the > >> "measurement" of the capability to the syscall. > >> > >> So you're suggesting to add more kernel complexity to code pending for > >> removal to achieve a theoretically more pure solution in the band-aid > >> required to defer the removal of the posix-breaking read > >> implementation of the uffd fork feature? > > > > And you're suggesting making a security check work weirdly unlike most > > other security checks because you hope it'll get removed one day? > > Temporary solutions aren't, and if something goes into the kernel at > > all, it's worth getting right. The general rule is that access checks > > happen at open time. The kernel has already been bitten by UFFD > > exempting itself from the normal rules (e.g., the > > read(2)-makes-a-file-descriptor thing) in the name of expediency. > > There shouldn't be any more exceptions. > > I don=E2=80=99t think ioctl() checking permission is particularly unusual= . In principle, it=E2=80=99s better than open for a retrofit =E2=80=94 open= didn=E2=80=99t capture this permission in the past, so adding it makes an = existing capability stronger than it was, which isn=E2=80=99t fantastic. All right, let's do it the way the OP's patch does it then.