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=-1.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 49B1BC04AB5 for ; Mon, 3 Jun 2019 16:30:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 290D323F32 for ; Mon, 3 Jun 2019 16:30:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728426AbfFCQam (ORCPT ); Mon, 3 Jun 2019 12:30:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38008 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728228AbfFCQam (ORCPT ); Mon, 3 Jun 2019 12:30:42 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7579081E05; Mon, 3 Jun 2019 16:30:31 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-120-173.rdu2.redhat.com [10.10.120.173]) by smtp.corp.redhat.com (Postfix) with ESMTP id E09DC5D9C6; Mon, 3 Jun 2019 16:30:26 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells In-Reply-To: References: <155905930702.7587.7100265859075976147.stgit@warthog.procyon.org.uk> <155905933492.7587.6968545866041839538.stgit@warthog.procyon.org.uk> <14347.1559127657@warthog.procyon.org.uk> <312a138c-e5b2-4bfb-b50b-40c82c55773f@schaufler-ca.com> To: Casey Schaufler Cc: dhowells@redhat.com, Jann Horn , Al Viro , raven@themaw.net, linux-fsdevel , Linux API , linux-block@vger.kernel.org, keyrings@vger.kernel.org, linux-security-module , kernel list , Andy Lutomirski Subject: Re: [PATCH 3/7] vfs: Add a mount-notification facility MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <19413.1559579426.1@warthog.procyon.org.uk> Date: Mon, 03 Jun 2019 17:30:26 +0100 Message-ID: <19414.1559579426@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 03 Jun 2019 16:30:41 +0000 (UTC) Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Casey Schaufler wrote: > >> should be used. Someone or something caused the event. It can > >> be important who it was. > > The kernel's normal security model means that you should be able to > > e.g. accept FDs that random processes send you and perform > > read()/write() calls on them without acting as a subject in any > > security checks; let alone close(). > > Passed file descriptors are an anomaly in the security model > that (in this developer's opinion) should have never been > included. More than one of the "B" level UNIX systems disabled > them outright. Considering further on this, I think the only way to implement what you're suggesting is to add a field to struct file to record the last fputter's creds as the procedure of fputting is offloaded to a workqueue. Note that's last fputter, not the last closer, as we don't track the number of open fds linked to a file struct. In the case of AF_UNIX sockets that contain in-the-process-of-being-passed fds at the time of closure, this is further complicated by the socket fput being achieved in the work item - thereby adding layers of indirection. It might be possible to replace f_cred rather than adding a new field, but that might get used somewhere after that point. Note also that fsnotify_close() doesn't appear to use the last fputter's path since it's not available if called from deferred fput. David