lkml.org 
[lkml]   [2014]   [May]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH -V1 08/22] vfs: Add permission flags for setting file attributes
Date
Dave Chinner <david@fromorbit.com> writes:

> On Sun, Apr 27, 2014 at 09:44:39PM +0530, Aneesh Kumar K.V wrote:
>> From: Andreas Gruenbacher <agruen@kernel.org>
>>
>> Some permission models can allow processes to take ownership of a file,
>> change the file permissions, and set the file timestamps. Introduce new
>> permission mask flags and check for those permissions in
>> inode_change_ok().
>>
>> Signed-off-by: Andreas Gruenbacher <agruen@kernel.org>
>> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
>> ---
>> fs/attr.c | 68 ++++++++++++++++++++++++++++++++++++++++++++----------
>> fs/namei.c | 2 +-
>> include/linux/fs.h | 4 ++++
>> 3 files changed, 61 insertions(+), 13 deletions(-)
>>
>> diff --git a/fs/attr.c b/fs/attr.c
>> index 1d158c972442..e468d4f2dca8 100644
>> --- a/fs/attr.c
>> +++ b/fs/attr.c
>> @@ -16,6 +16,54 @@
>> #include <linux/evm.h>
>> #include <linux/ima.h>
>>
>> +static int richacl_change_ok(struct inode *inode, int mask)
>> +{
>
> acl_change_ok()


Will update.

>
>> + if (!IS_RICHACL(inode))
>> + return -EPERM;
>> +
>> + if (inode->i_op->permission)
>> + return inode->i_op->permission(inode, mask);
>> +
>> + return check_acl(inode, mask);
>> +}
>> +
>> +static bool inode_uid_change_ok(struct inode *inode, kuid_t ia_uid)
>> +{
>> + if (uid_eq(current_fsuid(), inode->i_uid) &&
>> + uid_eq(ia_uid, inode->i_uid))
>> + return true;
>> + if (uid_eq(current_fsuid(), ia_uid) &&
>> + richacl_change_ok(inode, MAY_TAKE_OWNERSHIP) == 0)
>> + return true;
>> + if (capable(CAP_CHOWN))
>> + return true;
>> + return false;
>> +}
>> +
>> +static bool inode_gid_change_ok(struct inode *inode, kgid_t ia_gid)
>> +{
>> + int in_group = in_group_p(ia_gid);
>> + if (uid_eq(current_fsuid(), inode->i_uid) &&
>> + (in_group || gid_eq(ia_gid, inode->i_gid)))
>> + return true;
>> + if (in_group && richacl_change_ok(inode, MAY_TAKE_OWNERSHIP) == 0)
>> + return true;
>> + if (capable(CAP_CHOWN))
>> + return true;
>> + return false;
>> +}
>> +
>> +static bool inode_owner_permitted_or_capable(struct inode *inode, int mask)
>> +{
>> + if (uid_eq(current_fsuid(), inode->i_uid))
>> + return true;
>> + if (richacl_change_ok(inode, mask) == 0)
>> + return true;
>> + if (inode_capable(inode, CAP_FOWNER))
>> + return true;
>> + return false;
>> +}
>
> Some comments on when and why these need to be used instead of
> inode_owner_or_capable() would be useful. I can see people getting
> this wrong in future.
>

Ok.

-aneesh



\
 
 \ /
  Last update: 2014-05-01 18:01    [W:0.243 / U:0.824 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site