linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] fs: Export in_group_or_capable()
@ 2024-06-20  3:23 Youling Tang
  2024-06-20  3:23 ` [PATCH 2/3] f2fs: Use in_group_or_capable() helper Youling Tang
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Youling Tang @ 2024-06-20  3:23 UTC (permalink / raw)
  To: Alexander Viro, Christian Brauner, Jaegeuk Kim, Chao Yu,
	Miklos Szeredi
  Cc: Jan Kara, linux-fsdevel, linux-kernel, linux-f2fs-devel,
	youling.tang, Youling Tang

From: Youling Tang <tangyouling@kylinos.cn>

Export in_group_or_capable() as a VFS helper function.

Signed-off-by: Youling Tang <tangyouling@kylinos.cn>
---
 fs/attr.c          | 2 --
 fs/inode.c         | 1 +
 include/linux/fs.h | 2 ++
 3 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/attr.c b/fs/attr.c
index 960a310581eb..825007d5cda4 100644
--- a/fs/attr.c
+++ b/fs/attr.c
@@ -17,8 +17,6 @@
 #include <linux/filelock.h>
 #include <linux/security.h>
 
-#include "internal.h"
-
 /**
  * setattr_should_drop_sgid - determine whether the setgid bit needs to be
  *                            removed
diff --git a/fs/inode.c b/fs/inode.c
index 3a41f83a4ba5..e0815acc5abb 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -2538,6 +2538,7 @@ bool in_group_or_capable(struct mnt_idmap *idmap,
 		return true;
 	return false;
 }
+EXPORT_SYMBOL(in_group_or_capable);
 
 /**
  * mode_strip_sgid - handle the sgid bit for non-directories
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 0283cf366c2a..c375a4af7b11 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1926,6 +1926,8 @@ void inode_init_owner(struct mnt_idmap *idmap, struct inode *inode,
 extern bool may_open_dev(const struct path *path);
 umode_t mode_strip_sgid(struct mnt_idmap *idmap,
 			const struct inode *dir, umode_t mode);
+bool in_group_or_capable(struct mnt_idmap *idmap,
+			 const struct inode *inode, vfsgid_t vfsgid);
 
 /*
  * This is the "filldir" function type, used by readdir() to let
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/3] f2fs: Use in_group_or_capable() helper
  2024-06-20  3:23 [PATCH 1/3] fs: Export in_group_or_capable() Youling Tang
@ 2024-06-20  3:23 ` Youling Tang
  2024-06-20  3:23 ` [PATCH 3/3] fuse: " Youling Tang
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Youling Tang @ 2024-06-20  3:23 UTC (permalink / raw)
  To: Alexander Viro, Christian Brauner, Jaegeuk Kim, Chao Yu,
	Miklos Szeredi
  Cc: Jan Kara, linux-fsdevel, linux-kernel, linux-f2fs-devel,
	youling.tang, Youling Tang

From: Youling Tang <tangyouling@kylinos.cn>

Use the in_group_or_capable() helper function to simplify the code.

Signed-off-by: Youling Tang <tangyouling@kylinos.cn>
---
 fs/f2fs/acl.c  | 3 +--
 fs/f2fs/file.c | 4 +---
 2 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/fs/f2fs/acl.c b/fs/f2fs/acl.c
index ec2aeccb69a3..8bffdeccdbc3 100644
--- a/fs/f2fs/acl.c
+++ b/fs/f2fs/acl.c
@@ -219,8 +219,7 @@ static int f2fs_acl_update_mode(struct mnt_idmap *idmap,
 		return error;
 	if (error == 0)
 		*acl = NULL;
-	if (!vfsgid_in_group_p(i_gid_into_vfsgid(idmap, inode)) &&
-	    !capable_wrt_inode_uidgid(idmap, inode, CAP_FSETID))
+	if (!in_group_or_capable(idmap, inode, i_gid_into_vfsgid(idmap, inode)))
 		mode &= ~S_ISGID;
 	*mode_p = mode;
 	return 0;
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 5c0b281a70f3..7a23434963d1 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -923,10 +923,8 @@ static void __setattr_copy(struct mnt_idmap *idmap,
 		inode_set_ctime_to_ts(inode, attr->ia_ctime);
 	if (ia_valid & ATTR_MODE) {
 		umode_t mode = attr->ia_mode;
-		vfsgid_t vfsgid = i_gid_into_vfsgid(idmap, inode);
 
-		if (!vfsgid_in_group_p(vfsgid) &&
-		    !capable_wrt_inode_uidgid(idmap, inode, CAP_FSETID))
+		if (!in_group_or_capable(idmap, inode, i_gid_into_vfsgid(idmap, inode)))
 			mode &= ~S_ISGID;
 		set_acl_inode(inode, mode);
 	}
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/3] fuse: Use in_group_or_capable() helper
  2024-06-20  3:23 [PATCH 1/3] fs: Export in_group_or_capable() Youling Tang
  2024-06-20  3:23 ` [PATCH 2/3] f2fs: Use in_group_or_capable() helper Youling Tang
