diff mbox series

fs: apply umask if POSIX ACL support is disabled

Message ID 20230919081900.1096840-1-max.kellermann@ionos.com (mailing list archive)
State New, archived
Headers show
Series fs: apply umask if POSIX ACL support is disabled | expand

Commit Message

Max Kellermann Sept. 19, 2023, 8:18 a.m. UTC
Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
---
 fs/ceph/super.h           | 1 +
 fs/ext2/acl.h             | 1 +
 fs/jfs/jfs_acl.h          | 1 +
 include/linux/posix_acl.h | 1 +
 4 files changed, 4 insertions(+)

Comments

Xiubo Li Sept. 21, 2023, 12:51 a.m. UTC | #1
On 9/19/23 16:18, Max Kellermann wrote:
> Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
> ---
>   fs/ceph/super.h           | 1 +
>   fs/ext2/acl.h             | 1 +
>   fs/jfs/jfs_acl.h          | 1 +
>   include/linux/posix_acl.h | 1 +
>   4 files changed, 4 insertions(+)
>
> diff --git a/fs/ceph/super.h b/fs/ceph/super.h
> index 51c7f2b14f6f..e7e2f264acf4 100644
> --- a/fs/ceph/super.h
> +++ b/fs/ceph/super.h
> @@ -1194,6 +1194,7 @@ static inline void ceph_forget_all_cached_acls(struct inode *inode)
>   static inline int ceph_pre_init_acls(struct inode *dir, umode_t *mode,
>   				     struct ceph_acl_sec_ctx *as_ctx)
>   {
> +	*mode &= ~current_umask();
>   	return 0;
>   }

This LGTM.

Shouldn't we also do this in 'ceph_pre_init_acls()' when we couldn't get 
'acl' from 'posix_acl_create()' ?

Thanks!

- Xiubo


