[PATCH v2] fs/ceph/quota: ignore quota with CAP_SYS_RESOURCE

From: Max Kellermann
Date: Wed Sep 11 2024 - 10:25:40 EST


CAP_SYS_RESOURCE allows users to "override disk quota limits". Most
filesystems have a CAP_SYS_RESOURCE check in all quota check code
paths, but Ceph currently does not. This patch implements the
feature.

Signed-off-by: Max Kellermann <max.kellermann@xxxxxxxxx>
---
v1 -> v2: moved capable check to check_quota_exceeded()
---
fs/ceph/quota.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/fs/ceph/quota.c b/fs/ceph/quota.c
index 06ee397e0c3a..c428dc8e8f23 100644
--- a/fs/ceph/quota.c
+++ b/fs/ceph/quota.c
@@ -334,6 +334,9 @@ static bool check_quota_exceeded(struct inode *inode, enum quota_check_op op,
u64 max, rvalue;
bool exceeded = false;

+ if (capable(CAP_SYS_RESOURCE))
+ return false;
+
if (ceph_snap(inode) != CEPH_NOSNAP)
return false;

--
2.45.2