From d6a3e06cb0f0db57a2637d029b1ff3bfd1de3d7d Mon Sep 17 00:00:00 2001 From: Wang Shilong Date: Mon, 19 Jul 2021 15:14:43 +0800 Subject: [PATCH] LU-14740 quota: reject invalid project id on server side do sanity check before transfer project ID, reject invalid project id if it comes from some older clients. Test-parameters: trivial testlist=sanity-quota Signed-off-by: Wang Shilong Change-Id: If89e320c7808d188e615f5f0923c2322774b2ceb Reviewed-on: https://review.whamcloud.com/44339 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Hongchao Zhang Reviewed-by: Oleg Drokin --- lustre/osd-ldiskfs/osd_handler.c | 2 ++ lustre/osd-zfs/osd_object.c | 3 +++ 2 files changed, 5 insertions(+) diff --git a/lustre/osd-ldiskfs/osd_handler.c b/lustre/osd-ldiskfs/osd_handler.c index 3b46322..f2fedaa 100644 --- a/lustre/osd-ldiskfs/osd_handler.c +++ b/lustre/osd-ldiskfs/osd_handler.c @@ -3088,6 +3088,8 @@ static int osd_quota_transfer(struct inode *inode, const struct lu_attr *attr, /* Handle project id transfer here properly */ if (attr->la_valid & LA_PROJID && attr->la_projid != i_projid_read(inode)) { + if (!projid_valid(make_kprojid(&init_user_ns, attr->la_projid))) + return -EINVAL; #ifdef HAVE_PROJECT_QUOTA rc = osd_transfer_project(inode, attr->la_projid, handle); #else diff --git a/lustre/osd-zfs/osd_object.c b/lustre/osd-zfs/osd_object.c index 464e0d6..ffec3d3 100644 --- a/lustre/osd-zfs/osd_object.c +++ b/lustre/osd-zfs/osd_object.c @@ -1204,6 +1204,9 @@ static int osd_declare_attr_set(const struct lu_env *env, if (!osd->od_projectused_dn) GOTO(out, rc = -EOPNOTSUPP); + if (!projid_valid(make_kprojid(&init_user_ns, attr->la_projid))) + GOTO(out, rc = -EINVAL); + /* Usually, if project quota is upgradable for the * device, then the upgrade will be done before or when * mount the device. So when we come here, this project -- 1.8.3.1