Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5953181ybi; Wed, 12 Jun 2019 11:17:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqySTQ7WXLJonOuhm7ByDSqx5qrFBicOdyAjwWCJ0UNLX/4dMRXJ4aW4WQW/tuS7yFYqJUe0 X-Received: by 2002:a17:902:106:: with SMTP id 6mr19791488plb.64.1560363420305; Wed, 12 Jun 2019 11:17:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560363420; cv=none; d=google.com; s=arc-20160816; b=L/PFzFTR73LEGGMa2PYoSCu5oA0cgNMK1B/LXWjg3+1ZKgfErSBPc3z5lH4nqS/H+g eaUUD7Kt8w3lUZtLpJlaq5PAo2VL9nj8pdJsaHJobsLGBDWJ3EjWI+/YVTRYQIQPn/Mk 1qDGkJsnbpv1RpSUVyoMdya+GbveZxq6yPZ9cEpfvTQFoqbZE/bXMEw0XfCTBCHVmkUt 3SovRfGLgghzUKfqYsO7/8xmulTIS6P472GpGbO8D3J0FRE3JBtTpZJlo4YUr5Mzf5Fn LUqcopzYA/ir9sLCwQcbByY5i2nqt8SVLjinCHm+dCjDVC0c6H41KTPxPPGeB1OT5Kmy vHrg== 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=xIF1XHVgS31oW5M5zK0EqGkjdhl54UMxsg7idDaz8ik=; b=IG3ROX8x6U+WC5BmjvIoxjQjGQmQbkJKOV/fUyX0Hi8cAv1DVECrzwAOst3Kh4/gU9 DWxi3VGefzckA1e1FRBnSalloXAGw3vrj0bRyHA5AK7l5taZk7KloKhY0/H8hHO4FJ/e WfoUotc7HRvblq5SteHILC5yrbfCY2cjD7RERltx5e4e52xzhzgrknN51W7ZpQ/FKHN1 3/EsqH7FAud0jXT2y9kUNNW5Ca2gNPHsya176VJNzBdD0aeI/0OtS8CXo4opRYPEa2fe ymET04LeOq3KNW3qFxltPJSn8gLMFVQ67pi5gXyT8YZ8dmAWJL45aoOnSkT/4V2UPgTj pIag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yahoo.com header.s=s2048 header.b=aLd0A6CZ; 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 v18si307415ply.276.2019.06.12.11.16.44; Wed, 12 Jun 2019 11:17:00 -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=aLd0A6CZ; 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 S1726811AbfFLSOn (ORCPT + 99 others); Wed, 12 Jun 2019 14:14:43 -0400 Received: from sonic309-22.consmr.mail.bf2.yahoo.com ([74.6.129.196]:40769 "EHLO sonic309-22.consmr.mail.bf2.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726677AbfFLSOn (ORCPT ); Wed, 12 Jun 2019 14:14:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1560363281; bh=xIF1XHVgS31oW5M5zK0EqGkjdhl54UMxsg7idDaz8ik=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From:Subject; b=aLd0A6CZHfDugx9DtN3ricVSnlmVqdR2p8Kwr2MTVebdGsBkpUCszSmtm2gJZSE1JHzGOqK+EOhMfQBLjYa1jrsFipmpOvYGWBJWRlI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bmvbcQIeH5QFWwyDTeW7Q20jr5KOgL1N6hCtik7eH3pma4VHZB98d.mqesPvJYVQU7qYGhKitu wXmAVIucpUAUSiVeZNLAARtIN17iOMMSAvbkmF7xKo1CyhdVJuKZUKFCDA9VBbvDP6z1WCAZZZye PKEYUk_NAK55ahr_7njAE7MmwNQXd1FnU.21PqYo7ENAy6GVrQVGuhy96eTw5BNeDtGpsmMcnu1S ob5SFWowUOknCHJUIMiA3ifJTAjRsEgYNEHDdRJAOiahGYL7evsCZwq3fDSxyEBgscFiUi4Rfdjr AEMoamGkIjrJj5_l22Nzo_OI3273656M5mF9nmifOTtceOcioI6Q28ISUlcr.MJmie4M2ZR5q.6w Pu4ExRtMRNOnurhhDPqa92QJ0ZNki7ynA9Q9gQsXPseY67XslaXxRqhHCQI6elKZGZm6ZkHUtRmX yayT.TRuYJqJTdZp7kble Received: from sonic.gate.mail.ne1.yahoo.com by sonic309.consmr.mail.bf2.yahoo.com with HTTP; Wed, 12 Jun 2019 18:14:41 +0000 Received: from c-73-223-4-185.hsd1.ca.comcast.net (EHLO [192.168.0.103]) ([73.223.4.185]) by smtp405.mail.bf1.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID 90667aa732a85c97b8d2b127900fddb3; Wed, 12 Jun 2019 18:14:39 +0000 (UTC) Subject: Re: What do LSMs *actually* need for checks on notifications? To: David Howells Cc: Stephen Smalley , Andy Lutomirski , viro@zeniv.linux.org.uk, linux-usb@vger.kernel.org, linux-security-module@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, casey@schaufler-ca.com References: <9c41cd56-af21-f17d-ab54-66615802f30e@schaufler-ca.com> <155991702981.15579.6007568669839441045.stgit@warthog.procyon.org.uk> <31009.1560262869@warthog.procyon.org.uk> <14576.1560361278@warthog.procyon.org.uk> From: Casey Schaufler Openpgp: preference=signencrypt Autocrypt: addr=casey@schaufler-ca.com; keydata= mQINBFzV9HABEAC/mmv3jeJyF7lR7QhILYg1+PeBLIM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8kqnEQ9W2QgrjDX3et2WwZFLOoOCItWxT0/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: <0483c310-87c0-17b6-632e-d57b2274a32f@schaufler-ca.com> Date: Wed, 12 Jun 2019 11:14:37 -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: <14576.1560361278@warthog.procyon.org.uk> 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 6/12/2019 10:41 AM, David Howells wrote: > Casey Schaufler wrote: > >>> (4) The security attributes of the object on which the watch was set= (uid, >>> gid, mode, labels). >> Smack needs this to set a watch on the named object (file, key, ...). >> I am going to say that if you can't access an object you can't watch i= t. > So for the things I've so far defined: > > (*) Keys/keyrings require View permission, but it could be Read permis= sion > instead - though that may get disabled if the key type does not su= pport > KEYCTL_READ. View is good enough. > (*) Mount/superblock watches - I've made these require execute permiss= ion on > the specified directory. Could be read permission instead. Execute is good enough. > (*) Device events (block/usb) don't require any permissions, but curre= ntly > only deliver hardware notifications. How do you specify what device you want to watch? Don't you have to access a /dev/something? "currently" makes me nervous. >> I think that read access is sufficient provided that no one else can >> see what watches I've created. > You can't find out what watches exist. Not even your own? >>> At the moment, when post_one_notification() wants to write a notifica= tion >>> into a queue, it calls security_post_notification() to ask if it shou= ld be >>> allowed to do so. This is passed (1) and (3) above plus the notifica= tion >>> record. >> Is "current" (2)? Smack needs (2) for the event delivery access check.= > (2) was current_cred() when watch_sb(), KEYCTL_NOTIFY, etc. was called,= but > isn't necessarily current_cred() at the point post_one_notification() i= s > called. The latter is called at the point the event is generated and > current_cred() is the creds of whatever thread that is called in (which= may be > a work_queue thread if it got deferred). > > At the moment, I'm storing the creds of whoever opened the queue (ie. (= 1)) and > using that, but I could cache the creds of whoever created each watch > (ie. (2)) and pass that to post_one_notification() instead. > > However, it should be noted that (1) is the creds of the buffer owner. How are buffers shared? Who besides the buffer creator can use it? >>> (e) All the points at which we walk over an object in a chain from (= c) to >>> find the watch on which we can effect (d) (eg. we walk rootwards= from a >>> mountpoint to find watches on a branch in the mount topology). >> Smack does not require anything beyond existing checks. > I'm glad to hear that, as this might be sufficiently impractical as to = render > it unusable with Smack. Calling i_op->permissions() a lot would suck. > >>> (y) What checks should be done on object destruction after final put= and >>> what contexts need to be supplied? >> Classically there is no such thing as filesystem object deletion. >> By making it possible to set a watch on that you've inadvertently >> added a security relevant action to the security model. :o > That wasn't my original intention - I intended fsmount(2) to mount dire= ctly as > mount(2) does, but Al had other ideas. > > Now fsmount(2) produces a file descriptor referring to a new mount obje= ct that > can be mounted into by move_mount(2) before being spliced into the moun= t > topology by move_mount(2). However, if the fd is closed before the las= t step, > close() will destroy the mount subtree attached to it (kind of quasi-un= mount). > > That wouldn't be a problem, except that the fd from fsmount(2) can be u= sed > anywhere an O_PATH fd can be used - including watch_mount(2), fchdir(2)= , ... > Further, FMODE_NEED_UNMOUNT gets cleared if the mount is spliced in at = least > once. > > Okay, having tried it you don't get an unmount event (since there's no = actual > unmount), but you do get an event to say that your watch got deleted (i= f the > directory on which the watch was placed got removed from the system). > > So... does the "your watch got deleted" message need checking? In my > opinion, it shouldn't get discarded because then the watcher doesn't kn= ow > their watch went away. Can you glean information from the watch being deleted? I wouldn't think so, and it seems like a one-time event from the system, so I don't think an access check would be required. > > David