From: Wang Shilong Date: Mon, 19 Jul 2021 07:14:43 +0000 (+0800) Subject: LU-14740 quota: reject invalid project id on server side X-Git-Tag: 2.14.54~25 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=d6a3e06cb0f0db57a2637d029b1ff3bfd1de3d7d 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 --- 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