ceph: set sec_context xattr on symlink creation
PATCH 1/1 ceph: set sec_context xattr on symlink creation
Symlink inodes should have the security context set in their xattrs on creation. We already set the context on creation, but we don't attach the pagelist. Make it do so.
--- fs/ceph/dir.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/ceph/dir.c +4 -0
@@ -930,6 +930,10 @@ static int ceph_symlink(struct inode *dir, struct dentry *dentry, req->r_num_caps =2 ; req->r_dentry_drop =CEPH_CAP_FILE_SHARED |CEPH_CAP_AUTH_EXCL ; req->r_dentry_unless =CEPH_CAP_FILE_EXCL ; +if (as_ctx.pagelist) { + req->r_pagelist = as_ctx.pagelist; + as_ctx.pagelist =NULL ; + } err =ceph_mdsc_do_request (mdsc, dir, req);if (!err && !req->r_reply_info.head->is_dentry) err =ceph_handle_notrace_create (dir, dentry);
Signature · 1 line
2.26.2
Ilya Dryomov
maintainerQuoted 15 lines · Jeff Layton
Symlink inodes should have the security context set in their xattrs on creation. We already set the context on creation, but we don't attach the pagelist. Make it do so.
Signed-off-by Jeff Layton <[email protected]>--- fs/ceph/dir.c | 4 ++++ 1 file changed, 4 insertions(+)fs/ceph/dir.c +0
-0
fs/ceph/dir.c static int ceph_symlink(struct inode *dir, struct dentry *dentry, · line 939
Quoted 10 lines
fs/ceph/dir.c +4
-0@@ -930,6 +930,10 @@ static int ceph_symlink(struct inode *dir, struct dentry *dentry, req->r_num_caps =2 ; req->r_dentry_drop =CEPH_CAP_FILE_SHARED |CEPH_CAP_AUTH_EXCL ; req->r_dentry_unless =CEPH_CAP_FILE_EXCL ; +if (as_ctx.pagelist) { + req->r_pagelist = as_ctx.pagelist; + as_ctx.pagelist =NULL ; + } err =ceph_mdsc_do_request (mdsc, dir, req);if (!err && !req->r_reply_info.head->is_dentry) err =ceph_handle_notrace_create (dir, dentry);
What is the side effect? Should this go to stable?
Thanks,
Ilya
Quoted 19 lines · Ilya Dryomov
Quoted 18 lines · Jeff Layton
Symlink inodes should have the security context set in their xattrs on creation. We already set the context on creation, but we don't attach the pagelist. Make it do so.
Signed-off-by Jeff Layton <[email protected]>--- fs/ceph/dir.c | 4 ++++ 1 file changed, 4 insertions(+)fs/ceph/dir.c +1
-0@@ -930,6 +930,10 @@ static int ceph_symlink(struct inode *dir, struct dentry *dentry, req->r_num_caps =2 ; req->r_dentry_drop =CEPH_CAP_FILE_SHARED |CEPH_CAP_AUTH_EXCL ; req->r_dentry_unless =CEPH_CAP_FILE_EXCL ; +if (as_ctx.pagelist) {
Quoted 9 lines
fs/ceph/dir.c static int ceph_symlink(struct inode *dir, struct dentry *dentry, · line 939
Quoted 6 lines
fs/ceph/dir.c +3
-0+ req->r_pagelist = as_ctx.pagelist; + as_ctx.pagelist =NULL ; + } err =ceph_mdsc_do_request (mdsc, dir, req);if (!err && !req->r_reply_info.head->is_dentry) err =ceph_handle_notrace_create (dir, dentry);What is the side effect? Should this go to stable?
The effect is that symlink inodes don't get an SELinux context set on them at creation, so they end up unlabeled instead of inheriting the proper context. As to the severity, it really depends on what ends up being unlabeled.
It's probably harmless enough to put this into stable, but I only noticed it by inspection, so I'm not sure it meets the "it must fix a real bug that bothers people" criterion.
Signature · 1 line
Jeff Layton <[email protected]>
Quoted 30 lines · Jeff Layton
Quoted 19 lines · Ilya Dryomov
Quoted 18 lines · Jeff Layton
Symlink inodes should have the security context set in their xattrs on creation. We already set the context on creation, but we don't attach the pagelist. Make it do so.
Signed-off-by Jeff Layton <[email protected]>--- fs/ceph/dir.c | 4 ++++ 1 file changed, 4 insertions(+)fs/ceph/dir.c +1
-0@@ -930,6 +930,10 @@ static int ceph_symlink(struct inode *dir, struct dentry *dentry, req->r_num_caps =2 ; req->r_dentry_drop =CEPH_CAP_FILE_SHARED |CEPH_CAP_AUTH_EXCL ; req->r_dentry_unless =CEPH_CAP_FILE_EXCL ; +if (as_ctx.pagelist) {Quoted 9 lines
fs/ceph/dir.c static int ceph_symlink(struct inode *dir, struct dentry *dentry, · line 939
Quoted 6 lines
fs/ceph/dir.c +3
-0+ req->r_pagelist = as_ctx.pagelist; + as_ctx.pagelist =NULL ; + } err =ceph_mdsc_do_request (mdsc, dir, req);if (!err && !req->r_reply_info.head->is_dentry) err =ceph_handle_notrace_create (dir, dentry);What is the side effect? Should this go to stable?
Quoted 8 lines
The effect is that symlink inodes don't get an SELinux context set on them at creation, so they end up unlabeled instead of inheriting the proper context. As to the severity, it really depends on what ends up being unlabeled.
It's probably harmless enough to put this into stable, but I only noticed it by inspection, so I'm not sure it meets the "it must fix a real bug that bothers people" criterion.
After thinking about it some more, let's do go ahead and mark this for stable. While no one has complained about it, it's a subtle bug that could be problematic once people start populating cephfs trees with unlabeled symlinks. Better that we fix it early before SELinux support becomes even more widespread.
Ilya, can you add the Cc: stable tag before you send a PR to Linus?
Thanks,
Signature · 1 line
Jeff Layton <[email protected]>
Ilya Dryomov
maintainerQuoted 41 lines · Jeff Layton
Quoted 30 lines · Jeff Layton
Quoted 19 lines · Ilya Dryomov
Quoted 18 lines · Jeff Layton
Symlink inodes should have the security context set in their xattrs on creation. We already set the context on creation, but we don't attach the pagelist. Make it do so.
Signed-off-by Jeff Layton <[email protected]>--- fs/ceph/dir.c | 4 ++++ 1 file changed, 4 insertions(+)fs/ceph/dir.c +1
-0@@ -930,6 +930,10 @@ static int ceph_symlink(struct inode *dir, struct dentry *dentry, req->r_num_caps =2 ; req->r_dentry_drop =CEPH_CAP_FILE_SHARED |CEPH_CAP_AUTH_EXCL ; req->r_dentry_unless =CEPH_CAP_FILE_EXCL ; +if (as_ctx.pagelist) {Quoted 9 lines
fs/ceph/dir.c static int ceph_symlink(struct inode *dir, struct dentry *dentry, · line 939
Quoted 6 lines
fs/ceph/dir.c +3
-0+ req->r_pagelist = as_ctx.pagelist; + as_ctx.pagelist =NULL ; + } err =ceph_mdsc_do_request (mdsc, dir, req);if (!err && !req->r_reply_info.head->is_dentry) err =ceph_handle_notrace_create (dir, dentry);What is the side effect? Should this go to stable?
Quoted 8 lines
The effect is that symlink inodes don't get an SELinux context set on them at creation, so they end up unlabeled instead of inheriting the proper context. As to the severity, it really depends on what ends up being unlabeled.
It's probably harmless enough to put this into stable, but I only noticed it by inspection, so I'm not sure it meets the "it must fix a real bug that bothers people" criterion.
Quoted 7 lines
After thinking about it some more, let's do go ahead and mark this for stable. While no one has complained about it, it's a subtle bug that could be problematic once people start populating cephfs trees with unlabeled symlinks. Better that we fix it early before SELinux support becomes even more widespread.
Ilya, can you add the Cc: stable tag before you send a PR to Linus?
Sure, will do.
Thanks,
Ilya