Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp6601273ybi; Wed, 29 May 2019 10:06:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqyK7SLcvre4z1IqyMQB2ScyM19el1KP80TSmIY/NENhoWAGCoZ6Qhet/tbHylkHQiTTpivm X-Received: by 2002:a17:902:9698:: with SMTP id n24mr57572776plp.118.1559149603159; Wed, 29 May 2019 10:06:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559149603; cv=none; d=google.com; s=arc-20160816; b=HErr83uFLPHGH6ManSte519pBvAc8pgnnYLy8lWHjrzac0yZF3G32jNKy7qKbOvbpa oNTJl3vLs7cIHTzw7+aGO3XsveQ5tsKgp+YO8fL/bncIZVEjyiKPdZgHBAU6LbKt7+c/ I9FWU891tRbL6cvaOKBkq0RgHkXzMBUucQNZ+21fE7+PDI3bPHYY3Gh2GvbRTm8yICI4 Qx77/snZUv/+qnjbIfc0mOuoSiwMoRbC9SqzTfmqzmqDNRbXkYlgHl8X+jfLk/4vF73/ HvOeIuykmRcjUQSLhXv0LwcBmvqcw+e8D5YmFbw/G6QO3ARkloem68+qXMx02r4mgr6V TK4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:openpgp:from:references:cc:to:subject :dkim-signature; bh=69qvQzXWECR+GHkmC3NT5N0sgy7z9vk5McUZDG/bT6A=; b=JE+c9rm66e38uGxK45BTePrei/g9toSbW0j0a4J6zePJ8aTFTojhf/oZywwFUgEZdb oyC8P8SjeQD+dSoP+KKtCX2VoCpn/1ZRh3PZTBTUdW6WCEjLkkrhWABgl51CYR2B2yzb yFGWs0w8PCHyUQyiBGEbNhPeyDGgrGUlWECrxnJy9R9K4xKgtFjoyZNkNZ4GsDnDyDpN Folv6vOsN+R+U5C2eBtG1biksxzIYokgPbOCtCfxfGwKlHPVUXCoBjuYuKrPDSgglNbl 53/uXmNU4zVjBInN+GqgZRcWgEfg929iP89+XaZSFEzXgtILVDxgRymvx0vv75FjHHet QqAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yahoo.com header.s=s2048 header.b=IVQ2lEfx; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p23si239569pgj.356.2019.05.29.10.06.25; Wed, 29 May 2019 10:06:43 -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; dkim=pass header.i=@yahoo.com header.s=s2048 header.b=IVQ2lEfx; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726373AbfE2RE5 (ORCPT + 99 others); Wed, 29 May 2019 13:04:57 -0400 Received: from sonic303-8.consmr.mail.bf2.yahoo.com ([74.6.131.47]:41836 "EHLO sonic303-8.consmr.mail.bf2.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726099AbfE2RE5 (ORCPT ); Wed, 29 May 2019 13:04:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1559149495; bh=69qvQzXWECR+GHkmC3NT5N0sgy7z9vk5McUZDG/bT6A=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From:Subject; b=IVQ2lEfx6kiFcpbfRAHBZUQeoA7WitSq7TYjCYYY9zBCVVjn8Y7gu7txNTX7QrAKCDoSMrSymNBAu7mR13F3wgt+JaZTyASUs6wYiJy3FqNukoJuHyWy5ZW66wq+Mh8QScd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yc32SW4qE.Xq8mqcOZ0gDMgSHnvpSYz124rTtCz9W FEmwVwVYwij6b9pcX2UhKZiZBFV96tce2mngLh29gK4bDPcqBo4Fnl8.VvVyj7W.FNZPZv.0vuvR EwmoeklRN5Rpq_p6gc41pTWRMJLrwp.cxJOJJfxeHATS6o7dYJtafpPrcTGVdPM9mCw9GSebVY1h TuqSPD3u_A004EVM91JDFu_saJVldYIN02TS2ib68fwpwpPmJHkG6xthHYhCjO7te6gIiE.ogThN QKLNTIb8JlYDwLikiQACu0EBN_8VNKCWIr2Qkn2hO6N8IcaE288DCSglQOxCKMsI3oBBA8JB6ZXd 9l04hTFauxWhWwA1XxaUCqXu6XiKaKuYQL6CdJrqEv60XyeFvjUEas4k3wc9tOXhK.ww3riWiBFa wW3yBMqMVitbxOjpLVSWTGcOQ5mUx Received: from sonic.gate.mail.ne1.yahoo.com by sonic303.consmr.mail.bf2.yahoo.com with HTTP; Wed, 29 May 2019 17:04:55 +0000 Received: from c-73-223-4-185.hsd1.ca.comcast.net (EHLO [192.168.0.103]) ([73.223.4.185]) by smtp423.mail.bf1.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID d7b9ddca251f26edd5d38f2fa16e0b7e; Wed, 29 May 2019 17:04:53 +0000 (UTC) Subject: Re: [PATCH 3/7] vfs: Add a mount-notification facility To: Jann Horn Cc: David Howells , 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 , casey@schaufler-ca.com 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> From: Casey Schaufler Openpgp: preference=signencrypt Autocrypt: addr=casey@schaufler-ca.com; keydata= mQINBFzV9HABEAC/mmv3jeJyF7lR7QhILYg1+PeBLIMZv7KCzBSc/4ZZipo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3et2WwZFLOoOCItWxT0/1QO4ikcef/E7HXQf/ij Dxf9HG2o5hOlMIAkJq/uLNMvABEBAAGJAjwEGAEIACYWIQQL720fVjJTAhDNQh44pRV8jEPI EQUCXNX0cAIbDAUJEswDAAAKCRA4pRV8jEPIEWkzEACKFUnpp+wIVHpckMfBqN8BE5dUbWJc GyQ7wXWajLtlPdw1nNw0Wrv+ob2RCT7qQlUo6GRLcvj9Fn5tR4hBvR6D3m8aR0AGHbcC62cq I7LjaSDP5j/em4oVL2SMgNTrXgE2w33JMGjAx9oBzkxmKUqprhJomPwmfDHMJ0t7y39Da724 oLPTkQDpJL1kuraM9TC5NyLe1+MyIxqM/8NujoJbWeQUgGjn9uxQAil7o/xSCjrWCP3kZDID vd5ZaHpdl8e1mTExQoKr4EWgaMjmD/a3hZ/j3KfTVNpM2cLfD/QwTMaC2fkK8ExMsz+rUl1H icmcmpptCwOSgwSpPY1Zfio6HvEJp7gmDwMgozMfwQuT9oxyFTxn1X3rn1IoYQF3P8gsziY5 qtTxy2RrgqQFm/hr8gM78RhP54UPltIE96VywviFzDZehMvuwzW//fxysIoK97Y/KBZZOQs+ /T+Bw80Pwk/dqQ8UmIt2ffHEgwCTbkSm711BejapWCfklxkMZDp16mkxSt2qZovboVjXnfuq wQ1QL4o4t1hviM7LyoflsCLnQFJh6RSBhBpKQinMJl/z0A6NYDkQi6vEGMDBWX/M2vk9Jvwa v0cEBfY3Z5oFgkh7BUORsu1V+Hn0fR/Lqq/Pyq+nTR26WzGDkolLsDr3IH0TiAVH5ZuPxyz6 abzjfg== Message-ID: Date: Wed, 29 May 2019 10:04:51 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/29/2019 9:12 AM, Jann Horn wrote: > On Wed, May 29, 2019 at 5:53 PM Casey Schaufler wrote: >> On 5/29/2019 4:00 AM, David Howells wrote: >>> Jann Horn wrote: >>> >>>>> +void post_mount_notification(struct mount *changed, >>>>> + struct mount_notification *notify) >>>>> +{ >>>>> + const struct cred *cred =3D current_cred(); >>>> This current_cred() looks bogus to me. Can't mount topology changes >>>> come from all sorts of places? For example, umount_mnt() from >>>> umount_tree() from dissolve_on_fput() from __fput(), which could >>>> happen pretty much anywhere depending on where the last reference ge= ts >>>> dropped? >>> IIRC, that's what Casey argued is the right thing to do from a securi= ty PoV. >>> Casey? >> You need to identify the credential of the subject that triggered >> the event. If it isn't current_cred(), the cred needs to be passed >> in to post_mount_notification(), or derived by some other means. >> >>> Maybe I should pass in NULL creds in the case that an event is being = generated >>> because an object is being destroyed due to the last usage[*] being r= emoved. >> You should pass the cred of the process that removed the >> last usage. If the last usage was removed by something like >> the power being turned off on a disk drive a system cred >> 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.=20 > If you send a file descriptor over > a unix domain socket and the unix domain socket is garbage collected, > for example, I think the close() will just come from some random, > completely unrelated task that happens to trigger the garbage > collector? I never said this was going to be easy or pleasant. Who destroyed the UDS? It didn't just spontaneously become garbage. Well, not on modern Linux filesystems, anyway.=20 > Also, I think if someone does I/O via io_uring, I think the caller's > credentials for read/write operations will probably just be normal > kernel creds? > > Here the checks probably aren't all that important, but in other > places, when people try to use an LSM as the primary line of defense, > checks that don't align with the kernel's normal security model might > lead to a bunch of problems. The kernel does not have a "normal security model". It has a collection of disparate and almost but not quite contradictory models for the various objects and mechanisms it implements. It already has a bunch of problems, we're just used to them. I can only send a signal to a process with the same UID. Why doesn't a process have mode bits so that I could get signals from my group? Why do IPC object have creator bits, while files don't? Why can I send a file descriptor over a UDS, but not a message queue? Why can't I set the mode bits on a symlink? What can go wrong if I don't map groups into a user namespace? LSMs (SELinux and Smack, which are classic mandatory access control systems in particular) are more consistent, but still have to deal with some of these differences. A symlink gets a Smack label, for example. The point being that it's very easy to add new mechanisms that do wonderful things but that introduce unforeseen ways to bypass one or more of the existing protections.