Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4436729ybi; Mon, 3 Jun 2019 10:49:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqwWOE74idCVazbjfQkQBgGKixX3V1ZnEgZW3CNQMcQHegkTvEqaVrrRxrPlK1agLvde93uZ X-Received: by 2002:a63:514:: with SMTP id 20mr16505824pgf.272.1559584185726; Mon, 03 Jun 2019 10:49:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559584185; cv=none; d=google.com; s=arc-20160816; b=A52nV6QG9c+kbczV/HObU5b8tlQscv0NK5gJOdka+hFq9PzrMqxyVAdcrTWtzr/Izv seTQ19ukhlQN7FU4ECPBxRP38KxJdk+zem2JnVZuijqrBT9Mhnb4q4B7aHywpsCAfzYw K+ZJVpC2YcmVD+sNE1EPvo4ZffgQck8xbYN+kKVogRoYi8KUotaUsL+wAc3qIrHd3NE9 lN/+W7k+o1shnJqwdlzs2UgWi1oQGSIafH56lFf8y79H+e4mI2oJYc8xRdqMQTXhABVM T5Hxy0I8N+QIiji8BEeajY/Qu59hZiYbuCMbJE+daXQEjd1Tg+cL6KRPmP3hnu+fzv9y fyMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:content-id:mime-version :subject:cc:to:references:in-reply-to:from:organization; bh=rosTlSV9Elp9Qy9UXHGAjagL05tVYiBWpQ9JixqpUNE=; b=eDK72pZydmLhO+nhjKyJbhjoWvBs8dakVa9tJWA3MWkuJHyhck1e2N2l9m8LfFgN8q u954lJnUt+epzvlbNud8gxZfuTEAsJ7Bkpu9Vd345qqMYh/KEyVlF9js8Fzg+RPFT3M2 R+k/Fe8vxaUNxlDEYq9k98jaWUuHSHqw3YBKvTnxlWEs8LuViUwSB+8ECfYFMjFJoxC2 9RXJQTxhKBCh3dR6pWNAsadysClJ1sx3nW9pdRwx7Ghyuygqynl8GlgZ+J14DNRLQPfK tdQAws0BEXvi3JFRrdocNv4FzX9eYp0nQzFBPoazXBPM5ee39y24EJ0yJ4x2S72Gw9Vw 3+dw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (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 z16si18248058pgg.91.2019.06.03.10.49.29; Mon, 03 Jun 2019 10:49:45 -0700 (PDT) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728603AbfFCQam (ORCPT + 99 others); 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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