-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
client: Clear setuid bits when writing or truncating #12412
Changes from 4 commits
18e3f9c
6b7e39e
8338b94
2d1c91f
03076a6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3740,7 +3740,7 @@ void Server::handle_client_setattr(MDRequestRef& mdr) | |
__u32 access_mask = MAY_WRITE; | ||
|
||
// xlock inode | ||
if (mask & (CEPH_SETATTR_MODE|CEPH_SETATTR_UID|CEPH_SETATTR_GID|CEPH_SETATTR_BTIME)) | ||
if (mask & (CEPH_SETATTR_MODE|CEPH_SETATTR_UID|CEPH_SETATTR_GID|CEPH_SETATTR_BTIME|CEPH_SETATTR_KILL_SGUID)) | ||
xlocks.insert(&cur->authlock); | ||
if (mask & (CEPH_SETATTR_MTIME|CEPH_SETATTR_ATIME|CEPH_SETATTR_SIZE)) | ||
xlocks.insert(&cur->filelock); | ||
|
@@ -3800,7 +3800,7 @@ void Server::handle_client_setattr(MDRequestRef& mdr) | |
|
||
if (mask & CEPH_SETATTR_MODE) | ||
pi->mode = (pi->mode & ~07777) | (req->head.args.setattr.mode & 07777); | ||
else if ((mask & (CEPH_SETATTR_UID|CEPH_SETATTR_GID)) && | ||
else if ((mask & (CEPH_SETATTR_UID|CEPH_SETATTR_GID|CEPH_SETATTR_KILL_SGUID)) && | ||
S_ISREG(pi->mode)) { | ||
pi->mode &= ~S_ISUID; | ||
if ((pi->mode & (S_ISGID|S_IXGRP)) == (S_ISGID|S_IXGRP)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is from the previous set of commits but I guess I didn't ask — why are we unconditionally removing S_ISUID and doing a check before removing S_ISGID? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Having the S_ISGID bit set on a file that does not have the group execute bit is (oddly enough) used to indicate that the file is a candidate for mandatory locking. So you only want to clear that bit if the group execute bit is also set. |
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this is asynchronously sending off an MDS request and then doing the normal write. That does mean under nasty failure conditions we could send off the write, fail to send off the setattr, and then crash...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty sure that's a synchronous call. do_setattr calls make_request, which appears to wait on the reply (like we would for any other setattr). Am I missing something there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...wow, I'm not sure how I got that confused. You're right of course.