Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp990461ybx; Tue, 5 Nov 2019 08:34:59 -0800 (PST) X-Google-Smtp-Source: APXvYqwWSyinMZIlDpcLMehT6DHxXPoyKyq+wcfd5mBN7rLAPMalUtgOXkt0PieYc2mFnyZcViqZ X-Received: by 2002:a05:6402:38e:: with SMTP id o14mr3016053edv.285.1572971699171; Tue, 05 Nov 2019 08:34:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572971699; cv=none; d=google.com; s=arc-20160816; b=gFvCZiflzYuQgbdC/PJv6OnwfNlNkY3beXu4tEywc3KHhiwa4yQCJI8n+yUxxcwpyB 3Aj+ng8ExN19NdAyNqL5eHi4yoKcuoZQdPTSMJ3URpz0tb3Dcu8fxxCGX371TuPHMo9Y J2+7PmdQRcGDJQuAZImEPdVszZpQpd8uDD7pkktenVHNSudxaXCtZQoyC+fTJ0IKnpsj wWyKuMBgVaBXsF0oAS0bIKzJvXMu0MyIird7/QvUhcCSMobQQXJW+3F7e8nemMrPC47f pTG05rM6orP3OUmmIRvx/J5Bn5tf7/40Y3xsuvbg5pxHLVC/+z1sjz1znsg6wjFjDBnW hoHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:user-agent:in-reply-to:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Skg5arqhiojkrhAvFDjH124AuiwjgoDeP66mJMAYWGM=; b=PURVbA5g7pv2pCqI6P2TlBSth4gk5LEAseF9fFBXrT/nawpn6uAIiNHR7EXcz99apt evUzsWa/Eh3bEjEB9BtjI2kVMFwzqBtlNE/2GCl/UDwCfoKO82ssAZQks7GsSw4bJi6S T/4QQoOUvweChGKcE7eK2aox3ajEnBs6Bjkl5O3a1bF8BXHPzhP8QcalIA4JsRviU969 6Sswkgq3tuxXohm7bM4gdRgxcj5AA5zyMB65jSgB3DuLpLi3JoxpY7KMXHhQtdnTON9j g652p+SFSy9XRYF07i27np1PZTtuMBLm/Ru1N2YnbU0JDeKK9WRWTq+KIVBaD9de6Mum pvSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=aaXIS5cP; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ks15si4590705ejb.133.2019.11.05.08.34.34; Tue, 05 Nov 2019 08:34:59 -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=@redhat.com header.s=mimecast20190719 header.b=aaXIS5cP; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390559AbfKEQdZ (ORCPT + 99 others); Tue, 5 Nov 2019 11:33:25 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:34191 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2390543AbfKEQdY (ORCPT ); Tue, 5 Nov 2019 11:33:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1572971603; h=from:from: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Skg5arqhiojkrhAvFDjH124AuiwjgoDeP66mJMAYWGM=; b=aaXIS5cPcR2h6HOzCu9vY7K8DyPeKuUiqBvl2dLkBE606kNXn41QqKVJ7JRyQ7Urxl6ibN /Ev9pQwmxgq6n2UXyDtNhtxYrOacNndFukWxFKnpFMs0XDY1OC3/6TodRFDORdz5PuYU1T Mv/UHRFnrMFGBGZuPGyhDI2a51Ku6Cs= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-351-fdhOjGE1OwGmEEn4AJbycQ-1; Tue, 05 Nov 2019 11:33:20 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D34D01800D4A; Tue, 5 Nov 2019 16:33:17 +0000 (UTC) Received: from mail (ovpn-121-157.rdu2.redhat.com [10.10.121.157]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9CC2160C88; Tue, 5 Nov 2019 16:33:17 +0000 (UTC) Date: Tue, 5 Nov 2019 11:33:16 -0500 From: Andrea Arcangeli To: Daniel Colascione Cc: 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 Subject: Re: [PATCH 1/1] userfaultfd: require CAP_SYS_PTRACE for UFFD_FEATURE_EVENT_FORK Message-ID: <20191105163316.GI30717@redhat.com> References: <1572967777-8812-1-git-send-email-rppt@linux.ibm.com> <1572967777-8812-2-git-send-email-rppt@linux.ibm.com> MIME-Version: 1.0 In-Reply-To: User-Agent: Mutt/1.12.2 (2019-09-21) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-MC-Unique: fdhOjGE1OwGmEEn4AJbycQ-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 05, 2019 at 08:06:49AM -0800, Daniel Colascione wrote: > Sure, but the same argument applies to all the other permission checks > that we do at open time, not at ioctl time. For better or for worse, > the DAC-ish model used in most places is that access checks happen at > file object creation time and anyone who has the FD can perform those > operations later. Confusing the model by doing *some* permission > checks at open time and *some* permission checks at usage time makes > the system harder to understand. The only case that requires change is if userland requested the UFFD_FEATURE_EVENT_FORK feature (which AFIK only CRIU does) and that request is done in the UFFDIO_API call not during the syscall. Doing the check in the syscall would then break all non privileged users like if we'd set /proc/sys/vm/unprivileged_userfaultfd to zero. Qemu for example rightfully never runs with privilege (with a few exceptions like Kata which should be fixed in fact) and it never asks for the UFFD_FEATURE_EVENT_FORK feature either.