>   static inline void ceph_init_inode_acls(struct inode *inode,
> diff --git a/fs/ext2/acl.h b/fs/ext2/acl.h
> index 4a8443a2b8ec..694af789c614 100644
> --- a/fs/ext2/acl.h
> +++ b/fs/ext2/acl.h
> @@ -67,6 +67,7 @@ extern int ext2_init_acl (struct inode *, struct inode *);
>   
>   static inline int ext2_init_acl (struct inode *inode, struct inode *dir)
>   {
> +	inode->i_mode &= ~current_umask();
>   	return 0;
>   }
>   #endif
> diff --git a/fs/jfs/jfs_acl.h b/fs/jfs/jfs_acl.h
> index f892e54d0fcd..10791e97a46f 100644
> --- a/fs/jfs/jfs_acl.h
> +++ b/fs/jfs/jfs_acl.h
> @@ -17,6 +17,7 @@ int jfs_init_acl(tid_t, struct inode *, struct inode *);
>   static inline int jfs_init_acl(tid_t tid, struct inode *inode,
>   			       struct inode *dir)
>   {
> +	inode->i_mode &= ~current_umask();
>   	return 0;
>   }
>   
> diff --git a/include/linux/posix_acl.h b/include/linux/posix_acl.h
> index 0e65b3d634d9..54bc9b1061ca 100644
> --- a/include/linux/posix_acl.h
> +++ b/include/linux/posix_acl.h
> @@ -128,6 +128,7 @@ static inline void cache_no_acl(struct inode *inode)
>   static inline int posix_acl_create(struct inode *inode, umode_t *mode,
>   		struct posix_acl **default_acl, struct posix_acl **acl)
>   {
> +	*mode &= ~current_umask();
>   	*default_acl = *acl = NULL;
>   	return 0;
>   }
Dave Kleikamp Oct. 3, 2023, 3:32 p.m. UTC | #2
I think this is sane, but the patch needs a description of why this is 
necessary for these specific file systems.

Thanks,
Shaggy

On 9/19/23 3:18AM, Max Kellermann wrote:
> Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
> ---
>   fs/ceph/super.h           | 1 +
>   fs/ext2/acl.h             | 1 +
>   fs/jfs/jfs_acl.h          | 1 +
>   include/linux/posix_acl.h | 1 +
>   4 files changed, 4 insertions(+)
> 
> diff --git a/fs/ceph/super.h b/fs/ceph/super.h
> index 51c7f2b14f6f..e7e2f264acf4 100644
> --- a/fs/ceph/super.h
> +++ b/fs/ceph/super.h
> @@ -1194,6 +1194,7 @@ static inline void ceph_forget_all_cached_acls(struct inode *inode)
>   static inline int ceph_pre_init_acls(struct inode *dir, umode_t *mode,
>   				     struct ceph_acl_sec_ctx *as_ctx)
>   {
> +	*mode &= ~current_umask();
>   	return 0;
>   }
>   static inline void ceph_init_inode_acls(struct inode *inode,
> diff --git a/fs/ext2/acl.h b/fs/ext2/acl.h
> index 4a8443a2b8ec..694af789c614 100644
> --- a/fs/ext2/acl.h
> +++ b/fs/ext2/acl.h
> @@ -67,6 +67,7 @@ extern int ext2_init_acl (struct inode *, struct inode *);
>   
>   static inline int ext2_init_acl (struct inode *inode, struct inode *dir)
>   {
> +	inode->i_mode &= ~current_umask();
>   	return 0;
>   }
>   #endif
> diff --git a/fs/jfs/jfs_acl.h b/fs/jfs/jfs_acl.h
> index f892e54d0fcd..10791e97a46f 100644
> --- a/fs/jfs/jfs_acl.h
> +++ b/fs/jfs/jfs_acl.h
> @@ -17,6 +17,7 @@ int jfs_init_acl(tid_t, struct inode *, struct inode *);
>   static inline int jfs_init_acl(tid_t tid, struct inode *inode,
>   			       struct inode *dir)
>   {
> +	inode->i_mode &= ~current_umask();
>   	return 0;
>   }
>   
> diff --git a/include/linux/posix_acl.h b/include/linux/posix_acl.h
> index 0e65b3d634d9..54bc9b1061ca 100644
> --- a/include/linux/posix_acl.h
> +++ b/include/linux/posix_acl.h
> @@ -128,6 +128,7 @@ static inline void cache_no_acl(struct inode *inode)
>   static inline int posix_acl_create(struct inode *inode, umode_t *mode,
>   		struct posix_acl **default_acl, struct posix_acl **acl)
>   {
> +	*mode &= ~current_umask();
>   	*default_acl = *acl = NULL;
>   	return 0;
>   }
Xiubo Li Oct. 7, 2023, 1:19 a.m. UTC | #3
On 10/3/23 23:32, Dave Kleikamp wrote:
> I think this is sane, but the patch needs a description of why this is 
> necessary for these specific file systems.
>
Sounds reasonable.

Thanks

- Xiubo


> Thanks,
> Shaggy
>
> On 9/19/23 3:18AM, Max Kellermann wrote:
>> Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
>> ---
>>   fs/ceph/super.h           | 1 +
>>   fs/ext2/acl.h             | 1 +
>>   fs/jfs/jfs_acl.h          | 1 +
>>   include/linux/posix_acl.h | 1 +
>>   4 files changed, 4 insertions(+)
>>
>> diff --git a/fs/ceph/super.h b/fs/ceph/super.h
>> index 51c7f2b14f6f..e7e2f264acf4 100644
>> --- a/fs/ceph/super.h
>> +++ b/fs/ceph/super.h
>> @@ -1194,6 +1194,7 @@ static inline void 
>> ceph_forget_all_cached_acls(struct inode *inode)
>>   static inline int ceph_pre_init_acls(struct inode *dir, umode_t *mode,
>>                        struct ceph_acl_sec_ctx *as_ctx)
>>   {
>> +    *mode &= ~current_umask();
>>       return 0;
>>   }
>>   static inline void ceph_init_inode_acls(struct inode *inode,
>> diff --git a/fs/ext2/acl.h b/fs/ext2/acl.h
>> index 4a8443a2b8ec..694af789c614 100644
>> --- a/fs/ext2/acl.h
>> +++ b/fs/ext2/acl.h
>> @@ -67,6 +67,7 @@ extern int ext2_init_acl (struct inode *, struct 
>> inode *);
>>     static inline int ext2_init_acl (struct inode *inode, struct 
>> inode *dir)
>>   {
>> +    inode->i_mode &= ~current_umask();
>>       return 0;
>>   }
>>   #endif
>> diff --git a/fs/jfs/jfs_acl.h b/fs/jfs/jfs_acl.h
>> index f892e54d0fcd..10791e97a46f 100644
>> --- a/fs/jfs/jfs_acl.h
>> +++ b/fs/jfs/jfs_acl.h
>> @@ -17,6 +17,7 @@ int jfs_init_acl(tid_t, struct inode *, struct 
>> inode *);
>>   static inline int jfs_init_acl(tid_t tid, struct inode *inode,
>>                      struct inode *dir)
>>   {
>> +    inode->i_mode &= ~current_umask();
>>       return 0;
>>   }
>>   diff --git a/include/linux/posix_acl.h b/include/linux/posix_acl.h
>> index 0e65b3d634d9..54bc9b1061ca 100644
>> --- a/include/linux/posix_acl.h
>> +++ b/include/linux/posix_acl.h
>> @@ -128,6 +128,7 @@ static inline void cache_no_acl(struct inode *inode)
>>   static inline int posix_acl_create(struct inode *inode, umode_t *mode,
>>           struct posix_acl **default_acl, struct posix_acl **acl)
>>   {
>> +    *mode &= ~current_umask();
>>       *default_acl = *acl = NULL;
>>       return 0;
>>   }
>
Max Kellermann Oct. 9, 2023, 2:45 p.m. UTC | #4
On Tue, Oct 3, 2023 at 5:32 PM Dave Kleikamp <dave.kleikamp@oracle.com> wrote:
> I think this is sane, but the patch needs a description of why this is
> necessary for these specific file systems.

Indeed the patch description was lacking, sorry. I sent v2 with a
better description.

Max
diff mbox series

Patch

diff --git a/fs/ceph/super.h b/fs/ceph/super.h
index 51c7f2b14f6f..e7e2f264acf4 100644
--- a/fs/ceph/super.h
+++ b/fs/ceph/super.h
@@ -1194,6 +1194,7 @@  static inline void ceph_forget_all_cached_acls(struct inode *inode)
 static inline int ceph_pre_init_acls(struct inode *dir, umode_t *mode,
 				     struct ceph_acl_sec_ctx *as_ctx)
 {
+	*mode &= ~current_umask();
 	return 0;
 }
 static inline void ceph_init_inode_acls(struct inode *inode,
diff --git a/fs/ext2/acl.h b/fs/ext2/acl.h
index 4a8443a2b8ec..694af789c614 100644
--- a/fs/ext2/acl.h
+++ b/fs/ext2/acl.h
@@ -67,6 +67,7 @@  extern int ext2_init_acl (struct inode *, struct inode *);
 
 static inline int ext2_init_acl (struct inode *inode, struct inode *dir)
 {
+	inode->i_mode &= ~current_umask();
 	return 0;
 }
 #endif
diff --git a/fs/jfs/jfs_acl.h b/fs/jfs/jfs_acl.h
index f892e54d0fcd..10791e97a46f 100644
--- a/fs/jfs/jfs_acl.h
+++ b/fs/jfs/jfs_acl.h
@@ -17,6 +17,7 @@  int jfs_init_acl(tid_t, struct inode *, struct inode *);
 static inline int jfs_init_acl(tid_t tid, struct inode *inode,
 			       struct inode *dir)
 {
+	inode->i_mode &= ~current_umask();
 	return 0;
 }
 
diff --git a/include/linux/posix_acl.h b/include/linux/posix_acl.h
index 0e65b3d634d9..54bc9b1061ca 100644
--- a/include/linux/posix_acl.h
+++ b/include/linux/posix_acl.h
@@ -128,6 +128,7 @@  static inline void cache_no_acl(struct inode *inode)
 static inline int posix_acl_create(struct inode *inode, umode_t *mode,
 		struct posix_acl **default_acl, struct posix_acl **acl)
 {
+	*mode &= ~current_umask();
 	*default_acl = *acl = NULL;
 	return 0;
 }