From: "Mickaël Salaün" <mic@digikod.net>
To: xiujianfeng <xiujianfeng@huawei.com>,
paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com,
shuah@kernel.org, corbet@lwn.net
Cc: linux-security-module@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-doc@vger.kernel.org, roberto.sassu@huawei.com,
Konstantin Meskhidze <konstantin.meskhidze@huawei.com>,
Linux-Fsdevel <linux-fsdevel@vger.kernel.org>,
Christian Brauner <brauner@kernel.org>
Subject: Re: [PATCH -next v2 0/6] landlock: add chmod and chown support
Date: Wed, 26 Apr 2023 15:58:31 +0200 [thread overview]
Message-ID: <99c0648d-deec-c7e2-a54f-94a7f6a3a50f@digikod.net> (raw)
In-Reply-To: <5fc97b5b-e76f-99c7-7314-6bb16851f66e@huawei.com>
On 24/04/2023 10:52, xiujianfeng wrote:
>
>
> On 2023/4/21 1:40, Mickaël Salaün wrote:
>>
>> On 18/04/2023 12:53, xiujianfeng wrote:
>>> Hi Mickael,
>>>
>>> Sorry about the long silence on this work, As we known this work depends
>>> on another work about changing argument from struct dentry to struct
>>> path for some attr/xattr related lsm hooks, I'm stuck with this thing,
>>> because IMA/EVM is a special security module which is not LSM-based
>>> currently, and severely coupled with the file system. so I am waiting
>>> for Roberto Sassu' work (Move IMA and EVM to the LSM infrastructure) to
>>> be ready, I think it can make my work more easy. you can find
>>> Roberto'work here,
>>> https://lwn.net/ml/linux-kernel/20230303181842.1087717-1-roberto.sassu@huaweicloud.com/
>>>
>>> Any good idea are welcome, thanks.
>>
>> Thanks for the update Xiu.
>>
>> Which part would be needed from Roberto's patch series?
>>
> As we discussed before, the two access rights that need to be added and
> their usage is as below:
> LANDLOCK_ACCESS_FS_WRITE_METADATA controls
> 1.inode_setattr
> 2.inode_setxattr
> 3.inode_removexattr
> 4.inode_set_acl
> 5.inode_remove_acl
> LANDLOCK_ACCESS_FS_READ_METADATA controls
> 1.inode_getattr
> 2.inode_get_acl
> 3.inode_getxattr
> 4.inode_listxattr
>
> all these APIs should be changed to use struct path instead of dentry,
> and then several vfs APIs as follows are invovled:
> notify_change,
> __vfs_setxattr_locked,
> __vfs_removexattr_locked,
> __vfs_setxattr_noperm
> vfs_set_acl
> vfs_remove_acl
> vfs_getxattr
> vfs_listxattr
> vfs_get_acl
> and also include some LSM hooks such as inode_post_setxattr and
> inode_setsecctx.
>
> Since the original places where pass dentry to security_inode_xxx may
> not have any struct path, we have to pass it from the top caller, so
> this also touches lots of filesystems(e.g. cachefiles, ecryptfs, ksmbd,
> nfsd, overlayfs...).
>
> Other LSMs such as selinux, smack can be easy to refator because they
> are LSM-based, and if VFS passes path to security_inode_xxx and they can
> just use path->dentry instead inside they own modules.
>
> AS for IMA/EVM, unfortunately they are not LSM-based and coupled with
> the file system. To make things worse, there is a recursive dependency
> situation during the update of extended attribute which happen as follows:
>
> __vfs_setxattr_noperm
> => security_inode_post_setxattr
> => evm_inode_post_setxattr
> => evm_update_evmxattr
> => __vfs_setxattr_noperm
>
> To change the argument of __vfs_setxattr_noperm from a dentry to the
> path structure, the two EVM functions would have to be altered as well.
> However, evm_update_evmxattr is called by 3 other EVM functions who
> lives in the very heart of the complicated EVM framework. Any change to
> them would cause a nasty chain reaction in EVM and, as IMA would trigger
> EVM directly, in IMA as well.
>
> There is another callchain as follow:
> ima_appraise_measurement
> =>evm_verifyxattr
> =>evm_verifyxattr
> =>evm_verify_hmac
> =>evm_calc_hash
> =>evm_calc_hmac_or_hash
> =>vfs_getxattr
> Passing struct path into vfs_getxattr() would also affect this
> callchain. Currently ima_appraise_measurment accepts a struct file, and
> dentry is generated from file_dentry(file) in order to mitigate a
> deadlock issue involving overlayfs(commit e71b9dff0634ed). Once
> &file->f_path is passed through this callchain, and someone wants the
> dentry, it will be using file->f_path.dentry, which is different from
> file_dentry(file). In the overlayfs scenario, may this cause an issue?
I might be OK, but this need to be tested.
>
> The patchset of moving IMA and EVM into the LSM infrastructe would be
> helpfull but still can not completely resolve this situation. more
> refactor would be needed in EVM. That's all that's happening right now.
OK, thanks for the detailed explanation!
I guess you could start with easier hooks (e.g. inode_getattr and
inode_setattr) to see if there is potentially other implications, and
incrementally build on that.
>
>>
>>>
>>>
>>> On 2022/8/27 19:12, Xiu Jianfeng wrote:
>>>> v2:
>>>> * abstract walk_to_visible_parent() helper
>>>> * chmod and chown rights only take affect on directory's context
>>>> * add testcase for fchmodat/lchown/fchownat
>>>> * fix other review issues
>>>>
>>>> Xiu Jianfeng (6):
>>>> landlock: expand access_mask_t to u32 type
>>>> landlock: abstract walk_to_visible_parent() helper
>>>> landlock: add chmod and chown support
>>>> landlock/selftests: add selftests for chmod and chown
>>>> landlock/samples: add chmod and chown support
>>>> landlock: update chmod and chown support in document
>>>>
>>>> Documentation/userspace-api/landlock.rst | 9 +-
>>>> include/uapi/linux/landlock.h | 10 +-
>>>> samples/landlock/sandboxer.c | 13 +-
>>>> security/landlock/fs.c | 110 ++++++--
>>>> security/landlock/limits.h | 2 +-
>>>> security/landlock/ruleset.h | 2 +-
>>>> security/landlock/syscalls.c | 2 +-
>>>> tools/testing/selftests/landlock/base_test.c | 2 +-
>>>> tools/testing/selftests/landlock/fs_test.c | 267 ++++++++++++++++++-
>>>> 9 files changed, 386 insertions(+), 31 deletions(-)
>>>>
next prev parent reply other threads:[~2023-04-26 13:58 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-27 11:12 [PATCH -next v2 0/6] landlock: add chmod and chown support Xiu Jianfeng
2022-08-27 11:12 ` [PATCH -next v2 1/6] landlock: expand access_mask_t to u32 type Xiu Jianfeng
2022-08-27 11:12 ` [PATCH -next v2 2/6] landlock: abstract walk_to_visible_parent() helper Xiu Jianfeng
2022-08-30 11:22 ` Mickaël Salaün
2022-08-31 11:56 ` xiujianfeng
2022-08-27 11:12 ` [PATCH -next v2 3/6] landlock: add chmod and chown support Xiu Jianfeng
2022-08-27 19:30 ` Günther Noack
2022-08-29 1:17 ` xiujianfeng
2022-08-29 16:01 ` Mickaël Salaün
2022-09-01 13:06 ` xiujianfeng
2022-09-01 17:34 ` Mickaël Salaün
2022-10-29 8:33 ` xiujianfeng
2022-11-14 14:12 ` Mickaël Salaün
2022-11-18 9:03 ` xiujianfeng
2022-11-18 12:32 ` Mickaël Salaün
2022-11-21 13:48 ` xiujianfeng
2022-08-29 6:30 ` xiujianfeng
2022-08-29 6:35 ` xiujianfeng
2022-08-27 11:12 ` [PATCH -next v2 4/6] landlock/selftests: add selftests for chmod and chown Xiu Jianfeng
2022-08-27 17:48 ` Günther Noack
2022-08-29 1:49 ` xiujianfeng
2022-08-27 11:12 ` [PATCH -next v2 5/6] landlock/samples: add chmod and chown support Xiu Jianfeng
2022-08-27 11:12 ` [PATCH -next v2 6/6] landlock: update chmod and chown support in document Xiu Jianfeng
2022-08-27 17:28 ` Günther Noack
2022-08-29 1:52 ` xiujianfeng
2022-08-30 11:22 ` [PATCH -next v2 0/6] landlock: add chmod and chown support Mickaël Salaün
2023-04-18 10:53 ` xiujianfeng
2023-04-20 17:40 ` Mickaël Salaün
2023-04-24 8:52 ` xiujianfeng
2023-04-26 13:58 ` Mickaël Salaün [this message]
2023-05-05 3:50 ` xiujianfeng
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=99c0648d-deec-c7e2-a54f-94a7f6a3a50f@digikod.net \
--to=mic@digikod.net \
--cc=brauner@kernel.org \
--cc=corbet@lwn.net \
--cc=jmorris@namei.org \
--cc=konstantin.meskhidze@huawei.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=paul@paul-moore.com \
--cc=roberto.sassu@huawei.com \
--cc=serge@hallyn.com \
--cc=shuah@kernel.org \
--cc=xiujianfeng@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).