@ 2024-06-20  3:23 ` Youling Tang
  2024-06-20 14:03 ` [PATCH 1/3] fs: Export in_group_or_capable() Christian Brauner
  2024-07-24  2:16 ` [f2fs-dev] " patchwork-bot+f2fs
  3 siblings, 0 replies; 5+ messages in thread
From: Youling Tang @ 2024-06-20  3:23 UTC (permalink / raw)
  To: Alexander Viro, Christian Brauner, Jaegeuk Kim, Chao Yu,
	Miklos Szeredi
  Cc: Jan Kara, linux-fsdevel, linux-kernel, linux-f2fs-devel,
	youling.tang, Youling Tang

From: Youling Tang <tangyouling@kylinos.cn>

Use the in_group_or_capable() helper function to simplify the code.

Signed-off-by: Youling Tang <tangyouling@kylinos.cn>
---
 fs/fuse/acl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/fuse/acl.c b/fs/fuse/acl.c
index 3d192b80a561..04cfd8fee992 100644
--- a/fs/fuse/acl.c
+++ b/fs/fuse/acl.c
@@ -146,8 +146,8 @@ int fuse_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
 		 * be stripped.
 		 */
 		if (fc->posix_acl &&
-		    !vfsgid_in_group_p(i_gid_into_vfsgid(&nop_mnt_idmap, inode)) &&
-		    !capable_wrt_inode_uidgid(&nop_mnt_idmap, inode, CAP_FSETID))
+		    !in_group_or_capable(&nop_mnt_idmap, inode,
+					 i_gid_into_vfsgid(&nop_mnt_idmap, inode)))
 			extra_flags |= FUSE_SETXATTR_ACL_KILL_SGID;
 
 		ret = fuse_setxattr(inode, name, value, size, 0, extra_flags);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/3] fs: Export in_group_or_capable()
  2024-06-20  3:23 [PATCH 1/3] fs: Export in_group_or_capable() Youling Tang
  2024-06-20  3:23 ` [PATCH 2/3] f2fs: Use in_group_or_capable() helper Youling Tang
  2024-06-20  3:23 ` [PATCH 3/3] fuse: " Youling Tang
@ 2024-06-20 14:03 ` Christian Brauner
  2024-07-24  2:16 ` [f2fs-dev] " patchwork-bot+f2fs
  3 siblings, 0 replies; 5+ messages in thread
From: Christian Brauner @ 2024-06-20 14:03 UTC (permalink / raw)
  To: Youling Tang
  Cc: Christian Brauner, Jan Kara, linux-fsdevel, linux-kernel,
	linux-f2fs-devel, Youling Tang, Alexander Viro, Jaegeuk Kim,
	Chao Yu, Miklos Szeredi

On Thu, 20 Jun 2024 11:23:33 +0800, Youling Tang wrote:
> Export in_group_or_capable() as a VFS helper function.
> 
> 

This makes sense to me.

---

Applied to the vfs.misc branch of the vfs/vfs.git tree.
Patches in the vfs.misc branch should appear in linux-next soon.

Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.

It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.

Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs.misc

[1/3] fs: Export in_group_or_capable()
      https://git.kernel.org/vfs/vfs/c/daf0f1ce3585
[2/3] f2fs: Use in_group_or_capable() helper
      https://git.kernel.org/vfs/vfs/c/29a76d8b349b
[3/3] fuse: Use in_group_or_capable() helper
      https://git.kernel.org/vfs/vfs/c/d128e6b878ac

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [f2fs-dev] [PATCH 1/3] fs: Export in_group_or_capable()
  2024-06-20  3:23 [PATCH 1/3] fs: Export in_group_or_capable() Youling Tang
                   ` (2 preceding siblings ...)
  2024-06-20 14:03 ` [PATCH 1/3] fs: Export in_group_or_capable() Christian Brauner
@ 2024-07-24  2:16 ` patchwork-bot+f2fs
  3 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+f2fs @ 2024-07-24  2:16 UTC (permalink / raw)
  To: Youling Tang
  Cc: viro, brauner, jaegeuk, chao, miklos, tangyouling, jack,
	linux-kernel, linux-f2fs-devel, linux-fsdevel

Hello:

This series was applied to jaegeuk/f2fs.git (dev)
by Christian Brauner <brauner@kernel.org>:

On Thu, 20 Jun 2024 11:23:33 +0800 you wrote:
> From: Youling Tang <tangyouling@kylinos.cn>
> 
> Export in_group_or_capable() as a VFS helper function.
> 
> Signed-off-by: Youling Tang <tangyouling@kylinos.cn>
> ---
>  fs/attr.c          | 2 --
>  fs/inode.c         | 1 +
>  include/linux/fs.h | 2 ++
>  3 files changed, 3 insertions(+), 2 deletions(-)

Here is the summary with links:
  - [f2fs-dev,1/3] fs: Export in_group_or_capable()
    https://git.kernel.org/jaegeuk/f2fs/c/9b6a14f08b48
  - [f2fs-dev,2/3] f2fs: Use in_group_or_capable() helper
    https://git.kernel.org/jaegeuk/f2fs/c/8444ee22adb0
  - [f2fs-dev,3/3] fuse: Use in_group_or_capable() helper
    https://git.kernel.org/jaegeuk/f2fs/c/153216cf7bd5

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-07-24  2:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-20  3:23 [PATCH 1/3] fs: Export in_group_or_capable() Youling Tang
2024-06-20  3:23 ` [PATCH 2/3] f2fs: Use in_group_or_capable() helper Youling Tang
2024-06-20  3:23 ` [PATCH 3/3] fuse: " Youling Tang
2024-06-20 14:03 ` [PATCH 1/3] fs: Export in_group_or_capable() Christian Brauner
2024-07-24  2:16 ` [f2fs-dev] " patchwork-bot+f2fs

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).