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 X-Spam-Level: X-Spam-Status: No, score=-8.4 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5EA19C5DF60 for ; Tue, 5 Nov 2019 16:40:06 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 03DBC21882 for ; Tue, 5 Nov 2019 16:40:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="dpE3RFax" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 03DBC21882 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 619526B0006; Tue, 5 Nov 2019 11:40:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5C9506B0007; Tue, 5 Nov 2019 11:40:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4DEF76B0008; Tue, 5 Nov 2019 11:40:05 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0211.hostedemail.com [216.40.44.211]) by kanga.kvack.org (Postfix) with ESMTP id 380556B0006 for ; Tue, 5 Nov 2019 11:40:05 -0500 (EST) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with SMTP id F077D440B for ; Tue, 5 Nov 2019 16:40:04 +0000 (UTC) X-FDA: 76122785928.14.metal25_a33c2151533 X-HE-Tag: metal25_a33c2151533 X-Filterd-Recvd-Size: 4799 Received: from mail-lf1-f68.google.com (mail-lf1-f68.google.com [209.85.167.68]) by imf50.hostedemail.com (Postfix) with ESMTP for ; Tue, 5 Nov 2019 16:40:04 +0000 (UTC) Received: by mail-lf1-f68.google.com with SMTP id b20so15647886lfp.4 for ; Tue, 05 Nov 2019 08:40:04 -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; bh=fZq9/Aaey+SN0l5GZyRu+H8Ix+9Q121u+Zli7RR28cM=; b=dpE3RFaxGC2yX2g7QtFyT4MP1J4SEpPTm67DT/BUSSOJJeXrGc9iwGkOymna6/w9uD lLIBtKOpUDSqsi/miR1szIUzurpCjB4jV7rVtVe4gTLBVuAbmc2srBL57cbBW5dVz5Wy 2LstfRmABNveD5zGcn6Rna+1QQq8xqfD8uuCctL5tkHR0yCqBdyh8gqj3OI5VWRMoXMr HEju8amylItNdnUR8tZtFpc3BJ/lfi+REgf6BdEYyCYn0PRbQg+XIKPOcsoSnljyC3js HbDZ3DlGcYOmBx7lu8ovKuDJjXc5E2UxG7WzJuWyWi6O8nCKdymnpgiPrYQMxKbuFhyT rK4w== 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; bh=fZq9/Aaey+SN0l5GZyRu+H8Ix+9Q121u+Zli7RR28cM=; b=i/4yfIZA+tHrBJSej7UIDptVaO1JzzHG0UDd34M5bqmv9KeGUC++vPwytqWQdn6uWV TcZl1FdiLU5NcQMp1hrRNPJEP3tPBs2zUEMMf610saQw4qQuLaOf14z8PiHpWyPkOVWs XNIGAeo5yiyK358wIUYQuvRehJFJOTNqSvQyHWy97pcSX+c07xjZg5wtus0dOxc37LzE zKsXxjAXbaeGnPWoNECENyEK5D9iHs+Bg/RsQv2QV1bvqeePxXsygT1mjOaKoBm/Dxnw ccc68YFsKFy6Aotsjn7zuKWmcmOIb5u0GTx2xdgJkNXf2aZZ3IGFPtXi90/Ty5IZmeMv HUYA== X-Gm-Message-State: APjAAAVtWYjUcMe7vSPNropRgFpzUGNf4Y/6VQIWcuOH7WA2Dv4TDY9c JPrVwDTD31yqbac6FADscHg5nAIJl2eUhzKY/TPcXg== X-Google-Smtp-Source: APXvYqxDz7vYxn0I8N6/Nm40gjJSZsMVwWDW2LlwIjWat1+S/f9QVe+9VtUJH2n2yiwqFwxoN/MW67Pff05B2iT02Mk= X-Received: by 2002:ac2:561b:: with SMTP id v27mr21936445lfd.186.1572972002286; Tue, 05 Nov 2019 08:40:02 -0800 (PST) MIME-Version: 1.0 References: <1572967777-8812-1-git-send-email-rppt@linux.ibm.com> <1572967777-8812-2-git-send-email-rppt@linux.ibm.com> <20191105163316.GI30717@redhat.com> In-Reply-To: <20191105163316.GI30717@redhat.com> From: Daniel Colascione Date: Tue, 5 Nov 2019 08:39:26 -0800 Message-ID: Subject: Re: [PATCH 1/1] userfaultfd: require CAP_SYS_PTRACE for UFFD_FEATURE_EVENT_FORK To: Andrea Arcangeli 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 Content-Type: text/plain; charset="UTF-8" X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, Nov 5, 2019 at 8:33 AM Andrea Arcangeli wrote: > > 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. 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.